Java Code Examples for org.pentaho.di.core.xml.XMLHandler#countNodes()

The following examples show how to use org.pentaho.di.core.xml.XMLHandler#countNodes() . 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: XMLInputField.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public XMLInputField( Node fnode ) throws KettleValueException {
  setName( XMLHandler.getTagValue( fnode, "name" ) );
  setType( ValueMeta.getType( XMLHandler.getTagValue( fnode, "type" ) ) );
  setFormat( XMLHandler.getTagValue( fnode, "format" ) );
  setCurrencySymbol( XMLHandler.getTagValue( fnode, "currency" ) );
  setDecimalSymbol( XMLHandler.getTagValue( fnode, "decimal" ) );
  setGroupSymbol( XMLHandler.getTagValue( fnode, "group" ) );
  setLength( Const.toInt( XMLHandler.getTagValue( fnode, "length" ), -1 ) );
  setPrecision( Const.toInt( XMLHandler.getTagValue( fnode, "precision" ), -1 ) );
  setTrimType( getTrimTypeByCode( XMLHandler.getTagValue( fnode, "trim_type" ) ) );
  setRepeated( !"N".equalsIgnoreCase( XMLHandler.getTagValue( fnode, "repeat" ) ) );

  Node positions = XMLHandler.getSubNode( fnode, "positions" );
  int nrPositions = XMLHandler.countNodes( positions, "position" );

  fieldPosition = new XMLInputFieldPosition[nrPositions];

  for ( int i = 0; i < nrPositions; i++ ) {
    Node positionnode = XMLHandler.getSubNodeByNr( positions, "position", i );
    String encoded = XMLHandler.getNodeValue( positionnode );
    fieldPosition[i] = new XMLInputFieldPosition( encoded );
  }
}
 
Example 2
Source File: FlattenerMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    fieldName = XMLHandler.getTagValue( stepnode, "field_name" );

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

    allocate( nrfields );

    for ( int i = 0; i < nrfields; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );
      targetField[i] = XMLHandler.getTagValue( fnode, "name" );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "FlattenerMeta.Exception.UnableToLoadStepInfoFromXML" ), e );
  }
}
 
Example 3
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 4
Source File: JobEntryDeleteFolders.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 );
    argFromPrevious = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "arg_from_previous" ) );
    success_condition = XMLHandler.getTagValue( entrynode, "success_condition" );
    limit_folders = XMLHandler.getTagValue( entrynode, "limit_folders" );

    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 );

      arguments[i] = XMLHandler.getTagValue( fnode, "name" );
    }
  } catch ( KettleXMLException xe ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JobEntryDeleteFolders.UnableToLoadFromXml" ), xe );
  }
}
 
Example 5
Source File: RandomCCNumberGeneratorMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    int count = XMLHandler.countNodes( fields, "field" );

    allocate( count );

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

      fieldCCType[i] = XMLHandler.getTagValue( fnode, "cctype" );
      fieldCCLength[i] = XMLHandler.getTagValue( fnode, "cclen" );
      fieldCCSize[i] = XMLHandler.getTagValue( fnode, "ccsize" );
    }

    cardNumberFieldName = XMLHandler.getTagValue( stepnode, "cardNumberFieldName" );
    cardLengthFieldName = XMLHandler.getTagValue( stepnode, "cardLengthFieldName" );
    cardTypeFieldName = XMLHandler.getTagValue( stepnode, "cardTypeFieldName" );
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to read step information from XML", e );
  }
}
 
Example 6
Source File: RandomValueMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    int count = XMLHandler.countNodes( fields, "field" );
    String type;

    allocate( count );

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

      fieldName[i] = XMLHandler.getTagValue( fnode, "name" );
      type = XMLHandler.getTagValue( fnode, "type" );
      fieldType[i] = getType( type );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to read step information from XML", e );
  }
}
 
Example 7
Source File: UnivariateStatsMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Loads the meta data for this (configured) step from XML.
 *
 * @param stepnode
 *          the step to load
 * @exception KettleXMLException
 *              if an error occurs
 */
@Override
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {

  int nrStats = XMLHandler.countNodes( stepnode, UnivariateStatsMetaFunction.XML_TAG );

  allocate( nrStats );
  for ( int i = 0; i < nrStats; i++ ) {
    Node statnode = XMLHandler.getSubNodeByNr( stepnode, UnivariateStatsMetaFunction.XML_TAG, i );
    m_stats[i] = new UnivariateStatsMetaFunction( statnode );
  }
}
 
