public ProcessPropertyReader(Process element, BPMNDiagram diagram, BPMNShape shape, double resolutionFactor) { super(element, diagram, shape, resolutionFactor); this.process = element; this.flowElements = process.getFlowElements().stream() .collect(Collectors.toMap(FlowElement::getId, Function.identity())); }
public BpmnNode convertProcess() { Process process = delegate.definitionResolver.getProcess(); String definitionsId = delegate.definitionResolver.getDefinitions().getId(); BpmnNode processRoot = convertProcessNode(definitionsId, process); Map<String, BpmnNode> nodes = delegate.convertChildNodes(processRoot, process.getFlowElements(), process.getLaneSets()); delegate.convertEdges(processRoot, Stream.concat(process.getFlowElements().stream(), process.getArtifacts().stream()).collect(Collectors.toList()), nodes); return processRoot; }
protected void revisitBoundaryEventsPositions(Definitions def) { for (RootElement root : def.getRootElements()) { if (root instanceof Process) { Process process = (Process) root; List<BoundaryEvent> toRemove = new ArrayList(); for (FlowElement fe : process.getFlowElements()) { if (fe instanceof BoundaryEvent) { BoundaryEvent be = (BoundaryEvent) fe; FlowElementsContainer container = findContainerForBoundaryEvent(process, be); if (container != null && !(container instanceof Process)) { BoundaryEvent beCopy = copyBoundaryEvent(be); container.getFlowElements().add(beCopy); _outgoingFlows.put(beCopy, _outgoingFlows.get(be)); toRemove.add(be); _outgoingFlows.remove(be); } } } for (BoundaryEvent be : toRemove) { process.getFlowElements().remove(be); } } } reconnectFlows(); }
private Object getNamedFlowElement(Process process, Class cls, String name) { List<FlowElement> flowElements = process.getFlowElements(); for (FlowElement flowElement : flowElements) { if (cls.isInstance(flowElement) && name.equals(flowElement.getName())) { return flowElement; } } return null; }
private Object getNamedFlowElement(Process process, Class cls, String name) { List<FlowElement> flowElements = process.getFlowElements(); for (FlowElement flowElement : flowElements) { if (cls.isInstance(flowElement) && name.equals(flowElement.getName())) { return flowElement; } } return null; }
public void revisitLanes(Definitions def) { List<RootElement> rootElements = def.getRootElements(); for (RootElement root : rootElements) { if (root instanceof Process) { Process process = (Process) root; if ((process.getLaneSets() == null || process.getLaneSets().size() < 1) && _lanes.size() > 0) { LaneSet ls = Bpmn2Factory.eINSTANCE.createLaneSet(); for (Lane lane : _lanes) { ls.getLanes().add(lane); List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs(); for (FlowNode fl : laneFlowNodes) { process.getFlowElements().add(fl); } } process.getLaneSets().add(ls); } } } }
@Test @SuppressWarnings("unchecked") public void testProcessWhenActivityNotFound() { List<FlowElement> flowElements = new ArrayList<>(); when(process.getFlowElements()).thenReturn(flowElements); converter.process(processWriter, nodeWriter, (Node) node); verify(compensateEvent, never()).setActivityRef(activity); } }
@Test @SuppressWarnings("unchecked") public void testProcessWhenActivityFound() { List<FlowElement> flowElements = Collections.singletonList(activity); when(process.getFlowElements()).thenReturn(flowElements); converter.process(processWriter, nodeWriter, (Node) node); verify(compensateEvent).setActivityRef(activity); }
public void updateIDs(Definitions def) { // data object id update List<RootElement> rootElements = def.getRootElements(); for (RootElement root : rootElements) { if (root instanceof Process) { Process process = (Process) root; if (process.getId() != null) { String processId = process.getId().trim(); processId = processId.replaceAll("\\s", ""); process.setId(processId); } List<FlowElement> flowElements = process.getFlowElements(); for (FlowElement fe : flowElements) { if (fe instanceof DataObject) { DataObject da = (DataObject) fe; if (da.getName() != null) { String daId = da.getName().trim(); daId = daId.replaceAll("\\W", ""); da.setId(daId); } } } } } }
private void addLaneFlowNodes(Process process, Lane lane) { process.getFlowElements().addAll(lane.getFlowNodeRefs()); // for (FlowNode node : lane.getFlowNodeRefs()) { // if (node instanceof DataObject) { // ItemDefinition def = ((DataObject) node).getItemSubjectRef(); // if (def != null) { // if (def.eResource() == null) { // ((Definitions) process.eContainer()).getRootElements().add(0, ((DataObject) node).getItemSubjectRef()); // } // Import imported = def.getImport(); // if (imported != null && imported.eResource() == null) { // ((Definitions) process.eContainer()).getImports().add(0, ((DataObject) node).getItemSubjectRef().getImport()); // } // } // } // } if (lane.getChildLaneSet() != null) { for (Lane l : lane.getChildLaneSet().getLanes()) { addLaneFlowNodes(process, l); } } }
@Test @SuppressWarnings("unchecked") public void testProcessWhenOutEdgeExists() { String uuid = "UUID"; Edge edge = mock(Edge.class); Node targetNode = mock(Node.class); when(targetNode.getUUID()).thenReturn(uuid); List outEdges = new ArrayList<>(); outEdges.add(edge); when(node.getOutEdges()).thenReturn(outEdges); Activity activity = mock(Activity.class); when(activity.getId()).thenReturn(uuid); when(edge.getTargetNode()).thenReturn(targetNode); List<FlowElement> flowElements = Collections.singletonList(activity); when(process.getFlowElements()).thenReturn(flowElements); converter.process(processWriter, nodeWriter, (Node) node); verify(activity).setIsForCompensation(true); } }
@Before public void setUp() { when(propertyWriter.getRootElements()).thenReturn(propertyWriterRootElements); when(propertyWriter.getSimulationParameters()).thenReturn(propertyWriterElementParameters); when(propertyWriter.getItemDefinitions()).thenReturn(propertyWriterItemDefinitions); when(boundaryEventPropertyWriter.getRootElements()).thenReturn(propertyWriterRootElements); when(boundaryEventPropertyWriter.getSimulationParameters()).thenReturn(propertyWriterElementParameters); when(boundaryEventPropertyWriter.getItemDefinitions()).thenReturn(propertyWriterItemDefinitions); flowElement = new FlowElementImpl() {}; flowElement.setId(ELEMENT_ID); artifact = new ArtifactImpl() {}; artifact.setId(ELEMENT_ID); when(process.getFlowElements()).thenReturn(flowElements); when(process.getArtifacts()).thenReturn(artifacts); when(subProcess.getFlowElements()).thenReturn(flowElements); when(subProcess.getArtifacts()).thenReturn(artifacts); }
@Test public void addChildElement() { Process process = p.getProcess(); BoundaryEventPropertyWriter boundaryEventPropertyWriter = new BoundaryEventPropertyWriter(bpmn2.createBoundaryEvent(), variableScope); UserTaskPropertyWriter userTaskPropertyWriter = new UserTaskPropertyWriter(bpmn2.createUserTask(), variableScope); p.addChildElement(boundaryEventPropertyWriter); p.addChildElement(userTaskPropertyWriter); // boundary event should always occur after other nodes (compat with old marshallers) assertThat(process.getFlowElements().get(0)).isEqualTo(userTaskPropertyWriter.getFlowElement()); assertThat(process.getFlowElements().get(1)).isEqualTo(boundaryEventPropertyWriter.getFlowElement()); }
@Test public void testBasicMarshall() throws Exception { Diagram<Graph, Metadata> d = unmarshall(newMarshaller, BPMN_SERVICE_TASK_PROPERTIES_FILE_PATH); Definitions definitions = convertToDefinitions(d); org.eclipse.bpmn2.Task serviceTask = ((Process) definitions.getRootElements().get(0)) .getFlowElements() .stream() .filter(org.eclipse.bpmn2.Task.class::isInstance) .map(org.eclipse.bpmn2.Task.class::cast) .findFirst().get(); assertEquals("Custom Email", serviceTask.getName()); assertEquals("<![CDATA[This is an email task]]>", serviceTask.getDocumentation().get(0).getText()); }
for (FlowElement element : process.getFlowElements()) { if (element instanceof SubProcess) { container = (FlowElementsContainer) element;
@Test public void testUpdateIDs() { Definitions defs = mock(Definitions.class); Process process = mock(Process.class); DataObject flowElement = mock(DataObject.class); final Value<String> processId = new Value<>("Project:Bad Id"); final Value<String> flowElementId = new Value<>("Bad Flow Id!"); when(process.getId()).thenAnswer((m) -> processId.get()); doAnswer((m) -> { processId.set(m.getArgumentAt(0, String.class)); return null; }).when(process).setId(anyString()); when(flowElement.getId()).thenAnswer((m) -> flowElementId.get()); when(flowElement.getName()).thenAnswer((m) -> flowElementId.get()); doAnswer((m) -> { flowElementId.set(m.getArgumentAt(0, String.class)); return null; }).when(flowElement).setId(anyString()); when(process.getFlowElements()).thenReturn(Arrays.asList(flowElement)); when(defs.getRootElements()).thenReturn(Arrays.asList(process)); tested.updateIDs(defs); assertEquals("Project:BadId", processId.get()); assertEquals("BadFlowId", flowElementId.get()); }
@Test public void marshallAssociations() throws Exception { Diagram<Graph, Metadata> d = unmarshall(newMarshaller, BPMN_FILE_PATH); Node<View<UserTask>, ?> node = d.getGraph().getNode(TASK_ID); UserTask definition = node.getContent().getDefinition(); DefinitionsConverter definitionsConverter = new DefinitionsConverter(d.getGraph()); Definitions definitions = definitionsConverter.toDefinitions(); Process p = (Process) definitions.getRootElements().get(0); org.eclipse.bpmn2.UserTask flowElement = (org.eclipse.bpmn2.UserTask) p.getFlowElements().stream().filter(e -> e.getId().equals(TASK_ID)).findFirst().get(); List<DataInputAssociation> associations = flowElement.getDataInputAssociations(); assertEquals("myprocvar", findVar(associations, "From")); assertEquals("<![CDATA[HELLO]]>", findAssignment(associations, "Body")); }
for (FlowElement element : process.getFlowElements()) { if (element instanceof AdHocSubProcess) { container = (FlowElementsContainer) element;
for (FlowElement element : process.getFlowElements()) { if (element instanceof AdHocSubProcess) { container = (FlowElementsContainer) element;
for (FlowElement element : process.getFlowElements()) { if (element instanceof AdHocSubProcess) { container = (FlowElementsContainer) element;