Re: [rules-users] calling function defined in .drl file from ruleflow

2011-11-23 Thread xdyl
now i try import the model i declared in drl file use package.


it works for me .


maybe the model must have a package.

--
View this message in context: 
http://drools.46999.n3.nabble.com/calling-function-defined-in-drl-file-from-ruleflow-tp3525538p3532717.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor cluster problems

2011-11-23 Thread jayadev
I use database as the store for assets. I was thinking of asking DBA's to
just wipe out all the tables and then re-import. I am assuming the export is
healthy because when I imported it into a test environment it worked well. 

I am not too concerned about getting things back up. I am more concerned
about how did they ever get out of sync. Why did they get out of sync!!??
Shouldn't there be a warning or something so that users know about the
possible sync issues. Is there a way to find out which assets add/update
didnt make it to journal?

--
View this message in context: 
http://drools.46999.n3.nabble.com/Guvnor-cluster-problems-tp3528970p3532152.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] multi-factor rule

2011-11-23 Thread Welsh, Armand
Sorry to repost again  But I also realized after sending that if you have 
to exclude locations A, B, and C from the else rule, then you do not need 
salience, nor activation group, since all the rules are not mutually 
exclusive..  This this (much easier too now)


rule 'Rule One'

when

Person (location == 'A',  age > 60 )

Then

do_something();

end



rule 'Rule Two'

when

Person (location == 'B',  age > 70 )

Then

do_something();

end



rule 'Rule Three'

when

Person (location == 'C',  age > 80 )

Then

do_something();

end



rule 'Rule Else'

when

Person (location not in ('A','B','C'), age > 65 )

Then

do_something();

end


--Armand

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Welsh, Armand
Sent: Wednesday, November 23, 2011 12:50 PM
To: Rules Users List
Subject: Re: [rules-users] multi-factor rule

Oh... I misread the pseudo code.  I missed that the if (age>60) is inside the 
if(location=="A") rule. This is easy enough to fix.  It's would essentially be 
the same thing as the otherwise, but in DRL:


rule 'Rule One'

activation-group 'age-test'

salience 300

when

Person (location == 'A',  age > 60 )

Then

do_something();

end



rule 'Rule Two'

activation-group 'age-test'

salience 200

when

Person (location == 'B',  age > 70 )

Then

do_something();

end



rule 'Rule Three'

activation-group 'age-test'

salience 100

when

Person (location == 'C',  age > 80 )

Then

do_something();

end



rule 'Rule Else'

activation-group 'age-test'

when

Person (location not in ('A','B','C'), age > 65 )

Then

do_something();

end


This is a good example why it can be difficult to model rules from procedural 
language.  With a rule, you are reacting to a given condition, but with 
procedural language waterfall logic, you automatically exclude conditions as 
you fall through the logic.  With rules, there is not waterfall effect.  You 
have to simulate the waterfall logic with explicit exclusions.

This is best represented with a lot of if() but no else clauses in procedural 
language logic.

Not the only rule I modified to make this work was my else rule.

Regards,
Armand

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ronald Albury
Sent: Wednesday, November 23, 2011 11:22 AM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] multi-factor rule

Armand

I don't think that works if location=='B' and age=68

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] multi-factor rule

2011-11-23 Thread Welsh, Armand
Oh... I misread the pseudo code.  I missed that the if (age>60) is inside the 
if(location=="A") rule. This is easy enough to fix.  It's would essentially be 
the same thing as the otherwise, but in DRL:


rule 'Rule One'

activation-group 'age-test'

salience 300

when

Person (location == 'A',  age > 60 )

Then

do_something();

end



rule 'Rule Two'

activation-group 'age-test'

salience 200

when

Person (location == 'B',  age > 70 )

Then

do_something();

end



rule 'Rule Three'

activation-group 'age-test'

salience 100

when

Person (location == 'C',  age > 80 )

Then

do_something();

end



rule 'Rule Else'

activation-group 'age-test'

when

Person (location not in ('A','B','C'), age > 65 )

Then

do_something();

end


This is a good example why it can be difficult to model rules from procedural 
language.  With a rule, you are reacting to a given condition, but with 
procedural language waterfall logic, you automatically exclude conditions as 
you fall through the logic.  With rules, there is not waterfall effect.  You 
have to simulate the waterfall logic with explicit exclusions.

This is best represented with a lot of if() but no else clauses in procedural 
language logic.

Not the only rule I modified to make this work was my else rule.

Regards,
Armand

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ronald Albury
Sent: Wednesday, November 23, 2011 11:22 AM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] multi-factor rule

Armand

I don't think that works if location=='B' and age=68

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor cluster problems

2011-11-23 Thread Welsh, Armand
If you know that your export is good, then you could backup the directory that 
contains your guvnor repository (rename it) while guvnor is off-line.

Then start guvnor with an empty repository -- this will force guvnor to 
initialize the repository.  

Next simply launch Guvnor, and import your repository.

Again, backup your existing repository so you don't lose anything. And this 
requires that your exported repository is in fact healthy.

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of jayadev
Sent: Wednesday, November 23, 2011 9:38 AM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Guvnor cluster problems

And it wont allow me to re-import the whole repository! How can I fix it?!

