Codota Logo
Datastore.openConnection
Code IndexAdd Codota to your IDE (free)

How to use
openConnection
method
in
org.datacleaner.connection.Datastore

Best Java code snippets using org.datacleaner.connection.Datastore.openConnection (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ArrayList a =
  • Codota Iconnew ArrayList<String>()
  • Codota Iconnew ArrayList()
  • Codota Iconnew ArrayList<Object>()
  • Smart code suggestions by Codota
}
origin: datacleaner/DataCleaner

public AnalysisJobBuilder setDatastore(final Datastore datastore) {
  _datastore = datastore;
  final DatastoreConnection datastoreConnection;
  if (datastore == null) {
    datastoreConnection = null;
  } else {
    datastoreConnection = datastore.openConnection();
  }
  return setDatastoreConnection(datastoreConnection);
}
origin: datacleaner/DataCleaner

@Override
protected UsageAwareDatastoreConnection<DataContext> createDatastoreConnection() {
  final List<DataContext> dataContexts = new ArrayList<>(_datastores.size());
  final List<Closeable> closeables = new ArrayList<>(_datastores.size());
  for (final Datastore datastore : _datastores) {
    final DatastoreConnection con = datastore.openConnection();
    final DataContext dc = con.getDataContext();
    closeables.add(con);
    dataContexts.add(dc);
  }
  final Closeable[] closeablesArray = closeables.toArray(new Closeable[closeables.size()]);
  return new DatastoreConnectionImpl<>(DataContextFactory.createCompositeDataContext(dataContexts), this,
      closeablesArray);
}
origin: datacleaner/DataCleaner

@Override
public Table getPreviewTable(final Datastore datastore) {
  try (DatastoreConnection con = datastore.openConnection()) {
    return con.getSchemaNavigator().convertToTable(_schemaName, _tableName);
  }
}
origin: datacleaner/DataCleaner

private void openConnection(final Datastore datastore) {
  if (_connection != null && _connection.getDatastore() == datastore) {
    return;
  }
  if (_connection != null) {
    _connection.close();
    _connection = null;
  }
  if (datastore != null) {
    try {
      _connection = datastore.openConnection();
    } catch (final Exception e) {
      logger.warn("Could not open connection to datastore: {}", datastore);
    }
  }
}
origin: datacleaner/DataCleaner

@Initialize
public void init() {
  datastoreConnection = datastore.openConnection();
  resetCachedColumns();
  cache.invalidateAll();
  compileLookupQuery();
}
origin: datacleaner/DataCleaner

/**
 * Automatically maps all unmapped paths by looking them up in a datastore.
 *
 * @param schemaNavigator
 */
public void autoMap(final Datastore datastore) {
  setDatastore(datastore);
  try (DatastoreConnection con = datastore.openConnection()) {
    final SchemaNavigator schemaNavigator = con.getSchemaNavigator();
    for (final Entry<String, Column> entry : _map.entrySet()) {
      if (entry.getValue() == null) {
        final String path = entry.getKey();
        final Column column = schemaNavigator.convertToColumn(path);
        entry.setValue(column);
      }
    }
  }
}
origin: datacleaner/DataCleaner

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;
}
origin: datacleaner/DataCleaner

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;
}
origin: datacleaner/DataCleaner

  @Override
  protected RowProcessingQueryOptimizer fetch() {
    final Datastore datastore = getAnalysisJob().getDatastore();
    try (DatastoreConnection con = datastore.openConnection()) {
      final DataContext dataContext = con.getDataContext();
      final Column[] columnArray = _physicalColumns.toArray(new Column[_physicalColumns.size()]);
      final Query baseQuery = dataContext.query().from(getTable()).select(columnArray).toQuery();
      logger.debug("Base query for row processing: {}", baseQuery);
      // try to optimize
      return new RowProcessingQueryOptimizerImpl(datastore, getConsumersSorted(), baseQuery);
    } catch (final RuntimeException e) {
      logger.error("Failed to build query optimizer! {}", e.getMessage(), e);
      throw e;
    }
  }
};
origin: datacleaner/DataCleaner

