public Surrogate findChronicle(SeriesDefinition ss, Schema schema) throws T2DBException {
Surrogate result = null;
DBCursor cursor1 = null;
DBCursor cursor2 = null;
try {
Database db = schema.getDatabase();
cursor1 = getMongoDB(db).getChronicles().find(mongoObject(
MongoDatabase.FLD_CHRON_SCHEMA, getId(schema)));
OUTER: while (cursor1.hasNext()) {
ObjectId chronicleOid = getObjectId((BasicDBObject) cursor1.next());
cursor2 = getMongoDB(db).getSeries().find(mongoObject(
MongoDatabase.FLD_SER_CHRON, chronicleOid,
MongoDatabase.FLD_SER_NUM, ss.getNumber()));
while (cursor2.hasNext()) {
Surrogate entityKey = makeSurrogate(db, DBObjectType.CHRONICLE, chronicleOid);
Schema s = db.getChronicle(entityKey).getSchema(true);
if (s.dependsOnSchema(schema)) {
result = entityKey;
break OUTER;
}
}