ERROR 23-11 10:21:30,264
(RulesRepositoryAdministrator.java:clearRulesRepository:96)  Unable to
clear rules repository.
javax.jcr.ReferentialIntegrityException:
98096f69-7629-4083-95e7-73402a6f511e: the node cannot be removed because it is 
still being referenced.
at
org.apache.jackrabbit.core.state.SharedItemStateManager$Update.checkReferentialIntegrity(SharedItemStateManager.java:1039)
at
org.apache.jackrabbit.core.state.SharedItemStateManager$Update.begin(SharedItemStateManager.java:574)
at
org.apache.jackrabbit.core.state.SharedItemStateManager.beginUpdate(SharedItemStateManager.java:1110)
at
org.apache.jackrabbit.core.state.SharedItemStateManager.update(SharedItemStateManager.java:1140)
at
org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:351)
at
org.apache.jackrabbit.core.state.XAItemStateManager.update(XAItemStateManager.java:354)
at
org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:326)
at
org.apache.jackrabbit.core.state.SessionItemStateManager.update(SessionItemStateManager.java:328)
at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1141)
at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:920)
at
org.drools.repository.RulesRepositoryAdministrator.clearRulesRepository(RulesRepositoryAdministrator.java:87)
at
org.drools.repository.RulesRepository.importRulesRepositoryFromStream(RulesRepository.java:1058)
at
org.drools.guvnor.server.files.FileManagerUtils.importRulesRepository(FileManagerUtils.java:271)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:157)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
at
org.drools.guvnor.server.files.FileManagerUtils_$$_javassist_9.importRulesRepository(FileManagerUtils_$$_javassist_9.java)
at
org.drools.guvnor.server.files.RepositoryBackupServlet.processImportRepository(RepositoryBackupServlet.java:134)
at
org.drools.guvnor.server.files.RepositoryBackupServlet.access$100(RepositoryBackupServlet.java:42)
at
org.drools.guvnor.server.files.RepositoryBackupServlet$1.a(RepositoryBackupServlet.java:71)
at
org.drools.guvnor.server.files.RepositoryServlet.doAuthorizedAction(RepositoryServlet.java:97)
at
org.drools.guvnor.server.files.RepositoryBackupServlet.doPost(RepositoryBackupServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterCh

Re: [rules-users] multi-factor rule

2011-11-23 Thread Andreas Schlüter
Hi,

you might try something like one of the following two variants:


a) Checking for Location only first, inserting a Fact for the respective
location and doing a second rule for each location that checks for this fact
and the age (using salience to ensure only one rule fires and this in the
correct order).
In this case, exactly one of the rules without the additional facts will
fire:
 - if it is one of the first three, it will fire first,  then after that the
rule with the additional fact will fire and give the correct result
- else, your "else" rule fires right away.


b) using different agenda-groups for the different locations and setting
focus to the location-specific agenda-group in a first step. If I get it
correctly (I am a newbie too and don't have the time to try it out), this
should work.


True, you have two rules for each location, but I find this acceptable:
- Rules should be simple and (close to) declarative
- If I read your requirements correctly, you typically filter on location,
so in the long run, there will be location-specific agenda-groups anyway if
you build a complete rule base.

Variant B could look like this:

rule "Rule One"
activation-group "CheckLocation"
salience 300
when
Person(location == "A" )
Then
drools.setFocus("Location-A");
end

rule "Location A: age>60"
agenda-group 'Location-A'
when
 Person(age>60)
then
  do_something();
end

rule "Rule Two"
activation-group "CheckLocation"
salience 200
when
Person(location == "B" )
Then
drools.setFocus("Location-B");
end

rule "Location B: age>70"
agenda-group "Location-B"
when
 Person(age>70)
then
  do_something();
end

rule "Rule Three"
activation-group "CheckLocation"
salience 100
when
Person(location == "C" )
Then
drools.setFocus("Location-C");
end

rule "Location C: age>80"
agenda-group "Location-C"
when
 Person(age>80)
then
  do_something();
end


rule 'Rule Else'
activation-group "CheckLocation"
salience 0
when
Person (age > 65 )
Then
do_something();
end


--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-multi-factor-rule-tp3531130p3531860.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] multi-factor rule

2011-11-23 Thread Ronald Albury
Armand

I don't think that works if location=='B' and age=68
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Multiple Insert and negative rule

2011-11-23 Thread Welsh, Armand
As an aside note.  You may want to consider re-working your rules to never use 
the || condition.  

It's not that this is inherently bad, but that the any logical ORs mean that 
you are actually representing more than one rule within the singular rule.  
This can make mapping the logic to the rules difficult in the future.

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of FrankVhh
Sent: Wednesday, November 23, 2011 8:05 AM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Multiple Insert and negative rule

rule "test2"
salience 5
 when
  not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) ||
(system == "anyHost" && message matches ".*Hello.*")))   
 then
  System.out.println(" No strange message  :-) "); end

Hi,

Probably it is because you are using NOT (). The engine will not fire this rule 
for every event in the WM. 

Consider changing from 
not ( Event( system == "any" ) ) to 
Event( system != "any" )

That will force the engine to execute it for each Event in memory.

Regards,
Frank


annam2011 wrote
> 
> Hello,
> I'm a newbie to drools.
> I would like to know why i get the following output on the console : 
> 
> Test Message found!!
> No strange message  :-)
> Test Message found!! 
> Test Message found!!
> 
> NotifyEngineTest.java creates 10 events. Rule "test2" should be 
> activated with every event, so that the output should look like this:
> 
> Test Message found!!
> No strange message  :-)
> Test Message found!!
> No strange message  :-)
> Test Message found!!
> No strange message  :-)
> 
> Could somebody help me with this ? 
> I appriciate your help
> Thanks in advance,
> Anna
> 
> // NotifyEngineTest.java//
> 
> for (int i = 0; i < 10; i++){
> 
>Event e = new Event();
>e.setId("ID"+Math.random());
>e.setTimestamp(new Date());
>e.setCatagory("TEST");
>e.setMessage( i + " Test");
>e.setSystem("localhost");
> 
>  ruleEngine.insert(e);
> _   
> // RuleEngine.java//
>  public void insert(Event e) throws RuleEngineException  {
>   FactHandle factHandle = ksession.insert(e);  int numberOfRules = 
> ksession.fireAllRules();  logger.debug("Rules fired: "+numberOfRules);  
> } 
> __
> // Notify.drl//
> rule "test"
>  salience 10
>  when
>   $r: Event(message  matches ".*Test.*")   
>  then 
>   System.out.println("Test Message found!! "+ $r); end
> 
> rule "test2"
> salience 5
>  when
>   not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) ||
> (system == "anyHost" && message matches ".*Hello.*")))   
>  then 
>   System.out.println(" No strange message  :-) "); end 
> 
> 


--
View this message in context: 
http://drools.46999.n3.nabble.com/Multiple-Insert-and-negative-rule-tp3531135p3531203.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
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


Re: [rules-users] multi-factor rule

2011-11-23 Thread Welsh, Armand
Try this:

rule 'Rule One'
activation-group 'age-test'
salience 300
when
Person (location == 'A',  age > 60 )
Then
do_something();
end

rule 'Rule Two'
activation-group 'age-test'
salience 200
when
Person (location == 'B',  age > 70 )
Then
do_something();
end

