コード例 #1
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {

      urlInField = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "url_in_field"));
      urlFieldname = XMLHandler.getTagValue(stepnode, "url_field_name");
      includeRowNumber = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "rownum"));
      rowNumberField = XMLHandler.getTagValue(stepnode, "rownum_field");
      includeUrl = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "include_url"));
      urlField = XMLHandler.getTagValue(stepnode, "url_Field");
      readfrom = XMLHandler.getTagValue(stepnode, "read_from");
      Node fields = XMLHandler.getSubNode(stepnode, "fields");
      int nrFields = XMLHandler.countNodes(fields, "field");
      Node urlnode = XMLHandler.getSubNode(stepnode, "urls");
      int nrUrls = XMLHandler.countNodes(urlnode, "url");
      allocate(nrUrls, nrFields);
      for (int i = 0; i < nrUrls; i++) {
        Node urlnamenode = XMLHandler.getSubNodeByNr(urlnode, "url", i);
        url[i] = XMLHandler.getNodeValue(urlnamenode);
      }

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

      // Is there a limit on the number of rows we process?
      rowLimit = Const.toLong(XMLHandler.getTagValue(stepnode, "limit"), 0L);
    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
コード例 #2
0
  private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
      throws KettleXMLException {
    try {
      String commit, csize;

      schemaName = XMLHandler.getTagValue(stepnode, "schema"); // $NON-NLS-1$
      tablename = XMLHandler.getTagValue(stepnode, "table"); // $NON-NLS-1$
      String con = XMLHandler.getTagValue(stepnode, "connectionRead"); // $NON-NLS-1$
      databaseReadMeta = DatabaseMeta.findDatabase(databases, con);
      con = XMLHandler.getTagValue(stepnode, "connectionWrite"); // $NON-NLS-1$
      databaseWriteMeta = DatabaseMeta.findDatabase(databases, con);
      commit = XMLHandler.getTagValue(stepnode, "commit"); // $NON-NLS-1$
      commitSize = Const.toInt(commit, 0);
      csize = XMLHandler.getTagValue(stepnode, "cache_size"); // $NON-NLS-1$
      cacheSize = Const.toInt(csize, 0);

      replaceFields =
          "Y"
              .equalsIgnoreCase(
                  XMLHandler.getTagValue(stepnode, "replace")); // $NON-NLS-1$ //$NON-NLS-2$
      useHash =
          "Y"
              .equalsIgnoreCase(
                  XMLHandler.getTagValue(stepnode, "crc")); // $NON-NLS-1$ //$NON-NLS-2$

      hashField = XMLHandler.getTagValue(stepnode, "crcfield"); // $NON-NLS-1$

      Node keys = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      int nrkeys = XMLHandler.countNodes(keys, "key"); // $NON-NLS-1$

      allocate(nrkeys);

      // Read keys to dimension
      for (int i = 0; i < nrkeys; i++) {
        Node knode = XMLHandler.getSubNodeByNr(keys, "key", i); // $NON-NLS-1$
        keyField[i] = XMLHandler.getTagValue(knode, "name"); // $NON-NLS-1$
        keyLookup[i] = XMLHandler.getTagValue(knode, "lookup"); // $NON-NLS-1$
      }

      // If this is empty: use auto-increment field!
      sequenceFrom = XMLHandler.getTagValue(stepnode, "sequence"); // $NON-NLS-1$

      Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      Node retkey = XMLHandler.getSubNode(fields, "return"); // $NON-NLS-1$
      technicalKeyField = XMLHandler.getTagValue(retkey, "name"); // $NON-NLS-1$
      useAutoinc =
          !"N"
              .equalsIgnoreCase(
                  XMLHandler.getTagValue(retkey, "use_autoinc")); // $NON-NLS-1$ //$NON-NLS-2$
      lastUpdateField = XMLHandler.getTagValue(stepnode, "last_update_field"); // $NON-NLS-1$

      setTechKeyCreation(XMLHandler.getTagValue(retkey, "creation_method")); // $NON-NLS-1$
    } catch (Exception e) {
      throw new KettleXMLException(
          Messages.getString("ConcurrentCombinationLookupMeta.Exception.UnableToLoadStepInfo"),
          e); //$NON-NLS-1$
    }
  }
