Java Code Examples for org.pentaho.di.core.database.DatabaseMeta#setPassword()
The following examples show how to use
org.pentaho.di.core.database.DatabaseMeta#setPassword() .
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: 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 2
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 3
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 4
Source File: DatabaseMetaLoadSaveValidator.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public DatabaseMeta getTestObject() { DatabaseMeta db = new DatabaseMeta(); db.setObjectId( new LongObjectId( rand.nextInt( Integer.MAX_VALUE ) ) ); db.setName( UUID.randomUUID().toString() ); db.setHostname( UUID.randomUUID().toString() ); db.setUsername( UUID.randomUUID().toString() ); db.setPassword( UUID.randomUUID().toString() ); return db; }
Example 5
Source File: DatabaseConfigurationImportRuleIT.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public void testRule() throws Exception { // Assemble a new database. // String DBNAME = "test"; String HOSTNAME = "localhost"; String PORT = "3306"; String USERNAME = "foo"; String PASSWORD = "bar"; DatabaseMeta verifyMeta = new DatabaseMeta( "LOGDB", "MYSQL", "JDBC", HOSTNAME, DBNAME, PORT, USERNAME, PASSWORD ); // Create a transformation to test. // TransMeta transMeta = new TransMeta(); transMeta.addDatabase( (DatabaseMeta) verifyMeta.clone() ); // Load the plugin to test from the registry. // PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.findPluginWithId( ImportRulePluginType.class, "DatabaseConfiguration" ); assertNotNull( "The 'database configuration' rule could not be found in the plugin registry!", plugin ); DatabaseConfigurationImportRule rule = (DatabaseConfigurationImportRule) registry.loadClass( plugin ); assertNotNull( "The 'database configuration' class could not be loaded by the plugin registry!", plugin ); // Set the appropriate rule.. // rule.setEnabled( true ); List<ImportValidationFeedback> feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'database configuration'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); rule.setDatabaseMeta( verifyMeta ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An approval ruling was expected", feedback.get( 0 ).getResultType() == ImportValidationResultType.APPROVAL ); // Create some errors... // verifyMeta.setDBName( "incorrect-test" ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected validating the db name", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); verifyMeta.setDBName( DBNAME ); verifyMeta.setHostname( "incorrect-hostname" ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected validating the db hostname", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); verifyMeta.setHostname( HOSTNAME ); verifyMeta.setDBPort( "incorrect-port" ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected validating the db port", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); verifyMeta.setDBPort( PORT ); verifyMeta.setUsername( "incorrect-username" ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected validating the db username", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); verifyMeta.setUsername( USERNAME ); verifyMeta.setPassword( "incorrect-password" ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't get any feedback from the 'transformation has description rule'", !feedback.isEmpty() ); assertTrue( "An error ruling was expected validating the db password", feedback.get( 0 ).getResultType() == ImportValidationResultType.ERROR ); verifyMeta.setPassword( PASSWORD ); // No feedback expected! // rule.setEnabled( false ); feedback = rule.verifyRule( transMeta ); assertTrue( "We didn't expect any feedback from the 'transformation has trans log table configured' since disabled", feedback.isEmpty() ); }
Example 6
Source File: KettleDatabaseRepositoryDatabaseDelegate.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * * Load the Database Info */ public DatabaseMeta loadDatabaseMeta( ObjectId id_database ) throws KettleException { DatabaseMeta databaseMeta = new DatabaseMeta(); try { RowMetaAndData r = getDatabase( id_database ); if ( r != null ) { ObjectId id_database_type = new LongObjectId( r.getInteger( KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_TYPE, 0 ) ); // con_type String dbTypeDesc = getDatabaseTypeCode( id_database_type ); if ( dbTypeDesc != null ) { databaseMeta.setDatabaseInterface( DatabaseMeta.getDatabaseInterface( dbTypeDesc ) ); databaseMeta.setAttributes( new Properties() ); // new attributes } databaseMeta.setObjectId( id_database ); databaseMeta.setName( r.getString( KettleDatabaseRepository.FIELD_DATABASE_NAME, "" ) ); ObjectId id_database_contype = new LongObjectId( r.getInteger( KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_CONTYPE, 0 ) ); // con_access databaseMeta.setAccessType( DatabaseMeta.getAccessType( getDatabaseConTypeCode( id_database_contype ) ) ); databaseMeta.setHostname( r.getString( KettleDatabaseRepository.FIELD_DATABASE_HOST_NAME, "" ) ); databaseMeta.setDBName( r.getString( KettleDatabaseRepository.FIELD_DATABASE_DATABASE_NAME, "" ) ); databaseMeta.setDBPort( r.getString( KettleDatabaseRepository.FIELD_DATABASE_PORT, "" ) ); databaseMeta.setUsername( r.getString( KettleDatabaseRepository.FIELD_DATABASE_USERNAME, "" ) ); databaseMeta.setPassword( Encr.decryptPasswordOptionallyEncrypted( r.getString( KettleDatabaseRepository.FIELD_DATABASE_PASSWORD, "" ) ) ); databaseMeta.setServername( r.getString( KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME, "" ) ); databaseMeta.setDataTablespace( r.getString( KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS, "" ) ); databaseMeta.setIndexTablespace( r.getString( KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS, "" ) ); // Also, load all the properties we can find... final Collection<RowMetaAndData> attrs = repository.connectionDelegate.getDatabaseAttributes( id_database ); for ( RowMetaAndData row : attrs ) { String code = row.getString( KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE, "" ); String attribute = row.getString( KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR, "" ); databaseMeta.getAttributes().put( code, Const.NVL( attribute, "" ) ); } } return databaseMeta; } catch ( KettleDatabaseException dbe ) { throw new KettleException( "Error loading database connection from repository (id_database=" + id_database + ")", dbe ); } }