rule 'Rule Three'
activation-group 'age-test'
salience 100
when
Person (location == 'C',  age > 80 )
Then
do_something();
end

rule 'Rule Else'
activation-group 'age-test'
when
Person (age > 65 )
Then
do_something();
end


This will do what you want, and the first rule that matches will cancel the 
activation of any other rules that matches.  However, because these rules are 
not mutually exclusive,  this is not the best way to represent the logic, since 
a change to person could cause the wrong rule to fire, since only the rules 
that are affected by the change would be re-activated.

The EASIEST way to represent this is with an Excel Spreadsheet (or the Guvnor 
Decision Table).  Then you can craft the table to identify each rule 
exclusively, and use the otherwise keyword to deal with the negation of all 
specified facts.  If you can represent your rules without requiring salience as 
the conflict resolver, then you will have better (more predictable) rules, 
since this would mean that only one of the group rules could ever be true at 
any instance in proessing.



-Original Message-

> ronalbury wrote
>> Hi - I am a Drools newbie and I apologize in advance if the answer to my
>> question is intuitively obvious to the casual user.
>>
>> I have an object that has two fields: location(there are more than 50
>> locations) and age.  I am having difficulty building clean rules for the
>> following pseudo-code
>>
>>
>> // Rule One
>> if(location == "A") {
>> if(age>  60)
>>do_something();
>> }
>> // Rule Two
>> else if(location == "B") {
>>  if(age>  70)
>>  do_something();
>> }
>> // Rule Three
>> else if(location == "C") {
>>  if(age>  80)
>>  do_something();
>> }
>> // Rule Four
>> else {
>>  if(age>  65)
>>  do_something();
>> }
>>
>> The issue comes with Rule Four.  How do I avoid writing the rule so that I
>> don't have to say (location!="A"&&location!="B"&&location!="C") ?  I also
>> don't want to have to write an explicit rule for every possible location.
>>
>> I considered an activation-group with salience to have the rules executed
>> in order, but the problem is that if rules 1-3 do not fire, then rule 4
>> fires for all locations - I can get a hit if location=="C" and age==70.
>>
>> Is it possible to have a 'Map' and do something like
>> (age>map.get(location)) ?  I could live with creating a map with all
>> possible locations for key, although I'd rather not go this route.
>>
>> This problem is typical for the types of rules I'll be writing ... there
>> can be completely different sets of rule criteria depending on location.
>>
>>
>> Thanks in advance for your suggestions and your patience.
>>
>> ___
>> rules-users mailing list
>> rules-users@.jboss
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/rules-users-multi-factor-rule-tp3531130p3531237.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> 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

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to use contains with a function

2011-11-23 Thread Welsh, Armand
Wrap in in ()'s like this:

$tc : TaskContext( times contains (getTimeByID(ETimeID.NOW)) )

I have not personally tried this exact scenario, but the concept is the same as 
other scenarios I use this for.  The ()'s identifies that evaluation should be 
used here, except that it's not really an eval() because the contents don't 
returne true/false, but rather it's just java code to be processed, and the 
output can then be used in the evaluation.

I do this with matches like this:

LookupFact ( $lookupValue : value )
$sf : SomeFact ( value matches ("(?i)" + $lookupValue) )



From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Hezi Stern
Sent: Wednesday, November 23, 2011 7:51 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] How to use contains with a function

Hi all,

I encountered the following issue:

As an example TaskConectxt() holds a list of time related objects called times.
I would like to write a rule which ideally would filter the TaskContext 
according  to a specific time object.
The problematic restriction is that this time object is derived using a helper 
function (imported), in this case called getTimeByID which received as input an 
enum ID of a time and returns the desired time object.

Ideally the rule would like something like this:

rule "verify time"
  when

$tc:TaskContext(times contains 
getTimeByID(ETimeID.NOW))
  then
//something
end

unfortunately this does not work.
Is there any way to call a function with a param?
Is there a better alternative method than this one?

Thanks,
Hezi

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to delete fact in Guvnor?

2011-11-23 Thread Welsh, Armand
And after deleting the fact, you can go to Administration, and remove the 
Archive if you are absolutely sure you want it gone.

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of G S
Sent: Wednesday, November 23, 2011 6:48 AM
To: Rules Users List
Subject: Re: [rules-users] How to delete fact in Guvnor?

go to that folder and archive it

On Wed, Nov 23, 2011 at 7:39 AM, Zhao Yi  wrote:
> I have imported some rules and models in a package in Guvnor. How can 
> I delete some of them from the package?
>
>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/How-to-delete-fact-in-Guvnor-tp35306
> 88p3530688.html Sent from the Drools: User forum mailing list archive 
> at Nabble.com.
> ___
> 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

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How can I import a drl file in a package in duvnor?

2011-11-23 Thread Welsh, Armand
Yes.

The DRL file must either specify the package name that it will be imported to, 
or the package declaration line must be missing completely -- when missing 
Drools Guvnor prompts for the package name.

To import DRL, select the option to create a new Package.  Then select the 
radio button for import, and select your other DRL file.

Guvnor will merge your DRL into the existing package.  If any rules in the new 
DRL file have the same name as an existing rule, then the rule being imported 
will become the next revision of the rule guvnor (replacing the old rule with 
the new one).

Regards,
Armand

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Zhao Yi
Sent: Wednesday, November 23, 2011 6:35 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] How can I import a drl file in a package in duvnor?

I have created a package in duvnor. Can I upload other drl files to this 
package?

--
View this message in context: 
http://drools.46999.n3.nabble.com/How-can-I-import-a-drl-file-in-a-package-in-duvnor-tp3530871p3530871.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
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


Re: [rules-users] Guvnor cluster problems

2011-11-23 Thread jayadev
And it wont allow me to re-import the whole repository! How can I fix it?!

