Search in sources :

Example 1 with EventGateway

use of org.kie.workbench.common.stunner.bpmn.definition.EventGateway in project kie-wb-common by kiegroup.

the class GatewayConverterTest method testEvent.

@Test
public void testEvent() {
    EventGateway gateway = new EventGateway();
    gateway.getGeneral().getName().setValue(NAME);
    gateway.getGeneral().getDocumentation().setValue(DOCUMENTATION);
    Node<View<BaseGateway>, ?> node = newNode(UUID, gateway);
    when(propertyWriterFactory.of(any(org.eclipse.bpmn2.EventBasedGateway.class))).thenReturn(gatewayPropertyWriter);
    assertEquals(gatewayPropertyWriter, converter.toFlowElement(node));
    verifyCommonValues(gatewayPropertyWriter, node);
}
Also used : EventGateway(org.kie.workbench.common.stunner.bpmn.definition.EventGateway) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Example 2 with EventGateway

use of org.kie.workbench.common.stunner.bpmn.definition.EventGateway in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallEventGateway.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallEventGateway() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_EVENT_GATEWAY);
    assertDiagram(diagram, 7);
    assertEquals(diagram.getMetadata().getTitle(), "TestEventGateway");
    Graph graph = diagram.getGraph();
    Node<? extends Definition, ?> gatewayNode = graph.getNode("_AFDF2596-C521-4753-AC22-2DCCAD391F98");
    assertTrue(gatewayNode.getContent().getDefinition() instanceof EventGateway);
    EventGateway eventGateway = (EventGateway) gatewayNode.getContent().getDefinition();
    assertEquals("EventGatewayName", eventGateway.getGeneral().getName().getValue());
    assertEquals("EventGatewayDocumentation", eventGateway.getGeneral().getDocumentation().getValue());
    SequenceFlow inSequenceFlow = gatewayNode.getInEdges().stream().filter(edge -> "_E805280D-5862-4F56-B02A-E34F7D519050".equals(edge.getUUID())).map(edge -> (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition()).findFirst().orElseThrow(() -> new Exception("Expected sequenceFlow: _E805280D-5862-4F56-B02A-E34F7D519050 was not found"));
    SequenceFlow outSequenceFlow1 = gatewayNode.getOutEdges().stream().filter(edge -> "_CCEF6352-760D-4641-B9C9-0B01FD4DD704".equals(edge.getUUID())).map(edge -> (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition()).findFirst().orElseThrow(() -> new Exception("Expected sequenceFlow: _CCEF6352-760D-4641-B9C9-0B01FD4DD704 was not found"));
    SequenceFlow outSequenceFlow2 = gatewayNode.getOutEdges().stream().filter(edge -> "_1CD28E0D-1910-45FE-9AEC-932FA28C77AA".equals(edge.getUUID())).map(edge -> (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition()).findFirst().orElseThrow(() -> new Exception("Expected sequenceFlow: _1CD28E0D-1910-45FE-9AEC-932FA28C77AA was not found"));
    assertNotNull(inSequenceFlow);
    assertEquals("inSequence", inSequenceFlow.getGeneral().getName().getValue());
    assertNotNull(outSequenceFlow1);
    assertEquals("outSequence1", outSequenceFlow1.getGeneral().getName().getValue());
    assertNotNull(outSequenceFlow2);
    assertEquals("outSequence2", outSequenceFlow2.getGeneral().getName().getValue());
}
Also used : EventGateway(org.kie.workbench.common.stunner.bpmn.definition.EventGateway) Arrays(java.util.Arrays) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) ReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ReusableSubprocessTaskExecutionSet) EndErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.EndErrorEvent) Edge(org.kie.workbench.common.stunner.core.graph.Edge) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) SimulationSet(org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet) StartTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) GenericServiceTaskValue(org.kie.workbench.common.stunner.bpmn.definition.property.service.GenericServiceTaskValue) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) Matcher(java.util.regex.Matcher) BasePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter) GenericServiceTask(org.kie.workbench.common.stunner.bpmn.definition.GenericServiceTask) EndTerminateEvent(org.kie.workbench.common.stunner.bpmn.definition.EndTerminateEvent) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) BPMNTestDefinitionFactory(org.kie.workbench.common.stunner.bpmn.BPMNTestDefinitionFactory) WorkItemDefinitionMockRegistry(org.kie.workbench.common.stunner.bpmn.WorkItemDefinitionMockRegistry) NotificationValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) StartConditionalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartConditionalEvent) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) BaseReusableSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.BaseReusableSubprocessTaskExecutionSet) Stream(java.util.stream.Stream) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) GlobalVariables(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.GlobalVariables) Assert.assertFalse(org.junit.Assert.assertFalse) Dock(org.kie.workbench.common.stunner.core.graph.content.relationship.Dock) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) ViewConnectorImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnectorImpl) InputOutputSpecification(org.eclipse.bpmn2.InputOutputSpecification) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) DeclarationList(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.DeclarationList) NotificationsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationsInfo) Mockito.mock(org.mockito.Mockito.mock) StartCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.StartCompensationEvent) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) ItemDefinition(org.eclipse.bpmn2.ItemDefinition) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Mock(org.mockito.Mock) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) RunWith(org.junit.runner.RunWith) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) ArrayList(java.util.ArrayList) DataInput(org.eclipse.bpmn2.DataInput) Property(org.eclipse.bpmn2.Property) IntermediateEscalationEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEventThrowing) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) EndCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.EndCompensationEvent) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) IntermediateSignalEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventCatching) Before(org.junit.Before) MetaDataType(org.jboss.drools.MetaDataType) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) EndMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.EndMessageEvent) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) IntermediateEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEvent) Assert.assertTrue(org.junit.Assert.assertTrue) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Test(org.junit.Test) Association(org.kie.workbench.common.stunner.bpmn.definition.Association) InterruptingErrorEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.InterruptingErrorEventExecutionSet) Graph(org.kie.workbench.common.stunner.core.graph.Graph) IntermediateMessageEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventThrowing) Assert.assertNull(org.junit.Assert.assertNull) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) IsInterrupting(org.kie.workbench.common.stunner.bpmn.definition.property.event.IsInterrupting) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) ReassignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentsInfo) FlowElement(org.eclipse.bpmn2.FlowElement) ReassignmentValue(org.kie.workbench.common.stunner.bpmn.definition.property.reassignment.ReassignmentValue) Assert.assertEquals(org.junit.Assert.assertEquals) RootElement(org.eclipse.bpmn2.RootElement) IntermediateCompensationEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateCompensationEventThrowing) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) WorkItemDefinitionLookupService(org.kie.workbench.common.stunner.bpmn.workitem.service.WorkItemDefinitionLookupService) StartSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent) UserTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.UserTaskExecutionSet) Activity(org.eclipse.bpmn2.Activity) IntermediateCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateCompensationEvent) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutput(org.eclipse.bpmn2.DataOutput) Lane(org.kie.workbench.common.stunner.bpmn.definition.Lane) Assert.fail(org.junit.Assert.fail) Assertions.assertDiagram(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.Assertions.assertDiagram) EStructuralFeatureImpl(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Collectors(java.util.stream.Collectors) TaskTypes(org.kie.workbench.common.stunner.bpmn.definition.property.task.TaskTypes) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) List(java.util.List) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) Optional(java.util.Optional) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) StartMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.StartMessageEvent) Pattern(java.util.regex.Pattern) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Node(org.kie.workbench.common.stunner.core.graph.Node) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) EndEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.EndEscalationEvent) IntermediateConditionalEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateConditionalEvent) View(org.kie.workbench.common.stunner.core.graph.content.view.View) StunnerTestingGraphAPI(org.kie.workbench.common.stunner.core.StunnerTestingGraphAPI) GraphUtils(org.kie.workbench.common.stunner.core.graph.util.GraphUtils) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) Assertions.assertDocumentation(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.Assertions.assertDocumentation) Element(org.kie.workbench.common.stunner.core.graph.Element) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) Definitions(org.eclipse.bpmn2.Definitions) CancellingTimerEventExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.CancellingTimerEventExecutionSet) BPMNDirectDiagramMarshaller(org.kie.workbench.common.stunner.bpmn.backend.BPMNDirectDiagramMarshaller) VariableDeclaration(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration) Process(org.eclipse.bpmn2.Process) Iterator(java.util.Iterator) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) ParsedAssignmentsInfo(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.ParsedAssignmentsInfo) Assert.assertNotNull(org.junit.Assert.assertNotNull) DataTypeCacheServer(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.processes.DataTypeCacheServer) InclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.InclusiveGateway) StunnerTestingGraphBackendAPI(org.kie.workbench.common.stunner.core.backend.StunnerTestingGraphBackendAPI) Mockito.when(org.mockito.Mockito.when) AdHocSubprocessTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.AdHocSubprocessTaskExecutionSet) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) StartEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.StartEscalationEvent) ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) EventGateway(org.kie.workbench.common.stunner.bpmn.definition.EventGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 3 with EventGateway

use of org.kie.workbench.common.stunner.bpmn.definition.EventGateway in project kie-wb-common by kiegroup.

the class GatewayConverter method eventGateway.

private Result<BpmnNode> eventGateway(EventBasedGateway eventGateway) {
    Node<View<EventGateway>, Edge> node = factoryManager.newNode(eventGateway.getId(), EventGateway.class);
    GatewayPropertyReader p = propertyReaderFactory.of(eventGateway);
    node.getContent().setBounds(p.getBounds());
    EventGateway definition = node.getContent().getDefinition();
    definition.setGeneral(new BPMNGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
    definition.setAdvancedData(new AdvancedData(p.getMetaDataAttributes()));
    definition.setDimensionsSet(p.getCircleDimensionSet());
    definition.setFontSet(p.getFontSet());
    definition.setBackgroundSet(p.getBackgroundSet());
    return Result.success(BpmnNode.of(node, p));
}
Also used : EventGateway(org.kie.workbench.common.stunner.bpmn.definition.EventGateway) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) GatewayPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.GatewayPropertyReader) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Example 4 with EventGateway

