use of org.pentaho.metaverse.api.model.IOperation in project pentaho-metaverse by pentaho.
the class MetaverseUtil method convertOperationsStringToMap.
public static Operations convertOperationsStringToMap(String operations) {
Operations resultOps = null;
if (!Const.isEmpty(operations)) {
try {
Map<String, List<IOperation>> rawOpsMap = new JSONDeserializer<Map<String, List<IOperation>>>().use("values.values", Operation.class).deserialize(operations);
resultOps = new Operations();
for (String key : rawOpsMap.keySet()) {
resultOps.put(ChangeType.forValue(key), rawOpsMap.get(key));
}
} catch (Exception e) {
resultOps = null;
}
// return new JSONDeserializer<Operations>().use(null, Operations.class).deserialize( operations );
}
return resultOps;
}
use of org.pentaho.metaverse.api.model.IOperation in project pentaho-metaverse by pentaho.
the class SplitFieldsStepAnalyzerTest method testGetChangeRecords.
@Test
public void testGetChangeRecords() throws Exception {
Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(meta);
assertEquals(3, changeRecords.size());
for (ComponentDerivationRecord changeRecord : changeRecords) {
assertEquals("splitField", changeRecord.getOriginalEntityName());
assertTrue(ArrayUtils.contains(outputFields, changeRecord.getChangedEntityName()));
Operations operations = changeRecord.getOperations();
// Only data operations
assertEquals(1, operations.size());
List<IOperation> dataOperations = operations.get(ChangeType.DATA);
assertEquals(1, dataOperations.size());
}
}
use of org.pentaho.metaverse.api.model.IOperation in project pentaho-metaverse by pentaho.
the class ValueMapperStepAnalyzerTest method testGetChangeRecords.
@Test
public void testGetChangeRecords() throws Exception {
Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(meta);
assertEquals(1, changeRecords.size());
ComponentDerivationRecord changeRecord = changeRecords.iterator().next();
assertEquals(meta.getFieldToUse(), changeRecord.getOriginalEntityName());
assertEquals((meta.getTargetField() == null ? meta.getFieldToUse() : meta.getTargetField()), changeRecord.getChangedEntityName());
Operations operations = changeRecord.getOperations();
// Only data operations
assertEquals(1, operations.size());
List<IOperation> dataOperations = operations.get(ChangeType.DATA);
assertEquals(2, dataOperations.size());
}
use of org.pentaho.metaverse.api.model.IOperation in project pentaho-metaverse by pentaho.
the class ComponentDerivationRecordTest method testAddOperandNullOperand.
@Test
public void testAddOperandNullOperand() throws Exception {
Operations operations = record.getOperations();
assertNotNull(operations);
assertTrue(operations.isEmpty());
record.addOperation(new Operation("testOperation", null));
List<IOperation> checkOperands = record.getOperations().get("testOperation");
assertNull(checkOperands);
}
use of org.pentaho.metaverse.api.model.IOperation in project pentaho-metaverse by pentaho.
the class ComponentDerivationRecordTest method testAddOperand.
@Test
public void testAddOperand() throws Exception {
record.operations = null;
record.addOperation(new Operation("testOperation", "testOperand"));
Operations operations = record.getOperations();
assertNotNull(operations);
List<IOperation> checkOperations = operations.get(ChangeType.METADATA);
assertNotNull(checkOperations);
assertEquals(1, checkOperations.size());
IOperation checkOperation = checkOperations.get(0);
assertTrue("testOperand not in operands!", checkOperation.getDescription().contains("testOperand"));
}
Aggregations