ERROR 23-11 10:21:30,264
(RulesRepositoryAdministrator.java:clearRulesRepository:96)  Unable to
clear rules repository.
javax.jcr.ReferentialIntegrityException:
98096f69-7629-4083-95e7-73402a6f511e: the node cannot be removed because it
is still being referenced.
at
org.apache.jackrabbit.core.state.SharedItemStateManager$Update.checkReferentialIntegrity(SharedItemStateManager.java:1039)
at
org.apache.jackrabbit.core.state.SharedItemStateManager$Update.begin(SharedItemStateManager.java:574)
at
org.apache.jackrabbit.core.state.SharedItemStateManager.beginUpdate(SharedItemStateManager.java:1110)
at
org.apache.jackrabbit.core.state.SharedItemStateManager.update(SharedItemStateManager.java:1140)
at
org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:351)
at
org.apache.jackrabbit.core.state.XAItemStateManager.update(XAItemStateManager.java:354)
at
org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:326)
at
org.apache.jackrabbit.core.state.SessionItemStateManager.update(SessionItemStateManager.java:328)
at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1141)
at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:920)
at
org.drools.repository.RulesRepositoryAdministrator.clearRulesRepository(RulesRepositoryAdministrator.java:87)
at
org.drools.repository.RulesRepository.importRulesRepositoryFromStream(RulesRepository.java:1058)
at
org.drools.guvnor.server.files.FileManagerUtils.importRulesRepository(FileManagerUtils.java:271)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.security.SecurityInterceptor.aroundInvoke(SecurityInterceptor.java:157)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
at
org.drools.guvnor.server.files.FileManagerUtils_$$_javassist_9.importRulesRepository(FileManagerUtils_$$_javassist_9.java)
at
org.drools.guvnor.server.files.RepositoryBackupServlet.processImportRepository(RepositoryBackupServlet.java:134)
at
org.drools.guvnor.server.files.RepositoryBackupServlet.access$100(RepositoryBackupServlet.java:42)
at
org.drools.guvnor.server.files.RepositoryBackupServlet$1.a(RepositoryBackupServlet.java:71)
at
org.drools.guvnor.server.files.RepositoryServlet.doAuthorizedAction(RepositoryServlet.java:97)
at
org.drools.guvnor.server.files.RepositoryBackupServlet.doPost(RepositoryBackupServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.web.ContextFilter$1.process(ContextFilter.java:42)
at
org.jboss.seam.servlet.ContextualHttpServletRequest.run(ContextualHttpServletRequest.java:53)
at org.jboss.seam.web.ContextFilter.doFilter(ContextFilter.java:37)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.co

Re: [rules-users] Guvnor cluster problems

2011-11-23 Thread jayadev
I dont see any SQL Exceptions in the log, probably means that all journal
entries did make it to database. How can I figure out how/when/for how long/
the sync messages got lost? I have logs enabled at INFO and I dont see any
WARNING's or ERROR's.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Guvnor-cluster-problems-tp3528970p3531415.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rules that cumulate on consequence

2011-11-23 Thread Michael Anstis
Yay, a great improvement :)

2011/11/23 Vincent Legendre 

