Java Code Examples for org.pentaho.di.trans.TransMeta#environmentSubstitute()

The following examples show how to use org.pentaho.di.trans.TransMeta#environmentSubstitute() . 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: MappingMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<ResourceReference>( 5 );
  String realFilename = transMeta.environmentSubstitute( fileName );
  String realTransname = transMeta.environmentSubstitute( transName );
  ResourceReference reference = new ResourceReference( stepInfo );
  references.add( reference );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceType.ACTIONFILE ) );
  } else if ( !Utils.isEmpty( realTransname ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realTransname, ResourceType.ACTIONFILE ) );
    references.add( reference );
  }
  return references;
}
 
Example 2
Source File: GPBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
  IMetaStore metaStore ) throws KettleStepException {
  if ( prev != null ) {
    /* DEBUG CHECK THIS */
    // Insert dateMask fields : read/write
    for ( int i = 0; i < fieldTable.length; i++ ) {
      ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );

      DatabaseImpact ii =
        new DatabaseImpact(
          DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(), databaseMeta
            .getDatabaseName(), transMeta.environmentSubstitute( tableName ), fieldTable[i],
          fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta() );
      impact.add( ii );
    }
  }
}
 
Example 3
Source File: MetaInjectMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<ResourceReference>( 5 );
  String realFilename = transMeta.environmentSubstitute( fileName );
  String realTransname = transMeta.environmentSubstitute( transName );
  String realDirectoryPath = transMeta.environmentSubstitute( directoryPath );
  ResourceReference reference = new ResourceReference( stepInfo );
  references.add( reference );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceType.ACTIONFILE ) );
  } else if ( !Utils.isEmpty( realTransname ) ) {
    // Add the trans name (including full repository path) to dependencies
    String realTransformation = realDirectoryPath + "/" + realTransname;
    reference.getEntries().add( new ResourceEntry( realTransformation, ResourceType.ACTIONFILE ) );
  }
  return references;
}
 
Example 4
Source File: LucidDBBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
  IMetaStore metaStore ) throws KettleStepException {
  if ( prev != null ) {
    /* DEBUG CHECK THIS */
    // Insert dateMask fields : read/write
    for ( int i = 0; i < fieldTable.length; i++ ) {
      ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );

      DatabaseImpact ii =
        new DatabaseImpact(
          DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(), databaseMeta
            .getDatabaseName(), transMeta.environmentSubstitute( tableName ), fieldTable[i],
          fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta() );
      impact.add( ii );
    }
  }
}
 
Example 5
Source File: GPLoadMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
    RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
    IMetaStore metaStore ) throws KettleStepException {
  if ( prev != null ) {
    /* DEBUG CHECK THIS */
    // Insert dateMask fields : read/write
    for ( int i = 0; i < fieldTable.length; i++ ) {
      ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );

      DatabaseImpact ii =
          new DatabaseImpact( DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(),
              databaseMeta.getDatabaseName(), transMeta.environmentSubstitute( tableName ), fieldTable[i],
              fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta() );
      impact.add( ii );
    }
  }
}
 
Example 6
Source File: BaseStreamStepMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<>( 5 );
  String realFilename = transMeta.environmentSubstitute( transformationPath );
  ResourceReference reference = new ResourceReference( stepInfo );
  references.add( reference );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceEntry.ResourceType.ACTIONFILE ) );
  }

  return references;
}
 
Example 7
Source File: MySQLBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
    RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
    IMetaStore metaStore ) throws KettleStepException {
  if ( prev != null ) {
    /* DEBUG CHECK THIS */
    // Insert dateMask fields : read/write
    for ( int i = 0; i < fieldTable.length; i++ ) {
      ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );

      DatabaseImpact ii =
          new DatabaseImpact( DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(),
              databaseMeta.getDatabaseName(), transMeta.environmentSubstitute( tableName ), fieldTable[i],
              fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta() );
      impact.add( ii );
    }
  }
}
 
Example 8
Source File: OraBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
  IMetaStore metaStore ) throws KettleStepException {
  if ( prev != null ) {
    /* DEBUG CHECK THIS */
    // Insert dateMask fields : read/write
    for ( int i = 0; i < fieldTable.length; i++ ) {
      ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );

      DatabaseImpact ii =
        new DatabaseImpact(
          DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(), databaseMeta
            .getDatabaseName(), transMeta.environmentSubstitute( tableName ), fieldTable[i],
          fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta() );
      impact.add( ii );
    }
  }
}
 
