Java Code Examples for org.pentaho.di.core.database.DatabaseMeta#findDatabase()

The following examples show how to use org.pentaho.di.core.database.DatabaseMeta#findDatabase() . 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: JobEntryTruncateTables.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void loadXML( Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers,
  Repository rep, IMetaStore metaStore ) throws KettleXMLException {
  try {
    super.loadXML( entrynode, databases, slaveServers );

    String dbname = XMLHandler.getTagValue( entrynode, "connection" );
    this.connection = DatabaseMeta.findDatabase( databases, dbname );
    this.argFromPrevious = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "arg_from_previous" ) );

    Node fields = XMLHandler.getSubNode( entrynode, "fields" );

    // How many field arguments?
    int nrFields = XMLHandler.countNodes( fields, "field" );
    allocate( nrFields );

    // Read them all...
    for ( int i = 0; i < nrFields; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );
      this.arguments[i] = XMLHandler.getTagValue( fnode, "name" );
      this.schemaname[i] = XMLHandler.getTagValue( fnode, "schemaname" );
    }
  } catch ( KettleException e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JobEntryTruncateTables.UnableLoadXML" ), e );
  }
}
 
Example 2
Source File: PaloCellInputMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( final Node stepnode, final List<? extends SharedObjectInterface> databases )
  throws KettleXMLException {
  try {
    this.databaseMeta = DatabaseMeta.findDatabase( databases, XMLHandler.getTagValue( stepnode, "connection" ) );
    this.cube = XMLHandler.getTagValue( stepnode, "cube" );
    String cubeMeasureName = XMLHandler.getTagValue( stepnode, "cubemeasurename" );
    String cubeMeasureType = XMLHandler.getTagValue( stepnode, "cubemeasuretype" );
    this.cubeMeasure = new DimensionField( "Measure", cubeMeasureName, cubeMeasureType );

    this.fields = new ArrayList<DimensionField>();

    Node levels = XMLHandler.getSubNode( stepnode, "fields" );
    int nrLevels = XMLHandler.countNodes( levels, "field" );

    for ( int i = 0; i < nrLevels; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( levels, "field", i );

      String dimensionName = XMLHandler.getTagValue( fnode, "dimensionname" );
      String fieldName = XMLHandler.getTagValue( fnode, "fieldname" );
      String fieldType = XMLHandler.getTagValue( fnode, "fieldtype" );
      this.fields.add( new DimensionField( dimensionName, fieldName, fieldType ) );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 3
Source File: KettleDatabaseRepositoryMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadXML( Node repnode, List<DatabaseMeta> databases ) throws KettleException {
  super.loadXML( repnode, databases );
  try {
    String conn = XMLHandler.getTagValue( repnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, conn );
  } catch ( Exception e ) {
    throw new KettleException( "Unable to load Kettle database repository meta object", e );
  }
}
 
Example 4
Source File: JobGenerator.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
protected DatabaseMeta findSourceDatabaseMeta(String databaseName) throws KettleException {

    DatabaseMeta databaseMeta = DatabaseMeta.findDatabase(databases, databaseName);
    if (databaseMeta==null) {
      throw new KettleException(BaseMessages.getString(PKG, "LogicalModelerPerspective.MessageBox.SourceDBNotFound.Message", databaseName));
    }
    return databaseMeta;
  }
 
Example 5
Source File: MySQLBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode, List<? extends SharedObjectInterface> databases ) throws KettleXMLException {
  try {
    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );

    schemaName = XMLHandler.getTagValue( stepnode, "schema" );
    tableName = XMLHandler.getTagValue( stepnode, "table" );

    fifoFileName = XMLHandler.getTagValue( stepnode, "fifo_file_name" );

    encoding = XMLHandler.getTagValue( stepnode, "encoding" );
    enclosure = XMLHandler.getTagValue( stepnode, "enclosure" );
    delimiter = XMLHandler.getTagValue( stepnode, "delimiter" );
    escapeChar = XMLHandler.getTagValue( stepnode, "escape_char" );

    bulkSize = XMLHandler.getTagValue( stepnode, "bulk_size" );

    replacingData = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "replace" ) );
    ignoringErrors = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "ignore" ) );
    localFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "local" ) );

    int nrvalues = XMLHandler.countNodes( stepnode, "mapping" );
    allocate( nrvalues );

    for ( int i = 0; i < nrvalues; i++ ) {
      Node vnode = XMLHandler.getSubNodeByNr( stepnode, "mapping", i );

      fieldTable[i] = XMLHandler.getTagValue( vnode, "stream_name" );
      fieldStream[i] = XMLHandler.getTagValue( vnode, "field_name" );
      if ( fieldStream[i] == null ) {
        fieldStream[i] = fieldTable[i]; // default: the same name!
      }
      fieldFormatType[i] = getFieldFormatType( XMLHandler.getTagValue( vnode, "field_format_ok" ) );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG,
        "MySQLBulkLoaderMeta.Exception.UnableToReadStepInfoFromXML" ), e );
  }
}
 
