Package com.salesforce.dataloader.model

Examples of com.salesforce.dataloader.model.Row


        return outputRows;
    }

    @Override
    public Row readRow() throws DataAccessObjectException {
        Row row = null;

        if (!dbContext.isOpen()) {
            open();
        }

        String currentColumnName = "";
        try {
            ResultSet rs = dbContext.getDataResultSet();
            if (rs != null && rs.next()) {
                row = new Row(columnNames.size());

                for (String columnName : columnNames) {
                    currentColumnName = columnName;
                    Object value = rs.getObject(columnName);
                    row.put(columnName, value);
                }
                currentRowNumber++;
            }
            return row;
        } catch (SQLException sqe) {
View Full Code Here


            // insert accounts for the whole template or part of it if
            // maxInserts is smaller then template size
            int idx = 0;
            for (Row templateRow : templateRows) {
                final Row row = new Row(templateRow);
                if (listeners != null) {
                    for (TemplateListener l : listeners) {
                        l.updateRow(idx, row);
                    }
                }
View Full Code Here

            DataAccessObjectException {
        final String successFile = ctl.getConfig().getStringRequired(Config.OUTPUT_SUCCESS);
        //final String suceessFule2 = ctl.getConfig().
        assertNumRowsInCSVFile(successFile, numInserts + numUpdates);

        Row row = null;
        CSVFileReader rdr = new CSVFileReader(successFile, getController());
        String updateMsg = UPDATE_MSGS.get(ctl.getConfig().getOperationInfo());
        int insertsFound = 0;
        int updatesFound = 0;
        while ((row = rdr.readRow()) != null) {
            String id = (String)row.get("ID");
            if (emptyId) assertEquals("Expected empty id", "", id);
            else
                assertValidId(id);
            String status = (String)row.get("STATUS");
            if (INSERT_MSG.equals(status))
                insertsFound++;
            else if (updateMsg.equals(status))
                updatesFound++;
            else
View Full Code Here

                // sort the row list so that it comes out in the right order.
                // for the update, the order is reversed.
                Collections.sort(readRowList, new AccountRowComparator(!isInsert));
                logger.info("Verifying database success for next " + (rowsProcessed + readRowList.size()) + " rows");
                for (int i=0; i < readRowList.size(); i++) {
                    Row readRow = readRowList.get(i);
                    assertNotNull("Error reading data row #" + i + ": the row shouldn't be null", readRow);
                    assertTrue("Error reading data row #" + i + ": the row shouldn't be empty", readRow.size() > 0);
                    Row expectedRow = DatabaseTestUtil.getInsertOrUpdateAccountRow(isInsert, rowsProcessed, DatabaseTestUtil.DateType.VALIDATION);
                    // verify all expected data
                    for(String colName : VALIDATE_COLS) {
                        if(validateDates && colName.equals(DateType.DATE)) {
                            verifyCol(DatabaseTestUtil.LAST_UPDATED_COL, readRow, expectedRow);
                        } else {
View Full Code Here

            writer = new DatabaseWriter(theController.getConfig(), dbConfigName, dataSource, sqlConfig);
            writer.open();
            List<Row> accountRowList = new ArrayList<Row>();
            int rowsProcessed = 0;
            for(int i=0; i < numAccounts; i++) {
                Row accountRow = getInsertOrUpdateAccountRow(isInsert, i, dateType, insertNulls);
                accountRowList.add(accountRow);
                if(accountRowList.size() >= 1000 || i == (numAccounts-1)) {
                    rowsProcessed += accountRowList.size();
                    writer.writeRowList(accountRowList);
                    logger.info("Written " + rowsProcessed + " of " + numAccounts + " total accounts using database config: " + dbConfigName);
View Full Code Here

     *            Account sequence in set of generated accounts
     * @param dateType Type for the date field values
     * @return Row containing account data based on seqNum
     */
    public static Row getInsertOrUpdateAccountRow(boolean isInsert, int seqNum, DateType dateType, boolean insertNulls) {
        Row row = new Row();
        String operation;
        int seqInt;
        // external id is the key, use normal sequencing for update so the same set of records gets updated as inserted
        row.put(EXT_ID_COL, "1-" + String.format("%06d", seqNum));
        if(isInsert) {
            // for insert use "forward" sequence number for data
            seqInt = seqNum;
            operation = "insert";
        } else {
            // for update use "reverse" sequence number for data
            seqInt = 999999 - seqNum;
            operation = "update";
        }
        String seqStr = String.format("%06d", seqInt);
        row.put(NAME_COL, "account " + operation + "#" + seqStr); // this is important to get the correct sort order
        row.put(SFDC_ID_COL, "001account_" + seqStr);
        row.put(ACCOUNT_NUMBER_COL, "ACCT" + seqStr);
        if (insertNulls) {
            row.put(PHONE_COL, null);
            row.put(REVENUE_COL, null);
        } else {
            row.put(PHONE_COL, "415-555-" + seqStr);
            row.put(REVENUE_COL, BigDecimal.valueOf(seqInt * 1000));
        }
        Object dateValue;
        Calendar cal = Calendar.getInstance();
        switch(dateType) {
        case STRING:
            DateFormat formatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss'Z'Z");
            formatter.setCalendar(cal);
            dateValue = formatter.format(cal.getTime());
            break;
        case DATE:
            dateValue = cal.getTime();
            break;
        case NULL:
            dateValue = null;
            break;
        case VALIDATION:
            dateValue = new java.sql.Date(cal.getTimeInMillis());
            break;
        case CALENDAR:
        default:
            dateValue = cal;
            break;
        }
        row.put(LAST_UPDATED_COL, dateValue);
        return row;
    }
View Full Code Here

        return rdr;
    }

    private void getFirstRow(Row rowResult, CSVFileReader reader, boolean isSuccessFile, int rowOffset)
            throws Exception {
        Row firstRow = reader.readRow();

        for (int i = 0; i < rowOffset; i++) {
            firstRow = reader.readRow(); // then, for each, move down one row
        }

        if (isSuccessFile) {
            // Also ask for ID
            rowResult.put("ID", firstRow.get("ID"));
        }
        if (firstRow != null && firstRow.get("NAME") != null) {
            rowResult.put("NAME", firstRow.get("NAME"));
        }
    }
View Full Code Here

        for (int i = 0; i < writeHeader.size(); i++) {
            assertEquals(headerRow.get(i), writeHeader.get(i));
        }

        //check that row 1 is valid
        Row firstRow = csv.readRow();
        for (String headerColumn : writeHeader) {
            assertEquals(row1.get(headerColumn), firstRow.get(headerColumn));
        }

        //check that row 2 is valid
        Row secondRow = csv.readRow();
        for (String headerColumn : writeHeader) {
            assertEquals(row2.get(headerColumn), secondRow.get(headerColumn));
        }
        csv.close();
    }
View Full Code Here

    }

    private void getLastRow(Row rowResult, CSVFileReader reader, boolean isSuccessFile)
            throws Exception {

        Row tempRow = new Row();
        Row lastRow = new Row();

        // get to the last row:
        while ((tempRow = reader.readRow()) != null) {
            lastRow = tempRow;
        }

        if (isSuccessFile) {
            // Also ask for ID
            rowResult.put("ID", lastRow.get("ID"));
        }

        rowResult.put("NAME", lastRow.get("NAME"));
    }
View Full Code Here

        final DataReader resultReader = new CSVFileReader(fileName, getController());
        try {
            resultReader.open();

            // go through item by item and assert that it's there
            Row row;
            while ((row = resultReader.readRow()) != null) {
                final String resultId = (String)row.get(Config.ID_COLUMN_NAME);
                assertValidId(resultId);
                if (!expectedIds.remove(resultId)) {
                    unexpectedIds.add(resultId);
                }
            }
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.