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

The following examples show how to use org.pentaho.di.core.xml.XMLHandler#getSubNode() . 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: RepositoryImporter.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean transformationElementRead( String xml, RepositoryImportFeedbackInterface feedback ) {
  try {
    Document doc = XMLHandler.loadXMLString( getOrCreateDb(), xml );
    Node transformationNode = XMLHandler.getSubNode( doc, RepositoryExportSaxParser.STRING_TRANSFORMATION );
    if ( !importTransformation( transformationNode, feedback ) ) {
      return false;
    }
    transformationNumber++;
  } catch ( Exception e ) {
    // Some unexpected error occurred during transformation import
    // This is usually a problem with a missing plugin or something
    // like that...
    //
    feedback.showError( BaseMessages.getString( PKG,
        "RepositoryImporter.UnexpectedErrorDuringTransformationImport.Title" ), BaseMessages.getString( PKG,
        "RepositoryImporter.UnexpectedErrorDuringTransformationImport.Message" ), e );

    if ( !feedback.askContinueOnErrorQuestion( BaseMessages.getString( PKG,
        "RepositoryImporter.DoYouWantToContinue.Title" ), BaseMessages.getString( PKG,
        "RepositoryImporter.DoYouWantToContinue.Message" ) ) ) {
      return false;
    }
  }
  return true;
}
 
Example 2
Source File: RulesExecutorMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void loadXML( Node stepnode, List<DatabaseMeta> _databases, IMetaStore metaStore ) throws KettleXMLException {
  try {
    Node fields = XMLHandler.getSubNode( stepnode, StorageKeys.NODE_FIELDS.toString() );
    int nrfields = XMLHandler.countNodes( fields, StorageKeys.SUBNODE_FIELD.toString() );

    ValueMetaInterface vm = null;
    for ( int i = 0; i < nrfields; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( fields, StorageKeys.SUBNODE_FIELD.toString(), i );

      String name = XMLHandler.getTagValue( fnode, StorageKeys.COLUMN_NAME.toString() );
      int type = ValueMeta.getType( XMLHandler.getTagValue( fnode, StorageKeys.COLUMN_TYPE.toString() ) );

      vm = ValueMetaFactory.createValueMeta( name, type );
      getRuleResultColumns().add( vm );
    }

    setRuleFile( XMLHandler.getTagValue( stepnode, StorageKeys.RULE_FILE.toString() ) );
    setRuleDefinition( XMLHandler.getTagValue( stepnode, StorageKeys.RULE_DEFINITION.toString() ) );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "RulesMeta.Error.LoadFromXML" ), e );
  }
}
 
Example 3
Source File: SecurityService.java    From pentaho-metadata with GNU Lesser General Public License v2.1 6 votes vote down vote up
public List<SecurityACL> getAcls() {
  List<SecurityACL> acls = new ArrayList<SecurityACL>();
  if ( hasService() || hasFile() ) {
    try {
      Node contentNode = getContent( getURL( null ) );

      // Load the ACLs
      Node aclsNode = XMLHandler.getSubNode( contentNode, "acls" ); //$NON-NLS-1$
      int nrAcls = XMLHandler.countNodes( aclsNode, "acl" ); //$NON-NLS-1$
      for ( int i = 0; i < nrAcls; i++ ) {
        Node aclNode = XMLHandler.getSubNodeByNr( aclsNode, "acl", i ); //$NON-NLS-1$
        SecurityACL acl = new SecurityACL( aclNode );
        acls.add( acl );
      }
      Collections.sort( acls ); // sort by acl mask, from low to high
    } catch ( PentahoMetadataException ex ) {
      log.logError(
          Messages.getString( "SecurityReference.ERROR_0001_CANT_CREATE_REFERENCE_FROM_XML" ), ex.getLocalizedMessage() ); //$NON-NLS-1$
    } catch ( Exception e ) {
      log.logError(
          Messages.getString( "SecurityReference.ERROR_0001_CANT_CREATE_REFERENCE_FROM_XML" ), e.getLocalizedMessage() ); //$NON-NLS-1$
    }
  }
  return acls;
}
 