Example 8
Source File: SlaveServer.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public List<SlaveServerDetection> getSlaveServerDetections() throws Exception {
  String xml = execService( GetSlavesServlet.CONTEXT_PATH + "/" );
  Document document = XMLHandler.loadXMLString( xml );
  Node detectionsNode = XMLHandler.getSubNode( document, GetSlavesServlet.XML_TAG_SLAVESERVER_DETECTIONS );
  int nrDetections = XMLHandler.countNodes( detectionsNode, SlaveServerDetection.XML_TAG );

  List<SlaveServerDetection> detections = new ArrayList<SlaveServerDetection>();
  for ( int i = 0; i < nrDetections; i++ ) {
    Node detectionNode = XMLHandler.getSubNodeByNr( detectionsNode, SlaveServerDetection.XML_TAG, i );
    SlaveServerDetection detection = new SlaveServerDetection( detectionNode );
    detections.add( detection );
  }
  return detections;
}
 
Example 9
Source File: FieldSplitterMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    splitField = XMLHandler.getTagValue( stepnode, "splitfield" );
    delimiter = XMLHandler.getTagValue( stepnode, "delimiter" );
    enclosure = XMLHandler.getTagValue( stepnode, "enclosure" );

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

    allocate( nrfields );

    for ( int i = 0; i < nrfields; i++ ) {
      final Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );

      fieldName[i] = XMLHandler.getTagValue( fnode, "name" );
      fieldID[i] = XMLHandler.getTagValue( fnode, "id" );
      final String sidrem = XMLHandler.getTagValue( fnode, "idrem" );
      final String stype = XMLHandler.getTagValue( fnode, "type" );
      fieldFormat[i] = XMLHandler.getTagValue( fnode, "format" );
      fieldGroup[i] = XMLHandler.getTagValue( fnode, "group" );
      fieldDecimal[i] = XMLHandler.getTagValue( fnode, "decimal" );
      fieldCurrency[i] = XMLHandler.getTagValue( fnode, "currency" );
      final String slen = XMLHandler.getTagValue( fnode, "length" );
      final String sprc = XMLHandler.getTagValue( fnode, "precision" );
      fieldNullIf[i] = XMLHandler.getTagValue( fnode, "nullif" );
      fieldIfNull[i] = XMLHandler.getTagValue( fnode, "ifnull" );
      final String trim = XMLHandler.getTagValue( fnode, "trimtype" );

      fieldRemoveID[i] = "Y".equalsIgnoreCase( sidrem );
      fieldType[i] = ValueMetaFactory.getIdForValueMeta( stype );
      fieldLength[i] = Const.toInt( slen, -1 );
      fieldPrecision[i] = Const.toInt( sprc, -1 );
      fieldTrimType[i] = ValueMetaString.getTrimTypeByCode( trim );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "FieldSplitterMeta.Exception.UnableToLoadStepInfoFromXML" ), e );
  }
}
 
Example 10
Source File: JsonOutputMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    outputValue = XMLHandler.getTagValue( stepnode, "outputValue" );
    jsonBloc = XMLHandler.getTagValue( stepnode, "jsonBloc" );
    nrRowsInBloc = XMLHandler.getTagValue( stepnode, "nrRowsInBloc" );
    operationType = getOperationTypeByCode( Const.NVL( XMLHandler.getTagValue( stepnode, "operation_type" ), "" ) );
    compatibilityMode = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "compatibility_mode" ) );

    encoding = XMLHandler.getTagValue( stepnode, "encoding" );
    AddToResult = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "AddToResult" ) );
    fileName = XMLHandler.getTagValue( stepnode, "file", "name" );
    createparentfolder = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "create_parent_folder" ) );
    extension = XMLHandler.getTagValue( stepnode, "file", "extention" );
    fileAppended = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "append" ) );
    stepNrInFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "split" ) );
    partNrInFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "haspartno" ) );
    dateInFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "add_date" ) );
    timeInFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "add_time" ) );
    DoNotOpenNewFileInit = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "DoNotOpenNewFileInit" ) );
    servletOutput = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "servlet_output" ) );

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

    allocate( nrfields );

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

      outputFields[i] = new JsonOutputField();
      outputFields[i].setFieldName( XMLHandler.getTagValue( fnode, "name" ) );
      outputFields[i].setElementName( XMLHandler.getTagValue( fnode, "element" ) );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 11