コード例 #3
0
ファイル: SapInputMeta.java プロジェクト: hoverzheng/kettle
  private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
      throws KettleXMLException {
    try {
      databaseMeta =
          DatabaseMeta.findDatabase(databases, XMLHandler.getTagValue(stepnode, "connection"));

      String functionName = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "name");
      String functionDescription =
          XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "description");
      String functionGroup = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "group");
      String functionApplication =
          XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "application");
      String functionHost = XMLHandler.getTagValue(stepnode, XML_TAG_FUNCTION, "host");

      if (!Const.isEmpty(functionName)) {
        function =
            new SAPFunction(
                functionName,
                functionDescription,
                functionGroup,
                functionApplication,
                functionHost);
      } else {
        function = null;
      }

      Node paramsNode = XMLHandler.getSubNode(stepnode, XML_TAG_PARAMETERS);
      int nrParameters = XMLHandler.countNodes(paramsNode, XML_TAG_PARAMETER);
      for (int i = 0; i < nrParameters; i++) {
        Node paramNode = XMLHandler.getSubNodeByNr(paramsNode, XML_TAG_PARAMETER, i);
        String fieldName = XMLHandler.getTagValue(paramNode, "field_name");
        SapType sapType = SapType.findTypeForCode(XMLHandler.getTagValue(paramNode, "sap_type"));
        String tableName = XMLHandler.getTagValue(paramNode, "table_name");
        int targetType = ValueMeta.getType(XMLHandler.getTagValue(paramNode, "target_type"));
        String parameterName = XMLHandler.getTagValue(paramNode, "parameter_name");
        parameters.add(new SapParameter(fieldName, sapType, tableName, parameterName, targetType));
      }

      Node fieldsNode = XMLHandler.getSubNode(stepnode, XML_TAG_FIELDS);
      int nrFields = XMLHandler.countNodes(fieldsNode, XML_TAG_FIELD);
      for (int i = 0; i < nrFields; i++) {
        Node fieldNode = XMLHandler.getSubNodeByNr(fieldsNode, XML_TAG_FIELD, i);
        String sapFieldName = XMLHandler.getTagValue(fieldNode, "field_name");
        SapType sapType = SapType.findTypeForCode(XMLHandler.getTagValue(fieldNode, "sap_type"));
        String tableName = XMLHandler.getTagValue(fieldNode, "table_name");
        int targetType = ValueMeta.getType(XMLHandler.getTagValue(fieldNode, "target_type"));
        String newName = XMLHandler.getTagValue(fieldNode, "new_name");
        outputFields.add(new SapOutputField(sapFieldName, sapType, tableName, newName, targetType));
      }

    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
コード例 #4
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      passAllRows = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "all_rows"));
      aggregateIgnored = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "ignore_aggregate"));
      aggregateIgnoredField = XMLHandler.getTagValue(stepnode, "field_ignore");

      directory = XMLHandler.getTagValue(stepnode, "directory");
      prefix = XMLHandler.getTagValue(stepnode, "prefix");

      addingLineNrInGroup = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "add_linenr"));
      lineNrInGroupField = XMLHandler.getTagValue(stepnode, "linenr_fieldname");

      Node groupn = XMLHandler.getSubNode(stepnode, "group");
      Node fields = XMLHandler.getSubNode(stepnode, "fields");

      int sizegroup = XMLHandler.countNodes(groupn, "field");
      int nrfields = XMLHandler.countNodes(fields, "field");

      allocate(sizegroup, nrfields);

      for (int i = 0; i < sizegroup; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(groupn, "field", i);
        groupField[i] = XMLHandler.getTagValue(fnode, "name");
      }

      boolean hasNumberOfValues = false;
      for (int i = 0; i < nrfields; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
        aggregateField[i] = XMLHandler.getTagValue(fnode, "aggregate");
        subjectField[i] = XMLHandler.getTagValue(fnode, "subject");
        aggregateType[i] = getType(XMLHandler.getTagValue(fnode, "type"));

        if (aggregateType[i] == TYPE_GROUP_COUNT_ALL
            || aggregateType[i] == TYPE_GROUP_COUNT_DISTINCT
            || aggregateType[i] == TYPE_GROUP_COUNT_ANY) {
          hasNumberOfValues = true;
        }

        valueField[i] = XMLHandler.getTagValue(fnode, "valuefield");
      }

      String giveBackRow = XMLHandler.getTagValue(stepnode, "give_back_row");
      if (Utils.isEmpty(giveBackRow)) {
        alwaysGivingBackOneRow = hasNumberOfValues;
      } else {
        alwaysGivingBackOneRow = "Y".equalsIgnoreCase(giveBackRow);
      }
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "GroupByMeta.Exception.UnableToLoadStepInfoFromXML"), e);
    }
  }
