use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.
the class ComponentDerivationRecordTest method testPutOperationNullOperation.
@Test
public void testPutOperationNullOperation() throws Exception {
Operations operations = record.getOperations();
assertNotNull(operations);
assertTrue(operations.isEmpty());
record.addOperation(null);
String operands = "testOperand1, testOperand2";
record.addOperation(new Operation(null, operands));
operations = record.getOperations();
assertNotNull(operations);
List<IOperation> checkOperands = operations.get("testOperation");
assertNull(checkOperands);
}
use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.
the class ComponentDerivationRecordTest method testGetOperations.
@Test
public void testGetOperations() throws Exception {
Operations operations = record.getOperations();
assertNotNull(operations);
assertTrue(operations.isEmpty());
String operands = "testOperand1, testOperand2";
record.addOperation(new Operation("testOperation", operands));
assertNull(record.getOperations(ChangeType.DATA));
assertNotNull(record.getOperations(ChangeType.METADATA));
}
use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testMapChange.
@Test
public void testMapChange() throws Exception {
doReturn(outputs).when(analyzer).getOutputs();
doReturn(inputs).when(analyzer).getInputs();
Operation operation = new Operation("testOperation", "testOperation");
StepField original = new StepField("previousStep", "address");
StepField changed = new StepField("nextStep", "address");
ComponentDerivationRecord cdr = new ComponentDerivationRecord(original, changed);
cdr.addOperation(operation);
ComponentDerivationRecord spyCdr = spy(cdr);
analyzer.mapChange(spyCdr);
// get operations to verify it is not null, then agains to toString it
verify(spyCdr, times(1)).getOperations();
verify(analyzer).linkChangeNodes(any(IMetaverseNode.class), any(IMetaverseNode.class));
}
use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.
the class NumberRangeStepAnalyzer method getChangeRecords.
@Override
public Set<ComponentDerivationRecord> getChangeRecords(final NumberRangeMeta meta) throws MetaverseAnalyzerException {
Set<ComponentDerivationRecord> changeRecords = new HashSet<>();
ComponentDerivationRecord changeRecord = new ComponentDerivationRecord(meta.getInputField(), meta.getOutputField(), ChangeType.DATA);
List<NumberRangeRule> rules = meta.getRules();
if (rules != null) {
for (NumberRangeRule rule : rules) {
changeRecord.addOperation(new Operation(Operation.MAPPING_CATEGORY, ChangeType.DATA, DictionaryConst.PROPERTY_TRANSFORMS, rule.getLowerBound() + " <= " + meta.getInputField() + " <= " + rule.getUpperBound() + " -> " + rule.getValue()));
}
}
changeRecords.add(changeRecord);
return changeRecords;
}
use of org.pentaho.metaverse.api.model.Operation 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;
}
Aggregations