Source File: MultiMergeJoinMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {

    Node keysNode = XMLHandler.getSubNode( stepnode, "keys" );

    int nrKeys = XMLHandler.countNodes( keysNode, "key" );

    allocateKeys( nrKeys );

    for ( int i = 0; i < nrKeys; i++ ) {
      Node keynode = XMLHandler.getSubNodeByNr( keysNode, "key", i );
      keyFields[i] = XMLHandler.getNodeValue( keynode );
    }

    int nInputStreams = Integer.parseInt( XMLHandler.getTagValue( stepnode, "number_input" ) );

    allocateInputSteps( nInputStreams );

    for ( int i = 0; i < nInputStreams; i++ ) {
      inputSteps[i] = XMLHandler.getTagValue( stepnode, "step" + i );
    }

    joinType = XMLHandler.getTagValue( stepnode, "join_type" );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "MultiMergeJoinMeta.Exception.UnableToLoadStepInfo" ),
        e );
  }
}
 
Example 12
Source File: SynchronizeAfterMergeMeta.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 {
    int nrkeys, nrvalues;
    this.databases = databases;
    String con = XMLHandler.getTagValue( stepnode, "connection" );
    databaseMeta = DatabaseMeta.findDatabase( databases, con );
    commitSize = XMLHandler.getTagValue( stepnode, "commit" );
    schemaName = XMLHandler.getTagValue( stepnode, "lookup", "schema" );
    tableName = XMLHandler.getTagValue( stepnode, "lookup", "table" );

    useBatchUpdate = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_batch" ) );
    performLookup = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "perform_lookup" ) );

    tablenameInField = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "tablename_in_field" ) );
    tablenameField = XMLHandler.getTagValue( stepnode, "tablename_field" );
    operationOrderField = XMLHandler.getTagValue( stepnode, "operation_order_field" );
    OrderInsert = XMLHandler.getTagValue( stepnode, "order_insert" );
    OrderUpdate = XMLHandler.getTagValue( stepnode, "order_update" );
    OrderDelete = XMLHandler.getTagValue( stepnode, "order_delete" );

    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, "SynchronizeAfterMergeMeta.Exception.UnableToReadStepInfoFromXML" ), e );
  }
}
 