Example 4
Source File: JobEntryCheckFilesLocked.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_ATTR ) );
    includeSubfolders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, INCLUDE_SUBFOLDERS_ATTR ) );

    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_ATTR );
      filemasks[i] = XMLHandler.getTagValue( fnode, FILE_MASK_ATTR );
    }
  } catch ( KettleXMLException xe ) {
    throw new KettleXMLException(
      BaseMessages.getString( PKG, "JobEntryCheckFilesLocked.UnableToLoadFromXml" ), xe );
  }
}
 
Example 5
Source File: GetSubFoldersMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) );
    isFoldernameDynamic = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "foldername_dynamic" ) );
    rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" );
    dynamicFoldernameField = XMLHandler.getTagValue( stepnode, "foldername_field" );

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

    Node filenode = XMLHandler.getSubNode( stepnode, "file" );
    int nrfiles = XMLHandler.countNodes( filenode, "name" );

    allocate( nrfiles );

    for ( int i = 0; i < nrfiles; i++ ) {
      Node folderNamenode = XMLHandler.getSubNodeByNr( filenode, "name", i );
      Node folderRequirednode = XMLHandler.getSubNodeByNr( filenode, "file_required", i );
      folderName[i] = XMLHandler.getNodeValue( folderNamenode );
      folderRequired[i] = XMLHandler.getNodeValue( folderRequirednode );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 6
Source File: SortedMergeMeta.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 nrfields = XMLHandler.countNodes( fields, "field" );

    allocate( nrfields );

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

      fieldName[i] = XMLHandler.getTagValue( fnode, "name" );
      String asc = XMLHandler.getTagValue( fnode, "ascending" );
      if ( asc.equalsIgnoreCase( "Y" ) ) {
        ascending[i] = true;
      } else {
        ascending[i] = false;
      }
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 7
Source File: JobEntryCheckDbConnections.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 );
    Node fields = XMLHandler.getSubNode( entrynode, "connections" );

    // How many hosts?
    int nrFields = XMLHandler.countNodes( fields, "connection" );
    connections = new DatabaseMeta[nrFields];
    waitfors = new String[nrFields];
    waittimes = new int[nrFields];
    // Read them all...
    for ( int i = 0; i < nrFields; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( fields, "connection", i );
      String dbname = XMLHandler.getTagValue( fnode, "name" );
      connections[i] = DatabaseMeta.findDatabase( databases, dbname );
      waitfors[i] = XMLHandler.getTagValue( fnode, "waitfor" );
      waittimes[i] = getWaitByCode( Const.NVL( XMLHandler.getTagValue( fnode, "waittime" ), "" ) );
    }
  } catch ( KettleXMLException xe ) {
    throw new KettleXMLException( BaseMessages.getString(
      PKG, "JobEntryCheckDbConnections.ERROR_0001_Cannot_Load_Job_Entry_From_Xml_Node", xe.getMessage() ) );
  }
}
 
Example 8
Source File: AddXMLMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    encoding = XMLHandler.getTagValue( stepnode, "encoding" );
    valueName = XMLHandler.getTagValue( stepnode, "valueName" );
    rootNode = XMLHandler.getTagValue( stepnode, "xml_repeat_element" );

    omitXMLheader = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "omitXMLheader" ) );
    omitNullValues = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "file", "omitNullValues" ) );

    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 XMLField();
      outputFields[i].setFieldName( XMLHandler.getTagValue( fnode, "name" ) );
      outputFields[i].setElementName( XMLHandler.getTagValue( fnode, "element" ) );
      outputFields[i].setType( XMLHandler.getTagValue( fnode, "type" ) );
      outputFields[i].setFormat( XMLHandler.getTagValue( fnode, "format" ) );
      outputFields[i].setCurrencySymbol( XMLHandler.getTagValue( fnode, "currency" ) );
      outputFields[i].setDecimalSymbol( XMLHandler.getTagValue( fnode, "decimal" ) );
      outputFields[i].setGroupingSymbol( XMLHandler.getTagValue( fnode, "group" ) );
      outputFields[i].setNullString( XMLHandler.getTagValue( fnode, "nullif" ) );
      outputFields[i].setLength( Const.toInt( XMLHandler.getTagValue( fnode, "length" ), -1 ) );
      outputFields[i].setPrecision( Const.toInt( XMLHandler.getTagValue( fnode, "precision" ), -1 ) );
      outputFields[i].setAttribute( "Y".equalsIgnoreCase( XMLHandler.getTagValue( fnode, "attribute" ) ) );
      outputFields[i].setAttributeParentName( XMLHandler.getTagValue( fnode, "attributeParentName" ) );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 9
