public Table[] convertToTables(final String[] tableNames) { final Table[] result = new Table[tableNames.length]; for (int i = 0; i < result.length; i++) { result[i] = convertToTable(tableNames[i]); } return result; }
public DatastoreConnectionImpl(final E dataContext, final Datastore datastore, final AutoCloseable... closeables) { super(datastore); _dataContext = dataContext; _schemaNavigator = new SchemaNavigator(dataContext); _closeables = closeables; }
public Column[] convertToColumns(final String[] columnNames) { final Column[] result = new Column[columnNames.length]; for (int i = 0; i < result.length; i++) { result[i] = convertToColumn(columnNames[i]); } return result; }
if (ReflectionUtils.isColumn(type)) { try (DatastoreConnection connection = datastore.openConnection()) { final Column column = connection.getSchemaNavigator().convertToColumn(str); if (column == null) { throw new IllegalArgumentException("Column not found: " + str); final Table table = connection.getSchemaNavigator().convertToTable(str); if (table == null) { throw new IllegalArgumentException("Table not found: " + str); final Schema schema = connection.getSchemaNavigator().convertToSchema(str); if (schema == null) { throw new IllegalArgumentException("Schema not found: " + str);
_targetColumns = schemaNavigator.convertToColumns(schemaName, tableName, columnNames); for (int i = 0; i < _targetColumns.length; i++) { if (_targetColumns[i] == null) { _targetConditionColumns = schemaNavigator.convertToColumns(schemaName, tableName, conditionColumnNames); for (int i = 0; i < _targetConditionColumns.length; i++) { if (_targetConditionColumns[i] == null) {
public void setDatastore(final Datastore datastore) { final String previousValue = getValue(); _datastoreRef.set(datastore); if (datastore == null) { _comboBox.setModel(new DefaultComboBoxModel<>(new Schema[1])); } else { try (DatastoreConnection con = datastore.openConnection()) { Schema[] schemas = con.getSchemaNavigator().getSchemas(); schemas = CollectionUtils.array(new Schema[1], schemas); _comboBox.setModel(new DefaultComboBoxModel<>(schemas)); Schema newValue = null; if (previousValue != null) { newValue = con.getSchemaNavigator().getSchemaByName(previousValue); } if (newValue == null) { newValue = con.getSchemaNavigator().getDefaultSchema(); } _comboBox.setSelectedItem(newValue); } } }
final SchemaNavigator sn = datastoreConnection.getSchemaNavigator(); final Column masterTermColumn = sn.convertToColumn(synonymCatalog.getMasterTermColumnPath()); _masterTermColumnComboBox.setSelectedItem(masterTermColumn); final Column[] synonymColumns = sn.convertToColumns(synonymColumnPaths); _synonymColumnsPanel.setColumns(Arrays.asList(synonymColumns));
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; }
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; }
private void updateTree() { final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); final DefaultMutableTreeNode datastoreNode = new DefaultMutableTreeNode(); rootNode.add(datastoreNode); datastoreNode.setUserObject(_datastoreConnection.getDatastore()); final SchemaNavigator schemaNavigator = _datastoreConnection.getSchemaNavigator(); schemaNavigator.refreshSchemas(); final Schema[] schemas = schemaNavigator.getSchemas(); // make sure that information schemas are arranged at the top Arrays.sort(schemas, new SchemaComparator()); for (final Schema schema : schemas) { final DefaultMutableTreeNode schemaNode = new DefaultMutableTreeNode(schema); schemaNode.add(new DefaultMutableTreeNode(LOADING_TABLES_STRING)); datastoreNode.add(schemaNode); } if (_includeLibraryNode) { final DefaultMutableTreeNode libraryRoot = new DefaultMutableTreeNode(LIBRARY_STRING); createLibrary(libraryRoot); rootNode.add(libraryRoot); } final DefaultTreeModel treeModel = new DefaultTreeModel(rootNode); setModel(treeModel); }
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 Schema[] convertToSchemas(final String[] schemaNames) { final Schema[] result = new Schema[schemaNames.length]; for (int i = 0; i < result.length; i++) { result[i] = convertToSchema(schemaNames[i]); } return result; }
private Column[] getQueryConditionColumns() { if (queryConditionColumns == null) { if (isCarthesianProductMode()) { queryConditionColumns = new Column[0]; } else { try (DatastoreConnection con = datastore.openConnection()) { queryConditionColumns = con.getSchemaNavigator().convertToColumns(schemaName, tableName, conditionColumns); } } } return queryConditionColumns; }
@Override protected void setValue(String value) { final Datastore datastore = _datastoreRef.get(); if (value == null && datastore != null) { try (DatastoreConnection con = datastore.openConnection()) { value = con.getSchemaNavigator().getDefaultSchema().getName(); } } if (getValue() == value) { return; } final Schema schema; if (value == null) { schema = null; } else if (datastore == null) { schema = new MutableSchema(value); } else { try (DatastoreConnection con = datastore.openConnection()) { schema = con.getSchemaNavigator().getSchemaByName(value); } } _comboBox.setEditable(true); _comboBox.setSelectedItem(schema); _comboBox.setEditable(false); }
private void setSchemaTree(final Datastore datastore, final boolean expandTree, final DatastoreConnection con) { if (con != null) { final Schema defaultSchema = con.getSchemaNavigator().getDefaultSchema(); final int datastoreSize = defaultSchema.getTableCount(); if (datastoreSize == 1) { _schemaTreePanel.setDatastore(datastore, true); } else { _schemaTreePanel.setDatastore(datastore, expandTree); } } }
comboBoxList.add(null); final Schema[] schemas = con.getSchemaNavigator().getSchemas(); Arrays.sort(schemas, new SchemaComparator());
public Column[] convertToColumns(final String schemaName, final String tableName, final String[] columnNames) { if (columnNames == null) { return null; } if (columnNames.length == 0) { return new Column[0]; } final Table table = convertToTable(schemaName, tableName); final Column[] columns = new Column[columnNames.length]; for (int i = 0; i < columns.length; i++) { columns[i] = table.getColumnByName(columnNames[i]); } return columns; }
final SchemaNavigator schemaNavigator = con.getSchemaNavigator(); _targetColumns = schemaNavigator.convertToColumns(schemaName, tableName, columnNames); final List<String> columnsNotFound = new ArrayList<>(); for (int i = 0; i < _targetColumns.length; i++) {
public DataSourceDatastoreConnection(final UpdateableDataContext dataContext, final Datastore datastore) { super(datastore); _dataContext = dataContext; _schemaNavigator = new SchemaNavigator(_dataContext); }
public AnalysisJobBuilder addSourceColumns(final String... columnNames) { if (_datastoreConnection == null) { throw new IllegalStateException( "Cannot add source columns by name when no Datastore or DatastoreConnection has been set"); } final SchemaNavigator schemaNavigator = _datastoreConnection.getSchemaNavigator(); final Column[] columns = new Column[columnNames.length]; for (int i = 0; i < columns.length; i++) { final String columnName = columnNames[i]; final Column column = schemaNavigator.convertToColumn(columnName); if (column == null) { throw new IllegalArgumentException("No such column: " + columnName); } columns[i] = column; } return addSourceColumns(columns); }