@Override public List<Table> getTables() { return delegates.stream() .flatMap(delegate -> delegate.getTables().stream()) .filter(table -> table.getType() != TableType.ALIAS) .collect(Collectors.toList()); }
private List<Map<String, Object>> createTableList(Schema schema) { List<Map<String, Object>> tables = new ArrayList<>(); for (Table table : schema.getTables()) { tables.add(createTableMap(table)); } return tables; }
@Override public List<Table> getTables() { return delegates.stream() .flatMap(delegate -> delegate.getTables().stream()) .filter(table -> table.getType() != TableType.ALIAS) .collect(Collectors.toList()); }
@Override protected Void doInBackground() throws Exception { final Schema schema = (Schema) _schemaNode.getUserObject(); final List<Table> tables = schema.getTables(); for (final Table table : tables) { final String name = table.getName(); logger.debug("Publishing table name: {}", name); publish(table); } return null; }
private void addAddTablesToSourceMenuItem(final Schema schema, final JPopupMenu popup) { final JMenuItem addTableItem = WidgetFactory .createMenuItem("Add all schema tables to source", "images/actions/toggle-source-table.png"); addTableItem.addActionListener(e -> { final TableMouseListener tableMouseListener = _tableMouseListenerProvider.get(); final List<Table> tables = schema.getTables(); for (final Table table : tables) { tableMouseListener.addTable(table); } }); popup.add(addTableItem); }
@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 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; }
public void executeBlockingly() { if (!isNeeded()) { return; } final Schema schema = (Schema) _schemaNode.getUserObject(); final List<Table> tables = schema.getTables(); for (final Table table : tables) { final String name = table.getName(); logger.debug("Building table node: {}", name); final DefaultMutableTreeNode tableNode = new DefaultMutableTreeNode(table); final DefaultMutableTreeNode loadingColumnsNode = new DefaultMutableTreeNode(LOADING_COLUMNS_STRING); tableNode.add(loadingColumnsNode); _schemaNode.add(tableNode); } _schemaNode.remove(0); }
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 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); } }
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; } }
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); } }
private JButton createQueryButton(final Datastore datastore) { final JButton queryButton = WidgetFactory.createDefaultButton("Query", IconUtils.MODEL_QUERY); queryButton.setToolTipText("Query datastore"); queryButton.addActionListener(e -> { final String queryString; try (DatastoreConnection connection = datastore.openConnection()) { final List<Table> tables = connection.getSchemaNavigator().getDefaultSchema().getTables(); if (tables.size() > 0) { queryString = "SELECT *\nFROM " + tables.get(0).getQualifiedLabel(); } else { queryString = "SELECT *\nFROM ?"; } } final QueryWindow queryWindow = new QueryWindow(_windowContext, datastore, queryString); queryWindow.open(); }); return queryButton; }
comboBoxList.add(schema); if (!MetaModelHelper.isInformationSchema(schema)) { final List<Table> tables = schema.getTables(); for (final Table table : tables) { try {
private DCPanel createButtonPanel() { final JButton addButton = WidgetFactory.createSmallButton(IconUtils.ACTION_ADD_DARK); addButton.setText("Add table"); addButton.addActionListener(e -> { final String tableName = JOptionPane .showInputDialog(SimpleTableDefsPanel.this, "What is the name of the table", "Add table", JOptionPane.QUESTION_MESSAGE); if (!StringUtils.isNullOrEmpty(tableName)) { final SimpleTableDef tableDef = new SimpleTableDef(tableName, new String[0]); addTableDef(tableDef); } }); final DCPanel buttonPanel; if (_schemaFactory != null) { final JButton autoDetectButton = WidgetFactory.createSmallButton(IconUtils.ACTION_REFRESH); autoDetectButton.setText("Auto-detect tables"); autoDetectButton.addActionListener(e -> { removeAllTableDefs(); final Schema schema = _schemaFactory.createSchema(); final List<Table> tables = schema.getTables(); for (final Table table : tables) { addTableDef(createTableDef(table)); } }); buttonPanel = DCPanel.flow(Alignment.RIGHT, 10, 10, addButton, autoDetectButton); } else { buttonPanel = DCPanel.flow(Alignment.RIGHT, 10, 10, addButton); } return buttonPanel; }
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); } } }
if (columns == null || columns.isEmpty()) { schema = dataContext.getDefaultSchema(); tables = schema.getTables(); } else { tables = Arrays.asList(MetaModelHelper.getTables(columns));
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)) {