use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.
the class StringsReplaceStepAnalyzer method buildChangeRecord.
private ComponentDerivationRecord buildChangeRecord(final ReplaceStringMeta stringsReplaceMeta, final int index) throws MetaverseAnalyzerException {
String fieldInString = stringsReplaceMeta.getFieldInStream()[index];
String fieldOutString = stringsReplaceMeta.getFieldOutStream()[index];
if (containsField(fieldOutString)) {
Integer nameIdx = renameIndex.get(fieldOutString);
renameIndex.put(fieldOutString, (nameIdx == null ? 1 : nameIdx + 1));
fieldOutString += "_" + renameIndex.get(fieldOutString);
}
if (fieldOutString == null || fieldOutString.length() < 1) {
fieldOutString = fieldInString;
}
final ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(fieldInString, fieldOutString, ChangeType.DATA);
final String fieldReplaceString = stringsReplaceMeta.getFieldReplaceByString()[index];
String changeOperation = fieldInString + " -> [ replace [ ";
changeOperation += stringsReplaceMeta.getReplaceString()[index] + " with ";
if (fieldReplaceString != null && fieldReplaceString.length() > 0) {
changeOperation += fieldReplaceString;
} else {
changeOperation += stringsReplaceMeta.getReplaceByString()[0];
}
changeOperation += " ] ] -> " + fieldOutString;
changeRecord.addOperation(new Operation(Operation.CALC_CATEGORY, ChangeType.DATA, DictionaryConst.PROPERTY_TRANSFORMS, changeOperation));
return changeRecord;
}
use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.
the class ValueMapperStepAnalyzer method getChangeRecords.
@Override
public Set<ComponentDerivationRecord> getChangeRecords(ValueMapperMeta valueMapperMeta) throws MetaverseAnalyzerException {
final String fieldToUse = valueMapperMeta.getFieldToUse();
final String targetField = valueMapperMeta.getTargetField() == null ? fieldToUse : valueMapperMeta.getTargetField();
final String[] sourceValues = valueMapperMeta.getSourceValue();
final String[] targetValues = valueMapperMeta.getTargetValue();
Set<ComponentDerivationRecord> changeRecords = new HashSet<>(1);
final ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(fieldToUse, targetField, ChangeType.DATA);
for (int i = 0; i < sourceValues.length; i++) {
String mapping = sourceValues[i] + " -> " + targetValues[i];
changeRecord.addOperation(new Operation(Operation.MAPPING_CATEGORY, ChangeType.DATA, DictionaryConst.PROPERTY_TRANSFORMS, mapping));
}
changeRecords.add(changeRecord);
return changeRecords;
}
use of org.pentaho.metaverse.api.model.Operation 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.model.Operation 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.model.Operation 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;
}
Aggregations