Thanks for the explanation!
I've found the CR1 downloads, I've just tried it, and it works just as I
needed :).
Just one comment. In my first attempts I missed your comment about using a
variable with the specific name "processInstance"... I'm "slower"
than I
thought... But, just as a suggestion, it may be better to have a clearer way
to use this special matching. Maybe using a fact property or a keyword... ?
Well, I don't know anything about the ruleflow project and its complexity so
take my suggestion as it is :).
Well, thanks again for the help and congratulations for your impressive
work!
Ricardo.
2009/3/9 Kris Verlaenen <kris.verlaenen(a)cs.kuleuven.be>
Ricardo,
This method has recently been added into WorkflowProcessInstance, it is on
trunk and will be in CR1. For M5, you could indeed use
WorkflowProcessInstanceImpl ...
Kris
----- Original Message -----
*From:* Ricardo Gil Alcañiz <rgil(a)okode.com>
*To:* Rules Users List <rules-users(a)lists.jboss.org>
*Sent:* Monday, March 09, 2009 4:37 PM
*Subject:* [rules-users] Re: rules-users Digest, Vol 28, Issue 19
Thanks for your fast response Kris and Michal!
I tried to use your solution Kris, but I've found that 5.0.0 M5
WorkflowProcessInstance does not seems to provide getVariable method. I've
found that method into WorkflowProcessInstanceImpl searching in svn trunk. I
must work with that class or I missed something? Thanks again!
Ricardo.
> ---------- Mensaje reenviado ----------
> From: Kris Verlaenen <Kris.Verlaenen(a)cs.kuleuven.be>
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Date: Sun, 8 Mar 2009 03:56:29 +0100
> Subject: Re: [rules-users] Drools Flow, constraint parametrization
> Ricardo,
>
> If you need to access process variables and have only simple constraint
> expressions, I suggest you use code constraints (Java or MVEL dialect),
> as they have direct access to variables (and globals).
>
> If you want to use rule constraints anyway (because your constraints can
> become rather complex), there are a few options:
>
> - You cannot use globals to pass information used in your constraints,
> because globals are considered immutable with respect to rule conditions
>
> - You can put your data you want to access in your working memory.
> Rule constraints can then access this info just like any normal rule.
>
> - You access the variable value using the special "processInstance"
> rule constraint (I just added a new section in the documentation to
> explain):
>
> Rule constraints do not have direct access to variables defined inside
> the process. It is however possible to refer to the current process
> instance inside a rule constraint, by adding the process instance to the
> working memory and matching to the process instance inside your rule
> constraint. We have added special logic to make sure that a variable
> "processInstance" of type WorkflowProcessInstance will only match to the
> current process instance and not to other process instances in the
> working memory. Note that you are however responsible yourself to insert
> (and possibly update) the process instance into the session (for example
> using Java code or an (on-entry or on-exit or explicit) action in your
> process). The following exampleof a rule constraint will search for a
> person with the same name as the value stored in the variable "name" of
> the process:
>
> processInstance: WorkflowProcessInstance()
> Person( name == ( processInstance.getVariable("name") ) )
> # add more constraints here ...
>
> Kris
>
> Quoting Ricardo Gil Alcañiz <rgil(a)okode.com>:
>
> > Hi,
> >
> > I'm not a new drools user but I started to test rule flows (5.0M5)
> > recently
> > and I'm stucked, so any clue will be welcomed :). I'm testing how to
> > share a
> > StatefulKnowledgeSession between N rule flow instances. I'm trying
> > to
> > parametrize each instance with process variables at start time but I
> > don't
> > know how to use them from rule constraints (in event waits, splits,
> > etc.).
> > I've read the documentation and I've found this text related to
> > constraints
> > "Both rule and code constraints have access to globals that are
> > defined for
> > the process and can reuse imports at the process level." I tried it
> > assigning (from an action) a variable value to a global variable but
> > it's
> > not working for me. ¿I'm missing something?
> >
> > Thanks in advance!
> >
> > Ricardo.
> >
>
------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users