Source File: SecurityService.java    From pentaho-metadata with GNU Lesser General Public License v2.1 5 votes vote down vote up
public List<String> getRoles() {
  List<String> roles = new ArrayList<String>();
  if ( hasService() || hasFile() ) {
    try {

      if ( getDetailServiceType() == SecurityService.SERVICE_TYPE_ROLES || getDetailServiceType() == SERVICE_TYPE_ALL ) {
        String url = getURL( serviceTypeCodes[SERVICE_TYPE_ROLES] );
        Node contentNode = getContent( url );
        String rolesNode = "roles";
        if ( serviceURL.endsWith( "ServiceAction" ) ) {
          contentNode = XMLHandler.getSubNode( contentNode, rolesNode ); //$NON-NLS-1$
          rolesNode = "role";
        }

        // Load the roles
        int nrRoles = XMLHandler.countNodes( contentNode, rolesNode ); //$NON-NLS-1$
        for ( int i = 0; i < nrRoles; i++ ) {
          Node roleNode = XMLHandler.getSubNodeByNr( contentNode, rolesNode, i ); //$NON-NLS-1$
          String rolename = XMLHandler.getNodeValue( roleNode );
          if ( rolename != null ) {
            roles.add( rolename );
          }
        }
      }
    } catch ( PentahoMetadataException ex ) {
      log.logError( Messages.getString( "SecurityReference.ERROR_0001_CANT_CREATE_REFERENCE_FROM_XML" ), ex ); //$NON-NLS-1$
    } catch ( Exception e ) {
      log.logError( Messages.getString( "SecurityReference.ERROR_0001_CANT_CREATE_REFERENCE_FROM_XML" ), e ); //$NON-NLS-1$
    }
  }
  return roles;
}
 
Example 10
Source File: S3CsvInputMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    awsAccessKey = Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( stepnode, "aws_access_key" ) );
    awsSecretKey = Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( stepnode, "aws_secret_key" ) );
    bucket = XMLHandler.getTagValue( stepnode, "bucket" );
    filename = XMLHandler.getTagValue( stepnode, "filename" );
    filenameField = XMLHandler.getTagValue( stepnode, "filename_field" );
    rowNumField = XMLHandler.getTagValue( stepnode, "rownum_field" );
    includingFilename = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "include_filename" ) );
    delimiter = XMLHandler.getTagValue( stepnode, "separator" );
    enclosure = XMLHandler.getTagValue( stepnode, "enclosure" );
    maxLineSize = XMLHandler.getTagValue( stepnode, "max_line_size" );
    headerPresent = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "header" ) );
    lazyConversionActive = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "lazy_conversion" ) );
    runningInParallel = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "parallel" ) );
    Node fields = XMLHandler.getSubNode( stepnode, "fields" );
    int nrfields = XMLHandler.countNodes( fields, "field" );

    allocate( nrfields );

    for ( int i = 0; i < nrfields; i++ ) {
      inputFields[i] = new TextFileInputField();

      Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );

      inputFields[i].setName( XMLHandler.getTagValue( fnode, "name" ) );
      inputFields[i].setType( ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( fnode, "type" ) ) );
      inputFields[i].setFormat( XMLHandler.getTagValue( fnode, "format" ) );
      inputFields[i].setCurrencySymbol( XMLHandler.getTagValue( fnode, "currency" ) );
      inputFields[i].setDecimalSymbol( XMLHandler.getTagValue( fnode, "decimal" ) );
      inputFields[i].setGroupSymbol( XMLHandler.getTagValue( fnode, "group" ) );
      inputFields[i].setLength( Const.toInt( XMLHandler.getTagValue( fnode, "length" ), -1 ) );
      inputFields[i].setPrecision( Const.toInt( XMLHandler.getTagValue( fnode, "precision" ), -1 ) );
      inputFields[i].setTrimType( ValueMetaString.getTrimTypeByCode( XMLHandler.getTagValue( fnode, "trim_type" ) ) );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 11
