Re: [rules-users] Example of contains operator...

2007-02-13 Thread Marcus Ilgner

On 2/13/07, jdepaul [EMAIL PROTECTED] wrote:


Ok thanks - that worked when partnerList was an ArrayList, how would I code
my contains condition if the parternList was a HashMap!?


You could write an accessor in your model called getPartnerListKeys()
which returns getPartnerList().keySet() and then use (partnerListKeys
contains 2900) in your rule.
I'm not 100% sure (started with JBoss Rules only a couple of days
ago), but I'm pretty confident that this should work.

hth
Marcus


Michael Neale wrote:

 contains works on the Collection interface. So if parnerList is a
 ArrayList
 of String, then you could do:  parnerList contains 2900



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


Re: [rules-users] Using Java to write rules?

2007-03-02 Thread Marcus Ilgner

On 3/2/07, Aeinehchi Nader [EMAIL PROTECTED] wrote:


 I wonder if it is possible to write rules and make queries toward the
knowledge database of Jboss Rules using Java language itself.  What I need
is to to be able to access the rule engine's API.

I do not want to use Drools language or XML.



Although I guess that it would be possible to make all those calls manually,
I wonder what the advantage would be.
The RHS of a rule is already Java code and the LHS provides a lot of Java
functionality or can use eval() if neccessary.
Also you can embed the DRL in your source or dynamically create new rules
and add those using StringReader if need be: I'm currently working on a
business project where new rules are assembled by the application: POC works
like a charm.
If that is not feasible, I'd probably take a look at the
drools-decisiontables codebase which basically does a similar thing: replace
DRL/XML syntax with a new interface (decision tables).
Anyway, that's just my $0.02 ;)

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


Re: [rules-users] Rules with Lookup Tables...

2007-03-02 Thread Marcus Ilgner

On 3/2/07, Francisco Brum [EMAIL PROTECTED] wrote:


I also need to make a rule with a lookup tables, and I have found that the new 
version of rules support 'from'.


Another solution could be the the use of globals:
http://labs.jboss.com/file-access/default/members/jbossrules/freezone/docs/3.0.5/html_single/index.html#d0e719

You could insert a global PartnerList and a global
PortLocationList and evaluate on these.
It somewhat depends on your situation: using FROM is definitely more
powerful, globals are quicker to implement because you probably have
this List object laying around already.

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


Re: [rules-users] Using rules with database scenario

2007-03-09 Thread Marcus Ilgner

On 3/9/07, Uday Kamath [EMAIL PROTECTED] wrote:







We had similar use case. What we do is we model the Schema elements,
generate Java Beans (pojo), and write rules using these Pojo. Now we have
written a Service on top which takes Hibernate QL and gets the database
records as the same Pojos that Rules are defined on and fire the Rules. Thus
the service is generic and can be changed to take any Query. The Rules can
me modified and changed anytime and redeployed but business objects in form
of Pojos remain the same. Hope this helps

-Uday

 


From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Joe Chuby
 Sent: Friday, March 09, 2007 3:53 AM
 To: rules-users@lists.jboss.org
 Subject: [rules-users] Using rules with database scenario




Hi all,

 First time trying to learn JBoss Rules here. We have a pretty large
database (DBMS), we want to build some rules and retrieve data based on the
rules.

 Could someone give a hint or an example of this usage scenario? I mean, how
can I use rules for database query, without writing my rules in SQL
directly? We are currently writing everything in HQL (Hibernate), but the
rules change every 3 months on average, so that's not a way to maintain the
system. Therefore, we want to extract that portion of the business logic out
of the code. The data structure does not change, but the rules keep on
changing.

 I'm reading the user's guide, running thru the examples, writing some of my
own, but still no clue how to make it work with database.

 If someone could give a sample, that would be greatly appreciated.

 Thanks a lot.



That's probably the best solution. Using the current version (3.1M1),
you can use the FROM keyword to reference facts from List object
returned from a method call on a service, for example.
Something like this works very good in my current testing project:

rule foobar
when
 MyObject( someValue = foobar ) from MyObjectDAO.loadAll()
then
...
end

The DAO then uses Hibernate to load some objects and returns a
ListMyObject which can be used by Drools.
As Uday already wrote, you could also write a DAO which retrieves
arbitrary objects using a given HQL statement.

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


Re: [rules-users] Getting validation errors

2007-03-13 Thread Marcus Ilgner

Hi Mike,