Example 6
Source File: PaloCubeDeleteDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void doSelectConnection( boolean clearCurrentData ) {
  try {
    if ( clearCurrentData ) {
      comboCubeName.removeAll();
    }

    if ( comboCubeName.getItemCount() > 1 ) {
      return;
    }

    if ( addConnectionLine.getText() != null ) {
      DatabaseMeta dbMeta = DatabaseMeta.findDatabase( jobMeta.getDatabases(), addConnectionLine.getText() );
      if ( dbMeta != null ) {
        PaloHelper helper = new PaloHelper( dbMeta, DefaultLogLevel.getLogLevel() );
        helper.connect();
        List<String> cubes = helper.getCubesNames();
        Collections.sort( cubes, new PaloNameComparator() );
        for ( String cubename : cubes ) {
          if ( comboCubeName.indexOf( cubename ) == -1 ) {
            comboCubeName.add( cubename );
          }
        }
        helper.disconnect();
      }
    }
  } catch ( Exception ex ) {
    new ErrorDialog( shell, BaseMessages.getString( PKG, "PaloDimInputFlatDialog.RetreiveDimensionsErrorTitle" ),
      BaseMessages.getString( PKG, "PaloDimInputFlatDialog.RetreiveDimensionsError" ), ex );
  }
}
 
