Package com.salesforce.dataloader.model

Examples of com.salesforce.dataloader.model.Row


     */
    private void updateCSVTable(CSVFileReader csvReader) {

        List<List<Object>> rowList = new LinkedList<List<Object>>();
        for (int i = 0; i < numberOfRows; i++) {
            Row rowMap;
            try {
                rowMap = csvReader.readRow();
            } catch (DataAccessObjectException e) {
                break;
            }
            if (!DAORowUtil.isValidRow(rowMap)) {
                break;
            }

            List<String> columns = csvReader.getColumnNames();
            List<Object> row = new ArrayList<Object>();
            row.add(0, String.valueOf(i + 1));
            for(String column : columns) {
                row.add(rowMap.get(column));
            }
            rowList.add(row);
        }
        csvReader.close();
        csvTblViewer.setInput(rowList);
View Full Code Here


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

        Row row = new Row();
        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

    @Override
    public List<Row> readRowList(int maxRows) throws DataAccessObjectException {
        List<Row> outputRows = new ArrayList<Row>();
        for (int i = 0; i < maxRows; i++) {
            Row outputRow = readRow();
            if (outputRow != null) {
                // if row has been returned, add it to the output
                outputRows.add(outputRow);
            } else {
                // if encountered null, the reading is over
View Full Code Here

            String errMsg = Messages.getFormattedString("CSVFileDAO.errorRowTooLarge", new String[]{
                    String.valueOf(currentRowNumber), String.valueOf(record.size()), String.valueOf(headerRow.size())});
            throw new DataAccessRowException(errMsg);
        }

        Row row = new Row(record.size());

        for (int i = 0; i < headerRow.size(); i++) {
            String value = record.get(i);
            if (value == null) {
                value = "";
            }
            row.put(headerRow.get(i), value);
        }
        currentRowNumber++;
        return row;
    }
View Full Code Here

        writeHeader = new ArrayList<String>(3);
        writeHeader.add("COL1");
        writeHeader.add("COL2");
        writeHeader.add("COL3");

        row1 = new Row();
        row1.put("COL1", "row1col1");
        row1.put("COL2", "row1col2");
        row1.put("COL3", "row1col3");

        row2 = new Row();
        row2.put("COL1", "row2col1");
        row2.put("COL2", "row2col2");
        row2.put("COL3", "row2col3");
    }
View Full Code Here

        List<String> headerRow = csv.getColumnNames();
        assertEquals(COLUMN_1_NAME, headerRow.get(0));
        assertEquals(COLUMN_2_NAME, headerRow.get(1));
        assertEquals(COLUMN_3_NAME, headerRow.get(2));

        Row firstRow = csv.readRow();
        assertEquals("row1-1", firstRow.get(COLUMN_1_NAME));
        assertEquals("row1-2", firstRow.get(COLUMN_2_NAME));
        assertEquals("row1-3", firstRow.get(COLUMN_3_NAME));

        Row secondRow = csv.readRow();
        assertEquals("row2-1", secondRow.get(COLUMN_1_NAME));
        assertEquals("row2-2", secondRow.get(COLUMN_2_NAME));
        assertEquals("row2-3", secondRow.get(COLUMN_3_NAME));

        csv.close();
    }
View Full Code Here

        assertTrue(f.canRead());

        CSVFileReader csv = new CSVFileReader(f, getController().getConfig());
        csv.open();

        Row firstRow = csv.readRow();
        assertEquals("\"The Best\" Account", firstRow.get(COLUMN_1_NAME));

        Row secondRow = csv.readRow();
        assertEquals("The \"Best\" Account", secondRow.get(COLUMN_1_NAME));

        csv.close();
    }
View Full Code Here

            assertEquals("Number of lines between input and output do not match", numberOfInputRows,
                    numberOfSuccessRows + numberOfErrorRows + numberOfOffsetRows);
        }

        // Initializations of row results
        Row firstInputOffsetAdjustedRow = new Row();
        Row lastInputRow = new Row();
        Row firstSuccessRow = new Row();
        Row lastSuccessRow = new Row();
        Row firstErrorRow = new Row();
        Row lastErrorRow = new Row();

        // The next few if statements deal with the edge statements on file size...(i.e. suppose that there are no
        // errors)
        if (numberOfSuccessRows > 0) {
            getFirstRow(firstSuccessRow, successFileReader, true, 0);
            getLastRow(lastSuccessRow, successFileReader, true);
        }

        if (numberOfErrorRows > 0) {
            getFirstRow(firstErrorRow, errorFileReader, false, 0);
            getLastRow(lastErrorRow, errorFileReader, false);
        }

        if (numberOfInputRows > 0) {
            final CSVFileReader inputFileReader = openConfiguredPath(cfg, Config.DAO_NAME);

            getFirstRow(firstInputOffsetAdjustedRow, inputFileReader, false, numberOfOffsetRows);
            getLastRow(lastInputRow, inputFileReader, false);
        }

        // Requirement I: First offset-adjusted row of input matches to either the error or success file's first row
        if (numberOfSuccessRows > 0 || numberOfErrorRows > 0) {
            assertTrue(firstInputOffsetAdjustedRow.get("NAME").equals(firstSuccessRow.get("NAME"))
                    || firstInputOffsetAdjustedRow.get("NAME").equals(firstErrorRow.get("NAME")));

            // Requirement II: Last input row matches to either the error or success file's last row
            assertTrue(lastInputRow.get("NAME").equals(lastSuccessRow.get("NAME"))
                    || lastInputRow.get("NAME").equals(lastErrorRow.get("NAME")));
        } //otherwise vacuously true
    }
View Full Code Here

    private static Row invalidRow;
    private Map<String, String> argMap;

    @BeforeClass
    public static void setUpData() {
        validRow = new Row();
        validRow.put("Subject", TASK_SUBJECT);
        validRow.put("ReminderDateTime", "");

        invalidRow = new Row();
        invalidRow.put("Subject", TASK_SUBJECT);
        invalidRow.put("ReminderDateTime", "NULL"); // this makes date conversion fail
    }
View Full Code Here

     */
    @Override
    public List<Row> readRowList(int maxRows) throws DataAccessObjectException {
        List<Row> outputRows = new ArrayList<Row>();
        for(int i=0; i < maxRows; i++) {
            Row outputRow = readRow();
            if(outputRow != null) {
                // if row has been returned, add it to the output
                outputRows.add(outputRow);
            } else {
                // if encountered null, the reading is over
View Full Code Here

TOP

Related Classes of com.salesforce.dataloader.model.Row

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.