Map<String, Object> flowElementProperties) throws JsonGenerationException, IOException { Map<String, Object> properties = new LinkedHashMap<String, Object>(flowElementProperties); Iterator<FeatureMap.Entry> iter = callActivity.getAnyAttribute().iterator(); while (iter.hasNext()) { FeatureMap.Entry entry = iter.next(); if (callActivity.getCalledElement() != null && callActivity.getCalledElement().length() > 0) { properties.put(CALLEDELEMENT, callActivity.getCalledElement()); String customAsyncMetaData = Utils.getMetaDataValue(callActivity.getExtensionValues(), "customAsync"); String customAsync = (customAsyncMetaData != null && customAsyncMetaData.length() > 0) ? customAsyncMetaData : "false"; List<DataInputAssociation> inputAssociations = callActivity.getDataInputAssociations(); List<DataOutputAssociation> outputAssociations = callActivity.getDataOutputAssociations(); marshallDataInputAssociations(associationBuff, inputAssociations); ScriptTypeListValue onEntryActions = getOnEntryActions(callActivity.getExtensionValues()); ScriptTypeListValue onExitActions = getOnExitActions(callActivity.getExtensionValues()); if (!onEntryActions.isEmpty()) { properties.put(ONENTRYACTIONS, setSimulationProperties(callActivity.getId(), properties); marshallNode(callActivity,
public void setCalledElement(String value) { activity.setCalledElement(value); } }
protected void applyCallActivityProperties(CallActivity callActivity, Map<String, String> properties) { if (properties.get("name") != null) { callActivity.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " ")); "\n"))); } else { callActivity.setName(""); SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("independent")); callActivity.getAnyAttribute().add(extensionEntry); SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("waitforcompletion")); callActivity.getAnyAttribute().add(extensionEntry); callActivity.setCalledElement(properties.get("calledelement")); if (callActivity.getIoSpecification() != null && callActivity.getIoSpecification().getDataOutputs() != null) { List<DataInput> dataInputs = callActivity.getIoSpecification().getDataInputs(); for (DataInput di : dataInputs) { if (di.getId().equals(callActivity.getId() + "_" + fromPart + "InputX")) { dia.setTargetRef(di); if (di.getName().equals("TaskName")) { a.setTo(toExpression); dia.getAssignment().add(a); callActivity.getDataInputAssociations().add(dia);
@Test public void testCreateNode_case() throws Exception { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CaseManagementCustomElement.isCase.of(callActivity).set(Boolean.TRUE); CaseManagementActivityPropertyReader propertyReader = new CaseManagementActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); tested.createNode(callActivity, propertyReader); verify(factoryManager).newElement(eq(id), eq(CaseReusableSubprocess.class)); }
@Test public void testApplyCallActivityProperties() throws Exception { final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(new ArrayList<>()); final String propertyName = "isCase"; final String propertyValue = "true"; final String resultName = "case"; final String resultValue = "<![CDATA[" + propertyValue + "]]>"; final Map<String, String> properties = new HashMap<>(); properties.put(propertyName, propertyValue); tested.applyCallActivityProperties(callActivity, properties); assertFalse(callActivity.getExtensionValues().isEmpty()); final ExtensionAttributeValue extenstionValue = callActivity.getExtensionValues().get(0); final Optional<String> value = extenstionValue.getValue().stream() .filter(v -> resultName.equals(((MetaDataType) v.getValue()).getName())) .map(v -> ((MetaDataType) v.getValue()).getMetaValue()).findAny(); assertTrue(value.isPresent() && resultValue.equals(value.get())); }
@Override protected Node<View<ReusableSubprocess>, Edge> createNode(CallActivity activity, ActivityPropertyReader p) { return factoryManager.newNode(activity.getId(), ReusableSubprocess.class); }
@SuppressWarnings("unchecked") public BpmnNode convert(CallActivity activity) { ActivityPropertyReader p = propertyReaderFactory.of(activity); Node<View<R>, Edge> node = createNode(activity, p); R definition = node.getContent().getDefinition(); definition.setGeneral(new BPMNGeneralSet( new Name(p.getName()), new Documentation(p.getDocumentation()) )); definition.setExecutionSet(createReusableSubprocessTaskExecutionSet( new CalledElement(activity.getCalledElement()), new Independent(p.isIndependent()), new WaitForCompletion(p.isWaitForCompletion()), new IsAsync(p.isAsync()), new OnEntryAction(p.getOnEntryAction()), new OnExitAction(p.getOnExitAction()), p )); definition.setDataIOSet(new DataIOSet(p.getAssignmentsInfo())); node.getContent().setBounds(p.getBounds()); definition.setSimulationSet(p.getSimulationSet()); definition.setDimensionsSet(p.getRectangleDimensionsSet()); definition.setFontSet(p.getFontSet()); definition.setBackgroundSet(p.getBackgroundSet()); return BpmnNode.of(node); }
@Test public void testCreateNode_process() throws Exception { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CaseManagementCustomElement.isCase.of(callActivity).set(Boolean.FALSE); CaseManagementActivityPropertyReader propertyReader = new CaseManagementActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); tested.createNode(callActivity, propertyReader); verify(factoryManager).newElement(eq(id), eq(ProcessReusableSubprocess.class)); }
@Test public void testMarshallNode_CaseReusableSubprocess() throws Exception { expectedStencil = "CaseReusableSubprocess"; final MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn("case"); when(metaDataType.getMetaValue()).thenReturn("true"); final FeatureMap featureMap = mock(FeatureMap.class); when(featureMap.get(eq(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA), eq(true))) .thenReturn(Collections.singletonList(metaDataType)); final ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); when(extensionAttributeValue.getValue()).thenReturn(featureMap); final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(Collections.singletonList(extensionAttributeValue)); tested.marshallNode(callActivity, new HashMap<>(), "ReusableSubprocess", mock(BPMNPlane.class), mock(JsonGenerator.class), 0.0f, 0.0f); }
@Override protected Node<View<BaseCaseManagementReusableSubprocess>, Edge> createNode(CallActivity activity, ActivityPropertyReader p) { Class<? extends BaseCaseManagementReusableSubprocess> clazz = ((CaseManagementActivityPropertyReader) p).isCase() ? CaseReusableSubprocess.class : ProcessReusableSubprocess.class; return factoryManager.newNode(activity.getId(), clazz); }
@Test public void testIsCase_false() throws Exception { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CaseManagementCustomElement.isCase.of(callActivity).set(Boolean.FALSE); tested = new CaseManagementActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertFalse(tested.isCase()); } }
@Test public void testMarshallNode_ProcessReusableSubprocess() throws Exception { expectedStencil = "ProcessReusableSubprocess"; final MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn("case"); when(metaDataType.getMetaValue()).thenReturn("false"); final FeatureMap featureMap = mock(FeatureMap.class); when(featureMap.get(eq(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA), eq(true))) .thenReturn(Collections.singletonList(metaDataType)); final ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); when(extensionAttributeValue.getValue()).thenReturn(featureMap); final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(Collections.singletonList(extensionAttributeValue)); tested.marshallNode(callActivity, new HashMap<>(), "ReusableSubprocess", mock(BPMNPlane.class), mock(JsonGenerator.class), 0.0f, 0.0f); } }
@Test public void testIsCase_true() throws Exception { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CaseManagementCustomElement.isCase.of(callActivity).set(Boolean.TRUE); tested = new CaseManagementActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); assertTrue(tested.isCase()); }
@Test public void testCreateReusableSubprocessTaskExecutionSet_case() throws Exception { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CaseManagementCustomElement.isCase.of(callActivity).set(Boolean.TRUE); CaseManagementActivityPropertyReader propertyReader = new CaseManagementActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); BaseReusableSubprocessTaskExecutionSet result = tested.createReusableSubprocessTaskExecutionSet(null, null, null, null, null, null, propertyReader); assertTrue(result instanceof CaseReusableSubprocessTaskExecutionSet); assertTrue(((CaseReusableSubprocessTaskExecutionSet) result).getIsCase().getValue()); }
@Test public void testCreateReusableSubprocessTaskExecutionSet_process() throws Exception { String id = UUID.randomUUID().toString(); CallActivity callActivity = bpmn2.createCallActivity(); callActivity.setId(id); CaseManagementCustomElement.isCase.of(callActivity).set(Boolean.FALSE); CaseManagementActivityPropertyReader propertyReader = new CaseManagementActivityPropertyReader(callActivity, definitionResolver.getDiagram(), definitionResolver); BaseReusableSubprocessTaskExecutionSet result = tested.createReusableSubprocessTaskExecutionSet(null, null, null, null, null, null, propertyReader); assertTrue(result instanceof ProcessReusableSubprocessTaskExecutionSet); assertFalse(((ProcessReusableSubprocessTaskExecutionSet) result).getIsCase().getValue()); } }
public PropertyWriter toFlowElement(Node<View<T>, ?> n) { CallActivity activity = bpmn2.createCallActivity(); activity.setId(n.getUUID()); CallActivityPropertyWriter p = propertyWriterFactory.of(activity); T definition = n.getContent().getDefinition(); BPMNGeneralSet general = definition.getGeneral(); p.setName(general.getName().getValue()); p.setDocumentation(general.getDocumentation().getValue()); BaseReusableSubprocessTaskExecutionSet executionSet = definition.getExecutionSet(); p.setOnEntryAction(executionSet.getOnEntryAction()); p.setOnExitAction(executionSet.getOnExitAction()); p.setCalledElement(executionSet.getCalledElement().getValue()); p.setAsync(executionSet.getIsAsync().getValue()); p.setIndependent(executionSet.getIndependent().getValue()); p.setWaitForCompletion(executionSet.getWaitForCompletion().getValue()); p.setAssignmentsInfo(definition.getDataIOSet().getAssignmentsinfo()); p.setSimulationSet(definition.getSimulationSet()); p.setBounds(n.getContent().getBounds()); return p; } }