Search in sources :

Example 1 with Transition

use of ru.fix.completable.reactor.api.ReactorGraphModel.Transition in project completable-reactor by ru-fix.

the class ProcessorsHaveIncomingFlowsValidator method validateGraph.

@Override
public void validateGraph(ReactorGraphModel graph) throws ValidationException {
    val processorsWithIncomingTransitions = graph.getMergePoints().stream().flatMap(mergePoint -> mergePoint.getTransitions().stream()).map(Transition::getHandleByProcessingItem).filter(Objects::nonNull).collect(Collectors.toSet());
    processorsWithIncomingTransitions.addAll(graph.getStartPoint().getProcessingItems());
    graph.getMergePoints().stream().flatMap(mergePoint -> mergePoint.getTransitions().stream()).map(Transition::getHandleByProcessingItem).filter(Objects::nonNull).forEach(processorsWithIncomingTransitions::add);
    val processorWithoutIncomingTransitions = Stream.concat(graph.getProcessors().stream().map(Processor::getIdentity), graph.getSubgraphs().stream().map(Subgraph::getIdentity)).filter(processor -> !processorsWithIncomingTransitions.contains(processor)).findAny();
    if (processorWithoutIncomingTransitions.isPresent()) {
        throw new ValidationException(String.format("ProcessingItem %s does not have incoming transitions.", processorWithoutIncomingTransitions.get()));
    }
}
Also used : lombok.val(lombok.val) ReactorGraphModel(ru.fix.completable.reactor.api.ReactorGraphModel) Objects(java.util.Objects) Stream(java.util.stream.Stream) lombok.val(lombok.val) Processor(ru.fix.completable.reactor.api.ReactorGraphModel.Processor) Transition(ru.fix.completable.reactor.api.ReactorGraphModel.Transition) Collectors(java.util.stream.Collectors) Subgraph(ru.fix.completable.reactor.api.ReactorGraphModel.Subgraph) Transition(ru.fix.completable.reactor.api.ReactorGraphModel.Transition)

Aggregations

Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 lombok.val (lombok.val)1 ReactorGraphModel (ru.fix.completable.reactor.api.ReactorGraphModel)1 Processor (ru.fix.completable.reactor.api.ReactorGraphModel.Processor)1 Subgraph (ru.fix.completable.reactor.api.ReactorGraphModel.Subgraph)1 Transition (ru.fix.completable.reactor.api.ReactorGraphModel.Transition)1