org.pentaho.di.core.xml.XMLHandler Java Examples

The following examples show how to use org.pentaho.di.core.xml.XMLHandler. 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: UniqueRowsMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public String getXML() {
  StringBuilder retval = new StringBuilder();

  retval.append( "      " + XMLHandler.addTagValue( "count_rows", countRows ) );
  retval.append( "      " + XMLHandler.addTagValue( "count_field", countField ) );
  retval.append( "      " + XMLHandler.addTagValue( "reject_duplicate_row", rejectDuplicateRow ) );
  retval.append( "      " + XMLHandler.addTagValue( "error_description", errorDescription ) );

  retval.append( "    <fields>" );
  for ( int i = 0; i < compareFields.length; i++ ) {
    retval.append( "      <field>" );
    retval.append( "        " + XMLHandler.addTagValue( "name", compareFields[i] ) );
    retval.append( "        " + XMLHandler.addTagValue( "case_insensitive", caseInsensitive[i] ) );
    retval.append( "        </field>" );
  }
  retval.append( "      </fields>" );

  return retval.toString();
}
 
Example #2
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 #3
Source File: StringCutMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public String getXML() {
  StringBuilder retval = new StringBuilder( 500 );

  retval.append( "    <fields>" ).append( Const.CR );

  for ( int i = 0; i < fieldInStream.length; i++ ) {
    retval.append( "      <field>" ).append( Const.CR );
    retval.append( "        " ).append( XMLHandler.addTagValue( "in_stream_name", fieldInStream[i] ) );
    retval.append( "        " ).append( XMLHandler.addTagValue( "out_stream_name", fieldOutStream[i] ) );
    retval.append( "        " ).append( XMLHandler.addTagValue( "cut_from", cutFrom[i] ) );
    retval.append( "        " ).append( XMLHandler.addTagValue( "cut_to", cutTo[i] ) );
    retval.append( "      </field>" ).append( Const.CR );
  }

  retval.append( "    </fields>" ).append( Const.CR );

  return retval.toString();
}
 
Example #4
Source File: ZipFileMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public String getXML() {
  StringBuilder retval = new StringBuilder();

  retval.append( "    " + XMLHandler.addTagValue( "sourcefilenamefield", sourcefilenamefield ) );
  retval.append( "    " + XMLHandler.addTagValue( "targetfilenamefield", targetfilenamefield ) );
  retval.append( "    " + XMLHandler.addTagValue( "baseFolderField", baseFolderField ) );
  retval.append( "    " + XMLHandler.addTagValue( "operation_type", getOperationTypeCode( operationType ) ) );
  retval.append( "    " ).append( XMLHandler.addTagValue( "addresultfilenames", addresultfilenames ) );
  retval.append( "    " ).append( XMLHandler.addTagValue( "overwritezipentry", overwritezipentry ) );
  retval.append( "    " ).append( XMLHandler.addTagValue( "createparentfolder", createparentfolder ) );
  retval.append( "    " ).append( XMLHandler.addTagValue( "keepsourcefolder", keepsourcefolder ) );
  retval.append( "    " + XMLHandler.addTagValue( "movetofolderfield", movetofolderfield ) );
  parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( sourcefilenamefield );
  parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( targetfilenamefield );
  parentStepMeta.getParentTransMeta().getNamedClusterEmbedManager().registerUrl( baseFolderField );
  return retval.toString();
}
 
