• Icon: Feature Request Feature Request
    • Resolution: Done
    • Icon: Major Major
    • jBPM 4.4
    • jBPM 4.3
    • None

      it would be helpful to be able to use EL in the <description> tag of the (human) task node.
      This will allow to create dynamical task descriptions based on the process variables.

      Example:
      <task name="review_task">
      <description>Review order nr.#

      {order.nr}

      from customer #

      {order.customer.name}

      </description>
      </task>

      The main purpose is to make human task descriptions in the task list more readable and user-friendly.
      Because if you have 20 task instances of the same task and they are all called "Review order from customer" it is really hard to see at a first glance which task is related to which customer.

            [JBPM-2755] EL support in task's <description> tag

            I use Ronald's code to create a patch. After change LANGUAGE_UEL to LANGUAGE_UEL_VALUE the testcase could run successfully, but this issue depended on JBPM-1209, and that issue have last more than two years. I don't know when JBPM-1209 could finished, and whether it will affect this issue.

            HuiSheng Xu (Inactive) added a comment - I use Ronald's code to create a patch. After change LANGUAGE_UEL to LANGUAGE_UEL_VALUE the testcase could run successfully, but this issue depended on JBPM-1209 , and that issue have last more than two years. I don't know when JBPM-1209 could finished, and whether it will affect this issue.

            Patch for test:

            Index: src/test/java/org/jbpm/test/task/TaskPropertiesTest.java
            ===================================================================
            — src/test/java/org/jbpm/test/task/TaskPropertiesTest.java (revision 6151)
            +++ src/test/java/org/jbpm/test/task/TaskPropertiesTest.java (working copy)
            @@ -24,6 +24,9 @@
            */
            package org.jbpm.test.task;

            +import java.util.HashMap;
            +import java.util.Map;
            +
            import org.jbpm.api.ProcessDefinition;
            import org.jbpm.api.task.Task;
            import org.jbpm.test.JbpmTestCase;
            @@ -33,6 +36,7 @@

            • Testcase to check if properties can be resolved through a {@link Task}

              .

            • @author Joram Barrez
              + * @author Ronald van Kuijk
              */
              public class TaskPropertiesTest extends JbpmTestCase {

            @@ -50,6 +54,7 @@
            " <transition to='work hard for the money' />" +
            " </fork>" +
            " <task name='select destination' assignee='" + ACTOR + "'>" +
            + " <description>Description for 'select destination' with #

            {timeframe}

            </description>" +
            " <transition to='wait' />" +
            " </task>" +
            " <task name='work hard for the money' assignee='" + ACTOR2 + "_not_the_same'>" +
            @@ -60,9 +65,14 @@

            public void testGetActivityName()

            { Task task = startProcessInstanceAndReturnTaskFor(ACTOR); - assertEquals("select destination", task.getActivityName()); + assertEquals("select destination", task.getActivityName()); }

            + public void testGetDescription()

            { + Task task = startProcessInstanceAndReturnTaskFor(ACTOR); + assertEquals("Description for 'select destination' with Springbreak", task.getDescription()); + }

            +
            public void testGetProcessDefinitionThroughTask() {
            Task task = startProcessInstanceAndReturnTaskFor(ACTOR);

            @@ -75,7 +85,10 @@

            private Task startProcessInstanceAndReturnTaskFor(String actor)

            { deployJpdlXmlString(PROCESS); - executionService.startProcessInstanceByKey("VacationTrip"); + Map<String, String> vars = new HashMap<String, String>(); + vars.put("timeframe", "Springbreak"); + executionService.startProcessInstanceByKey("VacationTrip",vars); + return taskService.findPersonalTasks(actor).get(0); }

            Ronald van Kuijk (Inactive) added a comment - Patch for test: Index: src/test/java/org/jbpm/test/task/TaskPropertiesTest.java =================================================================== — src/test/java/org/jbpm/test/task/TaskPropertiesTest.java (revision 6151) +++ src/test/java/org/jbpm/test/task/TaskPropertiesTest.java (working copy) @@ -24,6 +24,9 @@ */ package org.jbpm.test.task; +import java.util.HashMap; +import java.util.Map; + import org.jbpm.api.ProcessDefinition; import org.jbpm.api.task.Task; import org.jbpm.test.JbpmTestCase; @@ -33,6 +36,7 @@ Testcase to check if properties can be resolved through a {@link Task} . @author Joram Barrez + * @author Ronald van Kuijk */ public class TaskPropertiesTest extends JbpmTestCase { @@ -50,6 +54,7 @@ " <transition to='work hard for the money' />" + " </fork>" + " <task name='select destination' assignee='" + ACTOR + "'>" + + " <description>Description for 'select destination' with # {timeframe} </description>" + " <transition to='wait' />" + " </task>" + " <task name='work hard for the money' assignee='" + ACTOR2 + "_not_the_same'>" + @@ -60,9 +65,14 @@ public void testGetActivityName() { Task task = startProcessInstanceAndReturnTaskFor(ACTOR); - assertEquals("select destination", task.getActivityName()); + assertEquals("select destination", task.getActivityName()); } + public void testGetDescription() { + Task task = startProcessInstanceAndReturnTaskFor(ACTOR); + assertEquals("Description for 'select destination' with Springbreak", task.getDescription()); + } + public void testGetProcessDefinitionThroughTask() { Task task = startProcessInstanceAndReturnTaskFor(ACTOR); @@ -75,7 +85,10 @@ private Task startProcessInstanceAndReturnTaskFor(String actor) { deployJpdlXmlString(PROCESS); - executionService.startProcessInstanceByKey("VacationTrip"); + Map<String, String> vars = new HashMap<String, String>(); + vars.put("timeframe", "Springbreak"); + executionService.startProcessInstanceByKey("VacationTrip",vars); + return taskService.findPersonalTasks(actor).get(0); }

            I created a small test to see if this works and it partly seems to... The expression is being recognized but once it should be actually parse, an error is thrown:

            org.jbpm.api.JbpmException: no scripting engine configured for language uel
            at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:111)
            at org.jbpm.pvm.internal.script.ScriptManager.evaluateExpression(ScriptManager.java:88)
            at org.jbpm.pvm.internal.el.ScriptExpression.evaluateInScope(ScriptExpression.java:45)
            at org.jbpm.pvm.internal.el.Expression.evaluate(Expression.java:102)
            at org.jbpm.pvm.internal.expr.UelExpressionTest.testUelExpression(UelExpressionTest.java:56)

            Testcase:

            import org.jbpm.pvm.activities.WaitState;
            import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;

            import org.jbpm.pvm.internal.el.Expression;
            import org.jbpm.pvm.internal.el.ScriptExpression;
            import org.jbpm.pvm.internal.el.UelValueExpression;
            import org.jbpm.pvm.internal.model.ExecutionImpl;
            import org.jbpm.test.JbpmTestCase;

            public class ExpressionTest extends JbpmTestCase {

            public void testUelExpression() {
            ExecutionImpl execution = (ExecutionImpl) ProcessDefinitionBuilder
            .startProcess()
            .startActivity("initial", new WaitState())
            .initial()
            .endActivity()
            .endProcess()
            .startProcessInstance();

            execution.setVariable("pv", "MyTest");

            Expression expression = Expression.create("#

            {pv}", Expression.LANGUAGE_UEL_VALUE);
            UelValueExpression uve = ((UelValueExpression) expression);
            assertEquals("MyTest", uve.evaluate(execution));

            Expression expression = Expression.create("#{pv}

            ", Expression.LANGUAGE_UEL);
            ScriptExpression se = ((ScriptExpression) expression);
            assertEquals("MyTest", se.evaluate(execution));

            }
            }

            The first one (UEL_VALUE) works and the second (UEL) not. I cannot seem to find the reason why there is no scripting engine. The way the second expression is constructed is the same as is done for the description. So I tried changing this in the parser (UEL ->UEL_VALUE) and the description could be parsed to (full test of task with description is attached)

            Index: src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
            ===================================================================
            — src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java (revision 6150)
            +++ src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java (working copy)
            @@ -493,7 +493,7 @@
            Element descriptionElement = XmlUtil.element(element, "description");
            if (descriptionElement!=null)

            { String descriptionText = XmlUtil.getContentText(descriptionElement); - Expression descriptionExpression = Expression.create(descriptionText, Expression.LANGUAGE_UEL); + Expression descriptionExpression = Expression.create(descriptionText, Expression.LANGUAGE_UEL_VALUE); assignableDefinition.setDescription(descriptionExpression); }

            Fixes the problem...

            Any ideas?

            Ronald van Kuijk (Inactive) added a comment - I created a small test to see if this works and it partly seems to... The expression is being recognized but once it should be actually parse, an error is thrown: org.jbpm.api.JbpmException: no scripting engine configured for language uel at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:111) at org.jbpm.pvm.internal.script.ScriptManager.evaluateExpression(ScriptManager.java:88) at org.jbpm.pvm.internal.el.ScriptExpression.evaluateInScope(ScriptExpression.java:45) at org.jbpm.pvm.internal.el.Expression.evaluate(Expression.java:102) at org.jbpm.pvm.internal.expr.UelExpressionTest.testUelExpression(UelExpressionTest.java:56) Testcase: import org.jbpm.pvm.activities.WaitState; import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder; import org.jbpm.pvm.internal.el.Expression; import org.jbpm.pvm.internal.el.ScriptExpression; import org.jbpm.pvm.internal.el.UelValueExpression; import org.jbpm.pvm.internal.model.ExecutionImpl; import org.jbpm.test.JbpmTestCase; public class ExpressionTest extends JbpmTestCase { public void testUelExpression() { ExecutionImpl execution = (ExecutionImpl) ProcessDefinitionBuilder .startProcess() .startActivity("initial", new WaitState()) .initial() .endActivity() .endProcess() .startProcessInstance(); execution.setVariable("pv", "MyTest"); Expression expression = Expression.create("# {pv}", Expression.LANGUAGE_UEL_VALUE); UelValueExpression uve = ((UelValueExpression) expression); assertEquals("MyTest", uve.evaluate(execution)); Expression expression = Expression.create("#{pv} ", Expression.LANGUAGE_UEL); ScriptExpression se = ((ScriptExpression) expression); assertEquals("MyTest", se.evaluate(execution)); } } The first one (UEL_VALUE) works and the second (UEL) not. I cannot seem to find the reason why there is no scripting engine. The way the second expression is constructed is the same as is done for the description. So I tried changing this in the parser (UEL ->UEL_VALUE) and the description could be parsed to (full test of task with description is attached) Index: src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java =================================================================== — src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java (revision 6150) +++ src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java (working copy) @@ -493,7 +493,7 @@ Element descriptionElement = XmlUtil.element(element, "description"); if (descriptionElement!=null) { String descriptionText = XmlUtil.getContentText(descriptionElement); - Expression descriptionExpression = Expression.create(descriptionText, Expression.LANGUAGE_UEL); + Expression descriptionExpression = Expression.create(descriptionText, Expression.LANGUAGE_UEL_VALUE); assignableDefinition.setDescription(descriptionExpression); } Fixes the problem... Any ideas?

            'regression' since this worked in 3.x afaik

            Ronald van Kuijk (Inactive) added a comment - 'regression' since this worked in 3.x afaik

              rebody HuiSheng Xu (Inactive)
              bestage_jira henry donnell (Inactive)
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: