formattedTableName).append(" set ");
List<Object> args = new ArrayList<Object>();
boolean bFirstArg = true;
// iterate over key/value pairs
for (int i = 0; i < fsa.size(); i++) {
KeyValuePair kp = (KeyValuePair) fsa.get(i);
String key = kp.getKey();
if (key.equalsIgnoreCase("instance_id")) {
// instance_id is something we 'know' about - set it
document.setInstanceID(kp.getValueLong());
} else if (key.equalsIgnoreCase("instance_key")) {
document.setInstanceKey(kp.getValueString());
} else if (this.docTableCols.containsKey(key)) {
// only attempt to map keys that correspond to valid columns
boolean badArg = false;
// verify that the value matches the datatype
// if valueString not null then assume integer
if (kp.getValueString() != null
&& stringTypes.contains(docTableCols.get(key))) {
args.add(kp.getValueString());
} else if (numericTypes.contains(docTableCols.get(key))) {
args.add(kp.getValueLong());
} else {
// invalid type for argument
badArg = true;
log.warn("document_id: " + documentId
+ ", bad type for key=" + key + ", value="
+ kp.getValueString() == null ? kp.getValueLong()
: kp.getValueString());
}
if (!badArg) {
// update
if (!bFirstArg) {
queryBuilder.append(", ");
}
queryBuilder.append(DBUtil.formatFieldName(key));
queryBuilder.append("=? ");
bFirstArg = false;
}
} else {
// don't know what to do with this key attribute
log.warn("document_id: " + documentId
+ ", could not map key attribute " + kp.getKey());
}
}
if (args.size() > 0) {
// have something to update - add the where condition
queryBuilder.append(" where document_id = ?");