Search in sources :

Example 6 with BpmnNode

use of org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode in project kie-wb-common by kiegroup.

the class IntermediateCatchEventConverter method convertBoundaryEvent.

public BpmnNode convertBoundaryEvent(BoundaryEvent event) {
    CatchEventPropertyReader p = propertyReaderFactory.of(event);
    List<EventDefinition> eventDefinitions = p.getEventDefinitions();
    switch(eventDefinitions.size()) {
        case 0:
            throw new UnsupportedOperationException("A boundary event should contain exactly one definition");
        case 1:
            return Match.of(EventDefinition.class, BpmnNode.class).when(SignalEventDefinition.class, e -> signalEvent(event, e)).when(TimerEventDefinition.class, e -> timerEvent(event, e)).when(MessageEventDefinition.class, e -> messageEvent(event, e)).when(ErrorEventDefinition.class, e -> errorEvent(event, e)).missing(EscalationEventDefinition.class).missing(CompensateEventDefinition.class).missing(ConditionalEventDefinition.class).apply(eventDefinitions.get(0)).value();
        default:
            throw new UnsupportedOperationException("Multiple definitions not supported for boundary event");
    }
}
Also used : EventDefinition(org.eclipse.bpmn2.EventDefinition) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) CancellingErrorEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.CancellingErrorEventExecutionSet) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) CancellingMessageEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.CancellingMessageEventExecutionSet) Edge(org.kie.workbench.common.stunner.core.graph.Edge) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) ErrorRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.ErrorRef) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) CancelActivity(org.kie.workbench.common.stunner.bpmn.definition.property.event.CancelActivity) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) IntermediateSignalEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventCatching) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) CancellingSignalEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.CancellingSignalEventExecutionSet) CancellingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.CancellingTimerEventExecutionSet) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) EventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) List(java.util.List) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) Match(org.kie.workbench.common.stunner.bpmn.backend.converters.Match) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) CatchEvent(org.eclipse.bpmn2.CatchEvent) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) Node(org.kie.workbench.common.stunner.core.graph.Node) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) EventDefinition(org.eclipse.bpmn2.EventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition)

Example 7 with BpmnNode

use of org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode in project kie-wb-common by kiegroup.

the class StartEventConverter method convert.

public BpmnNode convert(StartEvent event) {
    CatchEventPropertyReader p = propertyReaderFactory.of(event);
    List<EventDefinition> eventDefinitions = p.getEventDefinitions();
    switch(eventDefinitions.size()) {
        case 0:
            return noneEvent(event);
        case 1:
            return Match.of(EventDefinition.class, BpmnNode.class).when(SignalEventDefinition.class, e -> signalEvent(event, e)).when(MessageEventDefinition.class, e -> messageEvent(event, e)).when(TimerEventDefinition.class, e -> timerEvent(event, e)).when(ErrorEventDefinition.class, e -> errorEvent(event, e)).missing(ConditionalEventDefinition.class).missing(EscalationEventDefinition.class).missing(CompensateEventDefinition.class).apply(eventDefinitions.get(0)).value();
        default:
            throw new UnsupportedOperationException("Multiple event definitions not supported for start event");
    }
}
Also used : StartEvent(org.eclipse.bpmn2.StartEvent) EventDefinition(org.eclipse.bpmn2.EventDefinition) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) Edge(org.kie.workbench.common.stunner.core.graph.Edge) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) StartSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) StartTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) ErrorRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.ErrorRef) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) InterruptingSignalEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.InterruptingSignalEventExecutionSet) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) EventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition) InterruptingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.InterruptingTimerEventExecutionSet) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) InterruptingErrorEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.InterruptingErrorEventExecutionSet) List(java.util.List) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) Match(org.kie.workbench.common.stunner.bpmn.backend.converters.Match) Optional(java.util.Optional) StartMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.StartMessageEvent) IsInterrupting(org.kie.workbench.common.stunner.bpmn.definition.property.event.IsInterrupting) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) Node(org.kie.workbench.common.stunner.core.graph.Node) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) InterruptingMessageEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.InterruptingMessageEventExecutionSet) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) CatchEventPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.CatchEventPropertyReader) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) EventDefinition(org.eclipse.bpmn2.EventDefinition) ErrorEventDefinition(org.eclipse.bpmn2.ErrorEventDefinition) SignalEventDefinition(org.eclipse.bpmn2.SignalEventDefinition) MessageEventDefinition(org.eclipse.bpmn2.MessageEventDefinition) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) EscalationEventDefinition(org.eclipse.bpmn2.EscalationEventDefinition) CompensateEventDefinition(org.eclipse.bpmn2.CompensateEventDefinition) TimerEventDefinition(org.eclipse.bpmn2.TimerEventDefinition)