Example 7
Source File: PaloDimInputMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( final Node stepnode, final List<? extends SharedObjectInterface> databases )
  throws KettleXMLException {
  try {
    this.databaseMeta = DatabaseMeta.findDatabase( databases, XMLHandler.getTagValue( stepnode, "connection" ) );
    this.dimension = XMLHandler.getTagValue( stepnode, "dimension" );
    baseElementsOnly =
        ( XMLHandler.getTagValue( stepnode, "baseElementsOnly" ) == null ? false : XMLHandler.getTagValue( stepnode,
            "baseElementsOnly" ).equals( "Y" ) ? true : false );

    this.levels = new ArrayList<PaloDimensionLevel>();

    Node levels = XMLHandler.getSubNode( stepnode, "levels" );
    int nrLevels = XMLHandler.countNodes( levels, "level" );

    for ( int i = 0; i < nrLevels; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( levels, "level", i );

      String levelName = XMLHandler.getTagValue( fnode, "levelname" );
      String levelNumber = XMLHandler.getTagValue( fnode, "levelnumber" );
      String fieldName = XMLHandler.getTagValue( fnode, "fieldname" );
      String fieldType = XMLHandler.getTagValue( fnode, "fieldtype" );
      this.levels.add( new PaloDimensionLevel( levelName, Integer.parseInt( levelNumber ), fieldName, fieldType ) );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 8
Source File: RepositoryProxy.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private DatabaseMeta loadDatabaseMeta( String code, List<DatabaseMeta> databases ) throws KettleException {
  if ( DataNodeRef.REF_MISSING.equals( node.getProperty( code ).getRef().getId() )
      && System.getProperty( "kettle.allow_missing_refs" ) == null ) {
    throw new KettleException( BaseMessages.getString( PKG, "RepositoryProxy.ERROR_0001_MISSING_REF" ) );
  }
  ObjectId databaseId = new StringObjectId( node.getProperty( code ).getRef().getId().toString() );
  return DatabaseMeta.findDatabase( databases, databaseId );
}
 
Example 9
Source File: SlaveSequence.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public SlaveSequence( Node node, List<DatabaseMeta> databases ) throws KettleXMLException {
  name = XMLHandler.getTagValue( node, "name" );
  startValue = Const.toInt( XMLHandler.getTagValue( node, "start" ), 0 );
  databaseMeta = DatabaseMeta.findDatabase( databases, XMLHandler.getTagValue( node, "connection" ) );
  schemaName = XMLHandler.getTagValue( node, "schema" );
  tableName = XMLHandler.getTagValue( node, "table" );
  sequenceNameField = XMLHandler.getTagValue( node, "sequence_field" );
  valueField = XMLHandler.getTagValue( node, "value_field" );
}
 
Example 10
Source File: JobEntryTableExists.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadXML( Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers,
  Repository rep, IMetaStore metaStore ) throws KettleXMLException {
  try {
    super.loadXML( entrynode, databases, slaveServers );

    tablename = XMLHandler.getTagValue( entrynode, "tablename" );
    schemaname = XMLHandler.getTagValue( entrynode, "schemaname" );
    String dbname = XMLHandler.getTagValue( entrynode, "connection" );
    connection = DatabaseMeta.findDatabase( databases, dbname );
  } catch ( KettleException e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "TableExists.Meta.UnableLoadXml" ), e );
  }
}
 
Example 11
Source File: IngresVectorwiseLoaderMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {
  try {
    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );
    tablename = XMLHandler.getTagValue( stepnode, "table" );
    fifoFileName = XMLHandler.getTagValue( stepnode, "fifo_file_name" );
    sqlPath = XMLHandler.getTagValue( stepnode, "sql_path" );
    encoding = XMLHandler.getTagValue( stepnode, "encoding" );
    delimiter = XMLHandler.getTagValue( stepnode, "delimiter" );
    continueOnError = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "continue_on_error" ) );
    errorFileName = XMLHandler.getTagValue( stepnode, "error_file_name" );
    useStandardConversion = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_standard_conversion" ) );
    useAuthentication = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_authentication" ) );
    useDynamicVNode = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_dynamic_vnode" ) );
    useSSV = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_SSV_delimiter" ) );
    String escape = XMLHandler.getTagValue( stepnode, "escape_special_characters" );
    escapingSpecialCharacters = Utils.isEmpty( escape ) ? true : "Y".equalsIgnoreCase( escape );
    usingVwload = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_vwload" ) );
    maxNrErrors = XMLHandler.getTagValue( stepnode, "max_errors" );
    truncatingTable = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "truncate_table" ) );
    bufferSize = XMLHandler.getTagValue( stepnode, "buffer_size" );

    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    int nrRows = XMLHandler.countNodes( fields, "field" );

    allocate( nrRows );

    for ( int i = 0; i < nrRows; i++ ) {
      Node knode = XMLHandler.getSubNodeByNr( fields, "field", i );

      fieldDatabase[i] = XMLHandler.getTagValue( knode, "column_name" );
      fieldStream[i] = XMLHandler.getTagValue( knode, "stream_name" );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 12
Source File: CombinationLookupMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode, List<? extends SharedObjectInterface> databases ) throws KettleXMLException {
  this.databases = databases;
  try {
    String commit, csize;

    schemaName = XMLHandler.getTagValue( stepnode, "schema" );
    tablename = XMLHandler.getTagValue( stepnode, "table" );
    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );
    commit = XMLHandler.getTagValue( stepnode, "commit" );
    commitSize = Const.toInt( commit, 0 );
    csize = XMLHandler.getTagValue( stepnode, "cache_size" );
    cacheSize = Const.toInt( csize, 0 );

    replaceFields = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "replace" ) );
    preloadCache = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "preloadCache" ) );
    useHash = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "crc" ) );

    hashField = XMLHandler.getTagValue( stepnode, "crcfield" );

    Node keys = XMLHandler.getSubNode( stepnode, "fields" );
    int nrkeys = XMLHandler.countNodes( keys, "key" );

    allocate( nrkeys );

    // Read keys to dimension
    for ( int i = 0; i < nrkeys; i++ ) {
      Node knode = XMLHandler.getSubNodeByNr( keys, "key", i );
      keyField[ i ] = XMLHandler.getTagValue( knode, "name" );
      keyLookup[ i ] = XMLHandler.getTagValue( knode, "lookup" );
    }

    // If this is empty: use auto-increment field!
    sequenceFrom = XMLHandler.getTagValue( stepnode, "sequence" );

    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    Node retkey = XMLHandler.getSubNode( fields, "return" );
    technicalKeyField = XMLHandler.getTagValue( retkey, "name" );
    useAutoinc = !"N".equalsIgnoreCase( XMLHandler.getTagValue( retkey, "use_autoinc" ) );
    lastUpdateField = XMLHandler.getTagValue( stepnode, "last_update_field" );

    setTechKeyCreation( XMLHandler.getTagValue( retkey, "creation_method" ) );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "CombinationLookupMeta.Exception.UnableToLoadStepInfo" ), e );
  }
}
 
