/** * Public constructor to instantiate the helper. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public DroolsXMLProcessor() { super((EPackage.Registry.INSTANCE)); DroolsPackage.eINSTANCE.eClass(); }
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8"); inResource.setEncoding("UTF-8"); DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot(); OnExitScriptType root = DroolsFactory.eINSTANCE.createOnExitScriptType(); root.setScript("script"); root.setScriptFormat("format"); documentRoot.setOnExitScript(root); inResource.getContents().add(documentRoot); assertNotNull(outRoot.getOnExitScript()); OnExitScriptType scriptType = outRoot.getOnExitScript(); assertEquals("script", scriptType.getScript()); assertEquals("format", scriptType.getScriptFormat());
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8"); inResource.setEncoding("UTF-8"); DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot(); OnEntryScriptType root = DroolsFactory.eINSTANCE.createOnEntryScriptType(); root.setScript("script"); root.setScriptFormat("format"); documentRoot.setOnEntryScript(root); inResource.getContents().add(documentRoot); assertNotNull(outRoot.getOnEntryScript()); OnEntryScriptType scriptType = outRoot.getOnEntryScript(); assertEquals("script", scriptType.getScript()); assertEquals("format", scriptType.getScriptFormat());
String baseTimeUnitValue = ""; String baseCurrencyUnitValue = ""; if(scenario.getScenarioParameters() != null) { baseCurrencyUnitValue = scenario.getScenarioParameters().getBaseCurrencyUnit(); baseTimeUnitValue = scenario.getScenarioParameters().getBaseTimeUnit().getName(); if(scenario.getElementParameters() != null) { for(ElementParameters eleType : scenario.getElementParameters()) { if(eleType.getElementId().equals(nodeId)) { if(eleType.getControlParameters() != null && eleType.getControlParameters().getProbability() != null) { FloatingParameterType valType = (FloatingParameterType) eleType.getControlParameters().getProbability().getParameterValue().get(0); properties.put("probability", valType.getValue()); if(eleType.getTimeParameters() != null) { if(eleType.getTimeParameters().getProcessingTime() != null) { Parameter processingTime = eleType.getTimeParameters().getProcessingTime(); ParameterValue paramValue = processingTime.getParameterValue().get(0); if(paramValue instanceof NormalDistributionType) { NormalDistributionType ndt = (NormalDistributionType) paramValue; properties.put("mean", ndt.getMean()); properties.put("standarddeviation", ndt.getStandardDeviation()); properties.put("distributiontype", "normal"); } else if(paramValue instanceof UniformDistributionType) { UniformDistributionType udt = (UniformDistributionType) paramValue; properties.put("max", udt.getMax()); properties.put("min", udt.getMin()); properties.put("distributiontype", "uniform"); } else if(paramValue instanceof RandomDistributionType) { RandomDistributionType rdt = (RandomDistributionType) paramValue;
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8"); inResource.setEncoding("UTF-8"); DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot(); MetaDataType metadataType = DroolsFactory.eINSTANCE.createMetaDataType(); metadataType.setName("testvalue"); metadataType.setMetaValue("testentry"); documentRoot.setMetaData(metadataType); inResource.getContents().add(documentRoot); assertNotNull(outRoot.getMetaData()); MetaDataType outMetadataType = outRoot.getMetaData(); assertEquals(outMetadataType.getName(), "testvalue"); assertEquals(outMetadataType.getMetaValue(), "testentry");
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8"); inResource.setEncoding("UTF-8"); DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot(); GlobalType root = DroolsFactory.eINSTANCE.createGlobalType(); root.setIdentifier("identifier"); root.setType("type"); documentRoot.setGlobal(root); inResource.getContents().add(documentRoot); assertNotNull(outRoot.getGlobal()); GlobalType globalType = outRoot.getGlobal(); assertEquals("identifier", globalType.getIdentifier()); assertEquals("type", globalType.getType());
public static String getMetaDataValue(List<ExtensionAttributeValue> extensionValues, String metaDataName) { if (extensionValues != null && extensionValues.size() > 0) { for (ExtensionAttributeValue extattrval : extensionValues) { FeatureMap extensionElements = extattrval.getValue(); List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements .get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true); for (MetaDataType metaType : metadataExtensions) { if (metaType.getName() != null && metaType.getName().equals(metaDataName) && metaType.getMetaValue() != null && metaType.getMetaValue().length() > 0) { return metaType.getMetaValue(); } } } } return null; }
inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8"); inResource.setEncoding("UTF-8"); DocumentRoot documentRoot = DroolsFactory.eINSTANCE.createDocumentRoot(); ImportType root = DroolsFactory.eINSTANCE.createImportType(); root.setName("import"); documentRoot.setImport(root); inResource.getContents().add(documentRoot); assertNotNull(outRoot.getImport()); ImportType importType = outRoot.getImport(); assertEquals("import", importType.getName());
private MetaDataType metaDataOf(String value) { MetaDataType eleMetadata = DroolsFactory.eINSTANCE.createMetaDataType(); eleMetadata.setName(name); eleMetadata.setMetaValue(asCData(value)); return eleMetadata; }
public static void setOnExitAction(FlowElement flowElement, OnExitAction onExitAction) { ScriptTypeListValue value = onExitAction.getValue(); for (ScriptTypeValue scriptTypeValue : value.getValues()) { String scriptText = scriptTypeValue.getScript(); if (scriptText == null || scriptText.isEmpty()) { continue; } OnExitScriptType script = droolsFactory.createOnExitScriptType(); script.setScript(asCData(scriptText)); String scriptLanguage = Scripts.scriptLanguageToUri(scriptTypeValue.getLanguage()); script.setScriptFormat(scriptLanguage); addExtensionValue(flowElement, DOCUMENT_ROOT__ON_EXIT_SCRIPT, script); } }
public static void setOnEntryAction(FlowElement flowElement, OnEntryAction onEntryAction) { ScriptTypeListValue value = onEntryAction.getValue(); for (ScriptTypeValue scriptTypeValue : value.getValues()) { String scriptText = scriptTypeValue.getScript(); if (scriptText == null || scriptText.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); } }
public ScriptTypeValue getOnEntryAction(final OnEntryScriptType onEntryScriptType) { String language = Utils.getScriptLanguage(onEntryScriptType.getScriptFormat()); if (language == null) { //default to java language = "java"; } final String script = onEntryScriptType.getScript(); return new ScriptTypeValue(language, script); }
public ScriptTypeValue getOnExitAction(final OnExitScriptType onExitScriptType) { String language = Utils.getScriptLanguage(onExitScriptType.getScriptFormat()); if (language == null) { //default to java language = "java"; } final String script = onExitScriptType.getScript(); return new ScriptTypeValue(language, script); }
private Scenario getDefaultScenario(Definitions def) { if(def.getRelationships() != null && def.getRelationships().size() > 0) { // current support for single relationship Relationship relationship = def.getRelationships().get(0); for(ExtensionAttributeValue extattrval : relationship.getExtensionValues()) { FeatureMap extensionElements = extattrval.getValue(); @SuppressWarnings("unchecked") List<ProcessAnalysisDataType> processAnalysisExtensions = (List<ProcessAnalysisDataType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__PROCESS_ANALYSIS_DATA, true); if(processAnalysisExtensions != null && processAnalysisExtensions.size() > 0) { ProcessAnalysisDataType processAnalysis = processAnalysisExtensions.get(0); if(processAnalysis.getScenario() != null && processAnalysis.getScenario().size() > 0) { return processAnalysis.getScenario().get(0); } } } } return null; }
private void prepareExtensionElement(String extensionElementName, String value) { ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); FeatureMap extensionElements = mock(FeatureMap.class); when(extensionAttributeValue.getValue()).thenReturn(extensionElements); List<MetaDataType> metadataExtensions = new ArrayList<>(); MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn(extensionElementName); when(metaDataType.getMetaValue()).thenReturn(value); metadataExtensions.add(metaDataType); when(extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true)).thenReturn(metadataExtensions); List<ExtensionAttributeValue> extensionAttributes = new ArrayList<>(); extensionAttributes.add(extensionAttributeValue); when(baseElement.getExtensionValues()).thenReturn(extensionAttributes); }
public static void setMetaDataExtensionValue(BaseElement element, String metaDataName, String metaDataValue) { if (element != null) { MetaDataType eleMetadata = DroolsFactory.eINSTANCE.createMetaDataType(); eleMetadata.setName(metaDataName); eleMetadata.setMetaValue(metaDataValue); if (element.getExtensionValues() == null || element.getExtensionValues().isEmpty()) { ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue(); element.getExtensionValues().add(extensionElement); } FeatureMap.Entry eleExtensionElementEntry = new EStructuralFeatureImpl.SimpleFeatureMapEntry( (EStructuralFeature.Internal) DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, eleMetadata); element.getExtensionValues().get(0).getValue().add(eleExtensionElementEntry); } }
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); } } } }
/** * Public constructor to instantiate the helper. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public DroolsXMLProcessor() { super((EPackage.Registry.INSTANCE)); DroolsPackage.eINSTANCE.eClass(); }
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 ""; }
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 ""; }