public static Schema wrapIfAppropriate(Schema schema) { if (schema.getTableCount() > 1) { return schema; } else { return new DefaultTableAliasedSchema(schema); } }
@Override public List<Table> getTables() { List<Table> tables = wrappedSchema.getTables(); // ensure table size is 1 if (tables.size() != 1) { return tables; } // ensure no name clashes if (DEFAULT_TABLE_NAME.equals(tables.get(0).getName())) { return tables; } // ensure mutability if (!(tables instanceof ArrayList)) { tables = new ArrayList<>(tables); } tables.add(createTable(this, tables.get(0))); return tables; }
@Override protected final Schema getSchemaByNameInternal(final String name) throws MetaModelException { final String mainSchemaName = getMainSchemaName(); if (name == null && mainSchemaName != null) { return null; } if (name == null || name.equalsIgnoreCase(mainSchemaName)) { final Schema mainSchema = getMainSchema(); final boolean createAliasTable = singleTableDatastore && Boolean.parseBoolean(System.getProperty(SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS, "true")); if (createAliasTable) { return DefaultTableAliasedSchema.wrapIfAppropriate(mainSchema); } return mainSchema; } else if (name.equals(INFORMATION_SCHEMA_NAME)) { return getInformationSchema(); } logger.warn("Could not find matching schema of name '{}'. Main schema name is: '{}'. Returning null.", name, mainSchemaName); return null; }
@Override public List<Table> getTables() { List<Table> tables = wrappedSchema.getTables(); // ensure table size is 1 if (tables.size() != 1) { return tables; } // ensure no name clashes if (DEFAULT_TABLE_NAME.equals(tables.get(0).getName())) { return tables; } // ensure mutability if (!(tables instanceof ArrayList)) { tables = new ArrayList<>(tables); } tables.add(createTable(this, tables.get(0))); return tables; }
@Override protected final Schema getSchemaByNameInternal(final String name) throws MetaModelException { final String mainSchemaName = getMainSchemaName(); if (name == null && mainSchemaName != null) { return null; } if (name == null || name.equalsIgnoreCase(mainSchemaName)) { final Schema mainSchema = getMainSchema(); final boolean createAliasTable = singleTableDatastore && Boolean.parseBoolean(System.getProperty(SYSTEM_PROPERTY_CREATE_DEFAULT_TABLE_ALIAS, "true")); if (createAliasTable) { return DefaultTableAliasedSchema.wrapIfAppropriate(mainSchema); } return mainSchema; } else if (name.equals(INFORMATION_SCHEMA_NAME)) { return getInformationSchema(); } logger.warn("Could not find matching schema of name '{}'. Main schema name is: '{}'. Returning null.", name, mainSchemaName); return null; }
public static Schema wrapIfAppropriate(Schema schema) { if (schema.getTableCount() > 1) { return schema; } else { return new DefaultTableAliasedSchema(schema); } }