if (schemaName == null)
schemaName = Schemas.getNewTableSchema((JDBCConfiguration)
repos.getConfiguration());
// if no given and adapting or defaulting missing info, use template
SchemaGroup group = repos.getSchemaGroup();
Schema schema = null;
if (given == null) {
schema = group.getSchema(schemaName);
if (schema == null)
schema = group.addSchema(schemaName);
given = def.get(schema);
}
String fullName;
String sep = repos.getDBDictionary().catalogSeparator;
int dotIdx = given.lastIndexOf(sep);
if (dotIdx == -1)
fullName = (schemaName == null) ? given : schemaName + sep + given;
else {
fullName = given;
schema = null;
schemaName = given.substring(0, dotIdx);
given = given.substring(dotIdx + 1);
}
// 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(fullName);
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;