use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class CalculatorStepAnalyzer method buildChangeRecord.
protected Set<ComponentDerivationRecord> buildChangeRecord(final CalculatorMetaFunction function) {
Set<ComponentDerivationRecord> changes = new HashSet<>();
String fieldA = function.getFieldA();
String fieldB = function.getFieldB();
String fieldC = function.getFieldC();
String inputFields = (fieldA != null ? fieldA + ", " : "") + (fieldB != null ? fieldB + ", " : "") + (fieldC != null ? fieldC + ", " : "");
List<String> fields = new ArrayList<>();
if (fieldA != null) {
fields.add(fieldA);
}
if (fieldB != null) {
fields.add(fieldB);
}
if (fieldC != null) {
fields.add(fieldC);
}
for (String field : fields) {
final ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(field, function.getFieldName(), ChangeType.DATA);
changeRecord.addOperation(new Operation(Operation.CALC_CATEGORY, ChangeType.DATA, DictionaryConst.PROPERTY_TRANSFORMS, inputFields + "using " + function.getCalcTypeDesc() + " -> " + function.getFieldName()));
changes.add(changeRecord);
}
return changes;
}
use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord 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.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class GroupByStepAnalyzer method getChangeRecords.
@Override
public Set<ComponentDerivationRecord> getChangeRecords(final GroupByMeta groupByMeta) throws MetaverseAnalyzerException {
Set<ComponentDerivationRecord> changeRecords = new HashSet<>();
for (int i = 0; i < groupByMeta.getSubjectField().length; i++) {
ComponentDerivationRecord changeRecord = buildChangeRecord(groupByMeta.getSubjectField()[i], groupByMeta.getAggregateField()[i], groupByMeta.getAggregateType()[i]);
changeRecords.add(changeRecord);
}
return changeRecords;
}
use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class GroupByStepAnalyzer method buildChangeRecord.
private ComponentDerivationRecord buildChangeRecord(String subjectField, String aggregateField, int aggregateType) {
final ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(subjectField, aggregateField, ChangeType.DATA);
changeRecord.addOperation(new Operation(Operation.AGG_CATEGORY, ChangeType.DATA, DictionaryConst.PROPERTY_TRANSFORMS, subjectField + " using " + GroupByMeta.getTypeDesc(aggregateType) + " -> " + aggregateField));
return changeRecord;
}
use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class GroupByStepAnalyzerTest method testGetChangeRecords.
@Test
public void testGetChangeRecords() throws Exception {
Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(meta);
assertEquals(2, changeRecords.size());
ComponentDerivationRecord next = changeRecords.iterator().next();
assertTrue(next.getOriginalEntityName().equals("member") || next.getOriginalEntityName().equals("donation"));
if (next.getOriginalEntityName().equals("member")) {
assertEquals("memberlist", next.getChangedEntityName());
} else {
assertEquals("totalcity", next.getChangedEntityName());
}
}
Aggregations