Example #5
Source File: JobEntryDeleteFiles.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public String getXML() {
  StringBuilder retval = new StringBuilder( 300 );

  retval.append( super.getXML() );
  retval.append( "      " ).append( XMLHandler.addTagValue( "arg_from_previous", argFromPrevious ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "include_subfolders", includeSubfolders ) );

  retval.append( "      <fields>" ).append( Const.CR );
  if ( arguments != null ) {
    for ( int i = 0; i < arguments.length; i++ ) {
      retval.append( "        <field>" ).append( Const.CR );
      retval.append( "          " ).append( XMLHandler.addTagValue( "name", arguments[i] ) );
      retval.append( "          " ).append( XMLHandler.addTagValue( "filemask", filemasks[i] ) );
      retval.append( "        </field>" ).append( Const.CR );

      if ( getParentJobMeta() != null ) {
        getParentJobMeta().getNamedClusterEmbedManager().registerUrl( arguments[i] );
      }
    }
  }
  retval.append( "      </fields>" ).append( Const.CR );

  return retval.toString();
}
 
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: CartePluginType.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void registerXmlPlugins() throws KettlePluginException {
  for ( PluginFolderInterface folder : pluginFolders ) {

    if ( folder.isPluginXmlFolder() ) {
      List<FileObject> pluginXmlFiles = findPluginXmlFiles( folder.getFolder() );
      for ( FileObject file : pluginXmlFiles ) {

        try {
          Document document = XMLHandler.loadXMLFile( file );
          Node pluginNode = XMLHandler.getSubNode( document, "plugin" );
          if ( pluginNode != null ) {
            registerPluginFromXmlResource( pluginNode, KettleVFS.getFilename( file.getParent() ), this
              .getClass(), false, file.getParent().getURL() );
          }
        } catch ( Exception e ) {
          // We want to report this plugin.xml error, perhaps an XML typo or
          // something like that...
          //
          log.logError( "Error found while reading step plugin.xml file: " + file.getName().toString(), e );
        }
      }
    }
  }
}
 
Example #8
Source File: SasInputField.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public String getXML() {
  StringBuilder retval = new StringBuilder();

  retval.append( "    " + XMLHandler.addTagValue( "name", name ) );
  retval.append( "    " + XMLHandler.addTagValue( "rename", rename ) );
  retval.append( "    " + XMLHandler.addTagValue( "type", ValueMetaFactory.getValueMetaName( type ) ) );
  retval.append( "    " + XMLHandler.addTagValue( "length", length ) );
  retval.append( "    " + XMLHandler.addTagValue( "precision", precision ) );
  retval.append( "    " + XMLHandler.addTagValue( "conversion_mask", conversionMask ) );
  retval.append( "    " + XMLHandler.addTagValue( "decimal", decimalSymbol ) );
  retval.append( "    " + XMLHandler.addTagValue( "grouping", groupingSymbol ) );
  retval.append( "    " + XMLHandler.addTagValue( "trim_type", ValueMetaString.getTrimTypeCode( trimType ) ) );

  return retval.toString();
}
 
Example #9
Source File: Wsdl.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private Definition readWsdl( WSDLReader wsdlReader, String uri, String username, String password ) throws WSDLException, KettleException, AuthenticationException {

    try {
      HTTPProtocol http = new HTTPProtocol();
      Document doc = XMLHandler.loadXMLString( http.get( wsdlURI.toString(), username, password ), true, false );
      if ( doc != null ) {
        return ( wsdlReader.readWSDL( doc.getBaseURI(), doc ) );
      } else {
        throw new KettleException( "Unable to get document." );
      }
    } catch ( MalformedURLException mue ) {
      throw new KettleException( mue );
    } catch ( AuthenticationException ae ) {
      // re-throw this. If not IOException seems to catch it
      throw ae;
    } catch ( IOException ioe ) {
      throw new KettleException( ioe );
    }
  }
 
Example #10
Source File: KettleBeamUtil.java    From kettle-beam with Apache License 2.0 6 votes vote down vote up
public static void loadStepMetadataFromXml( String stepname, StepMetaInterface stepMetaInterface, String stepMetaInterfaceXml, IMetaStore metaStore ) throws KettleException {
  synchronized ( object ) {
    Document stepDocument = XMLHandler.loadXMLString( stepMetaInterfaceXml );
    if ( stepDocument == null ) {
      throw new KettleException( "Unable to load step XML document from : " + stepMetaInterfaceXml );
    }
    Node stepNode = XMLHandler.getSubNode( stepDocument, StepMeta.XML_TAG );
    if ( stepNode == null ) {
      throw new KettleException( "Unable to find XML tag " + StepMeta.XML_TAG + " from : " + stepMetaInterfaceXml );
    }
    try {
      stepMetaInterface.loadXML( stepNode, new ArrayList<>(), metaStore );
    } catch ( Exception e ) {
      throw new KettleException( "There was an error loading step metadata information (loadXML) for step '" + stepname + "'", e );
    } finally {
      XMLHandlerCache.getInstance().clear();
    }
  }
}
 
