Re: [rules-users] collection question

2010-07-21 Thread Earnest Dyke
Very clean.

Earnie!





From: Steve Ronderos 
To: Rules Users List 
Sent: Wed, July 21, 2010 9:56:56 AM
Subject: Re: [rules-users] collection question

Hi J, 

In your example I don't think that the collect is necessary. 

I believe the following will work: 

rule "AddBonusCd"

 when
   $so : ShippingOrder()
   Product(name == "cd1") from $so.products
   not (Product(name == "bonus_cd") from $so.products)
 then
   System.out.println("Adding Bonus Cd");
 
   Set productSet = new HashSet($so.getProducts());
 
   Product bonusCd = new Product();
   bonusCd.setName("bonus_cd");
   productSet.add(bonusCd);
 
   modify($so) {
 setProducts(productSet);
   }
end 

You don't need the collects because you are just checking for 
existence/non-existence of facts within the products collection. 


Good luck! 
Steve 


rules-users-boun...@lists.jboss.org wrote on 07/21/2010 01:59:40 AM:

> From: 
> 
> Wolfgang Laun  
> 
> To: 
> 
> Rules Users List  
> 
> Date: 
> 
> 07/21/2010 02:02 AM 
> 
> Subject: 
> 
> Re: [rules-users] collection question 
> 
> Sent by: 
> 
> rules-users-boun...@lists.jboss.org 
> 
> Things would be smpler if you could avoid re-creating Product objects
> because adding an identical Object does not change the Set. (This
> could be implemented with the help of a global Map,)
> 
> Second, overriding equals (and hashCode) in Product would also avoid adding
> an "evil twin" in your rule code - as it is!
> 
> Even simpler is a solution where the relevant Product objects are inserted
> as facts, so that
>$cd1 : Product( name == "cd1" )
>$bonus_cd : Product( name == "bonus_cd" )
>$order : ShippingOrder( products contains $cd1, products not
> contains $bonus_cd )
> is true (again, with equals and hashCode being overridden).
> 
> Given your solution with collect, an additional eval testing for
> "bonus_cd" not being the
> name of the single Product in List $productList might be more
> efficient than iterating
> all products a second time.
> 
> -W
> 
> On 21 July 2010 00:41, javaj  wrote:
> >
> > I'm trying to write a rule to add an object to a collection if thecollection
> > already contained a certain object with a specific attribute.
> >
> > I developed a small example so maybe that will make more sense:
> >
> > Use Case: In a product shipping applicaiton, anytime a product with the name
> > "cd1" is in the shipping order, a bonus product named "bonus_cd" needs to be
> > added to the shipping order.  The bonus cd should not be added if it's
> > already in the shipping order.
> >
> > Shipping Order:
> >
> > public class ShippingOrder {
> >
> >private Set products;
> >
> >public ShippingOrder() {}
> >
> >public Set getProducts() {
> >return products;
> >}
> >
> >public void setProducts(Set products) {
> >this.products = products;
> >}
> >
> > }
> >
> > Product:
> >
> > public class Product {
> >
> >private String name;
> >
> >public Product(){}
> >
> >public String getName() {
> >return name;
> >}
> >
> >public void setName(String name) {
> >this.name = name;
> >}
> >
> > }
> >
> >
> > Rule:
> >
> > rule "AddBonusCd"
> >
> >when
> >$so : ShippingOrder()
> >$productList : ArrayList(size == 1) from collect( 
> Product(name matches
> > "cd1|bonus_cd") from $so.products)
> >then
> >System.out.println("Adding Bonus Cd");
> >
> >Set productSet = new HashSet
> ($so.getProducts());
> >
> >Product bonusCd = new Product();
> >bonusCd.setName("bonus_cd");
> >productSet.add(bonusCd);
> >
> >modify($so) {
> >setProducts(productSet);
> >}
> > end
> >
> > The Shipping Order object is inserted as the fact.
> >
> > The rule is valid if only cd1 or cd_bonus is in the shipping order.  I only
> > want the rule to run when cd1 is in the product set but cd_bonus is not.
> > Makes sense?
> >
> > Thanks,
> > J
> > --
> > View this message in context: http://drools-java-rules-engine.
> 46999.n3.nabble.com/collection-question-tp982769p982769.html
> > Sent from the Drools - User 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] collection question

2010-07-20 Thread Earnest Dyke
Would the following accomplish your goal?

Earnie!

import java.util.*;
import com.sample.Product;
import com.sample.ShippingOrder;

rule "AddBonusCd"
when
$so : ShippingOrder()
ArrayList(size == 1) from collect( Product(name matches
   "cd1") from $so.products)
ArrayList(size == 0) from collect( Product(name matches
   "bonus_cd") from $so.products)
then
System.out.println("Adding Bonus Cd ");
   
Set productSet = new HashSet($so.getProducts());
   
Product bonusCd = new Product();
bonusCd.setName("bonus_cd");
productSet.add(bonusCd);
   
modify($so) {
setProducts(productSet);
}
end





From: javaj 
To: rules-users@lists.jboss.org
Sent: Tue, July 20, 2010 6:41:25 PM
Subject: [rules-users] collection question


I'm trying to write a rule to add an object to a collection if the collection
already contained a certain object with a specific attribute.

I developed a small example so maybe that will make more sense:

Use Case: In a product shipping applicaiton, anytime a product with the name
"cd1" is in the shipping order, a bonus product named "bonus_cd" needs to be
added to the shipping order.  The bonus cd should not be added if it's
already in the shipping order.

Shipping Order:

public class ShippingOrder {

private Set products;

public ShippingOrder() {}

public Set getProducts() {
return products;
}

public void setProducts(Set products) {
this.products = products;
}

}

Product:

public class Product {

private String name;

public Product(){}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}


