Search in sources :

Example 36 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface in project pdi-dataservice-server-plugin by pentaho.

the class AnnotationsQueryServiceTest method createPseudoAnnotate.

private DummyTransMeta createPseudoAnnotate(final ModelAnnotationGroup mag) {
    final String magicKey = "KEY_MODEL_ANNOTATIONS";
    DummyTransMeta annot1Meta = new DummyTransMeta() {

        @Override
        public StepInterface getStep(StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr, final Trans trans) {
            return new DummyTrans(stepMeta, stepDataInterface, cnr, tr, trans) {

                @Override
                public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
                    ModelAnnotationGroup existing = (ModelAnnotationGroup) trans.getExtensionDataMap().get(magicKey);
                    if (existing == null) {
                        trans.getExtensionDataMap().put(magicKey, mag);
                    } else {
                        existing.addAll(mag);
                    }
                    return true;
                }
            };
        }
    };
    return annot1Meta;
}
Also used : ModelAnnotationGroup(org.pentaho.agilebi.modeler.models.annotations.ModelAnnotationGroup) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) DummyTrans(org.pentaho.di.trans.steps.dummytrans.DummyTrans) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) DummyTrans(org.pentaho.di.trans.steps.dummytrans.DummyTrans)

Example 37 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface 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 38 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface 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 39 with StepMetaInterface

use of org.pentaho.di.trans.step.StepMetaInterface 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 40 with StepMetaInterface

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

the class StepExternalResourceConsumerListener method callExtensionPoint.

/**
 * This method is called by the Kettle code when a step is about to start
 *
 * @param log    the logging channel to log debugging information to
 * @param object The subject object that is passed to the plugin code
 * @throws org.pentaho.di.core.exception.KettleException In case the plugin decides that an error has occurred
 *                                                       and the parent process should stop.
 */
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    if (stepConsumerProvider == null) {
        stepConsumerProvider = (IStepExternalResourceConsumerProvider) MetaverseBeanUtil.getInstance().get("IStepExternalResourceConsumerProvider");
    }
    StepMetaDataCombi stepCombi = (StepMetaDataCombi) object;
    if (stepCombi != null) {
        StepMetaInterface meta = stepCombi.meta;
        StepInterface step = stepCombi.step;
        if (meta != null) {
            Class<?> metaClass = meta.getClass();
            if (BaseStepMeta.class.isAssignableFrom(metaClass)) {
                if (stepConsumerProvider != null) {
                    // Put the class into a collection and get the consumers that can process this class
                    Set<Class<?>> metaClassSet = new HashSet<Class<?>>(1);
                    metaClassSet.add(metaClass);
                    List<IStepExternalResourceConsumer> stepConsumers = stepConsumerProvider.getExternalResourceConsumers(metaClassSet);
                    if (stepConsumers != null) {
                        for (IStepExternalResourceConsumer stepConsumer : stepConsumers) {
                            // We might know enough at this point, so call the consumer
                            Collection<IExternalResourceInfo> resources = stepConsumer.getResourcesFromMeta(meta);
                            addExternalResources(resources, step);
                            // Add a RowListener if the step is data-driven
                            if (stepConsumer.isDataDriven(meta)) {
                                stepCombi.step.addRowListener(new StepExternalConsumerRowListener(stepConsumer, step));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) IStepExternalResourceConsumer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer) HashSet(java.util.HashSet)

Aggregations

StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)77 StepMeta (org.pentaho.di.trans.step.StepMeta)40 KettleException (org.pentaho.di.core.exception.KettleException)31 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)21 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)20 TransMeta (org.pentaho.di.trans.TransMeta)16 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)16 TableItem (org.eclipse.swt.widgets.TableItem)15 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)15 SourceToTargetMapping (org.pentaho.di.core.SourceToTargetMapping)14 Trans (org.pentaho.di.trans.Trans)14 EnterMappingDialog (org.pentaho.di.ui.core.dialog.EnterMappingDialog)14 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)12 Point (org.pentaho.di.core.gui.Point)12 TransHopMeta (org.pentaho.di.trans.TransHopMeta)11 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)11 NotePadMeta (org.pentaho.di.core.NotePadMeta)8 KettleStepException (org.pentaho.di.core.exception.KettleStepException)8 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)8