Example 13
Source File: DatabaseLookupMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode, List<? extends SharedObjectInterface> databases ) throws KettleXMLException {
  try {
    String dtype;
    String csize;

    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );
    cached = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "cache" ) );
    loadingAllDataInCache = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "cache_load_all" ) );
    csize = XMLHandler.getTagValue( stepnode, "cache_size" );
    cacheSize = Const.toInt( csize, 0 );
    schemaName = XMLHandler.getTagValue( stepnode, "lookup", "schema" );
    tablename = XMLHandler.getTagValue( stepnode, "lookup", "table" );

    Node lookup = XMLHandler.getSubNode( stepnode, "lookup" );

    int nrkeys = XMLHandler.countNodes( lookup, "key" );
    int nrvalues = XMLHandler.countNodes( lookup, "value" );

    allocate( nrkeys, nrvalues );

    for ( int i = 0; i < nrkeys; i++ ) {
      Node knode = XMLHandler.getSubNodeByNr( lookup, "key", i );

      streamKeyField1[i] = XMLHandler.getTagValue( knode, "name" );
      tableKeyField[i] = XMLHandler.getTagValue( knode, "field" );
      keyCondition[i] = XMLHandler.getTagValue( knode, "condition" );
      if ( keyCondition[i] == null ) {
        keyCondition[i] = "=";
      }
      streamKeyField2[i] = XMLHandler.getTagValue( knode, "name2" );
    }

    for ( int i = 0; i < nrvalues; i++ ) {
      Node vnode = XMLHandler.getSubNodeByNr( lookup, "value", i );

      returnValueField[i] = XMLHandler.getTagValue( vnode, "name" );
      returnValueNewName[i] = XMLHandler.getTagValue( vnode, "rename" );
      if ( returnValueNewName[i] == null ) {
        returnValueNewName[i] = returnValueField[i]; // default: the same name!
      }
      returnValueDefault[i] = XMLHandler.getTagValue( vnode, "default" );
      dtype = XMLHandler.getTagValue( vnode, "type" );
      returnValueDefaultType[i] = ValueMetaFactory.getIdForValueMeta( dtype );
      if ( returnValueDefaultType[i] < 0 ) {
        // logError("unknown default value type: "+dtype+" for value "+value[i]+", default to type: String!");
        returnValueDefaultType[i] = ValueMetaInterface.TYPE_STRING;
      }
    }
    orderByClause = XMLHandler.getTagValue( lookup, "orderby" ); // Optional, can by null
    failingOnMultipleResults = "Y".equalsIgnoreCase( XMLHandler.getTagValue( lookup, "fail_on_multiple" ) );
    eatingRowOnLookupFailure = "Y".equalsIgnoreCase( XMLHandler.getTagValue( lookup, "eat_row_on_failure" ) );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "DatabaseLookupMeta.ERROR0001.UnableToLoadStepFromXML" ), e );
  }
}
 