Rule:

rule "AddBonusCd"

when
$so : ShippingOrder()
$productList : ArrayList(size == 1) from collect( Product(name matches
"cd1|bonus_cd") from $so.products)
then
System.out.println("Adding Bonus Cd");

Set productSet = new HashSet($so.getProducts());

Product bonusCd = new Product();
bonusCd.setName("bonus_cd");
productSet.add(bonusCd);

modify($so) {
setProducts(productSet);
}
end

The Shipping Order object is inserted as the fact.

The rule is valid if only cd1 or cd_bonus is in the shipping order.  I only
want the rule to run when cd1 is in the product set but cd_bonus is not. 
Makes sense?

Thanks,
J
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/collection-question-tp982769p982769.html

Sent from the Drools - User 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] Dynamic attribute in Guvnor

2010-07-19 Thread Earnest Dyke
What triggers the change in DynamicAttribute? How does the rule know to use 
AssetID versus AssetOwner for instance?

Earnie!





From: bbarani 
To: rules-users@lists.jboss.org
Sent: Mon, July 19, 2010 2:40:41 PM
Subject: [rules-users] Dynamic attribute in Guvnor


Hi,

We have a scenario as below,  

Here is what we want to achieve. Let’s say we want to have following rule:

When AssetType = DSTR Then Decision = Granted. 

I can have AssetType as static class or attribute in the model. But this may
limit our ability to handle new information. Let’s say now I have rule to
restrict access to a specific metadata asset like:

When AssetID = 8-XXX-1234 and Group<>’HR’ then Decision = Denied.

If we don’t have AssetID, then no one can define that rule until we change
the code. What we really want is if Drools can do something like this:

When DynamicAttribute(“AssetID”) = 8-xxx-1234and Group<>’HR’ then Decision =
Denied.

Any one has implemented anything similar to this before??

Thanks,
BB

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Dynamic-attribute-in-Guvnor-tp979262p979262.html

Sent from the Drools - User 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] Avoiding writing redundant rules

2010-07-19 Thread Earnest Dyke
A couple of things come to mind with regards to your "example solution":

1. Will there only ever be one Person in working memory that can match and 
trigger your first rule? If not, setting a single boolean will only indicate 
that the first rule has fired at least once, not for each Person, or one 
Person, 
or two... or whatever your requirement is.

2. I usually accomplish this with a place holder fact or a fact created as an 
extension of a, for example your Person, class. This also acts as a place 
holder.

I agree, I don't like having duplicated code that is just negated because as we 
know, negating a "simple rule" can turn out to be not such a simple thing to do.

Earnie!





From: skasab2s 
To: rules-users@lists.jboss.org
Sent: Mon, July 19, 2010 12:57:39 PM
Subject: [rules-users] Avoiding writing redundant rules


Hello,

in our company we use DRL-files and we have the problem with the fact, that
rules have no 'else'-part. We've read in this forum, that we can simulate
the else-part of a rule by declaring a new rule which has the constraints of
the first rule, but  negated. We regard this as some kind of redundancy in
our code , besides our rule-files become twice as large and drools have to
evaluate the (almost) same constraints twice.

We wanted to ask you if it makes sense to declare additional variables in
order to mark if a rule has fired. Something like this:


declare FirstRuleHasFired
value: boolean
end

...
//Insert an object from type  FirstRuleHasFired

...

rule "FirstRule" salience 100
   when 
  Person (name)
   then
  //do some job 
firstRuleHasFired.setValue(true) ;  
end 

rule "SecondRule" salience 90
   when 
  not(FirstRuleHasFired(value == true))
   then
  //do some other job
  )
  ..


Or do you know some other useful tricks to avoid the redundancy I have
written about?

Thanks a lot for every idea and/or advice!

Regards,

skasab2s 
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Avoiding-writing-redundant-rules-tp979016p979016.html

Sent from the Drools - User 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] Inter-fact comparison

2010-06-23 Thread Earnest Dyke
Greg,

Thanks for the example. This should do what I need. Can you point me to some 
documentation on how to create custom operators?

Earnie!





From: Greg Barton 
To: Rules Users List 
Sent: Tue, June 22, 2010 4:29:50 PM
Subject: Re: [rules-users] Inter-fact comparison


A regular old accumulate could do this.  Doesn't even have to be custom:

rule "many bogus attempts"
when
$login : Login( $baseName : name)
$total : Number( intValue > 5 )
from accumulate( Login( this != login, eval(levenshtein(name, baseName) ),
init( int total = 0; ),
action( total++; ),
reverse( total--; ),
result( total ) )
then
//ALARM!
end

This basically says "accumulate all Logins where the name is within a 
levenshtein distance of a given Login and freak out if there's more than X."

This rule isn't all fusiony, but you get the idea.  Also, the eval in the 
accumulate could be a custom operator for readability.

--- On Tue, 6/22/10, Earnest Dyke  wrote:


>From: Earnest Dyke 
>Subject: Re: [rules-users] Inter-fact comparison
>To: "Rules Users List" 
>Date: Tuesday, June 22, 2010, 2:57 PM
>
>
>Thanks for the quick reply. 
>
>Yes, the original facts are already coming in via a stream (Fusion) to an 
>existing set of rules so I was hoping to build on that. What I am trying to do 
>is evaluate logins information as users are attempting to login trying to 
>identify hack attempts by a person trying to login with a slightly different 
>user name over a given period of time.
>
>Earnie!
>
>
>
>

From: David Sinclair 
>To: Rules Users List
> 
>Sent: Tue, June 22, 2010 3:47:36 PM
>Subject: Re: [rules-users] Inter-fact comparison
>
>>Hi Earnie,
>
>What you are explaining seems pretty straight forward and would more likely 
>than not be overkill to use a rule engine. Are there other aspects of the 
>system you are leaving out that warrant the use of Drools?
>
>dave
>
>
>2010/6/22 Earnest Dyke 
>
>Greetings all,
>>
>>I have a requirement to compare a set of facts against each other, calculate 
>>a value that indicates the amount of difference (Levenshtein distance) 
>>between a single attribute on each fact. So I load all of my facts into 
>>working memory then what? Do I execute a rule first that creates a new set of 
>>facts which is a Cartesian product of the original set of facts, each new 
>>fact containing a reference to two original facts and the diff between them? 
>>Looked at using a custom accumulate function but I don't think that's going 
>>to do what I need since it is intended to go through a set of facts and 
>>return a single value.
>>
>>Any and all related help is appreciated.
>>
>>Earnie! 
>>
>>___
>>>>rules-users mailing list
>>rules-users@lists.jboss.org
>>https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>-Inline Attachment Follows-
>
>
>___
>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] Inter-fact comparison