Source File: KettleTransFromFileProducer.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected TransMeta loadTransformation( final Repository repository,
                                        final ResourceManager resourceManager,
                                        final ResourceKey contextKey )
  throws ReportDataFactoryException, KettleException {
  if ( transformationFile == null ) {
    throw new ReportDataFactoryException( "No Transformation file given" );
  }

  if ( resourceManager == null || contextKey == null ) {
    return new TransMeta( transformationFile, repository );
  }

  try {
    final ResourceKey resourceKey = createKey( resourceManager, contextKey );
    final Resource resource = resourceManager.create( resourceKey, contextKey, Document.class );
    final Document document = (Document) resource.getResource();
    final Node node = XMLHandler.getSubNode( document, TransMeta.XML_TAG );
    final TransMeta meta = new TransMeta();
    meta.loadXML( node, repository, true, null, null );
    final String filename = computeFullFilename( resourceKey );
    if ( filename != null ) {
      logger.debug( "Computed Transformation Location: " + filename );
      meta.setFilename( filename );
    } else {
      logger.debug( "No Computed Transformation Location, using raw name: " + transformationFile );
      meta.setFilename( transformationFile );
    }
    return meta;
  } catch ( ResourceException re ) {
    throw new ReportDataFactoryException( "Unable to load Kettle-Transformation", re );
  }
}
 
Example 12
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 13
Source File: GetRepositoryNamesMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadXML( Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore ) throws KettleXMLException {
  try {
    String objectTypeString = XMLHandler.getTagValue( stepnode, "object_type" );
    if ( objectTypeString != null ) {
      objectTypeSelection = ObjectTypeSelection.valueOf( objectTypeString );
    }
    if ( objectTypeSelection == null ) {
      objectTypeSelection = ObjectTypeSelection.All;
    }
    includeRowNumber = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "rownum" ) );
    rowNumberField = XMLHandler.getTagValue( stepnode, "rownum_field" );

    Node filenode = XMLHandler.getSubNode( stepnode, "file" );
    int nrfiles = XMLHandler.countNodes( filenode, "directory" );

    allocate( nrfiles );

    for ( int i = 0; i < nrfiles; i++ ) {
      Node filenamenode = XMLHandler.getSubNodeByNr( filenode, "directory", i );
      Node filemasknode = XMLHandler.getSubNodeByNr( filenode, "name_mask", i );
      Node excludefilemasknode = XMLHandler.getSubNodeByNr( filenode, "exclude_name_mask", i );
      Node includeSubFoldersnode = XMLHandler.getSubNodeByNr( filenode, "include_subfolders", i );
      directory[i] = XMLHandler.getNodeValue( filenamenode );
      nameMask[i] = XMLHandler.getNodeValue( filemasknode );
      excludeNameMask[i] = XMLHandler.getNodeValue( excludefilemasknode );
      includeSubFolders[i] = "Y".equalsIgnoreCase( XMLHandler.getNodeValue( includeSubFoldersnode ) );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 14
Source File: PrioritizeStreamsMeta.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 {
    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" );
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 15
Source File: JobEntryMSAccessBulkLoad.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 );
    include_subfolders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "include_subfolders" ) );
    add_result_filenames = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "add_result_filenames" ) );
    is_args_from_previous = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "is_args_from_previous" ) );

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

    // How many field arguments?
    int nrFields = XMLHandler.countNodes( fields, "field" );
    source_filefolder = new String[nrFields];
    delimiter = new String[nrFields];
    source_wildcard = new String[nrFields];
    target_Db = new String[nrFields];
    target_table = new String[nrFields];

    // Read them all...
    for ( int i = 0; i < nrFields; i++ ) {
      Node fnode = XMLHandler.getSubNodeByNr( fields, "field", i );

      source_filefolder[i] = XMLHandler.getTagValue( fnode, "source_filefolder" );
      source_wildcard[i] = XMLHandler.getTagValue( fnode, "source_wildcard" );
      delimiter[i] = XMLHandler.getTagValue( fnode, "delimiter" );
      target_Db[i] = XMLHandler.getTagValue( fnode, "target_db" );
      target_table[i] = XMLHandler.getTagValue( fnode, "target_table" );
    }
  } catch ( KettleXMLException xe ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Meta.UnableLoadXML", xe
      .getMessage() ), xe );
  }
}
 