コード例 #5
0
ファイル: DenormaliserMeta.java プロジェクト: cnopens/BA
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      keyField = XMLHandler.getTagValue(stepnode, "key_field"); // $NON-NLS-1$

      Node groupn = XMLHandler.getSubNode(stepnode, "group"); // $NON-NLS-1$
      Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$

      int sizegroup = XMLHandler.countNodes(groupn, "field"); // $NON-NLS-1$
      int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$

      allocate(sizegroup, nrfields);

      for (int i = 0; i < sizegroup; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(groupn, "field", i); // $NON-NLS-1$
        groupField[i] = XMLHandler.getTagValue(fnode, "name"); // $NON-NLS-1$
      }

      for (int i = 0; i < nrfields; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$
        denormaliserTargetField[i] = new DenormaliserTargetField();
        denormaliserTargetField[i].setFieldName(
            XMLHandler.getTagValue(fnode, "field_name")); // $NON-NLS-1$
        denormaliserTargetField[i].setKeyValue(
            XMLHandler.getTagValue(fnode, "key_value")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetName(
            XMLHandler.getTagValue(fnode, "target_name")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetType(
            XMLHandler.getTagValue(fnode, "target_type")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetFormat(
            XMLHandler.getTagValue(fnode, "target_format")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetLength(
            Const.toInt(XMLHandler.getTagValue(fnode, "target_length"), -1)); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetPrecision(
            Const.toInt(XMLHandler.getTagValue(fnode, "target_precision"), -1)); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetDecimalSymbol(
            XMLHandler.getTagValue(fnode, "target_decimal_symbol")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetGroupingSymbol(
            XMLHandler.getTagValue(fnode, "target_grouping_symbol")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetCurrencySymbol(
            XMLHandler.getTagValue(fnode, "target_currency_symbol")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetNullString(
            XMLHandler.getTagValue(fnode, "target_null_string")); // $NON-NLS-1$
        denormaliserTargetField[i].setTargetAggregationType(
            XMLHandler.getTagValue(fnode, "target_aggregation_type")); // $NON-NLS-1$
      }
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "DenormaliserMeta.Exception.UnableToLoadStepInfoFromXML"),
          e); //$NON-NLS-1$
    }
  }
コード例 #6
0
  public CalculatorMetaFunction(Node calcnode) {
    fieldName = XMLHandler.getTagValue(calcnode, "field_name");
    calcType = getCalcFunctionType(XMLHandler.getTagValue(calcnode, "calc_type"));
    fieldA = XMLHandler.getTagValue(calcnode, "field_a");
    fieldB = XMLHandler.getTagValue(calcnode, "field_b");
    fieldC = XMLHandler.getTagValue(calcnode, "field_c");
    fieldD = XMLHandler.getTagValue(calcnode, "field_d");
    fieldE = XMLHandler.getTagValue(calcnode, "field_e");
    valueType = ValueMeta.getType(XMLHandler.getTagValue(calcnode, "value_type"));
    valueLength = Const.toInt(XMLHandler.getTagValue(calcnode, "value_length"), -1);
    valuePrecision = Const.toInt(XMLHandler.getTagValue(calcnode, "value_precision"), -1);
    removedFromResult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "remove"));
    conversionMask = XMLHandler.getTagValue(calcnode, "conversion_mask");
    decimalSymbol = XMLHandler.getTagValue(calcnode, "decimal_symbol");
    groupingSymbol = XMLHandler.getTagValue(calcnode, "grouping_symbol");
    currencySymbol = XMLHandler.getTagValue(calcnode, "currency_symbol");

    // Fix 2.x backward compatibility
    // The conversion mask was added in a certain revision.
    // Anything that we load from before then should get masks set to retain backward compatibility
    //
    if (XMLHandler.getSubNode(calcnode, "conversion_mask") == null) {
      fixBackwardCompatibility();
    }
  }
コード例 #7
0
  public void loadXML(
      Node entrynode,
      List<DatabaseMeta> databases,
      List<SlaveServer> slaveServers,
      Repository rep,
      IMetaStore metaStore)
      throws KettleXMLException {
    try {
      super.loadXML(entrynode, databases, slaveServers);
      replaceVars = "Y".equalsIgnoreCase(XMLHandler.getTagValue(entrynode, "replacevars"));

      filename = XMLHandler.getTagValue(entrynode, "filename");
      fileVariableType = getVariableType(XMLHandler.getTagValue(entrynode, "file_variable_type"));

      Node fields = XMLHandler.getSubNode(entrynode, "fields");
      // How many field variableName?
      int nrFields = XMLHandler.countNodes(fields, "field");
      variableName = new String[nrFields];
      variableValue = new String[nrFields];
      variableType = new int[nrFields];

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

        variableName[i] = XMLHandler.getTagValue(fnode, "variable_name");
        variableValue[i] = XMLHandler.getTagValue(fnode, "variable_value");
        variableType[i] = getVariableType(XMLHandler.getTagValue(fnode, "variable_type"));
      }
    } catch (KettleXMLException xe) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "JobEntrySetVariables.Meta.UnableLoadXML", xe.getMessage()),
          xe);
    }
  }
コード例 #8
0
  @Override
  public boolean jobElementRead(String xml, RepositoryImportFeedbackInterface feedback) {
    try {
      Document doc = XMLHandler.loadXMLString(getOrCreateDb(), xml);
      Node jobNode = XMLHandler.getSubNode(doc, RepositoryExportSaxParser.STRING_JOB);
      if (!importJob(jobNode, feedback)) {
        return false;
      }
      jobNumber++;
    } catch (Exception e) {
      // Some unexpected error occurred during job import
      // This is usually a problem with a missing plugin or something
      // like that...
      //
      showError(
          BaseMessages.getString(PKG, "RepositoryImporter.UnexpectedErrorDuringJobImport.Title"),
          BaseMessages.getString(PKG, "RepositoryImporter.UnexpectedErrorDuringJobImport.Message"),
          e);

      if (!feedback.askContinueOnErrorQuestion(
          BaseMessages.getString(PKG, "RepositoryImporter.DoYouWantToContinue.Title"),
          BaseMessages.getString(PKG, "RepositoryImporter.DoYouWantToContinue.Message"))) {
        return false;
      }
    }
    return true;
  }