2010-06-22 Thread Earnest Dyke
Thanks for the quick reply. 

Yes, the original facts are already coming in via a stream (Fusion) to an 
existing set of rules so I was hoping to build on that. What I am trying to do 
is evaluate logins information as users are attempting to login trying to 
identify hack attempts by a person trying to login with a slightly different 
user name over a given period of time.

Earnie!





From: David Sinclair 
To: Rules Users List 
Sent: Tue, June 22, 2010 3:47:36 PM
Subject: Re: [rules-users] Inter-fact comparison

Hi Earnie,

What you are explaining seems pretty straight forward and would more likely 
than not be overkill to use a rule engine. Are there other aspects of the 
system you are leaving out that warrant the use of Drools?

dave


2010/6/22 Earnest Dyke 

Greetings all,
>
>I have a requirement to compare a set of facts against each other, calculate a 
>value that indicates the amount of difference (Levenshtein distance) between a 
>single attribute on each fact. So I load all of my facts into working memory 
>then what? Do I execute a rule first that creates a new set of facts which is 
>a Cartesian product of the original set of facts, each new fact containing a 
>reference to two original facts and the diff between them? Looked at using a 
>custom accumulate function but I don't think that's going to do what I need 
>since it is intended to go through a set of facts and return a single value.
>
>Any and all related help is appreciated.
>
>Earnie! 
>
>___
>>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] Inter-fact comparison

2010-06-22 Thread Earnest Dyke
Greetings all,

I have a requirement to compare a set of facts against each other, calculate a 
value that indicates the amount of difference (Levenshtein distance) between a 
single attribute on each fact. So I load all of my facts into working memory 
then what? Do I execute a rule first that creates a new set of facts which is a 
Cartesian product of the original set of facts, each new fact containing a 
reference to two original facts and the diff between them? Looked at using a 
custom accumulate function but I don't think that's going to do what I need 
since it is intended to go through a set of facts and return a single value.

Any and all related help is appreciated.

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


Re: [rules-users] How to Enrich Facts with Data from a Database

2009-07-30 Thread Earnest Dyke
Ken,

Neither solution makes any assumption about data storage. Hibernate entities 
could be used or simple POJOs, matters not. As to your Example, I have used 
something similar to the following:

public class Entity {

private String firstName;

public String getFirstName() { return firstName; }
public void setFirstname(String firstName) { this.firstName = firstName; }
}

public class FactEntity {
private Entity entity;
private String additionalAttribute;

public FactEntity(Entity entity) { this.entity = entity; }
public Entity getEntity() { return entity; }
public void setEntity(Entity entity) { this.entity = entity; }
public String getAdditionalAttribute() { return additionalAttribute; }
public void setAdditionalAttribute(String additionalAttribute) { 
this.additionalAttribute = additionalAttribute; }
}

In your class that inserts the Entity facts into working memory, you just;

FactEntity fe = new FactEntity(originalEntity);
workingMemory.insert(fe);

In your rule, you can then do something like;

rule
when
$fe : FactEntity(additionalAttribute == "Supervisor")
then
   System.out.println($fe.entity.firstName);
end


Earnie!



From: Ken Archer 
To: rules-users@lists.jboss.org
Sent: Thursday, July 30, 2009 9:13:35 AM
Subject: Re: [rules-users] How to Enrich Facts with Data from a Database

 Earnie,

Thanks for this.  Do your two solutions to fact enrichment presume use of the 
Hibernate framework to interact with a database in the rules? Would an example 
of your first solution be the following?

when
$w : WMFact($key : id)
$d : DatabaseFact(parentKey == $key)
then
$w.Field1=$d.Field1 AND $w.Field2=$d.Field2 AND $w.Field3=$d.Field3

Ken 


Date: Tue, 28 Jul 2009 09:35:47 -0700
From: earnied...@yahoo.com
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] How to Enrich Facts with Data from a Database


One way is to extend the original classes and add the desired attributes, then 
insert the extended class into WorkingMemory. You could then use RHS to modify 
matched facts. Another way is to inject "related" facts. So your LHS matches a 
fact and you insert a new "related" fact in the RHS. Rules that must evaluate 
data from both facts can the do something like this:

when
$b : BaseFact($key : id)
$r : RelatedFact(parentKey == $key)
then
...

I have used both albeit on small sets of facts and both worked fine.

Earnie!




From: Ken Archer 
To: rules-users@lists.jboss.org
Sent: Tuesday, July 28, 2009 12:22:37 PM
Subject: [rules-users] How to Enrich Facts with Data from a Database

 
I would like to append values to facts in working memory with
values from a database before rules processing.  The Fusion documentation
says, “one of the most common use cases for rules is event data enrichment”,
but no documentation seems to explain how this is done whether we’re talking
about events or just plain old facts.  And the RHS syntax seems to be
limited to working with data already in working memory.  How can I enrich
facts with data from another system?  Thanks in advance.
 
