use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyScriptTaskProperties.
protected void applyScriptTaskProperties(ScriptTask scriptTask, Map<String, String> properties) {
String scriptTypeStr = properties.get("script");
if (scriptTypeStr != null && !scriptTypeStr.isEmpty()) {
ScriptTypeValue value = new ScriptTypeTypeSerializer().parse(scriptTypeStr);
if (value.getScript() != null && !value.getScript().isEmpty()) {
scriptTask.setScript(wrapInCDATABlock(value.getScript()));
}
String languageFormat = Utils.getScriptLanguageFormat(value.getLanguage());
if (languageFormat == null) {
// default to java
languageFormat = "http://www.java.com/java";
}
scriptTask.setScriptFormat(languageFormat);
}
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyAdHocSubProcessProperties.
protected void applyAdHocSubProcessProperties(AdHocSubProcess ahsp, Map<String, String> properties) {
if (properties.get("adhocordering") != null) {
if (properties.get("adhocordering").equals("Parallel")) {
ahsp.setOrdering(AdHocOrdering.PARALLEL);
} else {
ahsp.setOrdering(AdHocOrdering.SEQUENTIAL);
}
}
String adHocCompletionCondition = properties.get("adhoccompletioncondition");
if (adHocCompletionCondition != null) {
ScriptTypeValue value = new ScriptTypeTypeSerializer().parse(adHocCompletionCondition);
FormalExpression completionConditionExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
String completionExpression = value.getScript();
if (completionExpression == null || completionExpression.isEmpty()) {
// default to autocomplete
completionExpression = "autocomplete";
}
completionConditionExpression.setBody(wrapInCDATABlock(completionExpression));
String languageFormat = Utils.getScriptLanguageFormat(value.getLanguage());
if (languageFormat == null) {
// default to mvel
languageFormat = "mvel";
}
completionConditionExpression.setLanguage(languageFormat);
ahsp.setCompletionCondition(completionConditionExpression);
}
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyOnExitActions.
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);
}
}
}
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyConditionalEventProperties.
protected void applyConditionalEventProperties(ConditionalEventDefinition event, Map<String, String> properties) {
FormalExpression conditionExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
ScriptTypeValue value = new ScriptTypeTypeSerializer().parse(properties.get("conditionexpression"));
if (value.getLanguage() != null && !value.getLanguage().isEmpty()) {
String languageFormat = Utils.getScriptLanguageFormat(value.getLanguage());
if (languageFormat == null) {
// default to drools
languageFormat = "http://www.jboss.org/drools/rule";
}
conditionExpression.setLanguage(languageFormat);
}
if (value.getScript() != null && !value.getScript().isEmpty()) {
String scriptStr = value.getScript().replaceAll("\\\\n", "\n");
conditionExpression.setBody(wrapInCDATABlock(scriptStr));
}
event.setCondition(conditionExpression);
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Scripts method setOnEntryAction.
public static void setOnEntryAction(FlowElement flowElement, OnEntryAction onEntryAction) {
ScriptTypeListValue value = onEntryAction.getValue();
for (ScriptTypeValue scriptTypeValue : value.getValues()) {
if (scriptTypeValue.getScript() == null && scriptTypeValue.getScript().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);
}
}
Aggregations