Search in sources :

Example 1 with Monitoring

use of com.google.api.services.monitoring.v3.Monitoring 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 Monitoring

use of com.google.api.services.monitoring.v3.Monitoring in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applyEventProperties.

protected void applyEventProperties(Event event, Map<String, String> properties) {
    if (properties.get("name") != null) {
        event.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " "));
        // add unescaped and untouched name value as extension element as well
        Utils.setMetaDataExtensionValue(event, "elementname", wrapInCDATABlock(properties.get("name").replaceAll("\\\\n", "\n")));
    } else {
        event.setName("");
    }
    if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
        Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
        audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
        event.setAuditing(audit);
    }
    if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
        Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
        monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
        event.setMonitoring(monitoring);
    }
}
Also used : Monitoring(org.eclipse.bpmn2.Monitoring) Auditing(org.eclipse.bpmn2.Auditing)

Example 3 with Monitoring

use of com.google.api.services.monitoring.v3.Monitoring in project kie-wb-common by kiegroup.

the class Bpmn2JsonUnmarshaller method applySequenceFlowProperties.

protected void applySequenceFlowProperties(SequenceFlow sequenceFlow, Map<String, String> properties) {
    // sequence flow name is options
    if (properties.get("name") != null && !"".equals(properties.get("name"))) {
        sequenceFlow.setName(StringEscapeUtils.escapeXml(properties.get("name")).replaceAll("\\r\\n|\\r|\\n", " "));
        // add unescaped and untouched name value as extension eleent as well
        Utils.setMetaDataExtensionValue(sequenceFlow, "elementname", wrapInCDATABlock(properties.get("name").replaceAll("\\\\n", "\n")));
    }
    if (properties.get("bgcolor") != null && properties.get("bgcolor").length() > 0) {
        if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("bgcolor:" + properties.get("bgcolor"));
            _elementColors.put(sequenceFlow.getId(), colorsList);
        } else {
            _elementColors.get(sequenceFlow.getId()).add("bgcolor:" + properties.get("bgcolor"));
        }
    }
    if (properties.get("bordercolor") != null && properties.get("bordercolor").length() > 0) {
        if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("bordercolor:" + properties.get("bordercolor"));
            _elementColors.put(sequenceFlow.getId(), colorsList);
        } else {
            _elementColors.get(sequenceFlow.getId()).add("bordercolor:" + properties.get("bordercolor"));
        }
    }
    if (properties.get("fontsize") != null && properties.get("fontsize").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "fontsize", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("fontsize"));
        sequenceFlow.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("fontcolor") != null && properties.get("fontcolor").length() > 0) {
        if (!(_elementColors.containsKey(sequenceFlow.getId()))) {
            List<String> colorsList = new ArrayList<String>();
            colorsList.add("fontcolor:" + properties.get("fontcolor"));
            _elementColors.put(sequenceFlow.getId(), colorsList);
        } else {
            _elementColors.get(sequenceFlow.getId()).add("fontcolor:" + properties.get("fontcolor"));
        }
    }
    // Custom extended auto connection property for Stunner.
    String sourceConnAutoPropertyName = Bpmn2OryxManager.MAGNET_AUTO_CONNECTION + Bpmn2OryxManager.SOURCE;
    String sourceConnAutoRaw = properties.get(sourceConnAutoPropertyName);
    if (null != sourceConnAutoRaw && Boolean.TRUE.equals(Boolean.parseBoolean(sourceConnAutoRaw))) {
        Utils.setMetaDataExtensionValue(sequenceFlow, sourceConnAutoPropertyName, Boolean.toString(true));
    }
    String targetConnAutoPropertyName = Bpmn2OryxManager.MAGNET_AUTO_CONNECTION + Bpmn2OryxManager.TARGET;
    String targetConnAutoRaw = properties.get(targetConnAutoPropertyName);
    if (null != targetConnAutoRaw && Boolean.TRUE.equals(Boolean.parseBoolean(targetConnAutoRaw))) {
        Utils.setMetaDataExtensionValue(sequenceFlow, targetConnAutoPropertyName, Boolean.toString(true));
    }
    if (properties.get("isselectable") != null && properties.get("isselectable").length() > 0) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "selectable", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, properties.get("isselectable"));
        sequenceFlow.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("auditing") != null && !"".equals(properties.get("auditing"))) {
        Auditing audit = Bpmn2Factory.eINSTANCE.createAuditing();
        audit.getDocumentation().add(createDocumentation(properties.get("auditing")));
        sequenceFlow.setAuditing(audit);
    }
    applySequenceFlowCondition(sequenceFlow, properties);
    if (properties.get("priority") != null && !"".equals(properties.get("priority"))) {
        ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
        EAttributeImpl priorityElement = (EAttributeImpl) metadata.demandFeature("http://www.jboss.org/drools", "priority", false, false);
        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(priorityElement, properties.get("priority"));
        sequenceFlow.getAnyAttribute().add(extensionEntry);
    }
    if (properties.get("monitoring") != null && !"".equals(properties.get("monitoring"))) {
        Monitoring monitoring = Bpmn2Factory.eINSTANCE.createMonitoring();
        monitoring.getDocumentation().add(createDocumentation(properties.get("monitoring")));
        sequenceFlow.setMonitoring(monitoring);
    }
    sequenceFlow.setIsImmediate(Boolean.parseBoolean(properties.get("isimmediate")));
    // simulation properties
    if (properties.get("probability") != null && properties.get("probability").length() > 0) {
        ControlParameters controlParams = BpsimFactory.eINSTANCE.createControlParameters();
        Parameter probParam = BpsimFactory.eINSTANCE.createParameter();
        FloatingParameterType probParamValueParam = BpsimFactory.eINSTANCE.createFloatingParameterType();
        DecimalFormat twoDForm = new DecimalFormat("#.##");
        probParamValueParam.setValue(Double.valueOf(twoDForm.format(Double.valueOf(properties.get("probability")))));
        probParam.getParameterValue().add(probParamValueParam);
        controlParams.setProbability(probParam);
        if (_simulationElementParameters.containsKey(sequenceFlow.getId())) {
            _simulationElementParameters.get(sequenceFlow.getId()).add(controlParams);
        } else {
            List<EObject> values = new ArrayList<EObject>();
            values.add(controlParams);
            _simulationElementParameters.put(sequenceFlow.getId(), values);
        }
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) Auditing(org.eclipse.bpmn2.Auditing) FloatingParameterType(bpsim.FloatingParameterType) EAttributeImpl(org.eclipse.emf.ecore.impl.EAttributeImpl) EObject(org.eclipse.emf.ecore.EObject) ControlParameters(bpsim.ControlParameters) Parameter(bpsim.Parameter) SimpleFeatureMapEntry(org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry) ExtendedMetaData(org.eclipse.emf.ecore.util.ExtendedMetaData) Monitoring(org.eclipse.bpmn2.Monitoring)

Aggregations

Auditing (org.eclipse.bpmn2.Auditing)3 Monitoring (org.eclipse.bpmn2.Monitoring)3 EAttributeImpl (org.eclipse.emf.ecore.impl.EAttributeImpl)2 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)2 ExtendedMetaData (org.eclipse.emf.ecore.util.ExtendedMetaData)2 ControlParameters (bpsim.ControlParameters)1 FloatingParameterType (bpsim.FloatingParameterType)1 Parameter (bpsim.Parameter)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)1 Import (org.eclipse.bpmn2.Import)1 EObject (org.eclipse.emf.ecore.EObject)1 Internal (org.eclipse.emf.ecore.EStructuralFeature.Internal)1 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)1 GlobalType (org.jboss.drools.GlobalType)1 ImportType (org.jboss.drools.ImportType)1