On 3/13/07, Mike Dougherty [EMAIL PROTECTED] wrote:

Hello,

I am using JBoss Rules to validate entities before storing them in the
database. I therefore need a way to inform the calling code that the entity
which was asserted failed verification. The only way I have been able to
find that works is to assert an exception from within the rule file. For
example:

rule user is 'miked'
  when
identity : Identity( username == miked )
  then
assertLogical(new IllegalStateException(Entity failed verification.));
end

Then in the Java that fires the rule, I have:

workingMemory.fireAllRules();
for(Iterator i = workingMemory.getObjects(Exception.class).iterator();
i.hasNext(); ) {
System.out.println(Exception: +i.next());
}

Which seems to be working OK. But I wanted to see if maybe there is a better
way to accomplish what I need.

Thanks for you help.
Mike



My approach would be to derive all objects that will be validated from
a superclass, e.g. ValidatedObject, which provides a boolean property
validated.
Then you can set this property in your rules and later on display
warning/error messages for those objects that failed validation.

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


[rules-users] Remotely debugging application server code

2007-11-15 Thread Marcus Ilgner
Hi list,

I'm experiencing problems when remotely debugging my JBoss-Rules-using
application running on an application server.
The application server is JBoss 4.2.1.GA and I connect to it via
Eclipse. My JBoss Rules version is 4.0.3.
As soon as I start inserting facts, the application seems to hang. The
debugger reports the status Running on all threads, however the
application does not seem to reach the next statement (which is a
logging statement).
When I disconnect the debugger, the execution resumes and everything works fine.
The displayed callstack when suspending the execution claims that the
execution has reached the next breakpoint, however I'm in doubt that
this is true and there's no way for me to resume the execution.

Maybe some of you have experienced something similar. I had no
problems at all debugging the code that does all the work before the
fact insertion. Only after starting to insert facts the debugging goes
awry.

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


Re: [rules-users] Globals asserted as facts... how to modify them...

2008-02-16 Thread Marcus Ilgner
Hi,

On Feb 16, 2008 1:00 PM, mmquelo massi [EMAIL PROTECTED] wrote:

 Hi everybody,

 I followed all the topics about globals and the fact that they are
 immutables.

 I also understood that once we decide to reason over globals, it's
 time we no more use them and we start to use simple WM facts.

 Now...

 I tell you my scenario.

 I have got two globals.

 A request global and a reply global. The first one is a Request java
 instance
 and the second one is a Reply java instance. They belong to the Object
 model
 I designed.

 My application makes a request to the rule engine passing it a request as
 global,
 and get back a reply from it receiving a modified reply  global.

 I use a ruleflow to execute the rules.

 I think everything would be perfect and smooth if I had not the need to
 reason
 over the reply during the rule session

 That's the point!

 I do not just need to modify the reply global in order to get the final
 value outside
 the rule engine, but I DO need to reason over it INSIDE the rule session.

 So what should I do in order to reason over the reply INSIDE AND OUTSIDE
 the Rule Session?

 Should I insert the reply global into the WM?

 Let assume I do that, what happen if I pass the reply global to
 a drools function which alters the reply?

 Imagine a rule as follows and imagine I previously inserted the reply
 global into the WM:

 
 ...
 global my.object.model.Reply reply
 ...
 rule addcriminal_2_reply
   when
 $p: Person(job==criminal)
   then
  addCriminaltoReply(reply, $p );
 end
 

 Will this alteration affect the corresponding Reply() fact in the WM as
 well?


 Now let see this other rule:

 (Same, let imagine i previously inserted: insert(reply); )
 
 global my.object.model.Reply reply


 rule FullFill_replyCode
   when
  $r: Reply(code==john.wayne) from reply
   then
  $r.code.name = john;
  $r.code.lastname = wayne;
 end
 

 If I execute this rule in a ruleflow, do i need to update($r)
 in order to get the modified $r value in the next ruleflow node?

 And what happens to the global??? Will it get modified as well?

 I am sure you can help me.

 Bye bye.

 Massi


have you thought about initializing and asserting the Reply instance
in a separate rule at the beginning of the ruleflow?
After the ruleflow has finished, you can look for instances of Reply
in the WorkingMemory and retrieve your Reply object.

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


Re: [rules-users] Drools as OSGI bundle

2008-05-14 Thread Marcus Ilgner
Hi,

