Search in sources :

Example 1 with SimpleFeatureMapEntry

use of org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applyProcessProperties.

protected void applyProcessProperties(Process process, Map<String, String> properties) {
    if (properties.get("processn") != null) {
        process.setName(StringEscapeUtils.escapeXml(properties.get("processn")));
    } else {
        process.setName("");
    }
    if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
        Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
        audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
        process.setAuditing(audit);
    }
    process.setProcessType(ProcessType.getByName(properties.get("processtype")));
    process.setIsClosed(Boolean.parseBoolean(properties.get("isclosed")));
    process.setIsExecutable(Boolean.parseBoolean(properties.get("executable")));
    // get the drools-specific extension packageName attribute to Process if defined
    if (properties.get("package") != null && properties.get("package").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "packageName", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("package"));
        process.getAnyAttribute().add(extensionEntry);
    }
    // add version attrbute to process
    if (properties.get("version") != null && properties.get("version").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "version", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("version"));
        process.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
        Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
        monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
        process.setMonitoring(monitoring);
    }
    // import extension elements
    if (properties.get("imports") != null && properties.get("imports").length() > 0) {
        String[] allImports = properties.get("imports").split(",\\s*");
        for (String importStr : allImports) {
            String[] importParts = importStr.split("\\|\\s*");
            // sample 'com.sample.Myclass|default,location|namespace|wsdl
            if (importParts.length == 2 || importParts.length == 3) {
                if (importParts[1] != null && importParts[1].equals("default")) {
                    ImportType importType = DroolsFactory.eINSTANCE.createImportType();
                    importType.setName(importParts[0]);
                    if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                        ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                        process.getExtensionValues().add(extensionElement);
                    }
                    FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__IMPORT, importType);
                    process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
                } else {
                    Import imp = Bpmn2Factory.eINSTANCE.createImport();
                    imp.setImportType("http://schemas.xmlsoap.org/wsdl/");
                    imp.setLocation(importParts[0]);
                    imp.setNamespace(importParts[1]);
                    _wsdlImports.add(imp);
                }
            } else {
                // just default (support legacy)
                ImportType importType = DroolsFactory.eINSTANCE.createImportType();
                importType.setName(importStr);
                if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                    process.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__IMPORT, importType);
                process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            }
        }
    }
    // globals extension elements
    if (properties.get("globals") != null && properties.get("globals").length() > 0) {
        String[] allGlobals = properties.get("globals").split(",\\s*");
        for (String globalStr : allGlobals) {
            // identifier:type
            String[] globalParts = globalStr.split(":\\s*");
            if (globalParts.length == 2) {
                GlobalType globalType = DroolsFactory.eINSTANCE.createGlobalType();
                globalType.setIdentifier(globalParts[0]);
                globalType.setType(globalParts[1]);
                if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                    process.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__GLOBAL, globalType);
                process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            } else if (globalParts.length == 1) {
                GlobalType globalType = DroolsFactory.eINSTANCE.createGlobalType();
                globalType.setIdentifier(globalParts[0]);
                globalType.setType("Object");
                if (process.getExtensionValues() == null || process.getExtensionValues().size() < 1) {
                    ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                    process.getExtensionValues().add(extensionElement);
                }
                FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__GLOBAL, globalType);
                process.getExtensionValues().get(0).getValue().add(extensionElementEntry);
            }
        }
    }
    // simulation properties
    if (properties.get("timeunit") != null && properties.get("timeunit").length() > 0) {
        _simulationScenarioParameters.setBaseTimeUnit(TimeUnit.getByName(properties.get("timeunit")));
    }
    if (properties.get("currency") != null && properties.get("currency").length() > 0) {
        _simulationScenarioParameters.setBaseCurrencyUnit(properties.get("currency"));
    }
}
Also used : ImportType(org.jboss.drools.ImportType) Import(org.eclipse.bpmn2.Import) Internal(org.eclipse.emf.ecore.EStructuralFeature.Internal) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue) Auditing(org.eclipse.bpmn2.Auditing) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData) Monitoring(org.eclipse.bpmn2.Monitoring) GlobalType(org.jboss.drools.GlobalType)

Example 2 with SimpleFeatureMapEntry

use of org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applyServiceTaskProperties.

public void applyServiceTaskProperties(ServiceTask serviceTask, Map<String, String> properties) {
    if (properties.get("serviceimplementation") != null && properties.get("serviceimplementation").length() > 0) {
        serviceTask.setImplementation(properties.get("serviceimplementation"));
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "serviceimplementation", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("serviceimplementation"));
        serviceTask.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("serviceoperation") != null && properties.get("serviceoperation").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "serviceoperation", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("serviceoperation"));
        serviceTask.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("serviceinterface") != null && properties.get("serviceinterface").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "serviceinterface", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("serviceinterface"));
        serviceTask.getAnyAttribute().add(extensionEntry);
    }
}
Also used : EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData)

