use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-kettle by pentaho.
the class DatabaseLogExceptionFactory method extractDatabase.
private static DatabaseInterfaceExtended extractDatabase(LogTableCoreInterface table) {
DatabaseInterfaceExtended result = null;
if (table != null && table.getDatabaseMeta() != null) {
DatabaseInterface databaseInterface = table.getDatabaseMeta().getDatabaseInterface();
result = databaseInterface instanceof DatabaseInterfaceExtended ? (DatabaseInterfaceExtended) databaseInterface : null;
}
return result;
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-metaverse by pentaho.
the class TableInputExternalResourceConsumerTest method setUp.
@Before
public void setUp() throws Exception {
consumer = spy(new TableInputExternalResourceConsumer());
DatabaseInterface dbi = mock(DatabaseInterface.class);
when(dbMeta.getDatabaseInterface()).thenReturn(dbi);
when(dbi.getPluginId()).thenReturn("JNDI");
when(dbMeta.getAccessTypeDesc()).thenReturn("JNDI");
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-metaverse by pentaho.
the class TableOutputExternalResourceConsumerTest method testGetResourcesFromMeta_static.
@Test
public void testGetResourcesFromMeta_static() throws Exception {
TableOutputMeta meta = mock(TableOutputMeta.class);
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
DatabaseInterface dbi = mock(DatabaseInterface.class);
when(meta.getDatabaseMeta()).thenReturn(dbMeta);
when(meta.getTableName()).thenReturn("tableName");
when(meta.getSchemaName()).thenReturn("schemaName");
when(meta.getParentStepMeta()).thenReturn(parentStepMeta);
when(parentStepMeta.getParentTransMeta()).thenReturn(parentTransMeta);
when(parentTransMeta.environmentSubstitute("tableName")).thenReturn("tableName");
when(parentTransMeta.environmentSubstitute("schemaName")).thenReturn("schemaName");
when(dbMeta.getAccessTypeDesc()).thenReturn("JNDI");
when(dbMeta.getName()).thenReturn("TestConnection");
when(dbMeta.getDescription()).thenReturn("my conn description");
when(dbMeta.getDatabaseInterface()).thenReturn(dbi);
when(dbi.getPluginId()).thenReturn("POSTGRESQL");
Collection<IExternalResourceInfo> resources = consumer.getResourcesFromMeta(meta, new AnalysisContext(DictionaryConst.CONTEXT_STATIC));
assertEquals(1, resources.size());
IExternalResourceInfo res = resources.iterator().next();
assertEquals("TestConnection", res.getName());
assertEquals("tableName", res.getAttributes().get(DictionaryConst.PROPERTY_TABLE));
assertEquals("schemaName", res.getAttributes().get(DictionaryConst.PROPERTY_SCHEMA));
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-metaverse by pentaho.
the class DatabaseConnectionAnalyzer method analyze.
/**
* Analyzes a database connection for metadata.
*
* @param dbMeta the object
* @see IAnalyzer#analyze(IComponentDescriptor, java.lang.Object)
*/
@Override
public IMetaverseNode analyze(IComponentDescriptor descriptor, DatabaseMeta dbMeta) throws MetaverseAnalyzerException {
if (dbMeta == null) {
throw new MetaverseAnalyzerException(Messages.getString("ERROR.DatabaseMeta.IsNull"));
}
if (metaverseObjectFactory == null) {
throw new MetaverseAnalyzerException(Messages.getString("ERROR.MetaverseObjectFactory.IsNull"));
}
if (metaverseBuilder == null) {
throw new MetaverseAnalyzerException(Messages.getString("ERROR.MetaverseBuilder.IsNull"));
}
IMetaverseNode node = createNodeFromDescriptor(descriptor);
node.setType(DictionaryConst.NODE_TYPE_DATASOURCE);
int accessType = dbMeta.getAccessType();
node.setProperty("accessType", accessType);
String accessTypeDesc = dbMeta.getAccessTypeDesc();
node.setProperty("accessTypeDesc", accessTypeDesc);
String databaseName = dbMeta.getDatabaseName();
node.setProperty("databaseName", databaseName);
node.setProperty("name", dbMeta.getName());
DatabaseInterface dbInterface = dbMeta.getDatabaseInterface();
node.setProperty("databaseType", dbInterface != null ? Const.NVL(dbInterface.getPluginName(), "Unknown") : "Unknown");
String port = dbMeta.getDatabasePortNumberString();
node.setProperty(DictionaryConst.PROPERTY_PORT, port);
String host = dbMeta.getHostname();
node.setProperty(DictionaryConst.PROPERTY_HOST_NAME, host);
String user = dbMeta.getUsername();
node.setProperty(DictionaryConst.PROPERTY_USER_NAME, user);
boolean shared = dbMeta.isShared();
node.setProperty("shared", shared);
if (accessTypeDesc != null && accessTypeDesc.equals("JNDI")) {
node.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DB_JNDI);
} else {
node.setLogicalIdGenerator(getLogicalIdGenerator());
}
metaverseBuilder.addNode(node);
return node;
}
use of org.pentaho.di.core.database.DatabaseInterface in project pentaho-platform by pentaho.
the class SqlMetadataQueryExec method getDatabaseInterface.
protected DatabaseInterface getDatabaseInterface(final SQLConnection conn) {
String prod = null;
try {
prod = conn.getNativeConnection().getMetaData().getDatabaseProductName();
DatabaseInterface di = DatabaseMetaUtil.getDatabaseInterface(prod);
if (prod != null && di == null) {
logger.warn(Messages.getInstance().getString("MQLRelationalDataComponent.WARN_0001_NO_DIALECT_DETECTED", // $NON-NLS-1$
prod));
}
return di;
} catch (SQLException e) {
logger.warn(Messages.getInstance().getString("MQLRelationalDataComponent.WARN_0002_DIALECT_EXCEPTION", prod), // $NON-NLS-1$
e);
}
return null;
}
Aggregations