コード例 #1
0
 public StreamInterface findTargetStream(StepMeta targetStep) {
   for (StreamInterface stream : getTargetStreams()) {
     if (targetStep.equals(stream.getStepMeta())) {
       return stream;
     }
   }
   return null;
 }
コード例 #2
0
 public StreamInterface findInfoStream(StepMeta infoStep) {
   for (StreamInterface stream : getInfoStreams()) {
     if (infoStep.equals(stream.getStepMeta())) {
       return stream;
     }
   }
   return null;
 }
コード例 #3
0
  private void ok() {
    if (Utils.isEmpty(wStepname.getText())) {
      return;
    }

    input.setMainStreamField(wMainStreamField.getText());
    input.setLookupField(wLookupField.getText());

    input.setAlgorithmType(FuzzyMatchMeta.getAlgorithmTypeByDesc(wAlgorithm.getText()));
    input.setCaseSensitive(wcaseSensitive.getSelection());
    input.setGetCloserValue(wgetCloserValue.getSelection());
    input.setMaximalValue(wmaxValue.getText());
    input.setMinimalValue(wminValue.getText());

    input.setOutputMatchField(wmatchField.getText());
    input.setOutputValueField(wvalueField.getText());
    input.setSeparator(wseparator.getText());

    int nrvalues = wReturn.nrNonEmpty();
    input.allocate(nrvalues);
    if (isDebug()) {
      logDebug(BaseMessages.getString(PKG, "FuzzyMatchDialog.Log.FoundFields", nrvalues + ""));
    }
    // CHECKSTYLE:Indentation:OFF
    for (int i = 0; i < nrvalues; i++) {
      TableItem item = wReturn.getNonEmpty(i);
      input.getValue()[i] = item.getText(1);
      input.getValueName()[i] = item.getText(2);
      if (input.getValueName()[i] == null || input.getValueName()[i].length() == 0) {
        input.getValueName()[i] = input.getValue()[i];
      }
    }

    StreamInterface infoStream = input.getStepIOMeta().getInfoStreams().get(0);
    infoStream.setStepMeta(transMeta.findStep(wStep.getText()));
    if (infoStream.getStepMeta() == null) {
      MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
      if (Utils.isEmpty(wStep.getText())) {
        mb.setMessage(
            BaseMessages.getString(
                PKG, "FuzzyMatchDialog.NotStepSpecified.DialogMessage", wStep.getText()));
      } else {
        mb.setMessage(
            BaseMessages.getString(
                PKG, "FuzzyMatchDialog.StepCanNotFound.DialogMessage", wStep.getText()));
      }

      mb.setText(BaseMessages.getString(PKG, "FuzzyMatchDialog.StepCanNotFound.DialogTitle"));
      mb.open();
    }

    stepname = wStepname.getText(); // return value

    dispose();
  }
コード例 #4
0
 /**
  * @return the target streams of this step. Important: Modifying this list does not have any
  *     effect on the Steps IO metadata.
  */
 public List<StreamInterface> getTargetStreams() {
   List<StreamInterface> list = new ArrayList<StreamInterface>();
   synchronized (streams) {
     for (StreamInterface stream : streams) {
       if (stream.getStreamType().equals(StreamInterface.StreamType.TARGET)) {
         list.add(stream);
       }
     }
   }
   return list;
 }
コード例 #5
0
  /** Copy information from the meta-data input to the dialog fields. */
  public void getData() {
    if (isDebug()) {
      logDebug(BaseMessages.getString(PKG, "FuzzyMatchDialog.Log.GettingKeyInfo"));
    }

    wAlgorithm.setText(FuzzyMatchMeta.getAlgorithmTypeDesc(input.getAlgorithmType()));

    if (input.getMainStreamField() != null) {
      wMainStreamField.setText(input.getMainStreamField());
    }
    if (input.getLookupField() != null) {
      wLookupField.setText(input.getLookupField());
    }
    wcaseSensitive.setSelection(input.isCaseSensitive());
    wgetCloserValue.setSelection(input.isGetCloserValue());
    if (input.getMinimalValue() != null) {
      wminValue.setText(input.getMinimalValue());
    }
    if (input.getMaximalValue() != null) {
      wmaxValue.setText(input.getMaximalValue());
    }
    if (input.getOutputMatchField() != null) {
      wmatchField.setText(input.getOutputMatchField());
    }
    if (input.getOutputValueField() != null) {
      wvalueField.setText(input.getOutputValueField());
    }
    if (input.getSeparator() != null) {
      wseparator.setText(input.getSeparator());
    }

    if (input.getValue() != null) {
      for (int i = 0; i < input.getValue().length; i++) {
        TableItem item = wReturn.table.getItem(i);
        if (input.getValue()[i] != null) {
          item.setText(1, input.getValue()[i]);
        }
        if (input.getValueName()[i] != null
            && !input.getValueName()[i].equals(input.getValue()[i])) {
          item.setText(2, input.getValueName()[i]);
        }
      }
    }

    StreamInterface infoStream = input.getStepIOMeta().getInfoStreams().get(0);
    wStep.setText(Const.NVL(infoStream.getStepname(), ""));

    wReturn.setRowNums();
    wReturn.optWidth(true);

    wStepname.selectAll();
    wStepname.setFocus();
  }
コード例 #6
0
ファイル: AppendMeta.java プロジェクト: MarsChan/learngit
 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);
   }
 }
