use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter in project kie-wb-common by kiegroup.
the class AbstractProcessConverter method convertEdges.
public void convertEdges(ElementContainer p, DefinitionsBuildingContext context) {
context.childEdges().forEach(e -> {
BasePropertyWriter pSrc = p.getChildElement(e.getSourceNode().getUUID());
// if it's null, then it's a root: skip it
if (pSrc != null) {
BasePropertyWriter pTgt = p.getChildElement(e.getTargetNode().getUUID());
pTgt.setParent(pSrc);
}
});
context.dockEdges().forEach(e -> {
ActivityPropertyWriter pSrc = (ActivityPropertyWriter) p.getChildElement(e.getSourceNode().getUUID());
BoundaryEventPropertyWriter pTgt = (BoundaryEventPropertyWriter) p.getChildElement(e.getTargetNode().getUUID());
pTgt.setParentActivity(pSrc);
});
context.edges().map(e -> converterFactory.sequenceFlowConverter().toFlowElement(e, p)).forEach(p::addChildElement);
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter in project kie-wb-common by kiegroup.
the class SequenceFlowConverter method toFlowElement.
public Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process) {
ViewConnector<SequenceFlow> connector = (ViewConnector<SequenceFlow>) edge.getContent();
SequenceFlow definition = connector.getDefinition();
org.eclipse.bpmn2.SequenceFlow seq = bpmn2.createSequenceFlow();
SequenceFlowPropertyWriter p = propertyWriterFactory.of(seq);
seq.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("pSrc = %s, pTgt = %s", pSrc, pTgt);
LOG.debug(msg);
return Result.failure(msg);
}
p.setSource(pSrc);
p.setTarget(pTgt);
p.setConnection(connector);
BPMNGeneralSet general = definition.getGeneral();
p.setName(general.getName().getValue());
p.setDocumentation(general.getDocumentation().getValue());
SequenceFlowExecutionSet executionSet = definition.getExecutionSet();
p.setPriority(executionSet.getPriority().getValue());
p.setConditionExpression(executionSet.getConditionExpression().getValue());
return Result.of(p);
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter 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);
}
use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter in project kie-wb-common by kiegroup.
the class AssociationConverterTest method testToFlowElementSuccess.
@Test
public void testToFlowElementSuccess() {
org.kie.workbench.common.stunner.bpmn.definition.Association association = new org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation();
association.setGeneral(new BPMNGeneralSet("nameValue", "documentationValue"));
when(connector.getDefinition()).thenReturn(association);
Result<BasePropertyWriter> result = converter.toFlowElement(edge, process);
assertTrue(result.isSuccess());
verify(propertyWriterFactory).of(argumentCaptor.capture());
assertEquals(EDGE_ID, argumentCaptor.getValue().getId());
verify(associationPropertyWriter).setSource(pSrc);
verify(associationPropertyWriter).setTarget(pTgt);
verify(associationPropertyWriter).setConnection(connector);
verify(associationPropertyWriter).setDocumentation("documentationValue");
verify(associationPropertyWriter).setDirectionAssociation(association);
}
Aggregations