Search in sources :

Example 6 with IOperation

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;
}
Also used : List(java.util.List) JSONDeserializer(flexjson.JSONDeserializer) IOperation(org.pentaho.metaverse.api.model.IOperation) Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) MetaverseException(org.pentaho.metaverse.api.MetaverseException) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException)

Example 7 with IOperation

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());
    }
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 8 with IOperation

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());
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 9 with IOperation

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);
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) IOperation(org.pentaho.metaverse.api.model.IOperation) Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 10 with IOperation

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"));
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) IOperation(org.pentaho.metaverse.api.model.IOperation) Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Aggregations

IOperation (org.pentaho.metaverse.api.model.IOperation)16 Operations (org.pentaho.metaverse.api.model.Operations)16 Test (org.junit.Test)15 Operation (org.pentaho.metaverse.api.model.Operation)7 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)4 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)3 TransformationStepNode (org.pentaho.metaverse.frames.TransformationStepNode)3 List (java.util.List)2 ValueMapperMeta (org.pentaho.di.trans.steps.valuemapper.ValueMapperMeta)2 FieldNode (org.pentaho.metaverse.frames.FieldNode)2 JSONDeserializer (flexjson.JSONDeserializer)1 Set (java.util.Set)1 NumberRangeMeta (org.pentaho.di.trans.steps.numberrange.NumberRangeMeta)1 SelectValuesMeta (org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta)1 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)1 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1 StepFieldOperations (org.pentaho.metaverse.api.StepFieldOperations)1 SelectValuesTransStepNode (org.pentaho.metaverse.frames.SelectValuesTransStepNode)1