Example 13
Source File: BasePluginType.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected PluginInterface registerPluginFromXmlResource( Node pluginNode, String path,
  Class<? extends PluginTypeInterface> pluginType, boolean nativePlugin, URL pluginFolder ) throws KettlePluginException {
  try {

    String idAttr = XMLHandler.getTagAttribute( pluginNode, "id" );
    String description = getTagOrAttribute( pluginNode, "description" );
    String iconfile = getTagOrAttribute( pluginNode, "iconfile" );
    String tooltip = getTagOrAttribute( pluginNode, "tooltip" );
    String category = getTagOrAttribute( pluginNode, "category" );
    String classname = getTagOrAttribute( pluginNode, "classname" );
    String errorHelpfile = getTagOrAttribute( pluginNode, "errorhelpfile" );
    String documentationUrl = getTagOrAttribute( pluginNode, "documentation_url" );
    String casesUrl = getTagOrAttribute( pluginNode, "cases_url" );
    String forumUrl = getTagOrAttribute( pluginNode, "forum_url" );
    String suggestion = getTagOrAttribute( pluginNode, "suggestion" );

    Node libsnode = XMLHandler.getSubNode( pluginNode, "libraries" );
    int nrlibs = XMLHandler.countNodes( libsnode, "library" );

    List<String> jarFiles = new ArrayList<>();
    if ( path != null ) {
      for ( int j = 0; j < nrlibs; j++ ) {
        Node libnode = XMLHandler.getSubNodeByNr( libsnode, "library", j );
        String jarfile = XMLHandler.getTagAttribute( libnode, "name" );
        jarFiles.add( new File( path + Const.FILE_SEPARATOR + jarfile ).getAbsolutePath() );
      }
    }

    // Localized categories, descriptions and tool tips
    //
    Map<String, String> localizedCategories = readPluginLocale( pluginNode, "localized_category", "category" );
    category = getAlternativeTranslation( category, localizedCategories );

    Map<String, String> localDescriptions =
      readPluginLocale( pluginNode, "localized_description", "description" );
    description = getAlternativeTranslation( description, localDescriptions );
    description += addDeprecation( category );

    suggestion = getAlternativeTranslation( suggestion, localDescriptions );

    Map<String, String> localizedTooltips = readPluginLocale( pluginNode, "localized_tooltip", "tooltip" );
    tooltip = getAlternativeTranslation( tooltip, localizedTooltips );

    String iconFilename = ( path == null ) ? iconfile : path + Const.FILE_SEPARATOR + iconfile;
    String errorHelpFileFull = errorHelpfile;
    if ( !Utils.isEmpty( errorHelpfile ) ) {
      errorHelpFileFull = ( path == null ) ? errorHelpfile : path + Const.FILE_SEPARATOR + errorHelpfile;
    }

    Map<Class<?>, String> classMap = new HashMap<>();

    PluginMainClassType mainClassTypesAnnotation = pluginType.getAnnotation( PluginMainClassType.class );
    classMap.put( mainClassTypesAnnotation.value(), classname );

    // process annotated extra types
    PluginExtraClassTypes classTypesAnnotation = pluginType.getAnnotation( PluginExtraClassTypes.class );
    if ( classTypesAnnotation != null ) {
      for ( int i = 0; i < classTypesAnnotation.classTypes().length; i++ ) {
        Class<?> classType = classTypesAnnotation.classTypes()[i];
        String className = getTagOrAttribute( pluginNode, classTypesAnnotation.xmlNodeNames()[i] );

        classMap.put( classType, className );
      }
    }

    // process extra types added at runtime
    Map<Class<?>, String> objectMap = getAdditionalRuntimeObjectTypes();
    for ( Map.Entry<Class<?>, String> entry : objectMap.entrySet() ) {
      String clzName = getTagOrAttribute( pluginNode, entry.getValue() );
      classMap.put( entry.getKey(), clzName );
    }

    PluginInterface pluginInterface =
      new Plugin(
        idAttr.split( "," ), pluginType, mainClassTypesAnnotation.value(), category, description, tooltip,
        iconFilename, false, nativePlugin, classMap, jarFiles, errorHelpFileFull, pluginFolder,
        documentationUrl, casesUrl, forumUrl, suggestion );
    registry.registerPlugin( pluginType, pluginInterface );

    return pluginInterface;
  } catch ( Exception e ) {
    throw new KettlePluginException( BaseMessages.getString(
      PKG, "BasePluginType.RuntimeError.UnableToReadPluginXML.PLUGIN0001" ), e );
  }
}
 
Example 14
Source File: JobExecutorMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {
  try {
    String method = XMLHandler.getTagValue( stepnode, "specification_method" );
    specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode( method );
    String jobId = XMLHandler.getTagValue( stepnode, "job_object_id" );
    jobObjectId = Utils.isEmpty( jobId ) ? null : new StringObjectId( jobId );

    jobName = XMLHandler.getTagValue( stepnode, "job_name" );
    fileName = XMLHandler.getTagValue( stepnode, "filename" );
    directoryPath = XMLHandler.getTagValue( stepnode, "directory_path" );

    groupSize = XMLHandler.getTagValue( stepnode, "group_size" );
    groupField = XMLHandler.getTagValue( stepnode, "group_field" );
    groupTime = XMLHandler.getTagValue( stepnode, "group_time" );

    // Load the mapping parameters too..
    //
    Node mappingParametersNode = XMLHandler.getSubNode( stepnode, JobExecutorParameters.XML_TAG );
    parameters = new JobExecutorParameters( mappingParametersNode );

    // The output side...
    //
    executionResultTargetStep = XMLHandler.getTagValue( stepnode, "execution_result_target_step" );
    executionTimeField = XMLHandler.getTagValue( stepnode, "execution_time_field" );
    executionResultField = XMLHandler.getTagValue( stepnode, "execution_result_field" );
    executionNrErrorsField = XMLHandler.getTagValue( stepnode, "execution_errors_field" );
    executionLinesReadField = XMLHandler.getTagValue( stepnode, "execution_lines_read_field" );
    executionLinesWrittenField = XMLHandler.getTagValue( stepnode, "execution_lines_written_field" );
    executionLinesInputField = XMLHandler.getTagValue( stepnode, "execution_lines_input_field" );
    executionLinesOutputField = XMLHandler.getTagValue( stepnode, "execution_lines_output_field" );
    executionLinesRejectedField = XMLHandler.getTagValue( stepnode, "execution_lines_rejected_field" );
    executionLinesUpdatedField = XMLHandler.getTagValue( stepnode, "execution_lines_updated_field" );
    executionLinesDeletedField = XMLHandler.getTagValue( stepnode, "execution_lines_deleted_field" );
    executionFilesRetrievedField = XMLHandler.getTagValue( stepnode, "execution_files_retrieved_field" );
    executionExitStatusField = XMLHandler.getTagValue( stepnode, "execution_exit_status_field" );
    executionLogTextField = XMLHandler.getTagValue( stepnode, "execution_log_text_field" );
    executionLogChannelIdField = XMLHandler.getTagValue( stepnode, "execution_log_channelid_field" );

    resultRowsTargetStep = XMLHandler.getTagValue( stepnode, "result_rows_target_step" );

    int nrFields = XMLHandler.countNodes( stepnode, "result_rows_field" );
    resultRowsField = new String[nrFields];
    resultRowsType = new int[nrFields];
    resultRowsLength = new int[nrFields];
    resultRowsPrecision = new int[nrFields];

    for ( int i = 0; i < nrFields; i++ ) {

      Node fieldNode = XMLHandler.getSubNodeByNr( stepnode, "result_rows_field", i );

      resultRowsField[i] = XMLHandler.getTagValue( fieldNode, "name" );
      resultRowsType[i] = ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( fieldNode, "type" ) );
      resultRowsLength[i] = Const.toInt( XMLHandler.getTagValue( fieldNode, "length" ), -1 );
      resultRowsPrecision[i] = Const.toInt( XMLHandler.getTagValue( fieldNode, "precision" ), -1 );
    }

    resultFilesTargetStep = XMLHandler.getTagValue( stepnode, "result_files_target_step" );
    resultFilesFileNameField = XMLHandler.getTagValue( stepnode, "result_files_file_name_field" );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "JobExecutorMeta.Exception.ErrorLoadingJobExecutorDetailsFromXML" ), e );
  }
}
 
