use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.
the class AssociationPropertyReaderTest method testGetAssociationByDirection.
@Test
public void testGetAssociationByDirection() {
final Association association = Bpmn2Factory.eINSTANCE.createAssociation();
// null direction
association.setAssociationDirection(null);
propertyReader = new AssociationPropertyReader(association, bpmnDiagram, definitionResolver);
assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection());
// none direction
association.setAssociationDirection(AssociationDirection.NONE);
assertEquals(NonDirectionalAssociation.class, propertyReader.getAssociationByDirection());
// one direction
association.setAssociationDirection(AssociationDirection.ONE);
assertEquals(DirectionalAssociation.class, propertyReader.getAssociationByDirection());
}
use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.
the class ProcessConverterDelegateTest method setUp.
@Before
public void setUp() throws Exception {
parentNode = new BpmnNode.Simple(new NodeImpl<>("ParentNode"), basePropertyReader);
when(diagram.getPlane()).thenReturn(plane);
List<RootElement> rootElements = Collections.singletonList(process);
List<BPMNDiagram> diagrams = Collections.singletonList(diagram);
when(definitions.getRootElements()).thenReturn(rootElements);
when(definitions.getDiagrams()).thenReturn(diagrams);
when(definitions.getRelationships()).thenReturn(Collections.emptyList());
when(plane.getPlaneElement()).thenReturn(new ArrayList<>());
definitionResolver = new DefinitionResolver(definitions, Collections.emptyList());
StunnerTestingGraphBackendAPI api = StunnerTestingGraphBackendAPI.build(BPMNDefinitionSet.class, new BPMNTestDefinitionFactory());
TypedFactoryManager typedFactoryManager = new TypedFactoryManager(api.getFactoryManager());
factory = new ConverterFactory(definitionResolver, typedFactoryManager);
converterDelegate = new ProcessConverterDelegate(typedFactoryManager, propertyReaderFactory, definitionResolver, factory);
}
use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.
the class EmbeddedSubprocessPropertyReaderTest method setUp.
@Before
public void setUp() {
Definitions definitions = bpmn2.createDefinitions();
definitions.getRootElements().add(bpmn2.createProcess());
BPMNDiagram bpmnDiagram = di.createBPMNDiagram();
bpmnDiagram.setPlane(di.createBPMNPlane());
definitions.getDiagrams().add(bpmnDiagram);
definitionResolverReal = new DefinitionResolver(definitions, Collections.emptyList());
}
use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method createDiagram.
private void createDiagram(Definitions def) {
for (RootElement rootElement : def.getRootElements()) {
if (rootElement instanceof Process) {
Process process = (Process) rootElement;
BpmnDiFactory factory = BpmnDiFactory.eINSTANCE;
BPMNDiagram diagram = factory.createBPMNDiagram();
BPMNPlane plane = factory.createBPMNPlane();
plane.setBpmnElement(process);
diagram.setPlane(plane);
// first process flowNodes
for (FlowElement flowElement : process.getFlowElements()) {
if (flowElement instanceof FlowNode) {
createBpmnShapeForElement(factory, plane, flowElement);
if (flowElement instanceof BoundaryEvent) {
createDockersForBoundaryEvent((BoundaryEvent) flowElement);
}
// check if its a subprocess
if (flowElement instanceof SubProcess) {
createSubProcessDiagram(plane, flowElement, factory);
}
} else if (flowElement instanceof DataObject) {
createBpmnShapeForElement(factory, plane, flowElement);
} else if (flowElement instanceof SequenceFlow) {
createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) flowElement);
}
}
// then process artifacts
if (process.getArtifacts() != null) {
List<Association> incompleteAssociations = new ArrayList<Association>();
for (Artifact artifact : process.getArtifacts()) {
// if (artifact instanceof TextAnnotation || artifact instanceof Group) {
if (artifact instanceof Group) {
createBpmnShapeForElement(factory, plane, artifact);
}
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (association.getSourceRef() != null && association.getTargetRef() != null) {
createBpmnEdgeForAssociation(factory, plane, association);
} else {
incompleteAssociations.add(association);
}
}
}
if (!incompleteAssociations.isEmpty()) {
for (Association incompleteAssociation : incompleteAssociations) {
process.getArtifacts().remove(incompleteAssociation);
}
}
}
// finally process lanes
if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
for (LaneSet ls : process.getLaneSets()) {
for (Lane lane : ls.getLanes()) {
createBpmnShapeForElement(factory, plane, lane);
}
}
}
def.getDiagrams().add(diagram);
}
}
}
use of org.eclipse.bpmn2.di.BPMNDiagram in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method testUnmarshallProcessVariables.
@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessVariables() throws Exception {
Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
assertDiagram(diagram, 8);
assertEquals("ProcessVariables", diagram.getMetadata().getTitle());
ProcessVariables variables = null;
Iterator<Element> it = nodesIterator(diagram);
while (it.hasNext()) {
Element element = it.next();
if (element.getContent() instanceof View) {
Object oDefinition = ((View) element.getContent()).getDefinition();
if (oDefinition instanceof BPMNDiagram) {
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
variables = bpmnDiagram.getProcessData().getProcessVariables();
break;
}
}
}
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
Node<? extends Definition, ?> diagramNode = diagram.getGraph().getNode("_luRBMdEjEeWXpsZ1tNStKQ");
assertTrue(diagramNode.getContent().getDefinition() instanceof BPMNDiagram);
BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) diagramNode.getContent().getDefinition();
assertTrue(bpmnDiagram.getProcessData() != null);
assertTrue(bpmnDiagram.getProcessData().getProcessVariables() != null);
variables = bpmnDiagram.getProcessData().getProcessVariables();
assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
}
Aggregations