我使用Pentaho ddata集成的5.0.1版。 使用UDJC,我以特定的方式操纵数据。当我预先确定UDJC步骤中的数据时,数据是正确的。但如果将输出复制到虚拟步骤,则数据与UDJC步骤中预先设定的数据不同。
由于 java代码如下:
import java.util.*;
long current_id=-1;
long tmp_id=-1;
long i=0;
Object[] out_row1 =null;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
{
// Read current Line
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
String tmp = get(Fields.In, "date_mod").getString(r);
Long modif_id = get(Fields.In, "id").getInteger(r);
Long tmp_id = get(Fields.In, "items_id").getInteger(r);
Long id_search_option = get(Fields.In, "id_search_option").getInteger(r);
Long is_requester = get(Fields.In, "is_requester").getInteger(r);
String itemtype_link = get(Fields.In, "itemtype_link").getString(r);
String date_from = get(Fields.In, "date_from").getString(r);
String date_to = get(Fields.In, "date_to").getString(r);
if ( current_id==tmp_id )
{
//No change
if(null==tmp)
{
Object[] out_row = createOutputRow(r, data.outputRowMeta.size());
putRow(data.outputRowMeta, out_row);
return true;
}
//A change Occure
else
{
//add modif
String tmp1 = get(Fields.In, "date_mod").getString(out_row1);
Long modif_id1 = get(Fields.In, "id").getInteger(out_row1);
String status=get(Fields.Out, "statusvalue").getString(out_row1);
Long technicien=get(Fields.Out, "technicien").getInteger(out_row1);
Long technical_group=get(Fields.Out, "technical_group").getInteger(out_row1);
Long requester_group=get(Fields.Out, "requester_group").getInteger(out_row1);
//New modif date
if (modif_id1!=modif_id)
{
Object[] out_row= createOutputRow(r, data.outputRowMeta.size());
get(Fields.Out, "date_from").setValue(out_row1,tmp);
out_row=out_row1;
putRow(data.outputRowMeta, out_row);
date_to=get(Fields.Out, "date_from").getString(out_row1);
get(Fields.Out, "date_to").setValue(out_row1,date_to);
get(Fields.Out, "id").setValue(out_row1,modif_id);
}
//The same modif date (Two CASE: same modif for multiple data set OR many modif
//for a data set
if (id_search_option==12)//modif status
{
status = get(Fields.In, "old_value").getString(r);
get(Fields.Out, "statusvalue").setValue(out_row1,status);
} else if (itemtype_link=="User") //modif technicien
{
technicien = get(Fields.In, "old_value").getInteger(r);
get(Fields.Out, "technicien").setValue(out_row1,technicien);
} else { //modif technical groupe
if (is_requester==1)
{
requester_group = get(Fields.In, "old_value").getInteger(r);
get(Fields.Out, "requester_group").setValue(out_row1,requester_group);
} else {
technical_group = get(Fields.In, "old_value").getInteger(r);
get(Fields.Out, "technical_group").setValue(out_row1,technical_group);
}
}
return true;
}
//id change
} else {
if (out_row1!=null)
{
Object[] out_row = createOutputRow(r, data.outputRowMeta.size());
String date=get(Fields.Out, "date").getString(out_row1);
get(Fields.Out, "date_from").setValue(out_row1,date);
out_row=out_row1;
putRow(data.outputRowMeta, out_row);
out_row1=null;
}
current_id=tmp_id;
if(null==tmp)
{
Object[] out_row = createOutputRow(r, data.outputRowMeta.size());
putRow(data.outputRowMeta, out_row);
return true;
}
//A change Occure
else
{
Object[] out_row = createOutputRow(r, data.outputRowMeta.size());
get(Fields.Out, "date_from").setValue(out_row,tmp);
putRow(data.outputRowMeta, out_row);
out_row1=out_row;
//add first modif
if (id_search_option==12)//modif status
{
String status = get(Fields.In, "old_value").getString(r);
get(Fields.Out, "statusvalue").setValue(out_row1,status);
} else if (itemtype_link=="User") //modif technicien
{
Long technicien = get(Fields.In, "old_value").getInteger(r);
get(Fields.Out, "technicien").setValue(out_row1,technicien);
} else {
//modif technical or requester group
if (is_requester==1)
{
Long requester_group = get(Fields.In, "old_value").getInteger(r);
//technical_group.replaceFirst("\\D*(\\d*).*", "$1");
get(Fields.Out, "requester_group").setValue(out_row1,requester_group);
} else {
Long technical_group = get(Fields.In, "old_value").getInteger(r);
get(Fields.Out, "technical_group").setValue(out_row1,technical_group);
}
}
get(Fields.Out, "date_to").setValue(out_row1,tmp);
return true;
}
}
}
答案 0 :(得分:0)
如果我在输出行之前添加等待时间,则所有数据都是正确的。这可以解决我的问题但会降低我的表现。 任何建议。