use of org.kie.workbench.common.stunner.bpmn.backend.marshall.json.parser.common.ArrayParser 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.bpmn.backend.marshall.json.parser.common.ArrayParser in project kie-wb-common by kiegroup.
the class NodeParser method initialize.
@Override
public void initialize(final Context context) {
super.initialize(context);
// Children.
ArrayParser childrenParser = new ArrayParser("childShapes");
for (Parser childParser : children) {
if (childParser instanceof ContextualParser) {
((ContextualParser) childParser).initialize(context);
childrenParser.addParser(childParser);
}
}
super.addParser(childrenParser);
// Outgoing.
ArrayParser outgoingParser = new ArrayParser("outgoing");
super.addParser(outgoingParser);
List<Edge> outEdges = element.getOutEdges();
if (null != outEdges && !outEdges.isEmpty()) {
for (Edge edge : outEdges) {
String outId = null;
if (isViewEdge(edge)) {
// View connectors, such as sequence flows.
outId = edge.getUUID();
} else if (isDockEdge(edge)) {
// Docked nodes. Oryx marshallers do not expect an outgoing sequence flow id here, it expects the
// id of the docked node.
Node docked = edge.getTargetNode();
outId = docked.getUUID();
}
if (null != outId) {
outgoingParser.addParser(new ObjectParser("").addParser(new StringFieldParser("resourceId", outId)));
}
}
}
// Dockers - Only use if this node is docked.
if (isDocked(element)) {
Bounds.Bound ul = element.getContent().getBounds().getUpperLeft();
ObjectParser docker1ObjParser = new ObjectParser("").addParser(new IntegerFieldParser("x", ul.getX().intValue())).addParser(new IntegerFieldParser("y", ul.getY().intValue()));
ArrayParser dockersParser = new ArrayParser("dockers").addParser(docker1ObjParser);
super.addParser(dockersParser);
}
}
Aggregations