On Wed, May 14, 2008 at 1:12 PM, ekke [EMAIL PROTECTED] wrote:

  just seen that SpringSource published Drools as OSGI bundles
  http://www.springsource.com/repository/app/search?query=drools
  http://www.springsource.com/repository/app/search?query=drools
  - I'll create a request to get 4.0.7 - they published 4.0.4
  next two weeks I'll try the bundles
  ekke
  --

thanks for the hint! It's especially interesting that they apparently
managed to deploy core, compiler and JSR94 interface in separate
packages. Have you tried these packages already? I'd assume that one
has to specify Eclipse-RegisterBuddy: com.springsource.org.drools or
some equivalent so Drools can find the classes from the bundles that
are using it?
I tried to package Drools in OSGi bundles myself some weeks ago but
stumbled over some class loader issues after dividing the components
into their own bundles.
If SpringSource managed to build working manifest files, it would be
great if the Drools team would incorporate these into the
JAR-distribution.

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


Re: Re:[rules-users] JUnit testing

2008-05-22 Thread Marcus Ilgner
Glad that I could actually contribute something back to this great project.
I put together a patch for this issue in the JIRA at
http://jira.jboss.org/jira/browse/JBRULES-1618 as promised.

Best regards
Marcus

On Tue, May 20, 2008 at 2:34 AM, Mike Dean [EMAIL PROTECTED] wrote:

 Sorry to ask question and then figure it out!  I just substituted the actual
 name of my suite class instead of saying this.class and it works
 beautifully.  I am now testing Drools with JUnit 4 with no problems, after
 nearly six months!  THANK YOU.

 - Mike

 Mike Dean wrote:

 Thanks to both of you for pursuing this problem.  I have worked around it
 by putting my business classes and rules in a separate Drools project,
 testing everything there, and then copying them to my RCP.  I look forward
 to a better solution!

 I must confess Java ignorance, but I use a test suite and try to
 instantiate the engine once and then run a series of tests.  My crash
 occurs before I get to the individual tests.  However, the setUp routine
 is static, and your code work around cannot be executed in a static
 context.  Where exactly to you put the test for a null classloader?

 Thanks again.  I thought this issue simply died.


 Marcus Ilgner wrote:

 Hi Edson,

 thank you very much for testing this! Since I could not discern any
 differences between your approach and mine, I decided to resolve the
 issue manually by inserting a work-around in my test routine which
 sets the context class loader for the current thread before calling
 the method under test.

 if (Thread.currentThread().getContextClassLoader() == null) {

 Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 }

 My guess is that the custom JUnit 4 class runner
 (SpringJUnit4ClassRunner) somehow is responsible for the faulty
 behaviour.

 Thanks again
 Marcus


 On Mon, May 19, 2008 at 3:09 PM, Edson Tirelli [EMAIL PROTECTED] wrote:

All,

I see that the code in that spot is weak and could be improved.
 Although,
 using drools 4.0.7, I successfully created a junit 4 test that I paste
 bellow. Also, the whole drools code is tested with junit 3 and we have
 no
 problems. For instance, look at our integration tests here:

 http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/

The code I used to create the junit 4 test is based on the default
 example create by the drools plugin + the snippet you showed bellow:

 @Test
 public void testRuleBase() {
 try {

 //load up the rulebase
 RuleBase ruleBase = readRule();
 StatefulSession workingMemory =
 ruleBase.newStatefulSession();

 //go !
 Message message = new Message();
 message.setMessage(  Hello World );
 message.setStatus( Message.HELLO );
 workingMemory.insert( message );
 workingMemory.fireAllRules();
 workingMemory.dispose();

 } catch (Throwable t) {
 t.printStackTrace();
 Assert.fail(Something is wrong: +t.getMessage());
 }
 }

 /**
  * Please note that this is the low level rule assembly API.
  */
 private RuleBase readRule() throws Exception {
 //read in the source
 Reader source = new InputStreamReader(
 DroolsTest.class.getResourceAsStream( /Sample.drl ) );

 PackageBuilderConfiguration conf = new
 PackageBuilderConfiguration();
 JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
 conf.getDialectConfiguration(java);
 javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
 javaConf.setJavaLanguageLevel(1.5);

 PackageBuilder builder = new PackageBuilder( conf );
 builder.addPackageFromDrl( source );

 RuleBase ruleBase = RuleBaseFactory.newRuleBase();
 ruleBase.addPackage( builder.getPackage() );
 return ruleBase;
 }

 Hope it helps,
   Edson


 2008/5/19 Marcus Ilgner [EMAIL PROTECTED]:

 Hi list,

 I'm reviving this thread because I happen to have the same problem.

 On Sun, Mar 23, 2008 at 7:34 PM, Mike Dean [EMAIL PROTECTED] wrote:
 
  Thanks (months later!).  I have cut down my code example below to
 show
  this
  issue more clearly:
 
 
  John J. Franey wrote:
 
  NullPointerException on line 146 means classLoader is null.   That
 is
  odd.
  I have no idea why the code that gets classLoader won't work in
  eclipse's
  junit runtime, but does when run in your eclipse plugin.

  It seems indeed like during JUnit tests, the context classloader of
 the thread gets not set (null).

 The code leading up to the problem is as follows:
 PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
 JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
 conf.getDialectConfiguration(java);
 javaConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
 javaConf.setJavaLanguageLevel(1.5);
 RuleBase ruleBase

