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

The following examples show how to use org.pentaho.di.core.xml.XMLHandler#getSubNodeByNr() . 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: JobEntryDeleteFiles.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" ) );
    includeSubfolders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "include_subfolders" ) );

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

    int numberOfFields = XMLHandler.countNodes( fields, "field" );
    allocate( numberOfFields );

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

      arguments[i] = XMLHandler.getTagValue( fnode, "name" );
      filemasks[i] = XMLHandler.getTagValue( fnode, "filemask" );
    }
  } catch ( KettleXMLException xe ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JobEntryDeleteFiles.UnableToLoadFromXml" ), xe );
  }
}
 
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: StepsMetricsMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    Node steps = XMLHandler.getSubNode( stepnode, "steps" );
    int nrsteps = XMLHandler.countNodes( steps, "step" );

    allocate( nrsteps );

    for ( int i = 0; i < nrsteps; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( steps, "step", i );
      stepName[i] = XMLHandler.getTagValue( fnode, "name" );
      stepCopyNr[i] = XMLHandler.getTagValue( fnode, "copyNr" );
      stepRequired[i] = XMLHandler.getTagValue( fnode, "stepRequired" );
    }
    stepnamefield = XMLHandler.getTagValue( stepnode, "stepnamefield" );
    stepidfield = XMLHandler.getTagValue( stepnode, "stepidfield" );
    steplinesinputfield = XMLHandler.getTagValue( stepnode, "steplinesinputfield" );
    steplinesoutputfield = XMLHandler.getTagValue( stepnode, "steplinesoutputfield" );
    steplinesreadfield = XMLHandler.getTagValue( stepnode, "steplinesreadfield" );
    steplinesupdatedfield = XMLHandler.getTagValue( stepnode, "steplinesupdatedfield" );
    steplineswrittentfield = XMLHandler.getTagValue( stepnode, "steplineswrittentfield" );
    steplineserrorsfield = XMLHandler.getTagValue( stepnode, "steplineserrorsfield" );
    stepsecondsfield = XMLHandler.getTagValue( stepnode, "stepsecondsfield" );
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 4
Source File: SetValueFieldMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode, List<? extends SharedObjectInterface> databases ) 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 );

      fieldName[i] = XMLHandler.getTagValue( fnode, "name" );
      replaceByFieldValue[i] = XMLHandler.getTagValue( fnode, "replaceby" );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "SetValueFieldMeta.Exception.UnableToReadStepInfoFromXML" ), e );
  }
}
 
Example 5
Source File: FixedInputMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    filename = XMLHandler.getTagValue( stepnode, "filename" );
    lineWidth = XMLHandler.getTagValue( stepnode, "line_width" );
    bufferSize = XMLHandler.getTagValue( stepnode, "buffer_size" );
    headerPresent = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "header" ) );
    lineFeedPresent = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "line_feed" ) );
    lazyConversionActive = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "lazy_conversion" ) );
    runningInParallel = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "parallel" ) );
    fileType = getFileType( XMLHandler.getTagValue( stepnode, "file_type" ) );
    encoding = XMLHandler.getTagValue( stepnode, "encoding" );
    isaddresult = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "add_to_result_filenames" ) );

    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 );
      fieldDefinition[i] = new FixedFileInputField( fnode );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 6
Source File: FunctionDescription.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public FunctionDescription( Node node ) {
  this.category = XMLHandler.getTagValue( node, "category" );
  this.name = XMLHandler.getTagValue( node, "name" );
  this.description = XMLHandler.getTagValue( node, "description" );
  this.syntax = XMLHandler.getTagValue( node, "syntax" );
  this.returns = XMLHandler.getTagValue( node, "returns" );
  this.constraints = XMLHandler.getTagValue( node, "constraints" );
  this.semantics = XMLHandler.getTagValue( node, "semantics" );

  this.functionExamples = new ArrayList<FunctionExample>();

  Node examplesNode = XMLHandler.getSubNode( node, "examples" );
  int nrExamples = XMLHandler.countNodes( examplesNode, FunctionExample.XML_TAG );
  for ( int i = 0; i < nrExamples; i++ ) {
    Node exampleNode = XMLHandler.getSubNodeByNr( examplesNode, FunctionExample.XML_TAG, i );
    this.functionExamples.add( new FunctionExample( exampleNode ) );
  }
}
 