Example #11
Source File: JobEntryCheckFilesLocked.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public String getXML() {
  StringBuilder retval = new StringBuilder( 300 );

  retval.append( super.getXML() );
  retval.append( "      " ).append( XMLHandler.addTagValue( ARG_FROM_PREVIOUS_ATTR, argFromPrevious ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( INCLUDE_SUBFOLDERS_ATTR, includeSubfolders ) );

  retval.append( "      <fields>" ).append( Const.CR );
  if ( arguments != null ) {
    for ( int i = 0; i < arguments.length; i++ ) {
      retval.append( "        <field>" ).append( Const.CR );
      retval.append( "          " ).append( XMLHandler.addTagValue( NAME_ATTR, arguments[i] ) );
      retval.append( "          " ).append( XMLHandler.addTagValue( FILE_MASK_ATTR, filemasks[i] ) );
      retval.append( "        </field>" ).append( Const.CR );
    }
  }
  retval.append( "      </fields>" ).append( Const.CR );

  return retval.toString();
}
 
Example #12
Source File: GraphOutputMeta.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 6 votes vote down vote up
@Override public String getXML() {
  StringBuilder xml = new StringBuilder();
  xml.append( XMLHandler.addTagValue( CONNECTION, connectionName ) );
  xml.append( XMLHandler.addTagValue( MODEL, model ) );
  xml.append( XMLHandler.addTagValue( BATCH_SIZE, batchSize ) );
  xml.append( XMLHandler.addTagValue( CREATE_INDEXES, creatingIndexes ) );
  xml.append( XMLHandler.addTagValue( RETURNING_GRAPH, returningGraph ) );
  xml.append( XMLHandler.addTagValue( RETURN_GRAPH_FIELD, returnGraphField ) );
  xml.append( XMLHandler.addTagValue( VALIDATE_AGAINST_MODEL, validatingAgainstModel ) );

  xml.append( XMLHandler.openTag( MAPPINGS ) );
  for ( FieldModelMapping fieldModelMapping : fieldModelMappings ) {
    xml.append( XMLHandler.openTag( MAPPING ) );
    xml.append( XMLHandler.addTagValue( SOURCE_FIELD, fieldModelMapping.getField() ) );
    xml.append( XMLHandler.addTagValue( TARGET_TYPE, ModelTargetType.getCode( fieldModelMapping.getTargetType() ) ) );
    xml.append( XMLHandler.addTagValue( TARGET_NAME, fieldModelMapping.getTargetName() ) );
    xml.append( XMLHandler.addTagValue( TARGET_PROPERTY, fieldModelMapping.getTargetProperty() ) );
    xml.append( XMLHandler.closeTag( MAPPING ) );
  }
  xml.append( XMLHandler.closeTag( MAPPINGS ) );

  return xml.toString();
}
 
Example #13
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 #14
Source File: JobEntrySendNagiosPassiveCheck.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public String getXML() {
  StringBuilder retval = new StringBuilder( 200 );

  retval.append( super.getXML() );
  retval.append( "      " ).append( XMLHandler.addTagValue( "port", port ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "servername", serverName ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "password", password ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "responseTimeOut", responseTimeOut ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "connectionTimeOut", connectionTimeOut ) );

  retval.append( "      " ).append( XMLHandler.addTagValue( "senderServerName", senderServerName ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "senderServiceName", senderServiceName ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "message", message ) );
  retval.append( "      " ).append(
    XMLHandler.addTagValue( "encryptionMode", getEncryptionModeCode( encryptionMode ) ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "level", getLevelCode( level ) ) );

  return retval.toString();
}
 
Example #15
Source File: GetPreviousRowFieldMeta.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public String getXML() {
  StringBuffer retval = new StringBuffer( 500 );

  retval.append( "    <fields>" ).append( Const.CR );

  for ( int i = 0; i < fieldInStream.length; i++ ) {
    retval.append( "      <field>" ).append( Const.CR );
    retval.append( "        " ).append( XMLHandler.addTagValue( "in_stream_name", fieldInStream[i] ) );
    retval.append( "        " ).append( XMLHandler.addTagValue( "out_stream_name", fieldOutStream[i] ) );
    retval.append( "      </field>" ).append( Const.CR );
  }

  retval.append( "    </fields>" ).append( Const.CR );

  return retval.toString();
}
 
Example #16
Source File: SlaveServer.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public SlaveServer( Node slaveNode ) {
  this();
  this.name = XMLHandler.getTagValue( slaveNode, "name" );
  this.hostname = XMLHandler.getTagValue( slaveNode, "hostname" );
  this.port = XMLHandler.getTagValue( slaveNode, "port" );
  this.webAppName = XMLHandler.getTagValue( slaveNode, "webAppName" );
  this.username = XMLHandler.getTagValue( slaveNode, "username" );
  this.password = Encr.decryptPasswordOptionallyEncrypted( XMLHandler.getTagValue( slaveNode, "password" ) );
  this.proxyHostname = XMLHandler.getTagValue( slaveNode, "proxy_hostname" );
  this.proxyPort = XMLHandler.getTagValue( slaveNode, "proxy_port" );
  this.nonProxyHosts = XMLHandler.getTagValue( slaveNode, "non_proxy_hosts" );
  this.propertiesMasterName = XMLHandler.getTagValue( slaveNode, "get_properties_from_master" );
  this.overrideExistingProperties =
    "Y".equalsIgnoreCase( XMLHandler.getTagValue( slaveNode, "override_existing_properties" ) );
  this.master = "Y".equalsIgnoreCase( XMLHandler.getTagValue( slaveNode, "master" ) );
  initializeVariablesFrom( null );
  this.log = new LogChannel( this );

  setSslMode( "Y".equalsIgnoreCase( XMLHandler.getTagValue( slaveNode, SSL_MODE_TAG ) ) );
  Node sslConfig = XMLHandler.getSubNode( slaveNode, SslConfiguration.XML_TAG );
  if ( sslConfig != null ) {
    setSslMode( true );
    this.sslConfig = new SslConfiguration( sslConfig );
  }
}
 
Example #17
Source File: SpoonJobDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void copyJobEntries( List<JobEntryCopy> jec ) {
  if ( jec == null || jec.size() == 0 ) {
    return;
  }

  StringBuilder xml = new StringBuilder( XMLHandler.getXMLHeader() );
  xml.append( XMLHandler.openTag( Spoon.XML_TAG_JOB_JOB_ENTRIES ) ).append( Const.CR );

  for ( JobEntryCopy aJec : jec ) {
    xml.append( aJec.getXML() );
  }

  xml.append( "    " ).append( XMLHandler.closeTag( Spoon.XML_TAG_JOB_JOB_ENTRIES ) ).append( Const.CR );

  spoon.toClipboard( xml.toString() );
}
 
Example #18
Source File: JobEntryWaitForSQL.java    From pentaho-kettle with Apache License 2.0 6 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 dbname = XMLHandler.getTagValue( entrynode, "connection" );
    connection = DatabaseMeta.findDatabase( databases, dbname );
    schemaname = XMLHandler.getTagValue( entrynode, "schemaname" );
    tablename = XMLHandler.getTagValue( entrynode, "tablename" );
    successCondition =
      getSucessConditionByCode( Const.NVL( XMLHandler.getTagValue( entrynode, "success_condition" ), "" ) );
    rowsCountValue = Const.NVL( XMLHandler.getTagValue( entrynode, "rows_count_value" ), "0" );
    iscustomSQL = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "is_custom_sql" ) );
    isUseVars = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "is_usevars" ) );
    customSQL = XMLHandler.getTagValue( entrynode, "custom_sql" );
    isAddRowsResult = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "add_rows_result" ) );
    maximumTimeout = XMLHandler.getTagValue( entrynode, "maximum_timeout" );
    checkCycleTime = XMLHandler.getTagValue( entrynode, "check_cycle_time" );
    successOnTimeout = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "success_on_timeout" ) );
    isClearResultList = "Y".equalsIgnoreCase( XMLHandler.getTagValue( entrynode, "clear_result_rows" ) );

  } catch ( KettleException e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JobEntryWaitForSQL.UnableLoadXML" ), e );
  }
}
 