Re: [rules-users] Drools 4.0.7 supports Clustering and DB interaction ?

2008-05-30 Thread Marcus Ilgner
Hi,

On Fri, May 30, 2008 at 10:13 AM, Thalupula Ravi
[EMAIL PROTECTED] wrote:
 Hi,

 Can some one answer my questions regarding drools support

 1. is drools supports clustering?

I don't have that much experience on the topic, but I my guess would
be that if you write your code on top of some application server like
JBoss AS, clustering should be fairly transparent to your application.
You may want to have a look at
http://docs.jboss.com/jbossas/guides/clusteringguide/r2/en/html/ to
evaluate this approach with regard to your requirements.

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


Re: [rules-users] How to Configure Hibernate and use in Drools

2008-06-03 Thread Marcus Ilgner
Hi Sekhar,

On Mon, Jun 2, 2008 at 5:56 PM, RAJA SEKHAR REDDY MAYALURU
[EMAIL PROTECTED] wrote:
 hi ,

 i need to connect to data from a .drl file from a rule . i need to get the
 dynamic data from DB to frmae a rule .

 I have seen that Drools support  Hibernate .

 so how can i connect to DB from a drl to  DB using hibernate .

 i need to have dynamic (data ) rules in my drl file .

 we can configure hibernate on top of pojo , my main intrest is to know how
 to invoke hibernate from a drl file .

 how to execute named queries  in the rule project .

 please send me the steps to configure hibernate and use it in rules project
.
while you cannot directly access your ORM in Drools, it's nonetheless
quite simple: just write some DAO which provides methods to access
your objects - you could, for example, simply have a method which
takes the name of a NamedQuery and executes it - and register it as a
global. Then you can use the from syntax to retrieve the objects in
your rules.

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


Re: [rules-users] eclipse-jdtcore.jar

2008-06-03 Thread Marcus Ilgner
Hi,

just as a side note: I had one project using Eclipse which already
used another version of the JDT core. Encountering the same problem, I
just put the core-3.2.3.v_686_R32x.jar from Drools in my project, too,
and it worked without problems.

Best regards
Marcus

On Tue, Jun 3, 2008 at 3:25 PM, Augusto Rodriguez
[EMAIL PROTECTED] wrote:
 Hi Corneil,

 Unluckily I've seen that error more often that I would like. It's not a bug
 in drools, but is related to the dependencies of the drools-compiler.

 There's a big chance that you have a different version of the JDT core jar
 in your classpath (drools depends on version 3.2.3 - the filename of that
 jar is core-3.2.3.v_686_R32x.jar). This jar is used by drools to compile the
 rules.

 I hope this helps you to solve this issue.


 Cheers,
 Augusto

 Corneil du Plessis wrote:

 I am experiencing a conflict with a deployment:

 We used WebSphere Application Server 6.0.2.x in our integration testing
 environment and now the deployed application at a customer site is
 reporting
 the following exception:


 java.lang.NoSuchMethodError:
 org.eclipse.jdt.internal.compiler.CompilationResult: method
 getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem; not found
at

 org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(EclipseJ
 avaCompiler.java(Compiled Code))
at

 org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.
 java(Compiled Code))
at
 org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java(Compiled
 Code))
at

 org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaComp
 iler.java(Compiled Code))
at

 org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCo
 mpiler.java:51)
at

 org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java
 :342)

 Has anyone else comes across this?

 I am not sure where the JAR comes from because has not version info.

 ___
 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] eval question

2008-06-04 Thread Marcus Ilgner
Hi Mike,

