@Provides public AnalysisJobBuilder getAnalysisJobBuilder(final DataCleanerConfiguration configuration) { AnalysisJobBuilder ajb = _analysisJobBuilderRef.get(); if (ajb == null && _analysisJobBuilderRef instanceof MutableRef) { ajb = new AnalysisJobBuilder(configuration); final MutableRef<AnalysisJobBuilder> ref = (MutableRef<AnalysisJobBuilder>) _analysisJobBuilderRef; ref.set(ajb); } return ajb; }
public void setTable(final Table table) { _tableRef.set(table); for (final SourceColumnComboBox comboBox : _comboBoxes) { comboBox.setModel(table); } }
public void setTable(final Table table) { if (table != _tableRef.get()) { _tableRef.set(table); updateMappedColumns(); } }
private List<String> buildJarFiles(final MutableRef<String> primaryJarRef) throws IOException { final List<String> list = new ArrayList<>(); final Path directoryPath = new Path(_jarDirectoryPath); final RemoteIterator<LocatedFileStatus> files = _fileSystem.listFiles(directoryPath, false); while (files.hasNext()) { final LocatedFileStatus file = files.next(); final Path path = file.getPath(); final String filename = path.getName(); boolean primaryJar = false; for (final String prefix : PRIMARY_JAR_FILENAME_PREFIXES) { if (filename.startsWith(prefix)) { primaryJarRef.set(path.toString()); primaryJar = true; break; } } if (!primaryJar) { list.add(path.toString()); } } if (primaryJarRef.get() == null) { throw new IllegalArgumentException( "Failed to find primary jar (starting with '" + PRIMARY_JAR_FILENAME_PREFIXES[0] + "') in JAR file directory: " + _jarDirectoryPath); } return list; }
/** * Sets the table to use as a source for the available columns in the * combobox. * * @param table */ public void setTable(final Table table) { if (table != _tableRef.get()) { _tableRef.set(table); if (table == null) { _comboBox.setEmptyModel(); } else { _comboBox.setModel(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); } } }
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); } } }
private static Table getTable(final UpdateableDataContext dataContext, final String sheetName, final String[] columnNames) { final Schema schema = dataContext.getDefaultSchema(); Table table = schema.getTableByName(sheetName); if (table == null) { final MutableRef<Table> tableRef = new MutableRef<>(); dataContext.executeUpdate(callback -> { final TableCreationBuilder tableBuilder = callback.createTable(schema, sheetName); for (final String columnName : columnNames) { tableBuilder.withColumn(columnName); } tableRef.set(tableBuilder.execute()); }); table = tableRef.get(); } return table; }