Package com.salesforce.dataloader.dao.csv

Examples of com.salesforce.dataloader.dao.csv.CSVFileWriter


        row.put("OwnerId", userId);
        row.put("Subject", TASK_SUBJECT);
        row.put(nullFieldName, nullFieldValue);
        if (id != null) row.put("Id", id);

        CSVFileWriter writer = null;
        try {
            writer = new CSVFileWriter(CSV_FILE_PATH, getController().getConfig());
            writer.open();
            writer.setColumnNames(new ArrayList<String>(row.keySet()));
            writer.writeRow(row);
        } finally {
            if (writer != null) writer.close();
        }
    }
View Full Code Here


    @Test
    public void testCSVWriteBasic() throws Exception {
        File f = new File(getTestDataDir(), "csvtestTemp.csv");
        String path = f.getAbsolutePath();
        CSVFileWriter writer = new CSVFileWriter(path, getController().getConfig());
        List<Row> rowList = new ArrayList<Row>();

        rowList.add(row1);
        rowList.add(row2);

        writer.open();
        writer.setColumnNames(writeHeader);

        writer.writeRowList(rowList);
        writer.close();

        compareWriterFile(path);

        f.delete();
    }
View Full Code Here

        logger.info(Messages.getFormattedString("DataAccessObjectFactory.creatingDao", new String[] {config.getString(Config.DAO_NAME), daoType}));

        if (CSV_READ_TYPE.equalsIgnoreCase(daoType)) {
            dao = new CSVFileReader(config);
        } else if (CSV_WRITE_TYPE.equalsIgnoreCase(daoType)) {
            dao = new CSVFileWriter(config.getString(Config.DAO_NAME), config);
        } else if (DATABASE_READ_TYPE.equalsIgnoreCase(daoType)) {
            dao = new DatabaseReader(config);
        } else if (DATABASE_WRITE_TYPE.equalsIgnoreCase(daoType)) {
            dao = new DatabaseWriter(config);
        } else {
View Full Code Here

        if (csvFile.exists()) {
            boolean deleteCsvFileOk = csvFile.delete();
            assertTrue("Could not delete existing CSV file: " + CSV_FILE_PATH, deleteCsvFileOk);
        }

        CSVFileWriter writer = null;
        try {
            writer = new CSVFileWriter(CSV_FILE_PATH, getController().getConfig());
            writer.open();
            writer.setColumnNames(new ArrayList<String>(rows[0].keySet()));
            writer.writeRowList(Arrays.asList(rows));
        } finally {
            if (writer != null) {
                writer.close();
            }
        }
    }
View Full Code Here

                }
                inputRows.add(row);
                idx++;
            }
            final String inputPath = new File(getTestDataDir(), inputFileName).getAbsolutePath();
            final CSVFileWriter inputWriter = new CSVFileWriter(inputPath, getController().getConfig());
            try {
                inputWriter.open();
                inputWriter.setColumnNames(templateReader.getColumnNames());
                inputWriter.writeRowList(inputRows);
                return inputPath;
            } finally {
                inputWriter.close();
            }
        } finally {
            templateReader.close();
        }
    }
View Full Code Here

    private DataWriter createErrorWriter() throws DataAccessObjectInitializationException {
        final String filename = getConfig().getString(Config.OUTPUT_ERROR);
        if (filename == null || filename.length() == 0)
            throw new DataAccessObjectInitializationException(getMessage("errorMissingErrorFile"));
        // TODO: Make sure that specific DAO is not mentioned: use DataReader, DataWriter, or DataAccessObject
        return new CSVFileWriter(filename, getConfig());
    }
View Full Code Here

    private DataWriter createSuccesWriter() throws DataAccessObjectInitializationException {
        final String filename = getConfig().getString(Config.OUTPUT_SUCCESS);
        if (filename == null || filename.length() == 0)
            throw new DataAccessObjectInitializationException(getMessage("errorMissingSuccessFile"));
        // TODO: Make sure that specific DAO is not mentioned: use DataReader, DataWriter, or DataAccessObject
        return new CSVFileWriter(filename, getConfig());
    }
View Full Code Here

TOP

Related Classes of com.salesforce.dataloader.dao.csv.CSVFileWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.