* 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;
}