Example 16
Source File: JobEntryDosToUnix.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 );

    arg_from_previous = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "arg_from_previous" ) );
    include_subfolders = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "include_subfolders" ) );

    nr_errors_less_than = XMLHandler.getTagValue( entrynode, "nr_errors_less_than" );
    success_condition = XMLHandler.getTagValue( entrynode, "success_condition" );
    resultfilenames = XMLHandler.getTagValue( entrynode, "resultfilenames" );

    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] = XMLHandler.getTagValue( fnode, "source_filefolder" );
      wildcard[i] = XMLHandler.getTagValue( fnode, "wildcard" );
      conversionTypes[i] =
        getConversionTypeByCode( Const.NVL( XMLHandler.getTagValue( fnode, "ConversionType" ), "" ) );
    }
  } catch ( KettleXMLException xe ) {

    throw new KettleXMLException(
      BaseMessages.getString( PKG, "JobDosToUnix.Error.Exception.UnableLoadXML" ), xe );
  }
}
 
Example 17
Source File: DatabaseMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Reads the information from an XML Node into this new database connection.
 *
 * @param con
 *          The Node to read the data from
 * @throws KettleXMLException
 */
public DatabaseMeta( Node con ) throws KettleXMLException {
  this();

  try {
    String type = XMLHandler.getTagValue( con, "type" );
    try {
      databaseInterface = getDatabaseInterface( type );

    } catch ( KettleDatabaseException kde ) {
      throw new KettleXMLException( "Unable to create new database interface", kde );
    }

    setName( XMLHandler.getTagValue( con, "name" ) );
    setDisplayName( getName() );
    setHostname( XMLHandler.getTagValue( con, "server" ) );
    String acc = XMLHandler.getTagValue( con, "access" );
    setAccessType( getAccessType( acc ) );

    setDBName( XMLHandler.getTagValue( con, "database" ) );

    // The DB port is read here too for backward compatibility! getName()
    //
    setDBPort( XMLHandler.getTagValue( con, "port" ) );
    setUsername( XMLHandler.getTagValue( con, "username" ) );
    setPassword( Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( con, "password" ) ) );
    setServername( XMLHandler.getTagValue( con, "servername" ) );
    setDataTablespace( XMLHandler.getTagValue( con, "data_tablespace" ) );
    setIndexTablespace( XMLHandler.getTagValue( con, "index_tablespace" ) );

    setReadOnly( Boolean.valueOf( XMLHandler.getTagValue( con, "read_only" ) ) );

    // Also, read the database attributes...
    Node attrsnode = XMLHandler.getSubNode( con, "attributes" );
    if ( attrsnode != null ) {
      List<Node> attrnodes = XMLHandler.getNodes( attrsnode, "attribute" );
      for ( Node attrnode : attrnodes ) {
        String code = XMLHandler.getTagValue( attrnode, "code" );
        String attribute = XMLHandler.getTagValue( attrnode, "attribute" );
        if ( code != null && attribute != null ) {
          databaseInterface.addAttribute( code, attribute );
        }
        getDatabasePortNumberString();
      }
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load database connection info from XML node", e );
  }
}
 
