diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java index 24e3b82de..4a3bef877 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java @@ -1100,6 +1100,11 @@ public void setTaskID(int taskID) { // deprecated processID is still supported for a long period. See issue #384 replaceItemValue("$processid", taskID); } + + public ItemCollection task(int taskID) { + setTaskID(taskID); + return this; + } /** * This method is deprecated. Use instead getEventID() @@ -1152,6 +1157,11 @@ public void setEventID(int eventID) { replaceItemValue("$activityid", eventID); } } + + public ItemCollection event(int eventID) { + setEventID(eventID); + return this; + } /** * @return current $ModelVersion @@ -1159,6 +1169,41 @@ public void setEventID(int eventID) { public String getModelVersion() { return getItemValueString(WorkflowKernel.MODELVERSION); } + + /** + * set the $ModelVersion + */ + public void setModelVersion(String modelversion) { + replaceItemValue(WorkflowKernel.MODELVERSION,modelversion); + } + + public ItemCollection model(String modelversion) { + setModelVersion(modelversion); + return this; + } + + + + /** + * @return current $ModelVersion + */ + public String getWorkflowGroup() { + return getItemValueString(WorkflowKernel.WORKFLOWGROUP); + } + + /** + * set the $ModelVersion + */ + public void setWorkflowGroup(String group) { + replaceItemValue(WorkflowKernel.WORKFLOWGROUP, group); + } + + public ItemCollection workflowGroup(String group) { + setWorkflowGroup(group); + return this; + } + + /** * @return $UniqueID diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java index fd74356be..591dc12ab 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java @@ -734,16 +734,35 @@ public void testFileData() { } + /* + * Test the fluent code interface. + */ + @Test + @Category(org.imixs.workflow.ItemCollection.class) + public void testFluentInterface() { + ItemCollection itemCollection = new ItemCollection().model("1.0.0").task(1).event(10); + + Assert.assertEquals("1.0.0", itemCollection.getModelVersion()); + Assert.assertEquals(1, itemCollection.getTaskID()); + Assert.assertEquals(10, itemCollection.getEventID()); + + // set group + itemCollection = new ItemCollection().workflowGroup("Ticket").task(1).event(10); + Assert.assertEquals("Ticket", itemCollection.getWorkflowGroup()); + Assert.assertEquals(1, itemCollection.getTaskID()); + Assert.assertEquals(10, itemCollection.getEventID()); + } + /** * Test issue #383, #384 */ @Test @Category(org.imixs.workflow.ItemCollection.class) public void testDeprecatedFieldProcessID() { - + Assert.assertEquals("$processid", WorkflowKernel.PROCESSID); Assert.assertEquals("$taskid", WorkflowKernel.TASKID); - + ItemCollection itemColSource = new ItemCollection(); itemColSource.replaceItemValue("$processid", 42); @@ -757,10 +776,10 @@ public void testDeprecatedFieldProcessID() { Assert.assertEquals(43, itemColSource.getTaskID()); Assert.assertEquals(43, itemColSource.getProcessID()); Assert.assertEquals(43, itemColSource.getItemValueInteger("$processid")); - + // test direct setting itemColSource = new ItemCollection(); - itemColSource.replaceItemValue("$taskid",44); + itemColSource.replaceItemValue("$taskid", 44); Assert.assertEquals(44, itemColSource.getTaskID()); Assert.assertEquals(44, itemColSource.getProcessID()); // !!!