private String getJdbcSchemaName(Schema schema) { if (_usesCatalogsAsSchemas) { return null; } else { return schema.getName(); } }
public Update(Schema schema, String tableName) { this(schema.getTableByName(tableName)); }
protected Table getPreviewTable(final DataContext dc) { return dc.getDefaultSchema().getTable(0); }
protected Table getPreviewTable(final DataContext dc) { final Schema schema = dc.getDefaultSchema(); if (schema.getTableCount() == 0) { return null; } return schema.getTable(0); }
public ImmutableSchema(Schema schema) { this(schema.getName(), schema.getQuote()); List<Table> origTables = schema.getTables(); for (Table table : origTables) { tables.add(new ImmutableTable(table, this)); } Collection<Relationship> origRelationships = schema.getRelationships(); for (Relationship relationship : origRelationships) { ImmutableRelationship.create(relationship, this); } }
@Override public TableFromBuilder from(Schema schema, String tableName) { Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return from(table); }
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; }
public void setSchema(final Datastore datastore, final Schema schema) { _panelAroundButton.setVisible(CreateTableDialog.isCreateTableAppropriate(datastore, schema)); final String previousValue = getValue(); _schemaRef.set(schema); _datastoreRef.set(datastore); if (schema == null) { _comboBox.setModel(new DefaultComboBoxModel<>(new Table[1])); } else { final List<Table> tables = new ArrayList<>(schema.getTables()); tables.add(0, null); _comboBox.setModel(new DefaultComboBoxModel<>(tables.toArray(new Table[0]))); if (previousValue == null) { if (schema.getTableCount() == 1) { // if there is only 1 table, select that final Table table = schema.getTable(0); _comboBox.setSelectedItem(table); } } else { // select table by name final Table table = schema.getTableByName(previousValue); _comboBox.setSelectedItem(table); } } }
final Collection<PojoTableType> pojoTables = new ArrayList<PojoTableType>(); Table[] usageTables = schema.getTables(); if (usageTables == null || usageTables.length == 0) { usageTables = dataContext.getDefaultSchema().getTables(); final String schemaName = schema.getName(); for (final Table usageTable : usageTables) { Column[] usageColumns = usageTable.getColumns(); usageColumns = new Column[0]; } else { final Table table = schemaByName.getTableByName(tableName); usageColumns = table.getColumns();
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (obj instanceof Schema) { Schema other = (Schema) obj; EqualsBuilder eb = new EqualsBuilder(); eb.append(getName(), other.getName()); eb.append(getQuote(), other.getQuote()); if (eb.isEquals()) { try { int tableCount1 = getTableCount(); int tableCount2 = other.getTableCount(); eb.append(tableCount1, tableCount2); } catch (Exception e) { // might occur when schemas are disconnected. Omit this // check then. } } return eb.isEquals(); } return false; }
int highestTableCount = -1; for (Schema schema : schemas) { String name = schema.getName(); if (schema != null) { name = name.toLowerCase(); final boolean isInformationSchema = name.startsWith("information") && name.endsWith("schema"); if (!isInformationSchema && schema.getTableCount() > highestTableCount) { highestTableCount = schema.getTableCount(); result = schema;
schema = column.getTable().getSchema(); usageSchema.setName(schema.getName()); String[] tableNames = schema.getTableNames(); for (String tableName : tableNames) { usageSchema.addTable(new MutableTable(tableName).setSchema(usageSchema).setRemarks(
@Override public final String getQualifiedLabel() { StringBuilder sb = new StringBuilder(); Schema schema = getSchema(); if (schema != null && schema.getName() != null) { sb.append(schema.getQualifiedLabel()); sb.append('.'); } sb.append(getName()); return sb.toString(); }
@Override public List<Table> getTables() { return delegates.stream() .flatMap(delegate -> delegate.getTables().stream()) .filter(table -> table.getType() != TableType.ALIAS) .collect(Collectors.toList()); }
@Validate public void validate() { sheetName = sheetName.trim(); if (sheetName.length() > SHEET_NAME_MAX_LENGTH) { throw new IllegalStateException("Sheet name must be maximum " + SHEET_NAME_MAX_LENGTH + " characters long"); } for (final char c : SHEET_NAME_ILLEGAL_CHARS) { if (sheetName.indexOf(c) != -1) { throw new IllegalStateException("Sheet name cannot contain '" + c + "'"); } } if (!overwriteSheetIfExists && file.exists()) { final Datastore datastore = new ExcelDatastore(file.getName(), new FileResource(file), file.getAbsolutePath()); try (DatastoreConnection connection = datastore.openConnection()) { final List<String> tableNames = connection.getDataContext().getDefaultSchema().getTableNames(); for (String tableName : tableNames) { if (tableName.equals(sheetName)) { throw new IllegalStateException( "The sheet '" + sheetName + "' already exists. Please select another sheet name."); } } } } if (!FilenameUtils.isExtension(file.getName(), excelExtension)) { throw new IllegalStateException("Please add the '.xlsx' or '.xls' extension to the filename"); } }
table.getColumns().stream().map(SelectItem::new).collect(Collectors.toList()); final SimpleDataSetHeader header = new SimpleDataSetHeader(columnSelectItems); final List<Table> tables = getDefaultSchema().getTables(); final List<Row> data = new ArrayList<Row>(); if ("tables".equals(tableName)) { for (Relationship r : getDefaultSchema().getRelationships()) { List<Column> primaryColumns = r.getPrimaryColumns(); List<Column> foreignColumns = r.getForeignColumns();
public static Schema wrapIfAppropriate(Schema schema) { if (schema.getTableCount() > 1) { return schema; } else { return new DefaultTableAliasedSchema(schema); } }
@Override public final TableDropBuilder dropTable(Schema schema, String tableName) throws IllegalArgumentException, IllegalStateException, UnsupportedOperationException { final Table table = schema.getTableByName(tableName); if (table == null) { throw new IllegalArgumentException("Nu such table '" + tableName + "' found in schema: " + schema + ". Available tables are: " + Arrays.toString(schema.getTableNames().toArray())); } return dropTable(table); }
private final Column getColumn(final Schema schema, final String tableAndColumnPath) { Table table = null; String columnPath = tableAndColumnPath; final List<String> tableNames = schema.getTableNames(); for (final String tableName : tableNames) { if (tableName != null) { table = schema.getTableByName(tableName); columnPath = tableAndColumnPath.substring(tableName.length()); table = schema.getTableByName(tableName); columnPath = tableAndColumnPath.substring(tableName.length()); if (table == null && schema.getTables().stream().filter(t -> t.getType() != TableType.ALIAS).count() == 1) { table = schema.getTables().get(0);