Example 18
Source File: LDAPOutputMeta.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {

    useAuthentication = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "useauthentication" ) );
    Host = XMLHandler.getTagValue( stepnode, "host" );
    userName = XMLHandler.getTagValue( stepnode, "username" );
    setPassword( Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( stepnode, "password" ) ) );

    port = XMLHandler.getTagValue( stepnode, "port" );
    dnFieldName = XMLHandler.getTagValue( stepnode, "dnFieldName" );
    failIfNotExist = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "failIfNotExist" ) );
    operationType =
      getOperationTypeByCode( Const.NVL( XMLHandler.getTagValue( stepnode, "operationType" ), "" ) );
    multiValuedSeparator = XMLHandler.getTagValue( stepnode, "multivaluedseparator" );
    searchBase = XMLHandler.getTagValue( stepnode, "searchBase" );
    referralType = getReferralTypeByCode( Const.NVL( XMLHandler.getTagValue( stepnode, "referralType" ), "" ) );
    derefAliasesType =
      getDerefAliasesTypeByCode( Const.NVL( XMLHandler.getTagValue( stepnode, "derefAliasesType" ), "" ) );

    oldDnFieldName = XMLHandler.getTagValue( stepnode, "oldDnFieldName" );
    newDnFieldName = XMLHandler.getTagValue( stepnode, "newDnFieldName" );
    deleteRDN = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "deleteRDN" ) );

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

      updateLookup[i] = XMLHandler.getTagValue( fnode, "name" );
      updateStream[i] = XMLHandler.getTagValue( fnode, "field" );
      if ( updateStream[i] == null ) {
        updateStream[i] = updateLookup[i]; // default: the same name!
      }
      String updateValue = XMLHandler.getTagValue( fnode, "update" );
      if ( updateValue == null ) {
        // default TRUE
        update[i] = Boolean.TRUE;
      } else {
        if ( updateValue.equalsIgnoreCase( "Y" ) ) {
          update[i] = Boolean.TRUE;
        } else {
          update[i] = Boolean.FALSE;
        }
      }
    }

    protocol = XMLHandler.getTagValue( stepnode, "protocol" );
    trustStorePath = XMLHandler.getTagValue( stepnode, "trustStorePath" );
    trustStorePassword =
      Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( stepnode, "trustStorePassword" ) );
    trustAllCertificates = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "trustAllCertificates" ) );
    useCertificate = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "useCertificate" ) );

  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "LDAPOutputMeta.UnableToLoadFromXML" ), e );
  }
}
 
Example 19
Source File: DataGridMeta.java    From pentaho-kettle with Apache License 2.0 4 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;
    String 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" );
      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 );
      fieldNullIf[i] = XMLHandler.getTagValue( fnode, FIELD_NULL_IF );
    }

    Node datanode = XMLHandler.getSubNode( stepnode, "data" );
    dataLines = new ArrayList<>();

    Node lineNode = datanode.getFirstChild();
    while ( lineNode != null ) {
      if ( "line".equals( lineNode.getNodeName() ) ) {
        List<String> line = new ArrayList<>();
        Node itemNode = lineNode.getFirstChild();
        while ( itemNode != null ) {
          if ( "item".equals( itemNode.getNodeName() ) ) {
            String itemNodeValue = XMLHandler.getNodeValue( itemNode );
            line.add( itemNodeValue );
          }
          itemNode = itemNode.getNextSibling();
        }

        dataLines.add( line );

      }

      lineNode = lineNode.getNextSibling();
    }
  } catch ( Exception e ) {
    throw new KettleXMLException( "Unable to load step info from XML", e );
  }
}
 
Example 20
Source File: SlaveServerStatus.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public static SlaveServerStatus fromXML( String xml ) throws KettleException {
  Document document = XMLHandler.loadXMLString( xml );
  return new SlaveServerStatus( XMLHandler.getSubNode( document, XML_TAG ) );
}