Re: [rules-users] use rule assign actor
thank you for your answer.I look at the source code of Drools ,if want the "assignment rule" to take effect, must add the following code in drools configuration file : *drools.advancedProcessRuleIntegration = true* 2010/5/21 Esteban Aliverti > 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 > > *I paste all information here : >> >> HelloWorldSample.rf * : >> >> >> http://drools.org/drools-5.0/process"; >> xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"; >> >> xs:schemaLocation="http://drools.org/drools-5.0/processdrools-processes-5.0.xsd"; >> type="RuleFlow" name="flow" id="com.sample.evaluation" >> package-name="org.drools.bpmn2" > >> >> >> >> >> >> >>> height="40" > >> >> >> > name="org.drools.process.core.datatype.impl.type.StringDataType" /> >> >> >> >> > name="org.drools.process.core.datatype.impl.type.StringDataType" /> >> You need to perform a self-evaluation >> >> >> > name="org.drools.process.core.datatype.impl.type.StringDataType" /> >> >> >> > name="org.drools.process.core.datatype.impl.type.StringDataType" /> >> >> >> > name="org.drools.process.core.datatype.impl.type.StringDataType" /> >> false >> >> >> > name="org.drools.process.core.datatype.impl.type.StringDataType" /> >> firstHumanTask >> >> >> >> >> >> >> >> >> >> >> >> >> >> *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 >> then >> Set actor id "mary" >> end >> >> >> *assignment.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 component >> startHumanTaskComponent(); >> // load up the knowledge base >> KnowledgeBase kbase = readKnowledgeBase(); >> StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); >> KnowledgeRuntimeLogger logger = >> KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test"); >> ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new >> WSHumanTaskHandler()); >> // start a new process instance >> Map params = new HashMap(); >> 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); >>
Re: [rules-users] use rule assign actor
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 > *I paste all information here : > > HelloWorldSample.rf * : > > > http://drools.org/drools-5.0/process"; > xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"; > > xs:schemaLocation="http://drools.org/drools-5.0/processdrools-processes-5.0.xsd"; > type="RuleFlow" name="flow" id="com.sample.evaluation" > package-name="org.drools.bpmn2" > > > > > > > > height="40" > > > > name="org.drools.process.core.datatype.impl.type.StringDataType" /> > > > > name="org.drools.process.core.datatype.impl.type.StringDataType" /> > You need to perform a self-evaluation > > > name="org.drools.process.core.datatype.impl.type.StringDataType" /> > > > name="org.drools.process.core.datatype.impl.type.StringDataType" /> > > > name="org.drools.process.core.datatype.impl.type.StringDataType" /> > false > > > name="org.drools.process.core.datatype.impl.type.StringDataType" /> > firstHumanTask > > > > > > > > > > > > > > *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 > then > Set actor id "mary" > end > > > *assignment.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 component > startHumanTaskComponent(); > // load up the knowledge base > KnowledgeBase kbase = readKnowledgeBase(); > StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); > KnowledgeRuntimeLogger logger = > KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test"); > ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new > WSHumanTaskHandler()); > // start a new process instance > Map params = new HashMap(); > 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"); > Ta
Re: [rules-users] use rule assign actor
*I paste all information here : HelloWorldSample.rf * : http://drools.org/drools-5.0/process"; xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"; xs:schemaLocation="http://drools.org/drools-5.0/processdrools-processes-5.0.xsd"; type="RuleFlow" name="flow" id="com.sample.evaluation" package-name="org.drools.bpmn2" > You need to perform a self-evaluation false firstHumanTask *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 then Set actor id "mary" end *assignment.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 component startHumanTaskComponent(); // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test"); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler()); // start a new process instance Map params = new HashMap(); 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 : > 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 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.newClassPathResou
Re: [rules-users] use rule assign actor
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 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 > -- Esteban Aliverti ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] use rule assign actor
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