コード例 #7
0
ファイル: AppendMeta.java プロジェクト: MarsChan/learngit
 public void saveRep(
     Repository rep, IMetaStore metaStore, ObjectId id_transformation, ObjectId id_step)
     throws KettleException {
   try {
     List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
     StreamInterface headStream = infoStreams.get(0);
     StreamInterface tailStream = infoStreams.get(1);
     rep.saveStepAttribute(id_transformation, id_step, "head_name", headStream.getStepname());
     rep.saveStepAttribute(id_transformation, id_step, "tail_name", tailStream.getStepname());
   } catch (Exception e) {
     throw new KettleException(
         BaseMessages.getString(PKG, "AppendMeta.Exception.UnableToSaveStepInfo") + id_step, e);
   }
 }
コード例 #8
0
ファイル: AppendMeta.java プロジェクト: MarsChan/learngit
 public void readRep(
     Repository rep, IMetaStore metaStore, ObjectId id_step, List<DatabaseMeta> databases)
     throws KettleException {
   try {
     List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
     StreamInterface headStream = infoStreams.get(0);
     StreamInterface tailStream = infoStreams.get(1);
     headStream.setSubject(rep.getStepAttributeString(id_step, "head_name"));
     tailStream.setSubject(rep.getStepAttributeString(id_step, "tail_name"));
   } catch (Exception e) {
     throw new KettleException(
         BaseMessages.getString(PKG, "AppendMeta.Exception.UnexpectedErrorReadingStepInfo"), e);
   }
 }
コード例 #9
0
 /**
  * Replace the info steps with the supplied source steps.
  *
  * @param infoSteps
  */
 public void setInfoSteps(StepMeta[] infoSteps) {
   // First get the info steps...
   //
   List<StreamInterface> list = new ArrayList<StreamInterface>();
   synchronized (streams) {
     for (StreamInterface stream : streams) {
       if (stream.getStreamType().equals(StreamInterface.StreamType.INFO)) {
         list.add(stream);
       }
     }
   }
   for (int i = 0; i < infoSteps.length; i++) {
     if (i >= list.size()) {
       throw new RuntimeException("We expect all possible info streams to be pre-populated!");
     }
     streams.get(i).setStepMeta(infoSteps[i]);
   }
 }
コード例 #10
0
  /**
   * Get the meta data
   *
   * @param meta
   */
  private void getMeta(MultiMergeJoinMeta meta) {
    StepIOMetaInterface stepIOMeta = meta.getStepIOMeta();
    List<StreamInterface> infoStreams = stepIOMeta.getInfoStreams();
    StreamInterface stream;
    String streamDescription;
    ArrayList<String> inputStepNameList = new ArrayList<String>();
    ArrayList<String> keyList = new ArrayList<String>();
    CCombo wInputStep;
    String inputStepName;
    for (int i = 0; i < wInputStepArray.length; i++) {
      wInputStep = wInputStepArray[i];
      inputStepName = wInputStep.getText();

      if (Const.isEmpty(inputStepName)) {
        continue;
      }

      inputStepNameList.add(inputStepName);
      keyList.add(keyValTextBox[i].getText());

      if (infoStreams.size() < inputStepNameList.size()) {
        streamDescription = BaseMessages.getString(PKG, "MultiMergeJoin.InfoStream.Description");
        stream = new Stream(StreamType.INFO, null, streamDescription, StreamIcon.INFO, null);
        stepIOMeta.addStream(stream);
      }
    }

    int inputStepCount = inputStepNameList.size();
    meta.allocateInputSteps(inputStepCount);
    meta.allocateKeys(inputStepCount);

    String[] inputSteps = meta.getInputSteps();
    String[] keyFields = meta.getKeyFields();
    infoStreams = stepIOMeta.getInfoStreams();
    for (int i = 0; i < inputStepCount; i++) {
      inputStepName = inputStepNameList.get(i);
      inputSteps[i] = inputStepName;
      stream = infoStreams.get(i);
      stream.setStepMeta(transMeta.findStep(inputStepName));
      keyFields[i] = keyList.get(i);
    }

    meta.setJoinType(joinTypeCombo.getText());
  }
コード例 #11
0
ファイル: AppendMeta.java プロジェクト: MarsChan/learngit
  public void check(
      List<CheckResultInterface> remarks,
      TransMeta transMeta,
      StepMeta stepMeta,
      RowMetaInterface prev,
      String[] input,
      String[] output,
      RowMetaInterface info,
      VariableSpace space,
      Repository repository,
      IMetaStore metaStore) {
    CheckResult cr;

    List<StreamInterface> infoStreams = getStepIOMeta().getInfoStreams();
    StreamInterface headStream = infoStreams.get(0);
    StreamInterface tailStream = infoStreams.get(1);

    if (headStream.getStepname() != null && tailStream.getStepname() != null) {
      cr =
          new CheckResult(
              CheckResultInterface.TYPE_RESULT_OK,
              BaseMessages.getString(PKG, "AppendMeta.CheckResult.SourceStepsOK"),
              stepMeta);
      remarks.add(cr);
    } else if (headStream.getStepname() == null && tailStream.getStepname() == null) {
      cr =
          new CheckResult(
              CheckResultInterface.TYPE_RESULT_ERROR,
              BaseMessages.getString(PKG, "AppendMeta.CheckResult.SourceStepsMissing"),
              stepMeta);
      remarks.add(cr);
    } else {
      cr =
          new CheckResult(
              CheckResultInterface.TYPE_RESULT_OK,
              BaseMessages.getString(PKG, "AppendMeta.CheckResult.OneSourceStepMissing"),
              stepMeta);
      remarks.add(cr);
    }
  }
コード例 #12
0
ファイル: AppendMeta.java プロジェクト: MarsChan/learngit
 @Override
 public void searchInfoAndTargetSteps(List<StepMeta> steps) {
   for (StreamInterface stream : getStepIOMeta().getInfoStreams()) {
     stream.setStepMeta(StepMeta.findStep(steps, (String) stream.getSubject()));
   }
 }