Check if a pattern binding exists in the RHS
by hatzlj
Hello everybody,
on the LHS of my rule i connect several Conditions with OR and have
different variable bindings for this Condition. Now - if any of this
conditions does not fire, i assume that the binding variable is not created,
so I can't access it in the RHS. This results in an null pointer exception
when I call the fireAllRules-Command in my Java Application.
A simple rule example:
rule "Rule 1"
when
HKT: Parameter(parameterCode = "HKT", value < normalFloor) or
GGT: Parameter(parameterCode = "GGT", value < normalFloor) or
HSR: Parameter(parameterCode = "HSR", value < normalFloor) and
GOT: Parameter(parameterCode = "GOT", value > normalFloor)
then
System.out.println(HKT.toString();
end
So my Question is: Is there any way to check in the RHS wheter the pattern
binding has been created or not or do i have to change the way of writing my
rules (which i do not want to)?
thanks,
hatzlj
--
View this message in context: http://www.nabble.com/Check-if-a-pattern-binding-exists-in-the-RHS-tp1903...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months
FROM and the working memory
by David Boaz
Hi all,
in the drools manual (6.5.28): "FROM allows the engine to reason over data
not in the working memory".
Will drools use rete to evaluate patterns with a FROM source?
Lets assume the following rule:
WHEN p:Person(age>60), Address(city="NY") FROM p.addresses
will the rule engine match the Address pattern using rete?
and, what about the following rule:
when p:Person(age="m"), Person(age>60) from p
1) will it work?
2) will the age constraint be matched using rete?
Thanks, David
--
View this message in context: http://www.nabble.com/FROM-and-the-working-memory-tp19020847p19020847.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months
How can I know from the drools*jar files what version of drools I'm using ?
by Maxim Veksler
Hello everyone,
I have recently stumbled upon a bug with Enum's that could possibly indicate
I'm using an old version of Drools3. How can I verify that exact version of
the jar files I have in my system? Alternatively, where can I download
previous versions of Drools so that I could md5sum the files until I find
the matching md5?
Thank you,
Maxim.
--
Cheers,
Maxim Veksler
"Free as in Freedom" - Do u GNU ?
16 years, 5 months
Creation of RuleFlows using API (Runtime)
by Vikram Shitole
Hi,
I have a requirement in which the rules /ruleflows needs to be created at runtime.
We have our own data structure which holds the data for creation of rules/rulesflows.
I have created the rules using the brms RuleModel.
Is there a similar API for RuleFlows ?
It will be helpful somebody give me the necessary pointers to start this.
Thanks in Advance
Thanks & Regards
Vikram Shitole
MASTEK LTD.
Making a valuable difference
Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 years, 5 months
Re: [rules-users] how to share functions between drl files ?
by psentosa
Write your function as a static function.
Both rules have to import this function just like importing class
By using BRMS you put your function as a function asset and any rule can
(from the same package) can use it
regards
Ady Bastian wrote:
>
> I have same functions that is used on two rule files (.drl), is it
> possible to
> share the functions without write it twice.. ?
>
> Example :
> -------------------
> file: rule1.drl
>
> rule "rule_on_file_1"
> when
> ....
> call_function();
> end
> --------------------
> file: rule2.drl
>
> rule "rule_on_file_2"
> when
> ....
> call_function();
> end
> ---------------------
>
> call_function is a drool function :
>
> function call_function() {
> ....
> }
>
--
View this message in context: http://www.nabble.com/how-to-share-functions-between-drl-files---tp189764...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 5 months
Runtime fact-set and rule-set separation
by Tomasz Krzywicki
Its actually resend from dev list as I was pointed out that topic
is rather about drools usage not new feature development.
Thats very promising ...
I am looking for some lightweight solution of fact sets separation
withing single working memory. ... I am possibly messing up with
terminology therefore please let me present an example.
I have set of facts
"Set 1" contains:
- Fact ( name==A, property==1)
- Fact ( name==B, property==2)
"Set 2" contains:
- Fact ( name==A, property==1)
- Fact ( name==C, property==2)
- I would like to execute my dedicated package of rules for
instance of "Set 1" within single working memory.
- When "Set 1" is inserted ( instantiated ) twice or more into the
working memory I would like to separate the scope of rules to
this particular instance
- I would like to insert "Set 2" at the same time multiple times
and execute separate set of rules dedicated for "Set 2" separately
on each of inserted instance of "Set 2"
- In some cases I would like to have access to facts from other
instances of different sets within same working memory. eg.:
- rule associated to "Set 1" checks all the occurrences of
Fact( name == A ) - means it could read state of Fact
from other instances of "Set 1" and "Set 2"
- rule associated to "Set 1" checks state of fact associated
to Fact ( name == A ) from "Set 2"
I could do it currently by
- adding extra fact indicating instance to working memory
- adding property to my Fact indicating origin ( instance in this case )
- altering each rule.
Example: reaching facts in particular instance
...
when:
Instance ( instanceId: id, name == "Set 1")
Fact ( ... , origin == instanceId )
...
then
( ... )
Example: reaching fact in multiple instances
...
when:
Fact (...)
...
then
Idea behind is very prosaic. Majority of the rules are written
in my case with single instance context in mind. Only sometimes
there is a need to look out of the "hedge".
So my example requires more typing and better specification
for *modeler* ( name of the role in my org - means person who
writes the rules ) who is using simpler single *model*
( set of rules + set of facts ).
I am trying to implement this using multiple, chained working
memories but maintenance of graph of working memories does
not look very practical for longer term and its not working
perfectly.
How could it be implemented - high level of course
Or better ... How I would like to use it :)
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage ( "Set1" , MyPackageForSet1 );
// 1st argument is context name, 2nd compiled rule package
WorkingMemory wm = ruleBase.newStatefulSession();
wm.insertInContext ( "Set1", new Fact (A,1) ) // this could be also
solved by implementing interface on the fact
// inserting instance and context pointer after fact creation
// and then inserting it to wm regular way.
than if there would be a need to reach fact from other
contexts I would specify it using something-like-this syntax
...
when
Fact ( ... ) // facts within same context and instance
*.Fact ( ... ) // facts from all facts sets (contexts)
<ContextName>.Fact ( ... ) // facts from all
// instances of specific context.
<ContextName>(*).Fact ( ...) // same as above
<ContextName>(1).Fact ( ...) // facts from specific
// instance of specific context.
Ok. What I am looking here.
- is something like this possible now out of the box and
I skipped this nice chapter in documentation?
- does it make sense from your point of view to implement this
kind of functionality. In my case it has lets say business
justification and will allow to implement really complex solutions in
nice way.
- Does this problem have some buzzwordish/scientifically blessed
name so I can express it better next time or maybe find something
interesting in mailing list archive.
(Changing subject to something more sufficient is more the welcomed )
- is it at all possible ;)
- what I am missing in this problem description?
And big thanks for reading it till the end.
tk.
16 years, 5 months
BRL in Guided Editor in Eclipse
by Dr. Irene Weber
Hi,
how to use the Drools Guided editor for authoring brl rules in Eclipse?
The manual says I should provide a (rule).package file with package name and import statements but that did not work for me.
Thanks for any hints!
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
16 years, 5 months
Re: [rules-users] How do I assign a local variable from a function call?
by Samuel Doyle
4.0.7
This works if I do $changedEventCodes : List( ) from SubmissionReviewRulesActionHelper.checkIfEventCodesExist(
submission, entityManager );
However, there might be something added to the function after the call for example in terms of a message passed to the end user. I don't want to have to depend on the
Java method to handle the formatting for rule. It should simply be concerned with returning the requested data.
One more thing I noticed that was odd to. For this particular rule I can't filter it out.
I have a .drl with 4 rules. If I do something like this:
this.workingMemory.fireAllRules( new RuleNameStartsWithAgendaFilter( "FIRST" ) );
This rule which is clearly starting with "SECOND" fires as well.
The other rules THIRD and FOURTH behave as expected and do not fire but this one still does. Could it be something to do with calling a static method?
----- Original Message ----
From: Mark Proctor <mproctor(a)codehaus.org>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Friday, August 15, 2008 2:48:17 PM
Subject: Re: [rules-users] How do I assign a local variable from a function call?
What version of drools you using? I think I remember some issue with
calling functions directly from a "from" - not sure if it was fixed for
4.0.7 or if is in the upcomfing 4.0.8.
Mark
Samuel Doyle wrote:
Yes here is the full thing.
function List doEventCodesExist( Submission submission, EntityManager
entityManager )
{
return SubmissionReviewRulesActionHelper.checkIfEventCodesExist(
submission, entityManager );
}
rule "SECOND Event Codes must not exist - EPC"
// 4(2)
when
$event: Event( );
$submission: Submission( );
$entityManager : EntityManager( );
$changedEventCodes : List( ) from doEventCodesExist(
$submission, $entityManager );
eval( $changedEventCodes.size() > 0 );
then
$event.addReviewIssue( new ReviewIssue( $event, $submission,
SubmissionReviewConstants.SUBMISSION,
ReviewCriticality.CRITICAL, SectionFiltersEnum.SUBMISSION,
$changedEventCodes + "
submissionReview.submission.eventCodesAlreadyExist" ) );
end
-----
Original Message ----
From: Mark Proctor <mproctor(a)codehaus.org>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Friday, August 15, 2008 1:29:16 PM
Subject: Re: [rules-users] How do I assign a local variable from a
function call?
Did you try adding types to your functions like the documentation says?
samd wrote:
Nobody knows?
samd wrote:
All I want to do is something simple like the following:
$changedList: java.util.List( ) from getChangedList( $x, $y );
Then in the same .drl file a function something like:
function List getChangedList( $x, $y )
{
return JavaClass.staticDoSomethingToGetListMethod( $x, $y);
}
I have tried doing this and I get:
Unable to build expression for 'from' node 'getChangedList( $x, $y)'
It looks like there is supposed to be something in between the from and
the function? I have been looking for examples for something like this and
have not found any.
Thanks
________________________________
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
16 years, 5 months
Re: [rules-users] How do I assign a local variable from a function call?
by Samuel Doyle
Yes here is the full thing.
function List doEventCodesExist( Submission submission, EntityManager entityManager )
{
return SubmissionReviewRulesActionHelper.checkIfEventCodesExist( submission, entityManager );
}
rule "SECOND Event Codes must not exist - EPC"
// 4(2)
when
$event: Event( );
$submission: Submission( );
$entityManager : EntityManager( );
$changedEventCodes : List( ) from doEventCodesExist( $submission, $entityManager );
eval( $changedEventCodes.size() > 0 );
then
$event.addReviewIssue( new ReviewIssue( $event, $submission, SubmissionReviewConstants.SUBMISSION,
ReviewCriticality.CRITICAL, SectionFiltersEnum.SUBMISSION,
$changedEventCodes + " submissionReview.submission.eventCodesAlreadyExist" ) );
end
----- Original Message ----
From: Mark Proctor <mproctor(a)codehaus.org>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Friday, August 15, 2008 1:29:16 PM
Subject: Re: [rules-users] How do I assign a local variable from a function call?
Did you try adding types to your functions like the documentation says?
samd wrote:
Nobody knows?
samd wrote:
All I want to do is something simple like the following:
$changedList: java.util.List( ) from getChangedList( $x, $y );
Then in the same .drl file a function something like:
function List getChangedList( $x, $y )
{
return JavaClass.staticDoSomethingToGetListMethod( $x, $y);
}
I have tried doing this and I get:
Unable to build expression for 'from' node 'getChangedList( $x, $y)'
It looks like there is supposed to be something in between the from and
the function? I have been looking for examples for something like this and
have not found any.
Thanks
16 years, 5 months