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);
}
}
}
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));
}
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);
}
}
}
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));
}
}
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;
}
Aggregations