Ken Archer
Telogical Systems___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to Enrich Facts with Data from a Database

2009-07-28 Thread Earnest Dyke
One way is to extend the original classes and add the desired attributes, then 
insert the extended class into WorkingMemory. You could then use RHS to modify 
matched facts. Another way is to inject "related" facts. So your LHS matches a 
fact and you insert a new "related" fact in the RHS. Rules that must evaluate 
data from both facts can the do something like this:

when
$b : BaseFact($key : id)
$r : RelatedFact(parentKey == $key)
then
...

I have used both albeit on small sets of facts and both worked fine.

Earnie!




From: Ken Archer 
To: rules-users@lists.jboss.org
Sent: Tuesday, July 28, 2009 12:22:37 PM
Subject: [rules-users] How to Enrich Facts with Data from a Database

 
I would like to append values to facts in working memory with
values from a database before rules processing.  The Fusion documentation
says, “one of the most common use cases for rules is event data enrichment”,
but no documentation seems to explain how this is done whether we’re talking
about events or just plain old facts.  And the RHS syntax seems to be
limited to working with data already in working memory.  How can I enrich
facts with data from another system?  Thanks in advance.
 
Ken Archer
Telogical Systems___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] setFocus

2009-06-12 Thread Earnest Dyke
I vote helper method. :-)

Earnie!





From: Edson Tirelli 
To: Rules Users List 
Sent: Friday, June 12, 2009 11:59:40 AM
Subject: Re: [rules-users] setFocus


   getAgenda().getAgendaGroup(String group).setFocus();

   We are still discussing if we should create a helper method for this or 
keeping it normalized like that is good enough.

   []s
   Edson


2009/6/12 Earnest Dyke 

Converting a 4.0.7 project to 5.0.1 and StatefulKnowledgeSession does not have 
a .setFocus method like StatefulSession has. How do I accomplish the same 
function in 5.0.1?
>
>Earnie!
>
>___
>>rules-users mailing list
>rules-users@lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] setFocus

2009-06-12 Thread Earnest Dyke
Thanks Wolfgang. As usually happens I found this 10 minutes after I sent the 
email. :-)

Earnie!





From: Wolfgang Laun 
To: Rules Users List 
Sent: Friday, June 12, 2009 11:49:31 AM
Subject: Re: [rules-users] setFocus


For instance:

ksession.getAgenda().getAgendaGroup( "Group A" ).setFocus();

-W


2009/6/12 Earnest Dyke 

Converting a 4.0.7 project to 5.0.1 and StatefulKnowledgeSession does not have 
a .setFocus method like StatefulSession has. How do I accomplish the same 
function in 5.0.1?
>
>Earnie!
>
>___
>>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] setFocus

2009-06-12 Thread Earnest Dyke
Converting a 4.0.7 project to 5.0.1 and StatefulKnowledgeSession does not have 
a .setFocus method like StatefulSession has. How do I accomplish the same 
function in 5.0.1?

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


[rules-users] 5.0 newbie question

2009-06-10 Thread Earnest Dyke
Greetings all,

I just downloaded 5.0 yesterday and have been going through the doc and have a 
question: with Rules is the idea to have one active flow per session or can a 
session have more than one active flow?

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


Re: re[rules-users] move hardcoded values in DRL or have constants inside drl

2009-06-01 Thread Earnest Dyke
Wolfgang makes a good point. However, given the requirement that the value 
changes and is not truly static, I would recommend something like the following 
which, if your SearchParm loads the data from a persisted source you could 
change it's value without any code change.

Earnie!

package com.sample

rule "Test Rule"
   
when
SearchParam($searchName : searchName)
$person : Person(name == $searchName)
then
System.out.println(drools.getRule().getName() + " [" + $searchName + "] 
[" + $person.getName() + "]");
$person.setActivation(true);  
end

package com.sample;

public class Person {
private String name;
private Boolean activation;

public Person(String name, Boolean activation) {
this.name = name;
this.activation = activation;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Boolean getActivation() {
return activation;
}

public void setActivation(Boolean activation) {
this.activation = activation;
}

}
package com.sample;

public class SearchParam {
private String searchName;

public SearchParam(String searchName) {
super();
this.searchName = searchName;
}

public String getSearchName() {
return searchName;
}

public void setSearchName(String searchName) {
this.searchName = searchName;
}

}


package com.sample;

import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Properties;

import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.rule.Package;
import org.drools.rule.builder.dialect.java.JavaDialectConfiguration;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;


public class GlobalTest {
private RuleBase ruleBase;

@Test
public void testWithGlobal() {
StatefulSession ss = ruleBase.newStatefulSession();
Person p = new Person("John",false);
ss.insert(p);
SearchParam sp = new SearchParam("John");
ss.insert(sp);
ss.fireAllRules();
assertTrue(p.getActivation().equals(true));
}
@Before
public void buildRules() throws Exception {
Reader source = new InputStreamReader(this.getClass()
.getResourceAsStream("/test.drl"));

Properties props = new Properties();
props.setProperty("drools.dialect.java.compiler", "JANINO");
PackageBuilderConfiguration cfg = new 
PackageBuilderConfiguration(props);
JavaDialectConfiguration javaConf = (JavaDialectConfiguration) cfg
.getDialectConfiguration("java");
javaConf.setCompiler(JavaDialectConfiguration.JANINO);
PackageBuilder builder = new PackageBuilder(cfg);

builder.addPackageFromDrl(source);

Package pkg = builder.getPackage();

ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
}
}




From: Wolfgang Laun 
To: Rules Users List 
Sent: Monday, June 1, 2009 7:57:36 AM
Subject: Re: re[rules-users] move hardcoded values in DRL or have constants  
inside drl

But assigning a value to a global isn't straightforward - you can't do
it in the declaration. You'll have to do it from the application (or
use some dirty hack, in a start-up rule); either way it's separate
from the declaration.

IMHO, using a Java class with public static final is definitely cleaner.

-W


2009/6/1 Earnest Dyke :
> How about adding them as Globals and referencing them that way? You should
> be able to put them in a map as well in a Global and reference them.
>
> Earnie!
>
> 
> From: karthizap 
> To: rules-users@lists.jboss.org
> Sent: Monday, June 1, 2009 7:14:56 AM
> Subject: re[rules-users] move hardcoded values in DRL or have constants
> inside drl
>
> Is there is anyway i can remove hardcoded values in the DRL file? Can I have
> the constants file(like data dictionary) inside drl/functions. I don't want
> to refer java constants class directly in drl file and would like to declare
> and refer those constants inside drl file.
> 
> View this message in context: remove hardcoded values in DRL or have
> constants inside drl
> Sent from the drools - user 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: re[rules-users] move hardcoded values in DRL or have constants inside drl

2009-06-01 Thread Earnest Dyke
How about adding them as Globals and referencing them that way? You should be 
able to put them in a map as well in a Global and reference them.

Earnie!





From: karthizap 
To: rules-users@lists.jboss.org
Sent: Monday, June 1, 2009 7:14:56 AM
Subject: re[rules-users] move hardcoded values in DRL or have constants inside 
drl

Is there is anyway i can remove hardcoded values in the DRL file? Can I have 
the constants file(like data dictionary) inside drl/functions.  I don't want to 
refer java constants class directly in drl file and would like to declare and 
refer those constants inside drl file. 

 View this message in context: remove hardcoded values in DRL or have constants 
inside drl
Sent from the drools - user 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] Drools and OpenJPA

