Search in sources :

Example 16 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project data-access by pentaho.

the class JoinSelectionDebugGwtServlet method getTableFields.

public List<String> getTableFields(String table, IDatabaseConnection connection) throws Exception {
    DatabaseMeta databaseMeta = this.getDatabaseMeta(connection);
    MultitableDatasourceService service = new MultitableDatasourceService(databaseMeta);
    return service.getTableFields(table, connection);
}
Also used : MultitableDatasourceService(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.MultitableDatasourceService) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 17 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project mondrian by pentaho.

the class Workbench method getDbMeta.

/**
 * Convenience method for retrieving the dbMeta instance that handles
 * required Kettle initialization.
 *
 * @param xml output of {@link DatabaseMeta#getXML()} or <code>null</code>
 * @return the current {@link DatabaseMeta} instance
 */
private DatabaseMeta getDbMeta(String xml) {
    try {
        if (!KettleClientEnvironment.isInitialized()) {
            System.setProperty("KETTLE_PLUGIN_BASE_FOLDERS", KETTLE_PLUGIN_BASE_FOLDERS);
            KettleClientEnvironment.init();
        }
        if (dbMeta != null) {
            return dbMeta;
        }
        if (xml == null) {
            dbMeta = new DatabaseMeta();
        } else {
            dbMeta = new DatabaseMeta(xml);
        }
    } catch (KettleException e) {
        throw new RuntimeException(getResourceConverter().getFormattedString("workbench.new.Kettle.exception", "Kettle failed to initialize."), e);
    }
    return dbMeta;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 18 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-metaverse by pentaho.

the class JobEntryAnalyzerTest method addConnectionNodes.

@Test
public void addConnectionNodes() throws MetaverseAnalyzerException {
    DatabaseMeta[] dbs = new DatabaseMeta[] { mockDatabaseMeta };
    analyzer.jobEntryInterface = mockJobEntryInterface;
    // analyzer.addConnectionNodes( mockDescriptor );
    DatabaseConnectionAnalyzer dbAnalyzer = new JobEntryDatabaseConnectionAnalyzer();
    dbAnalyzer.setMetaverseBuilder(mockBuilder);
    analyzer.setConnectionAnalyzer(dbAnalyzer);
    when(analyzer.getConnectionAnalyzer()).thenReturn(dbAnalyzer);
    when(mockJobEntryInterface.getUsedDatabaseConnections()).thenReturn(dbs);
    analyzer.addConnectionNodes(mockDescriptor);
}
Also used : DatabaseConnectionAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.DatabaseConnectionAnalyzer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 19 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-metaverse by pentaho.

the class DatabaseConnectionAnalyzerTest method testGetUsedConnections.

@Test
public void testGetUsedConnections() throws Exception {
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    when(baseStepMeta.getUsedDatabaseConnections()).thenReturn(new DatabaseMeta[] { dbMeta });
    List<DatabaseMeta> dbMetaList = dbConnectionAnalyzer.getUsedConnections(baseStepMeta);
    assertEquals(1, dbMetaList.size());
    assertEquals(dbMeta, dbMetaList.get(0));
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 20 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-metaverse by pentaho.

the class TableInputExternalResourceConsumer method getResourcesFromMeta.

@Override
public Collection<IExternalResourceInfo> getResourcesFromMeta(TableInputMeta meta, IAnalysisContext context) {
    Set<IExternalResourceInfo> resources = new HashSet<IExternalResourceInfo>();
    DatabaseMeta dbMeta = meta.getDatabaseMeta();
    if (dbMeta != null) {
        IExternalResourceInfo databaseResource = ExternalResourceInfoFactory.createDatabaseResource(dbMeta, true);
        String query = context.equals(DictionaryConst.CONTEXT_RUNTIME) ? meta.getParentStepMeta().getParentTransMeta().environmentSubstitute(meta.getSQL()) : meta.getSQL();
        databaseResource.getAttributes().put(DictionaryConst.PROPERTY_QUERY, query);
        resources.add(databaseResource);
    }
    return resources;
}
Also used : IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) HashSet(java.util.HashSet)

Aggregations

DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)522 Test (org.junit.Test)133 KettleException (org.pentaho.di.core.exception.KettleException)131 Database (org.pentaho.di.core.database.Database)88 MessageBox (org.eclipse.swt.widgets.MessageBox)66 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)63 TransMeta (org.pentaho.di.trans.TransMeta)57 StepMeta (org.pentaho.di.trans.step.StepMeta)54 ArrayList (java.util.ArrayList)53 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)48 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)44 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)42 SlaveServer (org.pentaho.di.cluster.SlaveServer)33 IMetaStore (org.pentaho.metastore.api.IMetaStore)30 ObjectId (org.pentaho.di.repository.ObjectId)29 DatabaseExplorerDialog (org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog)29 JobMeta (org.pentaho.di.job.JobMeta)26 TransHopMeta (org.pentaho.di.trans.TransHopMeta)26 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)24 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)24