1 Reply Latest reply on Oct 9, 2012 10:32 PM by Thomas Setiabudi

    How to set a process to use drl rule just by using the drools-guvnor, web editor, and jbpm console?

    Thomas Setiabudi Expert

      Hi,

       

      I am using JBPM5.3 Full installer.

       

      Is it possible to create a process with a Business Process Task node that execute a drools rule (drl) without using the eclipse but just by using the drools-guvnor, web editor, and jbpm console?

       

      I refer to a discussion here:

      https://community.jboss.org/thread/167350

       

      It says we have to execute this script on a node prior to executing any rule

      kcontext.getKnowledgeRuntime().insert(kcontext.getProcessInstance());

       

      then on the rule itself looks to be something like this:

       

      import com.sample.User;

      import org.drools.runtime.process.WorkflowProcessInstance

       

      rule "AgeCheck3"

      ruleflow-group "AgeCheck"

       

       

          when

              processInstance : WorkflowProcessInstance()

              age: Integer() from (Integer)((WorkflowProcessInstance)processInstance).getVariable("Age");

              eval(age < 18);

          then

              processInstance.setVariable("Name", new String("Denied"));

              System.out.println(age);

              

      end

       

      The problem is I cannot figure out on how to specify import when I create a rule via drools guvnor. Is it even possible?

       

       

      And how do we trigger the fireAllRules or fireUntilHalt if we are not using eclipse?

       

       

      Any help is appreciated.

       

       

      Best Regards,

      Thomas Setiabudi

        • 1. Re: How to set a process to use drl rule just by using the drools-guvnor, web editor, and jbpm console?
          Thomas Setiabudi Expert

          Seems like I have to create a Technical Rule (DRL) inside the drools-guvnor,

          by doing it this way, i can specify my import line.

           

          And I manage to get my rule works without calling fireAllRules, maybe this is caused by my architecture where I use JBPM as service by managing the process via jbpm-console REST service instead of embedding the JBPM engine in my own application.

           

          my test rule that finally works looks like this:

           

          import org.drools.runtime.process.WorkflowProcessInstance

          rule "AlterName"
          ruleflow-group "ChangeName"

          when
          processInstance : WorkflowProcessInstance()
          eval(1 < 18);
          then
          processInstance.setVariable("name", "NewName");
          end