コード例 #9
0
  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);
          }
        }
      }
    }
  }
コード例 #10
0
ファイル: RowGeneratorMeta.java プロジェクト: cnopens/BA
  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] = !Const.isEmpty(emptyString) && "Y".equalsIgnoreCase(emptyString);
      }

      // Is there a limit on the number of rows we process?
      rowLimit = XMLHandler.getTagValue(stepnode, "limit");
    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
コード例 #11
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$

        fieldName[i] = XMLHandler.getTagValue(fnode, "name"); // $NON-NLS-1$
        fieldType[i] = ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")); // $NON-NLS-1$
        String slength = XMLHandler.getTagValue(fnode, "length"); // $NON-NLS-1$
        String sprecision = XMLHandler.getTagValue(fnode, "precision"); // $NON-NLS-1$

        fieldLength[i] = Const.toInt(slength, -1);
        fieldPrecision[i] = Const.toInt(sprecision, -1);
      }

      selectingAndSortingUnspecifiedFields =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(fields, "select_unspecified"));
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "MappingInputMeta.Exception.UnableToLoadStepInfoFromXML"),
          e); //$NON-NLS-1$
    }
  }
コード例 #12
0
  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");

      // 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");
        filemasks[i] = XMLHandler.getTagValue(fnode, "filemask");
      }
    } catch (KettleXMLException xe) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "JobEntryCheckFilesLocked.UnableToLoadFromXml"), xe);
    }
  }
コード例 #13
0
  private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
      throws KettleXMLException {
    try {
      String csize;
      int nrkeys;

      String con = XMLHandler.getTagValue(stepnode, "connection"); // $NON-NLS-1$
      databaseMeta = DatabaseMeta.findDatabase(databases, con);
      csize = XMLHandler.getTagValue(stepnode, "commit"); // $NON-NLS-1$
      commitSize = Const.toInt(csize, 0);
      schemaName =
          XMLHandler.getTagValue(stepnode, "lookup", "schema"); // $NON-NLS-1$ //$NON-NLS-2$
      tableName = XMLHandler.getTagValue(stepnode, "lookup", "table"); // $NON-NLS-1$ //$NON-NLS-2$

      Node lookup = XMLHandler.getSubNode(stepnode, "lookup"); // $NON-NLS-1$
      nrkeys = XMLHandler.countNodes(lookup, "key"); // $NON-NLS-1$

      allocate(nrkeys);

      for (int i = 0; i < nrkeys; i++) {
        Node knode = XMLHandler.getSubNodeByNr(lookup, "key", i); // $NON-NLS-1$

        keyStream[i] = XMLHandler.getTagValue(knode, "name"); // $NON-NLS-1$
        keyLookup[i] = XMLHandler.getTagValue(knode, "field"); // $NON-NLS-1$
        keyCondition[i] = XMLHandler.getTagValue(knode, "condition"); // $NON-NLS-1$
        if (keyCondition[i] == null) keyCondition[i] = "="; // $NON-NLS-1$
        keyStream2[i] = XMLHandler.getTagValue(knode, "name2"); // $NON-NLS-1$
      }

    } catch (Exception e) {
      throw new KettleXMLException(
          Messages.getString("DeleteMeta.Exception.UnableToReadStepInfoFromXML"), e); // $NON-NLS-1$
    }
  }
コード例 #14
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      directory = XMLHandler.getTagValue(stepnode, "directory");
      prefix = XMLHandler.getTagValue(stepnode, "prefix");
      sortSize = XMLHandler.getTagValue(stepnode, "sort_size");
      freeMemoryLimit = XMLHandler.getTagValue(stepnode, "free_memory");
      compressFiles = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "compress"));
      compressFilesVariable = XMLHandler.getTagValue(stepnode, "compress_variable");
      onlyPassingUniqueRows = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "unique_rows"));

      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");
        ascending[i] = "Y".equalsIgnoreCase(asc);
        String sens = XMLHandler.getTagValue(fnode, "case_sensitive");
        String coll = XMLHandler.getTagValue(fnode, "collator_enabled");
        caseSensitive[i] = Const.isEmpty(sens) || "Y".equalsIgnoreCase(sens);
        collatorEnabled[i] = Const.isEmpty(coll) || "Y".equalsIgnoreCase(coll);
        collatorStrength[i] = Integer.parseInt(XMLHandler.getTagValue(fnode, "collator_strength"));
        String presorted = XMLHandler.getTagValue(fnode, "presorted");
        preSortedField[i] = "Y".equalsIgnoreCase(presorted);
      }
    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