private DataSet getPreviewData(final String filename) {
  if (!isPreviewDataAvailable()) {
    logger.info("Not displaying preview table because isPreviewDataAvailable() returned false");
    return null;
  }
  final D datastore = getPreviewDatastore(filename);
  try (DatastoreConnection con = datastore.openConnection()) {
    final DataContext dc = con.getDataContext();
    final Table table = getPreviewTable(dc);
    List<Column> columns = table.getColumns();
    if (columns.size() > getPreviewColumns()) {
      // include max 10 columns
      columns = columns.stream().limit(getPreviewColumns()).collect(Collectors.toList());
    }
    final Query q = dc.query().from(table).select(columns).toQuery();
    q.setMaxRows(7);
    return dc.executeQuery(q);
  }
}
origin: datacleaner/DataCleaner

/**
 * Gets the output columns of the lookup query
 *
 * @param checkNames
 *            whether to check/validate/adjust the names of these columns
 * @return
 */
private Column[] getQueryOutputColumns(final boolean checkNames) {
  if (queryOutputColumns == null) {
    try (DatastoreConnection con = datastore.openConnection()) {
      queryOutputColumns = con.getSchemaNavigator().convertToColumns(schemaName, tableName, outputColumns);
    }
  } else if (checkNames) {
    if (!isQueryOutputColumnsUpdated()) {
      queryOutputColumns = null;
      return getQueryOutputColumns(false);
    }
  }
  return queryOutputColumns;
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

@Override
public SchemaIdentifier getDefaultSchema(TenantIdentifier tenant, DatastoreIdentifier datastoreId)
    throws DatastoreConnectionException {
  final TenantContext tenantContext = _tenantContextFactory.getContext(tenant);
  final Datastore datastore = tenantContext.getDatastore(datastoreId);
  if (datastore == null) {
    return null;
  }
  try (final DatastoreConnection con = datastore.openConnection()) {
    final Schema schema = con.getDataContext().getDefaultSchema();
    return new SchemaIdentifier(datastoreId, schema.getName());
  } catch (Exception e) {
    logger.warn("Failed to open connection to datastore: " + datastoreId.getName(), e);
    throw new DatastoreConnectionException(e.getMessage());
  }
}
origin: datacleaner/DataCleaner

  @Override
  public void actionPerformed(final ActionEvent event) {
    final String queryString = _queryTextArea.getText();
    logger.debug("Query being parsed: {}", queryString);
    try (DatastoreConnection con = _datastore.openConnection()) {
      final DataContext dataContext = con.getDataContext();
      final Query q = dataContext.parseQuery(queryString);
      logger.info("Parsed query: {}", q);
      final String limitString = _limitTextField.getText();
      if (!StringUtils.isNullOrEmpty(limitString)) {
        final int limit = Integer.parseInt(limitString);
        q.setMaxRows(limit);
      }
      final DataSet dataSet = dataContext.executeQuery(q);
      _centerPanel.setVisible(true);
      _table.setModel(new DataSetTableModel(dataSet));
    } catch (final MetaModelException e) {
      WidgetUtils.showErrorMessage("Failed to execute query", e.getMessage(), e);
    }
  }
});
origin: datacleaner/DataCleaner

@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);
}
origin: datacleaner/DataCleaner

@Override
public DictionaryConnection openConnection(final DataCleanerConfiguration configuration) {
  final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(_datastoreName);
  if (datastore == null) {
    throw new NoSuchDatastoreException(_datastoreName);
  }
  final DatastoreConnection datastoreConnection = datastore.openConnection();
  if (_loadIntoMemory) {
    final SimpleDictionary simpleDictionary = loadIntoMemory(datastoreConnection);
    // no need for the connection anymore
    datastoreConnection.close();
    return simpleDictionary.openConnection(configuration);
  }
  return new DatastoreDictionaryConnection(this, datastoreConnection);
}
origin: datacleaner/DataCleaner