Example 7
Source File: JobEntryColumnsExist.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 );
    tablename = XMLHandler.getTagValue( entrynode, "tablename" );
    schemaname = XMLHandler.getTagValue( entrynode, "schemaname" );

    String dbname = XMLHandler.getTagValue( entrynode, "connection" );
    connection = DatabaseMeta.findDatabase( databases, dbname );

    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 ( KettleException e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JobEntryColumnsExist.Meta.UnableLoadXml" ), e );
  }
}
 
Example 8
Source File: RowLevelSecurity.java    From pentaho-metadata with GNU Lesser General Public License v2.1 5 votes vote down vote up
public RowLevelSecurity( Node rlsNode ) throws Exception {
  String typeString = rlsNode.getAttributes().getNamedItem( ATTR_TYPE ).getTextContent();
  if ( ATTR_VALUE_GLOBAL.equals( typeString ) ) {
    type = Type.GLOBAL;
  } else if ( ATTR_VALUE_ROLE_BASED.equals( typeString ) ) {
    type = Type.ROLEBASED;
  } else {
    type = Type.NONE;
  }
  // global
  Node globalFormulaNode = XMLHandler.getSubNode( rlsNode, ELEM_FORMULA );
  globalConstraint = globalFormulaNode.getTextContent();
  // role-based
  Map<SecurityOwner, String> map = new HashMap<SecurityOwner, String>();
  Node entriesNode = XMLHandler.getSubNode( rlsNode, ELEM_ENTRIES );
  int entryCount = XMLHandler.countNodes( entriesNode, ELEM_ENTRY );
  for ( int i = 0; i < entryCount; i++ ) {
    Node entryNode = XMLHandler.getSubNodeByNr( entriesNode, ELEM_ENTRY, i );
    Node ownerNode = XMLHandler.getSubNode( entryNode, ELEM_OWNER );
    // build owner using its node constructor
    SecurityOwner owner = new SecurityOwner( ownerNode );
    Node formulaNode = XMLHandler.getSubNode( entryNode, ELEM_FORMULA );
    String formula = formulaNode.getTextContent();
    map.put( owner, formula );
  }
  roleBasedConstraintMap = map;

}
 
Example 9
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 10
Source File: ConstantMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    int nrfields = XMLHandler.countNodes( fields, "field" );

    allocate( nrfields );

    String slength, sprecision;

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

      fieldName[i] = XMLHandler.getTagValue( fnode, "name" );
      fieldType[i] = XMLHandler.getTagValue( fnode, "type" );
      fieldFormat[i] = XMLHandler.getTagValue( fnode, "format" );
      currency[i] = XMLHandler.getTagValue( fnode, "currency" );
      decimal[i] = XMLHandler.getTagValue( fnode, "decimal" );
      group[i] = XMLHandler.getTagValue( fnode, "group" );
      value[i] = XMLHandler.getTagValue( fnode, "nullif" );
      slength = XMLHandler.getTagValue( fnode, "length" );
      sprecision = XMLHandler.getTagValue( fnode, "precision" );

      fieldLength[i] = Const.toInt( slength, -1 );
      fieldPrecision[i] = Const.toInt( sprecision, -1 );
      String emptyString = XMLHandler.getTagValue( fnode, "set_empty_string" );
      setEmptyString[i] = !Utils.isEmpty( emptyString ) && "Y".equalsIgnoreCase( emptyString );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 11
Source File: BaseLogTable.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadFieldsXML( Node node ) {
  int nr = XMLHandler.countNodes( node, BaseLogTable.XML_TAG );
  for ( int i = 0; i < nr; i++ ) {
    Node fieldNode = XMLHandler.getSubNodeByNr( node, BaseLogTable.XML_TAG, i );
    String id = XMLHandler.getTagValue( fieldNode, "id" );
    LogTableField field = findField( id );
    if ( field == null && i < fields.size() ) {
      field = fields.get( i ); // backward compatible until we go GA
    }
    if ( field != null ) {
      field.setFieldName( XMLHandler.getTagValue( fieldNode, "name" ) );
      field.setEnabled( "Y".equalsIgnoreCase( XMLHandler.getTagValue( fieldNode, "enabled" ) ) );
    }
  }
}
 