On Wed, Jun 4, 2008 at 3:53 PM, Mike D [EMAIL PROTECTED] wrote:

 I'm close, but no cigar...

 I have a header record amount and did an accumulate on a detail amount.  The
 sum of the detail can be within a percent of the total.

 The $valueUsAmt is the header, and the totValue is the sum of lines...
 What I need to do is to take the valueUsAmt * .0001 and if that is = the
 abs value, all is good.

 eval($valueUsAmt.subtract($totValue).abs().compareTo(???) = 0)

 It's the * .0001 that is giving me the problem.  Any help would be
 appreciated.

 Thanks!

Have you tried compareTo(new Float($valueUsAm*0.0001f)) ?
I'm not 100% percent sure if this is faster, but eventually you could even use
Number(intValue  0) from
$valueUsAmt.subtract($totValue).abs().compareTo(new
Float($valueUsAm*0.0001f))

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


Re: [rules-users] precompile rules

2008-06-07 Thread Marcus Ilgner
Hi,

On Fri, Jun 6, 2008 at 10:02 PM, apor [EMAIL PROTECTED] wrote:

 hi, i am new with drools. one question , The rules can precompilar ?

yes, you can compile your rulebase and serialize then later
deserialize the compiled packages.
From the documentation:
7.1.4.4. Serializing

Practically all of the rulebase related objects in Drools are
serializable. For a working memory to be serializable, all of your
objects must of course be serializable. So it is always possible to
deploy remotely, and bind rule assets to JNDI as a means of using
them in a container environment.

Please note that when using package builder, you may want to check the
hasError() flag before continuing deploying your rules (if there are
errors, you can get them from the package builder - rather then
letting it fail later on when you try to deploy).

Best regards
Marcus

 Thank you
 --
 View this message in context: 
 http://www.nabble.com/precompile-rules-tp17700145p17700145.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] logging

2008-06-18 Thread Marcus Ilgner
On Wed, Jun 18, 2008 at 10:29 AM, Jaroslaw Kijanowski
[EMAIL PROTECTED] wrote:
 May be you could store the names of every fired rule in a global by putting
 drools.getRule().getName() into a list on the RHS.
 Then you could get all rules in your package ( pkg.getRules() ) into another
 list and diff both collections (another_list.removeAll(list) ).


 Thalupula Ravi wrote:

 Hi,
 How can i log that where a rule is executed or not for supplied data? If
 the
 rule fires, in 'then' section i can have a log statement.
 How can i log that the rule is not executed??

 I need to log in both scenarios.

 Thanks,
 Ravi Thalupula


Hi Ravi,

have you looked at the logging facilities included in Drools,
especially AgendaEventListener? That way you wouldn't have to manually
log activations in the RHS of every rule. Diffing the the names of
available rules versus those collected by the logging seems to me the
most straightforward solution, too.

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


Re: [rules-users] Re: access to in working memory generated objects

2008-06-18 Thread Marcus Ilgner
Hi,

On Wed, Jun 18, 2008 at 1:17 PM, Alexander Claus [EMAIL PROTECTED] wrote:
 I want to use rules which shall generate as a consequence a new java
 object.
 The GUI of my application shall display the new generated objekt.
 but how can the GUI of my application get informed by the rule engine that
 it has generated a new object (Warning)? And how the GUI or any other java
 component can access this new generated object from outside?

 Have a look at org.drools.event.WorkingMemoryEventListener.
 I think you find yourself how to use it.

 Best regards.
 Alexander Claus

another approach would be to register some service as a global to your
working memory. Then, when creating the object in the RHS of your
rule, you call some method on it like this

rule Value below threshold
when
FactX ( property   threshold)
then
Warning warning = new Warning( Under threshold );
service.addWarning(warning);
insert(warning);
end

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


Re: [rules-users] Beginner question about Dynamic Beans

2008-07-02 Thread Marcus Ilgner
Hi Francesco,

On Wed, Jul 2, 2008 at 10:28 AM, fmarchioni [EMAIL PROTECTED] wrote:

 Hi all drools users!
 I'm just learning Drools from the manual, I have a question about Dynamic
 Beans. I have added PropertyChangeSupport and listeners to my Beans: I can
 see that inside my rule, if I change
 one property the bean.

 rule Check Age

 salience 20

  when
 b : Buyer (age 18)
  then
  bankApp.addMessage(Messages.AGE_UNDER_18);
  b.setCash(4); // CHANGE OF PROPERTY
 end

 ..then all rules are fired back again. Is it the correct behaviour ? is
 there a way to re-evaluate only some of the Rules back again ?
 thanks a lot
 Francesco
 --

