Package org.pentaho.database.model

Examples of org.pentaho.database.model.DatabaseConnection


  @Override
  public DatabaseConnection unmarshal( DatabaseConnectionDto dbConnDto ) throws Exception {
    if ( dbConnDto != null ) {
      IDatabaseDialectService databaseDialectService = new DatabaseDialectService();
      DatabaseTypeHelper databaseTypeHelper = new DatabaseTypeHelper( databaseDialectService.getDatabaseTypes() );
      DatabaseConnection dbConn = new DatabaseConnection();
      dbConn.setId( dbConnDto.getId() );
      dbConn.setAccessType( dbConnDto.getAccessType() );
      dbConn.setAccessTypeValue( dbConnDto.getAccessTypeValue() );
      dbConn.setChanged( dbConnDto.getChanged() );
      dbConn.setConnectionPoolingProperties( dbConnDto.getConnectionPoolingProperties() );
      dbConn.setConnectSql( dbConnDto.getConnectSql() );
      dbConn.setDatabaseName( dbConnDto.getDatabaseName() );
      dbConn.setDatabasePort( dbConnDto.getDatabasePort() );
      if ( dbConnDto.getDatabaseType() != null ) {
        dbConn.setDatabaseType( databaseTypeHelper.getDatabaseTypeByShortName( dbConnDto.getDatabaseType() ) );
      }
      dbConn.setDataTablespace( dbConnDto.getDataTablespace() );
      dbConn.setForcingIdentifiersToLowerCase( dbConnDto.isForcingIdentifiersToLowerCase() );
      dbConn.setForcingIdentifiersToUpperCase( dbConnDto.isForcingIdentifiersToUpperCase() );
      dbConn.setHostname( dbConnDto.getHostname() );
      dbConn.setIndexTablespace( dbConnDto.getIndexTablespace() );
      dbConn.setInformixServername( dbConnDto.getInformixServername() );
      dbConn.setInitialPoolSize( dbConnDto.getInitialPoolSize() );
      dbConn.setMaximumPoolSize( dbConnDto.getMaximumPoolSize() );
      dbConn.setName( dbConnDto.getName() );
      dbConn.setPartitioned( dbConnDto.isPartitioned() );
      dbConn.setPartitioningInformation( dbConnDto.getPartitioningInformation() );
      dbConn.setPassword( dbConnDto.getPassword() );
      dbConn.setQuoteAllFields( dbConnDto.isQuoteAllFields() );
      dbConn.setSQLServerInstance( dbConnDto.getSQLServerInstance() );
      dbConn.setStreamingResults( dbConnDto.isStreamingResults() );
      dbConn.setUsername( dbConnDto.getUsername() );
      dbConn.setUsingConnectionPool( dbConnDto.isUsingConnectionPool() );
      dbConn.setUsingDoubleDecimalAsSchemaTableSeparator( dbConnDto.isUsingDoubleDecimalAsSchemaTableSeparator() );
      return dbConn;
    } else {
      return null;
    }
  }
View Full Code Here


    assertEquals( EXP_HOST_NAME, conn.getHostname() );
  }

  private IDatabaseConnection createDatabaseConnection( final String dbName ) throws Exception {
    IDatabaseConnection dbConnection = new DatabaseConnection();
    dbConnection.setName( dbName );
    dbConnection.setHostname( EXP_DBMETA_HOSTNAME );
    dbConnection.setDatabaseType( mockDatabaseType( "Hypersonic" ) );
    dbConnection.setAccessType( DatabaseAccessType.NATIVE );
    dbConnection.setDatabasePort( EXP_DBMETA_PORT );
    return dbConnection;
  }
View Full Code Here

  }

  @Test
  public void testEverything() throws Exception {
    DatabaseConnection databaseConnection = createDatabaseConnection( "testDatabase" );
    String id = datasourceMgmtWebService.createDatasource( dbConnectionAdapter.marshal( databaseConnection ) );
    assertNotNull( id );
    DatabaseConnectionDto databaseConnectionDto = datasourceMgmtWebService.getDatasourceByName( "testDatabase" );
    assertNotNull( databaseConnectionDto );
    assertEquals( EXP_DBMETA_HOSTNAME, databaseConnectionDto.getHostname() );
    DatabaseConnectionDto databaseConnectionDto1 = datasourceMgmtWebService.getDatasourceById( id );
    assertNotNull( databaseConnectionDto1 );
    assertEquals( EXP_DBMETA_HOSTNAME, databaseConnectionDto1.getHostname() );
    DatabaseConnection databaseConnection1 = createDatabaseConnection( "testDatabase1" );
    String id1 = datasourceMgmtWebService.createDatasource( dbConnectionAdapter.marshal( databaseConnection1 ) );
    assertNotNull( id1 );
    DatabaseConnectionDto databaseConnectionDto2 = datasourceMgmtWebService.getDatasourceByName( "testDatabase1" );
    assertNotNull( databaseConnectionDto2 );
    assertEquals( EXP_DBMETA_HOSTNAME, databaseConnectionDto2.getHostname() );
View Full Code Here

    ids = datasourceMgmtWebService.getDatasourceIds();
    assertEquals( 0, ids.size() );
  }

  private DatabaseConnection createDatabaseConnection( final String dbName ) throws Exception {
    DatabaseConnection dbConnection = new DatabaseConnection();
    dbConnection.setName( dbName );
    dbConnection.setHostname( EXP_DBMETA_HOSTNAME );
    dbConnection.setDatabaseType( mockDatabaseType( "Hypersonic" ) );
    dbConnection.setAccessType( DatabaseAccessType.NATIVE );
    dbConnection.setDatabasePort( EXP_DBMETA_PORT );
    return dbConnection;
  }