Example 12
Source File: JobEntryCopyFiles.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 );
    copy_empty_folders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "copy_empty_folders" ) );
    arg_from_previous = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "arg_from_previous" ) );
    overwrite_files = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "overwrite_files" ) );
    include_subfolders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "include_subfolders" ) );
    remove_source_files = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "remove_source_files" ) );
    add_result_filesname = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "add_result_filesname" ) );
    destination_is_a_file = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "destination_is_a_file" ) );
    create_destination_folder =
      "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "create_destination_folder" ) );

    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 );
      source_filefolder[i] = loadSource( fnode );
      destination_filefolder[i] = loadDestination( fnode );
      wildcard[i] = XMLHandler.getTagValue( fnode, "wildcard" );
    }
  } catch ( KettleXMLException xe ) {

    throw new KettleXMLException(
      BaseMessages.getString( PKG, "JobCopyFiles.Error.Exception.UnableLoadXML" ), xe );
  }
}
 
Example 13
Source File: MappingParameters.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public MappingParameters( Node paramNode ) {

    int nrVariables = XMLHandler.countNodes( paramNode, XML_VARIABLES_TAG );
    variable = new String[nrVariables];
    input = new String[nrVariables];

    for ( int i = 0; i < variable.length; i++ ) {
      Node variableMappingNode = XMLHandler.getSubNodeByNr( paramNode, XML_VARIABLES_TAG, i );

      variable[i] = XMLHandler.getTagValue( variableMappingNode, "variable" );
      input[i] = XMLHandler.getTagValue( variableMappingNode, "input" );
    }

    inheritingAllVariables = "Y".equalsIgnoreCase( XMLHandler.getTagValue( paramNode, "inherit_all_vars" ) );
  }
 
Example 14
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 15
Source File: JobEntryTrans.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
@Override
public void loadXML( Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers,
                     Repository rep, IMetaStore metaStore ) throws KettleXMLException {
  try {
    super.loadXML( entrynode, databases, slaveServers );

    String method = XMLHandler.getTagValue( entrynode, "specification_method" );
    specificationMethod = ObjectLocationSpecificationMethod.getSpecificationMethodByCode( method );

    String transId = XMLHandler.getTagValue( entrynode, "trans_object_id" );
    transObjectId = Utils.isEmpty( transId ) ? null : new StringObjectId( transId );
    filename = XMLHandler.getTagValue( entrynode, "filename" );
    transname = XMLHandler.getTagValue( entrynode, "transname" );
    directory = XMLHandler.getTagValue( entrynode, "directory" );

    if ( rep != null && rep.isConnected() && !Utils.isEmpty( transname ) ) {
      specificationMethod = ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME;
    }

    // Backward compatibility check for object specification
    //
    checkObjectLocationSpecificationMethod();

    argFromPrevious = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "arg_from_previous" ) );
    paramsFromPrevious = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "params_from_previous" ) );
    execPerRow = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "exec_per_row" ) );
    clearResultRows = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "clear_rows" ) );
    clearResultFiles = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "clear_files" ) );
    setLogfile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "set_logfile" ) );
    addDate = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "add_date" ) );
    addTime = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "add_time" ) );
    logfile = XMLHandler.getTagValue( entrynode, "logfile" );
    logext = XMLHandler.getTagValue( entrynode, "logext" );
    logFileLevel = LogLevel.getLogLevelForCode( XMLHandler.getTagValue( entrynode, "loglevel" ) );
    clustering = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "cluster" ) );
    createParentFolder = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "create_parent_folder" ) );
    loggingRemoteWork = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "logging_remote_work" ) );
    runConfiguration = XMLHandler.getTagValue( entrynode, "run_configuration" );
    setSuppressResultData( "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "suppress_result_data" ) ) );

    remoteSlaveServerName = XMLHandler.getTagValue( entrynode, "slave_server_name" );

    setAppendLogfile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "set_append_logfile" ) );
    String wait = XMLHandler.getTagValue( entrynode, "wait_until_finished" );
    if ( Utils.isEmpty( wait ) ) {
      waitingToFinish = true;
    } else {
      waitingToFinish = "Y".equalsIgnoreCase( wait );
    }

    followingAbortRemotely = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "follow_abort_remote" ) );

    // How many arguments?
    int argnr = 0;
    while ( XMLHandler.getTagValue( entrynode, "argument" + argnr ) != null ) {
      argnr++;
    }
    allocateArgs( argnr );

    // Read them all...
    for ( int a = 0; a < argnr; a++ ) {
      arguments[ a ] = XMLHandler.getTagValue( entrynode, "argument" + a );
    }

    Node parametersNode = XMLHandler.getSubNode( entrynode, "parameters" );

    String passAll = XMLHandler.getTagValue( parametersNode, "pass_all_parameters" );
    passingAllParameters = Utils.isEmpty( passAll ) || "Y".equalsIgnoreCase( passAll );

    int nrParameters = XMLHandler.countNodes( parametersNode, "parameter" );
    allocateParams( nrParameters );

    for ( int i = 0; i < nrParameters; i++ ) {
      Node knode = XMLHandler.getSubNodeByNr( parametersNode, "parameter", i );

      parameters[ i ] = XMLHandler.getTagValue( knode, "name" );
      parameterFieldNames[ i ] = XMLHandler.getTagValue( knode, "stream_name" );
      parameterValues[ i ] = XMLHandler.getTagValue( knode, "value" );
    }
  } catch ( KettleException e ) {
    throw new KettleXMLException( "Unable to load job entry of type 'trans' from XML node", e );
  }
}
 