>  It will work properly in a stateless session ... in sequential mode ...
> may be.
> This rule for instance, will loop by itself (and all other will also
> loop), in a stateless or statefull session :
>
>
> rule "one"
> when
> $r : Result( $score : score )
> Applicant( numberOfLoans > 1 )
> then
> $r.setScore( $score + 5 );
> update( $r ); // update $r, so re-trigger the rule, which
> re-update $r, etc etc etc ...
> end
>
> May be a no-loop could work, but no-loop is dangerous (hard to
> debug/maintain, and does not handle cycles between rules firing, ie "rule
> one" will trigger "rule two", which will trigger "rule one" again etc etc)
>
> The second set of rules could be better, if modified that way (test is the
> updated field is null in conditions)
>
> rule "one"
> salience 100
> when
> $r : Result(*numberOfLoans == null*)
>
> Applicant( $nl : numberOfLoans )
> then
> $r.setNumberOfLoans( $nl );
> update( $r );
> end
>  ...
>
> Another option is to add some flags in the Result object, holding the fact
> that a rule (or a rule group, for instance the rule group that manage the
> numberOfLoans, another the income ...) has been fire, meaning that the
> corresponding applicant attribute has been taken into account. This flag is
> used in the conditions to exclude all other rules in the same group.
>
> May be a last option is something that I already use for a use-case close
> to this one. This was about computing counter (agregate a value in a single
> object, and avoiding infinite loop), then check them (so I need the updated
> value). My solution was a rule-flow with 3 boxes :  [compute
> counter]->[update counters in RETE]->[check counters].
> The main trick is to update the value but not the object in  [compute
> counter] group, like this
>
> rule "one"
> when
> $r : Result()
>
> Applicant( numberOfLoans > 1 )
> then
> $r.addScore( 5 );
> end
>
> -> $r fact is not updated in RETE here, so no infinite loop problem
> -> The main point to care about is to avoid getting the actual score in
> condition, but uise the getter in the action part. Indeed, as the $r fact
> is not updated, the original binding would be kept and all "computing"
> rules will update the same initial value (so forget about agregate).
>
>
> Then update all Results in [update counters in RETE] group :
> rule "update_results"
> when
> $r : Result()
> then
> update ( $r );
> end
>
> -> this will update all object for their further use for validation rules
>
> And finally, use your Result object with score updated to perform other
> actions in the [check counters] group :
>
> rule "decide_reject"
> when
> $r : Result(decision == null, score < 25)
> then
> $r.setDecision( Decision.REJECT );
> update ( $r );
> end
>
> -> Note the null check to avoid loops, again ...
>
>
>
> Le 23/11/2011 11:22, Geoffrey De Smet a écrit :
>
> Good idea,
>
> but note that it will only work properly in a stateless session (which is
> most likely in his case).
>
> In a stateful session, with multiple fireAllRules and when the applicant's
> properties change between those fireAllRules call,
> the trick is to do an insertLogical of a ScoreDiff instead of setScore()
> and then add 1 general rule to accumulate all those ScoreDiffs and put the
> resulting score into the Result.
>
> Op 23-11-11 10:56, Michael Anstis schreef:
>
> Why not use a Fact that contains your result?
>
> In DRL terms it'd look like this:-
>
> rule "one"
> when
> $r : Result( $score : score )
> Applicant( numberOfLoans > 1 )
> then
> $r.setScore( $score + 5 );
> update( $r );
> end
>
> rule "two"
> when
> $r : Result( $score : score )
> Applicant( disposableIncome < 2 )
> then
> $r.setScore( $score + 10 );
> update( $r );
> end
>
> The result could equally just contain the factors influencing the score
> with a low salience rule then calculating the final score:-
>
> rule "one"
> salience 100
> when
> $r : Result()
> Applicant( $nl : numberOfLoans )
> then
> $r.setNumberOfLoans( $nl );
> update( $r );
> end
>
> rule "two"
> salience 100
> when
> $r : Result()
> Applicant( $di : disposableIncome )
> then
> $r.setDisposableIncome( $di );
> update( $r );
> end
>
> rule "calculate score"
> salience 200
> when
> $r : Result( $nl : numberOfLoans > 1, $di : disposableIncome <
> 2 )
> then
> $r.setScore( 20 );
> update( $r );
> end
>
>
> On 23 November 2011 09:44, lansyj  wrote:
>
>> hi folks
>>
>> We are working on a requirement that requires us to have multiple rules
>> that
>> could fire for a given input and for all the rules that fire, we would
>> want
>> to cumu

Re: [rules-users] string replace collision problem

2011-11-23 Thread FrankVhh
Hi,

Sorry, but I fogot about you :-(.

It does not work because both wolfgang and I did get your question wrong.

If I were you, I would try to work from the opposite direction and check
whether a String matches S but not SF. Than replace that S by VOL.

A second rule could than safely check for SF and replace that by S.

In short, reverse your salience, check that S is not SF and make sure that
you replace the right S in the RHS of your rules. You do not want to update
the WM.

Regards,
Frank


fiitkar wrote
> 
> Sorry, it does not work.
> For input SF I allways get VOLVOLFVOL.
> 
> Once again: if the input is S the output should be VOL. But if the input
> string contains SF the output should be S and not VOL.
> 
> For example: 
> SF --> S
> SSF --> VOLS
> SFSF -> SS
> etc.
> 


--
View this message in context: 
http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518826p3531296.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] multi-factor rule

2011-11-23 Thread Vincent Legendre
Or you can use Guvnor tables and "otherwise" special value (see doc on 
tables under guvnor)


Le 23/11/2011 17:14, FrankVhh a écrit :
> Hi,
>
> If you do not want to check for all alternative cases, you might need a
> showstopper to stop the firings of unwanted rules.
>
> This can be achieved by executing insert(new ShowStopper() ); in your RHS.
> All LHS of the rules will check for not( ShowStopper() )
>
> Alternatively, you can use the new -experimental - feature of drools called
> "declarative agenda". You could use this to block activations of rules
> directly.
>
> Also, be aware that relying on salience alone is very hard to maintain over
> time.
>
> Regards,
> Frank
>
>
> ronalbury wrote
>> Hi - I am a Drools newbie and I apologize in advance if the answer to my
>> question is intuitively obvious to the casual user.
>>
>> I have an object that has two fields: location(there are more than 50
>> locations) and age.  I am having difficulty building clean rules for the
>> following pseudo-code
>>
>>
>> // Rule One
>> if(location == "A") {
>> if(age>  60)
>>do_something();
>> }
>> // Rule Two
>> else if(location == "B") {
>>  if(age>  70)
>>  do_something();
>> }
>> // Rule Three
>> else if(location == "C") {
>>  if(age>  80)
>>  do_something();
>> }
>> // Rule Four
>> else {
>>  if(age>  65)
>>  do_something();
>> }
>>
>> The issue comes with Rule Four.  How do I avoid writing the rule so that I
>> don't have to say (location!="A"&&location!="B"&&location!="C") ?  I also
>> don't want to have to write an explicit rule for every possible location.
>>
>> I considered an activation-group with salience to have the rules executed
>> in order, but the problem is that if rules 1-3 do not fire, then rule 4
>> fires for all locations - I can get a hit if location=="C" and age==70.
>>
>> Is it possible to have a 'Map' and do something like
>> (age>map.get(location)) ?  I could live with creating a map with all
>> possible locations for key, although I'd rather not go this route.
>>
>> This problem is typical for the types of rules I'll be writing ... there
>> can be completely different sets of rule criteria depending on location.
>>
>>
>> Thanks in advance for your suggestions and your patience.
>>
>> ___
>> rules-users mailing list
>> rules-users@.jboss
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/rules-users-multi-factor-rule-tp3531130p3531237.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> 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


Re: [rules-users] multi-factor rule

2011-11-23 Thread FrankVhh
Hi,

If you do not want to check for all alternative cases, you might need a
showstopper to stop the firings of unwanted rules.

This can be achieved by executing insert(new ShowStopper() ); in your RHS.
All LHS of the rules will check for not( ShowStopper() )

Alternatively, you can use the new -experimental - feature of drools called
"declarative agenda". You could use this to block activations of rules
directly.

Also, be aware that relying on salience alone is very hard to maintain over
time.

Regards,
Frank


ronalbury wrote
> 
> Hi - I am a Drools newbie and I apologize in advance if the answer to my
> question is intuitively obvious to the casual user.
> 
> I have an object that has two fields: location(there are more than 50
> locations) and age.  I am having difficulty building clean rules for the
> following pseudo-code
> 
> 
> // Rule One
> if(location == "A") {
>if(age > 60)
>   do_something();
> }
> // Rule Two
> else if(location == "B") {
> if(age > 70)
> do_something();
> }
> // Rule Three
> else if(location == "C") {
> if(age > 80)
> do_something();
> }
> // Rule Four
> else {
> if(age > 65)
> do_something();
> }
> 
> The issue comes with Rule Four.  How do I avoid writing the rule so that I
> don't have to say (location!="A"&&location!="B"&&location!="C") ?  I also
> don't want to have to write an explicit rule for every possible location.
> 
> I considered an activation-group with salience to have the rules executed
> in order, but the problem is that if rules 1-3 do not fire, then rule 4
> fires for all locations - I can get a hit if location=="C" and age==70.
> 
> Is it possible to have a 'Map' and do something like
> (age>map.get(location)) ?  I could live with creating a map with all
> possible locations for key, although I'd rather not go this route.
> 
> This problem is typical for the types of rules I'll be writing ... there
> can be completely different sets of rule criteria depending on location.
> 
> 
> Thanks in advance for your suggestions and your patience.
> 
> ___
> rules-users mailing list
> rules-users@.jboss
> https://lists.jboss.org/mailman/listinfo/rules-users
> 


--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-multi-factor-rule-tp3531130p3531237.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Multiple Insert and negative rule

2011-11-23 Thread FrankVhh
rule "test2"
salience 5
 when
  not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) ||
