Problems with rules not firing
by Paul Smith
Hi Guys,
I've got a series of rules that compile fine but no rules seem to fire. The
following is the rule file
/**************************
Working times rules
***************************/
package au.com.codeprotechnology.online.ejb3.logic.crm
import au.com.codeprotechnology.online.bi.exception.ValidationError
import au.com.codeprotechnology.online.persistence.ejb.crm.WorkingTimes
import
au.com.codeprotechnology.online.ejb3.logic.constants.WorkingTimesConstants
import java.util.Calendar
rule "Invalid day of week"
when
obj : WorkingTimes(val : primaryKey -> (val.getDayId() == null ||
val.getDayId().intValue() < Calendar.SUNDAY || val.getDayId().intValue() >
Calendar.SATURDAY))
then
obj.addValidationError(new ValidationError(
WorkingTimesConstants.MSG_KEY_INVALID_DAY_OF_WEEK,
WorkingTimesConstants.MSG_INVALID_DAY_OF_WEEK));
end
rule "Invalid start hour"
when
obj : WorkingTimes(val : startHour -> (val.intValue() <
WorkingTimesConstants.MIN_HOUR || val.intValue() >
WorkingTimesConstants.MAX_HOUR))
then
obj.addValidationError(new ValidationError(
WorkingTimesConstants.MSG_KEY_INVALID_START_HOUR,
WorkingTimesConstants.MSG_INVALID_START_HOUR));
end
rule "Invalid start min"
when
obj : WorkingTimes(val : startMin -> (val.intValue() <
WorkingTimesConstants.MIN_MINUTE || val.intValue() >
WorkingTimesConstants.MAX_MINUTE))
then
obj.addValidationError(new ValidationError(
WorkingTimesConstants.MSG_KEY_INVALID_START_MIN,
WorkingTimesConstants.MSG_INVALID_START_MIN));
end
rule "Invalid stop hour"
when
obj : WorkingTimes(val : stopHour -> (val.intValue() <
WorkingTimesConstants.MIN_HOUR || val.intValue() >
WorkingTimesConstants.MAX_HOUR))
then
obj.addValidationError(new ValidationError(
WorkingTimesConstants.MSG_KEY_INVALID_STOP_HOUR,
WorkingTimesConstants.MSG_INVALID_STOP_HOUR));
end
rule "Invalid stop min"
when
obj : WorkingTimes(val : stopMin -> (val.intValue() <
WorkingTimesConstants.MIN_MINUTE || val.intValue() >
WorkingTimesConstants.MAX_MINUTE))
then
obj.addValidationError(new ValidationError(
WorkingTimesConstants.MSG_KEY_INVALID_STOP_MIN,
WorkingTimesConstants.MSG_INVALID_STOP_MIN));
end
And this is the object I'm trying to assert
package au.com.codeprotechnology.online.persistence.ejb.crm;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import au.com.codeprotechnology.online.persistence.AbstractPersistenceBean;
@Entity
@Table(name = "WORKING_TIMES")
public class WorkingTimes extends AbstractPersistenceBean implements
Serializable {
private static final long serialVersionUID = -4972337627878376131L;
private WorkingTimesPK primaryKey;
private Integer startHour;
private Integer stopMin;
private Integer stopHour;
private Integer startMin;
public WorkingTimes() {
this.primaryKey = new WorkingTimesPK();
}
@EmbeddedId
public WorkingTimesPK getPrimaryKey() {
return primaryKey;
}
public void setPrimaryKey(WorkingTimesPK primaryKey) {
this.primaryKey = primaryKey;
}
@Column(name = "START_HOUR")
public Integer getStartHour() {
return startHour;
}
public void setStartHour(Integer startHour) {
this.startHour = startHour;
}
@Column(name = "START_MIN")
public Integer getStartMin() {
return startMin;
}
public void setStartMin(Integer startMin) {
this.startMin = startMin;
}
@Column(name = "STOP_HOUR")
public Integer getStopHour() {
return stopHour;
}
public void setStopHour(Integer stopHour) {
this.stopHour = stopHour;
}
@Column(name = "STOP_MIN")
public Integer getStopMin() {
return stopMin;
}
public void setStopMin(Integer stopMin) {
this.stopMin = stopMin;
}
@Embeddable
public static class WorkingTimesPK implements Serializable {
private static final long serialVersionUID = -567654057787556805L;
private Long supplierId;
private Integer dayId;
@Column(name = "DAY_ID")
public Integer getDayId() {
return dayId;
}
public void setDayId(Integer dayId) {
this.dayId = dayId;
}
@Column(name = "PREF_ID")
public Long getSupplierId() {
return supplierId;
}
public void setSupplierId(Long supplierId) {
this.supplierId = supplierId;
}
}
/**
* Not Implemented
*/
@Transient
public Long getId() {
return null;
}
public void setId(Long id) {
}
}
I've got stacks of similar rules and entity beans and it all works fine but
this one doesn't seem to want to play. Does anybody have any ideas as to
what is missing?
17 years, 5 months
How to stop a rule from firing?
by McShiv
Hi,
I am using Drools 3.0.6. The rule is given below.
Rule:
[when] condition1 = \\someCondition;
[then] assert the Object1 into Working Memory;
[when] condition2 = \\someCondition;
[then] set the Error Message.
[when] condition3 = \\someCondition;
[then] assert the Object2 into Working Memory;
[when] condition4 = \\someCondition;
[then] Set the Error Message.
By requirement is when the condition2 is satisfied, the error code should be
set and the following rules should not fire. If the condition2 is not
satisfied, it goes to the condition3 and condition4. If condition4
satisfies, it should set the error code and stop firing the rules again.
I dont know how to stop the rules from firing after the error code is set in
the condition2.
Can someone help me on this issue.
Thanks & Regards
McShiv.........
--
View this message in context: http://www.nabble.com/How-to-stop-a-rule-from-firing--tf3961519.html#a112...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 5 months
Question on date literal constraint
by Sarika Khamitkar
I have the rule set up as follows, but the rule does not fire.
rule file:
package test
import test.Field;
rule "test date literal"
when
field : Field(dateValue >= "06-Nov-2005")
then
System.out.println("**Rule fired**");
end
java class:
package test;
import java.util.Date;
public Field
{
protected Date dateValue;
public Date getDateValue()
{
return dateValue;
}
public void setDateValue(Date dateValue)
{
this.dateValue = dateValue;
}
}
Before firing the rule, I assert the Field object as follows:
.....
Field field = new Field();
SimpleDateFormat sf = new SimpleDateFormat("dd-MMM-yyyy");
field.setDateValue(sf.parse("06-Nov-2005));
workingMemory.assertObject(field);
workingMemory.fireAllRules();
.....
I am using 4.0 MR2. Can anyone please let me know how to resolve this?
Thank you.
17 years, 5 months
probleam in breaking conditions into multiple lines in DSL
by kingston
Hi
i have written many rules in DRL . These rules look like
when
<condition1> ||
<condition2> &&
<condition3> ||
<condition4>
Then
<some action>
end;
I am trying to rewrite these rules in DSL format .
I tried something like this :
I added the english text before the statement for condition1 and used
variables for passing input values. and in the rule file ( .drl file ) i had
the english text along with the input value in the place for the variable.
Finally i could make the dsl syntax work onlly when i had all the conditions
on a single line using "eval". This looks pretty long. The syntax provided
in Drools documentaion " [when]- " works fine for "AND" conditions
How do i break my conditions in the dsl format on each new line with all my
logical conditions "AND" , "OR" intact ? Do we have any other options for
breaking into new line ? Is there any work around for that ? How do I handle
"OR" conditions?
Thanks.
--
View this message in context: http://www.nabble.com/probleam-in-breaking-conditions-into-multiple-lines...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 5 months
RE:[ rules-users] 4.0.0MR2 Beeta?
by Sikkandar Nawabjan
Hi,
am bit confused about 4.0.0MR2.
It is a official release i assume.
But the name(milestone) seems it is a Beeta release.
is it really a beeta version?If so when will be the standard edition planned to release?
Thanks and Regs,
Basha
________________________________
From: rules-users-bounces(a)lists.jboss.org on behalf of rules-users-request(a)lists.jboss.org
Sent: Tue 6/19/2007 10:26 AM
To: rules-users(a)lists.jboss.org
Subject: rules-users Digest, Vol 7, Issue 48
Send rules-users mailing list submissions to
rules-users(a)lists.jboss.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
rules-users-request(a)lists.jboss.org
You can reach the person managing the list at
rules-users-owner(a)lists.jboss.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."
Today's Topics:
1. NoMuchMethod - But there is! (Steven Waldren)
2. RE: NullPointerException:
org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(BaseObjectClassFieldExtractor.java:103)
(Prakash Galagali)
----------------------------------------------------------------------
Message: 1
Date: Mon, 18 Jun 2007 13:56:06 -0500
From: Steven Waldren <swaldren(a)gmail.com>
Subject: [rules-users] NoMuchMethod - But there is!
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID: <E5573FD8-A6C0-4206-8F86-23CCA07E8952(a)gmail.com>
Content-Type: text/plain; charset="us-ascii"
Hello,
I downloaded the JBoss Rules 4.0 Eclipse IDE. I built a small
project with about 120 rules. My test asserts around 500 objects.
When I try to add one more rule (regardless of the content of the
rule) I get the error below, stating no such method error. Even if I
add the following rule, I still get the error:
rule "new rule"
when
Object()
then
System.out.print("test");
end
What other problems can throw these errors?
Thanks,
Steven
--
Steven E. Waldren, M.D., M.S.
OpenHealth Data
Skype: steven.waldren
======= THE ERROR ==========
java.lang.NoSuchMethodError:
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()
[Lorg/eclipse/jdt/core/compiler/CategorizedProblem;
at org.apache.commons.jci.compilers.EclipseJavaCompiler
$2.acceptResult(EclipseJavaCompiler.java:295)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:
454)
at org.apache.commons.jci.compilers.EclipseJavaCompiler.compile
(EclipseJavaCompiler.java:332)
at org.drools.rule.builder.dialect.java.JavaDialect.compileAll
(JavaDialect.java:311)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:
237)
at org.drools.compiler.PackageBuilder.addPackageFromDrl
(PackageBuilder.java:157)
at com.sample.DroolsTest.readRule(DroolsTest.java:78)
at com.sample.DroolsTest.main(DroolsTest.java:37)
java.lang.NoSuchMethodError:
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()
[Lorg/eclipse/jdt/core/compiler/CategorizedProblem;
at org.apache.commons.jci.compilers.EclipseJavaCompiler
$2.acceptResult(EclipseJavaCompiler.java:295)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:
454)
at org.apache.commons.jci.compilers.EclipseJavaCompiler.compile
(EclipseJavaCompiler.java:332)
at org.drools.rule.builder.dialect.java.JavaDialect.compileAll
(JavaDialect.java:311)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:
237)
at org.drools.compiler.PackageBuilder.addPackageFromDrl
(PackageBuilder.java:157)
at com.sample.DroolsTest.readRule(DroolsTest.java:78)
at com.sample.DroolsTest.main(DroolsTest.java:37)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070618/0587f19...
------------------------------
Message: 2
Date: Mon, 18 Jun 2007 21:56:03 -0700
From: "Prakash Galagali" <prakash.galagali(a)tavant.com>
Subject: RE: [rules-users] NullPointerException:
org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(BaseObjectClassFieldExtractor.java:103)
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Message-ID:
<2DDBC6E8B743B543AA8DF3A1C8BFBF7A01B63E66(a)sclex01.us.corp.tavant.com>
Content-Type: text/plain; charset="us-ascii"
I guess one of the Attributes in IndividualNok has no getter / setter
method.
Just verify
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Jian Li
Sent: Monday, June 18, 2007 8:41 AM
To: rules-users(a)lists.jboss.org
Subject: [rules-users] NullPointerException:
org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(Ba
seObjectClassFieldExtractor.java:103)
Hi,
The following problem encountered:
I have a rule defintion :
----------------------------------------------dpd.drl
package ruletest;
import ruletest.IndividualNok;
rule Female_NOK_sex_401
//when (IndividualNok(nokRelationship==401) ||
IndividualNok(nokRelationship==402))
when (IndividualNok(nokRelationship==401) ||
IndividualNok(nokRelationship==402) ||
IndividualNok(nokRelationship==403))
then
System.out.println("abc");
end
------------------------------------------------
When I tried the commented out LSH, it works, however, when i add one
more expression to it , it fails with the following exceptions:
Exception in thread "main" java.lang.NullPointerException
at
org.drools.base.extractors.BaseObjectClassFieldExtractor.getLongValue(Ba
seObjectClassFieldExtractor.java:103)
at
org.drools.base.ClassFieldExtractor.getLongValue(ClassFieldExtractor.jav
a:144)
at
org.drools.reteoo.CompositeObjectSinkAdapter$HashKey.setValue(CompositeO
bjectSinkAdapter.java:467)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(Compo
siteObjectSinkAdapter.java:292)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:183)
at org.drools.reteoo.Rete.assertObject(Rete.java:121)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:201)
at
org.drools.reteoo.ReteooWorkingMemory.doAssertObject(ReteooWorkingMemory
.java:70)
at
org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemo
ry.java:724)
at
org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemo
ry.java:548)
Any idea about this? is it a bug
When I tried to create an additional rule with the 2 expression, it
still fails. This error can be reproduced with the followng code:
-------------------------the Main Class's main method
public static void main(String[] args) {
// TODO code application logic here
final PackageBuilder builder = new PackageBuilder();
try {
builder.addPackageFromDrl( new InputStreamReader(
Main.class.getResourceAsStream( "dpd.drl" ) ) );
} catch (DroolsParserException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
try {
ruleBase.addPackage( builder.getPackage() );
} catch (Exception ex) {
ex.printStackTrace();
}
final StatefulSession session = ruleBase.newStatefulSession();
IndividualNok individualNok = new IndividualNok();
session.assertObject(individualNok);
session.fireAllRules();
session.dispose();
}
-------------------------------------------------
-------------------------------------------------Person class: requried
by individualNok, a simple POJO
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author Jian.Li
*/
public class Person implements java.io.Serializable {
// Fields
private Long personId;
private Integer nationality;
private Integer race;
private String firstName;
private String lastName;
private String midName;
private Date birthdate;
private Integer occupation;
private Integer religion;
private Integer primaryLanguage;
private Integer veteransStatus;
private String idNo;
private Integer idType;
private String mobileNo;
private String email;
private Integer ethnicgroupcountry;
private Integer ethnicgroupstate;
private Integer ethnicgroupcity;
private Integer sex;
private Integer maritalStatus;
private Date lud;
private String lub;
private Set individualNoksForNokPersonId = new HashSet(0);
private Set careproviders = new HashSet(0);
private Set residentialAddresses = new HashSet(0);
private Set individualNoksForPersonId = new HashSet(0);
// Constructors
/** default constructor */
public Person() {
}
/** minimal constructor */
public Person(String firstName, String lastName, Date birthdate,
Integer sex, Integer maritalStatus, Date lud) {
this.firstName = firstName;
this.lastName = lastName;
this.birthdate = birthdate;
this.sex = sex;
this.maritalStatus = maritalStatus;
this.lud = lud;
}
/** full constructor */
public Person(Integer nationality, Integer race, String firstName,
String lastName, String midName, Date birthdate,
Integer occupation, Integer religion, Integer
primaryLanguage,
Integer veteransStatus, String idNo, Integer idType,
String mobileNo, String email, Integer ethnicgroupcountry,
Integer ethnicgroupstate, Integer ethnicgroupcity, Integer
sex,
Integer maritalStatus, Date lud, String lub,
Set individualNoksForNokPersonId, Set careproviders,
Set residentialAddresses, Set individualNoksForPersonId) {
this.nationality = nationality;
this.race = race;
this.firstName = firstName;
this.lastName = lastName;
this.midName = midName;
this.birthdate = birthdate;
this.occupation = occupation;
this.religion = religion;
this.primaryLanguage = primaryLanguage;
this.veteransStatus = veteransStatus;
this.idNo = idNo;
this.idType = idType;
this.mobileNo = mobileNo;
this.email = email;
this.ethnicgroupcountry = ethnicgroupcountry;
this.ethnicgroupstate = ethnicgroupstate;
this.ethnicgroupcity = ethnicgroupcity;
this.sex = sex;
this.maritalStatus = maritalStatus;
this.lud = lud;
this.lub = lub;
this.individualNoksForNokPersonId =
individualNoksForNokPersonId;
this.careproviders = careproviders;
this.residentialAddresses = residentialAddresses;
this.individualNoksForPersonId = individualNoksForPersonId;
}
// Property accessors
public Long getPersonId() {
return this.personId;
}
public void setPersonId(Long personId) {
this.personId = personId;
}
public Integer getNationality() {
return this.nationality;
}
public void setNationality(Integer nationality) {
this.nationality = nationality;
}
public Integer getRace() {
return this.race;
}
public void setRace(Integer race) {
this.race = race;
}
public String getFirstName() {
return this.firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return this.lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getMidName() {
return this.midName;
}
public void setMidName(String midName) {
this.midName = midName;
}
public Date getBirthdate() {
return this.birthdate;
}
public void setBirthdate(Date birthdate) {
this.birthdate = birthdate;
}
public Integer getOccupation() {
return this.occupation;
}
public void setOccupation(Integer occupation) {
this.occupation = occupation;
}
public Integer getReligion() {
return this.religion;
}
public void setReligion(Integer religion) {
this.religion = religion;
}
public Integer getPrimaryLanguage() {
return this.primaryLanguage;
}
public void setPrimaryLanguage(Integer primaryLanguage) {
this.primaryLanguage = primaryLanguage;
}
public Integer getVeteransStatus() {
return this.veteransStatus;
}
public void setVeteransStatus(Integer veteransStatus) {
this.veteransStatus = veteransStatus;
}
public String getIdNo() {
return this.idNo;
}
public void setIdNo(String idNo) {
this.idNo = idNo;
}
public Integer getIdType() {
return this.idType;
}
public void setIdType(Integer idType) {
this.idType = idType;
}
public String getMobileNo() {
return this.mobileNo;
}
public void setMobileNo(String mobileNo) {
this.mobileNo = mobileNo;
}
public String getEmail() {
return this.email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getEthnicgroupcountry() {
return this.ethnicgroupcountry;
}
public void setEthnicgroupcountry(Integer ethnicgroupcountry) {
this.ethnicgroupcountry = ethnicgroupcountry;
}
public Integer getEthnicgroupstate() {
return this.ethnicgroupstate;
}
public void setEthnicgroupstate(Integer ethnicgroupstate) {
this.ethnicgroupstate = ethnicgroupstate;
}
public Integer getEthnicgroupcity() {
return this.ethnicgroupcity;
}
public void setEthnicgroupcity(Integer ethnicgroupcity) {
this.ethnicgroupcity = ethnicgroupcity;
}
public Integer getSex() {
return this.sex;
}
public void setSex(Integer sex) {
this.sex = sex;
}
public Integer getMaritalStatus() {
return this.maritalStatus;
}
public void setMaritalStatus(Integer maritalStatus) {
this.maritalStatus = maritalStatus;
}
public Date getLud() {
return this.lud;
}
public void setLud(Date lud) {
this.lud = lud;
}
public String getLub() {
return this.lub;
}
public void setLub(String lub) {
this.lub = lub;
}
public Set getIndividualNoksForNokPersonId() {
return this.individualNoksForNokPersonId;
}
public void setIndividualNoksForNokPersonId(Set
individualNoksForNokPersonId) {
this.individualNoksForNokPersonId =
individualNoksForNokPersonId;
}
public Set getCareproviders() {
return this.careproviders;
}
public void setCareproviders(Set careproviders) {
this.careproviders = careproviders;
}
public Set getResidentialAddresses() {
return this.residentialAddresses;
}
public void setResidentialAddresses(Set residentialAddresses) {
this.residentialAddresses = residentialAddresses;
}
public Set getIndividualNoksForPersonId() {
return this.individualNoksForPersonId;
}
public void setIndividualNoksForPersonId(Set
individualNoksForPersonId) {
this.individualNoksForPersonId = individualNoksForPersonId;
}
}
------------------------------------------------------------------------
----------------------------
-------------------------------------IndividualNok class : a simple POJO
public class IndividualNok implements java.io.Serializable {
// Fields
private Long individualNokId;
private Person personByPersonId;
private Person personByNokPersonId;
private Integer nokRelationship;
private Integer emgcycntctInd;
// Constructors
/** default constructor */
public IndividualNok() {
}
/** minimal constructor */
public IndividualNok(Integer nokRelationship) {
this.nokRelationship = nokRelationship;
}
/** full constructor */
public IndividualNok(Person personByPersonId, Person
personByNokPersonId,
Integer nokRelationship, Integer emgcycntctInd) {
this.personByPersonId = personByPersonId;
this.personByNokPersonId = personByNokPersonId;
this.nokRelationship = nokRelationship;
this.emgcycntctInd = emgcycntctInd;
}
// Property accessors
public Long getIndividualNokId() {
return this.individualNokId;
}
public void setIndividualNokId(Long individualNokId) {
this.individualNokId = individualNokId;
}
public Person getPersonByPersonId() {
return this.personByPersonId;
}
public void setPersonByPersonId(Person personByPersonId) {
this.personByPersonId = personByPersonId;
}
public Person getPersonByNokPersonId() {
return this.personByNokPersonId;
}
public void setPersonByNokPersonId(Person personByNokPersonId) {
this.personByNokPersonId = personByNokPersonId;
}
public Integer getNokRelationship() {
return this.nokRelationship;
}
public void setNokRelationship(Integer nokRelationship) {
this.nokRelationship = nokRelationship;
}
public Integer getEmgcycntctInd() {
return this.emgcycntctInd;
}
public void setEmgcycntctInd(Integer emgcycntctInd) {
this.emgcycntctInd = emgcycntctInd;
}
}
---------------------------------------End of IndividualNok
________________________________
Yahoo! Movies
<http://sg.rd.yahoo.com/mail/sg/footer/def/*http:/sg.movies.yahoo.com>
<http://sg.yimg.com/i/sg/widgets/new.gif> - Search movie info and celeb
profiles and photos.
Any comments or statements made in this email are not necessarily those of Tavant Technologies. The information transmitted is intended only for the
person or entity to which it is addressed and may contain confidential and/or privileged material. If you have received this in error, please contact
the sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies. may be subject to our monitoring procedures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070618/4350f5a...
------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
End of rules-users Digest, Vol 7, Issue 48
******************************************
17 years, 5 months
ClassCastException using WorkingMemoryFileLogger (3.0.6)
by Yuri de Wit
I got a ClassCastException once I ran my app with the
WorkingMemoryFileLogger attached to it. After a bit of debugging the
CCE is being thrown because for an unknown reason the column of a
Declaration is wrong: it should have been 0 like all the other
declarations on the same Fact, but it is 0 instead. It seems that
column is wrongly set when building the rule package, even before
evaluating.
What I dont understand is why this is happening and why I dont see the
problem when I remove the WorkingMemoryFileLogger from the picture.
The rules goes a bit like this:
rule
when
Fact1(var1: a, var2: b, var3: c)
c : (
Setting( x==1, y==2, z==3)
or
Setting( x==1, y==2, z==ANY)
or
Setting( x==1, y==ANY, z==ANY)
or
Setting( x==ANY, y==ANY, z==ANY)
)
not Fact2( a == var1, b== var2, c==var3)
then
...
end
The declarations for a and b, for instance are referring to the right
column, but c doesnt.
BTW: Does any one know of a better pattern for implementing cascading
settings? The biggest problem I am facing is that I need to replicate
the long list or OR Settings for each rule that needs to check for
them (the actual settings depend on fact properties).
Here is the exception:
org.drools.spi.ConsequenceException: java.lang.ClassCastException: com....
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:441)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:407)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:268)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:255)
17 years, 5 months
Managing Collection Facts
by Yuri de Wit
Hi,
I have to create a set of rules that group facts together based on a
dynamic criteria X basd on fact data. So I created a rule to create a
first collection for the criteria X when no collection exist. I
created a second rule to add a fact to an existing collection, but I
cant get my head around how to create a rule that takes facts out of
the collection if a fact is updated and no longer satisfies X. Note
that the criteria X is a combination of 7-10 field equality.
rule
when
f:Fact1(var1: a, var2:b)
not FactCollection( a == var1, b == var2, fs:facts ->
(fs.contains(f) == true) )
then
...
assert(new FactCollection(f));
end
rule
when
f:Fact1(var1: a)
c:FactCollection( a == var1 )
then
c.add(f);
modify(c);
modify(f);
end
rule
when
f:Fact1(id:id, type=UPDATE, var1: a)
f2:Fact1(id == id, a == var1, b == var2)
fs:FactCollection( not(a == var1, b == var2), fs:facts ->
(fs.contains(f2) == true)
then
fs.remove(f2);
modify(fs);
end
Since I dont want to create a rule for each combination of a != var1,
b == var2, a == var1, b != var2 (I have 7-10 individual conditions),
but I do want to check whether the collection contains f2 what else to
do? any ideas?
17 years, 5 months