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"), ""));
      limit = Const.NVL(XMLHandler.getTagValue(entrynode, "limit"), "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"));
      isClearResultList =
          "Y".equalsIgnoreCase(XMLHandler.getTagValue(entrynode, "clear_result_rows"));

    } catch (KettleException e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "JobEntryEvalTableContent.UnableLoadXML"), e);
    }
  }
  /**
   * 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);
    }
  }
Example #3
0
  public String getXML() {
    StringBuffer retval = new StringBuffer(500);

    retval.append("    <fields>").append(Const.CR); // $NON-NLS-1$

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

    retval.append("    </fields>").append(Const.CR); // $NON-NLS-1$

    return retval.toString();
  }
  @Override
  public String getXML() {
    StringBuilder xml = new StringBuilder();
    xml.append(XMLHandler.addTagValue("name", name));
    xml.append(XMLHandler.addTagValue("filename", fileName));
    xml.append(XMLHandler.addTagValue("service_step", serviceStepName));
    xml.append(XMLHandler.openTag(XML_TAG_VARIABLE_MAPS));
    List<FieldVariableMapping> list = new ArrayList<FieldVariableMapping>(fieldVariableMappings);
    Collections.sort(
        list,
        new Comparator<FieldVariableMapping>() {
          @Override
          public int compare(FieldVariableMapping o1, FieldVariableMapping o2) {
            return o1.getFieldName().compareTo(o2.getFieldName());
          }
        });

    for (FieldVariableMapping mapping : list) {
      xml.append(XMLHandler.openTag(XML_TAG_VARIABLE_MAP));
      xml.append(XMLHandler.addTagValue("field", mapping.getFieldName()));
      xml.append(XMLHandler.addTagValue("variable", mapping.getVariableName()));
      xml.append(XMLHandler.addTagValue("type", mapping.getMappingType().name()));
      xml.append(XMLHandler.closeTag(XML_TAG_VARIABLE_MAP));
    }
    xml.append(XMLHandler.closeTag(XML_TAG_VARIABLE_MAPS));
    return xml.toString();
  }
  @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;
  }
  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 #7
0
  @Override
  public void loadPage(Map<String, List<String>> parameterHolder) throws KettlePageException {
    try {
      JSONArray fields = XMLHandler.getPageRows(parameterHolder, fid("fields"));
      int nrfields = fields.size();

      allocate(nrfields);

      for (int i = 0; i < nrfields; i++) {
        JSONObject field = (JSONObject) fields.get(i);

        fieldName[i] = (String) field.get("fieldName");
        fieldType[i] = (String) field.get("fieldType");
        fieldFormat[i] = (String) field.get("fieldFormat");
        currency[i] = (String) field.get("currency");
        decimal[i] = (String) field.get("decimal");
        group[i] = (String) field.get("group");
        value[i] = (String) field.get("value");

        fieldLength[i] = Const.toInt(String.valueOf(field.get("fieldLength")), -1);
        fieldPrecision[i] = Const.toInt(String.valueOf(field.get("fieldPrecision")), -1);
        setEmptyString[i] = Const.toBoolean(String.valueOf(field.get("setEmptyString")), false);
      }

      rowLimit = XMLHandler.getPageValue(parameterHolder, fid("limit"));
    } catch (Exception e) {
      throw new KettlePageException(
          "Unexpected error reading step information from the repository", e);
    }
  }
  @Override
  public void loadXML(Node ruleNode) throws KettleException {
    super.loadXML(ruleNode);

    schemaName = XMLHandler.getTagValue(ruleNode, "schema_name");
    tableName = XMLHandler.getTagValue(ruleNode, "table_name");
    connectionName = XMLHandler.getTagValue(ruleNode, "connection_name");
  }
Example #9
0
  public String getXML() {
    StringBuilder retval = new StringBuilder();

    List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
    retval.append(XMLHandler.addTagValue("head_name", infoStreams.get(0).getStepname()));
    retval.append(XMLHandler.addTagValue("tail_name", infoStreams.get(1).getStepname()));

    return retval.toString();
  }
  public String getXML() {
    StringBuffer retval = new StringBuffer(200);

    retval.append(super.getXML());
    retval.append("      ").append(XMLHandler.addTagValue("maximumTimeout", maximumTimeout));
    retval.append("      ").append(XMLHandler.addTagValue("scaletime", scaleTime));

    return retval.toString();
  }
 public TransDataService(Node serviceNode) {
   this(
       XMLHandler.getTagValue(serviceNode, "name"),
       XMLHandler.getTagValue(serviceNode, "filename"),
       null,
       XMLHandler.getTagValue(serviceNode, "service_step"),
       extractFieldVariableMapping(serviceNode),
       ServiceCacheMethod.None);
 }
  public String getXML() throws KettleException {
    StringBuffer retval = new StringBuffer(150);

    retval.append("    ").append(XMLHandler.addTagValue("rule_file_name", ruleFilename));
    retval.append("    ").append(XMLHandler.addTagValue("rule_step_main", stepMain));
    retval.append("    ").append(XMLHandler.addTagValue("rule_step_rule_results", stepRuleResults));
    retval.append("    ").append(XMLHandler.addTagValue("output_type", outputType));
    return retval.toString();
  }
 public void loadXML(Node stepnode, List<DatabaseMeta> databases, Map<String, Counter> counters)
     throws KettleXMLException {
   int nrCalcs = XMLHandler.countNodes(stepnode, CalculatorMetaFunction.XML_TAG);
   allocate(nrCalcs);
   for (int i = 0; i < nrCalcs; i++) {
     Node calcnode = XMLHandler.getSubNodeByNr(stepnode, CalculatorMetaFunction.XML_TAG, i);
     calculation[i] = new CalculatorMetaFunction(calcnode);
   }
 }
  public String getXML() {
    StringBuffer retval = new StringBuffer();

    retval.append("    " + XMLHandler.addTagValue("urlField", urlField));
    retval.append("    " + XMLHandler.addTagValue("readTimeOut", readTimeOut));
    retval.append("    " + XMLHandler.addTagValue("connectTimeOut", connectTimeOut));
    retval.append("    " + XMLHandler.addTagValue("resultfieldname", resultfieldname));
    return retval.toString();
  }
  /* (non-Javadoc)
   * @see org.pentaho.di.repository.RepositoryMeta#getXML()
   */
  public String getXML() {
    StringBuffer retval = new StringBuffer(100);

    retval.append("    ").append(XMLHandler.addTagValue("id", id));
    retval.append("    ").append(XMLHandler.addTagValue("name", name));
    retval.append("    ").append(XMLHandler.addTagValue("description", description));

    return retval.toString();
  }
    public String getXML() {
      StringBuffer retval = new StringBuffer(100);

      retval.append("  ").append(XMLHandler.openTag(XML_TAG));
      retval.append(super.getXML());
      retval.append("    ").append(XMLHandler.addTagValue("repository_location_url", url));
      retval.append("  ").append(XMLHandler.closeTag(XML_TAG));

      return retval.toString();
    }
  protected ModelAnnotationGroup readModelAnnotationGroup(Node step) throws KettleXMLException {

    setModelAnnotationCategory(XMLHandler.getTagValue(step, "category"));
    setTargetOutputStep(XMLHandler.getTagValue(step, "targetOutputStep"));
    ModelAnnotationGroupXmlReader mar = new ModelAnnotationGroupXmlReader();
    ModelAnnotationGroup modelAnnotationGroup = mar.readModelAnnotationGroup(step);
    sharedDimension = modelAnnotationGroup.isSharedDimension();

    return modelAnnotationGroup;
  }
  public String getXML() {
    StringBuilder retval = new StringBuilder(300);

    retval.append("      ").append(XMLHandler.addTagValue("valuename", valuename));
    retval.append("      ").append(XMLHandler.addTagValue("slave", slaveServerName));
    retval.append("      ").append(XMLHandler.addTagValue("seqname", sequenceName));
    retval.append("      ").append(XMLHandler.addTagValue("increment", increment));

    return retval.toString();
  }
 /* (non-Javadoc)
  * @see org.pentaho.di.repository.RepositoryMeta#loadXML(org.w3c.dom.Node, java.util.List)
  */
 public void loadXML(Node repnode, List<DatabaseMeta> databases) throws KettleException {
   try {
     // Fix for PDI-2508: migrating from 3.2 to 4.0 causes NPE on startup.
     id = Const.NVL(XMLHandler.getTagValue(repnode, "id"), id);
     name = XMLHandler.getTagValue(repnode, "name");
     description = XMLHandler.getTagValue(repnode, "description");
   } catch (Exception e) {
     throw new KettleException("Unable to load repository meta object", e);
   }
 }
  public String getXML() {
    StringBuffer xml = new StringBuffer();

    xml.append("     " + XMLHandler.addTagValue("hostname", hostname));
    xml.append("     " + XMLHandler.addTagValue("port", port));
    xml.append("     " + XMLHandler.addTagValue("buffer_size", bufferSize));
    xml.append("     " + XMLHandler.addTagValue("compressed", compressed));

    return xml.toString();
  }
  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);
    }
  }
  private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
      throws KettleXMLException {
    try {
      String csize;
      String con = XMLHandler.getTagValue(stepnode, "connection");
      databaseMeta = DatabaseMeta.findDatabase(databases, con);
      csize = XMLHandler.getTagValue(stepnode, "commit");
      commitSize = Const.toInt(csize, 0);
      sqlField = XMLHandler.getTagValue(stepnode, "sql_field");

      insertField = XMLHandler.getTagValue(stepnode, "insert_field");
      updateField = XMLHandler.getTagValue(stepnode, "update_field");
      deleteField = XMLHandler.getTagValue(stepnode, "delete_field");
      readField = XMLHandler.getTagValue(stepnode, "read_field");
      sqlFromfile = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "sqlFromfile"));

      sendOneStatement =
          "Y"
              .equalsIgnoreCase(
                  Const.NVL(XMLHandler.getTagValue(stepnode, "sendOneStatement"), "Y"));
    } catch (Exception e) {
      throw new KettleXMLException(
          BaseMessages.getString(PKG, "ExecSQLRowMeta.Exception.UnableToLoadStepInfoFromXML"), e);
    }
  }
 public void loadXML(Node repnode, List<DatabaseMeta> databases) throws KettleException {
   super.loadXML(repnode, databases);
   try {
     baseDirectory = XMLHandler.getTagValue(repnode, "base_directory");
     readOnly = "Y".equalsIgnoreCase(XMLHandler.getTagValue(repnode, "read_only"));
     hidingHiddenFiles =
         "Y".equalsIgnoreCase(XMLHandler.getTagValue(repnode, "hides_hidden_files"));
   } catch (Exception e) {
     throw new KettleException("Unable to load Kettle file repository meta object", e);
   }
 }