(system == "anyHost" && message matches ".*Hello.*")))   
 then 
  System.out.println(" No strange message  :-) "); 
end

Hi,

Probably it is because you are using NOT (). The engine will not fire this
rule for every event in the WM. 

Consider changing from 
not ( Event( system == "any" ) ) 
to 
Event( system != "any" )

That will force the engine to execute it for each Event in memory.

Regards,
Frank


annam2011 wrote
> 
> Hello,
> I'm a newbie to drools.
> I would like to know why i get the following output on the console : 
> 
> Test Message found!!
> No strange message  :-) 
> Test Message found!! 
> Test Message found!!
> 
> NotifyEngineTest.java creates 10 events. Rule "test2" should be activated
> with every event, 
> so that the output should look like this:
> 
> Test Message found!!
> No strange message  :-) 
> Test Message found!!
> No strange message  :-) 
> Test Message found!!
> No strange message  :-) 
> 
> Could somebody help me with this ? 
> I appriciate your help 
> Thanks in advance,
> Anna 
> 
> // NotifyEngineTest.java//
> 
> for (int i = 0; i < 10; i++){
> 
>Event e = new Event();
>e.setId("ID"+Math.random());
>e.setTimestamp(new Date());
>e.setCatagory("TEST");
>e.setMessage( i + " Test");
>e.setSystem("localhost");
> 
>  ruleEngine.insert(e);
> _   
> // RuleEngine.java//
>  public void insert(Event e) throws RuleEngineException  {
>   FactHandle factHandle = ksession.insert(e);
>  int numberOfRules = ksession.fireAllRules();
>  logger.debug("Rules fired: "+numberOfRules);
>  }
> __
> // Notify.drl//  
> rule "test"
>  salience 10
>  when
>   $r: Event(message  matches ".*Test.*")   
>  then 
>   System.out.println("Test Message found!! "+ $r); 
> end
> 
> rule "test2"
> salience 5
>  when
>   not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) ||
> (system == "anyHost" && message matches ".*Hello.*")))   
>  then 
>   System.out.println(" No strange message  :-) "); 
> end
> 
> 


--
View this message in context: 
http://drools.46999.n3.nabble.com/Multiple-Insert-and-negative-rule-tp3531135p3531203.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to use contains with a function

2011-11-23 Thread Vincent Legendre

I think this could work :

*rule*"verify time"
*when*
$now: java.util.Date() from getTimeByID(ETimeID.NOW)
$tc: TaskContext(times *contains*$now)
*then*
//something
*end*


or an eval :

*rule*"verify time"
*when*
$tc: TaskContext(eval( 
this.getTimes().*contains*(getTimeByID(ETimeID.NOW)) ))

*then*
//something
*end*


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Multiple Insert and negative rule

2011-11-23 Thread annam2011
Hello,
I'm a newbie to drools.
I would like to know why i get the following output on the console : 

Test Message found!!
No strange message  :-) 
Test Message found!! 
Test Message found!!

NotifyEngineTest.java creates 10 events. Rule "test2" should be activated
with every event, 
so that the output should look like this:

Test Message found!!
No strange message  :-) 
Test Message found!!
No strange message  :-) 
Test Message found!!
No strange message  :-) 

Could somebody help me with this ? 
I appriciate your help 
Thanks in advance,
Anna 

// NotifyEngineTest.java//

for (int i = 0; i < 10; i++){

   Event e = new Event();
   e.setId("ID"+Math.random());
   e.setTimestamp(new Date());
   e.setCatagory("TEST");
   e.setMessage( i + " Test");
   e.setSystem("localhost");

 ruleEngine.insert(e);
_   
// RuleEngine.java//
 public void insert(Event e) throws RuleEngineException  {
  FactHandle factHandle = ksession.insert(e);
 int numberOfRules = ksession.fireAllRules();
 logger.debug("Rules fired: "+numberOfRules);
 }
__
// Notify.drl//  
rule "test"
 salience 10
 when
  $r: Event(message  matches ".*Test.*")   
 then 
  System.out.println("Test Message found!! "+ $r); 
end

rule "test2"
salience 5
 when
  not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) ||
(system == "anyHost" && message matches ".*Hello.*")))   
 then 
  System.out.println(" No strange message  :-) "); 
end


--
View this message in context: 
http://drools.46999.n3.nabble.com/Multiple-Insert-and-negative-rule-tp3531135p3531135.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rules that cumulate on consequence

2011-11-23 Thread Vincent Legendre
It will work properly in a stateless session ... in sequential mode ... 
may be.
This rule for instance, will loop by itself (and all other will also 
loop), in a stateless or statefull session :


rule "one"
when
$r : Result( $score : score )
Applicant( numberOfLoans > 1 )
then
$r.setScore( $score + 5 );
update( $r ); // update $r, so re-trigger the rule, which 
re-update $r, etc etc etc ...

end

May be a no-loop could work, but no-loop is dangerous (hard to 
debug/maintain, and does not handle cycles between rules firing, ie 
"rule one" will trigger "rule two", which will trigger "rule one" again 
etc etc)


The second set of rules could be better, if modified that way (test is 
the updated field is null in conditions)

rule "one"
salience 100
when
$r : Result(*numberOfLoans == null*)
Applicant( $nl : numberOfLoans )
then
$r.setNumberOfLoans( $nl );
update( $r );
end
 ...

Another option is to add some flags in the Result object, holding the 
fact that a rule (or a rule group, for instance the rule group that 
manage the numberOfLoans, another the income ...) has been fire, meaning 
that the corresponding applicant attribute has been taken into account. 
This flag is used in the conditions to exclude all other rules in the 
same group.


May be a last option is something that I already use for a use-case 
close to this one. This was about computing counter (agregate a value in 
a single object, and avoiding infinite loop), then check them (so I need 
the updated value). My solution was a rule-flow with 3 boxes :  [compute 
counter]->[update counters in RETE]->[check counters].
The main trick is to update the value but not the object in  [compute 
counter] group, like this


