Search in sources :

Example 6 with ScriptTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue in project kie-wb-common by kiegroup.

the class ScriptTypeListTypeSerializerTest method testParse.

@Test
public void testParse() {
    String serializedValue = buildExpectedSerialization(currentScripts);
    ScriptTypeListValue result = serializer.parse(serializedValue);
    assertEquals(scriptTypeList, result);
}
Also used : ScriptTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue) Test(org.junit.Test)

Example 7 with ScriptTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue in project kie-wb-common by kiegroup.

the class ScriptTypeListTypeSerializerTest method testParseWithNoValues.

@Test
public void testParseWithNoValues() {
    ScriptTypeListValue result = serializer.parse("[]");
    assertEquals(new ScriptTypeListValue(), result);
}
Also used : ScriptTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue) Test(org.junit.Test)

Example 8 with ScriptTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue in project kie-wb-common by kiegroup.

the class ScriptTypeListFieldEditorPresenterTest method testSetValueWhenNotEmpty.

@Test
public void testSetValueWhenNotEmpty() {
    ScriptTypeValue value = mock(ScriptTypeValue.class);
    editor.setValue(new ScriptTypeListValue().addValue(value));
    verify(scriptTypePresenter, times(1)).setValue(value);
}
Also used : ScriptTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue) Test(org.junit.Test)

Example 9 with ScriptTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue 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);
            }
        }
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) ScriptTypeListTypeSerializer(org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer) OnExitScriptType(org.jboss.drools.OnExitScriptType) ScriptTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Example 10 with ScriptTypeListValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue 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);
    }
}
Also used : OnEntryScriptType(org.jboss.drools.OnEntryScriptType) ScriptTypeListValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Aggregations

ScriptTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue)18 ScriptTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)9 Test (org.junit.Test)7 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)6 ScriptTypeListTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer)6 ArrayList (java.util.ArrayList)4 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)4 LinkedHashMap (java.util.LinkedHashMap)3 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)3 DataObject (org.eclipse.bpmn2.DataObject)3 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)3 OnEntryScriptType (org.jboss.drools.OnEntryScriptType)3 OnExitScriptType (org.jboss.drools.OnExitScriptType)3 List (java.util.List)2 Entry (java.util.Map.Entry)2 DataInput (org.eclipse.bpmn2.DataInput)2 DataOutput (org.eclipse.bpmn2.DataOutput)2 FormalExpression (org.eclipse.bpmn2.FormalExpression)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 MultiInstanceLoopCharacteristics (org.eclipse.bpmn2.MultiInstanceLoopCharacteristics)2