Example 14
Source File: InsertUpdateMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Injection( name = "CONNECTIONNAME" )
public void setConnection( String connectionName ) {
  databaseMeta = DatabaseMeta.findDatabase( databases, connectionName );
}
 
Example 15
Source File: InsertUpdateMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode, List<? extends SharedObjectInterface> databases ) throws KettleXMLException {
  this.databases = databases;
  try {
    String csize;
    int nrkeys, nrvalues;

    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );
    csize = XMLHandler.getTagValue( stepnode, "commit" );
    commitSize = ( csize != null ) ? csize : "0";
    schemaName = XMLHandler.getTagValue( stepnode, "lookup", "schema" );
    tableName = XMLHandler.getTagValue( stepnode, "lookup", "table" );
    updateBypassed = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "update_bypassed" ) );

    Node lookup = XMLHandler.getSubNode( stepnode, "lookup" );
    nrkeys = XMLHandler.countNodes( lookup, "key" );
    nrvalues = XMLHandler.countNodes( lookup, "value" );

    allocate( nrkeys, nrvalues );

    for ( int i = 0; i < nrkeys; i++ ) {
      Node knode = XMLHandler.getSubNodeByNr( lookup, "key", i );

      keyStream[i] = XMLHandler.getTagValue( knode, "name" );
      keyLookup[i] = XMLHandler.getTagValue( knode, "field" );
      keyCondition[i] = XMLHandler.getTagValue( knode, "condition" );
      if ( keyCondition[i] == null ) {
        keyCondition[i] = "=";
      }
      keyStream2[i] = XMLHandler.getTagValue( knode, "name2" );
    }

    for ( int i = 0; i < nrvalues; i++ ) {
      Node vnode = XMLHandler.getSubNodeByNr( lookup, "value", i );

      updateLookup[i] = XMLHandler.getTagValue( vnode, "name" );
      updateStream[i] = XMLHandler.getTagValue( vnode, "rename" );
      if ( updateStream[i] == null ) {
        updateStream[i] = updateLookup[i]; // default: the same name!
      }
      String updateValue = XMLHandler.getTagValue( vnode, "update" );
      if ( updateValue == null ) {
        // default TRUE
        update[i] = Boolean.TRUE;
      } else {
        if ( updateValue.equalsIgnoreCase( "Y" ) ) {
          update[i] = Boolean.TRUE;
        } else {
          update[i] = Boolean.FALSE;
        }
      }
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "InsertUpdateMeta.Exception.UnableToReadStepInfoFromXML" ), e );
  }
}
 
Example 16
Source File: ExecSQLRowMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Injection( name = "CONNECTION_NAME" )
public void setConnection( String connectionName ) {
  databaseMeta = DatabaseMeta.findDatabase( getDatabasesList(), connectionName );
}
 