rule "one"
when
$r : Result()
Applicant( numberOfLoans > 1 )
then
$r.addScore( 5 );
end

-> $r fact is not updated in RETE here, so no infinite loop problem
-> The main point to care about is to avoid getting the actual score in 
condition, but uise the getter in the action part. Indeed, as the $r 
fact is not updated, the original binding would be kept and all 
"computing" rules will update the same initial value (so forget about 
agregate).



Then update all Results in [update counters in RETE] group :
rule "update_results"
when
$r : Result()
then
update ( $r );
end

-> this will update all object for their further use for validation rules

And finally, use your Result object with score updated to perform other 
actions in the [check counters] group :


rule "decide_reject"
when
$r : Result(decision == null, score < 25)
then
$r.setDecision( Decision.REJECT );
update ( $r );
end

-> Note the null check to avoid loops, again ...



Le 23/11/2011 11:22, Geoffrey De Smet a écrit :

Good idea,

but note that it will only work properly in a stateless session (which 
is most likely in his case).


In a stateful session, with multiple fireAllRules and when the 
applicant's properties change between those fireAllRules call,

the trick is to do an insertLogical of a ScoreDiff instead of setScore()
and then add 1 general rule to accumulate all those ScoreDiffs and put 
the resulting score into the Result.


Op 23-11-11 10:56, Michael Anstis schreef:

Why not use a Fact that contains your result?

In DRL terms it'd look like this:-

rule "one"
when
$r : Result( $score : score )
Applicant( numberOfLoans > 1 )
then
$r.setScore( $score + 5 );
update( $r );
end

rule "two"
when
$r : Result( $score : score )
Applicant( disposableIncome < 2 )
then
$r.setScore( $score + 10 );
update( $r );
end

The result could equally just contain the factors influencing the 
score with a low salience rule then calculating the final score:-


rule "one"
salience 100
when
$r : Result()
Applicant( $nl : numberOfLoans )
then
$r.setNumberOfLoans( $nl );
update( $r );
end

rule "two"
salience 100
when
$r : Result()
Applicant( $di : disposableIncome )
then
$r.setDisposableIncome( $di );
update( $r );
end

rule "calculate score"
salience 200
when
$r : Result( $nl : numberOfLoans > 1, $di : disposableIncome 
< 2 )

then
$r.setScore( 20 );
update( $r );
end


On 23 November 2011 09:44, lansyj > wrote:


hi folks

We are working on a requirement that requires us to have multiple
rules that
could fire for a given input and for all the rules that fire, we
would want
to cumulate the consequence to reach the final consequence.

As an example, if we want to identify the credit score for a
person, based
on his gender you might want to assign/increment/decrement the
score, then
based on nationality, and so on.

So, considering the l

[rules-users] How to use contains with a function

2011-11-23 Thread Hezi Stern
Hi all,

 

I encountered the following issue:

 

As an example TaskConectxt() holds a list of time related objects called
times. 

I would like to write a rule which ideally would filter the TaskContext
according  to a specific time object.

The problematic restriction is that this time object is derived using a
helper function (imported), in this case called getTimeByID which received
as input an enum ID of a time and returns the desired time object.

 

Ideally the rule would like something like this: 

 

rule "verify time"

  when



$tc:TaskContext(times contains
getTimeByID(ETimeID.NOW))

  then

//something 

end

 

unfortunately this does not work. 

Is there any way to call a function with a param?

Is there a better alternative method than this one?

 

Thanks,

Hezi

 

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] multi-factor rule

2011-11-23 Thread Ronald Albury
Hi - I am a Drools newbie and I apologize in advance if the answer to my
question is intuitively obvious to the casual user.

I have an object that has two fields: location(there are more than 50
locations) and age.  I am having difficulty building clean rules for the
following pseudo-code


// Rule One
if(location == "A") {
   if(age > 60)
  do_something();
}
// Rule Two
else if(location == "B") {
if(age > 70)
do_something();
}
// Rule Three
else if(location == "C") {
if(age > 80)
do_something();
}
// Rule Four
else {
if(age > 65)
do_something();
}

The issue comes with Rule Four.  How do I avoid writing the rule so that I
don't have to say (location!="A"&&location!="B"&&location!="C") ?  I also
don't want to have to write an explicit rule for every possible location.

I considered an activation-group with salience to have the rules executed
in order, but the problem is that if rules 1-3 do not fire, then rule 4
fires for all locations - I can get a hit if location=="C" and age==70.

Is it possible to have a 'Map' and do something like
(age>map.get(location)) ?  I could live with creating a map with all
possible locations for key, although I'd rather not go this route.

This problem is typical for the types of rules I'll be writing ... there
can be completely different sets of rule criteria depending on location.


Thanks in advance for your suggestions and your patience.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to delete fact in Guvnor?

2011-11-23 Thread G S
go to that folder and archive it

On Wed, Nov 23, 2011 at 7:39 AM, Zhao Yi  wrote:
> I have imported some rules and models in a package in Guvnor. How can I
> delete some of them from the package?
>
>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/How-to-delete-fact-in-Guvnor-tp3530688p3530688.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> 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


Re: [rules-users] How to change Guvnor language?

2011-11-23 Thread Michael Anstis
Guvnor is localised to the following locale:-

   - es_ES
   - fr_FR
   - ja_JP
   - pt_BR
   - zh_CN

The default language for messages etc when no locale is provided (or is
unavailable) is English.

Provided you are using the downloaded WAR, or you have compiled from source
using the "full" profile you should be able to append the required locale
to your URL.

e.g. http://127.0.0.1:/org.drools.guvnor.Guvnor/Guvnor.html?locale=es_ES

You can also use the Guvnor.jsp page that uses the HTTP request header
locale setting (that should be set by your browser).

e.g. http://127.0.0.1:/org.drools.guvnor.Guvnor/Guvnor.jsp

On 23 November 2011 12:21, Zhao Yi  wrote:

> How can I change Guvnor interface language?
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-change-Guvnor-language-tp3530505p3530505.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> 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


[rules-users] How can I import a drl file in a package in duvnor?

2011-11-23 Thread Zhao Yi
I have created a package in duvnor. Can I upload other drl files to this
package?