コード例 #15
0
  /**
   * Load step attributes.
   *
   * @throws KettleException the kettle exception
   */
  protected void loadStepAttributes() throws KettleException {
    try {
      InputStream inputStream = getClass().getResourceAsStream(STEP_ATTRIBUTES_FILE);
      if (inputStream != null) {
        Document document = XMLHandler.loadXMLFile(inputStream);
        Node attrsNode = XMLHandler.getSubNode(document, "attributes");
        List<Node> nodes = XMLHandler.getNodes(attrsNode, "attribute");
        attributes = new ArrayList<KettleAttributeInterface>();
        for (Node node : nodes) {
          String key = XMLHandler.getTagAttribute(node, "id");
          String xmlCode = XMLHandler.getTagValue(node, "xmlcode");
          String repCode = XMLHandler.getTagValue(node, "repcode");
          String description = XMLHandler.getTagValue(node, "description");
          String tooltip = XMLHandler.getTagValue(node, "tooltip");
          int valueType = ValueMeta.getType(XMLHandler.getTagValue(node, "valuetype"));
          String parentId = XMLHandler.getTagValue(node, "parentid");

          KettleAttribute attribute =
              new KettleAttribute(
                  key,
                  xmlCode,
                  repCode,
                  description,
                  tooltip,
                  valueType,
                  findParent(attributes, parentId));
          attributes.add(attribute);
        }
      }
    } catch (Exception e) {
      throw new KettleException("Unable to load file " + STEP_ATTRIBUTES_FILE, e);
    }
  }
コード例 #16
0
  // TODO Carregar campos a partir do XML de um .ktr
  @SuppressWarnings("unchecked")
  @Override
  public void loadXML(
      Node stepDomNode, List<DatabaseMeta> databases, Map<String, Counter> sequenceCounters)
      throws KettleXMLException {

    try {
      XStream xs = new XStream(new DomDriver());

      StringWriter sw = new StringWriter();
      Transformer t = TransformerFactory.newInstance().newTransformer();
      // IPC: se algum colocar um caracter, seja qual for, no getXML() o
      // getFirstChild() para de funcionar aqui!
      t.transform(
          new DOMSource(
              XMLHandler.getSubNode(stepDomNode, Field.DATA_ROOT_NODE.name()).getFirstChild()),
          new StreamResult(sw));

      Map<String, Object> data = (Map<String, Object>) xs.fromXML(sw.toString());

      endpointUri = (String) data.get(Field.ENDPOINT_URI.name());
      defaultGraph = (String) data.get(Field.DEFAULT_GRAPH.name());
      queryString = (String) data.get(Field.QUERY_STRING.name());
      prefixes = (List<List<String>>) data.get(Field.PREFIXES.name());

      varResult = (String) data.get(Field.VAR_RESULT.name());

    } catch (Throwable e) {
      e.printStackTrace();
    }
  }
コード例 #17
0
  @Override
  public void loadXML(Node node, List<DatabaseMeta> list, List<SlaveServer> list1, Repository rpstr)
      throws KettleXMLException {
    try {
      super.loadXML(node, list, list1);

      this.setRecordSetName(XMLHandler.getNodeValue(XMLHandler.getSubNode(node, "recordset_name")));
      this.setRecordSet(XMLHandler.getNodeValue(XMLHandler.getSubNode(node, "recordset")));
      this.setBreakCriteria(XMLHandler.getNodeValue(XMLHandler.getSubNode(node, "breakCriteria")));
      this.setIsAllString(XMLHandler.getNodeValue(XMLHandler.getSubNode(node, "isAll")));
      this.setRunLocalString(XMLHandler.getNodeValue(XMLHandler.getSubNode(node, "runLocal")));

    } catch (Exception e) {
      throw new KettleXMLException(
          "ECL Group Job Plugin is unable to read step info from XML node", e);
    }
  }
コード例 #18
0
  private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
      throws KettleXMLException {
    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);
    }
  }
