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