Example 15
Source File: MetaInjectMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {
  try {

    String method = XMLHandler.getTagValue( stepnode, SPECIFICATION_METHOD );
    specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode( method );
    String transId = XMLHandler.getTagValue( stepnode, TRANS_OBJECT_ID );
    transObjectId = Utils.isEmpty( transId ) ? null : new StringObjectId( transId );

    transName = XMLHandler.getTagValue( stepnode, TRANS_NAME );
    fileName = XMLHandler.getTagValue( stepnode, FILENAME );
    directoryPath = XMLHandler.getTagValue( stepnode, DIRECTORY_PATH );

    sourceStepName = XMLHandler.getTagValue( stepnode, SOURCE_STEP );
    Node outputFieldsNode = XMLHandler.getSubNode( stepnode, SOURCE_OUTPUT_FIELDS );
    List<Node> outputFieldNodes = XMLHandler.getNodes( outputFieldsNode, SOURCE_OUTPUT_FIELD );
    sourceOutputFields = new ArrayList<MetaInjectOutputField>();
    for ( Node outputFieldNode : outputFieldNodes ) {
      String name = XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_NAME );
      String typeName = XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_TYPE );
      int length = Const.toInt( XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_LENGTH ), -1 );
      int precision = Const.toInt( XMLHandler.getTagValue( outputFieldNode, SOURCE_OUTPUT_FIELD_PRECISION ), -1 );
      int type = ValueMetaFactory.getIdForValueMeta( typeName );
      sourceOutputFields.add( new MetaInjectOutputField( name, type, length, precision ) );
    }

    targetFile = XMLHandler.getTagValue( stepnode, TARGET_FILE );
    noExecution = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, NO_EXECUTION ) );

    streamSourceStepname = XMLHandler.getTagValue( stepnode, STREAM_SOURCE_STEP );
    streamTargetStepname = XMLHandler.getTagValue( stepnode, STREAM_TARGET_STEP );

    Node mappingsNode = XMLHandler.getSubNode( stepnode, MAPPINGS );
    int nrMappings = XMLHandler.countNodes( mappingsNode, MAPPING );
    for ( int i = 0; i < nrMappings; i++ ) {
      Node mappingNode = XMLHandler.getSubNodeByNr( mappingsNode, MAPPING, i );
      String targetStepname = XMLHandler.getTagValue( mappingNode, TARGET_STEP_NAME );
      String targetAttributeKey = XMLHandler.getTagValue( mappingNode, TARGET_ATTRIBUTE_KEY );
      boolean targetDetail = "Y".equalsIgnoreCase( XMLHandler.getTagValue( mappingNode, TARGET_DETAIL ) );
      String sourceStepname = XMLHandler.getTagValue( mappingNode, SOURCE_STEP );
      String sourceField = XMLHandler.getTagValue( mappingNode, SOURCE_FIELD );

      TargetStepAttribute target = new TargetStepAttribute( targetStepname, targetAttributeKey, targetDetail );
      SourceStepField source = new SourceStepField( sourceStepname, sourceField );
      targetSourceMapping.put( target, source );
    }

    MetaInjectMigration.migrateFrom70( targetSourceMapping );
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 16
Source File: Mapping.java    From pentaho-hadoop-shims with Apache License 2.0 4 votes vote down vote up
public boolean loadXML( Node stepnode ) throws KettleXMLException {
  stepnode = XMLHandler.getSubNode( stepnode, "mapping" );

  if ( stepnode == null
    || Const.isEmpty( XMLHandler.getTagValue( stepnode, "key" ) ) ) {
    return false; // no mapping info in XML
  }

  setMappingName( XMLHandler.getTagValue( stepnode, "mapping_name" ) );
  setTableName( XMLHandler.getTagValue( stepnode, "table_name" ) );

  String keyName = XMLHandler.getTagValue( stepnode, "key" );
  if ( keyName.indexOf( ',' ) > 0 ) {
    setTupleMapping( true );
    setKeyName( keyName.substring( 0, keyName.indexOf( ',' ) ) );
    if ( keyName.indexOf( ',' ) != keyName.length() - 1 ) {
      // specific families have been supplied
      String familiesList = keyName.substring( keyName.indexOf( ',' ) + 1,
        keyName.length() );
      if ( !Const.isEmpty( familiesList.trim() ) ) {
        setTupleFamilies( familiesList );
      }
    }
  } else {
    setKeyName( keyName );
  }

  String keyTypeS = XMLHandler.getTagValue( stepnode, "key_type" );
  for ( KeyType k : KeyType.values() ) {
    if ( k.toString().equalsIgnoreCase( keyTypeS ) ) {
      setKeyType( k );
      break;
    }
  }

  Node fields = XMLHandler.getSubNode( stepnode, "mapped_columns" );
  if ( fields != null && XMLHandler.countNodes( fields, "mapped_column" ) > 0 ) {
    int nrfields = XMLHandler.countNodes( fields, "mapped_column" );

    for ( int i = 0; i < nrfields; i++ ) {
      Node fieldNode = XMLHandler.getSubNodeByNr( fields, "mapped_column", i );
      String alias = XMLHandler.getTagValue( fieldNode, "alias" );
      String colFam = XMLHandler.getTagValue( fieldNode, "column_family" );
      if ( colFam == null ) {
        colFam = "";
      }
      String colName = XMLHandler.getTagValue( fieldNode, "column_name" );
      if ( colName == null ) {
        colName = "";
      }
      String type = XMLHandler.getTagValue( fieldNode, "type" );
      String combined = colFam + HBaseValueMeta.SEPARATOR + colName
        + HBaseValueMeta.SEPARATOR + alias;
      HBaseValueMeta hbvm = new HBaseValueMeta( combined, 0, -1, -1 );
      hbvm.setHBaseTypeFromString( type );

      String indexedV = XMLHandler.getTagValue( fieldNode, "indexed_vals" );
      if ( !Const.isEmpty( indexedV ) ) {
        Object[] nomVals = HBaseValueMeta.stringIndexListToObjects( indexedV );
        hbvm.setIndex( nomVals );
        hbvm.setStorageType( ValueMetaInterface.STORAGE_TYPE_INDEXED );
      }

      try {
        addMappedColumn( hbvm, isTupleMapping() );
      } catch ( Exception ex ) {
        throw new KettleXMLException( ex );
      }
    }
  }

  return true;
}
 