2009-05-07 Thread Earnest Dyke
As an update: I tried several things to remedy this problem. I tried adding the 
classloader to the JPA classes to the RuleBaseConfiguration but that had no 
effect. After much code digging, debugging and research I decided to 
setShadowProxy(false) on the RuleBaseConfiguration and low-and-behold things 
worked. No sure why Drools can't create the proxies for the JPA classes. I will 
save that for the next rainy day.

Earnie1





From: Earnest Dyke 
To: JBoss Rules 
Sent: Wednesday, May 6, 2009 11:15:10 AM
Subject: [rules-users] Drools and OpenJPA


Greetings all,

I am trying to use Drools 4.0.7 with objects that are retrieved via OpenJPA. So 
I have a Person entity which is in the package com.my.company.entity. When I 
retrieve it via OpenJPA what I get, and subsequently insert into working 
memory, is a 
org.apache.openjpa.enhance.com$my$company$entity$Person$pcsubclass. I have 
tried casting before inserting into working memory but that does not change 
things. Drools is throwing java.lang.NoClassDefFoundError: 
org/apache/openjpa/enhance/com$my$company$entity$Person$pcsubclass exception. 

Any ideas of how to get around this? I really don't want to have to declare the 
concrete (OpenJPA) classes in my rules if I can help it.

Thanks in advance for any and all help!

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


[rules-users] Drools and OpenJPA

2009-05-06 Thread Earnest Dyke
Greetings all,

I am trying to use Drools 4.0.7 with objects that are retrieved via OpenJPA. So 
I have a Person entity which is in the package com.my.company.entity. When I 
retrieve it via OpenJPA what I get, and subsequently insert into working 
memory, is a 
org.apache.openjpa.enhance.com$my$company$entity$Person$pcsubclass. I have 
tried casting before inserting into working memory but that does not change 
things. Drools is throwing java.lang.NoClassDefFoundError: 
org/apache/openjpa/enhance/com$my$company$entity$Person$pcsubclass exception. 

Any ideas of how to get around this? I really don't want to have to declare the 
concrete (OpenJPA) classes in my rules if I can help it.

Thanks in advance for any and all help!

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


Re: [rules-users] listbox in DSL

2009-05-02 Thread Earnest Dyke
Do you want to use Drools to determine which elements are added to the listbox?

Earnie!





From: sreenivas555 
To: rules-users@lists.jboss.org
Sent: Wednesday, April 22, 2009 8:58:09 AM
Subject: [rules-users] listbox in DSL


Hi All,

I want to create a listbox (multi selections) using DSL. is it possible? 
If yes, please provide some pointers. 

I am using Drools 5, JDK 1.5 , jboss-eap-4.3

Thanks in advance. 
-- 
View this message in context: 
http://www.nabble.com/listbox-in-DSL-tp23175424p23175424.html
Sent from the drools - user 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] Old messages

2009-05-02 Thread Earnest Dyke
Is anyone else receiving old list messages? I have received over 20 with some 
dated as far back as June 2008.

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


Re: [rules-users] Using rules engine to find patterns in time series data

2009-04-17 Thread Earnest Dyke
Not sure what type of data you expect to get back. Are you looking for all the 
objects that make up an "event" of just the fact (no pun intended) that the 
event has occured?

Earnie!





From: "Towler, Robert [RA]" 
To: rules-users@lists.jboss.org
Sent: Friday, April 17, 2009 11:19:31 AM
Subject: [rules-users] Using rules engine to find patterns in time series data

 
I’m looking at the rules engine as a mechanism to find
patterns in some time series data.
 
I’m looking for things like there where N spikes above
a certain threshold value in a certain period of time.
 
I was wondering if anyone has done this, or have any ideas
on how best to do this with the rules engine.
 
My own ideas & the prototype I’ve built seem to be
really procedural, so I’m wondering if there’s a better way that I’m
missing.
 