コード例 #19
0
  public void loadXML(
      Node entrynode,
      List<DatabaseMeta> databases,
      List<SlaveServer> slaveServers,
      Repository rep,
      IMetaStore metaStore)
      throws KettleXMLException {
    try {
      super.loadXML(entrynode, databases, slaveServers);
      xmlfilename = XMLHandler.getTagValue(entrynode, "xmlfilename");
      xslfilename = XMLHandler.getTagValue(entrynode, "xslfilename");
      outputfilename = XMLHandler.getTagValue(entrynode, "outputfilename");
      iffileexists = Const.toInt(XMLHandler.getTagValue(entrynode, "iffileexists"), -1);
      addfiletoresult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(entrynode, "addfiletoresult"));
      filenamesfromprevious =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(entrynode, "filenamesfromprevious"));
      xsltfactory = XMLHandler.getTagValue(entrynode, "xsltfactory");
      if (xsltfactory == null) {
        xsltfactory = FACTORY_JAXP;
      }
      Node parametersNode = XMLHandler.getSubNode(entrynode, "parameters");
      int nrparams = XMLHandler.countNodes(parametersNode, "parameter");

      Node parametersOutputProps = XMLHandler.getSubNode(entrynode, "outputproperties");
      int nroutputprops = XMLHandler.countNodes(parametersOutputProps, "outputproperty");
      allocate(nrparams, nroutputprops);

      for (int i = 0; i < nrparams; i++) {
        Node anode = XMLHandler.getSubNodeByNr(parametersNode, "parameter", i);
        parameterField[i] = XMLHandler.getTagValue(anode, "field");
        parameterName[i] = XMLHandler.getTagValue(anode, "name");
      }
      for (int i = 0; i < nroutputprops; i++) {
        Node anode = XMLHandler.getSubNodeByNr(parametersOutputProps, "outputproperty", i);
        outputPropertyName[i] = XMLHandler.getTagValue(anode, "name");
        outputPropertyValue[i] = XMLHandler.getTagValue(anode, "value");
      }

    } catch (KettleXMLException xe) {
      throw new KettleXMLException("Unable to load job entry of type 'xslt' from XML node", xe);
    }
  }
コード例 #20
0
  public Validation(Node calcnode) throws KettleXMLException {
    this();

    fieldName = XMLHandler.getTagValue(calcnode, "name");
    name = XMLHandler.getTagValue(calcnode, "validation_name");
    if (Const.isEmpty(name)) {
      name = fieldName; // remain backward compatible
    }

    maximumLength = XMLHandler.getTagValue(calcnode, "max_length");
    minimumLength = XMLHandler.getTagValue(calcnode, "min_length");

    nullAllowed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "null_allowed"));
    onlyNullAllowed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "only_null_allowed"));
    onlyNumericAllowed =
        "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "only_numeric_allowed"));

    dataType = ValueMeta.getType(XMLHandler.getTagValue(calcnode, "data_type"));
    dataTypeVerified = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "data_type_verified"));
    conversionMask = XMLHandler.getTagValue(calcnode, "conversion_mask");
    decimalSymbol = XMLHandler.getTagValue(calcnode, "decimal_symbol");
    groupingSymbol = XMLHandler.getTagValue(calcnode, "grouping_symbol");

    minimumValue = XMLHandler.getTagValue(calcnode, "min_value");
    maximumValue = XMLHandler.getTagValue(calcnode, "max_value");

    startString = XMLHandler.getTagValue(calcnode, "start_string");
    endString = XMLHandler.getTagValue(calcnode, "end_string");
    startStringNotAllowed = XMLHandler.getTagValue(calcnode, "start_string_not_allowed");
    endStringNotAllowed = XMLHandler.getTagValue(calcnode, "end_string_not_allowed");

    regularExpression = XMLHandler.getTagValue(calcnode, "regular_expression");
    regularExpressionNotAllowed =
        XMLHandler.getTagValue(calcnode, "regular_expression_not_allowed");

    errorCode = XMLHandler.getTagValue(calcnode, "error_code");
    errorDescription = XMLHandler.getTagValue(calcnode, "error_description");

    sourcingValues = "Y".equalsIgnoreCase(XMLHandler.getTagValue(calcnode, "is_sourcing_values"));
    sourcingStepName = XMLHandler.getTagValue(calcnode, "sourcing_step");
    sourcingField = XMLHandler.getTagValue(calcnode, "sourcing_field");

    Node allowedValuesNode = XMLHandler.getSubNode(calcnode, XML_TAG_ALLOWED);
    int nrValues = XMLHandler.countNodes(allowedValuesNode, "value");
    allowedValues = new String[nrValues];
    for (int i = 0; i < nrValues; i++) {
      Node allowedNode = XMLHandler.getSubNodeByNr(allowedValuesNode, "value", i);
      allowedValues[i] = XMLHandler.getNodeValue(allowedNode);
    }
  }
コード例 #21
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      encoding = XMLHandler.getTagValue(stepnode, "encoding"); // $NON-NLS-1$
      valueName = XMLHandler.getTagValue(stepnode, "valueName"); // $NON-NLS-1$
      rootNode = XMLHandler.getTagValue(stepnode, "xml_repeat_element"); // $NON-NLS-1$

      omitXMLheader =
          "Y"
              .equalsIgnoreCase(
                  XMLHandler.getTagValue(
                      stepnode, "file", "omitXMLheader")); // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
      omitNullValues =
          "Y"
              .equalsIgnoreCase(
                  XMLHandler.getTagValue(
                      stepnode, "file", "omitNullValues")); // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$

      Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$

        outputFields[i] = new XMLField();
        outputFields[i].setFieldName(XMLHandler.getTagValue(fnode, "name")); // $NON-NLS-1$
        outputFields[i].setElementName(XMLHandler.getTagValue(fnode, "element")); // $NON-NLS-1$
        outputFields[i].setType(XMLHandler.getTagValue(fnode, "type")); // $NON-NLS-1$
        outputFields[i].setFormat(XMLHandler.getTagValue(fnode, "format")); // $NON-NLS-1$
        outputFields[i].setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency")); // $NON-NLS-1$
        outputFields[i].setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal")); // $NON-NLS-1$
        outputFields[i].setGroupingSymbol(XMLHandler.getTagValue(fnode, "group")); // $NON-NLS-1$
        outputFields[i].setNullString(XMLHandler.getTagValue(fnode, "nullif")); // $NON-NLS-1$
        outputFields[i].setLength(
            Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1)); // $NON-NLS-1$
        outputFields[i].setPrecision(
            Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1)); // $NON-NLS-1$
        outputFields[i].setAttribute(
            "Y"
                .equalsIgnoreCase(
                    XMLHandler.getTagValue(fnode, "attribute"))); // $NON-NLS-1$ //$NON-NLS-2$
        outputFields[i].setAttributeParentName(
            XMLHandler.getTagValue(fnode, "attributeParentName")); // $NON-NLS-1$
      }
    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e); // $NON-NLS-1$
    }
  }
