Tracking non-matches...
by jdepaul
I was hoping for some opinions on the following:
Client will have many rules (about 1000) per RuleBase. The primary goal is
to assert Facts and find Matches in one or more rules. The secondary goal
may be to keep track of those Facts that did not produce Matches. I was
wondering what the best solution may be in this case?!
The benefit in keeping track of the non-matches would be periodic analysis
of the non-matches to discover patterns and perhaps provide some proactive
monitoring and notification. An additional benefit may be to spot a trend
and setup additional rules to reduce the number of non-matches.
So I would need to not only spot the no-match condition, I also need to
persist the no-match event in the database for tracking and later reporting.
One way I can see is to assert a new Match fact the instance a single rule
is matched and then test for the presence/absence of the Match() fact.
Efficiency and speed are paramount in our case, so I'm wondering if there is
an alternate approach that would work here.
Thanks,
James
--
View this message in context: http://www.nabble.com/Tracking-non-matches...-tf3596042.html#a10044235
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 7 months
Efficiency of rules with XPath...
by Schwenker, Stephen
Hey all,
I'm trying to make my rule more efficient but I'm not sure how. I've
designed my rules based around xml objects. Basically, I have these
documents and XPath queries are executed against the Object to determine
if the rule should be executed. The problems is, is that we have over
900 rules that need to be executed. The performance isn't really that
bad but I would like to Make it even better.
To do the job, I have written an XmlUtils class to execute the
expression. The class first gets the XPathFactory. Then compiles the
expression and then executes the expression. This happens for every
expression, and will happen each time the same expression is executed.
I want to make the rules more efficient by getting the XPathFactory once
and compiling the expression once and then execute the expression n time
on the same compiled object.
I would like to know if there is a way I can have the rule object that
is generated by the package build do the compile of the XPath Expression
and then use it instead of compiling it every time.
Here is a sample of one of my rule criteria.
asset: AssetDocument()
eval( XmlUtils.evaluatePathBoolean( asset,
"boolean(//ass:asset/ass:properties/ass:property[@name =
'Desk']/ass:value/text() = 'column')") )
17 years, 7 months
conways game of life
by Mark Proctor
I have just moved Jeff Brown's "Conways Game of Life" to a stateful
example, this is now the best place to look to understand jboss rules.
It's also good to compare this stateful implementation to the old
stateless version. Trunk introduces a new feature to help deal with
recursion "lock-on-active" which stops a rule being able to create
activations while it's agenda-group/rule-flow-group has focus - so it's
a much stronger no-loop. Probably the most important thing this example
shows is how to think relationally, the old example used nested
properties and sets to maintain the "neighbour" information; this
example shows how to achieve the same but expressing it relationally,
using the Neighbor relation class, further it shows how we can exploit
the the cross-product relational information to drive the engine without
us having to write loops. Currently the example is using agenda-groups
to drive execution flow, I'm now in the process of moving this to
rule-flow-groups.
You'll need trunk to be able to run this, so checkout:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/
Make sure you have maven 2.0.6 installed and then type the following
from the root directory:
mvn clean install -Declipse=true
The eclipse plugin will now be built in the drools-eclipse/target
directory, so open that up and unzip into your eclipse install (make
sure you use -clean to start eclipse). Then import drools-examples and
"run as application" the ConwayGUI class.
I plan to do a blog or two on how this exampe works, and my next
challenge will be to migrate the pacman game to jboss rules.
Mark
--
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire,
SI4 1TE, United Kingdom.
Registered in UK and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (USA), Charlie Peters (USA) and David
Owens (Ireland)
package org.drools.examples
import org.drools.examples.conway.Cell;
import org.drools.examples.conway.CellGrid;
import org.drools.examples.conway.Neighbor;
import org.drools.examples.conway.Phase;
import org.drools.examples.conway.CellState;
import org.drools.WorkingMemory;
import org.drools.common.InternalWorkingMemoryActions;
import org.drools.RuleBase;
rule "register north east"
agenda-group "register neighbor"
when
CellGrid( $numberOfColumns : numberOfColumns )
$cell: Cell( $row : row > 0, $col : col < ( $numberOfColumns - 1 ) )
$northEast : Cell( row == ($row - 1), col == $col )
then
assert( new Neighbor( $cell, $northEast ) );
assert( new Neighbor( $northEast, $cell ) );
end
rule "register north"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col )
$north : Cell( row == ($row - 1), col == $col )
then
assert( new Neighbor( $cell, $north ) );
assert( new Neighbor( $north, $cell ) );
end
rule "register north west"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col > 0 )
$northWest : Cell( row == ($row - 1), col == ( $col - 1 ) )
then
assert( new Neighbor( $cell, $northWest ) );
assert( new Neighbor( $northWest, $cell ) );
end
rule "register west"
agenda-group "register neighbor"
when
$cell: Cell( $row : row > 0, $col : col > 0 )
$west : Cell( row == $row, col == ( $col - 1 ) )
then
assert( new Neighbor( $cell, $west ) );
assert( new Neighbor( $west, $cell ) );
end
rule "Kill The Lonely"
agenda-group "evaluate"
no-loop
when
# A live cell has fewer than 2 live neighbors
theCell: Cell(liveNeighbors < 2, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
theCell.setPhase(Phase.KILL);
modify( theCell );
end
rule "Kill The Overcrowded"
agenda-group "evaluate"
no-loop
when
# A live cell has more than 3 live neighbors
theCell: Cell(liveNeighbors > 3, cellState == CellState.LIVE, phase == Phase.EVALUATE)
then
theCell.setPhase(Phase.KILL);
modify( theCell );
end
rule "Give Birth"
agenda-group "evaluate"
no-loop
when
# A dead cell has 3 live neighbors
theCell: Cell(liveNeighbors == 3, cellState == CellState.DEAD, phase == Phase.EVALUATE)
then
theCell.setPhase(Phase.BIRTH);
modify( theCell );
end
rule "reset calculate"
agenda-group "reset calculate"
when
then
WorkingMemory wm = drools.getWorkingMemory();
wm.getAgenda().clearAgendaGroup( "calculate" );
end
rule "kill"
agenda-group "kill"
no-loop
when
theCell: Cell(phase == Phase.KILL)
then
theCell.setCellState(CellState.DEAD);
theCell.setPhase(Phase.DONE);
modify( theCell );
end
rule "birth"
agenda-group "birth"
no-loop
when
theCell: Cell(phase == Phase.BIRTH)
then
theCell.setCellState(CellState.LIVE);
theCell.setPhase(Phase.DONE);
modify( theCell );
end
rule "Calculate Live"
agenda-group "calculate"
lock-on-active
when
theCell: Cell(cellState == CellState.LIVE)
Neighbor(cell == theCell, $neighbor : neighbor)
then
$neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() + 1 );
$neighbor.setPhase( Phase.EVALUATE );
modify( $neighbor );
end
rule "Calculate Dead"
agenda-group "calculate"
lock-on-active
when
theCell: Cell(cellState == CellState.DEAD)
Neighbor(cell == theCell, $neighbor : neighbor )
then
$neighbor.setLiveNeighbors( $neighbor.getLiveNeighbors() - 1 );
$neighbor.setPhase( Phase.EVALUATE );
modify( $neighbor );
end
rule "Kill All"
agenda-group "kill all"
no-loop
when
theCell: Cell(cellState == CellState.LIVE)
then
theCell.setCellState(CellState.DEAD);
modify( theCell );
end
package org.drools.examples.conway;
/**
* A <code>Cell</code> represents a single cell within a <code>CellGrid</code>.
* A cell may be either live or dead. <p/>
*
* @author <a href="mailto:brown_j@ociweb.com">Jeff Brown</a>
* @see CellState
* @see CellGrid
*/
public class Cell {
private CellState cellState = CellState.DEAD;
private int phase = Phase.DONE;
private int liveNeighbors;
private int col;
private int row;
public Cell(int col,
int row) {
this.col = col;
this.row = row;
}
public int getCol() {
return col;
}
public int getRow() {
return row;
}
public int getPhase() {
return this.phase;
}
public void setPhase(int phase) {
this.phase = phase;
}
public int getLiveNeighbors() {
return this.liveNeighbors;
}
public void setLiveNeighbors(int liveNeighbors) {
this.liveNeighbors = liveNeighbors;
}
/**
* @return this cell's current life state
* @see #queueNextCellState(org.drools.examples.conway.CellState)
* @see CellState
*/
public CellState getCellState() {
return this.cellState;
}
/**
* Sets this cells state
*
* @param newState
* new state for this cell
* @see CellState
*/
public void setCellState(final CellState newState) {
this.cellState = newState;
}
public String toString() {
return cellState + " col=" + this.col + " row=" + this.row + " phase '" + phase + "' liveNeighbors '" + liveNeighbors + "'";
}
}
package org.drools.examples.conway;
import org.drools.RuleBase;
import org.drools.WorkingMemory;
import org.drools.event.AgendaGroupPoppedEvent;
import org.drools.event.DefaultAgendaEventListener;
import org.drools.examples.conway.patterns.ConwayPattern;
/**
* A <code>CellGrid</code> represents a grid of <code>Cell</code> objects.
* <p/>
*
* @author <a href="mailto:brown_j@ociweb.com">Jeff Brown</a>
* @see Cell
*/
public class CellGrid {
private final Cell[][] cells;
private WorkingMemory workingMemory;
/**
* Constructs a CellGrid
*
* @param rows
* number of rows in the grid
* @param columns
* number of columns in the grid
*/
public CellGrid(final int rows,
final int columns) {
this.cells = new Cell[rows][columns];
final RuleBase ruleBase = ConwayRuleBaseFactory.getRuleBase();
this.workingMemory = ruleBase.newWorkingMemory();
DefaultAgendaEventListener listener = new DefaultAgendaEventListener() {
public void agendaGroupPopped(AgendaGroupPoppedEvent event,
WorkingMemory workingMemory) {
System.out.println( "popped AgendaGroup = '" + event.getAgendaGroup().getName() + "'" );
System.out.println( CellGrid.this.toString() );
System.out.println( "" );
}
};
this.workingMemory.addEventListener( listener );
this.workingMemory.assertObject( this );
// populate the array of Cells and hook each
// cell up with its neighbors...
for ( int row = 0; row < rows; row++ ) {
for ( int column = 0; column < columns; column++ ) {
final Cell newCell = new Cell( column,
row );
this.cells[row][column] = newCell;
this.workingMemory.assertObject( newCell );
}
}
this.workingMemory.setFocus( "register neighbor" );
this.workingMemory.fireAllRules();
}
/**
* @param row
* row of the requested cell
* @param column
* column of the requested cell
* @return the cell at the specified coordinates
* @see Cell
*/
public Cell getCellAt(final int row,
final int column) {
return this.cells[row][column];
}
/**
* @return the number of rows in this grid
* @see #getNumberOfColumns()
*/
public int getNumberOfRows() {
return this.cells.length;
}
/**
* @return the number of columns in this grid
* @see #getNumberOfRows()
*/
public int getNumberOfColumns() {
return this.cells[0].length;
}
/**
* Moves this grid to its next generation
*
* @return <code>true</code> if the state changed, otherwise false
* @see #transitionState()
*/
public boolean nextGeneration() {
System.out.println( "next generation" );
workingMemory.setFocus( "calculate" );
workingMemory.setFocus( "kill" );
workingMemory.setFocus( "birth" );
workingMemory.setFocus( "reset calculate" );
workingMemory.setFocus( "rest" );
workingMemory.setFocus( "evaluate" );
workingMemory.fireAllRules();
return workingMemory.getAgenda().getAgendaGroup( "evaluate" ).size() != 0;
}
/**
* kills all cells in the grid
*/
public void killAll() {
this.workingMemory.setFocus( "calculate" );
this.workingMemory.setFocus( "kill all" );
this.workingMemory.setFocus( "reset calculate" );
this.workingMemory.fireAllRules();
}
/**
* Populates the grid with a <code>ConwayPattern</code>
*
* @param pattern
* pattern to populate the grid with
* @see ConwayPattern
*/
public void setPattern(final ConwayPattern pattern) {
final boolean[][] gridData = pattern.getPattern();
int gridWidth = gridData[0].length;
int gridHeight = gridData.length;
int columnOffset = 0;
int rowOffset = 0;
if ( gridWidth > getNumberOfColumns() ) {
gridWidth = getNumberOfColumns();
} else {
columnOffset = (getNumberOfColumns() - gridWidth) / 2;
}
if ( gridHeight > getNumberOfRows() ) {
gridHeight = getNumberOfRows();
} else {
rowOffset = (getNumberOfRows() - gridHeight) / 2;
}
killAll();
for ( int column = 0; column < gridWidth; column++ ) {
for ( int row = 0; row < gridHeight; row++ ) {
if ( gridData[row][column] ) {
final Cell cell = getCellAt( row + rowOffset,
column + columnOffset );
cell.setCellState( CellState.LIVE );
this.workingMemory.modifyObject( this.workingMemory.getFactHandle( cell ),
cell );
}
}
}
workingMemory.setFocus( "calculate" );
workingMemory.fireAllRules();
System.out.println( "" );
}
public String toString() {
StringBuffer buf = new StringBuffer();
for ( int i = 0; i < this.cells.length; i++ ) {
for ( int j = 0; j < this.cells[i].length; j++ ) {
Cell cell = this.cells[i][j];
System.out.print( cell.getLiveNeighbors() + ((cell.getCellState() == CellState.DEAD) ? "D" : "L") + " " );
}
System.out.println( "" );
}
return buf.toString();
}
}
package org.drools.examples.conway;
public class Neighbor {
private Cell cell;
private Cell neighbor;
public Neighbor(Cell cell, Cell neighbor) {
this.cell = cell;
this.neighbor = neighbor;
}
public Cell getCell() {
return cell;
}
public Cell getNeighbor() {
return neighbor;
}
public String toString() {
return "cell '"+ this.cell + "' neighbour '" + this.neighbor + "'";
}
}
17 years, 7 months
many response
by fakhfakh ismail
Hello,
First sorry for my bad english
when I execute a regle I get many response I don't know why?
Example:
rule "userrole"
when
user1: BnUserValue(nameuser : name)
and
Role : BnRoleValue()
and
ActiviteOut : BnNodeValue(bnRole == Role,executor == nameuser )
and
ActiviteIn : BnNodeValue(bnRole == Role )
and
lien: BnEdgeValue(outBnNode == ActiviteOut,inBnNode ==ActiviteIn )
then
System.out.println("cette personne "+user1.getName()+ " ne peut pas executer cette activiter");
end
the execution result
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
cette personne ismail ne peut pas executer cette activiter
so the result is repeat 6 I don't know why?
thank for your help
Ismail
---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
17 years, 7 months
RE: [rules-users] How to pre compile rule files for production
by abhilashkumar@amritatech.com
Hi Michael,
Thanks very much for the advice and the effort you put to check my code.
We had a load test script which we used to simulate the problem and now
with the new code, the problem seems to be gone away.
Once again, thanks very much of the help.
Thanks and Regards,
-- Abhilash.
17 years, 7 months
RE: [rules-users] How to pre compile rule files for production
by Michael Rhoden
Yes something like that should work fine. I'm not to up on the
"synchronized" call you're making but if you can access some app scoped
memory, what you have will work fine. I might suggest you try and cache
the rulebases [call execute(String ruleFile, Object [] objects)] well
before you expect them to perform well, maybe at app startup. It seems,
for us anyway, that the rulebase building takes hundreds of times longer
than the rest.
-Michael
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of
abhilashkumar(a)amritatech.com
Sent: Sunday, April 15, 2007 4:23 AM
To: Rules Users List
Subject: Re: [rules-users] How to pre compile rule files for production
Hi Michael,
Thanks very much for the instant reply. In my application, I have
number of .drl files for differnt kinds of domain problems and i pass
the .drl file name to the RuleExecuter from the EJB. The RuleExecuter
will fetch and load the rule file into RuleBase and then execute the
rule.
So, if i rewrite the code to store the RuleBase in a static HashMap
(with synchronized put) when it is created for the first time and then
get it from there for subsequent use, whether it will be fine? My code
will now look like the below one. Please give your advice on this.
Thanks and Regards,
-- Abhilash.
// This HashMap will act as the cache for RuleBase instances of each
rule in .drl file
private static HashMap ruleBaseCache = null;
static {
ruleBaseCache = new HashMap();
}
/**
* @param ruleFile - Name of the rule file (.drl file)
* @param objects - Fact objects for the rule
* @return
* @throws AppException
*/
private static RuleResultVO execute( String ruleFile, Object []
objects
) throws AppException {
/* This will contain the execution result of the rule. Every
rule will have reference to
* this object and will finally store the result in this object
*/
RuleResultVO ruleResult = new RuleResultVO();
try {
//See whether the ruleBase for this rule file is in cache.
Theoretically, this also should be synchrnoized, but will be a
performance overhead.
RuleBase ruleBase = (RuleBase) ruleBaseCache.get( ruleFile
);
if ( ruleBase == null ) { // First time access. Create the
ruleBase and put it in cache
synchronized( RuleExecuter.ruleBaseCache ) {
//Read the rule source file
InputStream in =
ResourceLoader.getResourceAsStream(ruleFile);
Reader reader = new InputStreamReader(in);
DrlParser parser = new DrlParser();
PackageDescr packageDescr = parser.parse(
reader );
//pre build the package
PackageBuilder builder = new PackageBuilder();
builder.addPackage( packageDescr );
Package pkg = builder.getPackage();
//add the package to a rulebase
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
//Add the RuleBase to the cache so that the
subsequent calls will use it from there.
ruleBaseCache.put( ruleFile, ruleBase );
}
}
//create the WorkingMemory
WorkingMemory workingMemory =
ruleBase.newWorkingMemory();
//Supply the fact objects for the rule
for ( int i = 0; i < objects.length; i++ ) {
workingMemory.assertObject( objects[i] );
}
workingMemory.assertObject( ruleResult );
// go !
workingMemory.fireAllRules();
}catch( Exception e ) {
e.printStackTrace();
ExceptionUtil.throwAppException(
"RuleExecuter.executeRule() :
Exception Occured :[" +e.getMessage()+"]");
}
return ruleResult;
}
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
17 years, 7 months
How to pre compile rule files for production
by abhilashkumar@amritatech.com
Hello,
I am using 3.0 RC 2 version of DROOLS in one of our project. (JDK 1.4.2
and JBoss 3.2.7) When we deployed the application into production, we
are facing performance issues that seems to be because of class loading
and GC collection of rule classes that are created at runtime. So I went
back to the docs and wiki and decided to try the pre-compile and caching
options. Eventhough i searched the wiki, mailing list archives and doc,
i was not able to find any advice on how can I do this. Ours is a J2EE
application and the EJBs call a static method in an helper class which
will laod the .drl file, build the PackageBuilder and Rulebase, create
the WorkingMemory and execute the rule.
Any pointers on how to pre compile the rule and then execute it will be
really helpful. Below is the current code that executes the rule.
Thanks and Regards,
-- Abhilash.
private static RuleResultVO execute( String ruleFile, Object [] objects )
throws AppException {
RuleResultVO ruleResult = new RuleResultVO();
try {
//read in the source
InputStream in = ResourceLoader.getResourceAsStream(ruleFile);
Reader reader = new InputStreamReader(in);
DrlParser parser = new DrlParser();
PackageDescr packageDescr = parser.parse( reader );
//pre build the package
PackageBuilder builder = new PackageBuilder();
builder.addPackage( packageDescr );
Package pkg = builder.getPackage();
//add the package to a rulebase
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
//load up the rulebase
WorkingMemory workingMemory = ruleBase.newWorkingMemory();
//go !
for ( int i = 0; i < objects.length; i++ ) {
workingMemory.assertObject( objects[i] );
}
workingMemory.assertObject( ruleResult );
workingMemory.fireAllRules();
}catch( Exception e ) {
e.printStackTrace();
ExceptionUtil.throwAppException( "RuleExecuter.executeRule() :
Exception Occured :[" +e.getMessage()+"]");
}
return ruleResult;
}
17 years, 7 months
var null
by fakhfakh ismail
hello,
I want to affect var outBnNode == null
there's no problem de compilation but the result doesn't correct
when
user1: BnUserValue(nameuser : name)
user : BnUserValue(name != nameuser)
and
Role : BnRoleValue()
and
ActiviteOut : BnNodeValue(executor == nameuser )
and
ActiviteIn : BnNodeValue(bnRole == Role )
and
lien1: BnEdgeValue(outBnNode == ActiviteOut,inBnNode == null )
lien2: BnEdgeValue(outBnNode == null,inBnNode ==ActiviteIn )
then
System.out.println("seulement les utiisateurs qui peuvent executer cette activités sont " +user.getName());
end
I want to know can I affect a var null (outBnNode is var type object)
best regards
Ismail
---------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses.
17 years, 7 months
Questions about collect performance
by Dirk Bergstrom
Edson Tirelli (JIRA) was heard to exclaim, On 04/11/07 05:57:
> Edson Tirelli commented on JBRULES-740:
> Being brief, using the following rule:
> rule "Find all PRs for user"
> when
> $user : User( )
> $pr_list : RecordSet( size > 0 ) from
> collect( PRRecord( $resp : responsible -> ( $user.hasReport($resp) ) ) )
> then
> $user.setRecords($pr_list, DataSource.GNATS);
> end
> if you already have "User" facts asserted into the working memory, it means
> that for every PRRecord that matches your <constraints>, it will recalculate
> the "collect". So, if you have a User fact, and assert a PRRecord, it will
> create a RecordSet and add your PRRecord to the set. When you assert a second
> PRRecord, it will create a new RecordSet and add the 2 PRRecord. As you see,
> it is a progression: 1+2+3+4...+N. Your case is even worst because your
> constraint is a predicate (not indexable right now), so, it means the
> progression above is executed in full.
As it turns out, this is actually quite fast; it takes 50-100 msec per PR
assertion, so I can cram in 10,000 of them in a few minutes. Nonetheless, I
understand that it is less than optimal at the moment.
> Anyway, what you need to do:
> 1) If possible, adjust your business model in a way to replace the predicate
> for a regular "==" constraint, avoiding full iteration because of indexing.
There's no way to do that. What I really want is this:
$user : User( $reports : reports )
$pr_list : RecordSet( size > 0 ) from
collect( PRRecord( $reports contains responsible ) )
(the syntax could also be "responsible containedIn $reports").
But Drools doesn't (yet?) support that.
For now, I could warp my application such that I could write this:
collect( PRRecord( responsible_users contains $user ) )
Is that something that Drools could index?
That would introduce some unpleasant dependencies in my code, but if it allows
indexing, it might be worth it.
> 2) Use a control fact to limit the partial matches. Example:
> rule "Find all PRs for user"
> when
> $control : ControlFact( phase == "findPR" )
> $user : User( )
> $pr_list : RecordSet( size > 0 ) from
> collect( PRRecord( $resp : responsible -> ( $user.hasReport($resp) ) ) )
> then
> $user.setRecords($pr_list, DataSource.GNATS);
> $control.setPhase( "do everything else" )
> modify( $control )
> end
> Doing the above, make sure you assert all PRRecords first and only then, set
> (or assert) your control fact to phase "findPR". The above will make the
> engine avoid wasting time calculating partial matches that will never be
> used. It seems ugly at first, but it is a technique that unfortunately needs
> to be used in some special cases.
That doesn't really fit with the application flow. I could have a rule like this:
when
ControlFact( )
$user : User( )
$pr_list : RecordSet( size > 0 ) from
collect( PRRecord( $resp : responsible -> ( $user.hasReport($resp) ) ) )
then
$user.setRecords($pr_list, DataSource.GNATS);
And retract the ControlFact before asserting PR objects, then assert it when I'm
ready to fireAllRules(). Would that have the desired effect?
Thanks.
--
Dirk Bergstrom dirk(a)juniper.net
_____________________________________________
Juniper Networks Inc., Computer Geek
Tel: 408.745.3182 Fax: 408.745.8905
17 years, 7 months
Re: [drools-user] NoClassDefFoundError: org/antlr/runtime/CharStream
by Shankar
Hi!
I added antlr3.jar and so the previous exception
is no longer coming. But I get another error.
Exception in thread "main" java.lang.NoSuchFieldError: recognizer
at org.drools.lang.DRLLexer$DFA18.<init>(DRLLexer.java:3914)
at org.drools.lang.DRLLexer.<init>(DRLLexer.java:3565)
at org.drools.compiler.DrlParser.getParser(DrlParser.java:78)
at org.drools.compiler.DrlParser.parse(DrlParser.java:47)
at org.drools.compiler.DrlParser.parse(DrlParser.java:85)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:146)
at com.eclipsePractice.AviationQuoteAction.readRule(AviationQuoteAction.java:57)
at com.eclipsePractice.AviationQuoteAction.doRun(AviationQuoteAction.java:31)
com.eclipsePractice.AviationQuoteAction.generateQuote(AviationQuoteAction.java
at com.eclipsePractice.AviationQuoteAction.main(AviationQuoteAction.java:74)
I have the following jars in my classpath now.
janino.jar,
drools-jsr94-3.1.0-M1.jar,
drools-compiler-3.1.0-M1.jar,
drools-core-3.1.0-M1.jar,
drools-decisiontables-3.1.0-M1.jar,
antlr.jar,
antlr-3.0ea9.jar,
commons-logging.jar,
commons-lang.jar,
antlr-2.7.6.jar,
stringtemplate-2.3b7.jar
Thanks!
Shankar
17 years, 7 months