use of com.sforce.async.CSVReader in project components by Talend.
the class SalesforceBulkRuntime method getBatchLog.
/**
* Gets the results of the operation and checks for errors.
*
* @param batchNum
* @return
* @throws AsyncApiException
* @throws IOException
* @throws ConnectionException
*/
public List<BulkResult> getBatchLog(int batchNum) throws AsyncApiException, IOException, ConnectionException {
// batchInfoList was populated when batches were created and submitted
List<BulkResult> resultInfoList = new ArrayList<BulkResult>();
BulkResult resultInfo;
BatchInfo b = batchInfoList.get(batchNum);
CSVReader rdr = new CSVReader(getBatchResultStream(job.getId(), b.getId()));
List<String> resultHeader = rdr.nextRecord();
int resultCols = resultHeader.size();
List<String> row;
while ((row = rdr.nextRecord()) != null) {
resultInfo = new BulkResult();
resultInfo.copyValues(getBaseFileRow());
for (int i = 0; i < resultCols; i++) {
String header = resultHeader.get(i);
resultInfo.setValue(header, row.get(i));
if ("Created".equals(header)) {
resultInfo.setValue("salesforce_created", row.get(i));
} else if ("Id".equals(header)) {
resultInfo.setValue("salesforce_id", row.get(i));
}
}
resultInfoList.add(resultInfo);
}
return resultInfoList;
}
use of com.sforce.async.CSVReader in project tdi-studio-se by Talend.
the class SalesforceBulkAPI method getBatchLog.
public List<Map<String, String>> getBatchLog(int batchNum) throws AsyncApiException, IOException, ConnectionException {
// batchInfoList was populated when batches were created and submitted
List<Map<String, String>> resultInfoList = new ArrayList<Map<String, String>>();
Map<String, String> resultInfo;
BatchInfo b = batchInfoList.get(batchNum);
CSVReader rdr = new CSVReader(connection.getBatchResultStream(job.getId(), b.getId()));
List<String> resultHeader = rdr.nextRecord();
int resultCols = resultHeader.size();
List<String> row;
while ((row = rdr.nextRecord()) != null) {
resultInfo = new HashMap<String, String>();
resultInfo.putAll(getBaseFileRow());
for (int i = 0; i < resultCols; i++) {
resultInfo.put(resultHeader.get(i), row.get(i));
}
resultInfoList.add(resultInfo);
// boolean success = Boolean.valueOf(resultInfo.get("Success"));
// boolean created = Boolean.valueOf(resultInfo.get("Created"));
// String id = resultInfo.get("Id");
// String error = resultInfo.get("Error");
// if (success && created) {
// System.out.println("Created row with id " + id);
// } else if (!success) {
// System.out.println("Failed with error: " + error);
// }
}
return resultInfoList;
}