Robert___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to clone object inside a rule

2009-04-01 Thread Earnest Dyke
Override and implement the clone method of the class you want to clone/copy 
then in the RHS of your rule do:

SomeClass copy = $someclass.clone();

Earnie!





From: Ashish Soni 
To: Rules Users List 
Sent: Wednesday, April 1, 2009 9:50:25 AM
Subject: [rules-users] How to clone object inside a rule

Hi All , 

I want to clone/copy one object inside a rule depends on some condition , 
Please let me know how i can do that ?


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


Re: [rules-users] Guvnor and 'from' database

2009-03-27 Thread Earnest Dyke
Could you do the same thing with an entity manager?

Earnie!





From: Mark Proctor 
To: Rules Users List 
Sent: Friday, March 27, 2009 2:09:19 PM
Subject: Re: [rules-users] Guvnor and 'from' database

a...@work wrote:
> I am trying to use drools to evaluate the following rule:
> 
> Given a telephone number, if the telephone number already exists in database
> and has a balance > 0, set isAllowed = false. 
> Looking at forum posts I understand that this can be achieved using
> hibernate and 'from' keyword. However, this is my current scenario - I
> create a package snapshot for my rules in Guvnor and use the URL in Drools
> execution server. Execution server runs only stateless sessions. 
> Where and how do I use hibernate named queries?  
set the hibernate session as a global and then the 'from' can access it.
> Thx,
> Anu
> 
> 
>  


___
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] Chart notation, update, and infinite loops

2008-11-04 Thread Earnest Dyke
Dan,

Why would you have more than one Charge when you are not qualifying it? Are 
they all the same? Do you not care which one matches?

Earnie!




From: Dan Seaver <[EMAIL PROTECTED]>
To: rules-users@lists.jboss.org
Sent: Tuesday, November 4, 2008 12:50:09 PM
Subject: [rules-users] Chart notation, update, and infinite loops


I'm trying to find a good technique for updating specific facts in working
memory. What I'm currently doing is something like this:

Rule "Update Amount"
   when
  amountFact : Fact(name == "Amount")
  charge : Charge()
   then
  Double amount = amountFact.getAmount();
  Double chargeAmount = charge.getAmount();
  amountFact.setAmount(amount + chargeAmount);
  update(amountFact);
end

The update statement causes an infinite loop.
I tried using no-loop, which works if there is 1 charge, but not if there
are more than one.

Any help with solutions or strategies would be much appreciated.
-- 
View this message in context: 
http://www.nabble.com/Chart-notation%2C-update%2C-and-infinite-loops-tp20327483p20327483.html
Sent from the drools - user 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] Newbie question on accessing predecessor and successor in a list

2008-11-04 Thread Earnest Dyke
Chris,

You wouldn't necessarily need to clone you business objects. If you create 
classes that had them as attributes and injected your "new" classes into the 
rules engine, you could accomplish both goals: no parallel model and classes 
that support the needs of your rules.

Earnie!





From: CSchr <[EMAIL PROTECTED]>
To: rules-users@lists.jboss.org
Sent: Tuesday, November 4, 2008 11:58:22 AM
Subject: Re: [rules-users] Newbie question on accessing predecessor and 
successor in a list


Yes that's correct. No way to change the model yet. But I think I could
introduce additional objects and could even "clone" the business objects
into more convenient objects just for rule evaluation. But this would be my
least prefered solution as it would introduce a layer of transformation and
a parallel (mirror) model that needs to be updated whenever the business
model changes in future releases.

Regards,

Chris


Greg Barton wrote:
> 
> I think you'd have to toss in ControlFact instances with positions from 1
> to journey.segmentList.size-1 for this to work.  Otherwise the evaluation
> of the journey.segmentList would halt on the first failure of the rule to
> match.  Then the modify block wouldn't be needed in the action.
> 
> Also, CSchr, you mentioned that the business model could not be altered. 
> Does that mean you can't use additional objects like control facts?  
> 
> --- On Tue, 11/4/08, Edson Tirelli <[EMAIL PROTECTED]> wrote:
> 
>> From: Edson Tirelli <[EMAIL PROTECTED]>
>> Subject: Re: [rules-users] Newbie question on accessing predecessor and
>> successor in a list
>> To: "Rules Users List" 
>> Date: Tuesday, November 4, 2008, 8:56 AM
>> Christian,
>> 
>>My guess is that there are better approaches to do what
>> you want (i.e.,
>> write your business rules) without using specific indexes
>> in a list, since
>> that is usually a sign of trying to use a imperative
>> algorithm in a
>> declarative engine.
>>If you can share a mock of what your business rule is,
>> maybe we can help
>> more.
>> 
>>Having said that, about your questions:
>> 
>> * You can use eval inside patterns. Just remember that
>> eval() uses a code
>> block in the same dialect you are using to write your rules
>> (default is
>> java). So, $journey.segmentList is probably not valid in
>> java (since
>> segmentList is probably private attribute), but is valid in
>> MVEL that
>> transparently call getSegmentList(). So, either change your
>> expression to a
>> correct java expression or change the rule dialect to MVEL.
>> 
>> * DISCLAIMER: THIS IS REALLY BAD PRACTICE: if you really
>> want to emulate
>> "imperative programming" for this rule, you need
>> a control fact to keep
>> track of the index you are testing:
>> 
>> rule "Children: do not do this at home, unless your
>> parents says it is ok"
>> when
>> $cf : ControlFact( $pos : position <
>> $journey.segmentList.size )
>> $s : Segment( countries contains Country.Switzerland,
>> ... ) from
>> $journey.segmentList[$pos]
>> $ps : Segment( countries not contains
>> Country.Switzerland, ... ) from
>> $journey.segmentList[$pos-1]
>> then
>> // do something
>> // and also update control fact
>> modify( $cf ) { setPosition( $pos + 1 ) }
>> end
>> 
>> Initialize control fact with position number 1 and it
>> should be fine, but I
>> did not tested the above rule.
>> 
>>[]s
>>Edson
>> 
>> 
>> 2008/11/4 CSchr <[EMAIL PROTECTED]>
>> 
>> >
>> > Thanks Greg for your fast reply. Unfortunately I do
>> not get this to work:
>> >
>> > $preSegment : Segment (
>> >  
>> $journey.segmentList.indexOf(this) ==
>> > ($journey.segmentList.indexOf($segment) - 1),
>> >countries not contains
>> Country.Switzerland && ...
>> > ) from $journey.segmentList
>> >
>> > Compiler throws:
>> >
>> > [36,48]: unknown:36:48 Unexpected token
>> 'this'[36,98]: unknown:36:98
>> > Unexpected token '$segment'
>> >
>> > Is it possible to use eval() inside Segment ()?
>> >
>> > With eval the compiler throws something like this:
>> >
>> > $journey.segmentList cannot be resolved to a type
>> > Cannot use this in a static context
>> >
>> > I don't know how matching works in drools, but
>> wouldn't this also be very
>> > expensive? As for every match of Segment ( ) the
>> segmentList has to be
>> > iterated two times. These lists can get very long. A
>> cheap approach would
>> > be
>> > if the from statement would "know" the index
>> of the Segment () matched. I
>> > was hoping this would be possible.
>> >
>> >
>> > Regards,
>> >
>> > Chris
>> >
>> >
>> > Greg Barton wrote:
>> > >
>> > > You can't do
>> $journey.segmentList.indexOf(this) and
>> > > $journey.segmentList.indexOf($segment), even in
>> an eval?
>> > >
>> > > --- On Mon, 11/3/08, CSchr
>> <[EMAIL PROTECTED]> wrote:
>> > >
>> > >> From: CSchr
>> <[EMAIL PROTECTED]>
>> > >> Subject: [rules-users] Newbie question on
>> accessing predeces