Example 9
Source File: SimpleMappingMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<ResourceReference>( 5 );
  String realFilename = transMeta.environmentSubstitute( fileName );
  String realTransname = transMeta.environmentSubstitute( transName );
  ResourceReference reference = new ResourceReference( stepInfo );
  references.add( reference );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceType.ACTIONFILE ) );
  } else if ( !Utils.isEmpty( realTransname ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realTransname, ResourceType.ACTIONFILE ) );
    references.add( reference );
  }
  return references;
}
 
Example 10
Source File: MonetDBBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
    RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
    IMetaStore metaStore ) throws KettleStepException {
  if ( prev != null ) {
    /* DEBUG CHECK THIS */
    // Insert dateMask fields : read/write
    for ( int i = 0; i < fieldTable.length; i++ ) {
      ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );

      DatabaseImpact ii =
          new DatabaseImpact(
              DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(), databaseMeta
              .getDatabaseName(), transMeta.environmentSubstitute( tableName ), fieldTable[i],
              fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta() );
      impact.add( ii );
    }
  }
}
 
Example 11
Source File: JobExecutorMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<ResourceReference>( 5 );
  String realFilename = transMeta.environmentSubstitute( fileName );
  String realTransname = transMeta.environmentSubstitute( jobName );
  ResourceReference reference = new ResourceReference( stepInfo );
  references.add( reference );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceType.ACTIONFILE ) );
  } else if ( !Utils.isEmpty( realTransname ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realTransname, ResourceType.ACTIONFILE ) );
    references.add( reference );
  }
  return references;
}
 
Example 12
Source File: SingleThreaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<ResourceReference>( 5 );
  String realFilename = transMeta.environmentSubstitute( fileName );
  String realTransname = transMeta.environmentSubstitute( transName );
  ResourceReference reference = new ResourceReference( stepInfo );
  references.add( reference );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceType.ACTIONFILE ) );
  } else if ( !Utils.isEmpty( realTransname ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realTransname, ResourceType.ACTIONFILE ) );
    references.add( reference );
  }
  return references;
}
 
Example 13
Source File: PGBulkLoaderMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
  IMetaStore metaStore ) throws KettleStepException {
  if ( prev != null ) {
    /* DEBUG CHECK THIS */
    // Insert dateMask fields : read/write
    for ( int i = 0; i < fieldTable.length; i++ ) {
      ValueMetaInterface v = prev.searchValueMeta( fieldStream[i] );

      DatabaseImpact ii =
        new DatabaseImpact(
          DatabaseImpact.TYPE_IMPACT_READ_WRITE, transMeta.getName(), stepMeta.getName(), databaseMeta
            .getDatabaseName(), transMeta.environmentSubstitute( tableName ), fieldTable[i],
          fieldStream[i], v != null ? v.getOrigin() : "?", "", "Type = " + v.toStringMeta() );
      impact.add( ii );
    }
  }
}
 
Example 14
Source File: DatabaseJoinMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void analyseImpact( List<DatabaseImpact> impact, TransMeta transMeta, StepMeta stepMeta,
  RowMetaInterface prev, String[] input, String[] output, RowMetaInterface info, Repository repository,
  IMetaStore metaStore ) throws KettleStepException {

  // Find the lookupfields...
  //
  RowMetaInterface out = prev.clone();
  getFields( out, stepMeta.getName(), new RowMetaInterface[] { info, }, null, transMeta, repository, metaStore );

  if ( out != null ) {
    for ( int i = 0; i < out.size(); i++ ) {
      ValueMetaInterface outvalue = out.getValueMeta( i );
      DatabaseImpact di =
        new DatabaseImpact(
          DatabaseImpact.TYPE_IMPACT_READ, transMeta.getName(), stepMeta.getName(),
          databaseMeta.getDatabaseName(), "", outvalue.getName(), outvalue.getName(), stepMeta.getName(),
          transMeta.environmentSubstitute( sql ),
          BaseMessages.getString( PKG, "DatabaseJoinMeta.DatabaseImpact.Title" ) );
      impact.add( di );

    }
  }
}
 