--
View this message in context: 
http://drools.46999.n3.nabble.com/How-can-I-import-a-drl-file-in-a-package-in-duvnor-tp3530871p3530871.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] How to delete fact in Guvnor?

2011-11-23 Thread Zhao Yi
I have imported some rules and models in a package in Guvnor. How can I
delete some of them from the package?



--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-delete-fact-in-Guvnor-tp3530688p3530688.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] How to change Guvnor language?

2011-11-23 Thread Zhao Yi
How can I change Guvnor interface language?

--
View this message in context: 
http://drools.46999.n3.nabble.com/How-to-change-Guvnor-language-tp3530505p3530505.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Does drools support rule doc?

2011-11-23 Thread Zhao Yi
Do you mean the Guvnor package editor? 

I don't use Guvnor. How can I generate the document from command line like
mvn?



--
View this message in context: 
http://drools.46999.n3.nabble.com/Does-drools-support-rule-doc-tp3529621p3530488.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rules that cumulate on consequence

2011-11-23 Thread Geoffrey De Smet

Good idea,

but note that it will only work properly in a stateless session (which 
is most likely in his case).


In a stateful session, with multiple fireAllRules and when the 
applicant's properties change between those fireAllRules call,

the trick is to do an insertLogical of a ScoreDiff instead of setScore()
and then add 1 general rule to accumulate all those ScoreDiffs and put 
the resulting score into the Result.


Op 23-11-11 10:56, Michael Anstis schreef:

Why not use a Fact that contains your result?

In DRL terms it'd look like this:-

rule "one"
when
$r : Result( $score : score )
Applicant( numberOfLoans > 1 )
then
$r.setScore( $score + 5 );
update( $r );
end

rule "two"
when
$r : Result( $score : score )
Applicant( disposableIncome < 2 )
then
$r.setScore( $score + 10 );
update( $r );
end

The result could equally just contain the factors influencing the 
score with a low salience rule then calculating the final score:-


rule "one"
salience 100
when
$r : Result()
Applicant( $nl : numberOfLoans )
then
$r.setNumberOfLoans( $nl );
update( $r );
end

rule "two"
salience 100
when
$r : Result()
Applicant( $di : disposableIncome )
then
$r.setDisposableIncome( $di );
update( $r );
end

rule "calculate score"
salience 200
when
$r : Result( $nl : numberOfLoans > 1, $di : disposableIncome < 
2 )

then
$r.setScore( 20 );
update( $r );
end


On 23 November 2011 09:44, lansyj > wrote:


hi folks

We are working on a requirement that requires us to have multiple
rules that
could fire for a given input and for all the rules that fire, we
would want
to cumulate the consequence to reach the final consequence.

As an example, if we want to identify the credit score for a
person, based
on his gender you might want to assign/increment/decrement the
score, then
based on nationality, and so on.

So, considering the long list of such criteria, having rules that
cover all
scenarios and are still mutually exclusive isnt a scalable
solution. Could
you please advice on how this could be achieved.

We run Drools 5.1.1 and Guvnor; rules are made using the guided
editor with
DSLs.

Awaiting your support,

Best Regards

-lj

--
View this message in context:

http://drools.46999.n3.nabble.com/Rules-that-cumulate-on-consequence-tp3530214p3530214.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
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


--
With kind regards,
Geoffrey De Smet

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rules that cumulate on consequence

2011-11-23 Thread lansyj
Thanks a billion mantis!

We do think this would work; let me try it and confirm.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Rules-that-cumulate-on-consequence-tp3530214p3530252.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rules that cumulate on consequence

2011-11-23 Thread Michael Anstis
Why not use a Fact that contains your result?

In DRL terms it'd look like this:-

rule "one"
when
$r : Result( $score : score )
Applicant( numberOfLoans > 1 )
then
$r.setScore( $score + 5 );
update( $r );
end

rule "two"
when
$r : Result( $score : score )
Applicant( disposableIncome < 2 )
then
$r.setScore( $score + 10 );
update( $r );
end

The result could equally just contain the factors influencing the score
with a low salience rule then calculating the final score:-

rule "one"
salience 100
when
$r : Result()
Applicant( $nl : numberOfLoans )
then
$r.setNumberOfLoans( $nl );
update( $r );
end

rule "two"
salience 100
when
$r : Result()
Applicant( $di : disposableIncome )
then
$r.setDisposableIncome( $di );
update( $r );
end

rule "calculate score"
salience 200
when
$r : Result( $nl : numberOfLoans > 1, $di : disposableIncome <
2 )
then
$r.setScore( 20 );
update( $r );
end


On 23 November 2011 09:44, lansyj  wrote:

> hi folks
>
> We are working on a requirement that requires us to have multiple rules
> that
> could fire for a given input and for all the rules that fire, we would want
> to cumulate the consequence to reach the final consequence.
>
> As an example, if we want to identify the credit score for a person, based
> on his gender you might want to assign/increment/decrement the score, then
> based on nationality, and so on.
>
> So, considering the long list of such criteria, having rules that cover all
> scenarios and are still mutually exclusive isnt a scalable solution. Could
> you please advice on how this could be achieved.
>
> We run Drools 5.1.1 and Guvnor; rules are made using the guided editor with
> DSLs.
>
> Awaiting your support,
>
> Best Regards
>
> -lj
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Rules-that-cumulate-on-consequence-tp3530214p3530214.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> 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


[rules-users] Rules that cumulate on consequence

2011-11-23 Thread lansyj
hi folks 

We are working on a requirement that requires us to have multiple rules that
could fire for a given input and for all the rules that fire, we would want
to cumulate the consequence to reach the final consequence.

As an example, if we want to identify the credit score for a person, based
on his gender you might want to assign/increment/decrement the score, then
based on nationality, and so on. 

So, considering the long list of such criteria, having rules that cover all
scenarios and are still mutually exclusive isnt a scalable solution. Could
you please advice on how this could be achieved.

We run Drools 5.1.1 and Guvnor; rules are made using the guided editor with
DSLs.

Awaiting your support, 

Best Regards

-lj

--
View this message in context: 
http://drools.46999.n3.nabble.com/Rules-that-cumulate-on-consequence-tp3530214p3530214.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users