[rules-users] How to access process variables within a work-item (human task)

Robert robert.weissmann at web.de
Mon Apr 26 11:46:06 EDT 2010


Hi, thanks for the help, I got it somehow to work.

But its a little odd, since the doc says:

"You may specify additional parameters that are used to pass on input data  
to the process, using the startProcess(String processId, Map parameters)  
method, which takes an additional set of parameters as name-value pairs.  
These parameters are then copied to the newly created process instance as  
top-level variables of the process."

Which implies that it will automatically be copied over. And it does  
somehow, since I have access through the ProcessContext.getVariable(NAME)  
within actions. But do NOT have access on a work-item level and a simple  
mapping on work-item level will also not help:


... work-item-config ...
       <mapping type="in" from="dc" to="dc" />
       <mapping type="in" from="equipment" to="equipment" />
...

At this point, it is necessary what you have been descriping, I also had  
to add

   <header>
     <variables>
       <variable name="equipment" >
         <type  
name="org.drools.process.core.datatype.impl.type.StringDataType" />
         <value>Whatever</value>
       </variable>
       <variable name="dc" >
         <type  
name="org.drools.process.core.datatype.impl.type.UndefinedDataType" />
       </variable>
     </variables>
   </header>

I still do not understand why this is necessary for the work-item, and not  
for the actions, but I can life with it.

Thanks, cheers, Rob.



Am 26.04.2010, 15:41 Uhr, schrieb Mauricio Salatino <salaboy at gmail.com>:

> in the process designer select the background and you will see in the
> properties panel all the global process configurations. There you will  
> find
> variables, you need to register it all the variables that you will insert
> with its types.
> greetings
>
> On Mon, Apr 26, 2010 at 8:56 AM, Robert <robert.weissmann at web.de> wrote:
>
>> Hi,
>>
>> I don't understand what you mean ?
>>
>> I thought with
>>
>> ksession.startProcess(processName, processVariables);
>>
>> they are registered.
>>
>> Am 26.04.2010, 15:28 Uhr, schrieb Salaboy <salaboy at gmail.com>:
>>
>> > Did you register the equipement variable at process level? Mapping
>> > uses that definitions to know about the variables used across the
>> > processes.
>> > Greetings
>> >
>> > - Ing. Mauricio Salatino -
>> >
>> > On Apr 26, 2010, at 1:56, Robert <robert.weissmann at web.de> wrote:
>> >
>> >> Hi,
>> >>
>> >> I have
>> >>
>> >> ...
>> >>     StatefulKnowledgeSession
>> >> ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
>> >> taskHandler);
>> >> ...
>> >>
>> >>     Map<String, Object> processVariables = new HashMap<String,
>> >> Object>();
>> >>     processVariables.put("equipment", "OvenQP33");
>> >>
>> >>     ProcessInstance pi = ksession.startProcess(processName,
>> >> processVariables);
>> >> ...
>> >>
>> >> ... within the taskHandler.executeWorkItem(WorkItem workItem,
>> >> WorkItemManager workItemManager):
>> >>
>> >> I am setting a break-point, and I am getting there, but how am I
>> >> able to
>> >> access my processVariables or even set specific data for this
>> >> particular
>> >> work-item ?
>> >>
>> >> I tried using as described in the doc "9.1 Human tasks inside
>> >> processes":
>> >>
>> >>    - Parameter mapping: Allows copying the value of process
>> >> variables to
>> >> parameters of the human task. Upon creation of the human
>> >> tasks, the
>> >> values will be copied.
>> >>
>> >> But without any success. I just not getting to the "equipment"
>> >> variable,
>> >> which I need at this point of processing the work-item.
>> >>
>> >> The mapping I did: "equipment" -> "equipment". With the hope to find
>> >> them
>> >> within workItem.getParameters(), but they are not there and nowhere-
>> >> else
>> >> too.
>> >>
>> >> Any ideas ?
>> >>
>> >> Generally there are even many more settings possible for the human
>> >> task,
>> >> see doc (here the list:
>> >> Id,
>> >> Name,TaskName,Priority,Comment,ActorId,Skippable,Content,Swimlane,On-
>> >> entry
>> >> and on-exit actions,Parameter mapping,Result
>> >> mapping,Timers,ParentId), but
>> >> only a few are accessible through workItem.getParameters(). The
>> >> others ?
>> >> Also, no idea to get this data.
>> >>
>> >> Cheers, Rob.
>> >>
>> >>
>> >> --
>> >> Erstellt mit Operas revolutionärem E-Mail-Modul:
>> >> http://www.opera.com/mail
>> >> /
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users at lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >
>> > _______________________________________________
>> > rules-users mailing list
>> > rules-users at lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>> --
>> Erstellt mit Operas revolutionärem E-Mail-Modul:
>> http://www.opera.com/mail/
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>


-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/



More information about the rules-users mailing list