2015-04-07 33 views
0

我有兩個目標流(匹配和不匹配),定義如下:發送不同的元數據,以不同的目標流 - PDI

@Override 
public StepIOMetaInterface getStepIOMeta() { 

    StepMeta stepMeta = new StepMeta(); 


    if (ioMeta == null) { 
     ioMeta = new StepIOMeta(true, false, false, false, false, true); 

     StreamInterface matchStream = new Stream(StreamType.TARGET, null, "Matches", StreamIcon.TARGET, null); 
     StreamInterface mismatchStream = new Stream(StreamType.TARGET, null, "Mismatches", StreamIcon.TARGET, null); 

     ioMeta.addStream(matchStream); 
     ioMeta.addStream(mismatchStream); 

    } 

    return ioMeta; 
} 

我想不同的元數據發送到這兩個目標。元數據是從前面的步驟中收到的。對於匹配,它需要是兩個輸入流的串聯,並且僅僅是第一個輸入流的不匹配。

我被困在如何分別爲兩個目標流定義元數據。

感謝您的幫助。

回答

0
List<StreamInterface> targets=getStepIOMeta().getTargetStreams();  
     List<StreamInterface> infos=getStepIOMeta().getInfoStreams(); 
     if (info != null) 
    { 
      if(targets!=null) 
      { 

if(nextStep.getName().equals(targets.get(0).getStepname())) 
        { 
         if (info != null) { 
           for (int i = 0; i < info.length; i++) { 
           if (info[i] != null) { 
            r.mergeRowMeta(info[i]); 
           } 
           } 
          } 
        } 
        if(nextStep.getName().equals(targets.get(1).getStepname())) 
        { 
         if (info != null) { 
           if (info.length > 0 && info[0] != null) { 
           r.mergeRowMeta(info[0]); 
           } 
          } 
        } 
        if(nextStep.getName().equals(targets.get(2).getStepname())) 
        { 
         if (info != null) { 
           if (info.length > 0 && info[0] != null) { 
           r.mergeRowMeta(info[1]); 
           } 
          } 
        } 

      } 
+0

這應該以傳遞給目標步的元數據,但爲了做到這一點,你應該有目標列表,並知道他們的名字,所以你可以從第一步驟中的元數據,並通過被添加到getFields方法目標 – Shyqyri

+1

更好的是在你的答案中編輯這個評論。 – serenesat

相關問題