* @return true if any value found
* @throws T2DBException
*/
public boolean getAttributeValue(List<Chronicle> chronicles, Attribute<?> attribute) throws T2DBException {
boolean found = false;
Surrogate s = attribute.getProperty().getSurrogate();
Database db = s.getDatabase();
try {
ObjectId[] chrOids = new ObjectId[chronicles.size()];
int offset = 0;
for(Chronicle chronicle : chronicles) {
chrOids[offset++] = getId(chronicle);
}
DBCursor cursor = getMongoDB(db).getAttributes().find(
mongoObject(MongoDatabase.FLD_ATTR_PROP,
getId(s), MongoDatabase.FLD_ATTR_CHRON,
mongoObject(Operator.IN.op(), chrOids)));
offset = Integer.MAX_VALUE;
BasicDBObject objAtOffset = null;
while (cursor.hasNext()) {
BasicDBObject obj = (BasicDBObject) cursor.next();
ObjectId chrOid = obj.getObjectId(MongoDatabase.FLD_ATTR_CHRON);
int offset1 = findOffset(chrOid, chronicles);
if (offset1 < offset) {
offset = offset1;
objAtOffset = obj;
}
if (offset == 0)
break;
}
if (objAtOffset != null) {
ObjectId chrOid = objAtOffset.getObjectId(MongoDatabase.FLD_ATTR_CHRON);
Surrogate chronicle = makeSurrogate(db, DBObjectType.CHRONICLE, chrOid);
check(Permission.READ, chronicle);
attribute.scan(objAtOffset.getString(MongoDatabase.FLD_ATTR_VALUE));
String description = objAtOffset.getString(MongoDatabase.FLD_ATTR_DESC);
if (description.length() > 0)
attribute.setDescription(description);