Example #19
Source File: SelectMetadataChange.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void loadXML( Node metaNode ) {
  name = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_NAME" ) );
  rename = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_RENAME" ) );
  type = ValueMetaFactory.getIdForValueMeta(
    XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_TYPE" ) ) );
  length = Const.toInt( XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_LENGTH" ) ), -2 );
  precision =
    Const.toInt( XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_PRECISION" ) ), -2 );
  storageType =
    ValueMetaBase.getStorageType( XMLHandler.getTagValue( metaNode, attributesInterface
      .getXmlCode( "META_STORAGE_TYPE" ) ) );
  conversionMask = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_CONVERSION_MASK" ) );
  dateFormatLenient =
    Boolean.parseBoolean( XMLHandler.getTagValue( metaNode, attributesInterface
      .getXmlCode( "META_DATE_FORMAT_LENIENT" ) ) );
  dateFormatLocale =
    XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_DATE_FORMAT_LOCALE" ) );
  dateFormatTimeZone =
    XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_DATE_FORMAT_TIMEZONE" ) );
  encoding = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_ENCODING" ) );
  lenientStringToNumber =
    Boolean.parseBoolean( XMLHandler.getTagValue( metaNode, attributesInterface
      .getXmlCode( "META_LENIENT_STRING_TO_NUMBER" ) ) );
  encoding = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_ENCODING" ) );
  decimalSymbol = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_DECIMAL" ) );
  groupingSymbol = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_GROUPING" ) );
  currencySymbol = XMLHandler.getTagValue( metaNode, attributesInterface.getXmlCode( "META_CURRENCY" ) );
}
 
Example #20
Source File: JobEntryMail.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addBacktracking( JobTracker jobTracker, StringBuilder messageText, int level ) {
  int nr = jobTracker.nrJobTrackers();

  messageText.append( Const.rightPad( " ", level * 2 ) );
  messageText.append( Const.NVL( jobTracker.getJobName(), "-" ) );
  JobEntryResult jer = jobTracker.getJobEntryResult();
  if ( jer != null ) {
    messageText.append( " : " );
    if ( jer.getJobEntryName() != null ) {
      messageText.append( " : " );
      messageText.append( jer.getJobEntryName() );
    }
    if ( jer.getResult() != null ) {
      messageText.append( " : " );
      messageText.append( "[" + jer.getResult().toString() + "]" );
    }
    if ( jer.getReason() != null ) {
      messageText.append( " : " );
      messageText.append( jer.getReason() );
    }
    if ( jer.getComment() != null ) {
      messageText.append( " : " );
      messageText.append( jer.getComment() );
    }
    if ( jer.getLogDate() != null ) {
      messageText.append( " (" );
      messageText.append( XMLHandler.date2string( jer.getLogDate() ) );
      messageText.append( ')' );
    }
  }
  messageText.append( Const.CR );

  for ( int i = 0; i < nr; i++ ) {
    JobTracker jt = jobTracker.getJobTracker( i );
    addBacktracking( jt, messageText, level + 1 );
  }
}
 
Example #21
Source File: JobEntryEval.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 );
    script = XMLHandler.getTagValue( entrynode, "script" );
  } catch ( Exception e ) {
    throw new KettleXMLException( BaseMessages.getString( PKG, "JobEntryEval.UnableToLoadFromXml" ), e );
  }
}
 
