cancel
Showing results for 
Search instead for 
Did you mean: 

Is the task controller working at all ?

rand
Champ in-the-making
Champ in-the-making
Hi there, here's my problem :

I am trying to determine if the task controller has any effect ('cause I've been having the feeling it has none for some time now). To do that, I've created a very simple task model and a test workflow.

workflow :
[size=75]
(…)
   <start-state name="Start">
      <task name="ecm:Task1" swimlane="initiator">
         <controller>
            <variable name="ecm:1" access="read,write,required" mapped-name="ecm:m11"/>
            <variable name="ecm:2" access="read" mapped-name="ecm:m12"/>
            <variable name="ecm:3" access="write" mapped-name="ecm:m13"/>
         </controller>
      </task>
      <transition name="" to="Node2"></transition>
   </start-state>

   <task-node name="Node2">
      <task name="ecm:Task2" swimlane="initiator">
         <controller>
            <variable name="ecm:1" access="read,write,required" mapped-name="ecm:m21"/>
            <variable name="ecm:2" access="read,write" mapped-name="ecm:m22"/>
            <variable name="ecm:3" access="read" mapped-name="ecm:m23"/>
         </controller>
      </task>
      <transition name="" to="end"></transition>
   </task-node>
(…)
[/size]

task model :
[size=75]
(…)
   <type name="ecm:Task1">
      <parent>bpm:startTask</parent>
        <properties>
           <property name="ecm:m11">
               <type>d:int</type>
            </property>
            <property name="ecm:m12">
               <type>d:int</type>
            </property>
            <property name="ecm:m13">
               <type>d:int</type>
            </property>
         </properties>
   </type>

   <type name="ecm:Task2">
      <parent>bpm:workflowTask</parent>
        <properties>
         <property name="ecm:m21">
               <type>d:int</type>
            </property>
            <property name="ecm:m22">
               <type>d:int</type>
            </property>
            <property name="ecm:m23">
               <type>d:int</type>
            </property>
         </properties>            
   </type>
(…)
[/size]

web-client-config-custom :
[size=75]
(…)
   <config evaluator="node-type" condition="ecm:Task2" replace="true">
      <property-sheet>
         <show-property name="ecm:m11" />
         <show-property name="ecm:m12" />
         <show-property name="ecm:m13" />
         </property-sheet>
   </config>
   
   <config evaluator="node-type" condition="ecm:Task2" replace="true">
      <property-sheet>
         <show-property name="ecm:m21" />
         <show-property name="ecm:m22" />
         <show-property name="ecm:m23" />
         </property-sheet>
   </config>
(…)
[/size]

When I test this, everything works fine as far as swimlanes and transitions are concerned, but :
- the m11 property isn't mandatory (neither in the first task nor in the second)
- in the second task, all fields are empty whereas m21 and m22 should have the values entered in the first task

Am I doing something wrong ?

Some time ago I avoided these problems by using the <mandatory> option in the task model, and the read-only="true" in the web-client-config.
Since properties with identical names in different task types are forbidden, I had defined one "base task type" of which every task in my workflow was a child.
This way, property values were passed from a task to the following without using the controller. However, it required that every task be a child from bpm:startTask, and mandatory properties were required in every task, even when the were read-only.

I guess this last part must not be very clear, but the important thing is, I know workarounds for this problem. However, using the controller would be much more simple and "clean".

Don't hesitate to ask for details, and thanks for any help you choose to offer.

Rand
3 REPLIES 3

davidc
Star Contributor
Star Contributor
Hi Rand,

Task controllers within Alfresco are no different to task controllers in any other JBoss jBPM application.

There's one issue in your process definition.  The variables names are incorrectly referenced - the :'s should be replaced with _'s.

e.g.

<variable name="ecm_2" access="read" mapped-name="ecm_m12"/> 

Unfortunately, not all aspects of jPDL (i.e. scripting/expressions) support : in a name.

The model definition etc should continue to use :.

the m11 property isn't mandatory (neither in the first task nor in the second)

I'll check this one.

Since properties with identical names in different task types are forbidden, I had defined one "base task type" of which every task in my workflow was a child.

To get around this, define an aspect for the common properties across all tasks.  Then, for each task type, define the aspect as mandatory (using the <mandatory-aspect> element in the content model).  That way, you don't have to derive from a common task type (e.g. the start task, in your case).

I would use the model to declare mandatory properties.  The web-client etc will honour the model.

rand
Champ in-the-making
Champ in-the-making
Thanks a lot David, your reply should help me greatly.

the m11 property isn't mandatory (neither in the first task nor in the second)

I'll check this one.

I haven't had time to test again with the correct controller format ( _ instead of : ), but I guess the only reason properties weren't mandatory was that they weren't correctly mapped to the model.

Thanks for the aspects tip as well, with that and the controller I should be able to do everything I want.

Rand

rand
Champ in-the-making
Champ in-the-making
I may have spoken a little too quickly about the "required" attribute.

Now that I've fixed the mapping format, the "read" and "write" attributes work perfectly, but "required" doesn't seem to have any effect.

So I guess it's an issue to add to the JIRA, even though it's not so bad, as one can easily get around this with mandatory properties or aspects in the model.

Rand