Example 16
Source File: JsonInputMeta.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" );
    addResultFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "addresultfile" ) );
    readurl = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "readurl" ) );
    removeSourceField = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "removeSourceField" ) );
    isIgnoreEmptyFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "IsIgnoreEmptyFile" ) );
    ignoreMissingPath = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "ignoreMissingPath" ) );
    defaultPathLeafToNull = getDefaultPathLeafToNull( stepnode );
    doNotFailIfNoFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "doNotFailIfNoFile" ) );
    includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) );
    rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" );

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

    initArrayFields( nrFiles, nrFields );

    for ( int i = 0; i < nrFiles; i++ ) {
      Node filenamenode = XMLHandler.getSubNodeByNr( filenode, "name", i );
      Node filemasknode = XMLHandler.getSubNodeByNr( filenode, "filemask", i );
      Node excludefilemasknode = XMLHandler.getSubNodeByNr( filenode, "exclude_filemask", i );
      Node fileRequirednode = XMLHandler.getSubNodeByNr( filenode, "file_required", i );
      Node includeSubFoldersnode = XMLHandler.getSubNodeByNr( filenode, "include_subfolders", i );
      getFileName()[i] = XMLHandler.getNodeValue( filenamenode );
      getFileMask()[i] = XMLHandler.getNodeValue( filemasknode );
      getExcludeFileMask()[i] = XMLHandler.getNodeValue( excludefilemasknode );
      getFileRequired()[i] = XMLHandler.getNodeValue( fileRequirednode );
      getIncludeSubFolders()[i] = XMLHandler.getNodeValue( includeSubFoldersnode );
    }

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

    // Is there a limit on the number of rows we process?
    rowLimit = Const.toLong( XMLHandler.getTagValue( stepnode, "limit" ), 0L );

    setInFields( "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "IsInFields" ) ) );
    isAFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "IsAFile" ) );
    setFieldValue( XMLHandler.getTagValue( stepnode, "valueField" ) );
    setShortFileNameField( XMLHandler.getTagValue( stepnode, "shortFileFieldName" ) );
    setPathField( XMLHandler.getTagValue( stepnode, "pathFieldName" ) );
    setIsHiddenField( XMLHandler.getTagValue( stepnode, "hiddenFieldName" ) );
    setLastModificationDateField( XMLHandler.getTagValue( stepnode, "lastModificationTimeFieldName" ) );
    setUriField( XMLHandler.getTagValue( stepnode, "uriNameFieldName" ) );
    setRootUriField( XMLHandler.getTagValue( stepnode, "rootUriNameFieldName" ) );
    setExtensionField( XMLHandler.getTagValue( stepnode, "extensionFieldName" ) );
    setSizeField( XMLHandler.getTagValue( stepnode, "sizeFieldName" ) );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JsonInputMeta.Exception.ErrorLoadingXML", e
        .toString() ) );
  }
}
 
