9 Replies Latest reply on Aug 7, 2006 12:30 PM by Michael Holtzman

    Task priority problem

    Guillem Gelabert Newbie

      I'm trying to set some priorities for my tasks in diferent task-nodes with the following jpdl file:

      <process-definition name="traspaso_propiedad">
       <start-state name="start">
       <transition to="nota_registro" />
       </start-state>
       <task-node name="nota_registro">
       <task name="recopilardatos.inmueble.registro" priority="1">
       <assignment class="com.okkum.arada.workflow.assignment.GenericAssign" />
       </task>
       <task name="solicitar.nota.registro" priority="1">
       <assignment class="com.okkum.arada.workflow.assignment.GenericAssign" />
       </task>
       <task name="recoger.nota.registro" priority="1">
       <assignment class="com.okkum.arada.workflow.assignment.GenericAssign" />
       </task>
       <transition to="firma_notario" />
       </task-node>
       <task-node name="firma_notario">
       <task name="entregar.escritura.notario" priority="1">
       <assignment class="com.okkum.arada.workflow.assignment.GenericAssign" />
       </task>
       <task name="recoger.escritura.notario" priority="2">
       <assignment class="com.okkum.arada.workflow.assignment.GenericAssign" />
       </task>
       <transition to="end" />
       </task-node>
       <end-state name="end">
       </end-state>
      </process-definition>
      

      But no matter the priority I set in the jpdl file, all Task instances get it's priority set to 3, the code I use to retrieve each task instance priority is this one:
       ProcessInstance processInstance = getProcessInstanceFromSession(session);
       Iterator itasks = processInstance.getTaskMgmtInstance().getTaskInstances().iterator();
       while (itasks.hasNext()){
       TaskInstance tempTask = (TaskInstance)itasks.next();
       if (logger.isDebugEnabled()){
       logger.debug("listTasks() - Tarea: " + tempTask.getName() + " Prioridad: " + tempTask.getPriority());
       }
       }
      

      And all I get is each task instance name (that's correct) but each one with priority set to 3. Any ideas?

        • 1. Re: Task priority problem
          Tom Baeyens Master

          http://jira.jboss.com/jira/browse/JBPM-325

          thanks for reporting. i'll have a look later. you can monitor progress in the issue.

          regards, tom.

          • 2. Re: Task priority problem
            Michael Holtzman Newbie

            The JIRA issue for this is marked as closed, but it is STILL a problem.
            (http://jira.jboss.com/jira/browse/JBPM-325)
            The priority assigned to the task in the process definition is not propagated to the task instance.

            If we look at the hibernate cfg for task ...

            <?xml version="1.0"?>
            
            <!DOCTYPE hibernate-mapping PUBLIC
             "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
             "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
            
            <hibernate-mapping default-access="field">
            
             <class name="org.jbpm.taskmgmt.def.Task"
             table="JBPM_TASK">
             <cache usage="nonstrict-read-write"/>
             <id name="id" column="ID_"><generator class="native" /></id>
            
             <!-- GRAPHELEMENT -->
             <property name="name" column="NAME_" />
             <many-to-one name="processDefinition"
             column="PROCESSDEFINITION_"
             foreign-key="FK_TASK_PROCDEF"/>
             <map name="events" cascade="all">
             <cache usage="nonstrict-read-write"/>
             <key column="TASK_" foreign-key="FK_EVENT_TASK" />
             <index column="EVENTTYPE_" type="string"/>
             <one-to-many class="org.jbpm.graph.def.Event" />
             </map>
             <list name="exceptionHandlers" cascade="all">
             <cache usage="nonstrict-read-write"/>
             <key column="TASK_" foreign-key="none" />
             <list-index column="GRAPHELEMENTINDEX_" />
             <one-to-many class="org.jbpm.graph.def.ExceptionHandler" />
             </list>
             <!-- ============ -->
            
             <property name="description" type="string_max" column="DESCRIPTION_" length="4000"/>
             <property name="isBlocking" column="ISBLOCKING_" />
             <property name="isSignalling" column="ISSIGNALLING_" />
             <property name="dueDate" column="DUEDATE_" />
             <property name="actorIdExpression" column="ACTORIDEXPRESSION_" />
             <property name="pooledActorsExpression" column="POOLEDACTORSEXPRESSION_" />
            
             <many-to-one name="taskMgmtDefinition"
             column="TASKMGMTDEFINITION_"
             foreign-key="FK_TASK_TASKMGTDEF"/>
             <many-to-one name="taskNode"
             column="TASKNODE_"
             foreign-key="FK_TASK_TASKNODE"/>
             <many-to-one name="startState"
             column="STARTSTATE_"
             foreign-key="FK_TASK_STARTST"/>
             <many-to-one name="assignmentDelegation"
             column="ASSIGNMENTDELEGATION_"
             foreign-key="FK_TASK_ASSDEL"
             cascade="all" />
             <many-to-one name="swimlane"
             column="SWIMLANE_"
             foreign-key="FK_TASK_SWIMLANE"/>
             <many-to-one name="taskController"
             column="TASKCONTROLLER_"
             foreign-key="FK_TSK_TSKCTRL"
             cascade="all" />
            
             </class>
            
            </hibernate-mapping>
            


            ... there is no property for PRIORITY. When a task instance is spawned from the task, it always gets the default priority of "3".

            • 3. Re: Task priority problem
              Ronald van Kuijk Master

              hmm.. the testcase itself does probably not use persistency, so it works as long as persistency is not involved. I reopend this issue. Lets see what Tom thinks about it. What version of jBPM are you using btw?

              • 4. Re: Task priority problem
                Michael Holtzman Newbie

                Currently using 3.1, but I hope to migrate to 3.1.2 in the next few weeks.

                • 5. Re: Task priority problem
                  Ronald van Kuijk Master

                  hmm..... I looked into this a little and came to the conclusion (should have seen that directly) that your hbm file is for the the task in the process definition, org.jbpm.taskmgmt.def.Task. Task instances are in org.jbpm.taskmgmt.exe.TaskInstance. The accompanying hbm file contains the priority, at least it does in the 3.1.2 branche. It does not mean it is no bug, but it could be I reopened the issus to quick.

                  There are some testcases for this, could you create a unit test WITH db?

                  • 6. Re: Task priority problem
                    Ronald van Kuijk Master

                    and I read again, and see that you indeed mention the PD, not PI, so sorry.

                    So it seams right. You can set it designtime in the PD but it is not stored in the db. Setting it runtime does work?

                    • 7. Re: Task priority problem
                      Michael Holtzman Newbie

                      Yes, setting it at run time does work.

                      I am working around the problem by setting the priority that I need in the task assignment handler.

                      However, having the priority correctly assigned when the task instance is created would be "nicer".

                      • 8. Re: Task priority problem
                        Ronald van Kuijk Master

                        setting it runtime also persists it, right?