@Override
public SynonymCatalogConnection openConnection(final DataCleanerConfiguration configuration) {
  final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(_datastoreName);
  if (datastore == null) {
    throw new NoSuchDatastoreException(_datastoreName);
  }
  final DatastoreConnection datastoreConnection = datastore.openConnection();
  if (_loadIntoMemory) {
    final SimpleSynonymCatalog simpleSynonymCatalog = loadIntoMemory(datastoreConnection);
    // no need for the connection anymore
    datastoreConnection.close();
    return simpleSynonymCatalog.openConnection(configuration);
  }
  return new DatastoreSynonymCatalogConnection(this, datastoreConnection);
}
origin: datacleaner/DataCleaner

  /**
   * A main method that will display the results of a few example number
   * analyzers. Useful for tweaking the charts and UI.
   *
   * @param args
   */
  public static void main(final String[] args) throws Exception {
    LookAndFeelManager.get().init();

    final Injector injector =
        Guice.createInjector(new DCModuleImpl(VFSUtils.getFileSystemManager().resolveFile("."), null));

    // run a small job
    final AnalysisJobBuilder ajb = injector.getInstance(AnalysisJobBuilder.class);
    final Datastore ds = injector.getInstance(DatastoreCatalog.class).getDatastore("orderdb");
    final DatastoreConnection con = ds.openConnection();
    final Table table = con.getSchemaNavigator().convertToTable("PUBLIC.CUSTOMERS");
    ajb.setDatastore(ds);
    ajb.addSourceColumns(table.getNumberColumns());
    ajb.addAnalyzer(NumberAnalyzer.class).addInputColumns(ajb.getSourceColumns());

    final ResultWindow resultWindow = injector.getInstance(ResultWindow.class);
    resultWindow.setVisible(true);
    resultWindow.startAnalysis();
  }
}
origin: datacleaner/DataCleaner

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);
    }
  }
}
origin: org.eobjects.datacleaner/DataCleaner-monitor-services

@Override
public List<TableIdentifier> getTables(final TenantIdentifier tenant, final SchemaIdentifier schemaId) {
  final TenantContext tenantContext = _tenantContextFactory.getContext(tenant);
  final Datastore datastore = tenantContext.getDatastore(schemaId.getDatastore());
  if (datastore == null) {
    return null;
  }
  try (final DatastoreConnection con = datastore.openConnection()) {
    final Schema schema = con.getDataContext().getSchemaByName(schemaId.getName());
    final String[] tableNames = schema.getTableNames();
    final List<TableIdentifier> tableIdentifiers = CollectionUtils.map(tableNames,
        new Func<String, TableIdentifier>() {
          @Override
          public TableIdentifier eval(String tableName) {
            return new TableIdentifier(schemaId, tableName);
          }
        });
    return tableIdentifiers;
  }
}
origin: datacleaner/DataCleaner

  public Column resolveForeignColumn(final DatastoreCatalog datastoreCatalog) {
    final Datastore datastore = datastoreCatalog.getDatastore(getForeignDatastoreName());
    if (datastore == null) {
      return null;
    }
    try (DatastoreConnection connection = datastore.openConnection()) {
      final DataContext dataContext = connection.getDataContext();
      final Schema schema = dataContext.getSchemaByName(getForeignSchemaName());
      if (schema == null) {
        return null;
      }
      final Table table = schema.getTableByName(getForeignTableName());
      if (table == null) {
        return null;
      }
      return table.getColumnByName(getForeignColumnName());
    }
  }
}
org.datacleaner.connectionDatastoreopenConnection

Javadoc

Opens up the connection to the datastore. If the datastore is already opened, most times this method will simply share the existing connection.

Popular methods of Datastore

  • getName
  • getDescription
  • getPerformanceCharacteristics
    Gets the performance characteristics of this datastore.
  • setDescription
    Sets the description of the datastore.

Popular in Java

  • Reactive rest calls using spring rest template
  • findViewById (Activity)
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ResourceBundle (java.util)
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Runner (org.openjdk.jmh.runner)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now