protected FeatureMap getExtensionElements(BaseElement element) { if (element.getExtensionValues() == null || element.getExtensionValues().isEmpty()) { ExtensionAttributeValue eav = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue(); element.getExtensionValues().add(eav); return eav.getValue(); } else { return element.getExtensionValues().get(0).getValue(); } }
private static void addExtensionValue(FlowElement flowElement, FeatureMap.Entry value) { extensionFor(flowElement).getValue().add(value); }
@SuppressWarnings("unchecked") private Map<String, ElementParameters> initSimulationParameters(Definitions definitions) { Map<String, ElementParameters> simulationParameters = new HashMap<>(); List<Relationship> relationships = definitions.getRelationships(); if (relationships.isEmpty()) { return Collections.emptyMap(); } FeatureMap value = relationships.get(0) .getExtensionValues().get(0) .getValue(); Object simData = value.get(BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA, true); List<BPSimDataType> bpsimExtensions = (List<BPSimDataType>) simData; Scenario scenario = bpsimExtensions.get(0).getScenario().get(0); for (ElementParameters parameters : scenario.getElementParameters()) { simulationParameters.put(parameters.getElementRef(), parameters); } return simulationParameters; }
private Scenario getDefaultScenario(Definitions def) { if(def.getRelationships() != null && !def.getRelationships().isEmpty()) { // current support for single relationship Relationship relationship = def.getRelationships().get(0); for(ExtensionAttributeValue extattrval : relationship.getExtensionValues()) { FeatureMap extensionElements = extattrval.getValue(); @SuppressWarnings("unchecked") List<BPSimDataType> bpsimExtension = (List<BPSimDataType>) extensionElements.get(BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA, true); if(bpsimExtension != null && !bpsimExtension.isEmpty()) { BPSimDataType bpmsim = bpsimExtension.get(0); if(bpmsim.getScenario() != null && !bpmsim.getScenario().isEmpty()) { return bpmsim.getScenario().get(0); } } } } return null; }
private Scenario getDefaultScenario(Definitions def) { if(def.getRelationships() != null && !def.getRelationships().isEmpty()) { // current support for single relationship Relationship relationship = def.getRelationships().get(0); for(ExtensionAttributeValue extattrval : relationship.getExtensionValues()) { FeatureMap extensionElements = extattrval.getValue(); @SuppressWarnings("unchecked") List<BPSimDataType> bpsimExtension = (List<BPSimDataType>) extensionElements.get(BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA, true); if(bpsimExtension != null && !bpsimExtension.isEmpty()) { BPSimDataType bpmsim = bpsimExtension.get(0); if(bpmsim.getScenario() != null && !bpmsim.getScenario().isEmpty()) { return bpmsim.getScenario().get(0); } } } } return null; }
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; }
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; }
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 ScriptTypeListValue getOnExitActions(final List<ExtensionAttributeValue> extensionValues) { final ScriptTypeListValue onExitActions = new ScriptTypeListValue(); ScriptTypeValue onExitAction; if (extensionValues != null && !extensionValues.isEmpty()) { for (ExtensionAttributeValue extattrval : extensionValues) { FeatureMap extensionElements = extattrval.getValue(); @SuppressWarnings("unchecked") List<OnExitScriptType> onExitExtensions = (List<OnExitScriptType>) extensionElements .get(DroolsPackage.Literals.DOCUMENT_ROOT__ON_EXIT_SCRIPT, true); for (OnExitScriptType onExitScript : onExitExtensions) { onExitAction = getOnExitAction(onExitScript); if (onExitAction.getScript() != null && !onExitAction.getScript().isEmpty()) { onExitActions.addValue(onExitAction); } } } } return onExitActions; }
public ScriptTypeListValue getOnEntryActions(final List<ExtensionAttributeValue> extensionValues) { final ScriptTypeListValue onEntryActions = new ScriptTypeListValue(); ScriptTypeValue onEntryAction; if (extensionValues != null && !extensionValues.isEmpty()) { for (ExtensionAttributeValue extattrval : extensionValues) { FeatureMap extensionElements = extattrval.getValue(); @SuppressWarnings("unchecked") List<OnEntryScriptType> onEntryExtensions = (List<OnEntryScriptType>) extensionElements .get(DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, true); for (OnEntryScriptType onEntryScript : onEntryExtensions) { onEntryAction = getOnEntryAction(onEntryScript); if (onEntryAction.getScript() != null && !onEntryAction.getScript().isEmpty()) { onEntryActions.addValue(onEntryAction); } } } } return onEntryActions; }
public static ScriptTypeListValue onExit(List<ExtensionAttributeValue> extensions) { if (extensions.isEmpty()) { return new ScriptTypeListValue() .addValue(new ScriptTypeValue("java", "")); } @SuppressWarnings("unchecked") List<OnExitScriptType> onExitExtensions = (List<OnExitScriptType>) extensions.get(0).getValue() .get(DroolsPackage.Literals.DOCUMENT_ROOT__ON_EXIT_SCRIPT, true); if (!onExitExtensions.isEmpty()) { List<ScriptTypeValue> scripts = onExitExtensions.stream() .map(onExitScriptType -> new ScriptTypeValue( scriptLanguageFromUri(onExitScriptType.getScriptFormat()), onExitScriptType.getScript() )) .collect(Collectors.toList()); return new ScriptTypeListValue(scripts); } return new ScriptTypeListValue() .addValue(new ScriptTypeValue("java", "")); }
public static ScriptTypeListValue onEntry(List<ExtensionAttributeValue> extensions) { if (extensions.isEmpty()) { return new ScriptTypeListValue() .addValue(new ScriptTypeValue("java", "")); } @SuppressWarnings("unchecked") List<OnEntryScriptType> onEntryExtensions = (List<OnEntryScriptType>) extensions.get(0).getValue() .get(DroolsPackage.Literals.DOCUMENT_ROOT__ON_ENTRY_SCRIPT, true); if (!onEntryExtensions.isEmpty()) { List<ScriptTypeValue> scripts = onEntryExtensions.stream() .map(onEntryScriptType -> new ScriptTypeValue( scriptLanguageFromUri(onEntryScriptType.getScriptFormat()), onEntryScriptType.getScript() )) .collect(Collectors.toList()); return new ScriptTypeListValue(scripts); } return new ScriptTypeListValue() .addValue(new ScriptTypeValue("java", "")); }
@Test public void testMarshallNode_CaseReusableSubprocess() throws Exception { expectedStencil = "CaseReusableSubprocess"; final MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn("case"); when(metaDataType.getMetaValue()).thenReturn("true"); final FeatureMap featureMap = mock(FeatureMap.class); when(featureMap.get(eq(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA), eq(true))) .thenReturn(Collections.singletonList(metaDataType)); final ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); when(extensionAttributeValue.getValue()).thenReturn(featureMap); final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(Collections.singletonList(extensionAttributeValue)); tested.marshallNode(callActivity, new HashMap<>(), "ReusableSubprocess", mock(BPMNPlane.class), mock(JsonGenerator.class), 0.0f, 0.0f); }
@Test public void testMarshallNode_ProcessReusableSubprocess() throws Exception { expectedStencil = "ProcessReusableSubprocess"; final MetaDataType metaDataType = mock(MetaDataType.class); when(metaDataType.getName()).thenReturn("case"); when(metaDataType.getMetaValue()).thenReturn("false"); final FeatureMap featureMap = mock(FeatureMap.class); when(featureMap.get(eq(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA), eq(true))) .thenReturn(Collections.singletonList(metaDataType)); final ExtensionAttributeValue extensionAttributeValue = mock(ExtensionAttributeValue.class); when(extensionAttributeValue.getValue()).thenReturn(featureMap); final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(Collections.singletonList(extensionAttributeValue)); tested.marshallNode(callActivity, new HashMap<>(), "ReusableSubprocess", mock(BPMNPlane.class), mock(JsonGenerator.class), 0.0f, 0.0f); } }
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); } }
FeatureMap extensionElements = extattrval.getValue(); @SuppressWarnings("unchecked") List<BPSimDataType> bpsimExtensions = (List<BPSimDataType>) extensionElements.get(BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA,
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); } } } }
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); } } } }
@Test public void testApplyCallActivityProperties() throws Exception { final CallActivity callActivity = mock(CallActivity.class); when(callActivity.getExtensionValues()).thenReturn(new ArrayList<>()); final String propertyName = "isCase"; final String propertyValue = "true"; final String resultName = "case"; final String resultValue = "<![CDATA[" + propertyValue + "]]>"; final Map<String, String> properties = new HashMap<>(); properties.put(propertyName, propertyValue); tested.applyCallActivityProperties(callActivity, properties); assertFalse(callActivity.getExtensionValues().isEmpty()); final ExtensionAttributeValue extenstionValue = callActivity.getExtensionValues().get(0); final Optional<String> value = extenstionValue.getValue().stream() .filter(v -> resultName.equals(((MetaDataType) v.getValue()).getName())) .map(v -> ((MetaDataType) v.getValue()).getMetaValue()).findAny(); assertTrue(value.isPresent() && resultValue.equals(value.get())); }
(Internal) DroolsPackage.Literals.DOCUMENT_ROOT__IMPORT, importType); process.getExtensionValues().get(0).getValue().add(extensionElementEntry); } else { Import imp = Bpmn2Factory.eINSTANCE.createImport(); (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__IMPORT, importType); process.getExtensionValues().get(0).getValue().add(extensionElementEntry); (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__GLOBAL, globalType); process.getExtensionValues().get(0).getValue().add(extensionElementEntry); } else if (globalParts.length == 1) { GlobalType globalType = DroolsFactory.eINSTANCE.createGlobalType(); (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__GLOBAL, globalType); process.getExtensionValues().get(0).getValue().add(extensionElementEntry);