Search in sources :

Example 16 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class TransMetaJsonDeserializer method deserializeSteps.

protected void deserializeSteps(TransMeta transMeta, JsonNode node, ObjectMapper mapper) throws IOException {
    ArrayNode stepsArrayNode = (ArrayNode) node.get(TransMetaJsonSerializer.JSON_PROPERTY_STEPS);
    String stepName = null;
    for (int i = 0; i < stepsArrayNode.size(); i++) {
        JsonNode stepNode = stepsArrayNode.get(i);
        String className = stepNode.get(IInfo.JSON_PROPERTY_CLASS).asText();
        stepName = stepNode.get(IInfo.JSON_PROPERTY_NAME).asText();
        ObjectId stepId = new StringObjectId(stepName);
        // add the step attributes to the repo so they can be found when they are looked up by the readRep impl
        JsonNode attributes = stepNode.get(AbstractStepMetaJsonSerializer.JSON_PROPERTY_ATTRIBUTES);
        writeJsonAttributes(attributes, mapper, stepId);
        JsonNode fields = stepNode.get(AbstractStepMetaJsonSerializer.JSON_PROPERTY_FIELDS);
        writeJsonFields(fields, mapper, stepId);
        try {
            Class clazz = this.getClass().getClassLoader().loadClass(className);
            BaseStepMeta meta = (BaseStepMeta) clazz.newInstance();
            meta.readRep(getRepository(), null, stepId, transMeta.getDatabases());
            StepMetaInterface smi = (StepMetaInterface) meta;
            StepMeta step = new StepMeta(stepName, smi);
            transMeta.addStep(step);
        } catch (Exception e) {
            LOGGER.warn(Messages.getString("WARNING.Deserialization.Trans.Steps", stepName), e);
        }
    }
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) KettleException(org.pentaho.di.core.exception.KettleException) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException)

Example 17 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method getBaseStepMetaFromStepMeta.

protected BaseStepMeta getBaseStepMetaFromStepMeta(StepMeta stepMeta) {
    // Attempt to discover a BaseStepMeta from the given StepMeta
    BaseStepMeta baseStepMeta = new BaseStepMeta();
    baseStepMeta.setParentStepMeta(stepMeta);
    if (stepMeta != null) {
        StepMetaInterface smi = stepMeta.getStepMetaInterface();
        if (smi instanceof BaseStepMeta) {
            baseStepMeta = (BaseStepMeta) smi;
        }
    }
    return baseStepMeta;
}
Also used : StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta)

Example 18 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class TransformationAnalyzer method getBaseStepMetaFromStepMeta.

protected BaseStepMeta getBaseStepMetaFromStepMeta(StepMeta stepMeta) {
    // Attempt to discover a BaseStepMeta from the given StepMeta
    BaseStepMeta baseStepMeta = new BaseStepMeta();
    baseStepMeta.setParentStepMeta(stepMeta);
    if (stepMeta != null) {
        StepMetaInterface smi = stepMeta.getStepMetaInterface();
        if (smi instanceof BaseStepMeta) {
            baseStepMeta = (BaseStepMeta) smi;
        }
    }
    return baseStepMeta;
}
Also used : StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta)

Example 19 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class StepAnalyzerProviderTest method testGetAnalyzersForClass.

@Test
public void testGetAnalyzersForClass() throws Exception {
    Set<IStepAnalyzer> baseStepAnalyzerSet = Sets.newSet(mock(IStepAnalyzer.class));
    Set<IStepAnalyzer> tableOutputStepAnalyzerSet = Sets.newSet(mock(IStepAnalyzer.class));
    // Return the baseStepAnalyzer set if BaseStepMeta analyzers are requested
    provider.analyzerTypeMap.put(BaseStepMeta.class, baseStepAnalyzerSet);
    // Return the tableOutputStepAnalyzerSet set if TableOutputMeta analyzers are requested
    provider.analyzerTypeMap.put(TableOutputMeta.class, tableOutputStepAnalyzerSet);
    List<IStepAnalyzer> analyzers = provider.getAnalyzers(new ArrayList() {

        {
            add(BaseStepMeta.class);
            add(TableOutputMeta.class);
        }
    });
    assertEquals(analyzers.size(), 2);
    analyzers = provider.getAnalyzers(new HashSet() {

        {
            add(TableOutputMeta.class);
        }
    });
    assertEquals(analyzers.size(), 1);
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) ArrayList(java.util.ArrayList) TableOutputMeta(org.pentaho.di.trans.steps.tableoutput.TableOutputMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 20 with BaseStepMeta

use of org.pentaho.di.trans.step.BaseStepMeta in project pentaho-metaverse by pentaho.

the class AbstractStepMetaJsonSerializerTest method setUp.

@Before
public void setUp() throws Exception {
    repo = new LineageRepository();
    serializer = new BaseStepMetaJsonSerializer(BaseStepMeta.class, repo);
    spyMeta = spy(new BaseStepMeta());
    spyParent = spy(new StepMeta());
    spyParentTrans = spy(new TransMeta());
    when(spyMeta.getParentStepMeta()).thenReturn(spyParent);
    when(spyParent.getName()).thenReturn(STEP_META_NAME);
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) LineageRepository(org.pentaho.metaverse.impl.model.kettle.LineageRepository) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) Before(org.junit.Before)

Aggregations

BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)22 Test (org.junit.Test)8 HashSet (java.util.HashSet)7 StepMeta (org.pentaho.di.trans.step.StepMeta)7 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)6 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)3 KettleException (org.pentaho.di.core.exception.KettleException)3 TransMeta (org.pentaho.di.trans.TransMeta)3 StepInterface (org.pentaho.di.trans.step.StepInterface)3 MetaverseObjectFactory (org.pentaho.metaverse.api.MetaverseObjectFactory)3 StepField (org.pentaho.metaverse.api.StepField)3 IStepAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer)3 IStepExternalResourceConsumer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer)3 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)3 Set (java.util.Set)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 ObjectId (org.pentaho.di.repository.ObjectId)2 StringObjectId (org.pentaho.di.repository.StringObjectId)2 Trans (org.pentaho.di.trans.Trans)2