private BasicDBObject prepareIdObject(IdSourceKey key) {
return this.prepareIdObject( key.getColumnNames(), key.getColumnValues() );
}
private BasicDBObject prepareIdObject(String[] columnNames, Object[] columnValues) {
BasicDBObject object;
if ( columnNames.length == 1 ) {
object = new BasicDBObject( ID_FIELDNAME, columnValues[0] );
}
else {
object = new BasicDBObject();
DBObject idObject = new BasicDBObject();
for ( int i = 0; i < columnNames.length; i++ ) {
String columnName = columnNames[i];
Object columnValue = columnValues[i];
if ( columnName.contains( PROPERTY_SEPARATOR ) ) {
int dotIndex = columnName.indexOf( PROPERTY_SEPARATOR );
String shortColumnName = columnName.substring( dotIndex + 1 );
idObject.put( shortColumnName, columnValue );
}
else {
idObject.put( columnNames[i], columnValue );
}
}
object.put( ID_FIELDNAME, idObject );
}