Re: [rules-users] Problem with setting a Global

2008-09-11 Thread Earnest Dyke
Thanks for the response. I have tried that actually. Left it out of the code 
snippet by accident. I  have tired both:

import org.jboss.seam.log.Log

global Log log


as well as:

global import org.jboss.seam.log.Log log

and neither made a difference. 

Earnie!


- Original Message 
From: Ingomar Otter <[EMAIL PROTECTED]>
To: Rules Users List 
Sent: Thursday, September 11, 2008 12:42:43 PM
Subject: Re: [rules-users] Problem with setting a Global

You have to declare the global in the rule package.

global foo.bar.Logger  logger;

--Ingomar
Am 11.09.2008 um 18:24 schrieb Earnest Dyke:

> Greetings all,
>
> I have the following Java code and rule. When executed I get an  
> "Unexpected Global" exception (see below). What am I doing wrong?
>
> 
> @In WorkingMemory wm
>
> @Logger Log log;
>
> public void calculate() {
>wm.setGlobal("logger",log);
>wm.insert(calcResult);
>wm.fireAllRules();
> }
>
>
> rule "Calc"
>when
>$c : CalcResult();
> then
>log(drools.getRule().getName(),log);
>// Do calculation
> end
>
> function void log(String msg, Log log) {
>log.debug(msg,new Object[]{});
> }
>
> When the calculate method is executed I get the following exception:
>
>
> java.lang.RuntimeException: Unexpected global [logger]
> at  
> org 
> .drools 
> .common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java: 
> 367)
> at  
> org.ebsinc.ia.action.AnalysisAction.createData(AnalysisAction.java:93)
> 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:585)
> at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
> at  
> org 
> .jboss 
> .seam 
> .intercept.RootInvocationContext.proceed(RootInvocationContext.java: 
> 31)
> at  
> org 
> .jboss 
> .seam 
> .intercept.SeamInvocationContext.proceed(SeamInvocationContext.java: 
> 56)
> at  
> org 
> .jboss 
> .seam 
> .core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
> at  
> org 
> .jboss 
> .seam 
> .intercept.SeamInvocationContext.proceed(SeamInvocationContext.java: 
> 68)
> at  
> org 
> .jboss 
> .seam 
> .persistence 
> .ManagedEntityIdentityInterceptor 
> .aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
> at  
> org 
> .jboss 
> .seam 
> .intercept.SeamInvocationContext.proceed(SeamInvocationContext.java: 
> 68)
> at  
> org 
> .jboss 
> .seam 
> .transaction 
> .RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
> at  
> org 
> .jboss 
> .seam 
> .intercept.SeamInvocationContext.proceed(SeamInvocationContext.java: 
> 68)
> at  
> org 
> .jboss 
> .seam 
> .core 
> .MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java: 
> 42)
> at  
> org 
> .jboss 
> .seam 
> .intercept.SeamInvocationContext.proceed(SeamInvocationContext.java: 
> 68)
> at  
> org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java: 
> 106)
> at  
> org 
> .jboss 
> .seam 
> .intercept 
> .JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
> at  
> org 
> .jboss 
> .seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java: 
> 91)
> at org.ebsinc.ia.action.AnalysisAction_$ 
> $_javassist_9.createData(AnalysisAction_$$_javassist_9.java)
> 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:585)
> at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
> at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java: 
> 125)
> at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
> at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
> at org.jboss.seam.Component.newInstance(Component.java:1968)
> at org.jboss.seam.Component.getInstance(Component.java:1865)
> at org.jboss.seam.Component.getInstance(Component.java:1832)
> at org.jboss.seam.Component.getInstanceFromFactory(Component.java: 
> 1911)
> at org.jboss.seam.Compone