Example #24
0
 public YamlInputField(Node fnode) throws KettleValueException {
   setName(XMLHandler.getTagValue(fnode, "name"));
   setPath(XMLHandler.getTagValue(fnode, "path"));
   setType(ValueMeta.getType(XMLHandler.getTagValue(fnode, "type")));
   setFormat(XMLHandler.getTagValue(fnode, "format"));
   setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
   setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
   setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
   setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
   setPrecision(Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
   setTrimType(getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type")));
 }
  public String getXML() {
    StringBuffer retval = new StringBuffer();

    retval.append("    " + XMLHandler.addTagValue("accept_field", acceptingField));
    for (SasInputField field : outputFields) {
      retval.append(XMLHandler.openTag(XML_TAG_FIELD));
      retval.append(field.getXML());
      retval.append(XMLHandler.closeTag(XML_TAG_FIELD));
    }

    return retval.toString();
  }
 private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
     throws KettleXMLException {
   try {
     urlField = XMLHandler.getTagValue(stepnode, "urlField");
     connectTimeOut = XMLHandler.getTagValue(stepnode, "connectTimeOut");
     readTimeOut = XMLHandler.getTagValue(stepnode, "readTimeOut");
     resultfieldname = XMLHandler.getTagValue(stepnode, "resultfieldname");
   } catch (Exception e) {
     throw new KettleXMLException(
         BaseMessages.getString(PKG, "WebServiceAvailableMeta.Exception.UnableToReadStepInfo"), e);
   }
 }
 private void readData(Node stepnode, List<? extends SharedObjectInterface> databases)
     throws KettleXMLException {
   try {
     valuename = XMLHandler.getTagValue(stepnode, "valuename");
     slaveServerName = XMLHandler.getTagValue(stepnode, "slave");
     sequenceName = XMLHandler.getTagValue(stepnode, "seqname");
     increment = XMLHandler.getTagValue(stepnode, "increment");
   } catch (Exception e) {
     throw new KettleXMLException(
         BaseMessages.getString(PKG, "GetSequenceMeta.Exception.ErrorLoadingStepInfo"), e);
   }
 }
Example #28
0
 private void readData(Node stepnode) throws KettleXMLException {
   try {
     List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
     StreamInterface headStream = infoStreams.get(0);
     StreamInterface tailStream = infoStreams.get(1);
     headStream.setSubject(XMLHandler.getTagValue(stepnode, "head_name"));
     tailStream.setSubject(XMLHandler.getTagValue(stepnode, "tail_name"));
   } catch (Exception e) {
     throw new KettleXMLException(
         BaseMessages.getString(PKG, "AppendMeta.Exception.UnableToLoadStepInfo"), e);
   }
 }
  public void loadXML(Node stepnode, List<DatabaseMeta> databases, Map<String, Counter> counters)
      throws KettleXMLException {
    try {
      ruleFilename = XMLHandler.getTagValue(stepnode, "rule_file_name");
      stepMain = XMLHandler.getTagValue(stepnode, "rule_step_main");
      stepRuleResults = XMLHandler.getTagValue(stepnode, "rule_step_rule_results");
      outputType = Integer.parseInt(XMLHandler.getTagValue(stepnode, "output_type"));

    } catch (Exception e) {
      throw new KettleXMLException("Unable to read rule engine step info from XML node", e);
    }
  }
  public String getXML() {
    StringBuilder retval = new StringBuilder(100);

    retval.append("  ").append(XMLHandler.openTag(XML_TAG));
    retval.append(super.getXML());
    retval.append("    ").append(XMLHandler.addTagValue("base_directory", baseDirectory));
    retval.append("    ").append(XMLHandler.addTagValue("read_only", readOnly));
    retval.append("    ").append(XMLHandler.addTagValue("hides_hidden_files", hidingHiddenFiles));
    retval.append("  ").append(XMLHandler.closeTag(XML_TAG));

    return retval.toString();
  }