Example 17
Source File: TableOutputMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode, List<? extends SharedObjectInterface> databases ) throws KettleXMLException {
  try {
    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );
    schemaName = XMLHandler.getTagValue( stepnode, "schema" );
    tableName = XMLHandler.getTagValue( stepnode, "table" );
    commitSize = XMLHandler.getTagValue( stepnode, "commit" );
    truncateTable = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "truncate" ) );
    ignoreErrors = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "ignore_errors" ) );
    useBatchUpdate = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_batch" ) );

    // If not present it will be false to be compatible with pre-v3.2
    specifyFields = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "specify_fields" ) );

    partitioningEnabled = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "partitioning_enabled" ) );
    partitioningField = XMLHandler.getTagValue( stepnode, "partitioning_field" );
    partitioningDaily = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "partitioning_daily" ) );
    partitioningMonthly = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "partitioning_monthly" ) );

    tableNameInField = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "tablename_in_field" ) );
    tableNameField = XMLHandler.getTagValue( stepnode, "tablename_field" );
    tableNameInTable = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "tablename_in_table" ) );

    returningGeneratedKeys = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "return_keys" ) );
    generatedKeyField = XMLHandler.getTagValue( stepnode, "return_field" );

    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    int nrRows = XMLHandler.countNodes( fields, "field" );

    allocate( nrRows );

    for ( int i = 0; i < nrRows; i++ ) {
      Node knode = XMLHandler.getSubNodeByNr( fields, "field", i );

      fieldDatabase[ i ] = XMLHandler.getTagValue( knode, "column_name" );
      fieldStream[ i ] = XMLHandler.getTagValue( knode, "stream_name" );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 18
Source File: TableInputMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Injection( name = "CONNECTIONNAME" )
public void setConnection( String connectionName ) {
  databaseMeta = DatabaseMeta.findDatabase( this.databases, connectionName );
}
 
Example 19
Source File: MetadataGenerator.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public Domain generatePhysicalMetadataModel() throws KettleException {

    // First do some checking and lookups...
    //
    String targetDatabaseName = ConceptUtil.getString(logicalDomain, DefaultIDs.DOMAIN_TARGET_DATABASE);
    if (Utils.isEmpty(targetDatabaseName)) {
      throw new KettleException("Please specify a target database!");
    }
    DatabaseMeta targetDatabaseMeta = DatabaseMeta.findDatabase(databases, targetDatabaseName);
    if (targetDatabaseMeta==null) {
      throw new KettleException("Target database with name '"+targetDatabaseName+"' can't be found!");
    }

    // Now start creation of a new domain with physical underpinning.
    //
    Domain domain = new Domain();

    // Copy the domain information...
    //
    domain.setId( createId("DOMAIN", null, domain) );
    domain.setName(logicalDomain.getName());
    domain.setDescription(logicalDomain.getDescription());

    // Now copy all the models...
    //
    for (LogicalModel logicalModel : logicalDomain.getLogicalModels()) {
      // Copy model information...
      //
      LogicalModel model = new LogicalModel();
      model.setId( createId("MODEL", domain, model));
      model.setName(logicalModel.getName());
      model.setDescription(logicalModel.getDescription());

      // Create a physical model...
      //
      SqlPhysicalModel sqlModel = new SqlPhysicalModel();
      sqlModel.setDatasource(createSqlDataSource(targetDatabaseMeta));
      model.setPhysicalModel(sqlModel);

      for (LogicalTable logicalTable : logicalModel.getLogicalTables()) {
        LogicalTable table = new LogicalTable();
        table.setId( createId("LOGICAL_TABLE", logicalModel, logicalTable) );
        table.setName(logicalTable.getName());
        table.setDescription(logicalTable.getDescription());

        String targetTable = ConceptUtil.getString(logicalTable, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME);

        SqlPhysicalTable sqlTable = new SqlPhysicalTable(sqlModel);
        table.setPhysicalTable(sqlTable);

        // Copy name & description from physical level...
        //
        sqlTable.setId( createId("PHYSICAL_TABLE", logicalModel, logicalTable));
        sqlTable.setName(logicalTable.getName());
        sqlTable.setDescription(logicalTable.getDescription());
        sqlTable.setTableType(ConceptUtil.getTableType(logicalTable));
        sqlTable.setTargetSchema(targetDatabaseMeta.getPreferredSchemaName());
        sqlTable.setTargetTable(targetTable);


      }
    }

    return domain;
  }
 
Example 20
Source File: OraBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Injection( name = "CONNECTION_NAME" )
public void setConnection( String connectionName ) {
  databaseMeta = DatabaseMeta.findDatabase( databases, connectionName );
}