Example 15
Source File: TransExecutorMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies( TransMeta transMeta, StepMeta stepInfo ) {
  List<ResourceReference> references = new ArrayList<ResourceReference>( 5 );
  String realFilename = transMeta.environmentSubstitute( fileName );
  String realTransname = transMeta.environmentSubstitute( transName );
  String realDirectoryPath = transMeta.environmentSubstitute( directoryPath );
  ResourceReference reference = new ResourceReference( stepInfo );

  if ( !Utils.isEmpty( realFilename ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    reference.getEntries().add( new ResourceEntry( realFilename, ResourceType.ACTIONFILE ) );
  } else if ( !Utils.isEmpty( realTransname ) ) {
    // Add the filename to the references, including a reference to this step
    // meta data.
    //
    String realTransformation = realDirectoryPath + "/" + transName;
    reference.getEntries().add( new ResourceEntry( realTransformation, ResourceType.ACTIONFILE ) );
  }
  references.add( reference );
  return references;
}
 
Example 16
Source File: CsvInputMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public FileObject getHeaderFileObject( final TransMeta transMeta ) {
  final String filename = transMeta.environmentSubstitute( getFilename() );
  try {
    return KettleVFS.getFileObject( filename );
  } catch ( final KettleFileException e ) {
    return null;
  }
}
 
Example 17
Source File: GetXMLDataExternalResourceConsumer.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<IExternalResourceInfo> getResourcesFromMeta( GetXMLDataMeta meta, IAnalysisContext context ) {
  Collection<IExternalResourceInfo> resources = Collections.emptyList();

  // We only need to collect these resources if we're not data-driven and there are no used variables in the
  // metadata relating to external files.
  if ( !isDataDriven( meta ) ) {
    StepMeta parentStepMeta = meta.getParentStepMeta();
    if ( parentStepMeta != null ) {
      TransMeta parentTransMeta = parentStepMeta.getParentTransMeta();
      if ( parentTransMeta != null ) {
        String[] paths = parentTransMeta.environmentSubstitute( meta.getFileName() );
        if ( paths != null ) {
          resources = new ArrayList<IExternalResourceInfo>( paths.length );

          for ( String path : paths ) {
            if ( !Utils.isEmpty( path ) ) {
              try {

                IExternalResourceInfo resource = ExternalResourceInfoFactory
                  .createFileResource( KettleVFS.getFileObject( path ), true );
                if ( resource != null ) {
                  resources.add( resource );
                } else {
                  throw new KettleFileException( "Error getting file resource!" );
                }
              } catch ( KettleFileException kfe ) {
                // TODO throw or ignore?
              }
            }
          }
        }
      }
    }
  }
  return resources;
}
 
Example 18
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 4 votes vote down vote up
private void saveUnitTest( MetaStoreFactory<TransUnitTest> testFactory, TransUnitTest unitTest, TransMeta transMeta ) throws MetaStoreException {

    // Build relative path whenever a transformation is saved
    //
    if ( StringUtils.isNotEmpty( transMeta.getFilename() ) ) {
      // Set the filename to be safe
      //
      unitTest.setTransFilename( transMeta.getFilename() );

      String basePath = unitTest.getBasePath();
      if ( StringUtils.isEmpty( basePath ) ) {
        basePath = transMeta.getVariable( DataSetConst.VARIABLE_UNIT_TESTS_BASE_PATH );
      }
      basePath = transMeta.environmentSubstitute( basePath );
      if ( StringUtils.isNotEmpty( basePath ) ) {
        // See if the basePath is present in the filename
        // Then replace the filename
        //
        try {
          FileObject baseFolder = KettleVFS.getFileObject( basePath );
          FileObject transFile = KettleVFS.getFileObject( transMeta.getFilename() );
          FileObject parent = transFile.getParent();
          while ( parent != null ) {
            if ( parent.equals( baseFolder ) ) {
              // Here we are, we found the base folder in the transformation file
              //
              String transFilename = transFile.toString();
              String baseFoldername = parent.toString();

              // Final validation & unit test filename correction
              //
              if ( transFilename.startsWith( baseFoldername ) ) {
                String relativeFile = transFilename.substring( baseFoldername.length() );
                String filename;
                if ( relativeFile.startsWith( "/" ) ) {
                  filename = "." + relativeFile;
                } else {
                  filename = "./" + relativeFile;
                }
                // Set the transformation filename to the relative path
                //
                unitTest.setTransFilename( filename );
                LogChannel.GENERAL.logBasic( "Unit test '" + unitTest.getName() + "' : Saved relative path to transformation: " + filename );
              }
            }
            parent = parent.getParent();
          }
        } catch ( Exception e ) {
          throw new MetaStoreException( "Error calculating relative unit test file path", e );
        }
      }
    }

    testFactory.saveElement( unitTest );
  }