@Override
    public void serializeKAM(final String kamName, String filePath)
            throws PKAMSerializationFailure {
        if (nulls(kamName, filePath)) {
            throw new InvalidArgument("argument(s) were null");
        }

        final SystemConfiguration cfg =
                SystemConfiguration.getSystemConfiguration();

        KamInfo kamInfo = loadKAMInfo(kamName, filePath, cfg);

        PKAMWriter pkw = null;
        CSVWriter tabbedWriter = null;
        KAMExportDAO kdao = null;
        try {
            pkw = new PKAMWriter(filePath);
            tabbedWriter = new CSVWriter(pkw, FIELD_SEPARATOR,
                    CSVParser.DEFAULT_QUOTE_CHARACTER,
                    CSVParser.DEFAULT_ESCAPE_CHARACTER);

            final DBConnection kcc = createKAMConnection(kamName, cfg);
            kdao = new KAMExportDAO(kcc, kamInfo.getSchemaName());
            for (KAMStoreTables1_0 kamTable : KAMStoreTables1_0.values()) {
                tabbedWriter.writeNext(new String[] { "["
                        + kamTable.getTableName() + "]" });

                // write out column headers
                // tabbedWriter.writeNext(kamTable.getOtherColumnNames());

                // query all rows for the current kam table
                List<String[]> allRows = kdao.getAllRowsForTable(kamTable);

                // write data as tsv if there is any
                if (hasItems(allRows)) {
                    for (String[] row : allRows) {
                        tabbedWriter.writeNext(row);
                    }
                }
            }
        } catch (IOException e) {
            throw new PKAMSerializationFailure(kamName, e.getMessage());
        } catch (SQLException e) {
            throw new PKAMSerializationFailure(kamName, e.getMessage());
        } finally {
            // close tabbed-data writer
            if (tabbedWriter != null) {
                try {
                    tabbedWriter.close();
                } catch (IOException e1) {}
            }

            // close kam catalog connection
            if (kdao != null) {
                kdao.terminate();
            }
        }
    }
@ Override public void serializeKAM ( final String kamName , String filePath ) throws PKAMSerializationFailure { if ( nulls ( kamName , filePath ) ) { throw new InvalidArgument ( "argument(s) were null" ) ; } final SystemConfiguration cfg = SystemConfiguration . getSystemConfiguration ( ) ; KamInfo kamInfo = loadKAMInfo ( kamName , filePath , cfg ) ; PKAMWriter pkw = null ; CSVWriter tabbedWriter = null ; KAMExportDAO kdao = null ; try { pkw = new PKAMWriter ( filePath ) ; tabbedWriter = new CSVWriter ( pkw , FIELD_SEPARATOR , CSVParser . DEFAULT_QUOTE_CHARACTER , CSVParser . DEFAULT_ESCAPE_CHARACTER ) ; final DBConnection kcc = createKAMConnection ( kamName , cfg ) ; kdao = new KAMExportDAO ( kcc , kamInfo . getSchemaName ( ) ) ; for ( KAMStoreTables1_0 kamTable : KAMStoreTables1_0 . values ( ) ) { tabbedWriter . writeNext ( new String [ ] { "[" + kamTable . getTableName ( ) + "]" } ) ; List < String [ ] > allRows = kdao . getAllRowsForTable ( kamTable ) ; if ( hasItems ( allRows ) ) { for ( String [ ] row : allRows ) { tabbedWriter . writeNext ( row ) ; } } } } catch ( IOException e ) { throw new PKAMSerializationFailure ( kamName , e . getMessage ( ) ) ; } catch ( SQLException e ) { throw new PKAMSerializationFailure ( kamName , e . getMessage ( ) ) ; } finally { if ( tabbedWriter != null ) { try { tabbedWriter . close ( ) ; } catch ( IOException e1 ) { } } if ( kdao != null ) { kdao . terminate ( ) ; } } }
{@inheritDoc}