schemaName = Schemas.getNewTableSchemaIdentifier((JDBCConfiguration)
repos.getConfiguration());
// if no given and adapting or defaulting missing info, use template
SchemaGroup group = repos.getSchemaGroup();
Schema schema = null;
if (DBIdentifier.isNull(given)) {
schema = group.getSchema(schemaName);
if (schema == null)
schema = group.addSchema(schemaName);
given = def.getIdentifier(schema);
}
QualifiedDBIdentifier path = QualifiedDBIdentifier.getPath(given);
if (DBIdentifier.isNull(path.getSchemaName())) {
if (!DBIdentifier.isNull(schemaName)) {
path.setSchemaName(schemaName);
}
} else {
schemaName = path.getSchemaName();
schema = null;
}
// look for named table using full name and findTable, which allows
// the dynamic schema factory to create the table if needed
Table table = group.findTable(path);
if (table != null)
return table;
if (!adapt)
throw new MetaDataException(_loc.get("bad-table", given, context));
// named table doesn't exist; create it
if (schema == null) {
schema = group.getSchema(schemaName);
if (schema == null)
schema = group.addSchema(schemaName);
}
table = schema.getTable(given);
if (table == null)
table = schema.addTable(given);
return table;
}