private AttributeDefinition<?> attributeDefinition(Surrogate schemaSurrogate, int seriesNr, Database db, BasicDBObject bo) throws T2DBException {
int number = bo.getInt(MongoDatabase.FLD_ATTRIBDEF_NUM);
boolean era = bo.getBoolean(MongoDatabase.FLD_ATTRIBDEF_ERASING);
AttributeDefinitionImpl<?> def = null;
if (era) {
def = new AttributeDefinitionImpl(seriesNr, number, null, null);
def.edit();
def.setErasing(true);
} else {
ObjectId propId = bo.getObjectId(MongoDatabase.FLD_ATTRIBDEF_PROP);
Surrogate propSurr = makeSurrogate(db, DBObjectType.PROPERTY, new MongoDBObjectId(propId));
Property<?> prop = ((MongoDatabase) db).getReadMethodsForProperty().getProperty(propSurr);
String val = bo.getString(MongoDatabase.FLD_ATTRIBDEF_VAL);
checkIntegrity(prop, propSurr, schemaSurrogate);
def = new AttributeDefinitionImpl(seriesNr, number, prop, prop.getValueType().scan(val));
}
return def;
}