that's strange. From my experience, only those rules that depend on
the cash property should be fired if the new value triggers an
activation that wouldn't have been triggered for the old value. Could
you post the code of your PropertyChangeSupport implementation?

Here's some sample code from one of my projects:

public abstract class BindObject { /* simple proxy */
private PropertyChangeSupport propertyChangeSupport = new
PropertyChangeSupport(this);

public void addPropertyChangeListener(PropertyChangeListener _listener) {
propertyChangeSupport.addPropertyChangeListener(_listener);
}

public void addPropertyChangeListener(String _propertyName,
PropertyChangeListener _listener) {
propertyChangeSupport.addPropertyChangeListener(_propertyName,
_listener);
}

public void removePropertyChangeListener(PropertyChangeListener _listener) {
propertyChangeSupport.removePropertyChangeListener(_listener);
}

public void removePropertyChangeListener(String _propertyName,
PropertyChangeListener _listener) {
propertyChangeSupport.removePropertyChangeListener(_propertyName,
_listener);
}

protected void firePropertyChange(String _propertyName, Object
_oldValue, Object _newValue) {
propertyChangeSupport.firePropertyChange(_propertyName,
_oldValue, _newValue);
}

protected void firePropertyChange(String _propertyName, int
_oldValue, int _newValue) {
propertyChangeSupport.firePropertyChange(_propertyName,
_oldValue, _newValue);
}

protected void firePropertyChange(String _propertyName, boolean
_oldValue, boolean _newValue) {
propertyChangeSupport.firePropertyChange(_propertyName,
_oldValue, _newValue);
}
}

Now I simply inherit my classes from BindObject and write my setters like this:

public final static String PROPERTY_ARTICLE_NUMBER = articleNumber;
public void setArticleNumber(String _articleNumber) {
String oldValue = _articleNumber;
articleNumber = _articleNumber;
firePropertyChange(PROPERTY_ARTICLE_NUMBER, oldValue, articleNumber);
}

This has been working great for me so far.

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


Re: [rules-users] drools-eclipse sources?

2008-07-03 Thread Marcus Ilgner
On Thu, Jul 3, 2008 at 8:23 AM, Markus Helbig [EMAIL PROTECTED] wrote:
 Hi everybody,

 where can i get the sources for drools-eclipse? I remember they were
 in svn but currently i can't find them there.

 Cheers

 Markus

Hi Markus,

have a look at 
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-eclipse/

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


Re: [rules-users] insert a collection/ArrayList of facts

2008-07-03 Thread Marcus Ilgner
On Thu, Jul 3, 2008 at 2:55 PM, thomas kukofka [EMAIL PROTECTED] wrote:
 Hello,

 is it possible to insert an Arraylist of facts like this?:

 ArraList list;
 wm.insert (list);

 And if yes how can I iterate over the list in the when-part of the rule?
 The rule should be applied to all elements of the inserted list.

 A short drl-example would be perfect.

 Kind Regards
 Thomas


Hi Thomas,

I'm not sure if this is what you want but I think this should work:

rule ItemsFromList
when
  $list : List();
  $item : MyObject() from $list;
then
  // do something
end

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


Re: [rules-users] Using from

2008-07-17 Thread Marcus Ilgner
Hi Aziz,

On Thu, Jul 17, 2008 at 8:26 PM, Aziz Boxwala [EMAIL PROTECTED] wrote:
 I have the following class structure.

 Class GrandFather {
   ListFather fathers;
   public ListFather getFathers() {return fathers;}
 }

 Class Father {
int age;
   ListSon sons;
   public int getAge() {return age;}
   public ListSon getSons() {return sons;}
 }

 Class Son {
  int age;
   public int getAge() {return age;}
 }

 I'd like to write a rule that finds all the Fathers who have age  45 and
 have Sons where the son's age is greater than 5. But I can't figure out how
 to use from to iterate over father first and then over son.

 Any help will be greatly appreciated.

 Thanks,
 --Aziz

Something like this?

rule FatherAndSon
when
  $father : Father(age  45)
  $son : Son(age  5) from $father.sons
then
// do something
end

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


Re: [rules-users] How to avoid circular rule activation for non circular problems?

