Java Code Examples for org.pentaho.di.core.database.DatabaseMeta#setDatabaseType()
The following examples show how to use
org.pentaho.di.core.database.DatabaseMeta#setDatabaseType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobEntryEvalTableContentTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { MockDriver.registerInstance(); Job job = new Job( null, new JobMeta() ); entry = new JobEntryEvalTableContent(); job.getJobMeta().addJobEntry( new JobEntryCopy( entry ) ); entry.setParentJob( job ); job.setStopped( false ); DatabaseMeta dbMeta = new DatabaseMeta(); dbMeta.setDatabaseType( "mock-db" ); entry.setDatabase( dbMeta ); // set KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES to default, in case overwritten at any point. entry.setVariable( Const.KETTLE_COMPATIBILITY_SET_ERROR_ON_SPECIFIC_JOB_ENTRIES, "N" ); }
Example 2
Source File: RepositoryTestBase.java From pentaho-kettle with Apache License 2.0 | 6 votes |
protected DatabaseMeta createDatabaseMeta( final String dbName ) throws Exception { DatabaseMeta dbMeta = new DatabaseMeta(); dbMeta.setName( dbName ); dbMeta.setHostname( EXP_DBMETA_HOSTNAME ); dbMeta.setDatabaseType( EXP_DBMETA_TYPE ); dbMeta.setAccessType( EXP_DBMETA_ACCESS ); dbMeta.setDBName( EXP_DBMETA_DBNAME ); dbMeta.setDBPort( EXP_DBMETA_PORT ); dbMeta.setUsername( EXP_DBMETA_USERNAME ); dbMeta.setPassword( EXP_DBMETA_PASSWORD ); dbMeta.setServername( EXP_DBMETA_SERVERNAME ); dbMeta.setDataTablespace( EXP_DBMETA_DATA_TABLESPACE ); dbMeta.setIndexTablespace( EXP_DBMETA_INDEX_TABLESPACE ); // Properties attrs = new Properties(); // exposed mutable state; yikes dbMeta.getAttributes().put( EXP_DBMETA_ATTR1_KEY, EXP_DBMETA_ATTR1_VALUE ); dbMeta.getAttributes().put( EXP_DBMETA_ATTR2_KEY, EXP_DBMETA_ATTR2_VALUE ); // TODO mlowery more testing on DatabaseMeta options return dbMeta; }
Example 3
Source File: CwmSchemaFactory.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read a DatabaseMeta from a CWM model by providing the catalog reference. * * @param cwm * @param catalog * @return a new DatabaseMeta instance, read from the specified CWM model. */ public DatabaseMeta getDatabaseMeta( CWM cwm, CwmCatalog catalog ) { DatabaseMeta databaseMeta = new DatabaseMeta(); databaseMeta.setName( catalog.getName() ); databaseMeta.setHostname( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_SERVER ) ); databaseMeta.setDatabaseType( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_TYPE ) ); databaseMeta.setAccessType( DatabaseMeta .getAccessType( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_ACCESS ) ) ); databaseMeta.setDBName( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_DATABASE ) ); databaseMeta.setDBPort( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_PORT ) ); databaseMeta.setUsername( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_USERNAME ) ); databaseMeta.setPassword( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_PASSWORD ) ); databaseMeta.setServername( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_SERVERNAME ) ); databaseMeta.setDataTablespace( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_DATA_TABLESPACE ) ); databaseMeta.setIndexTablespace( cwm.getFirstTaggedValue( catalog, CWM.TAG_DATABASE_INDEX_TABLESPACE ) ); // And now load the attributes... CwmTaggedValue[] taggedValue = cwm.getTaggedValues( catalog ); for ( int i = 0; i < taggedValue.length; i++ ) { if ( taggedValue[ i ].getTag().startsWith( CWM.TAG_DATABASE_ATTRIBUTE_PREFIX ) ) { String key = taggedValue[ i ].getTag().substring( CWM.TAG_DATABASE_ATTRIBUTE_PREFIX.length() ); String attribute = taggedValue[ i ].getValue(); // Add the attribute databaseMeta.getAttributes().put( key, attribute ); } } return databaseMeta; }
Example 4
Source File: ThinModelConverter.java From pentaho-metadata with GNU Lesser General Public License v2.1 | 5 votes |
public static DatabaseMeta convertToLegacy( String name, SqlDataSource datasource ) { // make sure that the Kettle environment is initialized before DatabaseMeta creation try { KettleEnvironment.init( false ); } catch ( KettleException e ) { logger.error( "Error initializing the Kettle Environment", e ); throw new RuntimeException( "Error initializing the Kettle Environment", e ); } DatabaseMeta databaseMeta = new DatabaseMeta(); databaseMeta.setName( name ); databaseMeta.setHostname( datasource.getHostname() ); if ( datasource.getDialectType() == null ) { // default to mysql if dialect is null databaseMeta.setDatabaseType( "GENERIC" ); //$NON-NLS-1$ } else { databaseMeta.setDatabaseType( datasource.getDialectType() ); } databaseMeta.setAccessType( DatabaseMeta.getAccessType( datasource.getType().toString() ) ); databaseMeta.setDBName( datasource.getDatabaseName() ); databaseMeta.setDBPort( datasource.getPort() ); databaseMeta.setUsername( datasource.getUsername() ); databaseMeta.setPassword( datasource.getPassword() ); databaseMeta.setServername( datasource.getServername() ); // And now load the attributes... for ( String key : datasource.getAttributes().keySet() ) { databaseMeta.getAttributes().put( key, datasource.getAttributes().get( key ) ); } return databaseMeta; }
Example 5
Source File: AsyncDatabaseActionTest.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Before public void before() { dbMeta = new DatabaseMeta(); H2DatabaseMeta h2 = new H2DatabaseMeta(); dbMeta.setDatabaseInterface( h2 ); dbMeta.setName( "mem:TEST" ); dbMeta.setDBName( "mem:TEST" ); dbMeta.setDatabaseType( "H2" ); KettleLogStore.getAppender().addLoggingEventListener( errorLogListener ); }
Example 6
Source File: ExplorerHarness.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * @param args */ @SuppressWarnings( "nls" ) public static void main( String[] args ) { KettleDatabaseRepositoryMeta repositoryMeta; KettleDatabaseRepository repository; @SuppressWarnings( "unused" ) UserInfo userInfo; repositoryMeta = new KettleDatabaseRepositoryMeta(); repositoryMeta.setName( "Kettle Database Repository" ); repositoryMeta.setDescription( "Kettle database test repository" ); DatabaseMeta connection = new DatabaseMeta(); connection.setDatabaseType( "Hypersonic" ); connection.setHostname( "localhost" ); connection.setDBName( "kettle_repository_4x" ); connection.setDBPort( "9002" ); connection.setUsername( "sa" ); repositoryMeta.setConnection( connection ); userInfo = new UserInfo( "admin", "admin", "Administrator", "The system administrator", true ); repository = new KettleDatabaseRepository(); repository.init( repositoryMeta ); @SuppressWarnings( "unused" ) RepositoryExplorerCallback cb = new RepositoryExplorerCallback() { public boolean open( UIRepositoryContent element, String revision ) throws Exception { System.out.println( "Name: ".concat( element.getName() ) ); System.out.println( "Type: ".concat( element.getRepositoryElementType().name() ) ); System.out.println( "Directory: ".concat( element.getRepositoryDirectory().toString() ) ); System.out.println( "Revision: ".concat( revision == null ? "null" : revision ) ); return false; // do not close explorer } @Override public boolean error ( String message ) throws Exception { System.out.println( "Error message: ".concat( message ) ); return true; } }; /* * try { repository.connect(userInfo.getLogin(), userInfo.getPassword()); //RepositoryExplorer explorer = new * RepositoryExplorer(new Shell(), repository, cb, null); //explorer.show(); } catch (XulException e) { * e.printStackTrace(); } catch (KettleSecurityException e) { e.printStackTrace(); } catch (KettleException e) { * e.printStackTrace(); } */ }
Example 7
Source File: SynchronizeAfterMergeIT.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Before public void setUp() throws KettleDatabaseException, SQLException { connection = DriverManager.getConnection( "jdbc:h2:mem:PERSON;" ); connection.setAutoCommit( false ); PreparedStatement stmt = connection.prepareStatement( "CREATE TABLE PERSON (ID INT PRIMARY KEY, personName VARCHAR(64) )" ); stmt.execute(); stmt.close(); stmt = connection.prepareStatement( "INSERT INTO PERSON (ID, personName) VALUES (?, ?)" ); for ( int i = 0; i < ROW_FOR_UPDATE + ROW_FOR_DELETE; i++ ) { stmt.setInt( 1, i ); stmt.setString( 2, "personName" + i ); stmt.addBatch(); } stmt.executeBatch(); stmt.close(); connection.commit(); PluginRegistry pluginRegistry = PluginRegistry.getInstance(); transMeta = new TransMeta(); transMeta.setName( "SynchronizeAfterMerge" ); InjectorMeta injectorMeta = new InjectorMeta(); String injectorPid = pluginRegistry.getPluginId( StepPluginType.class, injectorMeta ); StepMeta injectorStep = new StepMeta( injectorPid, injectorStepname, injectorMeta ); transMeta.addStep( injectorStep ); DatabaseMeta dbMeta = spy( new DatabaseMeta() ); dbMeta.setDatabaseType( "H2" ); when( dbMeta.getURL() ).thenReturn( "jdbc:h2:mem:PERSON;" ); when( dbMeta.supportsErrorHandlingOnBatchUpdates() ).thenReturn( false ); SynchronizeAfterMergeMeta synchronizeAfterMergeMeta = new SynchronizeAfterMergeMeta(); //set commit size synchronizeAfterMergeMeta.setCommitSize( COMMIT_SIZE ); synchronizeAfterMergeMeta.setDatabaseMeta( dbMeta ); synchronizeAfterMergeMeta.setKeyCondition( new String[] { "=" } ); synchronizeAfterMergeMeta.setKeyLookup( new String[] { "ID" } ); synchronizeAfterMergeMeta.setKeyStream( new String[] { "personName" } ); synchronizeAfterMergeMeta.setKeyStream2( new String[] { null } ); synchronizeAfterMergeMeta.setUpdate( new Boolean[] { Boolean.TRUE } ); synchronizeAfterMergeMeta.setOperationOrderField( "flag" ); synchronizeAfterMergeMeta.setOrderDelete( DELETE_FLAG ); synchronizeAfterMergeMeta.setOrderInsert( INSERT_FLAG ); synchronizeAfterMergeMeta.setOrderUpdate( UPDATE_FLAG ); synchronizeAfterMergeMeta.setPerformLookup( true ); synchronizeAfterMergeMeta.setTableName( "PERSON" ); synchronizeAfterMergeMeta.settablenameInField( false ); synchronizeAfterMergeMeta.settablenameField( null ); synchronizeAfterMergeMeta.setUseBatchUpdate( true ); synchronizeAfterMergeMeta.setUpdateLookup( new String[] { "ID" } ); synchronizeAfterMergeMeta.setUpdateStream( new String[] { "personName" } ); String synchronizeAfterMergePid = pluginRegistry.getPluginId( StepPluginType.class, synchronizeAfterMergeStepname ); StepMeta synchronizeAfterMerge = new StepMeta( synchronizeAfterMergePid, synchronizeAfterMergeStepname, synchronizeAfterMergeMeta ); transMeta.addStep( synchronizeAfterMerge ); String dummyResultStepName = "dummyResultStepName"; DummyTransMeta dummyResultTransMeta = new DummyTransMeta(); String dummyResultPid = pluginRegistry.getPluginId( StepPluginType.class, dummyResultTransMeta ); StepMeta dummyResultStep = new StepMeta( dummyResultPid, dummyResultStepName, dummyResultTransMeta ); transMeta.addStep( dummyResultStep ); String dummyErrorStepName = "dummyErrorStepName"; DummyTransMeta dummyErrorTransMeta = new DummyTransMeta(); String dummyErrorPid = pluginRegistry.getPluginId( StepPluginType.class, dummyErrorTransMeta ); StepMeta dummyErrorStep = new StepMeta( dummyErrorPid, dummyErrorStepName, dummyErrorTransMeta ); transMeta.addStep( dummyErrorStep ); StepErrorMeta stepErrorMeta = new StepErrorMeta( transMeta, synchronizeAfterMerge, dummyErrorStep ); stepErrorMeta.setEnabled( true ); synchronizeAfterMerge.setStepErrorMeta( stepErrorMeta ); TransHopMeta injSynch = new TransHopMeta( injectorStep, synchronizeAfterMerge ); transMeta.addTransHop( injSynch ); TransHopMeta synchDummyResult = new TransHopMeta( synchronizeAfterMerge, dummyResultStep ); transMeta.addTransHop( synchDummyResult ); TransHopMeta synchDummyError = new TransHopMeta( synchronizeAfterMerge, dummyErrorStep ); transMeta.addTransHop( synchDummyError ); }