[rules-users] Problem with setting a Global

2008-09-11 Thread Earnest Dyke
Greetings all,

I have the following Java code and rule. When executed I get an "Unexpected 
Global" exception (see below). What am I doing wrong?


@In WorkingMemory wm

@Logger Log log;

public void calculate() {
wm.setGlobal("logger",log);
wm.insert(calcResult);
wm.fireAllRules();
}


rule "Calc"
when 
$c : CalcResult();
 then
log(drools.getRule().getName(),log);
// Do calculation
end

function void log(String msg, Log log) {
log.debug(msg,new Object[]{});
}

When the calculate method is executed I get the following exception:


java.lang.RuntimeException: Unexpected global [logger]
at 
org.drools.common.AbstractWorkingMemory.setGlobal(AbstractWorkingMemory.java:367)
at 
org.ebsinc.ia.action.AnalysisAction.createData(AnalysisAction.java:93)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at 
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at 
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:46)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.persistence.ManagedEntityIdentityInterceptor.aroundInvoke(ManagedEntityIdentityInterceptor.java:48)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:31)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at 
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
at 
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
at 
org.ebsinc.ia.action.AnalysisAction_$$_javassist_9.createData(AnalysisAction_$$_javassist_9.java)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
at org.jboss.seam.Component.newInstance(Component.java:1968)
at org.jboss.seam.Component.getInstance(Component.java:1865)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1911)
at org.jboss.seam.Component.getInstance(Component.java:1855)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
at org.jboss.seam.Namespace.get(Namespace.java:28)
at 
org.jboss.seam.el.SeamELResolver.resolveInNamespace(SeamELResolver.java:197)
at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:57)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at 
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at 
org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
at 
org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at 
com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
at 
javax.faces.component.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:102)
at com.sun.facelets.component.UIRepeat.getValue(UIRepeat.java:143)
at com.sun.facelets.component.UIRepeat.getDataModel(UIRepeat.java:121)
at com.sun.facelets.component.UIRepeat.setIndex(UIRepeat.java:305)
at com.sun.facelets.component.UIRepeat.process(UIRepeat.java:333)
at com.sun.

[rules-users] Drools problem in Seam

2008-08-26 Thread Earnest Dyke
Greetings all,

I posted this to the Seam users forum and they recommended I post it here as 
well.

I am using Seam 2.0.0 and Drools 4.0.7. I am getting the following exception 
when my rule is compiled on first access. 

Rule:

package org.ebsinc.ia.rules

#list any import classes here.

import org.ebsinc.ia.entity.BenefitAnalysis;
import org.ebsinc.ia.entity.RetirementEligibility;

#declare any global variables here

rule "Verify FERS"
when
$ba : BenefitAnalysis(plan == "FERS")
$elig : RetirementEligibility(eligible == false)
then 
System.out.println("FERS retirement");
$elig.setReason("ok");
end


components.xml



/security.drl





/RetirementEligibility.drl




Exception:

2008-08-26
08:40:37,750 ERROR [STDERR] at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:123)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at 
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at 
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:58)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
at org.jboss.seam.Component.newInstance(Component.java:1968)
at org.jboss.seam.Component.getInstance(Component.java:1865)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at 
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
at 
org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
at 
org.jboss.seam.drools.ManagedWorkingMemory.getRuleBaseFromValueBinding(ManagedWorkingMemory.java:78)
at 
org.jboss.seam.drools.ManagedWorkingMemory.getStatefulSession(ManagedWorkingMemory.java:67)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.unwrap(Component.java:2100)
at org.jboss.seam.Component.getInstance(Component.java:1879)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at 
org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2174)
at org.jboss.seam.Component.getValueToInject(Component.java:2126)
at org.jboss.seam.Component.injectAttributes(Component.java:1590)
at org.jboss.seam.Component.inject(Component.java:1408)
at 
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at 
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
at 
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
at 
org.ebsinc.ia.action.AgentActi

[rules-users] Drools problem in Seam

2008-08-26 Thread Earnest Dyke
Greetings all,

I posted this to the Seam users forum and they recommended I post it here as 
well.

I am using Seam 2.0.0 and Drools 4.0.7. I am getting the following exception 
when my rule is compiled on first access. 

Rule:

package org.ebsinc.ia.rules

#list any import classes here.

import org.ebsinc.ia.entity.BenefitAnalysis;
import org.ebsinc.ia.entity.RetirementEligibility;

#declare any global variables here

rule "Verify FERS"
when
$ba : BenefitAnalysis(plan == "FERS")
$elig : RetirementEligibility(eligible == false)
then 
System.out.println("FERS retirement");
$elig.setReason("ok");
end


components.xml



/security.drl





/RetirementEligibility.drl




Exception:

2008-08-26
08:40:37,750 ERROR [STDERR] at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:123)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at 
org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at 
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:58)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
at org.jboss.seam.Component.newInstance(Component.java:1968)
at org.jboss.seam.Component.getInstance(Component.java:1865)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at 
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
at 
org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
at 
org.jboss.seam.drools.ManagedWorkingMemory.getRuleBaseFromValueBinding(ManagedWorkingMemory.java:78)
at 
org.jboss.seam.drools.ManagedWorkingMemory.getStatefulSession(ManagedWorkingMemory.java:67)
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:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.unwrap(Component.java:2100)
at org.jboss.seam.Component.getInstance(Component.java:1879)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at 
org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2174)
at org.jboss.seam.Component.getValueToInject(Component.java:2126)
at org.jboss.seam.Component.injectAttributes(Component.java:1590)
at org.jboss.seam.Component.inject(Component.java:1408)
at 
org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at 
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at 
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at 
org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
at 
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
at 
org.ebsinc.ia.action.AgentActi