I don't really know whether your rule will be activated or not, but you are missing the ksession.fireAllRules() call. Try to add a Logger to your session to see if the rule gets activated or not.Best,
2010/5/19 HONG DENG <denghongster@gmail.com>
I paste all information here :
HelloWorldSample.rf :
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
type="RuleFlow" name="flow" id="com.sample.evaluation" package-name="org.drools.bpmn2" >
<header>
</header>
<nodes>
<start id="1" name="Start" x="44" y="139" width="48" height="48" />
<humanTask id="2" name="thefirstone" x="156" y="140" width="80" height="40" >
<work name="Human Task" >
<parameter name="ActorId" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value></value>
</parameter>
<parameter name="Comment" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>You need to perform a self-evaluation</value>
</parameter>
<parameter name="Content" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Priority" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
</parameter>
<parameter name="Skippable" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>false</value>
</parameter>
<parameter name="TaskName" >
<type name="org.drools.process.core.datatype.impl.type.StringDataType" />
<value>firstHumanTask</value>
</parameter>
</work>
</humanTask>
<end id="3" name="End" x="290" y="140" width="80" height="40" />
</nodes>
<connections>
<connection from="1" to="2" />
<connection from="2" to="3" />
</connections>
</process>
assignment.dslr:
package org.drools.examples.process.order
import org.drools.process.instance.impl.WorkItemImpl
import org.drools.workflow.instance.node.WorkItemNodeInstance
expander assignment.dsl
/********** Generic assignment rules **********/
rule "Assign actor" salience 30
when
There is a human task
thenSet actor id "mary"
endassignment.dsl:[condition][HumanTaskWorkItem]- with actor id "{actorId}"=parameters['ActorId'] == "{actorId}"[condition][HumanTaskWorkItem]- without actor id=parameters['ActorId'] == null[condition][HumanTaskWorkItem]- with task name "{taskName}"=parameters['TaskName'] == "{taskName}"[condition][HumanTaskWorkItem]There is a human task=workItemNodeInstance: WorkItemNodeInstance( ) workItem: WorkItemImpl( name == "Human Task" ) from workItemNodeInstance.workItem[consequence][]Set actor id "{actorId}"=workItem.setParameter("ActorId", "{actorId}"); update(workItemNodeInstance);[condition][HumanTaskWorkItem]- with priority {priority}=parameters['Priority'] == {priority}[condition][HumanTaskWorkItem]Process "{processId}" contains a human task=workItemNodeInstance: WorkItemNodeInstance( processInstance.processId == "{processId}" ) workItem: WorkItemImpl( name == "Human Task" ) from workItemNodeInstance.workItem
and have following code to start a process instance:package com.sample;/*** This is a sample file to launch a process.*/public class ProcessTest {public static final void main(String[] args) {try {//start humantask componentstartHumanTaskComponent();// load up the knowledge baseKnowledgeBase kbase = readKnowledgeBase();StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());// start a new process instanceMap<String, Object> params = new HashMap<String, Object>();params.put("employee", "Administrator");ksession.startProcess("com.sample.evaluation", params);} catch (Throwable t) {t.printStackTrace();}}private static KnowledgeBase readKnowledgeBase() throws Exception {KnowledgeBuilderConfiguration conf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();// ((PackageBuilderConfiguration) conf).initSemanticModules();// ((PackageBuilderConfiguration) conf).loadSemanticModule("BPMN2SemanticModule.conf");KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(conf);// kbuilder.add(ResourceFactory.newClassPathResource("hellowWorld.bpmn"), ResourceType.DRF);kbuilder.add(ResourceFactory.newClassPathResource("HelloWorldSample.rf"), ResourceType.DRF);kbuilder.add(ResourceFactory.newClassPathResource("assignment.dsl"), ResourceType.DSL);kbuilder.add(ResourceFactory.newClassPathResource("assignment.dslr"), ResourceType.DSLR);KnowledgeBuilderErrors errors = kbuilder.getErrors();if (errors.size() > 0) {for (KnowledgeBuilderError error: errors) {System.err.println(error);}throw new IllegalArgumentException("Could not parse knowledge.");}KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());return kbase;}private static void startHumanTaskComponent(){EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.drools.task");TaskService taskService = new TaskService(emf,SystemEventListenerFactory.getSystemEventListener());User a = new User("john");User b = new User("mary");TaskServiceSession taskSession = taskService.createSession();taskSession.addUser(new User("Administrator"));taskSession.addUser(a);taskSession.addUser(b);MinaTaskServer server = new MinaTaskServer( taskService );Thread thread = new Thread( server );thread.start();}}
2010/5/19 Esteban Aliverti <esteban.aliverti@gmail.com>:
> A good start could be to give us more info, like your rules, your flow and
> how are you executing them. ;)
> Best,
>
> On Wed, May 19, 2010 at 6:39 AM, HONG DENG <denghongster@gmail.com> wrote:
>>
>> hi , i am a drools flow newbie.I want to using "assignment rule"
>> assign a actor to a HumanTask. I have write a dsl and dslr files and
>> following code :
>>
>>
>> kbuilder.add(ResourceFactory.newClassPathResource("HelloWorldSample.rf"),
>> ResourceType.DRF);
>> kbuilder.add(ResourceFactory.newClassPathResource("assignment.dsl"),
>> ResourceType.DSL);
>> kbuilder.add(ResourceFactory.newClassPathResource("assignment.dslr"),
>> ResourceType.DSLR);
>>
>> but when i start a process instance and the token arrive at a
>> humantask,the "assignment rule" couldn't be firing.
>> who can tell me how can i do it?
>> _______________________________________________
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users