/** * The plugin ID of the database interface */ public String getPluginId() { return databaseInterface.getPluginId(); }
public void databaseTypeAdded( String pluginName, DatabaseInterface databaseInterface ) { connectionMap.put( pluginName, databaseInterface ); connectionNametoID.put( pluginName, databaseInterface.getPluginId() ); }
/** * This method is designed to identify whether the actual database for two database connection types is the same. * This situation can occur in two cases: * 1. plugin id of {@code primary} is the same as plugin id of {@code secondary} * 2. {@code secondary} is a descendant {@code primary} (with any deepness). */ protected boolean databaseForBothDbInterfacesIsTheSame( DatabaseInterface primary, DatabaseInterface secondary ) { if ( primary == null || secondary == null ) { throw new IllegalArgumentException( "DatabaseInterface shouldn't be null!" ); } if ( primary.getPluginId() == null || secondary.getPluginId() == null ) { return false; } if ( primary.getPluginId().equals( secondary.getPluginId() ) ) { return true; } return primary.getClass().isAssignableFrom( secondary.getClass() ); }
public DatabaseFactoryInterface getDatabaseFactory() throws Exception { PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( DatabasePluginType.class, databaseInterface.getPluginId() ); if ( plugin == null ) { throw new KettleDatabaseException( "database type with plugin id [" + databaseInterface.getPluginId() + "] couldn't be found!" ); } ClassLoader loader = registry.getClassLoader( plugin ); Class<?> clazz = Class.forName( databaseInterface.getDatabaseFactoryName(), true, loader ); return (DatabaseFactoryInterface) clazz.newInstance(); }
public Properties getConnectionProperties() { Properties properties = new Properties(); Map<String, String> map = getExtraOptions(); if ( map.size() > 0 ) { Iterator<String> iterator = map.keySet().iterator(); while ( iterator.hasNext() ) { String typedParameter = iterator.next(); int dotIndex = typedParameter.indexOf( '.' ); if ( dotIndex >= 0 ) { String typeCode = typedParameter.substring( 0, dotIndex ); String parameter = typedParameter.substring( dotIndex + 1 ); String value = map.get( typedParameter ); // Only add to the URL if it's the same database type code... // if ( databaseInterface.getPluginId().equals( typeCode ) ) { if ( value != null && value.equals( EMPTY_OPTIONS_STRING ) ) { value = ""; } properties.put( parameter, environmentSubstitute( Const.NVL( value, "" ) ) ); } } } } return properties; }
currentType = connectionMap.get( connection.toString() ).getPluginId();
String dbType = dbMeta.getDatabaseInterface().getPluginId(); jdbcSchema = options.get(dbType + "." + FILTER_SCHEMA_LIST);
public static DatabaseInterface getDatabaseInterface( String productName ) { if ( productName == null ) { return null; } productName = productName.toLowerCase(); // special case to map hsql to hypersonic if ( productName.indexOf( "hsql" ) >= 0 ) { //$NON-NLS-1$ productName = "hypersonic"; //$NON-NLS-1$ } // look through all available database dialects for a match DatabaseInterface[] interfaces = DatabaseMeta.getDatabaseInterfaces(); for ( int i = 0; i < interfaces.length; i++ ) { String typeDesc = interfaces[i].getPluginId().toLowerCase(); if ( productName.equals( typeDesc ) ) { return DatabaseMeta.getDatabaseInterfaces()[i]; } } for ( int i = 0; i < interfaces.length; i++ ) { String typeDesc = interfaces[i].getPluginId().toLowerCase(); if ( productName.indexOf( typeDesc ) >= 0 ) { return DatabaseMeta.getDatabaseInterfaces()[i]; } } return null; }
public static DatabaseInterface getDatabaseInterface( String productName, DatabaseMeta databaseMeta ) { if ( productName == null ) { return null; } // special case to separate hive1 and hive2 if ( productName.indexOf( "Apache Hive" ) >= 0 ) { //$NON-NLS-1$ String hivePluginId = databaseMeta.getDatabaseInterface().getPluginId(); switch ( hivePluginId ) { case "HIVE": //$NON-NLS-1$ case "HIVE2": //$NON-NLS-1$ productName = hivePluginId; break; } } return getDatabaseInterface( productName ); } }