if (cycleDetector == null)
cycleDetector = new LinkedHashSet<Integer>();
if (cycleDetector.contains(rawSchema.getId()))
throw T2DBJMsg.exception(J.J30115, rawSchema.getId(), cycleDetector.toString());
cycleDetector.add(rawSchema.getId());
UpdatableSchemaImpl schema = null;
String name = rawSchema.getName();
UpdatableSchema base = null;
if (rawSchema.getParent() > 0) {
Surrogate parentKey = makeSurrogate(database, DBObjectType.SCHEMA, rawSchema.getParent());
RawSchema brs = getRawSchema(parentKey);
if (brs == null)
throw T2DBJMsg.exception(J.J30116, rawSchema.getParent(), name);
base = getSchema(database, brs, cycleDetector);
}
Surrogate surrogate = makeSurrogate(database, DBObjectType.SCHEMA, rawSchema.getId());
RawSchemaComponents rscs = getRawSchemaComponents(surrogate);
if (rscs != null) {
Collection<AttributeDefinition<?>> attributeDefs = makeAttributeDefinitions(database, rscs.attributes);
Collection<SeriesDefinition> seriesDefinitions = makeSeriesSchemas(database, rscs.series);
schema = new UpdatableSchemaImpl(name, base, attributeDefs, seriesDefinitions, surrogate);
} else
schema = new UpdatableSchemaImpl(name, base, null, null, surrogate);
return schema;
}