2008-07-24 Thread Marcus Ilgner
On Thu, Jul 24, 2008 at 3:28 PM, Ralph Ammon [EMAIL PROTECTED] wrote:
 I'd like to get some hints to improve the rules of my simple planning
 system.



 My simple planning system is derived from the HelloWorld Drools Project. The
 job of my planning system is to calculate startTime and endTime as function
 of duration and predecessors for each task. Each task has the fields

 long duration;

 SetTask predesessors;

 long startTime;

 long endTime;

 For each task the rule (endTime = startTime + duration) should hold. If a
 task has no predecessors, then its startTime should be 0. If a task has
 predecessors, then is should start at the latest endTime of all
 predecessors.


Maybe something like this would work?

rule Calc EndTime
no-loop true
when
$t : Task(endTime != (startTime+duration))
then
$t.setEndTime( $t.getStartTime() + $t.getDuration() );
System.out.println( Drools: Set  + $t.getName() + .EndTime to 
+ $t.getEndTime() );
update( $t );
end

Afaik, this will also enable Drools to only check this rule if one of
the attributes used in the LHS is changed. So if you change any other
field of your object at some point, this rule will not be evaluated
again.
Please note that I haven't checked the syntax but I think that it
should work like this.

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


Re: [rules-users] Handle activationCancelled Event

2008-07-25 Thread Marcus Ilgner
On Fri, Jul 25, 2008 at 1:04 PM, Claudio Rainoldi
[EMAIL PROTECTED] wrote:
 Hi everyone,
 i'm developing a java application using drools 4 for domotic control;
 i ve implemented a listener on my working memory with the
 method afterActivationFired(...) and activationCancelled(...) .
 At startup of my app i've write the following lines:

 listener = new FiredRulesListener();
 workingMemory.addEventListener(listener);

 Each time a rule is fired the method afterActivationFired(...) is called and
 it is ok; but when the rule stop to be true the
 method activationCancelled  isn't never called.

Afaik, activationCancelled works like this:
The fact is added, a rule would match, the activation is scheduled.
However, another rule (probably with higher priority) matches, too,
and it modifies the fact in a way that would make the first rule not
match - thus, the activation is cancelled and the corresponding
listener method gets called.

Somebody correct me if I'm wrong, please ;)
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Handle activationCancelled Event

2008-07-25 Thread Marcus Ilgner
On Fri, Jul 25, 2008 at 3:15 PM, Ingomar Otter [EMAIL PROTECTED] wrote:
 Why don't you use facts for control?
 when mylamp==on
 then
 assert/update sth?

 That looks easier to me.

 --I

Indeed. If I understand your problem correctly, the corresponding rule
should rather look like
rule Lamp is not on
when
 $lamp : Lamp(state != on)
then
// the lamp isn't on anymore - do something
end

Best regards
Marcus

 Am 25.07.2008 um 13:04 schrieb Claudio Rainoldi:

 Hi everyone,
 i'm developing a java application using drools 4 for domotic control;
 i ve implemented a listener on my working memory with the method
 afterActivationFired(...)
 and activationCancelled(...) .
 At startup of my app i've write the following lines:

 listener = *new* FiredRulesListener();
 workingMemory.addEventListener(listener);

 Each time a rule is fired the method afterActivationFired(...) is called
 and
 it is ok; but when the rule stop to be true the method
 activationCancelled  isn't
 never called.
 I try to be more clear:

 i 've the following rule:
 when mylamp==on
 then
 System.out.println(light 1 on);


 When i turn on the light 1 the method afterActivationFired(...)  is
 called,
 but when i turn off the light the method activationCancelled isn't called.
 Can someboy help me??
 Thanks in advance.


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


Re: [rules-users] Request for assistance in removing eval from a rule

2008-09-17 Thread Marcus Ilgner
Hi,

On Wed, Sep 17, 2008 at 12:48 AM, Warren, David [USA]
[EMAIL PROTECTED] wrote:
 If it helps, RulesUtil.containsKeywordString()  checks to see if a string
 passed in is present in a list of keywords held in the class.


maybe it would work if you asserted your keywords as a ListString
global and then did something like

s1 : Sensor( source == X, $rfp : RFP , $rfp memberOf keywordList , $tcn : TCN)

But I'm not sure if memberOf would work in this case since the
documentation states that it requires a variable.

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


Re: [rules-users] Storing RuleDescr and/or PackageDescr in a database table

2008-09-17 Thread Marcus Ilgner
Hi,