Example 17
Source File: MailMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode ) {
  setServer( XMLHandler.getTagValue( stepnode, "server" ) );
  setPort( XMLHandler.getTagValue( stepnode, "port" ) );
  setDestination( XMLHandler.getTagValue( stepnode, "destination" ) );
  setDestinationCc( XMLHandler.getTagValue( stepnode, "destinationCc" ) );
  setDestinationBCc( XMLHandler.getTagValue( stepnode, "destinationBCc" ) );
  setReplyToAddresses( XMLHandler.getTagValue( stepnode, "replyToAddresses" ) );
  setReplyAddress( XMLHandler.getTagValue( stepnode, "replyto" ) );
  setReplyName( XMLHandler.getTagValue( stepnode, "replytoname" ) );
  setSubject( XMLHandler.getTagValue( stepnode, "subject" ) );
  setIncludeDate( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include_date" ) ) );
  setIncludeSubFolders( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include_subfolders" ) ) );
  setZipFilenameDynamic( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "zipFilenameDynamic" ) ) );
  setisDynamicFilename( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "isFilenameDynamic" ) ) );
  setDynamicFieldname( XMLHandler.getTagValue( stepnode, "dynamicFieldname" ) );
  setDynamicWildcard( XMLHandler.getTagValue( stepnode, "dynamicWildcard" ) );
  setAttachContentFromField( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "attachContentFromField" ) ) );
  setAttachContentField( XMLHandler.getTagValue( stepnode, "attachContentField" ) );
  setAttachContentFileNameField( XMLHandler.getTagValue( stepnode, "attachContentFileNameField" ) );

  setDynamicZipFilenameField( XMLHandler.getTagValue( stepnode, "dynamicZipFilename" ) );
  setSourceFileFoldername( XMLHandler.getTagValue( stepnode, "sourcefilefoldername" ) );
  setSourceWildcard( XMLHandler.getTagValue( stepnode, "sourcewildcard" ) );
  setContactPerson( XMLHandler.getTagValue( stepnode, "contact_person" ) );
  setContactPhone( XMLHandler.getTagValue( stepnode, "contact_phone" ) );
  setComment( XMLHandler.getTagValue( stepnode, "comment" ) );
  setIncludingFiles( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include_files" ) ) );
  setUsingAuthentication( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_auth" ) ) );
  setUsingSecureAuthentication( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_secure_auth" ) ) );
  setAuthenticationUser( XMLHandler.getTagValue( stepnode, "auth_user" ) );
  setAuthenticationPassword( Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue(
    stepnode, "auth_password" ) ) );
  setOnlySendComment( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "only_comment" ) ) );
  setUseHTML( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_HTML" ) ) );
  setUsePriority( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "use_Priority" ) ) );
  setEncoding( XMLHandler.getTagValue( stepnode, "encoding" ) );
  setPriority( XMLHandler.getTagValue( stepnode, "priority" ) );
  setImportance( XMLHandler.getTagValue( stepnode, "importance" ) );
  setSensitivity( XMLHandler.getTagValue( stepnode, "sensitivity" ) );
  setSecureConnectionType( XMLHandler.getTagValue( stepnode, "secureconnectiontype" ) );
  setZipFiles( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "zip_files" ) ) );
  setZipFilename( XMLHandler.getTagValue( stepnode, "zip_name" ) );
  setZipLimitSize( XMLHandler.getTagValue( stepnode, "zip_limit_size" ) );

  Node images = XMLHandler.getSubNode( stepnode, "embeddedimages" );
  // How many field embedded images ?
  int nrImages = XMLHandler.countNodes( images, "embeddedimage" );

  allocate( nrImages );

  // Read them all...
  for ( int i = 0; i < nrImages; i++ ) {
    Node fnode = XMLHandler.getSubNodeByNr( images, "embeddedimage", i );

    embeddedimages[i] = XMLHandler.getTagValue( fnode, "image_name" );
    contentids[i] = XMLHandler.getTagValue( fnode, "content_id" );
  }
}
 
