inResource.setEncoding("UTF-8"); DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot(); OnExitScriptType root = DroolsFactory.eINSTANCE.createOnExitScriptType(); root.setScript("script"); root.setScriptFormat("format");
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); } } } }
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); } }