public String serialize(final ScriptTypeListValue value) { final StringBuilder serializedValue = new StringBuilder(); ScriptTypeTypeSerializer scriptTypeSerializer = new ScriptTypeTypeSerializer(); if (value.isEmpty()) { serializedValue.append("[]"); } else { value.getValues().forEach(scriptTypeValue -> { if (serializedValue.length() > 0) { serializedValue.append(DELIMITER); } serializedValue.append(scriptTypeSerializer.serialize(scriptTypeValue)); }); } return serializedValue.toString(); }
protected void onValueChange(ScriptTypeValue oldScriptValue, ScriptTypeValue newScriptValue) { ScriptTypeListValue oldValue = value; value = new ScriptTypeListValue(); value.getValues().add(newScriptValue); notifyChange(oldValue, value); }
protected void applyOnExitActions(BaseElement element, Map<String, String> properties) { if (properties.get("onexitactions") != null && properties.get("onexitactions").length() > 0) { ScriptTypeListValue onExitActions = new ScriptTypeListTypeSerializer().parse(properties.get("onexitactions")); if (!onExitActions.isEmpty()) { ScriptTypeValue onExitAction = onExitActions.getValues().get(0); if (onExitAction.getScript() != null && !onExitAction.getScript().isEmpty()) { OnExitScriptType onExitScript = DroolsFactory.eINSTANCE.createOnExitScriptType(); onExitScript.setScript(wrapInCDATABlock(onExitAction.getScript())); String scriptLanguage = Utils.getScriptLanguageFormat(onExitAction.getLanguage()); if (scriptLanguage == null) { //default to java scriptLanguage = "http://www.java.com/java"; } onExitScript.setScriptFormat(scriptLanguage); if (element.getExtensionValues() == null || element.getExtensionValues().size() < 1) { ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue(); element.getExtensionValues().add(extensionElement); } FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry( (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__ON_EXIT_SCRIPT, onExitScript); element.getExtensionValues().get(0).getValue().add(extensionElementEntry); } } } }
protected void applyOnEntryActions(BaseElement element, Map<String, String> properties) { if (properties.get("onentryactions") != null && properties.get("onentryactions").length() > 0) { ScriptTypeListValue onEntryActions = new ScriptTypeListTypeSerializer().parse(properties.get("onentryactions")); if (!onEntryActions.isEmpty()) { ScriptTypeValue onEntryAction = onEntryActions.getValues().get(0); if (onEntryAction.getScript() != null && !onEntryAction.getScript().isEmpty()) { OnEntryScriptType onEntryScript = DroolsFactory.eINSTANCE.createOnEntryScriptType(); onEntryScript.setScript(wrapInCDATABlock(onEntryAction.getScript())); String scriptLanguage = Utils.getScriptLanguageFormat(onEntryAction.getLanguage()); if (scriptLanguage == null) { //default to java scriptLanguage = "http://www.java.com/java"; } onEntryScript.setScriptFormat(scriptLanguage); if (element.getExtensionValues() == null || element.getExtensionValues().size() < 1) { ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue(); element.getExtensionValues().add(extensionElement); } FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry( (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, onEntryScript); element.getExtensionValues().get(0).getValue().add(extensionElementEntry); } } } }
public static void setOnExitAction(FlowElement flowElement, OnExitAction onExitAction) { ScriptTypeListValue value = onExitAction.getValue(); for (ScriptTypeValue scriptTypeValue : value.getValues()) { String scriptText = scriptTypeValue.getScript(); if (scriptText == null || scriptText.isEmpty()) { continue; } OnExitScriptType script = droolsFactory.createOnExitScriptType(); script.setScript(asCData(scriptText)); String scriptLanguage = Scripts.scriptLanguageToUri(scriptTypeValue.getLanguage()); script.setScriptFormat(scriptLanguage); addExtensionValue(flowElement, DOCUMENT_ROOT__ON_EXIT_SCRIPT, script); } }
public static void setOnEntryAction(FlowElement flowElement, OnEntryAction onEntryAction) { ScriptTypeListValue value = onEntryAction.getValue(); for (ScriptTypeValue scriptTypeValue : value.getValues()) { String scriptText = scriptTypeValue.getScript(); if (scriptText == null || scriptText.isEmpty()) { continue; } OnEntryScriptType script = droolsFactory.createOnEntryScriptType(); script.setScript(asCData(scriptTypeValue.getScript())); String scriptLanguage = Scripts.scriptLanguageToUri(scriptTypeValue.getLanguage()); script.setScriptFormat(scriptLanguage); addExtensionValue(flowElement, DOCUMENT_ROOT__ON_ENTRY_SCRIPT, script); } }
assertEquals("drools", completionCondition.getLanguage()); ScriptTypeValue entryAction = executionSet.getOnEntryAction().getValue().getValues().get(0); assertEquals("StageTest", entryAction.getScript()); assertEquals("java", entryAction.getLanguage()); ScriptTypeValue exitAction = executionSet.getOnExitAction().getValue().getValues().get(0); assertEquals("StageTest", exitAction.getScript()); assertEquals("java", exitAction.getLanguage());
miSubprocess.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript()); assertEquals("java", miSubprocess.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage()); miSubprocess.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript()); assertEquals("java", miSubprocess.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage());
userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getScript()); userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage()); userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getScript()); userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
assertTrue(subcaseExecutionSet.getWaitForCompletion().getValue()); ScriptTypeValue entryAction = subcaseExecutionSet.getOnEntryAction().getValue().getValues().get(0); assertEquals("SubcaseTest", entryAction.getScript()); assertEquals("java", entryAction.getLanguage()); ScriptTypeValue exitAction = subcaseExecutionSet.getOnExitAction().getValue().getValues().get(0); assertEquals("SubcaseTest", exitAction.getScript()); assertEquals("java", exitAction.getLanguage());
protected void assertServiceTaskExecutionSet(ServiceTaskExecutionSet executionSet, String onEntryActionScriptValue, String onEntryActionScriptLanguage, String onExitActionScriptValue, String onExitActionScriptLanguage, boolean isAsync, boolean adHocAutostart) { assertNotNull(executionSet); assertNotNull(executionSet.getOnEntryAction()); assertNotNull(executionSet.getOnExitAction()); assertNotNull(executionSet.getIsAsync()); assertNotNull(executionSet.getAdHocAutostart()); assertNotNull(executionSet.getOnEntryAction().getValue()); assertNotNull(executionSet.getOnExitAction().getValue()); List<ScriptTypeValue> onEntryScriptTypeValues = executionSet.getOnEntryAction().getValue().getValues(); List<ScriptTypeValue> onExitScriptTypeValues = executionSet.getOnExitAction().getValue().getValues(); assertNotNull(onEntryScriptTypeValues); assertNotNull(onExitScriptTypeValues); assertNotNull(onEntryScriptTypeValues.get(0)); assertNotNull(onExitScriptTypeValues.get(0)); assertEquals(onEntryActionScriptValue, onEntryScriptTypeValues.get(0).getScript()); assertEquals(onEntryActionScriptLanguage, onEntryScriptTypeValues.get(0).getLanguage()); assertEquals(onExitActionScriptValue, onExitScriptTypeValues.get(0).getScript()); assertEquals(onExitActionScriptLanguage, onExitScriptTypeValues.get(0).getLanguage()); assertEquals(isAsync, executionSet.getIsAsync().getValue()); assertEquals(adHocAutostart, executionSet.getAdHocAutostart().getValue()); }
userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getScript()); userTaskExecutionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage()); userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getScript()); userTaskExecutionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
executionSet.getOnEntryAction().getValue().getValues().size()); assertEquals("System.out.println(\"onEntryAction\");", executionSet.getOnEntryAction().getValue().getValues().get(0).getScript()); assertEquals("mvel", executionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage()); executionSet.getOnExitAction().getValue().getValues().size()); assertEquals("System.out.println(\"onExitAction\");", executionSet.getOnExitAction().getValue().getValues().get(0).getScript()); assertEquals("java", executionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript()); businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage()); businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript()); businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage());
businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript()); businessRuleTask.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage()); businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript()); businessRuleTask.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage());
@Test public void testUnmarshallMultipleInstanceSubprocess() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(BPMN_MULTIPLE_INSTANCE_SUBPROCESS); assertDiagram(diagram, 2); assertEquals("MultipleInstanceSubprocess", diagram.getMetadata().getTitle()); Node<? extends Definition, ?> multipleInstanceSubprocessNode = diagram.getGraph().getNode("_2316CEC1-C1F7-41B1-8C91-3CE73ADE5571"); MultipleInstanceSubprocess multipleInstanceSubprocess = (MultipleInstanceSubprocess) multipleInstanceSubprocessNode.getContent().getDefinition(); assertEquals("var1", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceCollectionInput().getValue()); assertEquals("var2", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceCollectionOutput().getValue()); assertEquals("dataInput", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceDataInput().getValue()); assertEquals("dataOutput", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceDataOutput().getValue()); assertEquals("a=b", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceCompletionCondition().getValue()); assertEquals("onEntryAction", multipleInstanceSubprocess.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript()); assertEquals("java", multipleInstanceSubprocess.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage()); assertEquals("onExitAction", multipleInstanceSubprocess.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript()); assertEquals("java", multipleInstanceSubprocess.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage()); assertTrue(multipleInstanceSubprocess.getExecutionSet().getIsAsync().getValue()); assertEquals("mi-var1:String", multipleInstanceSubprocess.getProcessData().getProcessVariables().getValue()); }
executionSet.getOnEntryAction().getValue().getValues().get(0).getScript()); assertEquals("java", executionSet.getOnEntryAction().getValue().getValues().get(0).getLanguage()); executionSet.getOnExitAction().getValue().getValues().get(0).getScript()); assertEquals("java", executionSet.getOnExitAction().getValue().getValues().get(0).getLanguage());
@Test public void testUnmarshallMultipleInstanceSubprocess() throws Exception { Diagram<Graph, Metadata> diagram = unmarshall(BPMN_MULTIPLE_INSTANCE_SUBPROCESS); assertDiagram(diagram, 2); assertEquals("MultipleInstanceSubprocess", diagram.getMetadata().getTitle()); Node<? extends Definition, ?> multipleInstanceSubprocessNode = diagram.getGraph().getNode("_2316CEC1-C1F7-41B1-8C91-3CE73ADE5571"); MultipleInstanceSubprocess multipleInstanceSubprocess = (MultipleInstanceSubprocess) multipleInstanceSubprocessNode.getContent().getDefinition(); assertEquals("var1", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceCollectionInput().getValue()); assertEquals("var2", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceCollectionOutput().getValue()); assertEquals("dataInput", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceDataInput().getValue()); assertEquals("dataOutput", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceDataOutput().getValue()); assertEquals("a=b", multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceCompletionCondition().getValue()); assertEquals("onEntryAction", multipleInstanceSubprocess.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getScript()); assertEquals("java", multipleInstanceSubprocess.getExecutionSet().getOnEntryAction().getValue().getValues().get(0).getLanguage()); assertEquals("onExitAction", multipleInstanceSubprocess.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getScript()); assertEquals("java", multipleInstanceSubprocess.getExecutionSet().getOnExitAction().getValue().getValues().get(0).getLanguage()); assertTrue(multipleInstanceSubprocess.getExecutionSet().getIsAsync().getValue()); assertEquals("mi-var1:String", multipleInstanceSubprocess.getProcessData().getProcessVariables().getValue()); }