Example 8 with BpmnNode

use of org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode in project kie-wb-common by kiegroup.

the class AbstractProcessConverter method convertLaneSets.

private void convertLaneSets(List<LaneSet> laneSets, Map<String, BpmnNode> freeFloatingNodes, BpmnNode firstDiagramNode) {
    laneSets.stream().flatMap(laneSet -> laneSet.getLanes().stream()).forEach(lane -> {
        BpmnNode laneNode = converterFactory.laneConverter().convert(lane);
        laneNode.setParent(firstDiagramNode);
        lane.getFlowNodeRefs().forEach(node -> {
            freeFloatingNodes.get(node.getId()).setParent(laneNode);
        });
    });
}
Also used : LinkedHashMap(java.util.LinkedHashMap) Result(org.kie.workbench.common.stunner.bpmn.backend.converters.Result) List(java.util.List) LaneSet(org.eclipse.bpmn2.LaneSet) Map(java.util.Map) TypedFactoryManager(org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) FlowElement(org.eclipse.bpmn2.FlowElement) PropertyReaderFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)

Example 9 with BpmnNode

use of org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode in project kie-wb-common by kiegroup.

the class RootProcessConverter method convertProcess.

public BpmnNode convertProcess() {
    Process process = definitionResolver.getProcess();
    String definitionsId = definitionResolver.getDefinitions().getId();
    BpmnNode processRoot = convertProcessNode(definitionsId, process);
    Map<String, BpmnNode> nodes = super.convertChildNodes(processRoot, process.getFlowElements(), process.getLaneSets());
    super.convertEdges(processRoot, process.getFlowElements(), nodes);
    return processRoot;
}
Also used : Process(org.eclipse.bpmn2.Process) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)

Example 10 with BpmnNode

use of org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshaller method unmarshall.

@Override
public Graph<DefinitionSet, Node> unmarshall(final Metadata metadata, final InputStream inputStream) throws IOException {
    LOG.debug("Starting diagram unmarshalling...");
    // definition resolver provides utlities to access elements of the BPMN datamodel
    DefinitionResolver definitionResolver = new DefinitionResolver(parseDefinitions(inputStream));
    metadata.setCanvasRootUUID(definitionResolver.getDefinitions().getId());
    metadata.setTitle(definitionResolver.getProcess().getName());
    ConverterFactory converterFactory = new ConverterFactory(definitionResolver, typedFactoryManager);
    // perform actual conversion. Process is the root of the diagram
    BpmnNode diagramRoot = converterFactory.rootProcessConverter().convertProcess();
    LOG.debug("Diagram unmarshalling completed successfully.");
    // the root node contains all of the information
    // needed to build the entire graph (including parent/child relationships)
    // thus, we can now walk the graph to issue all the commands
    // to draw it on our canvas
    Diagram<Graph<DefinitionSet, Node>, Metadata> diagram = typedFactoryManager.newDiagram(definitionResolver.getDefinitions().getId(), BPMNDefinitionSet.class, metadata);
    GraphBuilder graphBuilder = new GraphBuilder(diagram.getGraph(), definitionManager, typedFactoryManager, ruleManager, commandFactory, commandManager);
    graphBuilder.render(diagramRoot);
    LOG.debug("Diagram drawing completed successfully.");
    return diagram.getGraph();
}
Also used : DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) GraphBuilder(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.GraphBuilder) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)

Aggregations

BpmnNode (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)10 List (java.util.List)6 TypedFactoryManager (org.kie.workbench.common.stunner.bpmn.backend.converters.TypedFactoryManager)6 PropertyReaderFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.PropertyReaderFactory)6 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)6 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)6 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)6 Node (org.kie.workbench.common.stunner.core.graph.Node)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)6 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)5 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)5 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)5 EventDefinition (org.eclipse.bpmn2.EventDefinition)5 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)5 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)5 Match (org.kie.workbench.common.stunner.bpmn.backend.converters.Match)5 EventPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader)5 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)5 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)5 SignalRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef)5