use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class SequenceFlowConverter method toFlowElement.
public SequenceFlowPropertyWriter toFlowElement(Edge<?, ?> edge, ElementContainer process) {
ViewConnector<SequenceFlow> content = (ViewConnector<SequenceFlow>) edge.getContent();
SequenceFlow definition = content.getDefinition();
org.eclipse.bpmn2.SequenceFlow seq = bpmn2.createSequenceFlow();
SequenceFlowPropertyWriter p = propertyWriterFactory.of(seq);
seq.setId(edge.getUUID());
BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID());
BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID());
p.setSource(pSrc);
p.setTarget(pTgt);
seq.setId(edge.getUUID());
seq.setName(definition.getGeneral().getName().getValue());
p.setConnection(content);
SequenceFlowExecutionSet executionSet = definition.getExecutionSet();
ScriptTypeValue scriptTypeValue = executionSet.getConditionExpression().getValue();
String language = scriptTypeValue.getLanguage();
String script = scriptTypeValue.getScript();
if (script != null) {
FormalExpression formalExpression = bpmn2.createFormalExpression();
String uri = Scripts.scriptLanguageToUri(language);
formalExpression.setLanguage(uri);
formalExpression.setBody(asCData(script));
seq.setConditionExpression(formalExpression);
}
process.addChildElement(p);
process.addChildEdge(p.getEdge());
return p;
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Scripts method setOnExitAction.
public static void setOnExitAction(FlowElement flowElement, OnExitAction onExitAction) {
ScriptTypeListValue value = onExitAction.getValue();
for (ScriptTypeValue scriptTypeValue : value.getValues()) {
if (scriptTypeValue.getScript() == null && scriptTypeValue.getScript().isEmpty()) {
continue;
}
OnExitScriptType script = droolsFactory.createOnExitScriptType();
script.setScript(asCData(scriptTypeValue.getScript()));
String scriptLanguage = Scripts.scriptLanguageToUri(scriptTypeValue.getLanguage());
script.setScriptFormat(scriptLanguage);
addExtensionValue(flowElement, DOCUMENT_ROOT__ON_EXIT_SCRIPT, script);
}
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method setAdHocSubProcessProperties.
private void setAdHocSubProcessProperties(final AdHocSubProcess subProcess, final Map<String, Object> properties) {
if (subProcess.getOrdering().equals(AdHocOrdering.PARALLEL)) {
properties.put(ADHOCORDERING, "Parallel");
} else if (subProcess.getOrdering().equals(AdHocOrdering.SEQUENTIAL)) {
properties.put(ADHOCORDERING, "Sequential");
} else {
// default to parallel
properties.put(ADHOCORDERING, "Parallel");
}
if (subProcess.getCompletionCondition() != null) {
final FormalExpression expression = (FormalExpression) subProcess.getCompletionCondition();
final String language = Utils.getScriptLanguage(expression.getLanguage());
final String script = expression.getBody().replaceAll("\n", "\\\\n");
final ScriptTypeValue value = new ScriptTypeValue(language, script);
properties.put(ADHOCCOMPLETIONCONDITION, new ScriptTypeTypeSerializer().serialize(value));
}
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyOnEntryActions.
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);
}
}
}
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applySequenceFlowCondition.
protected void applySequenceFlowCondition(SequenceFlow sequenceFlow, Map<String, String> properties) {
String conditionExpression = properties.get("conditionexpression");
if (conditionExpression != null && !conditionExpression.isEmpty()) {
ScriptTypeValue value = new ScriptTypeTypeSerializer().parse(conditionExpression);
if (value.getScript() != null && !value.getScript().isEmpty()) {
FormalExpression expr = Bpmn2Factory.eINSTANCE.createFormalExpression();
expr.setBody(wrapInCDATABlock(value.getScript()));
if (value.getLanguage() != null && !value.getLanguage().isEmpty()) {
String languageFormat = Utils.getScriptLanguageFormat(value.getLanguage());
if (languageFormat == null) {
// default to mvel
languageFormat = "http://www.mvel.org/2.0";
}
expr.setLanguage(languageFormat);
}
sequenceFlow.setConditionExpression(expr);
}
}
}
Aggregations