Example 17
Source File: SpoonSlave.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
protected void sniff() {
  TreeItem[] ti = wTree.getSelection();
  if ( ti.length == 1 ) {
    TreeItem treeItem = ti[0];
    String[] path = ConstUI.getTreeStrings( treeItem );

    // Make sure we're positioned on a step
    if ( path.length <= 2 ) {
      return;
    }

    String name = path[1];
    String step = path[2];
    String copy = treeItem.getText( 1 );

    EnterNumberDialog numberDialog = new EnterNumberDialog( shell, PropsUI.getInstance().getDefaultPreviewSize(),
      BaseMessages.getString( PKG, "SpoonSlave.SniffSizeQuestion.Title" ),
      BaseMessages.getString( PKG, "SpoonSlave.SniffSizeQuestion.Message" ) );
    int lines = numberDialog.open();
    if ( lines <= 0 ) {
      return;
    }

    EnterSelectionDialog selectionDialog = new EnterSelectionDialog( shell,
      new String[] { SniffStepServlet.TYPE_INPUT, SniffStepServlet.TYPE_OUTPUT, },
      BaseMessages.getString( PKG, "SpoonSlave.SniffTypeQuestion.Title" ),
      BaseMessages.getString( PKG, "SpoonSlave.SniffTypeQuestion.Message" ) );
    String type = selectionDialog.open( 1 );
    if ( type == null ) {
      return;
    }

    try {
      String xml = slaveServer.sniffStep( name, step, copy, lines, type );

      Document doc = XMLHandler.loadXMLString( xml );
      Node node = XMLHandler.getSubNode( doc, SniffStepServlet.XML_TAG );
      Node metaNode = XMLHandler.getSubNode( node, RowMeta.XML_META_TAG );
      RowMetaInterface rowMeta = new RowMeta( metaNode );

      int nrRows = Const.toInt( XMLHandler.getTagValue( node, "nr_rows" ), 0 );
      List<Object[]> rowBuffer = new ArrayList<Object[]>();
      for ( int i = 0; i < nrRows; i++ ) {
        Node dataNode = XMLHandler.getSubNodeByNr( node, RowMeta.XML_DATA_TAG, i );
        Object[] row = rowMeta.getRow( dataNode );
        rowBuffer.add( row );
      }

      PreviewRowsDialog prd = new PreviewRowsDialog( shell, new Variables(), SWT.NONE, step, rowMeta, rowBuffer );
      prd.open();
    } catch ( Exception e ) {
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "SpoonSlave.ErrorSniffingStep.Title" ),
        BaseMessages.getString( PKG, "SpoonSlave.ErrorSniffingStep.Message" ), e );
    }
  }
}
 
Example 18
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 19
Source File: YamlInputMeta.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" );

    addResultFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "addresultfile" ) );
    validating = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "validating" ) );
    IsIgnoreEmptyFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "IsIgnoreEmptyFile" ) );
    doNotFailIfNoFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "doNotFailIfNoFile" ) );

    includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) );
    rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" );
    encoding = XMLHandler.getTagValue( stepnode, "encoding" );

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

    allocate( nrFiles, nrFields );

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

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

    // Is there a limit on the number of rows we process?
    rowLimit = Const.toLong( XMLHandler.getTagValue( stepnode, "limit" ), 0L );
    inFields = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "IsInFields" ) );
    IsAFile = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "IsAFile" ) );
    yamlField = XMLHandler.getTagValue( stepnode, "YamlField" );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "YamlInputMeta.Exception.ErrorLoadingXML", e
      .toString() ) );
  }
}
 
Example 20
Source File: ReservoirSamplingMeta.java    From pentaho-kettle with Apache License 2.0 3 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
 */
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {

  int nrSteps = XMLHandler.countNodes( stepnode, XML_TAG );

  if ( nrSteps > 0 ) {
    Node reservoirnode = XMLHandler.getSubNodeByNr( stepnode, XML_TAG, 0 );

    m_sampleSize = XMLHandler.getTagValue( reservoirnode, "sample_size" );
    m_randomSeed = XMLHandler.getTagValue( reservoirnode, "seed" );

  }
}