Search in sources :

Example 6 with ExtensionAttributeValue

use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method getProcessExtensionValue.

private String getProcessExtensionValue(Process process, String propertyName) {
    List<ExtensionAttributeValue> extensionValues = process.getExtensionValues();
    for (ExtensionAttributeValue extensionValue : extensionValues) {
        FeatureMap featureMap = extensionValue.getValue();
        for (int i = 0; i < featureMap.size(); i++) {
            EStructuralFeatureImpl.SimpleFeatureMapEntry featureMapEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) featureMap.get(i);
            MetaDataType featureMapValue = (MetaDataType) featureMapEntry.getValue();
            if (propertyName.equals(featureMapValue.getName())) {
                return featureMapValue.getMetaValue();
            }
        }
    }
    return "";
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) MetaDataType(org.jboss.drools.MetaDataType) EStructuralFeatureImpl(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue)

Example 7 with ExtensionAttributeValue

use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method getProcessExtensionValue.

private String getProcessExtensionValue(Process process, String propertyName) {
    List<ExtensionAttributeValue> extensionValues = process.getExtensionValues();
    for (ExtensionAttributeValue extensionValue : extensionValues) {
        FeatureMap featureMap = extensionValue.getValue();
        for (int i = 0; i < featureMap.size(); i++) {
            EStructuralFeatureImpl.SimpleFeatureMapEntry featureMapEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) featureMap.get(i);
            MetaDataType featureMapValue = (MetaDataType) featureMapEntry.getValue();
            if (propertyName.equals(featureMapValue.getName())) {
                return featureMapValue.getMetaValue();
            }
        }
    }
    return "";
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) MetaDataType(org.jboss.drools.MetaDataType) EStructuralFeatureImpl(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue)

Example 8 with ExtensionAttributeValue

use of org.eclipse.bpmn2.ExtensionAttributeValue 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 9 with ExtensionAttributeValue

use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method addSimulation.

public void addSimulation(Definitions def) {
    Relationship relationship = Bpmn2Factory.eINSTANCE.createRelationship();
    relationship.getSources().add(def);
    relationship.getTargets().add(def);
    relationship.setType(defaultRelationshipType);
    BPSimDataType simDataType = BpsimFactory.eINSTANCE.createBPSimDataType();
    // currently support single scenario
    Scenario defaultScenario = BpsimFactory.eINSTANCE.createScenario();
    // single scenario suppoert
    defaultScenario.setId("default");
    // single scenario support
    defaultScenario.setName("Simulationscenario");
    defaultScenario.setScenarioParameters(_simulationScenarioParameters);
    if (_simulationElementParameters.size() > 0) {
        Iterator<String> iter = _simulationElementParameters.keySet().iterator();
        while (iter.hasNext()) {
            String key = iter.next();
            ElementParameters etype = BpsimFactory.eINSTANCE.createElementParameters();
            etype.setElementRef(key);
            List<EObject> params = _simulationElementParameters.get(key);
            for (EObject np : params) {
                if (np instanceof ControlParameters) {
                    etype.setControlParameters((ControlParameters) np);
                } else if (np instanceof CostParameters) {
                    etype.setCostParameters((CostParameters) np);
                } else if (np instanceof PriorityParameters) {
                    etype.setPriorityParameters((PriorityParameters) np);
                } else if (np instanceof ResourceParameters) {
                    etype.setResourceParameters((ResourceParameters) np);
                } else if (np instanceof TimeParameters) {
                    etype.setTimeParameters((TimeParameters) np);
                }
            }
            defaultScenario.getElementParameters().add(etype);
        }
    }
    simDataType.getScenario().add(defaultScenario);
    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
    relationship.getExtensionValues().add(extensionElement);
    FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA, simDataType);
    relationship.getExtensionValues().get(0).getValue().add(extensionElementEntry);
    def.getRelationships().add(relationship);
}
Also used : CostParameters(bpsim.CostParameters) ElementParameters(bpsim.ElementParameters) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) ResourceParameters(bpsim.ResourceParameters) Scenario(bpsim.Scenario) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Relationship(org.eclipse.bpmn2.Relationship) EObject(org.eclipse.emf.ecore.EObject) ControlParameters(bpsim.ControlParameters) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) PriorityParameters(bpsim.PriorityParameters) BPSimDataType(bpsim.BPSimDataType) TimeParameters(bpsim.TimeParameters)

Example 10 with ExtensionAttributeValue

use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method setUserTaskInfo.

private void setUserTaskInfo(FlowElementsContainer container) {
    List<FlowElement> flowElements = container.getFlowElements();
    for (FlowElement fe : flowElements) {
        // Set name and metaData "elementname" to "Task_n" if empty
        if (fe instanceof UserTask) {
            UserTask task = (UserTask) fe;
            String name = task.getName();
            if (name == null || name.length() == 0) {
                LastUserTaskID++;
                String newName = DEFAULT_USERTASK_NAME_PREFIX + LastUserTaskID;
                task.setName(newName);
                if (task.getExtensionValues() != null && task.getExtensionValues().size() > 0) {
                    for (ExtensionAttributeValue extattrval : task.getExtensionValues()) {
                        FeatureMap extensionElements = extattrval.getValue();
                        List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true);
                        for (MetaDataType eleMetadata : metadataExtensions) {
                            if (eleMetadata.getName() != null && eleMetadata.getName().equals("elementname")) {
                                eleMetadata.setMetaValue(wrapInCDATABlock(newName));
                            }
                        }
                    }
                }
            }
        }
        if (fe instanceof FlowElementsContainer) {
            setUserTaskInfo((FlowElementsContainer) fe);
        }
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) MetaDataType(org.jboss.drools.MetaDataType) FlowElement(org.eclipse.bpmn2.FlowElement) UserTask(org.eclipse.bpmn2.UserTask) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) ArrayList(java.util.ArrayList) List(java.util.List) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue)

Aggregations

ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)16 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)15 MetaDataType (org.jboss.drools.MetaDataType)7 List (java.util.List)6 ArrayList (java.util.ArrayList)5 EList (org.eclipse.emf.common.util.EList)4 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)4 ScriptTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeListValue)4 ScriptTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)4 BPSimDataType (bpsim.BPSimDataType)3 Relationship (org.eclipse.bpmn2.Relationship)3 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)3 Scenario (bpsim.Scenario)2 Entry (java.util.Map.Entry)2 EStructuralFeatureImpl (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl)2 GlobalType (org.jboss.drools.GlobalType)2 ImportType (org.jboss.drools.ImportType)2 OnEntryScriptType (org.jboss.drools.OnEntryScriptType)2 OnExitScriptType (org.jboss.drools.OnExitScriptType)2 ScriptTypeListTypeSerializer (org.kie.workbench.common.stunner.bpmn.backend.marshall.json.oryx.property.ScriptTypeListTypeSerializer)2