Example #22
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 #23
Source File: GoogleSpreadsheetOutputMeta.java    From pdi-google-spreadsheet-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public String getXML() throws KettleException {
    StringBuilder xml = new StringBuilder();
    try {
        xml.append(XMLHandler.addTagValue("serviceEmail", this.serviceEmail));
        xml.append(XMLHandler.addTagValue("spreadsheetKey", this.spreadsheetKey));
        xml.append(XMLHandler.addTagValue("worksheetId", this.worksheetId));
        xml.append(XMLHandler.openTag("privateKeyStore"));
        xml.append(XMLHandler.buildCDATA(GoogleSpreadsheet.base64EncodePrivateKeyStore(this.privateKeyStore)));
        xml.append(XMLHandler.closeTag("privateKeyStore"));
    } catch (Exception e) {
        throw new KettleValueException("Unable to write step to XML", e);
    }
    return xml.toString();
}
 
Example #24
Source File: SplitFieldToRowsMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public String getXML() {
  StringBuilder retval = new StringBuilder();

  retval.append( "   " + XMLHandler.addTagValue( "splitfield", splitField ) );
  retval.append( "   " + XMLHandler.addTagValue( "delimiter", delimiter ) );
  retval.append( "   " + XMLHandler.addTagValue( "newfield", newFieldname ) );
  retval.append( "   " + XMLHandler.addTagValue( "rownum", includeRowNumber ) );
  retval.append( "   " + XMLHandler.addTagValue( "rownum_field", rowNumberField ) );
  retval.append( "   " + XMLHandler.addTagValue( "resetrownumber", resetRowNumber ) );
  retval.append( "   " + XMLHandler.addTagValue( "delimiter_is_regex", isDelimiterRegex ) );

  return retval.toString();
}
 
