use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class StringOperationsStepAnalyzer method getChangeRecords.
@Override
public Set<ComponentDerivationRecord> getChangeRecords(final StringOperationsMeta stringOperationsMeta) throws MetaverseAnalyzerException {
Set<ComponentDerivationRecord> changeRecords = new HashSet<>();
for (int i = 0; i < stringOperationsMeta.getFieldInStream().length; i++) {
String fieldInString = stringOperationsMeta.getFieldInStream()[i];
String fieldOutString = stringOperationsMeta.getFieldOutStream()[i];
if (Const.isEmpty(fieldOutString)) {
fieldOutString = fieldInString;
}
final ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(fieldInString, fieldOutString, ChangeType.DATA);
String trimTypeDescription = StringOperationsMeta.getTrimTypeDesc(stringOperationsMeta.getTrimType()[i]);
String lowerUpperDescription = StringOperationsMeta.getLowerUpperDesc(stringOperationsMeta.getLowerUpper()[i]);
String initCapDescription = StringOperationsMeta.getInitCapDesc(stringOperationsMeta.getInitCap()[i]);
String digitsDescription = StringOperationsMeta.getDigitsDesc(stringOperationsMeta.getDigits()[i]);
String maskXMLDescription = StringOperationsMeta.getMaskXMLDesc(stringOperationsMeta.getMaskXML()[i]);
String paddingDescription = StringOperationsMeta.getPaddingDesc(stringOperationsMeta.getPaddingType()[i]);
String specialCharactersDescription = StringOperationsMeta.getRemoveSpecialCharactersDesc(stringOperationsMeta.getRemoveSpecialCharacters()[i]);
String changeOperation = fieldOutString;
changeOperation += " { trim = [ " + trimTypeDescription + " ] && ";
changeOperation += "lower/upper = [ " + lowerUpperDescription + " ] && ";
changeOperation += "padding = [ " + paddingDescription + (stringOperationsMeta.getPaddingType()[i] == StringOperationsMeta.PADDING_NONE ? "" : ", " + stringOperationsMeta.getPadChar()[i]) + ", " + stringOperationsMeta.getPadLen()[i] + " ] && ";
changeOperation += "cap = [ " + initCapDescription + " ] && ";
changeOperation += "maskXML = [ " + maskXMLDescription + " ] && ";
changeOperation += "digits = [ " + digitsDescription + " ] && ";
changeOperation += "remove = [ " + specialCharactersDescription + " ] } -> ";
changeOperation += fieldOutString;
changeRecord.addOperation(new Operation(Operation.CALC_CATEGORY, ChangeType.DATA, DictionaryConst.PROPERTY_TRANSFORMS, changeOperation));
changeRecords.add(changeRecord);
}
return changeRecords;
}
use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord 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.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class TableOutputStepAnalyzer method getChangeRecords.
@Override
public Set<ComponentDerivationRecord> getChangeRecords(TableOutputMeta meta) throws MetaverseAnalyzerException {
Set<ComponentDerivationRecord> changes = new HashSet<>();
String[] tableFields = meta.getFieldDatabase();
String[] streamFields = meta.getFieldStream();
if (getInputs() != null) {
Set<String> stepNames = getInputs().getStepNames();
for (int i = 0; i < tableFields.length; i++) {
String tableField = tableFields[i];
String streamField = streamFields[i];
for (String stepName : stepNames) {
if (!RESOURCE.equals(stepName)) {
StepField inputField = new StepField(stepName, streamField);
StepField outField = new StepField(RESOURCE, tableField);
ComponentDerivationRecord change = new ComponentDerivationRecord(inputField, outField);
changes.add(change);
}
}
}
}
return changes;
}
use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord 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.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class CalculatorStepAnalyzer method getChangeRecords.
@Override
public Set<ComponentDerivationRecord> getChangeRecords(final CalculatorMeta calculatorMeta) throws MetaverseAnalyzerException {
Set<ComponentDerivationRecord> changeRecords = new HashSet<ComponentDerivationRecord>();
for (CalculatorMetaFunction function : calculatorMeta.getCalculation()) {
Set<ComponentDerivationRecord> changeRecord = buildChangeRecord(function);
changeRecords.addAll(changeRecord);
}
return changeRecords;
}
Aggregations