use of org.kie.workbench.common.stunner.bpmn.definition.EventGateway in project kie-wb-common by kiegroup.

the class GatewayConverter method event.

private PropertyWriter event(Node<View<EventGateway>, ?> n) {
    GatewayPropertyWriter p = propertyWriterFactory.of(bpmn2.createEventBasedGateway());
    p.setId(n.getUUID());
    p.setGatewayDirection(GatewayDirection.DIVERGING);
    EventGateway definition = n.getContent().getDefinition();
    BPMNGeneralSet general = definition.getGeneral();
    p.setName(general.getName().getValue());
    p.setDocumentation(general.getDocumentation().getValue());
    p.setMetaData(definition.getAdvancedData().getMetaDataAttributes());
    p.setAbsoluteBounds(n);
    return p;
}
Also used : EventGateway(org.kie.workbench.common.stunner.bpmn.definition.EventGateway) GatewayPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.GatewayPropertyWriter) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)

Aggregations

EventGateway (org.kie.workbench.common.stunner.bpmn.definition.EventGateway)4 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)3 View (org.kie.workbench.common.stunner.core.graph.content.view.View)3 Test (org.junit.Test)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Activity (org.eclipse.bpmn2.Activity)1 DataInput (org.eclipse.bpmn2.DataInput)1 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)1 DataOutput (org.eclipse.bpmn2.DataOutput)1