Example #25
Source File: OlapUtil.java    From pentaho-metadata with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
   * Create an OlapRole object from an XML node
   * @param node
   * @return
   * @throws KettleXMLException
   */
public static OlapRole olapRoleFromNode( Node node ) throws KettleXMLException {
  String name = XMLHandler.getTagValue( node, "name" );
  StringBuilder xml = new StringBuilder();
  NodeList children = XMLHandler.getSubNode( node, "definition" ).getChildNodes();
  for ( int i = 0; i < children.getLength(); i++ ) {
    xml.append( ( XMLHandler.formatNode( children.item( i ) ) ) );
  }
  String definition = xml.toString();

  return new OlapRole( name, definition );
}
 
Example #26
Source File: CubeInputMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void readData( Node stepnode ) throws KettleXMLException {
  try {
    filename = XMLHandler.getTagValue( stepnode, "file", "name" );
    rowLimit = XMLHandler.getTagValue( stepnode, "limit" );
    addfilenameresult = "Y".equalsIgnoreCase( XMLHandler.getTagValue( stepnode, "addfilenameresult" ) );

  } catch ( Exception e ) {
    throw new KettleXMLException(
      BaseMessages.getString( PKG, "CubeInputMeta.Exception.UnableToLoadStepInfo" ), e );
  }
}
 
Example #27
Source File: StepPartitioningMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public String getXML() {
  StringBuilder xml = new StringBuilder( 150 );

  xml.append( "    " ).append( XMLHandler.openTag( "partitioning" ) ).append( Const.CR );
  xml.append( "      " ).append( XMLHandler.addTagValue( "method", getMethodCode() ) );
  xml.append( "      " ).append(
    XMLHandler.addTagValue( "schema_name", partitionSchema != null ? partitionSchema.getName() : "" ) );
  if ( partitioner != null ) {
    xml.append( partitioner.getXML() );
  }
  xml.append( "    " ).append( XMLHandler.closeTag( "partitioning" ) ).append( Const.CR );

  return xml.toString();
}
 
Example #28
Source File: CypherScript.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 5 votes vote down vote up
@Override public void loadXML( Node node, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, Repository rep, IMetaStore metaStore ) throws KettleXMLException {

    super.loadXML( node, databases, slaveServers );

    connectionName = XMLHandler.getTagValue( node, "connection" );
    script = XMLHandler.getTagValue( node, "script" );
    replacingVariables =  "Y".equalsIgnoreCase( XMLHandler.getTagValue( node, "replace_variables" ) );
  }
 
Example #29
Source File: JobEntryWriteToLog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public String getXML() {
  StringBuilder retval = new StringBuilder( 200 );

  retval.append( super.getXML() );
  retval.append( "      " ).append( XMLHandler.addTagValue( "logmessage", logmessage ) );
  retval.append( "      " ).append(
    XMLHandler.addTagValue( "loglevel", ( getEntryLogLevel() == null ) ? null : getEntryLogLevel().getCode() ) );
  retval.append( "      " ).append( XMLHandler.addTagValue( "logsubject", logsubject ) );

  return retval.toString();
}
 
Example #30
Source File: Result.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public String getBasicXml() {
  StringBuilder xml = new StringBuilder();
  xml.append( XMLHandler.openTag( XML_TAG ) );
  setBasicXmlAttrs( xml );
  xml.append( XMLHandler.closeTag( XML_TAG ) );
  return xml.toString();
}