View Full Code Here

    metadata.setDomainId( "testDomain" );
    metadata.setFile( "testMetadata.xml" );
    exportManifest.addMetadata( metadata );
    exportManifest.addSchedule( new JobScheduleRequest() );

    DatabaseConnection connection = new DatabaseConnection();
    connection.setAccessType( DatabaseAccessType.NATIVE );
    connection.setDatabaseName( "SampleData" );
    connection.setDatabasePort( "9001" );
    DatabaseType type = new DatabaseType();
    type.setName( "Hypersonic" );
    type.setShortName( "HYPERSONIC" );
    connection.setDatabaseType( type );
    connection.setHostname( "localhost" );
    connection.setUsername( "pentaho_user" );
    connection.setPassword( "password" );
    connection.setMaximumPoolSize( 20 );

    exportManifest.addDatasource( connection );

  }
View Full Code Here

    ExportManifestMetadata metadata1 = importManifest.getMetadataList().get( 0 );
    assertEquals( "testDomain", metadata1.getDomainId() );
    assertEquals( "testMetadata.xml", metadata1.getFile() );

    DatabaseConnection connection = importManifest.getDatasourceList().get( 0 );
    assertEquals( "SampleData", connection.getDatabaseName() );
    assertEquals( "9001", connection.getDatabasePort() );
    assertEquals( "Hypersonic", connection.getDatabaseType().getName() );
    assertEquals( "HYPERSONIC", connection.getDatabaseType().getShortName() );
    assertEquals( "localhost", connection.getHostname() );
    assertEquals( "pentaho_user", connection.getUsername() );
    assertEquals( "password", connection.getPassword() );
    assertEquals( 20, connection.getMaximumPoolSize() );

  }