Example 18
Source File: MailInputMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode ) {
  servername = XMLHandler.getTagValue( stepnode, "servername" );
  username = XMLHandler.getTagValue( stepnode, "username" );
  password = Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( stepnode, "password" ) );
  usessl = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "usessl" ) );
  sslport = XMLHandler.getTagValue( stepnode, "sslport" );
  retrievemails = Const.toInt( XMLHandler.getTagValue( stepnode, "retrievemails" ), -1 );
  firstmails = XMLHandler.getTagValue( stepnode, "firstmails" );
  delete = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "delete" ) );

  protocol = Const.NVL( XMLHandler.getTagValue( stepnode, "protocol" ), MailConnectionMeta.PROTOCOL_STRING_POP3 );
  valueimaplist =
    MailConnectionMeta.getValueImapListByCode( Const.NVL(
      XMLHandler.getTagValue( stepnode, "valueimaplist" ), "" ) );
  imapfirstmails = XMLHandler.getTagValue( stepnode, "imapfirstmails" );
  imapfolder = XMLHandler.getTagValue( stepnode, "imapfolder" );
  // search term
  senderSearch = XMLHandler.getTagValue( stepnode, "sendersearch" );
  notTermSenderSearch = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "nottermsendersearch" ) );
  recipientSearch = XMLHandler.getTagValue( stepnode, "recipientsearch" );
  notTermRecipientSearch = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "notTermRecipientSearch" ) );
  subjectSearch = XMLHandler.getTagValue( stepnode, "subjectsearch" );
  notTermSubjectSearch = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "nottermsubjectsearch" ) );
  conditionReceivedDate =
    MailConnectionMeta.getConditionByCode( Const.NVL( XMLHandler.getTagValue(
      stepnode, "conditionreceiveddate" ), "" ) );
  notTermReceivedDateSearch =
    "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "nottermreceiveddatesearch" ) );
  receivedDate1 = XMLHandler.getTagValue( stepnode, "receivedDate1" );
  receivedDate2 = XMLHandler.getTagValue( stepnode, "receivedDate2" );
  includesubfolders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "includesubfolders" ) );
  usedynamicfolder = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "usedynamicfolder" ) );
  folderfield = XMLHandler.getTagValue( stepnode, "folderfield" );
  proxyusername = XMLHandler.getTagValue( stepnode, "proxyusername" );
  useproxy = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "useproxy" ) );
  useBatch = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, Tags.USE_BATCH ) );
  try {
    batchSize = Integer.parseInt( XMLHandler.getTagValue( stepnode, Tags.BATCH_SIZE ) );
  } catch ( NumberFormatException e ) {
    batchSize = DEFAULT_BATCH_SIZE;
  }
  start = XMLHandler.getTagValue( stepnode, Tags.START_MSG );
  end = XMLHandler.getTagValue( stepnode, Tags.END_MSG );
  stopOnError = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, Tags.STOP_ON_ERROR ) );

  rowlimit = XMLHandler.getTagValue( stepnode, "rowlimit" );
  Node fields = XMLHandler.getSubNode( stepnode, "fields" );
  int nrFields = XMLHandler.countNodes( fields, "field" );

  allocate( nrFields );
  for ( int i = 0; i < nrFields; i++ ) {
    Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );
    inputFields[i] = new MailInputField();
    inputFields[i].setName( XMLHandler.getTagValue( fnode, "name" ) );
    inputFields[i].setColumn( MailInputField.getColumnByCode( XMLHandler.getTagValue( fnode, "column" ) ) );
  }
}
 