On Mon, Sep 15, 2008 at 10:11 PM, imraan [EMAIL PROTECTED] wrote:

 Users in my system will be able to configure their own rules to an extent
 through a UI.  I will create these rules programmatically using the
 org.drools.lang.descr package.  Right now, I am trying to see if its
 possible to store the RuleDescr or PackageDescr object(s) in a database.  Is
 there another way to store these objects in a database besides storing the
 contents of a DRL dump?

 Thanks,
 Imraan

those objects implement java.io.Serializable, so you can directly
write them to and from a storage type of your liking.

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


[rules-users] Defining fallback rules

2008-09-17 Thread Marcus Ilgner
Hi all,

I'm currently puzzled on how to implement a sort of fallback rule. In
my scenario I have a couple of articles and payments related to those
articles. Now I need to distribute royalties to the authors of these
articles. There's a common business logic which says distribute X
percent for articles of type T, Y percent for articles of type S and Z
percent for all other articles.
At first, my approach was to write the rules like this (omitting a
rule for type 'S' for the sake of brevity):

rule1
activation-group article1
salience 100
when
  $article : Article(type == 'T')
  $payment : Payment( article==$article )
then
  account(x%)
end

rule3
activation-group article1
salience 0
when
  $article : Article()
  $payment : Payment( article==$article )
then
  account(z%)
end

However, I quickly found out that the use of activation-group will
then only consider all articles of type T and ignore all other
fact-combinations. Retracting payments from the WM is also not
feasible since there may be other rules that should work on them.
I also cannot write the last rule as Article( type != 'T', type != 'S'
etc) since new article types may be added later on and it would not be
manageable to update all previously written rules (which may very well
number in thousands in the future).
Now I'm a bit stuck on this issue and would welcome any hints.

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


Re: [rules-users] Does drools have any trigger?

2009-04-28 Thread Marcus Ilgner
2009/4/24 Lindy hagan lindyha...@gmail.com:
 I was looking at  Blaze Advisor documentation it has  “when changed”
 operator that only fires when an attribute of an object changes. A business
 analyst might use it to watch for any important issue, such as a thermostat
 warning in a process plant or a particular stock reaching a certain price or
 volume.

 In similar way does Drools have this feature?

 Can any one correct if I am wrong: Rules can be updated by business users
 thru BRMS and Guvnor? (I did not get chance to go thru these)

Hi,

you can register your business objects (facts) as dynamic facts. They
will need to implement addPropertyChangeListener and related methods.
That way, as soon as a property that is used in a rule changes, the
rule will re-evaluate and fire if appropriate.
See section 2.5.4.7. of the docs for more information on this feature.

Best regards
Marcus

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


Re: [rules-users] The Eclipse JDT Core jar is not in the classpath error

2009-06-02 Thread Marcus Ilgner
2009/6/2 Chris Richmond crichm...@referentia.com:
 Hello,



 I am using netbeans and ivy with Drools 5.  I have successfully named,
 published the jars from drools to and could build my port of the stock
 ticker application in netbeans, but when I try to run it, I get the
 following error:





 java.lang.NoClassDefFoundError: org/antlr/runtime/tree/TreeNodeStream



 I have the antlr-runtime jar from the bin/lib on my classpath where I added
 all the others, but it always fails at this line

 In loadRuleBase() in Broker.java of the stock ticker sample



 builder.add( ResourceFactory.newInputStreamResource(
 Broker.class.getResourceAsStream( RULES_FILE ) ),

 ResourceType.DRL);.





 Does anyone have any ideas what jar I might be missing if it’s not the
 antlr-runtime?



 Thanks,

 Chris


Hi,

in one of my projects, I actually needed two different versions of
antlr in the classpath. Did you check if the class referenced in the
exception actually exists in the deployed antlr jar file?

Best regards
Marcus

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


Re: [rules-users] A relational SQL Database as RuleBase

2009-06-04 Thread Marcus Ilgner
On Wed, Jun 3, 2009 at 10:21 PM, r.r.neum...@freenet.de
r.r.neum...@freenet.de wrote:

 Hi guys,

 my question is listed in the topic. Is it possible? I read, that Drools 4
 provides such a feature but in this case, there is noch DSL available? Is
 this correct? What's about Drools 5, same thing?

 Thanks for an answer!

 Regards
 René


If you want to store the rules in a RDBMS in order to have them
accessible from many sources and/or outside your application, you may
want to consider using Guvnor to decouple the rule management from the
main application code.
Inside your app you can then download the rules which were created
within Guvnor from a URL on the application server.
Maybe that helps.

Best regards
Marcus

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