Search in sources :

Example 81 with TransHopMeta

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

the class TransMetaJsonDeserializer method deserializeHops.

protected void deserializeHops(TransMeta transMeta, JsonNode root, ObjectMapper mapper) {
    ArrayNode hopsArray = (ArrayNode) root.get(TransMetaJsonSerializer.JSON_PROPERTY_HOPS);
    for (int i = 0; i < hopsArray.size(); i++) {
        JsonNode hopNode = hopsArray.get(i);
        try {
            HopInfo hop = mapper.readValue(hopNode.toString(), HopInfo.class);
            if (hop != null) {
                TransHopMeta hopMeta = new TransHopMeta();
                hopMeta.setFromStep(transMeta.findStep(hop.getFromStepName()));
                hopMeta.setToStep(transMeta.findStep(hop.getToStepName()));
                hopMeta.setEnabled(hop.isEnabled());
                transMeta.addTransHop(hopMeta);
            }
        } catch (IOException e) {
            LOGGER.warn(Messages.getString("WARNING.Deserialization.Trans.Hops"), e);
        }
    }
}
Also used : HopInfo(org.pentaho.metaverse.api.model.kettle.HopInfo) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) TransHopMeta(org.pentaho.di.trans.TransHopMeta) IOException(java.io.IOException)

Example 82 with TransHopMeta

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

the class TransMetaJsonSerializerTest method testSerializeHops.

@Test
public void testSerializeHops() throws Exception {
    TransHopMeta hop = mock(TransHopMeta.class);
    when(transMeta.nrTransHops()).thenReturn(1);
    when(transMeta.getTransHop(0)).thenReturn(hop);
    serializer.serializeHops(transMeta, json);
    verify(json).writeArrayFieldStart(TransMetaJsonSerializer.JSON_PROPERTY_HOPS);
    verify(json).writeObject(any(HopInfo.class));
}
Also used : HopInfo(org.pentaho.metaverse.api.model.kettle.HopInfo) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Test(org.junit.Test)

Example 83 with TransHopMeta

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

the class TransMutators method findUpstreamHops.

private static void findUpstreamHops(Set<TransHopMeta> upstreamHops, List<TransHopMeta> all, StepMeta step, final boolean includeTargetedSteps) {
    for (TransHopMeta hop : all) {
        if (hop.getToStep().equals(step) && !upstreamHops.contains(hop)) {
            upstreamHops.add(hop);
            // steps to be reachable, we need to leave those hops enabled
            if (includeTargetedSteps && !hop.getToStep().chosesTargetSteps()) {
                all.stream().filter(thm -> thm.getFromStep().equals(hop.getToStep())).filter(thm -> !upstreamHops.contains(thm)).forEach(thm -> findUpstreamHops(upstreamHops, all, thm.getToStep(), true));
            }
            findUpstreamHops(upstreamHops, all, hop.getFromStep(), includeTargetedSteps);
        }
    }
}
Also used : HashSet(java.util.HashSet) IntStream(java.util.stream.IntStream) StepMeta(org.pentaho.di.trans.step.StepMeta) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) TransMeta(org.pentaho.di.trans.TransMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Set(java.util.Set) TransHopMeta(org.pentaho.di.trans.TransHopMeta)

Example 84 with TransHopMeta

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

the class TransMutators method disableAllUnrelatedHops.

public static void disableAllUnrelatedHops(final String stepName, final TransMeta serviceTrans, final boolean includeTargetedSteps) {
    StepMeta step = serviceTrans.findStep(stepName);
    List<TransHopMeta> allHops = IntStream.range(0, serviceTrans.nrTransHops()).mapToObj(serviceTrans::getTransHop).collect(toList());
    HashSet<TransHopMeta> upstreamHops = new HashSet<>();
    findUpstreamHops(upstreamHops, allHops, step, includeTargetedSteps);
    if (upstreamHops.isEmpty()) {
        serviceTrans.getSteps().clear();
        serviceTrans.addStep(step);
        IntStream.generate(() -> 0).limit(serviceTrans.nrTransHops()).forEach(serviceTrans::removeTransHop);
    } else {
        allHops.stream().filter(thm -> !upstreamHops.contains(thm)).forEach(thm -> thm.setEnabled(false));
    }
}
Also used : HashSet(java.util.HashSet) IntStream(java.util.stream.IntStream) StepMeta(org.pentaho.di.trans.step.StepMeta) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) TransMeta(org.pentaho.di.trans.TransMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta) Set(java.util.Set) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) HashSet(java.util.HashSet)

Example 85 with TransHopMeta

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

the class SqlTransGenerator method addToTrans.

private StepMeta addToTrans(StepMeta sortStep, TransMeta transMeta, StepMeta lastStep) {
    transMeta.addStep(sortStep);
    transMeta.addTransHop(new TransHopMeta(lastStep, sortStep));
    return sortStep;
}
Also used : TransHopMeta(org.pentaho.di.trans.TransHopMeta)

Aggregations

TransHopMeta (org.pentaho.di.trans.TransHopMeta)153 StepMeta (org.pentaho.di.trans.step.StepMeta)127 TransMeta (org.pentaho.di.trans.TransMeta)114 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)80 Trans (org.pentaho.di.trans.Trans)78 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)71 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)71 StepInterface (org.pentaho.di.trans.step.StepInterface)70 RowStepCollector (org.pentaho.di.trans.RowStepCollector)66 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)63 RowProducer (org.pentaho.di.trans.RowProducer)49 InjectorMeta (org.pentaho.di.trans.steps.injector.InjectorMeta)49 Test (org.junit.Test)35 KettleException (org.pentaho.di.core.exception.KettleException)28 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)25 Point (org.pentaho.di.core.gui.Point)21 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)19 NotePadMeta (org.pentaho.di.core.NotePadMeta)15 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)14 File (java.io.File)12