From d7fc909881be0766634a992582b2b85118806046 Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Mon, 2 Sep 2024 12:21:59 +0200 Subject: [PATCH] refactoring Issue #823 --- .../java/org/imixs/workflow/ModelManager.java | 105 ++++++++++------ .../org/imixs/workflow/WorkflowKernel.java | 8 +- .../workflow/bpmn/TestBPMNModelBasic.java | 28 ++--- .../bpmn/TestBPMNParserCollaboration.java | 2 +- .../TestBPMNParserCollaborationMinutes.java | 2 +- .../workflow/bpmn/TestBPMNParserGroups.java | 4 +- .../bpmn/TestBPMNParserMessageText.java | 2 +- .../bpmn/TestBPMNParserSharedLinkEvent.java | 2 +- .../workflow/bpmn/TestBPMNParserTicket.java | 4 +- .../imixs/workflow/engine/ModelService.java | 6 +- .../workflow/engine/plugins/RulePlugin.java | 16 +-- .../workflow/engine/TestModelServiceNew.java | 46 ------- .../engine/WorkflowMockEnvironment.java | 3 +- .../engine/adapters/TestAccessAdapter.java | 2 +- .../workflow/plugins/TestRulePlugin.java | 112 +----------------- .../workflow/jaxrs/ModelRestService.java | 6 +- 16 files changed, 98 insertions(+), 250 deletions(-) delete mode 100644 imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/TestModelServiceNew.java diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java index a6762ab0e..b38592c9b 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/ModelManager.java @@ -3,10 +3,10 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -58,6 +58,7 @@ public class ModelManager { // cache private final Map bpmnEntityCache = new ConcurrentHashMap<>(); private final Map bpmnElementCache = new ConcurrentHashMap<>(); + private final Map> groupCache = new ConcurrentHashMap<>(); private RuleEngine ruleEngine = null; @@ -310,7 +311,7 @@ public List getVersions() { // convert to List List result = new ArrayList<>(); result.addAll(versions); - Collections.sort(result); + Collections.sort(result, Collections.reverseOrder()); return result; } @@ -335,7 +336,7 @@ public BPMNModel findModelByWorkitem(ItemCollection workitem) throws ModelExcept } else { // try to find model by regex if version is not empty... if (version != null && !version.isEmpty()) { - List matchingVersions = findVersionsByRegEx(version); + Set matchingVersions = findVersionsByRegEx(version); for (String matchingVersion : matchingVersions) { result = modelStore.get(matchingVersion); if (result != null) { @@ -350,9 +351,9 @@ public BPMNModel findModelByWorkitem(ItemCollection workitem) throws ModelExcept // Still no match, try to find model version by group if (!workitem.getWorkflowGroup().isEmpty()) { - List versions = findAllVersionsByGroup(workitem.getWorkflowGroup()); + Set versions = findAllVersionsByGroup(workitem.getWorkflowGroup()); if (!versions.isEmpty()) { - String newVersion = versions.get(0); + String newVersion = versions.iterator().next(); if (!newVersion.isEmpty()) { logger.log(Level.WARNING, "Deprecated model version: ''{0}'' -> migrating to ''{1}''," + " $workflowgroup: ''{2}'', $uniqueid: {3}", @@ -382,33 +383,59 @@ public BPMNModel findModelByWorkitem(ItemCollection workitem) throws ModelExcept * @param group * @return */ - public Set findAllGroups(BPMNModel _model) { - Set result = new LinkedHashSet<>(); - - Set processList = _model.getProcesses(); - for (BPMNProcess _process : processList) { - String groupName = _process.getName(); - if (_model.isCollaborationDiagram()) { - // collaboration diagram - only add private processes (Pools) - if (BPMNTypes.PROCESS_TYPE_PRIVATE.equals(_process.getProcessType())) { - // add only private process types - result.add(groupName); - } - } else { - // if it is not a collaboration diagram we return the name of the first Public - // Process - if (BPMNTypes.PROCESS_TYPE_PUBLIC.equals(_process.getProcessType())) { - result.add(groupName); - break; + public Set findAllGroupsByModel(BPMNModel _model) { + Set result = null; + // test cache + String version = BPMNUtil.getVersion(_model); + result = groupCache.get(version); + if (result == null) { + result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + + Set processList = _model.getProcesses(); + for (BPMNProcess _process : processList) { + String groupName = _process.getName(); + if (_model.isCollaborationDiagram()) { + // collaboration diagram - only add private processes (Pools) + if (BPMNTypes.PROCESS_TYPE_PRIVATE.equals(_process.getProcessType())) { + // add only private process types + result.add(groupName); + } + } else { + // if it is not a collaboration diagram we return the name of the first Public + // Process + if (BPMNTypes.PROCESS_TYPE_PUBLIC.equals(_process.getProcessType())) { + result.add(groupName); + break; + } } } + if (result.size() == 0) { + logger.warning("Model " + BPMNUtil.getVersion(_model) + + " does not contain valid process elements! Please check your model file!"); + } + // finally cache the new group set + groupCache.put(version, result); } - if (result.size() == 0) { - logger.warning("Model " + BPMNUtil.getVersion(_model) - + " does not contain valid process elements! Please check your model file!"); - } + // Create an immutable set from the sorted set + return Set.copyOf(result); + } + /** + * This method returns a sorted list of all unique workflow groups contained in + * the model store. + *