コード例 #22
0
  private static List<FieldVariableMapping> extractFieldVariableMapping(Node serviceNode) {
    List<FieldVariableMapping> map = new ArrayList<FieldVariableMapping>();

    List<Node> nodes =
        XMLHandler.getNodes(
            XMLHandler.getSubNode(serviceNode, XML_TAG_VARIABLE_MAPS), XML_TAG_VARIABLE_MAP);
    for (Node node : nodes) {
      String field = XMLHandler.getTagValue(node, "field");
      String target = XMLHandler.getTagValue(node, "target");
      String variable = XMLHandler.getTagValue(node, "variable");
      MappingType mappingType =
          FieldVariableMapping.MappingType.getMappingType(XMLHandler.getTagValue(node, "type"));
      map.add(new FieldVariableMapping(field, target, variable, mappingType));
    }

    return map;
  }
コード例 #23
0
  /** Scan & register internal step plugins */
  protected void registerNatives() throws KettlePluginException {
    // Scan the native steps...
    //
    String kettleStepsXmlFile = Const.XML_FILE_KETTLE_STEPS;
    String alternative = System.getProperty(Const.KETTLE_CORE_STEPS_FILE, null);
    if (!Const.isEmpty(alternative)) {
      kettleStepsXmlFile = alternative;
    }

    // Load the plugins for this file...
    //
    try {
      InputStream inputStream = getClass().getResourceAsStream(kettleStepsXmlFile);
      if (inputStream == null) {
        inputStream = getClass().getResourceAsStream("/" + kettleStepsXmlFile);
      }
      // Retry to load a regular file...
      if (inputStream == null && !Const.isEmpty(alternative)) {
        try {
          inputStream = new FileInputStream(kettleStepsXmlFile);
        } catch (Exception e) {
          throw new KettlePluginException(
              "Unable to load native step plugins '" + kettleStepsXmlFile + "'", e);
        }
      }
      if (inputStream == null) {
        throw new KettlePluginException(
            "Unable to find native step definition file: " + Const.XML_FILE_KETTLE_STEPS);
      }
      Document document = XMLHandler.loadXMLFile(inputStream, null, true, false);

      // Document document = XMLHandler.loadXMLFile(kettleStepsXmlFile);

      Node stepsNode = XMLHandler.getSubNode(document, "steps");
      List<Node> stepNodes = XMLHandler.getNodes(stepsNode, "step");
      for (Node stepNode : stepNodes) {
        registerPluginFromXmlResource(stepNode, null, this.getClass(), true, null);
      }

    } catch (KettleXMLException e) {
      throw new KettlePluginException(
          "Unable to read the kettle steps XML config file: " + kettleStepsXmlFile, e);
    }
  }
コード例 #24
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      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");
      bufferSize = XMLHandler.getTagValue(stepnode, "buffer_size");
      headerPresent = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "header"));
      lazyConversionActive =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "lazy_conversion"));
      isaddresult = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "add_filename_result"));
      runningInParallel = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "parallel"));
      encoding = XMLHandler.getTagValue(stepnode, "encoding");

      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(ValueMeta.getType(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(
            ValueMeta.getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type")));
      }
    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
コード例 #25
0
  @Override
  public void loadXML(Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore)
      throws KettleXMLException {
    try {
      String con = XMLHandler.getTagValue(stepnode, "connection");
      databaseMeta = DatabaseMeta.findDatabase(databases, con);
      tablename = XMLHandler.getTagValue(stepnode, "table");
      fifoFileName = XMLHandler.getTagValue(stepnode, "fifo_file_name");
      sqlPath = XMLHandler.getTagValue(stepnode, "sql_path");
      encoding = XMLHandler.getTagValue(stepnode, "encoding");
      delimiter = XMLHandler.getTagValue(stepnode, "delimiter");
      continueOnError = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "continue_on_error"));
      errorFileName = XMLHandler.getTagValue(stepnode, "error_file_name");
      useStandardConversion =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_standard_conversion"));
      useAuthentication =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_authentication"));
      useDynamicVNode = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_dynamic_vnode"));
      useSSV = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_SSV_delimiter"));
      String escape = XMLHandler.getTagValue(stepnode, "escape_special_characters");
      escapingSpecialCharacters = Const.isEmpty(escape) ? true : "Y".equalsIgnoreCase(escape);
      usingVwload = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_vwload"));
      maxNrErrors = XMLHandler.getTagValue(stepnode, "max_errors");
      truncatingTable = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "truncate_table"));
      bufferSize = XMLHandler.getTagValue(stepnode, "buffer_size");

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

      allocate(nrRows);

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

        fieldDatabase[i] = XMLHandler.getTagValue(knode, "column_name");
        fieldStream[i] = XMLHandler.getTagValue(knode, "stream_name");
      }
    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }
