cancel
Showing results for 
Search instead for 
Did you mean: 

how to set the task priority on the bpmn20.xml

luisalves00
Champ in-the-making
Champ in-the-making
This is a simple thing but I can't find it anywhere.

programmatically:
 
org.activiti.engine.task
       -> setPriority()
9 REPLIES 9

frederikherema1
Star Contributor
Star Contributor
Nothing is available at the moment to specify the priority on the task-definition. Can you create a jira task for this feature?

luisalves00
Champ in-the-making
Champ in-the-making
here:  http://jira.codehaus.org/browse/ACT-797

so how it's done at this point?

frederikherema1
Star Contributor
Star Contributor
Best solution I can think of is using a TaskListener and field-injection to set the priority in your definition, eg:
(don't mind the syntax, just from the top of my head)

<userTask id="task1" name="My task" >
  <extensionElements>
    <activiti:taskListener event="create" class="org.activiti.SetPriorityTaskListener">
       <activiti:field name="priority" stringValue="1234" />
    </activiti:taskListener>
  </extensionElements>
</userTask>


public class SetPriorityTaskListener implements TaskListener {
 
  public Expression priority;

  public void notify(DelegateTask delegateTask) {
    delegateTask.setPriority((String)Integer.valueOf(priority.getValue(delegateTask)));
  }

  // get and set priority
}

luisalves00
Champ in-the-making
Champ in-the-making
a little bit of hard work for a simple thing…but thanks frederikheremans, I'll do it this way Smiley Happy

frederikherema1
Star Contributor
Star Contributor
That's the only workaround I could think of. You're always free to submit a patch for the issue you reported… Smiley Wink

frederikherema1
Star Contributor
Star Contributor
Does it work with a single task? AFAIK, tasklisteners are called on each instance…

luisalves00
Champ in-the-making
Champ in-the-making
it works for all cases so far…tks

walterjs
Champ in-the-making
Champ in-the-making
There is a slightly easier way to achieve the same thing until this is fixed. Add the following listener to the task elements:

<extensionElements>
    <activiti:taskListener event="create" expression="#{task.setPriority(100)}"></activiti:taskListener>
</extensionElements>

luisalves00
Champ in-the-making
Champ in-the-making
tks WalterJS…didn't try it yet…but its a lot lot easier solution