View Full Code Here

  }
 
  public IDatabaseConnection dataNodeToDatabaseConnection( final Serializable id, final String name,
      final DataNode rootNode ) {
    IDatabaseConnection databaseConnection = new DatabaseConnection();
    String databaseType = getString( rootNode, PROP_TYPE );
    databaseConnection.setDatabaseType( databaseType != null ? databaseTypeHelper
        .getDatabaseTypeByShortName( databaseType ) : null );
    databaseConnection.setName( name );
    if ( id != null ) {
      databaseConnection.setId( id.toString() );
    }
    String accessType = getString( rootNode, PROP_CONTYPE );

    // This is a special case with some PDI connections
    if(accessType != null && accessType.contains( "Native")) {
      accessType = DatabaseAccessType.NATIVE.getName();
    } else if(accessType != null && accessType.equals(", ")) {
      accessType = DatabaseAccessType.JNDI.getName();
    }
   
    databaseConnection.setAccessType( accessType != null
      ? DatabaseAccessType.getAccessTypeByName( accessType ) : null );
    databaseConnection.setHostname( getString( rootNode, PROP_HOST_NAME ) );
    databaseConnection.setDatabaseName( getString( rootNode, PROP_DATABASE_NAME ) );
    databaseConnection.setDatabasePort( getString( rootNode, PROP_PORT ) );
    databaseConnection.setUsername( getString( rootNode, PROP_USERNAME ) );
    databaseConnection.setPassword( Encr.decryptPasswordOptionallyEncrypted(getString(rootNode, PROP_PASSWORD)));
    databaseConnection.setInformixServername( getString( rootNode, PROP_SERVERNAME ) );
    databaseConnection.setDataTablespace( getString( rootNode, PROP_DATA_TBS ) );
    databaseConnection.setIndexTablespace( getString( rootNode, PROP_INDEX_TBS ) );
    databaseConnection.setConnectSql( getString( rootNode, PROP_CONNECT_SQL ) );
    databaseConnection.setInitialPoolSize( getInt( rootNode, PROP_INITIAL_POOL_SIZE ) );
    databaseConnection.setMaximumPoolSize( getInt( rootNode, PROP_MAX_POOL_SIZE ) );
    databaseConnection.setUsingConnectionPool( getBoolean( rootNode, PROP_IS_POOLING ) );
    databaseConnection.setForcingIdentifiersToLowerCase( getBoolean( rootNode, PROP_IS_FORCING_TO_LOWER ) );
    databaseConnection.setForcingIdentifiersToUpperCase( getBoolean( rootNode, PROP_IS_FORCING_TO_UPPER ) );
    databaseConnection.setQuoteAllFields( getBoolean( rootNode, PROP_IS_QUOTE_FIELDS ) );
    databaseConnection.setUsingDoubleDecimalAsSchemaTableSeparator( getBoolean( rootNode, PROP_IS_DECIMAL_SEPERATOR ) );

    // Also, load all the properties we can find...
    DataNode attrNode = rootNode.getNode( NODE_ATTRIBUTES );
    if ( attrNode != null ) {
      for ( DataProperty property : attrNode.getProperties() ) {
        String code = property.getName();
        String attribute = property.getString();
        databaseConnection.getAttributes()
            .put( code, ( attribute == null || attribute.length() == 0 ) ? "" : attribute ); //$NON-NLS-1$
      }
    }

    // Also, load any pooling params
    attrNode = rootNode.getNode( NODE_POOLING_PROPS );
    if ( attrNode != null ) {
      for ( DataProperty property : attrNode.getProperties() ) {
        String code = property.getName();
        String attribute = property.getString();
        databaseConnection.getConnectionPoolingProperties().put( code,
            ( attribute == null || attribute.length() == 0 ) ? "" : attribute ); //$NON-NLS-1$
      }
    }

    // Load extra options
    attrNode = rootNode.getNode( NODE_EXTRA_OPTIONS );
    if ( attrNode != null ) {
      for ( DataProperty property : attrNode.getProperties() ) {
        String code = property.getName();
        String attribute = property.getString();
        databaseConnection.getExtraOptions().put( code,
            ( attribute == null || attribute.length() == 0 ) ? "" : attribute ); //$NON-NLS-1$
      }
    }

    return databaseConnection;
View Full Code Here

    return rootNode;
  }

  public IDatabaseConnection databaseMetaToDatabaseConnection( final DatabaseMeta databaseMeta) {
   
    IDatabaseConnection databaseConnection = new DatabaseConnection();
    databaseConnection.setDatabaseType( databaseTypeHelper
        .getDatabaseTypeByShortName( databaseMeta.getDatabaseTypeDesc() ));
    databaseConnection.setName( databaseMeta.getName() );
    if ( databaseMeta.getObjectId() != null ) {
      databaseConnection.setId( databaseMeta.getObjectId().getId() );
    }
    String accessType = databaseMeta.getAccessTypeDesc();

    // This is a special case with some PDI connections
    if(accessType != null && accessType.contains( "Native")) {
      accessType = DatabaseAccessType.NATIVE.getName();
    } else if(accessType != null && accessType.equals(", ")) {
      accessType = DatabaseAccessType.JNDI.getName();
    }
   
    databaseConnection.setAccessType( accessType != null
      ? DatabaseAccessType.getAccessTypeByName( accessType ) : null );
    databaseConnection.setHostname(databaseMeta.getHostname() );
    databaseConnection.setDatabaseName( databaseMeta.getDatabaseName() );
    databaseConnection.setDatabasePort( databaseMeta.getDatabasePortNumberString() );
    databaseConnection.setUsername( databaseMeta.getUsername() );
    databaseConnection.setPassword( databaseMeta.getPassword() );
    databaseConnection.setInformixServername( databaseMeta.getServername() );
    databaseConnection.setDataTablespace( databaseMeta.getDataTablespace() );
    databaseConnection.setIndexTablespace( databaseMeta.getIndexTablespace() );
    databaseConnection.setConnectSql( databaseMeta.getConnectSQL() );
    databaseConnection.setInitialPoolSize( databaseMeta.getInitialPoolSize() );
    databaseConnection.setMaximumPoolSize( databaseMeta.getMaximumPoolSize() );
    databaseConnection.setUsingConnectionPool( databaseMeta.isUsingConnectionPool() );
    databaseConnection.setForcingIdentifiersToLowerCase( databaseMeta.isForcingIdentifiersToLowerCase() );
    databaseConnection.setForcingIdentifiersToUpperCase( databaseMeta.isForcingIdentifiersToUpperCase() );
    databaseConnection.setQuoteAllFields( databaseMeta.isQuoteAllFields() );
    databaseConnection.setUsingDoubleDecimalAsSchemaTableSeparator( databaseMeta.isUsingDoubleDecimalAsSchemaTableSeparator() );
   
    Map<String,String> attributeMap = new HashMap<String, String>();
   
    for(Entry<Object, Object> entry:databaseMeta.getAttributes().entrySet()) {
      attributeMap.put( (String)entry.getKey(), (String)entry.getValue() );
    }
    databaseConnection.setAttributes(attributeMap);
   
    Map<String,String> connectionPoolingMap = new HashMap<String, String>();
    for(Entry<Object, Object> entry:databaseMeta.getConnectionPoolingProperties().entrySet()) {
      connectionPoolingMap.put( (String)entry.getKey(), (String)entry.getValue() );
    }
    databaseConnection.setConnectionPoolingProperties(connectionPoolingMap);
   
    databaseConnection.setExtraOptions(databaseMeta.getExtraOptions());

    return databaseConnection;

  }
View Full Code Here

TOP

Related Classes of org.pentaho.database.model.DatabaseConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.