コード例 #26
0
  private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
      throws KettleXMLException {
    try {
      usevar = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "usevar"));
      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");
        replaceValue[i] = XMLHandler.getTagValue(fnode, "value");
        replaceMask[i] = XMLHandler.getTagValue(fnode, "mask");
        String emptyString = XMLHandler.getTagValue(fnode, "set_empty_string");
        setEmptyString[i] = !Const.isEmpty(emptyString) && "Y".equalsIgnoreCase(emptyString);
      }
    } catch (Exception e) {
      throw new KettleXMLException(
          "It was not possible to load the metadata for this step from XML", e);
    }
  }
コード例 #27
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      splitField = XMLHandler.getTagValue(stepnode, "splitfield"); // $NON-NLS-1$
      delimiter = XMLHandler.getTagValue(stepnode, "delimiter"); // $NON-NLS-1$

      final Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      final int nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        final Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$

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

        fieldRemoveID[i] = "Y".equalsIgnoreCase(sidrem); // $NON-NLS-1$
        fieldType[i] = ValueMeta.getType(stype);
        fieldLength[i] = Const.toInt(slen, -1);
        fieldPrecision[i] = Const.toInt(sprc, -1);
        fieldTrimType[i] = ValueMeta.getTrimTypeByCode(trim);
      }
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "FieldSplitterMeta.Exception.UnableToLoadStepInfoFromXML"),
          e); //$NON-NLS-1$
    }
  }
コード例 #28
0
ファイル: AggregateRowsMeta.java プロジェクト: cnopens/BA
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      int i, nrfields;
      String type;

      Node fields = XMLHandler.getSubNode(stepnode, "fields"); // $NON-NLS-1$
      nrfields = XMLHandler.countNodes(fields, "field"); // $NON-NLS-1$

      allocate(nrfields);

      for (i = 0; i < nrfields; i++) {
        Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i); // $NON-NLS-1$
        fieldName[i] = XMLHandler.getTagValue(fnode, "name"); // $NON-NLS-1$
        fieldNewName[i] = XMLHandler.getTagValue(fnode, "rename"); // $NON-NLS-1$
        type = XMLHandler.getTagValue(fnode, "type"); // $NON-NLS-1$
        aggregateType[i] = getType(type);
      }
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "AggregateRowsMeta.Exception.UnableToLoadStepInfo"),
          e); //$NON-NLS-1$
    }
  }
コード例 #29
0
  public XMLInputSaxField(Node fnode) throws KettleValueException {
    setName(XMLHandler.getTagValue(fnode, "name"));
    setType(ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")));
    setFormat(XMLHandler.getTagValue(fnode, "format"));
    setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
    setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
    setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
    setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
    setPrecision(Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
    setTrimType(getTrimType(XMLHandler.getTagValue(fnode, "trim_type")));
    setRepeated(!"N".equalsIgnoreCase(XMLHandler.getTagValue(fnode, "repeat")));

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

    fieldPosition = new XMLInputSaxFieldPosition[nrPositions];

    for (int i = 0; i < nrPositions; i++) {
      Node positionnode = XMLHandler.getSubNodeByNr(positions, "position", i);
      String encoded = XMLHandler.getNodeValue(positionnode);
      fieldPosition[i] = new XMLInputSaxFieldPosition(encoded);
    }
  }
コード例 #30
0
  private void readData(Node stepnode) throws KettleXMLException {
    try {
      setBatchSize(XMLHandler.getTagValue(stepnode, "batchSize"));
      setSalesforceIDFieldName(XMLHandler.getTagValue(stepnode, "salesforceIDFieldName"));

      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, "useExternalId");
        if (updateValue == null) {
          // default FALSE
          useExternalId[i] = Boolean.FALSE;
        } else {
          if (updateValue.equalsIgnoreCase("Y")) {
            useExternalId[i] = Boolean.TRUE;
          } else {
            useExternalId[i] = Boolean.FALSE;
          }
        }
      }
      setRollbackAllChangesOnError(
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "rollbackAllChangesOnError")));

    } catch (Exception e) {
      throw new KettleXMLException("Unable to load step info from XML", e);
    }
  }