use of org.pentaho.di.core.Condition in project pentaho-metaverse by pentaho.
the class FilterRowsStepAnalyzer method customAnalyze.
@Override
protected void customAnalyze(FilterRowsMeta stepMeta, IMetaverseNode stepNode) {
// add the filter condition as properties on the step node
final Condition condition = stepMeta.getCondition();
if (condition != null) {
String filterCondition = condition.toString();
Operation operation = new Operation("filter", ChangeType.DATA_FLOW, DATA_FLOW_CONDITION, filterCondition);
ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(stepNode.getName(), ChangeType.DATA_FLOW);
changeRecord.addOperation(operation);
stepNode.setProperty(DictionaryConst.PROPERTY_OPERATIONS, changeRecord.toString());
}
}
use of org.pentaho.di.core.Condition in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConditionDelegate method saveCondition.
public ObjectId saveCondition(Condition condition, ObjectId id_condition_parent) throws KettleException {
try {
condition.setObjectId(insertCondition(id_condition_parent, condition));
for (int i = 0; i < condition.nrConditions(); i++) {
Condition subc = condition.getCondition(i);
repository.saveCondition(subc, condition.getObjectId());
}
return condition.getObjectId();
} catch (KettleException dbe) {
throw new KettleException("Error saving condition to the repository.", dbe);
}
}
use of org.pentaho.di.core.Condition in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryConditionDelegate method loadCondition.
/**
* Read a condition from the repository.
*
* @param id_condition
* The condition id
* @throws KettleException
* if something goes wrong.
*/
public Condition loadCondition(ObjectId id_condition) throws KettleException {
Condition condition = new Condition();
try {
RowMetaAndData r = getCondition(id_condition);
if (r != null) {
condition.setNegated(r.getBoolean("NEGATED", false));
condition.setOperator(Condition.getOperator(r.getString("OPERATOR", null)));
long conditionId = r.getInteger("ID_CONDITION", -1L);
if (conditionId > 0) {
condition.setObjectId(new LongObjectId(conditionId));
} else {
condition.setObjectId(null);
}
ObjectId[] subids = repository.getSubConditionIDs(condition.getObjectId());
if (subids.length == 0) {
condition.setLeftValuename(r.getString("LEFT_NAME", null));
condition.setFunction(Condition.getFunction(r.getString("CONDITION_FUNCTION", null)));
condition.setRightValuename(r.getString("RIGHT_NAME", null));
long id_value = r.getInteger("ID_VALUE_RIGHT", -1L);
if (id_value > 0) {
ValueMetaAndData v = repository.loadValueMetaAndData(new LongObjectId(id_value));
condition.setRightExact(v);
}
} else {
for (int i = 0; i < subids.length; i++) {
condition.addCondition(loadCondition(subids[i]));
}
}
return condition;
} else {
throw new KettleException("Condition with id_condition=" + id_condition + " could not be found in the repository");
}
} catch (KettleException dbe) {
throw new KettleException("Error loading condition from the repository (id_condition=" + id_condition + ")", dbe);
}
}
use of org.pentaho.di.core.Condition in project pentaho-kettle by pentaho.
the class FilterRowsMetaTest method modifiedTarget.
@Test
public void modifiedTarget() throws Exception {
FilterRowsMeta filterRowsMeta = new FilterRowsMeta();
StepMeta trueOutput = new StepMeta("true", new DummyTransMeta());
StepMeta falseOutput = new StepMeta("false", new DummyTransMeta());
filterRowsMeta.setCondition(new Condition());
filterRowsMeta.setTrueStepname(trueOutput.getName());
filterRowsMeta.setFalseStepname(falseOutput.getName());
filterRowsMeta.searchInfoAndTargetSteps(ImmutableList.of(trueOutput, falseOutput));
trueOutput.setName("true renamed");
falseOutput.setName("false renamed");
assertEquals("true renamed", filterRowsMeta.getTrueStepname());
assertEquals("false renamed", filterRowsMeta.getFalseStepname());
}
use of org.pentaho.di.core.Condition in project pentaho-kettle by pentaho.
the class ConditionLoadSaveValidator method getTestObject.
@Override
public Condition getTestObject() {
Condition rtn = new Condition();
rtn.setFunction(rand.nextInt(Condition.functions.length));
rtn.setLeftValuename(UUID.randomUUID().toString());
rtn.setNegated(rand.nextBoolean());
rtn.setOperator(rand.nextInt(Condition.operators.length));
rtn.setRightValuename(UUID.randomUUID().toString());
return rtn;
}
Aggregations