+ * In case the model is a collaboration diagram, the method returns only group + * names from private process instances (Pools)! + * + * @param group + * @return + */ + public Set findAllGroups() { + Set result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + for (BPMNModel model : modelStore.values()) { + result.addAll(findAllGroupsByModel(model)); + } return result; } @@ -420,22 +447,22 @@ public Set findAllGroups(BPMNModel _model) { * @param group - name of the workflow group * @return list of matching model versions */ - public List findAllVersionsByGroup(String group) { + public Set findAllVersionsByGroup(String group) { boolean debug = logger.isLoggable(Level.FINE); - List result = new ArrayList(); + // Sorted in reverse order + Set result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); if (debug) { logger.log(Level.FINEST, "......searching model versions for workflowgroup ''{0}''...", group); } // try to find matching model version by group Collection models = modelStore.values(); for (BPMNModel _model : models) { - Set allGroups = findAllGroups(_model); + Set allGroups = findAllGroupsByModel(_model); if (allGroups.contains(group)) { result.add(BPMNUtil.getVersion(_model)); } } - // sort result - Collections.sort(result, Collections.reverseOrder()); + return result; } @@ -453,9 +480,9 @@ public List findAllVersionsByGroup(String group) { */ public String findVersionByGroup(String group) { String result = null; - List versions = findAllVersionsByGroup(group); + Set versions = findAllVersionsByGroup(group); if (versions.size() > 0) { - result = versions.get(0); + result = versions.iterator().next(); } return result; } @@ -468,9 +495,11 @@ public String findVersionByGroup(String group) { * @param group * @return */ - public List findVersionsByRegEx(String modelRegex) { + public Set findVersionsByRegEx(String modelRegex) { boolean debug = logger.isLoggable(Level.FINE); - List result = new ArrayList(); + // List result = new ArrayList(); + // Sorted in reverse order + Set result = new TreeSet<>(Collections.reverseOrder()); if (debug) { logger.log(Level.FINEST, "......searching model versions for regex ''{0}''...", modelRegex); } @@ -482,8 +511,6 @@ public List findVersionsByRegEx(String modelRegex) { result.add(_version); } } - // sort result - Collections.sort(result, Collections.reverseOrder()); return result; } @@ -680,6 +707,7 @@ public boolean evaluateCondition(String expression, ItemCollection workitem) { private void clearCache() { bpmnEntityCache.clear(); bpmnElementCache.clear(); + groupCache.clear(); } /** @@ -741,7 +769,6 @@ private Activity lookupTaskElementByID(final BPMNModel model, int taskID) { String id = activity.getExtensionAttribute(BPMNUtil.getNamespace(), "processid"); try { if (taskID == Long.parseLong(id)) { - logger.info("lookupTaskElementByID " + taskID + " took " + (System.currentTimeMillis() - l) + "ms"); return activity; } } catch (NumberFormatException e) { diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/WorkflowKernel.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/WorkflowKernel.java index a7e47fe9f..6c1b540fd 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/WorkflowKernel.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/WorkflowKernel.java @@ -427,13 +427,7 @@ private ItemCollection processEvent(ItemCollection workitem, ItemCollection even BPMNModel model = this.ctx.getModelManager().getModel(workitem.getModelVersion()); // set $lastEventDate workitem.replaceItemValue(LASTEVENTDATE, new Date()); - - // invalidate deprecated models! - if (event.hasItem("keyFollowUp")) { - throw new ModelException(ModelException.INVALID_MODEL_ENTRY, - "Invalid Event Item: keyFollowUp no longer supported!"); - } - + // Execute Plugins and Adapters.... workitem = executeMicroKernels(workitem, event); // test if a new model version was assigned by the last event diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNModelBasic.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNModelBasic.java index f64109662..4c15b6425 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNModelBasic.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNModelBasic.java @@ -165,15 +165,12 @@ public void testModifyTask() throws ModelException { // test task 1000 ItemCollection task = openBPMNModelManager.findTaskByID(model, 1000); - Assert.assertNotNull(task); Assert.assertEquals("Task 1", task.getItemValueString("name")); Assert.assertEquals("Some documentation...", task.getItemValueString("documentation")); - // change some attributes of task.... task.replaceItemValue("txtworkflowgroup", "test"); Assert.assertEquals("test", task.getItemValueString("txtworkflowgroup")); - // test task 1000 once again task = openBPMNModelManager.findTaskByID(model, 1000); Assert.assertNotNull(task); @@ -194,25 +191,20 @@ public void testModifyTask() throws ModelException { */ @Test public void testModifyDefinition() throws ModelException { - ItemCollection workitem = new ItemCollection(); workitem.model("1.0.0"); // test definition ItemCollection definition = openBPMNModelManager.loadDefinition(model); - Assert.assertNotNull(definition); Assert.assertEquals("1.0.0", definition.getItemValueString("$ModelVersion")); - // change name of definition.... definition.replaceItemValue("$ModelVersion", "test"); Assert.assertEquals("test", definition.getItemValueString("$ModelVersion")); - // test definition once again definition = openBPMNModelManager.loadDefinition(model); Assert.assertNotNull(definition); Assert.assertEquals("1.0.0", definition.getItemValueString("$ModelVersion")); - } /** @@ -227,18 +219,20 @@ public void testModifyDefinition() throws ModelException { */ @Test public void testModifyGroups() throws ModelException { - - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); Assert.assertNotNull(groups); Assert.assertEquals(1, groups.size()); // add a new group.... - groups.add("test-group1"); - Assert.assertEquals(2, groups.size()); - // test groups once again - groups = openBPMNModelManager.findAllGroups(model); - Assert.assertNotNull(groups); - Assert.assertEquals(1, groups.size()); - + try { + groups.add("test-group1"); + Assert.fail(); + } catch (UnsupportedOperationException e) { + // we expect a UnsupportedOperationException + // test groups once again + groups = openBPMNModelManager.findAllGroupsByModel(model); + Assert.assertNotNull(groups); + Assert.assertEquals(1, groups.size()); + } } /** diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaboration.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaboration.java index d55ae76e6..2ab35ae63 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaboration.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaboration.java @@ -52,7 +52,7 @@ public void testSimple() Assert.assertEquals("WorkflowEnvironmentEntity", profile.getItemValueString("type")); Assert.assertEquals("1.0.0", profile.getItemValueString("$ModelVersion")); - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); // List groups = model.getGroups(); // Test Groups Assert.assertFalse(groups.contains("Collaboration")); diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaborationMinutes.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaborationMinutes.java index ea7ca6606..d88284ff0 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaborationMinutes.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserCollaborationMinutes.java @@ -48,7 +48,7 @@ public void testSimple() throws ModelException { BPMNModel model = openBPMNModelManager.getModel("1.0.0"); Assert.assertNotNull(model); - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); // Test Groups Assert.assertFalse(groups.contains("Collaboration")); Assert.assertTrue(groups.contains("Protokoll")); diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserGroups.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserGroups.java index 68ede51a4..cec5abaea 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserGroups.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserGroups.java @@ -55,7 +55,7 @@ public void testSingleGroup() { Assert.fail(e.getMessage()); } // Test Groups - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); Assert.assertTrue(groups.contains("Simple")); @@ -87,7 +87,7 @@ public void testMultiGroups() } // Test Groups - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); Assert.assertEquals(2, groups.size()); Assert.assertTrue(groups.contains("Protokoll")); Assert.assertTrue(groups.contains("Protokollpunkt")); diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserMessageText.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserMessageText.java index 04c25ac28..b1bad700a 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserMessageText.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserMessageText.java @@ -46,7 +46,7 @@ public void testSimple() throws ParseException, Assert.fail(); } - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); Assert.assertTrue(groups.contains("Message Example")); // test count of elements diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserSharedLinkEvent.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserSharedLinkEvent.java index 890d8926f..99fb3df75 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserSharedLinkEvent.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserSharedLinkEvent.java @@ -50,7 +50,7 @@ public void testLinkEventSimple() { } // Test Environment - Assert.assertTrue(openBPMNModelManager.findAllGroups(model).contains("Simple")); + Assert.assertTrue(openBPMNModelManager.findAllGroupsByModel(model).contains("Simple")); // test count of elements Assert.assertEquals(3, model.findAllActivities().size()); diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserTicket.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserTicket.java index 579951af1..8d9a1cf84 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserTicket.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/TestBPMNParserTicket.java @@ -70,7 +70,7 @@ public void testSimple() throws ModelException { Assert.assertEquals("org.imixs.workflow.plugins.HistoryPlugin", plugins.get(2)); Assert.assertEquals("org.imixs.workflow.plugins.ResultPlugin", plugins.get(3)); - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); Assert.assertTrue(groups.contains("Ticket")); // test task 1000 @@ -149,7 +149,7 @@ public void testSimpleDeprecatedItemNames() throws ModelException { Assert.assertEquals("org.imixs.workflow.plugins.HistoryPlugin", plugins.get(2)); Assert.assertEquals("org.imixs.workflow.plugins.ResultPlugin", plugins.get(3)); - Set groups = openBPMNModelManager.findAllGroups(model); + Set groups = openBPMNModelManager.findAllGroupsByModel(model); Assert.assertTrue(groups.contains("Ticket")); // test task 1000 diff --git a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/ModelService.java b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/ModelService.java index 8138656d0..2e951693e 100644 --- a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/ModelService.java +++ b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/ModelService.java @@ -90,13 +90,13 @@ public class ModelService { private static final Logger logger = Logger.getLogger(ModelService.class.getName()); - private ModelManager modelManager = null; + protected ModelManager modelManager = null; @Inject - private DocumentService documentService; + protected DocumentService documentService; @Resource - private SessionContext ctx; + protected SessionContext ctx; public ModelService() { super(); diff --git a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/RulePlugin.java b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/RulePlugin.java index 448ae3d93..27881d613 100644 --- a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/RulePlugin.java +++ b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/RulePlugin.java @@ -169,25 +169,13 @@ public ItemCollection run(ItemCollection workitem, ItemCollection event) "BusinessRule: validation failed - ErrorCode=" + sErrorCode, params); } - // now test the variable 'followUp' - Object followUp = null; + // now test the deprecated variable 'followUp' // first test result object if (result.hasItem("followUp")) { - followUp = result.getItemValueString("followUp"); + logger.warning("Rule contains deprecated item 'followUp'. This item is no longer supported."); result.removeItem("followUp"); } - // If followUp is defined we update now the activityEntity.... - if (followUp != null) { - // try to get double value... - Double d = Double.valueOf(followUp.toString()); - Long followUpActivity = d.longValue(); - if (followUpActivity != null && followUpActivity > 0) { - event.replaceItemValue("keyFollowUp", "1"); - event.replaceItemValue("numNextActivityID", followUpActivity); - } - } - // if result has item values then we update now the current // workitem iterate over all entries diff --git a/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/TestModelServiceNew.java b/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/TestModelServiceNew.java deleted file mode 100644 index a9207b240..000000000 --- a/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/TestModelServiceNew.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.imixs.workflow.engine; - -import org.imixs.workflow.ModelManager; -import org.imixs.workflow.exceptions.ModelException; -import org.junit.Assert; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -/** - * Test class for WorkflowService - * - * This test verifies specific method implementations of the workflowService by - * mocking the WorkflowService with the @spy annotation. - * - * - * @author rsoika - */ -@ExtendWith(MockitoExtension.class) -public class TestModelServiceNew { - public static final String DEFAULT_MODEL_VERSION = "1.0.0"; - - @Mock - private DocumentService documentService; - - @InjectMocks - ModelService modelServiceMock; - - /** - * This test - * - * @throws ModelException - * - */ - @Test - public void testGetDataObject() throws ModelException { - - ModelManager openBPMNModelManager = modelServiceMock.getModelManager(); - - Assert.assertNotNull(openBPMNModelManager); - - } - -} diff --git a/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/WorkflowMockEnvironment.java b/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/WorkflowMockEnvironment.java index b5ec2535e..39208e501 100644 --- a/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/WorkflowMockEnvironment.java +++ b/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/WorkflowMockEnvironment.java @@ -11,6 +11,7 @@ import org.imixs.workflow.Adapter; import org.imixs.workflow.ItemCollection; +import org.imixs.workflow.ModelManager; import org.imixs.workflow.WorkflowKernel; import org.imixs.workflow.exceptions.ModelException; import org.imixs.workflow.exceptions.PluginException; @@ -104,10 +105,10 @@ public void setUp() throws PluginException { // Set up test environment createTestDatabase(); - loadBPMNModel("/bpmn/plugin-test.bpmn"); // Link modelService to workflowServiceMock workflowService.modelService = modelService; + modelService.modelManager = new ModelManager(); Assert.assertNotNull(modelService.getModelManager()); workflowContext = new WorkflowContextMock(); diff --git a/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/adapters/TestAccessAdapter.java b/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/adapters/TestAccessAdapter.java index 32811423b..3dfd60085 100644 --- a/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/adapters/TestAccessAdapter.java +++ b/imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/adapters/TestAccessAdapter.java @@ -49,7 +49,7 @@ public void setUp() throws PluginException, ModelException { // Setup Environment workflowEnvironment.setUp(); workflowEnvironment.loadBPMNModel("/bpmn/TestAccessPlugin.bpmn"); - model = workflowEnvironment.getModelService().getModel("1.0.0"); + model = workflowEnvironment.getModelService().getModelManager().getModel("1.0.0"); accessAdapter.workflowService = workflowEnvironment.getWorkflowService(); // prepare data diff --git a/imixs-workflow-engine/src/test/java/org/imixs/workflow/plugins/TestRulePlugin.java b/imixs-workflow-engine/src/test/java/org/imixs/workflow/plugins/TestRulePlugin.java index bed99e9a9..b1d32c5dd 100644 --- a/imixs-workflow-engine/src/test/java/org/imixs/workflow/plugins/TestRulePlugin.java +++ b/imixs-workflow-engine/src/test/java/org/imixs/workflow/plugins/TestRulePlugin.java @@ -1,6 +1,5 @@ package org.imixs.workflow.plugins; -import java.math.BigDecimal; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -220,38 +219,6 @@ public void testComplexPluginException() { } - /** - * This test verifies the follUp behavior. If set then keyFollowUp and - * numNextActivity should be overwritten by the RulePlugin - * - * @throws ScriptException - * @throws PluginException - */ - @Test - public void testFollowUpActivity() throws PluginException { - - ItemCollection adocumentContext = new ItemCollection(); - ItemCollection adocumentActivity = new ItemCollection(); - - // set a business rule - String script = "var result={}; var a=1.0;var b=2;result.followUp =a+b;"; - - logger.log(Level.INFO, "Script={0}", script); - adocumentActivity.replaceItemValue("txtBusinessRUle", script); - - // run plugin - adocumentContext = rulePlugin.run(adocumentContext, adocumentActivity); - Assert.assertNotNull(adocumentContext); - - String sFllowUp = adocumentActivity.getItemValueString("keyFollowUp"); - int followUp = adocumentActivity.getItemValueInteger("numNextActivityID"); - - Assert.assertEquals("1", sFllowUp); - - Assert.assertEquals(followUp, 3); - - } - /** * only to evaluate some behavior * @@ -263,7 +230,7 @@ public void simpleApprovalTest() throws PluginException { // set a business rule // workitem.get(refField1)[0]) - String script = " var result={}; result.followUp=null;" + " if (workitem._amount_brutto[0]>5000)" + String script = " var result={};" + " if (workitem._amount_brutto[0]>5000)" + " result.followUp=90;"; logger.log(Level.INFO, "Script={0}", script); @@ -276,12 +243,6 @@ public void simpleApprovalTest() throws PluginException { // run plugin workitem = rulePlugin.run(workitem, event); Assert.assertNotNull(workitem); - String sFllowUp = event.getItemValueString("keyFollowUp"); - int followUp = event.getItemValueInteger("numNextActivityID"); - - Assert.assertEquals("1", sFllowUp); - - Assert.assertEquals(90, followUp); /* * Case 2 @@ -297,45 +258,6 @@ public void simpleApprovalTest() throws PluginException { workitem = rulePlugin.run(workitem, event); Assert.assertNotNull(workitem); - sFllowUp = event.getItemValueString("keyFollowUp"); - followUp = event.getItemValueInteger("numNextActivityID"); - - Assert.assertEquals("", sFllowUp); - - Assert.assertEquals(0, followUp); - - } - - /** - * This test verifies the BigDecimal support of the RulePlugin - * - * @throws ScriptException - * @throws PluginException - */ - @Test - public void bigDecimalTest() throws PluginException { - - // set a business rule - String script = " var result={};" + " if (workitem._amount_brutto[0]>5000.50)" + " result.followUp=90;"; - logger.log(Level.INFO, "Script={0}", script); - - ItemCollection adocumentContext = new ItemCollection(); - adocumentContext.replaceItemValue("_amount_brutto", BigDecimal.valueOf(5000.51d)); - ItemCollection adocumentActivity = new ItemCollection(); - - adocumentActivity.replaceItemValue("txtBusinessRUle", script); - - // run plugin - adocumentContext = rulePlugin.run(adocumentContext, adocumentActivity); - Assert.assertNotNull(adocumentContext); - - String sFllowUp = adocumentActivity.getItemValueString("keyFollowUp"); - int followUp = adocumentActivity.getItemValueInteger("numNextActivityID"); - - Assert.assertEquals("1", sFllowUp); - - Assert.assertEquals(90, followUp); - } /** @@ -741,38 +663,6 @@ public void testResultObjectJSON() throws PluginException { } - /** - * This test verifies the follUp behavior. If set then keyFollowUp and - * numNextActivity should be overwritten by the RulePlugin - * - * @throws ScriptException - * @throws PluginException - */ - @Test - public void testResultObjectFollowUpActivity() throws PluginException { - - ItemCollection adocumentContext = new ItemCollection(); - ItemCollection adocumentActivity = new ItemCollection(); - - // set a business rule - String script = "var a=1.0;var b=2;var result={}; result.followUp =a+b;"; - - logger.log(Level.INFO, "Script={0}", script); - adocumentActivity.replaceItemValue("txtBusinessRUle", script); - - // run plugin - adocumentContext = rulePlugin.run(adocumentContext, adocumentActivity); - Assert.assertNotNull(adocumentContext); - - String sFllowUp = adocumentActivity.getItemValueString("keyFollowUp"); - int followUp = adocumentActivity.getItemValueInteger("numNextActivityID"); - - Assert.assertEquals("1", sFllowUp); - - Assert.assertEquals(followUp, 3); - - } - /** * This test verifies setting a new value via the result object * diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java index fdb90a883..58720a08d 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java @@ -309,7 +309,7 @@ public Set getGroups(@PathParam("version") String version, @QueryParam(" Set col = null; try { BPMNModel model = modelService.getModelManager().getModel(version); - col = modelService.getModelManager().findAllGroups(model); + col = modelService.getModelManager().findAllGroupsByModel(model); return col; } catch (ModelException e) { throw new WebApplicationException("BPMN Model Error: ", e); @@ -539,8 +539,8 @@ private void appendTagsToBuffer(String modelVersion, String rootContext, StringB ItemCollection modelEntity = modelService.loadModel(modelVersion); // now check groups... - Set groupList = modelService.getModelManager().findAllGroups(model);// .getWorkflowGroups(model);// - // model.getGroups(); + Set groupList = modelService.getModelManager().findAllGroupsByModel(model);// .getWorkflowGroups(model);// + // model.getGroups(); buffer.append(""); if (modelEntity != null) {