Example 3 with SimpleFeatureMapEntry

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

Example 4 with SimpleFeatureMapEntry

use of org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applyDataObjectProperties.

protected void applyDataObjectProperties(DataObject da, Map<String, String> properties) {
    if (properties.get("name") != null && properties.get("name").length() > 0) {
        da.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " "));
        // add unescaped and untouched name value as extension element as well
        Utils.setMetaDataExtensionValue(da, "elementname", wrapInCDATABlock(properties.get("name").replaceAll("\\\\n", "\n")));
    } else {
        // we need a name, use id instead
        da.setName(da.getId());
    }
    boolean haveCustomType = false;
    if (properties.get("customtype") != null && properties.get("customtype").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "datype", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("customtype"));
        da.getAnyAttribute().add(extensionEntry);
        haveCustomType = true;
    }
    if (properties.get("standardtype") != null && properties.get("standardtype").length() > 0 && !haveCustomType) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "datype", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("standardtype"));
        da.getAnyAttribute().add(extensionEntry);
    }
}
Also used : EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData)

Example 5 with SimpleFeatureMapEntry

use of org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method updateEdgeColors.

public void updateEdgeColors(BPMNEdge edge) {
    List<String> eleColorsForEdge = _elementColors.get(edge.getBpmnElement().getId());
    if (eleColorsForEdge != null) {
        String backgroundColor = "";
        String borderColor = "";
        String fontColor = "";
        for (String edgeColor : eleColorsForEdge) {
            String[] shapeColorParts = edgeColor.split(":");
            if (shapeColorParts[0].equals("bgcolor")) {
                backgroundColor = shapeColorParts[1];
            }
            if (shapeColorParts[0].equals("bordercolor")) {
                borderColor = shapeColorParts[1];
            }
            if (shapeColorParts[0].equals("fontcolor")) {
                fontColor = shapeColorParts[1];
            }
        }
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttributeBgColor = (EAttributeImpl) metadata.demandFeature("http://www.omg.org/spec/BPMN/non-normative/color", "background-color", false, false);
        SimpleFeatureMapEntry extensionEntryBgColor = new SimpleFeatureMapEntry(extensionAttributeBgColor, backgroundColor);
        edge.getBpmnElement().getAnyAttribute().add(extensionEntryBgColor);
        EAttributeImpl extensionAttributeBorderColor = (EAttributeImpl) metadata.demandFeature("http://www.omg.org/spec/BPMN/non-normative/color", "border-color", false, false);
        SimpleFeatureMapEntry extensionEntryBorderColor = new SimpleFeatureMapEntry(extensionAttributeBorderColor, borderColor);
        edge.getBpmnElement().getAnyAttribute().add(extensionEntryBorderColor);
        EAttributeImpl extensionAttributeColor = (EAttributeImpl) metadata.demandFeature("http://www.omg.org/spec/BPMN/non-normative/color", "color", false, false);
        SimpleFeatureMapEntry extensionEntryColor = new SimpleFeatureMapEntry(extensionAttributeColor, fontColor);
        edge.getBpmnElement().getAnyAttribute().add(extensionEntryColor);
    } else {
        _logger.debug("Unable to find color information for shape: " + edge.getBpmnElement().getId());
    }
}
Also used : EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData)

Aggregations

SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)28 EAttributeImpl (org.eclipse.emf.ecore.impl.EAttributeImpl)25 ExtendedMetaData (org.eclipse.emf.ecore.util.ExtendedMetaData)25 ArrayList (java.util.ArrayList)10 EObject (org.eclipse.emf.ecore.EObject)8 Parameter (bpsim.Parameter)6 FloatingParameterType (bpsim.FloatingParameterType)5 TimeParameters (bpsim.TimeParameters)5 DecimalFormat (java.text.DecimalFormat)5 DataInput (org.eclipse.bpmn2.DataInput)5 NormalDistributionType (bpsim.NormalDistributionType)4 PoissonDistributionType (bpsim.PoissonDistributionType)4 UniformDistributionType (bpsim.UniformDistributionType)4 List (java.util.List)4 Assignment (org.eclipse.bpmn2.Assignment)4 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)4 DataOutput (org.eclipse.bpmn2.DataOutput)4 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)4 FormalExpression (org.eclipse.bpmn2.FormalExpression)4 InputOutputSpecification (org.eclipse.bpmn2.InputOutputSpecification)4