try {
if (locationCollection != null) {
StringBuffer stringBuffer = new StringBuffer();
Iterator it = locationCollection.iterator();
while (it.hasNext()) {
DDNameValue sourceObject = (DDNameValue) it.next();
// System.out.println("[DEBUG] [AppSettingsEJB]: sourceObject: " +
// sourceObject.toString());
if (sourceObject.getName() != null && sourceObject.getId() == -1) {
// create a new Source Record
cvdl.setSqlQueryToNull();
cvdl.setSqlQuery("INSERT INTO location (title) VALUES (?)");
cvdl.setString(1, sourceObject.getName());
cvdl.executeUpdate();
int newId = cvdl.getAutoGeneratedKey();
stringBuffer.append(newId);
} // end of if statement (sourceObject.getName() != null ...
else if (sourceObject.getName() != null) {
// update the existing Source Record
cvdl.setSqlQueryToNull();
cvdl.setSqlQuery("UPDATE location SET title = ? WHERE locationid = ?");
cvdl.setString(1, sourceObject.getName());
cvdl.setInt(2, sourceObject.getId());
cvdl.executeUpdate();
stringBuffer.append(sourceObject.getId());
} // end of else if statement (sourceObject.getName() != null)
if (stringBuffer.length() > 0 && it.hasNext()) {
stringBuffer.append(", ");
}
} // end of while loop (it.hasNext())