use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector in project kie-wb-common by kiegroup.
the class EdgeParser method initialize.
@SuppressWarnings("unchecked")
@Override
public void initialize(final Context context) {
super.initialize(context);
String outNodeId = element.getTargetNode() != null ? element.getTargetNode().getUUID() : null;
// Outgoing.
if (null != outNodeId) {
ArrayParser outgoingParser = new ArrayParser("outgoing");
outgoingParser.addParser(new ObjectParser("").addParser(new StringFieldParser("resourceId", outNodeId)));
super.addParser(outgoingParser);
}
// Use dockers
ArrayParser dockersParser = new ArrayParser("dockers");
ViewConnector viewConnector = (ViewConnector) element.getContent();
// insert source
dockersParser.addParser(createDockerObjectParser(viewConnector.getSourceConnection()));
// inserting ControlPoints
viewConnector.getControlPoints().stream().sequential().map(ControlPoint::getLocation).map(this::createDockerObjectParser).forEach(dockersParser::addParser);
// insert target
dockersParser.addParser(createDockerObjectParser(viewConnector.getTargetConnection()));
super.addParser(dockersParser);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector in project kie-wb-common by kiegroup.
the class EdgeParser method parseExtendedProperties.
@Override
protected void parseExtendedProperties(final ObjectParser propertiesParser) {
super.parseExtendedProperties(propertiesParser);
ViewConnector viewConnector = (ViewConnector) element.getContent();
viewConnector.getTargetConnection().ifPresent(connection -> appendConnAuto((Connection) connection, Bpmn2OryxManager.TARGET, propertiesParser));
viewConnector.getSourceConnection().ifPresent(connection -> appendConnAuto((Connection) connection, Bpmn2OryxManager.SOURCE, propertiesParser));
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallInclusiveGateway.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallInclusiveGateway() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_INCLUSIVE_GATEWAY);
assertDiagram(diagram, 7);
assertEquals(diagram.getMetadata().getTitle(), "TestInclusiveGateway");
Graph graph = diagram.getGraph();
Node<? extends Definition, ?> gatewayNode = graph.getNode("_526EE472-FE8B-4E9A-A951-CFBA86C3691F");
assertTrue(gatewayNode.getContent().getDefinition() instanceof InclusiveGateway);
InclusiveGateway inclusiveGateway = (InclusiveGateway) gatewayNode.getContent().getDefinition();
assertEquals("InclusiveGatewayName", inclusiveGateway.getGeneral().getName().getValue());
assertEquals("_3D5701E9-CFD3-4218-9200-897B6D4FF041", inclusiveGateway.getExecutionSet().getDefaultRoute().getValue());
SequenceFlow sequenceFlow1 = null;
SequenceFlow sequenceFlow2 = null;
List<Edge> outEdges = (List<Edge>) gatewayNode.getOutEdges();
if (outEdges != null) {
for (Edge edge : outEdges) {
if ("_3D5701E9-CFD3-4218-9200-897B6D4FF041".equals(edge.getUUID())) {
sequenceFlow1 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
} else if ("_A414F16D-90BB-4742-A4E7-EBF7EA1ECD7E".equals(edge.getUUID())) {
sequenceFlow2 = (SequenceFlow) ((ViewConnector) edge.getContent()).getDefinition();
}
}
}
assertNotNull(sequenceFlow1);
assertEquals("OutSequence1", sequenceFlow1.getGeneral().getName().getValue());
assertNotNull(sequenceFlow2);
assertEquals("OutSequence2", sequenceFlow2.getGeneral().getName().getValue());
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testMagnetDockers.
private void testMagnetDockers(Diagram<Graph, Metadata> diagram) {
Node userTaskNode = (Node) findElementByContentType(diagram, UserTask.class);
Node businessRuleTaskNode = (Node) findElementByContentType(diagram, BusinessRuleTask.class);
Node scriptTaskNode = (Node) findElementByContentType(diagram, ScriptTask.class);
assertNotNull(userTaskNode);
assertNotNull(businessRuleTaskNode);
assertNotNull(scriptTaskNode);
ViewConnector userTaskInEdgeConnector = getInEdgeViewConnector(userTaskNode);
ViewConnector businessRuleTaskInEdgeConnector = getInEdgeViewConnector(businessRuleTaskNode);
ViewConnector scriptTaskInEdgeConnector = getInEdgeViewConnector(scriptTaskNode);
assertNotNull(userTaskInEdgeConnector);
assertNotNull(businessRuleTaskInEdgeConnector);
assertNotNull(scriptTaskInEdgeConnector);
ViewConnector userTaskOutEdgeConnector = getOutEdgeViewConnector(userTaskNode);
ViewConnector businessRuleTaskOutEdgeConnector = getOutEdgeViewConnector(businessRuleTaskNode);
ViewConnector scriptTaskOutEdgeConnector = getOutEdgeViewConnector(scriptTaskNode);
assertNotNull(userTaskOutEdgeConnector);
assertNotNull(businessRuleTaskOutEdgeConnector);
assertNotNull(scriptTaskOutEdgeConnector);
// userTaskInEdgeConnector is from magnet top-middle to left-middle
assertTrue(userTaskInEdgeConnector.getSourceConnection().isPresent());
assertTrue(userTaskInEdgeConnector.getTargetConnection().isPresent());
DiscreteConnection sourceConnection = (DiscreteConnection) userTaskInEdgeConnector.getSourceConnection().get();
DiscreteConnection targetConnection = (DiscreteConnection) userTaskInEdgeConnector.getTargetConnection().get();
assertEquals(20d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(0d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(24d, targetConnection.getLocation().getY(), 0.1d);
// Assert both connections for userTaskInEdgeConnector are set to auto.
assertTrue(sourceConnection.isAuto());
assertTrue(targetConnection.isAuto());
// businessRuleTaskInEdgeConnector is from magnet right-middle to top-left
assertTrue(businessRuleTaskInEdgeConnector.getSourceConnection().isPresent());
assertTrue(businessRuleTaskInEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (DiscreteConnection) businessRuleTaskInEdgeConnector.getSourceConnection().get();
targetConnection = (DiscreteConnection) businessRuleTaskInEdgeConnector.getTargetConnection().get();
assertEquals(40d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(20d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getY(), 0.1d);
// Assert both connections for businessRuleTaskInEdgeConnector are NOT set to auto.
assertFalse(sourceConnection.isAuto());
assertFalse(targetConnection.isAuto());
// scriptTaskInEdgeConnector is from magnet left-bottom to left-bottom
assertTrue(scriptTaskInEdgeConnector.getSourceConnection().isPresent());
assertTrue(scriptTaskInEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (DiscreteConnection) scriptTaskInEdgeConnector.getSourceConnection().get();
targetConnection = (DiscreteConnection) scriptTaskInEdgeConnector.getTargetConnection().get();
assertEquals(0d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(40d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(48d, targetConnection.getLocation().getY(), 0.1d);
// userTaskOutEdgeConnector is from magnet right-middle to left-middle
assertTrue(userTaskOutEdgeConnector.getSourceConnection().isPresent());
assertTrue(userTaskOutEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (DiscreteConnection) userTaskOutEdgeConnector.getSourceConnection().get();
targetConnection = (DiscreteConnection) userTaskOutEdgeConnector.getTargetConnection().get();
assertEquals(136d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(24d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(14d, targetConnection.getLocation().getY(), 0.1d);
// businessRuleTaskOutEdgeConnector is from magnet middle-bottom to middle-bottom
assertTrue(businessRuleTaskOutEdgeConnector.getSourceConnection().isPresent());
assertTrue(businessRuleTaskOutEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (DiscreteConnection) businessRuleTaskOutEdgeConnector.getSourceConnection().get();
targetConnection = (DiscreteConnection) businessRuleTaskOutEdgeConnector.getTargetConnection().get();
assertEquals(68d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(48d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(14d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(28d, targetConnection.getLocation().getY(), 0.1d);
// scriptTaskOutEdgeConnector is from magnet left-top to left-top
assertTrue(scriptTaskOutEdgeConnector.getSourceConnection().isPresent());
assertTrue(scriptTaskOutEdgeConnector.getTargetConnection().isPresent());
sourceConnection = (DiscreteConnection) scriptTaskOutEdgeConnector.getSourceConnection().get();
targetConnection = (DiscreteConnection) scriptTaskOutEdgeConnector.getTargetConnection().get();
assertEquals(0d, sourceConnection.getLocation().getX(), 0.1d);
assertEquals(0d, sourceConnection.getLocation().getY(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getX(), 0.1d);
assertEquals(0d, targetConnection.getLocation().getY(), 0.1d);
}
use of org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method testUnmarshallNotBoundaryEvents.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallNotBoundaryEvents() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_NOT_BOUNDARY_EVENTS);
assertEquals("Not Boundary Event", diagram.getMetadata().getTitle());
assertDiagram(diagram, 6);
// Assert than the intermediate event is connected using a view connector,
// so not boundary to the task ( not docked ).
Node event = diagram.getGraph().getNode("_CB178D55-8DC2-4CAA-8C42-4F5028D4A1F6");
List<Edge> inEdges = event.getInEdges();
boolean foundViewConnector = false;
for (Edge e : inEdges) {
if (e.getContent() instanceof ViewConnector) {
foundViewConnector = true;
}
}
assertTrue(foundViewConnector);
// Assert absolute position as the node is not docked.
Bounds bounds = ((View) event.getContent()).getBounds();
Bounds.Bound ul = bounds.getUpperLeft();
Bounds.Bound lr = bounds.getLowerRight();
assertEquals(305, ul.getX(), 0);
assertEquals(300, ul.getY(), 0);
assertEquals(335, lr.getX(), 0);
assertEquals(330, lr.getY(), 0);
}
Aggregations