use of org.kie.workbench.common.stunner.bpmn.definition.Association in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallIntermediateCompensationEventsWithAssociations.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallIntermediateCompensationEventsWithAssociations() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INTERMEDIATE_COMPENSATION_EVENTS_WITH_ASSOCIATION);
assertDiagram(diagram, 6);
assertEquals("IntermediateCompensationEventsWithAssociation", diagram.getMetadata().getTitle());
Node<? extends Definition, ?> catchingEventNode = diagram.getGraph().getNode("_DF70C614-A641-4109-8A8D-506B15E3F31B");
assertNotNull(catchingEventNode);
IntermediateCompensationEvent intermediateCompensationEvent = (IntermediateCompensationEvent) catchingEventNode.getContent().getDefinition();
assertTrue(GraphUtils.isDockedNode(catchingEventNode));
assertNotNull(intermediateCompensationEvent.getGeneral());
assertEquals("IntermediateCompensationEventName", intermediateCompensationEvent.getGeneral().getName().getValue());
assertEquals("IntermediateCompensationEventDocumentation", intermediateCompensationEvent.getGeneral().getDocumentation().getValue());
assertEquals("12/25/1983", intermediateCompensationEvent.getExecutionSet().getSlaDueDate().getValue());
Node<? extends Definition, ?> userTask1Node = diagram.getGraph().getNode("_C18CC8D2-D7CA-457D-9258-01D1E6973A86");
assertNotNull(userTask1Node);
UserTask userTask1 = (UserTask) userTask1Node.getContent().getDefinition();
assertEquals("Task1", userTask1.getGeneral().getName().getValue());
assertEquals("Task1Documentation", userTask1.getGeneral().getDocumentation().getValue());
assertEquals(userTask1Node, GraphUtils.getDockParent(catchingEventNode).orElse(null));
Node<? extends Definition, ?> userTask2Node = diagram.getGraph().getNode("_7EF24042-BD4E-4843-9874-8AC3F7AFF3CD");
assertNotNull(userTask2Node);
UserTask userTask2 = (UserTask) userTask2Node.getContent().getDefinition();
assertEquals("Task2", userTask2.getGeneral().getName().getValue());
assertEquals("Task2Documentation", userTask2.getGeneral().getDocumentation().getValue());
Edge associationEdge = userTask2Node.getInEdges().stream().filter(edge -> edge.getUUID().equals("_B41D28D1-FC39-40E8-BF89-C57649989014")).map(e -> e.asEdge()).findFirst().orElse(null);
assertNotNull(associationEdge);
assertNotNull(associationEdge.getContent());
Association association = (Association) ((View) associationEdge.getContent()).getDefinition();
assertEquals("AssociationDocumentation", association.getGeneral().getDocumentation().getValue());
assertEquals(associationEdge.getSourceNode(), catchingEventNode);
assertEquals(associationEdge.getTargetNode(), userTask2Node);
}
use of org.kie.workbench.common.stunner.bpmn.definition.Association in project kie-wb-common by kiegroup.
the class AssociationConverter method convertEdge.
public Result<BpmnEdge> convertEdge(org.eclipse.bpmn2.Association association, Map<String, BpmnNode> nodes) {
AssociationPropertyReader p = propertyReaderFactory.of(association);
Edge<View<Association>, Node> edge = factoryManager.newEdge(association.getId(), p.getAssociationByDirection());
Association definition = edge.getContent().getDefinition();
definition.setGeneral(new BPMNGeneralSet(new Name(""), new Documentation(p.getDocumentation())));
return result(nodes, edge, p, "Association ignored from " + p.getSourceId() + " to " + p.getTargetId(), MarshallingMessageKeys.associationIgnored);
}
use of org.kie.workbench.common.stunner.bpmn.definition.Association in project kie-wb-common by kiegroup.
the class AssociationConverter method toFlowElement.
public Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process) {
ViewConnector<Association> connector = (ViewConnector<Association>) edge.getContent();
Association definition = connector.getDefinition();
org.eclipse.bpmn2.Association association = bpmn2.createAssociation();
AssociationPropertyWriter p = propertyWriterFactory.of(association);
association.setId(edge.getUUID());
BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID());
BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID());
if (pSrc == null || pTgt == null) {
String msg = String.format("BasePropertyWriter was not found for source node or target node at edge: %s, pSrc = %s, pTgt = %s", edge.getUUID(), pSrc, pTgt);
LOG.debug(msg);
return Result.failure(msg);
}
p.setSource(pSrc);
p.setTarget(pTgt);
p.setConnection(connector);
BPMNGeneralSet general = definition.getGeneral();
p.setDocumentation(general.getDocumentation().getValue());
p.setDirectionAssociation(definition);
return Result.of(p);
}
Aggregations