Example 19
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 20
Source File: XMLInputMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    includeFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include" ) );
    filenameField = XMLHandler.getTagValue( stepnode, "include_field" );
    includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) );
    rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" );
    fileBaseURI = XMLHandler.getTagValue( stepnode, "file_base_uri" );
    ignoreEntities = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "ignore_entities" ) );
    namespaceAware = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "namespace_aware" ) );

    Node filenode = XMLHandler.getSubNode( stepnode, "file" );
    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    Node positions = XMLHandler.getSubNode( stepnode, "positions" );
    int nrFiles = XMLHandler.countNodes( filenode, "name" );
    int nrFields = XMLHandler.countNodes( fields, "field" );
    int nrPositions = XMLHandler.countNodes( positions, "position" );

    allocate( nrFiles, nrFields, nrPositions );

    for ( int i = 0; i < nrFiles; i++ ) {
      Node filenamenode = XMLHandler.getSubNodeByNr( filenode, "name", i );
      Node filemasknode = XMLHandler.getSubNodeByNr( filenode, "filemask", i );
      fileName[i] = XMLHandler.getNodeValue( filenamenode );
      fileMask[i] = XMLHandler.getNodeValue( filemasknode );
    }

    for ( int i = 0; i < nrFields; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );
      XMLInputField field = new XMLInputField( fnode );
      inputFields[i] = field;
    }

    for ( int i = 0; i < nrPositions; i++ ) {
      Node positionnode = XMLHandler.getSubNodeByNr( positions, "position", i );
      inputPosition[i] = XMLHandler.getNodeValue( positionnode );
    }

    // Is there a limit on the number of rows we process?
    rowLimit = Const.toLong( XMLHandler.getTagValue( stepnode, "limit" ), 0L );
    // Do we skip rows before starting to read
    nrRowsToSkip = Const.toInt( XMLHandler.getTagValue( stepnode, "skip" ), 0 );
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}