@Override public List<Table> getTables() { return delegates.stream() .flatMap(delegate -> delegate.getTables().stream()) .filter(table -> table.getType() != TableType.ALIAS) .collect(Collectors.toList()); }
@Override public List<Table> getTables() { return delegates.stream() .flatMap(delegate -> delegate.getTables().stream()) .filter(table -> table.getType() != TableType.ALIAS) .collect(Collectors.toList()); }
@Override public final List<Table> getTables(final TableType type) { return getTables().stream() .filter(table -> table.getType().equals(type)) .collect(Collectors.toList()); }
@Override public final List<Table> getTables(final TableType type) { return getTables().stream() .filter(table -> table.getType().equals(type)) .collect(Collectors.toList()); }
/** * Creates a SelectItem that references a column from a particular {@link FromItem}, for example a.price or p.age * * @param column * @param fromItem */ public SelectItem(Column column, FromItem fromItem) { this(null, column, fromItem); if (fromItem != null) { Table fromItemTable = fromItem.getTable(); if (fromItemTable != null && fromItemTable.getType() != TableType.ALIAS) { Table columnTable = column.getTable(); if (columnTable != null && !columnTable.equals(fromItemTable)) { throw new IllegalArgumentException("Column's table '" + columnTable.getName() + "' is not equal to referenced table: " + fromItemTable); } } } }
/** * Creates a SelectItem that references a column from a particular {@link FromItem}, for example a.price or p.age * * @param column * @param fromItem */ public SelectItem(Column column, FromItem fromItem) { this(null, column, fromItem); if (fromItem != null) { Table fromItemTable = fromItem.getTable(); if (fromItemTable != null && fromItemTable.getType() != TableType.ALIAS) { Table columnTable = column.getTable(); if (columnTable != null && !columnTable.equals(fromItemTable)) { throw new IllegalArgumentException("Column's table '" + columnTable.getName() + "' is not equal to referenced table: " + fromItemTable); } } } }
public Table convertToTable(final String schemaName, final String tableName) { final Schema schema; if (schemaName == null) { schema = getDefaultSchema(); } else { schema = getSchemaByName(schemaName); } if (schema == null) { throw new IllegalArgumentException( "Schema " + schemaName + " not found. Available schema names are: " + dataContext.getSchemaNames()); } final Table table; if (tableName == null) { if (schema.getTables().stream().filter(t -> t.getType() == TableType.TABLE).count() == 1) { table = schema.getTables().stream().filter(t -> t.getType() == TableType.TABLE).findFirst().get(); } else { throw new IllegalArgumentException( "No table name specified, and multiple options exist. Available table names are: " + schema.getTableNames()); } } else { table = schema.getTableByName(tableName); } if (table == null) { throw new IllegalArgumentException( "Table not found. Available table names are: " + schema.getTableNames()); } return table; }
protected ImmutableTable(Table table, ImmutableSchema schema) { this(table.getName(), table.getType(), schema, table.getRemarks(), table.getQuote()); List<Column> origColumns = table.getColumns(); for (Column column : origColumns) { columns.add(new ImmutableColumn(column, this)); } }
private String getColumnPathQualification(final Datastore datastore, final Collection<InputColumn<?>> sourceColumns) { if (datastore == null || sourceColumns == null || sourceColumns.isEmpty()) { return COLUMN_PATH_QUALIFICATION_FULL; } try (DatastoreConnection connection = datastore.openConnection()) { final SchemaNavigator schemaNavigator = connection.getSchemaNavigator(); final Schema[] schemas = schemaNavigator.getSchemas(); Schema singleSchema = null; int realSchemas = 0; for (final Schema schema : schemas) { if (!MetaModelHelper.isInformationSchema(schema)) { realSchemas++; singleSchema = schema; } } if (realSchemas == 1) { final long tableCount = singleSchema.getTables().stream().filter(t -> t.getType() == TableType.TABLE).count(); if (tableCount == 1L) { return COLUMN_PATH_QUALIFICATION_COLUMN; } return COLUMN_PATH_QUALIFICATION_TABLE; } return COLUMN_PATH_QUALIFICATION_FULL; } }
protected ImmutableTable(Table table, ImmutableSchema schema) { this(table.getName(), table.getType(), schema, table.getRemarks(), table.getQuote()); List<Column> origColumns = table.getColumns(); for (Column column : origColumns) { columns.add(new ImmutableColumn(column, this)); } }
if (table == null && schema.getTables().stream().filter(t -> t.getType() != TableType.ALIAS).count() == 1) { table = schema.getTables().get(0);
if (table == null && schema.getTables().stream().filter(t -> t.getType() != TableType.ALIAS).count() == 1) { table = schema.getTables().get(0);
return false; if (getType() != other.getType()) { return false;
return false; if (getType() != other.getType()) { return false;