Re: [rules-users] Rules writing best practice?

2010-02-09 Thread Pegram, Macon
Regarding your comment for DAO's in the WHEN clause.   I'd say that's a
very strong anti-pattern.   In general our approach has been to look for
the absence of the fact being inserted, and move the DAO call into the
THEN clause.   I'm sure you're thinking, "what if my DAO doesn't return
anything?"  See the next discussion on breadcrumbing.  Drools will fire
your DAO call on every agenda scan (IE: whenever a fact is inserted,
modified, or retracted) if it's included in the WHEN clause.  

The other two tools we've used are to create what we call a "bootstrap"
agenda and use "breadcrumb" facts.  The bootstrap agenda is made up of a
small set of rules that handle loading up initial facts for our rule
set.  Using simple "Breadcrumb" facts you can cut down on
rescans/execution of rules.  We created a simple RuleBreadcrumb object
that contains a "name" attribute.  Note, we don't use breadcrumbing for
all rules.  We mostly use them in the bootstrap phase because there are
a lot of unrelated changes going on in working memory and there's a risk
that the DAO may not return a fact. Putting it all together it looks
something like this:

rule "Start Bootstrap Agenda"
salience 100
when
GoalsRequest(memberID != null) 
not RuleBreadcrumb(name == "Start Bootstrap Agenda")
then
drools.setFocus("bootstrap");
insert(new RuleBreadcrumb("Start Bootstrap Agenda"));
end

rule "Load Some Fact Bootstrap"
agenda-group "bootstrap"
when
   not RuleBreadcrumb(name == "Load Some Fact Bootstrap")
 SomeOtherCriteria(anAttribute != null)
then
   insert(new RuleBreadcrumb("Load Some Fact Bootstrap"));
insert(myDao.getSomeData());
end


So while I wouldn't call this a "best practices" document, those are at
least 2 patterns we've found to be performant and quite useful in our
own rule development. 

Macon

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Brice Figureau
Sent: Tuesday, February 09, 2010 4:40 AM
To: Rules Users List
Subject: [rules-users] Rules writing best practice?

Hi,

Is there a rules writing best practice document somewhere?

I'm asking the question because as a newbie rule writer (which doesn't
know anything about the underlying drools matching algorithm), I'm
wondering if my rules will behave gracefully.

For instance, I (ab)use a lot the from/accumulate to bring in the
knowledge some external facts coming from some DAO. 
All my rules use one time or more the same "from
dao.getInformationFromDatabase(  )" structure and I'm not
sure the algorithm is smart enough to cache this information which is
constant for a given inserted fact.

Should I instead insert all this information as facts prior to the rules
firing?
-- 
Brice Figureau
My Blog: http://www.masterzen.fr/

___
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] prevent infinite loops

2010-02-01 Thread Pegram, Macon
We have used a "BreadCrumb" fact to avoid this in the past.  We had a
situation where there wasn't a direct loop (rule A triggering rule A)
but rather a trifecta of facts (Rule A triggers Rule B which trigger
Rule C which triggered Rule A).

 

To solve for this we created a simple "RuleBreadCrumb" fact that takes a
"rule name" as a parameter.  We check for the non-existence of this fact
in our WHEN clause (on rules at risk of a loop) and insert the
RuleBreadCrumb fact in the THEN statements.  

 

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mauricio
Salatino
Sent: Friday, January 29, 2010 1:21 PM
To: Rules Users List
Subject: Re: [rules-users] prevent infinite loops

 

lock-on-active it's ok for that kind of situations

On Fri, Jan 29, 2010 at 3:00 PM, Garner, Shawn
 wrote:

Is there a good way to globally prevent infinite loops.
I had rule A and rule B and they both have FactA on the condition.
They also both modify FactA.
I tried no-loop and it prevents a loop of repeating RuleA over and over.
However it then goes from Rule A back to Rule B back to Rule A.
I fixed it by lock-on-active instead of no-loop.

However I was wondering if there was either a timeout feature or a
maximum number of times you could set a rule to be executed to error out
on infinite loops.

Any guidance would be appreciated.

Thanks,
SDG


-Message Disclaimer-

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable
law.
If you are not the intended recipient, any dissemination, distribution
or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to conn...@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic
signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.

While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to
provide
general information about the subject matter covered and is provided
with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to
legal,
tax, or accounting obligations and requirements.


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




-- 
- http://salaboy.wordpress.com
- http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -

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


Re: [rules-users] Does rule execution block when the Knowlege Agent is rebuild KnowlegeBase???

2010-01-27 Thread Pegram, Macon
We've tested this behavior under load and there is a brief (duration of
about 1 - 1.5 seconds) uptick when the rulebase switch happens, but we
noticed consistent and rapid recovery.

I have not confirmed this but I believe what happens is a new
KnowledgeBase is built, and once it's build is complete, it does a swap
which causes the brief uptick.   I don't believe there's any blocking
going on while the KnowledgeBase is built however.

Macon

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wing
Sent: Tuesday, January 26, 2010 7:10 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Does rule execution block when the Knowlege Agent
is rebuild KnowlegeBase???


Hello Drools User,

I am using Knowlege Agent to monitor changes in the repository.  I have
started the following services:

ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();

I was able to change the rules in the repository and the changes did get
pick up in my application and everything is working fine as expected.

However, I have a question regarding rule execution when the Knowlege
Base
is in the middle of being build by the Knowlege Agent.   What happen
when I
execute the rules using:

ksessionStateless = knowledgeAgent.newStatelessKnowledgeSession();
ksessionStateless.execute(ObjList);

Will the method ksessionStateless.execute(ObjList) block and wait until
the
Knowlege Base is finish being build by the knowledge agent or the method
won't block and just pick up the old Knowlege Base and then switch to
the
new knowlege base when the knowlege agent is finish building it?  Will
the
method ksessionStateless.execute(ObjList) block or not block?

thanks very much in advace for any help on this!

Wing Tang





-- 
View this message in context:
http://n3.nabble.com/Does-rule-execution-block-when-the-Knowlege-Agent-i
s-rebuild-KnowlegeBase-tp139987p139987.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] KnowledgeAgent doesn't load dsl files and dslrfile from a change-set correctly - JIRA:JBRULES-2377 updated

2010-01-27 Thread Pegram, Macon
Hmmm.. good catch.  Thanks for pointing that out.  I've up voted that
ticket as well.  The issues are in fact at least partially the same.
I've provided more detail in my ticket but added the below ticket in the
comments of my ticket to draw attention to the issue.  

 

I'd really love to see this resolved before 5.1 becomes final. 

 

Macon



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Esteban
Aliverti
Sent: Wednesday, January 27, 2010 6:35 AM
To: Rules Users List
Subject: Re: [rules-users] KnowledgeAgent doesn't load dsl files and
dslrfile from a change-set correctly - JIRA:JBRULES-2377 updated

 

I think it is related with
https://jira.jboss.org/jira/browse/JBRULES-2350

On Wed, Jan 27, 2010 at 1:20 AM, Pegram, Macon 
wrote:


I have updated the JIRA ticket with more detailed information.   If this
issue is important to you, please vote up its importance so that we can
hopefully capture the attention of the development team.

You can find the JIRA ticket at:
https://jira.jboss.org/jira/browse/JBRULES-2377

Thanks!
Macon

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Pritham
Sent: Tuesday, January 26, 2010 4:29 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] KnowledgeAgent doesn't load dsl files and
dslr file from a change-set correctly


Thanks for the heads up. I can even load the same change-set.xml via
kbuilder
and get the rules to fire and work, turns out that KnowledgeAgent has an
issue.

On a larger note, looking at 5.1M1, KnowledgeAgentImpl has changed a lot
(Mark Proctor) and a lot of "todos" and comments were uncommented in the
newer one. Is it recommended to try the class in an older distribution?
--
View this message in context:
http://n3.nabble.com/KnowledgeAgent-doesn-t-load-dsl-files-and-dslr-file
-from-a-change-set-correctly-tp139702p139849.html
<http://n3.nabble.com/KnowledgeAgent-doesn-t-load-dsl-files-and-dslr-fil
e%0d%0a-from-a-change-set-correctly-tp139702p139849.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

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information or otherwise protected by law.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply e-mail and destroy all copies of the original message.



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




-- 


Esteban Aliverti

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


Re: [rules-users] KnowledgeAgent doesn't load dsl files and dslr file from a change-set correctly - JIRA:JBRULES-2377 updated

2010-01-26 Thread Pegram, Macon

I have updated the JIRA ticket with more detailed information.   If this
issue is important to you, please vote up its importance so that we can
hopefully capture the attention of the development team.

You can find the JIRA ticket at:
https://jira.jboss.org/jira/browse/JBRULES-2377

Thanks!
Macon

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Pritham
Sent: Tuesday, January 26, 2010 4:29 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] KnowledgeAgent doesn't load dsl files and
dslr file from a change-set correctly


Thanks for the heads up. I can even load the same change-set.xml via
kbuilder
and get the rules to fire and work, turns out that KnowledgeAgent has an
issue.

On a larger note, looking at 5.1M1, KnowledgeAgentImpl has changed a lot
(Mark Proctor) and a lot of "todos" and comments were uncommented in the
newer one. Is it recommended to try the class in an older distribution?
-- 
View this message in context:
http://n3.nabble.com/KnowledgeAgent-doesn-t-load-dsl-files-and-dslr-file
-from-a-change-set-correctly-tp139702p139849.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

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information or otherwise protected by law.  Any unauthorized review, 
use, disclosure or distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by reply e-mail and destroy all copies of 
the original message.



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


Re: [rules-users] KnowledgeAgent doesn't load dsl files and dslr file from a change-set correctly

2010-01-26 Thread Pegram, Macon
I did my trace (which led to the comments below) on 5.1M1, but the I
noticed the problem originally on 5.0.1 so I don't believe there's any
version that will work for you at this time.

Macon

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Pritham
Sent: Tuesday, January 26, 2010 4:29 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] KnowledgeAgent doesn't load dsl files and
dslr file from a change-set correctly


Thanks for the heads up. I can even load the same change-set.xml via
kbuilder
and get the rules to fire and work, turns out that KnowledgeAgent has an
issue.

On a larger note, looking at 5.1M1, KnowledgeAgentImpl has changed a lot
(Mark Proctor) and a lot of "todos" and comments were uncommented in the
newer one. Is it recommended to try the class in an older distribution?
-- 
View this message in context:
http://n3.nabble.com/KnowledgeAgent-doesn-t-load-dsl-files-and-dslr-file
-from-a-change-set-correctly-tp139702p139849.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

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information or otherwise protected by law.  Any unauthorized review, 
use, disclosure or distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by reply e-mail and destroy all copies of 
the original message.



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


Re: [rules-users] KnowledgeAgent doesn't load dsl files and dslr file from a change-set correctly

2010-01-26 Thread Pegram, Macon
That's actually my ticket, and I've been hoping to get it resolved for
awhile now.  I've posted to this mailing list as well as the actual
ticket but haven't heard responses from anyone.

 

I've recently done more research into the issue, and have some updated
information that needs to be attached to the ticket (I'll try to get it
in shortly) but what it boils down to is a collision of two problems...

 

Problem 1: DSL and DSLR need to be in the same folder, but if you don't
explicitly list the resources for each item in the changeset, you can't
define an independent resource type.This is kind of silly and in my
mind defeats the benefits of the change-set.  The benefit in my mind of
a change set is being able to point it at a folder and have it scan for
new rule additions as well as changes. 

 

Problem 2: Internally the identified resources in the change set are
held in a hashmap.  Since there's no ordering to a hashmap, when they're
pulled out and added to the knowledgebuilder they could be added in any
order.  In order for a DSL and DSLR to work, they have to be added to
the KnowledgeBuilder in the proper order (DSL first then DSLR).  It does
not matter what order you list them in the change set, the rebuild code
in the KnowledgeAgent framework does not enforce any concept of ordering
or priority to resource types.

 

The documentation (since 5.0.1) has suggested that at some point they
plan to have "autodetection" of file types which would solve for problem
#1, but problem #2 would remain without some priority given to how the
KnowledgeBuilder is being instructed to construct rule sets.  This
problem is present even in the latest 5.1 milestone.

 

Unfortunately this has driven us to choose between having a DSL or
having hot deployment of rules (we've chosen the later)

 

Macon

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Steve Ronderos
Sent: Tuesday, January 26, 2010 2:58 PM
To: Rules Users List
Subject: Re: [rules-users] KnowledgeAgent doesn't load dsl files and
dslr file from a change-set correctly

 


Pritham, 

I've experienced this issue before as well.  It has to do with the way
that the KnowledgeAgent subscribes to resources.  I believe behind the
scenes the resources are loaded in an arbitrary order.  There is a JIRA
bug report already filed: 

https://jira.jboss.org/jira/browse/JBRULES-2377
  

Hope this helps, 

Steve 

rules-users-boun...@lists.jboss.org wrote on 01/26/2010 01:07:29 PM:

> [image removed] 
> 
> [rules-users] KnowledgeAgent doesn't load dsl files and dslr file 
> from a change-set correctly 
> 
> Pritham 
> 
> to: 
> 
> rules-users 
> 
> 01/26/2010 01:10 PM 
> 
> Sent by: 
> 
> rules-users-boun...@lists.jboss.org 
> 
> Please respond to Rules Users List 
> 
> 
> I have a folder in classpath:
> 
> dsl/global.dsl
> rules/section-A.dslr
> rules/section-A/page-1.dslr
> 
> I create a knowledge base like this:
> 
> public KnowledgeBase createKnowledgeBase() throws
DroolsParserException,
> IOException {
> 
> KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory
> .newKnowledgeBuilder();
> 
> knowledgeBuilder.add(ResourceFactory
> .newClassPathResource("dsl/global.dsl"),
> ResourceType.DSL);
> knowledgeBuilder.add(ResourceFactory
> .newClassPathResource("rules/section-A.dslr"),
> ResourceType.DSLR);
> knowledgeBuilder.add(ResourceFactory
> .newClassPathResource("rules/section-A/page-1.dslr"),
> ResourceType.DSLR);   
> 
> if (knowledgeBuilder.hasErrors()) {
> throw new
RuntimeException(knowledgeBuilder.getErrors().toString());
> }
> 
> KnowledgeBase knowledgeBase =
KnowledgeBaseFactory.newKnowledgeBase();
>
>
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages
());
> 
> return knowledgeBase;
> }
> 
> // code
> knowledgeBase = createKnowledgeBase();
> session = knowledgeBase.newStatefulKnowledgeSession();
> // insert facts
> session.fireAllRules();
> session.dispose();   
> 
> The above code works and I can get a unit test to work that processes
rules
> accordingly. I can see my dslr converting to a drl using the "drl
viewer"
> correctly (provided I temporarily place the dsl file in the same
location
> since expander doesn't accept a relative path).
> 
> The problem, however is when I use a change-set.xml and a
KnowledgeAgent,
> things don't work 
> 
> code for loading via knowledgeAgent
> 
> public static KnowledgeBase loadKnowledgeBase() throws
> DroolsParserException, IOException {
> agent = KnowledgeAgentFactory.newKnowledgeAgent("msll agent");
>
>
agent.applyChangeSet(ResourceFactory.newClassPathResource("change-set.xm
l"));
> 
> return agent.getKnowledgeBase();
> }   
> 
> 
>   xmlns:xs='http://www.w3.org/2001/XMLSche

Re: [rules-users] Testing individual rules

2009-12-02 Thread Pegram, Macon
Yes... 

 

We've used a combination of JUnit, and Easymock to test individual
rules.  At a very high level, we do the following:

 

-  In the static setupBeforeClass() method we construct a
KnowledgeBuilder, load any necessary rule files, and construct a
KnowledgeBase using the KnowledgeBuilder.

-  In the setup() method we initialize any create EasyMock
objects, create a KnowledgeSession, attach any globals and setup a
KnowledgeBase audit logger (KnowledgeRuntimeLoggerFactory), 

-  In the individual test we construct an ArrayList of Command
objects to do fact insertion, rule firing, and run a query (to extract
inserted or modified facts from the Working Memory) like so:

oCmds.add (CommandFactory.newInsert(aFact))

oCmds.add(CommandFactory.newFireAllRules())

oCmds.add(CommandFactory.newQuery(xxx, ));

-  We batch execute the commands (see session.execute()) and use
the ExecutionResults to extract query results. 

-  Finally we use the JUnit framework to assert expectations
that come out of our ExecutionResults.

 

I've left a lot of details out, but if you do Javadoc lookups on the
API's I've mentioned above most of it should be clear.

 

We've written over 1,000 unit tests this way, and they run quite fast.

 

Macon

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Asif Iqbal
Sent: Wednesday, December 02, 2009 6:59 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Testing individual rules

 

Hi,

 

This is general question, is it possible to test individual rules in a
rules file? And using what, I am familiar with JUnit, but have seen Fit
being used in examples.

 

regards

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


[rules-users] Can DSL / DSLR be loaded in a changeset?

2009-10-29 Thread Pegram, Macon
All,

 

I asked this question earlier this week, but didn't get a response.  I
may have provided too much information, so let me distill it down to
this simple question 

 

Can DSL/DSLR files be loaded and accessed as part of a KnowledgeBase
constructed using the KnowledgeAgent / changeset model in Drools 5.0.1

 

My test code, attached to my earlier post, suggests this does not work.


 

Macon

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


Re: [rules-users] Is there any way to hook-up Drools 4.0 RuleBase(session) to a Drools 5.0 KnowledgeBase (session) ??

2009-10-27 Thread Pegram, Macon
To accomplish this is largely a "renaming" operation.  They are
syntactically the same.  I did a similar thing a few months ago and it
mostly involved renaming everything from RuleXXX to KnowledgeXXX.

 

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Chetan Mahadev
Sent: Monday, October 26, 2009 4:10 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Is there any way to hook-up Drools 4.0
RuleBase(session) to a Drools 5.0 KnowledgeBase (session) ??

 

 

Hi ,

 

We have been using drools 4.0 in our application. All the rules are
loaded using RuleBase and PackageBuilder.

The application is pretty old, and has got lot of work into it.

 

Now we want to use Drools 5.0 CEP (Fusion) along with the old rules
(based on drools 4.0).

 

But the problem , is, how can we hook-up the old "RuleBase" based
sessions with the "KnowledgeBase" sessions of Drools 5.0??

 

The use case is:

 

1.Fact enters the system ( asserted using Rulebase), is enriched by
rules (Based on Drools 4.0)

2.The same fact will be treated as EVENT (for CEP), for further
correlation of Events (facts)  using KnowledgeBase as proposed i Drools
5.0.

 

I am facing difficulty in hooking up the two sessions. Is there an way??

 

Following is the test i did. ( http://drools.pastebin.com/m7d6c613b)

 

Can anybody help??

 

IN MY JAVA CODE

1.  //load up the rulebase

2.  RuleBase ruleBase = readRule(); // Read and load
rules frm a packagebuilder()

3.  StatefulSession rBaseSession =
ruleBase.newStatefulSession();

4.  Message message = new Message();

5.  message.setMessage(  "Hello World" );

6.  message.setStatus( Message.HELLO );

7.  rBaseSession.insert( message );

8.   

9.  @@//Load KnoweledgeBase  

10. KnowledgeBase kbase = loadRuleBase();
// I set options for EventProcessing in loadRuleBase()

11. KnowledgeSessionConfiguration conf = 

12.
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();

13. ((SessionConfiguration)
conf).setClockType( ClockType.REALTIME_CLOCK );

14. StatefulKnowledgeSession
kbaseSession =  kbase.newStatefulKnowledgeSession(conf,null);

15. 

16. rBaseSession.fireAllRules();  

17.  

 

IN MY RULE FILE

1.  rule "Hello World"

2.  when

3.  $m : Message( status == Message.HELLO, message :
message )

4.  then

5.  System.out.println( message ); 

6.  Message message2 = new Message();

7.  message2.setMessage(  "Hello World" );

8.  message2.setStatus( Message.HELLO );

9.   

10. WorkingMemoryEntryPoint eventsignaturestream =
drools.getEntryPoint("EVENT SIGNATURE STREAM") ;  // I Get a NULLPOINTER
EXCEPTION here

11. eventsignaturestream.insert(message2);

12.  

13. end

 

 

 

 

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


[rules-users] DSL, DSLR and Changesets...

2009-10-26 Thread Pegram, Macon
All,

 

Are DSL and DSLR files supported by the KnowledgeAgent / Changeset code.
Here's the details of my test case:

 

I have a Changeset file I'm trying to load which looks like the
following:

 





   





   



 

There's a single DSL and a single DSLR file in this folder.   I'm
loading the change set as follows:

 

KnowledgeAgent ka = KnowledgeAgentFactory.newKnowledgeAgent(agentName);

  ka.applyChangeSet(ResourceFactory.newClassPathResource(agentName +
"-changeset.xml", getClass()));

 

When I run this code, the logger suggests the DSL and DSLR are being
loaded and compiled:

 

[2009:10:299 16:10:52:info] KnowledgAgent created, with configuration:

monitorChangeSetEvents=true scanResources=true scanDirectories=true

++ Constructing and applying changeSet: dsl-test

[2009:10:299 16:10:52:info] KnowledegAgent has started listening for
ChangeSet notifications

(null: 3, 68): cvc-elt.1: Cannot find the declaration of element
'change-set'.

[2009:10:299 16:10:317:info] KnowledgAgent applying ChangeSet

[2009:10:299 16:10:317:debug] KnowledgeAgent subscribing to
directory=[ClassPathResource path='com/test/general/']

[2009:10:299 16:10:317:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.knowledgeagenti...@b9b618 to
resource=[ClassPathResource path='com/test/general/']

[2009:10:299 16:10:317:debug] ResourceChangeScanner subcribing
notifier=org.drools.io.impl.resourcechangenotifieri...@61ec49 to
resource=[ClassPathResource path='com/test/general/']

[2009:10:299 16:10:317:debug] KnowledgeAgent subscribing to directory
content resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test.dsl']

[2009:10:299 16:10:317:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.knowledgeagenti...@b9b618 to
resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test.dsl']

[2009:10:299 16:10:317:debug] ResourceChangeScanner subcribing
notifier=org.drools.io.impl.resourcechangenotifieri...@61ec49 to
resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test.dsl']

[2009:10:299 16:10:317:debug] KnowledgeAgent subscribing to directory
content resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test-dsl.dslr']

[2009:10:299 16:10:317:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.knowledgeagenti...@b9b618 to
resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test-dsl.dslr']

[2009:10:299 16:10:317:debug] ResourceChangeScanner subcribing
notifier=org.drools.io.impl.resourcechangenotifieri...@61ec49 to
resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test-dsl.dslr']

[2009:10:299 16:10:317:debug] KnowledgeAgent subscribing to
directory=[ClassPathResource path='com/hmc/test/general/']

[2009:10:299 16:10:317:debug] ResourceChangeNotification subscribing
listener=org.drools.agent.impl.knowledgeagenti...@b9b618 to
resource=[ClassPathResource path='com/hmc/test/general/']

[2009:10:299 16:10:317:debug] KnowledgeAgent ChangeSet requires
KnowledgeBuilder

[2009:10:299 16:10:317:debug] KnowledgeAgent rebuilding KnowledgeBase
using ChangeSet

[2009:10:299 16:10:317:debug] KnowledgeAgent building
resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test.dsl']

[2009:10:299 16:10:333:debug] KnowledgeAgent building
resource=[FileResource
file='C:\bea\user_projects\workspaces\alerts\rules-kb\test-kb\target\tes
t-classes\com\test\general\test-dsl.dslr']

[2009:10:299 16:10:333:info] KnowledgeAgent new KnowledgeBase now built
and in use

 

However after load is completed I try to run the following code:

  

  System.out.println("KB Info");

  Collection pkgs =
ka.getKnowledgeBase().getKnowledgePackages();

  for (KnowledgePackage kp : pkgs) {

for (Rule rule : kp.getRules()) {

  System.out.println("Rule: " + rule.getName() + ", " +
ule.getPackageName());

for (String attribs : rule.listMetaAttributes())

  System.out.println(" " + attribs);

  }

}

}

 

I get NO output (except of course "KB Info").

 

If I initialize the knowledgebase like this:

 

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

.newKnowledgeBuilder();

kbuilder.add(ResourceFactory

 
.newClassPathResource("com/test/general/test.dsl"),

ResourceType.DSL);

 

kbuilder.add(ResourceFactory

 
.newClassPathResource("com/test/general/test-dsl.dslr"),


Re: [rules-users] Rule is not firing

2009-10-26 Thread Pegram, Macon
Assuming a proper classpath, the attached jar file runs from the
commandline. 

 

java -cp test-case.jar TestDrive

 

I suspect your issue may stem from the setup code calling your rule
instead of the rules themselves. I've included source code in the jar
file, but I'll include it inline in this message for reference sake as
well.

 

  public static void main(String[] args) throws Exception {

KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();

 
kbuilder.add(ResourceFactory.newClassPathResource("test/rule.drl"),Resou
rceType.DRL);

if (kbuilder.hasErrors()) {

  throw new Exception(kbuilder.getErrors().toString());

}

 

KnowledgeBase kbase =
KnowledgeBaseFactory.newKnowledgeBase();

kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());



StatelessKnowledgeSession session =
kbase.newStatelessKnowledgeSession();



Message testMessage = new Message();

testMessage.setMessage("Hello");



session.execute(testMessage);

  }

 

 

Macon

 

 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of satyasri.ch
Sent: Monday, October 26, 2009 6:34 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Rule is not firing

 

 

Hi ,

 

I am doing the sample drools project.

 

Below are the sample rule and Fact class.

 

when Running from eclipse ide both rules are working fine.

Where as running the rule outside eclipse  ide only second rule fired .

 

Suggest me any ideas

 

 

--

package test

import test.Message;

 

 

rule "Your First Rule"

dialect "mvel" 

when

m:Message(  )

eval(m.getMessage() == "Hello")

then

System.out.println("First Rule fired");

end

 

rule "Your Second Rule"

dialect "mvel" 

when

eval(true)

then

System.out.println("Second Rule fired");

end

 



 

package test;

public class Message{

private String message;

public String getMessage(){

return this.message;

}

 

public void setMessage(String message) {

this.message = message;

}

 

}

 

 

Thanks,

Satyasri.

-- 

View this message in context:
http://www.nabble.com/Rule-is-not-firing-tp26056180p26056180.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



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


[rules-users] New DSL question...Interpreting constants...

2009-10-22 Thread Pegram, Macon
Given the following rules (contrived example):

rule "Monetary 1"

  when

Currency(typeID in (CurrencyConst.DOLLAR,
CurrencyConst.EURO, CurrencyConst.YEN))

  then

  insert(new Fact());

end   

 

 

rule "Monetary 2"

  when

Currency(typeID in (CurrencyConst.RUBLES,
CurrencyConst.WON))

  then

  insert(new Fact());

end   

 

 

Is it possible to map constant values into a DSL?  

 

So the above rules could be partially rewritten as:

rule "Monetary 1"

  when

Currency is one of DOLLAR, EURO, YEN 

  then

  insert(new Fact());

end   

 

rule "Monetary 2"

  when

Currency is one of RUBLES, WON 

  then

  insert(new Fact());

end   

 

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


Re: [rules-users] DSL questions....

2009-10-22 Thread Pegram, Macon
Lucas,

 

Great!  Thanks for the quick reply. 

 

Macon

 



From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Lucas Amador
Sent: Thursday, October 22, 2009 10:58 AM
To: Rules Users List
Subject: Re: [rules-users] DSL questions

 

Hi Macon,

you can write all on one statement, but must be separated by comma

 


[when]User is eligible for "{testCD}"=not MyFeature(testCD == 
"{testCD}") ,  $eligible : FeatureEligible(testCD = "{testCD}")

 

and you will not get any overhead at runtime because all the interpretation 
happens at compilation, as you says

 

lucaz

 

El 22/10/2009, a las 11:28, Pegram, Macon escribió:





All,

 

Given the following rule:

 

rule "Add ABC123 Feature"

  when

not MyFeature(testCD == "ABC123")

UserRequest(someValue == "ABC123_FEATURE")

$eligible : FeatureEligible(testCD == "ABC123")

  then

insert(new MyFeature($eligible));

end

 

I'd like to create a DSL.   Notice that "testCD" is the same value.   

 

Is it possible to apply a value captured in a DSL and use it in more than one 
condition?In the above scenario we want to see if the user is eligible for 
the feature ABC123, and check whether or not that feature has already been 
added in working memory.

 

The DSL version of the rule might look something like:
rule "Add ABC123 Feature"

  when

  User is eligible for "ABC123"

  User requests "ABC123_FEATURE"

  then

Add feature  

end

 

Would I need to write the DSL for the "ABC123" piece like this?

[when]User is eligible for "{testCD}"=not MyFeature(testCD == "{testCD}")   
$eligible : FeatureEligible(testCD = "{testCD}")
 
Or will I always need to create 2 statements? 
 
What are the performance implications of using a DSL?  Is there extra overhead 
at runtime or does all the interpretation occur at rule compilation?
 
Thanks!
Macon
 
 

 



___
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] DSL questions....

2009-10-22 Thread Pegram, Macon
All,

 

Given the following rule:

 

rule "Add ABC123 Feature"

  when

not MyFeature(testCD == "ABC123")

UserRequest(someValue == "ABC123_FEATURE")

$eligible : FeatureEligible(testCD == "ABC123")

  then

insert(new MyFeature($eligible)); 

end

 

I'd like to create a DSL.   Notice that "testCD" is the same value.

 

Is it possible to apply a value captured in a DSL and use it in more
than one condition?In the above scenario we want to see if the user
is eligible for the feature ABC123, and check whether or not that
feature has already been added in working memory. 

 

The DSL version of the rule might look something like:
rule "Add ABC123 Feature"

  when

  User is eligible for "ABC123"

  User requests "ABC123_FEATURE"

  then

Add feature   

end

 

Would I need to write the DSL for the "ABC123" piece like this?

[when]User is eligible for "{testCD}"=not MyFeature(testCD ==
"{testCD}")   $eligible : FeatureEligible(testCD = "{testCD}")
 
Or will I always need to create 2 statements? 
 
What are the performance implications of using a DSL?  Is there extra
overhead at runtime or does all the interpretation occur at rule
compilation?
 
Thanks!
Macon
 
 

 

 

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


Re: [rules-users] How to deploy Guvnor on Weblogic 9.x / 10.x - Fixing depdencies

2009-10-16 Thread Pegram, Macon
I think the bottom line here is that even though it's going to generate a 
fatter WAR file, it would be helpful if the Drools team made fewer assumptions 
about the JARs present in the environment, and modify the build poms to include 
all dependencies.  

 

>From what I recall of my experience (and you'll have to forgive me, I did this 
>about 4 months ago), it was the lack of "Faces" that required most of the jar 
>files I had to pull in.


Macon

 



From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wesley Akio Imamura
Sent: Friday, October 16, 2009 10:39 AM
To: Rules Users List
Subject: Re: [rules-users] How to deploy Guvnor on Weblogic 9.x / 10.x

 

Thank you Macon,

I just got guvnor 5.0 running on Weblogic 11g in a different way just putting 
some jboss-seam-2.1.2 libs inside the war.



2009/10/16 Pegram, Macon 

I was asked how I deployed Guvnor on Weblogic 10.x.  I believe the procedure 
will be the same for both 9.x and 10.x... 

 

You will have to make some changes to the WAR file.  

 

1.  Create a weblogic.xml file like the one below and put it in WEB-INF\



http://www.bea.com/ns/weblogic/weblogic-web-app";>



  true





 

2. Added the following JARS in WEB-INF\lib

commons-beanutils-1.7.0.jar

commons-codec-1.3.jar

commons-digester-1.8.jar

commons-discovery-0.4.jar

concurrent-1.3.4.jar

hibernate-annotations-3.4.0.GA.jar

hibernate-commons-annotations-3.1.0.GA.jar

hibernate-core-3.3.0.SP1.jar

hibernate-entitymanager-3.4.0.GA.jar

myfaces-api-1.2.6.jar

myfaces-impl-1.2.6.jar

 

Now don't ask me how I came up with this list.  I honestly don't remember.  I 
believe it was largely trial an error.  Basically starting/restarting the app 
server and see which "NoClassDefinitionFound" error came up next.   

 

I think the Drools builds process lists a few things as "provided" in the Maven 
setup for Guvnor assuming they're present in the app server itself.  In JBoss 
they likely are, but in other vendors they are not.  

 

Macon

 

 


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




-- 
Wesley Akio Imamura
São Paulo - SP - Brazil

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


[rules-users] How to deploy Guvnor on Weblogic 9.x / 10.x

2009-10-16 Thread Pegram, Macon
I was asked how I deployed Guvnor on Weblogic 10.x.  I believe the
procedure will be the same for both 9.x and 10.x... 

 

You will have to make some changes to the WAR file.  

 

1.  Create a weblogic.xml file like the one below and put it in WEB-INF\



http://www.bea.com/ns/weblogic/weblogic-web-app";>



  true





 

2. Added the following JARS in WEB-INF\lib

commons-beanutils-1.7.0.jar

commons-codec-1.3.jar

commons-digester-1.8.jar

commons-discovery-0.4.jar

concurrent-1.3.4.jar

hibernate-annotations-3.4.0.GA.jar

hibernate-commons-annotations-3.1.0.GA.jar

hibernate-core-3.3.0.SP1.jar

hibernate-entitymanager-3.4.0.GA.jar

myfaces-api-1.2.6.jar

myfaces-impl-1.2.6.jar

 

Now don't ask me how I came up with this list.  I honestly don't
remember.  I believe it was largely trial an error.  Basically
starting/restarting the app server and see which
"NoClassDefinitionFound" error came up next.   

 

I think the Drools builds process lists a few things as "provided" in
the Maven setup for Guvnor assuming they're present in the app server
itself.  In JBoss they likely are, but in other vendors they are not.  

 

Macon

 

 

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


Re: [rules-users] Drool 5 API and Agenda Listeners

2009-10-12 Thread Pegram, Macon
Using the listener, you could construct your own agenda stack to track
what's going on.  The AgendaEventListener interface has the methods:
agendaGroupPopped(AgendaGroupPoppedEvent event) 
agendaGroupPushed(AgendaGroupPushedEvent event)

In your listener, construct a java.util.Stack, and just Push/Pop
agenda-group information that you retrieve from the AgendaGroupXXXEvent
onto/off of your internal Stack.  You can do similar tracking of event
firing with the "before" or "after" ActivationFired event.  Construct a
list to capture the sequence of events.  

I'm not entirely clear on what you're trying to accomplish, but the
event listener interface provides hook points for all the related events
on the agenda, so you should be able to craft a listener to do whatever
you need.  I've used a similar mechanism in unit testing to validate
correct processing of a set of agenda groups.  

Macon

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of SPAAARKY21
Sent: Sunday, October 11, 2009 7:34 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Drool 5 API and Agenda Listeners


Thanks for clearing that up for me.

As for the agenda, I am writing an agenda listener already but the
problem
is getting the information I want.  In Drools 5, an
org.drools.event.rule.AgendaEventListener's afterActivationFired()
method
takes an org.drools.event.rule.AfterActivationFiredEvent object but
where do
I go from there?  The getKnowledgeRuntime() method returns a
KnowledgeRuntime, which has a getAgenda() method that returns an
org.drools.runtime.rule.Agenda.  But that Agenda doesn't have methods
for
getting all of the agenda groups on the focus stack.  It only has
methods to
clear the agenda or get an activation/agenda/rule flow group by name.
What
I am looking for is a way to get all of the agenda groups on the focus
stack
(as a List or through an Iterator,) and then get each activation from
each
one of those groups.

In Drools 4, I would have been using an org.drools.Agenda instead, which
has
a getAgendaGroups() method and AgendaGroup has a getActivations()
method. 
In a Drools 5 org.drools.runtime.rule.AgendaGroup, there are only three
methods - clear(), getName() and setFocus() - so even if I could get all
of
the AgendaGroups, it wouldn't do me any good.  Do you see why I'm having
trouble doing anything useful with the new API?  In Drool 5, are you
supposed to approach this in a different way (not in an agenda
listener?)


Pegram, Macon wrote:
> 
> The primary reason to move to the "Knowledge APIs" apart from what
> you've already mentioned is that they help to bring together the
newest
> features of Drools.  In a single KnowledgeBase you can now have not
only
> rules, but Flows, and Complex Event Processing.   
> 
> As to tracking activity on the agenda... there's two ways...
> 1. If you're using Eclipse, one great feature of the Drools plugin is
> the Audit Log.  You can start logging with the following code:
> KnowledgeRuntimeLogger logger =
> KnowledgeRuntimeLoggerFactory.newFileLogger(knowledgeSession,
FILENAME);
> Then open the resulting log in the Eclipse Drools Audit Log tab and
get
> a pretty good graphical representation of what happened during your
run.
> See the following URL for a screenshot:
>
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/h
> tml_single/index.html#d0e6801
> 
> 2. Create your own AgendaEventListener.   Simply implement the
interface
> and place whatever actions you want on each event.  Then attach it to
> your session before you start processing like this:
> knowledgeSession.addEventListener(new YourAgendaListener());
> 
> Macon
> 
> -Original Message-
> From: rules-users-boun...@lists.jboss.org
> [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of SPAAARKY21
> Sent: Sunday, October 11, 2009 12:26 PM
> To: rules-users@lists.jboss.org
> Subject: [rules-users] Drool 5 API and Agenda Listeners
> 
> 
> I recently moved from Drool 4 to 5 in a little example application I
had
> written.  At first I hesitated because I thought the API had changed
> drastically. When I did upgrade, I found that there were few changes. 
> However, I was still using all of the "Rule" classes instead of the
> "Knowledge" classes - like RuleBase and StatefulRuleSession instead of
> KnowledgeBase and StatefulKnowledgeBase.  It sounds like the
"Knowledge"
> API
> is the way of the future so to speak but I haven't been able to find
> much
> information on it.  What is the advantage in using the new "Knowledge"
> API? 
> Will the "Rule" API become deprecated at some point?
> 
> Anyway, after switching to the Knowledge AP

Re: [rules-users] Drool 5 API and Agenda Listeners

2009-10-11 Thread Pegram, Macon
The primary reason to move to the "Knowledge APIs" apart from what
you've already mentioned is that they help to bring together the newest
features of Drools.  In a single KnowledgeBase you can now have not only
rules, but Flows, and Complex Event Processing.   

As to tracking activity on the agenda... there's two ways...
1. If you're using Eclipse, one great feature of the Drools plugin is
the Audit Log.  You can start logging with the following code:
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(knowledgeSession, FILENAME);
Then open the resulting log in the Eclipse Drools Audit Log tab and get
a pretty good graphical representation of what happened during your run.
See the following URL for a screenshot:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/h
tml_single/index.html#d0e6801

2. Create your own AgendaEventListener.   Simply implement the interface
and place whatever actions you want on each event.  Then attach it to
your session before you start processing like this:
knowledgeSession.addEventListener(new YourAgendaListener());

Macon

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of SPAAARKY21
Sent: Sunday, October 11, 2009 12:26 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Drool 5 API and Agenda Listeners


I recently moved from Drool 4 to 5 in a little example application I had
written.  At first I hesitated because I thought the API had changed
drastically. When I did upgrade, I found that there were few changes. 
However, I was still using all of the "Rule" classes instead of the
"Knowledge" classes - like RuleBase and StatefulRuleSession instead of
KnowledgeBase and StatefulKnowledgeBase.  It sounds like the "Knowledge"
API
is the way of the future so to speak but I haven't been able to find
much
information on it.  What is the advantage in using the new "Knowledge"
API? 
Will the "Rule" API become deprecated at some point?

Anyway, after switching to the Knowledge API, I have been working on an
agenda listener I had written.  What I want to do is iterate through
agenda
groups on the focus stack and, for each group, iterate through the
activations in the order in which they are queued up.  However, I don't
see
any way to do that.  In fact, since switching to Drools 5 and the
"Knowledge" API, it looks like the API for dealing with the agenda and
activations and whatnot has become quite small.  Or at least it is when
you
stick to the interfaces.  Am I missing a better way of doing this?

Brandon
-- 
View this message in context:
http://www.nabble.com/Drool-5-API-and-Agenda-Listeners-tp25844904p258449
04.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] (no subject)

2009-10-01 Thread Pegram, Macon
What you need to do is implement your own SystemEventListener
implementation to override the default one.  Before you do anything
meaningful with Drools, you'll want to override the default by calling:

   SystemEventListenerFactory.setSystemEventListener();

 

Here's a basic no-op listener:

new SystemEventListener () {

 

  public void debug(String arg0) { }

  public void debug(String arg0, Object arg1) {}

  public void exception(Throwable arg0) {}

  public void exception(String arg0, Throwable arg1) {}

  public void info(String arg0) {}

  public void info(String arg0, Object arg1) {}

  public void warning(String arg0) {}

  public void warning(String arg0, Object arg1) {}

  

};

 

In reality what you probably want to do is hook in your application's
logger here so it will respect the same log levels the rest of your
application runs under.

 

Macon

 

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Steve Ronderos
Sent: Wednesday, September 30, 2009 12:53 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] (no subject)

 


Hello Drools Users, 

I've been looking into why Drools 5 is logging debug and info messages
to System.out in my app and trying to figure out how to make it stop.
It looks like the SystemEventListener that the
SystemEventListenerFactory returns is a DelegatingSystemEventListener
that delegates to a PrintStreamSystemEventListener.  This, by default,
uses System.out as the print stream target.  I looked into the Factory
and it looks like I can provide a different SystemEventListener or
SystemEventListenerProvider, but it also mentions that it did not find
anything in the properties, so it fails over to the default
SystemEventListenerProvider.  Is there a way to configure a custom
SystemEventListener or SystemEventListenerProvider so that you don't
have to call SystemEventListenerFactory.setSystemEventListenerProvider()
at startup? 

Thanks, 

Steve Ronderos

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


Re: [rules-users] Push model for rule updates?

2009-09-29 Thread Pegram, Macon
There are a host of other options.  You just need some way to make your
resources available via a URL of some type.  The Rules resources could
just as easily be deployed in a web server, FTP or in Guvnor.


-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Blythe,
Marshall
Sent: Tuesday, September 29, 2009 11:53 AM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Push model for rule updates?

> The only wrinkle I see is that you want to store the rulebase in the
> database.  I'm not quite sure how you'd configure the changescanner to
> read from the database.  Is a shared file system not viable?

I suppose could use a shared file system if push came to shove, but
using a database would actually follow the path of least resistance in
my organization- at least from a political standpoint (don't get me
started!).
- This e-mail and any
attachments may contain CONFIDENTIAL information, including PROTECTED
HEALTH INFORMATION. If you are not the intended recipient, any use or
disclosure of this information is STRICTLY PROHIBITED; you are requested
to delete this e-mail and any attachments, notify the sender
immediately, and notify the LabCorp Privacy Officer at
privacyoffi...@labcorp.com or call (877) 23-HIPAA.


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

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information or otherwise protected by law.  Any unauthorized review, 
use, disclosure or distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by reply e-mail and destroy all copies of 
the original message.



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


Re: [rules-users] Push model for rule updates?

2009-09-29 Thread Pegram, Macon
It's actually not terribly difficult to pull off.  The key things you'll
want to do are:

-  Initialize and start the ResourceChangeNotifierService.

-  Initialize but DO NOT start the ResourceChangeScanner
service.

-  Determine how you're going to trigger your rescan.

-  When your API (or listener, or whatever) receives the message
to update the knowledgebase, call resourceChangeScanner.scan()

 

The only wrinkle I see is that you want to store the rulebase in the
database.  I'm not quite sure how you'd configure the changescanner to
read from the database.  Is a shared file system not viable?

 

 

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Blythe,
Marshall
Sent: Tuesday, September 29, 2009 11:21 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Push model for rule updates?

 

Has anyone successfully implemented a push model for updating rules in a
Drools 5.0 application? Here's what I'd like to do:

 

1.   Rules will be authored out-of-process, and serialized
KnowledgePackages will be stored in a database.

2.   When the client application starts up (i.e. a regular
servlet-based app) it will fetch the KnowledgePackages from the database
and use them to configure a singleton KnowledgeBase instance.

3.   A special UI in the client application will allow authorized
users to upload new KnowledgePackages. When new packages are uploaded
they are first persisted in the database and then used to update the
KnowledgeBase at runtime. All subsequent calls to fireAllRules() should
use the rules in the new package.

 

If anyone has done something like this before then I'd appreciate some
advice on how to manage updates to the KnowledgeBase at runtime.

- This e-mail and any
attachments may contain CONFIDENTIAL information, including PROTECTED
HEALTH INFORMATION. If you are not the intended recipient, any use or
disclosure of this information is STRICTLY PROHIBITED; you are requested
to delete this e-mail and any attachments, notify the sender
immediately, and notify the LabCorp Privacy Officer at
privacyoffi...@labcorp.com or call (877) 23-HIPAA.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] persistent java objects in working memory

2009-09-24 Thread Pegram, Macon
Chris,

I believe in one of your earlier emails you said that there were several 
MyDataObject instances in working memory.  (I seem to recall you saying there 
were 3).  

When you do an "update" (or a retract, or insert) you're notifying Drools that 
the state of it's working memory has changed.  At that time, the RuleBase is 
rescanned and the Agenda for rule firing is reset.  During this rulebase scan, 
rules are Pattern matched to data in working memory.  

So let's say you have 2 MyDataObjects:
Obj1.testDataField = 10
Obj2.testDataField = 25

If both are in working memory, both meet the criteria for "Identify My Object" 
so it will fire twice.  

Assuming nothing changed on Obj1 during the update that would modify the value 
above 20, it would cause rule 2 "Identify Problem" to fire.

However, and this may be where your problem is, I notice that you have 
"lock-on-active" set for both Rule 1 and Rule 2.  Looking at the Drools docs we 
see the following statement regarding "lock-on-active":


   Whenever a ruleflow-group becomes active or an agenda-group receives the 
focus, 
   any rule within that group that has lock-on-active set to true will not 
be activated 
   any more; irrespective of the origin of the update, the activation of a 
matching rule 
   is discarded. This is a stronger version of no-loop, because the change 
could now be 
   caused not only by the rule itself. It's ideal for calculation rules 
where you have 
   a number of rules that modify a fact and you don't want any rule 
re-matching and 
   firing again. Only when the ruleflow-group is no longer active or the 
agenda-group 
   loses the focus those rules with lock-on-active set to true become 
eligible again for 
   their activations to be placed onto the agenda.

So I believe because "lock-on-active" is "true" the second rule will not fire 
as a result of an "Update".  It would have to already be true at the point when 
you call "fireAllRules()" for it to actually run.


-Original Message-
From: rules-users-boun...@lists.jboss.org on behalf of Chris Richmond
Sent: Wed 9/23/2009 5:33 PM
To: 'Rules Users List'
Subject: Re: [rules-users] persistent java objects in working memory
 
Yes..I have these rules and the problem was I wasn't including the  $c:
cycle in the second rule ( I bolded it).  

 

So any rule I write subsequently has to have that $c : cycle()  check in
order to fire now? Not just the first rule which identifies all in memory
objects and calls update on them?  That seems counterintuitive..it seems
like if I simply call update() on each object in the first rule, that the
second should fire withought checking the Cycle object as well.

 

Chris

 

rule "Identify  MyObject"

   lock-on-active

when

   $mo : MyDataObject();

   $c : Cycle();

then

   System.err.println("MYDATAOBJECT in system: " + $mo.getID() + " | " +
$mo.getTestFieldData();

   update($sb);

end

 

rule "Identify Problem"

   lock-on-active

when

   $mo : MyDataObject($td:testFieldData < 20);

   $c : Cycle();

then

   System.err.println("OUT OF SPEC MYDATAOBJECT: " + $mo.getID() + " | " +
$mo.getTestFieldData() + " | " + $td);

 

end

 

  _  

From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: Wednesday, September 23, 2009 11:01 AM
To: Rules Users List
Subject: Re: [rules-users] persistent java objects in working memory

 

Did you inform the engine that testFieldData had changed?  You need to
either call update(MyDataObject) from the action of a rule, or if you're
outside the engine, update() or asyncUpdate() on the session.  Otherwise, as
far as the engine is concerned, the value hasn't changed.

 

  _  

From: Chris Richmond 
To: Rules Users List 
Sent: Wednesday, September 23, 2009 3:35:46 PM
Subject: Re: [rules-users] persistent java objects in working memory

Now I am really confused, when I try to set some condition on the
MyDataObject itself like this

 

rule "Identify Java Objects"

   lock-on-active

when

   $mo : MyDataObject($mf:testFieldData < 20);

   $c : Cycle();

then

   System.err.println("MYOBJECT in system: " + $mo.getID() + " | " +
$mo.getTestFieldData());

end 

 

 

Then this still fires every single time, even when testFieldData is over
20..

 

-Chris

 

 

 

  _  

From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: Wednesday, September 23, 2009 10:02 AM
To: Rules Users List
Subject: Re: [rules-users] persistent java objects in working memory

 

You've answered your own question. :)  The rule you've given will only fire
when the object is asserted or modified. (And you have to inform the engine
of the modification.)  You have to inform the engine that the object has
been modified every cycle. (And if you want the engine to fire that rule
even if the object has not been modified, you can still inform the engine.
All that

Re: [rules-users] Support on Weblogic?

2009-09-23 Thread Pegram, Macon
I'm not able to give specifics other than to say that it's a very thin
java layer J2EE based Web Service fronting rules processing which
retrieves most of its data during the course of rule processing from an
O/R modeling framework.

 

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mel Odeus
Sent: Wednesday, September 23, 2009 4:23 PM
To: Rules Users List
Subject: Re: [rules-users] Support on Weblogic?

 

May i ask what kind of application you use drools for?

2009/9/23 Pegram, Macon 

I am using the Community edition. Between the documentation at JBoss,
and this mailing list, I've been able to work through any issues I've
encountered.

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mel Odeus
Sent: Wednesday, September 23, 2009 4:12 PM
To: Rules Users List
Subject: Re: [rules-users] Support on Weblogic?

 

Do you use the community "drools" edition or the enterprise "RedHat"
edition? How do you get support in case a problem happens in production?



 

On Wed, Sep 23, 2009 at 3:52 PM, Pegram, Macon 
wrote:

The short answer is "YES".  I have had success running both Guvnor and a
Drools application on Weblogic.

Guvnor took a little configuration, but it will run on Weblogic.  As for
straight Drools... It's just an API, so there's nothing special about it
that should present a problem for any type of container.  It's perfectly
useful in an application deployed in your container of choice, from the
commandline, or from a unit test.



-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of MelOdeus
Sent: Wednesday, September 23, 2009 3:17 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Support on Weblogic?


Hi,

I'd like to know if it is indeed possible to run drools on a platform
other
than JBoss, especially Weblogic.
I read the JBoss BRMS FAQ http://www.jboss.com/pdf/brms-faq.pdf and it
gave
me doubt regarding the support of Drools outside of the JBoss App
Server.

Is anyone running Drools on Weblogic?
--
View this message in context:
http://www.nabble.com/Support-on-Weblogic--tp25531262p25531262.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

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information or otherwise protected by law.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply e-mail and destroy all copies of the original message.




___
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] Support on Weblogic?

2009-09-23 Thread Pegram, Macon
I am using the Community edition. Between the documentation at JBoss,
and this mailing list, I've been able to work through any issues I've
encountered.

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mel Odeus
Sent: Wednesday, September 23, 2009 4:12 PM
To: Rules Users List
Subject: Re: [rules-users] Support on Weblogic?

 

Do you use the community "drools" edition or the enterprise "RedHat"
edition? How do you get support in case a problem happens in production?



 

On Wed, Sep 23, 2009 at 3:52 PM, Pegram, Macon 
wrote:

The short answer is "YES".  I have had success running both Guvnor and a
Drools application on Weblogic.

Guvnor took a little configuration, but it will run on Weblogic.  As for
straight Drools... It's just an API, so there's nothing special about it
that should present a problem for any type of container.  It's perfectly
useful in an application deployed in your container of choice, from the
commandline, or from a unit test.



-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of MelOdeus
Sent: Wednesday, September 23, 2009 3:17 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Support on Weblogic?


Hi,

I'd like to know if it is indeed possible to run drools on a platform
other
than JBoss, especially Weblogic.
I read the JBoss BRMS FAQ http://www.jboss.com/pdf/brms-faq.pdf and it
gave
me doubt regarding the support of Drools outside of the JBoss App
Server.

Is anyone running Drools on Weblogic?
--
View this message in context:
http://www.nabble.com/Support-on-Weblogic--tp25531262p25531262.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

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential and privileged information or otherwise protected by law.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply e-mail and destroy all copies of the original message.




___
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] Support on Weblogic?

2009-09-23 Thread Pegram, Macon
The short answer is "YES".  I have had success running both Guvnor and a
Drools application on Weblogic.  

Guvnor took a little configuration, but it will run on Weblogic.  As for
straight Drools... It's just an API, so there's nothing special about it
that should present a problem for any type of container.  It's perfectly
useful in an application deployed in your container of choice, from the
commandline, or from a unit test.


-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of MelOdeus
Sent: Wednesday, September 23, 2009 3:17 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Support on Weblogic?


Hi,

I'd like to know if it is indeed possible to run drools on a platform
other
than JBoss, especially Weblogic. 
I read the JBoss BRMS FAQ http://www.jboss.com/pdf/brms-faq.pdf and it
gave
me doubt regarding the support of Drools outside of the JBoss App
Server.

Is anyone running Drools on Weblogic?
-- 
View this message in context:
http://www.nabble.com/Support-on-Weblogic--tp25531262p25531262.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

CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information or otherwise protected by law.  Any unauthorized review, 
use, disclosure or distribution is prohibited.  If you are not the intended 
recipient, please contact the sender by reply e-mail and destroy all copies of 
the original message.



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


Re: [rules-users] KnowledgeAgent Log Level

2009-09-11 Thread Pegram, Macon
I had been wondering the same thing, so I finally decided to take a look @ the 
Drools source. 

 

These log message are provided by the SystemEventListener interface.  There's 
no direct way (that I can see) in the code to set and enforce an actual "log 
level" (Someone please tell me I'm wrong here.. I'd love to do this 
differently!)

 

What you need to do is implement your own SystemEventListener implementation to 
override the default one.  Before you do anything meaningful with Drools, 
you'll want to override the default by calling:

   SystemEventListenerFactory.setSystemEventListener();

 

Here's a basic no-op listener:

new SystemEventListener () {

 

  public void debug(String arg0) { }

  public void debug(String arg0, Object arg1) {}

  public void exception(Throwable arg0) {}

  public void exception(String arg0, Throwable arg1) {}

  public void info(String arg0) {}

  public void info(String arg0, Object arg1) {}

  public void warning(String arg0) {}

  public void warning(String arg0, Object arg1) {}

  

};

 

In reality what you probably want to do is hook in your application's logger 
here so it will respect the same log levels the rest of your application runs 
under.

 

Macon

 



From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Andrew Waterman
Sent: Thursday, September 10, 2009 6:30 PM
To: Rules Users List
Subject: [rules-users] KnowledgeAgent Log Level

 

Hi,

 

I'm wondering if there is a way to manipulate the log level for the 
KnowledgeAgent.  Currently, I'm getting dumps to the console that I'd like to 
control:

 

[2009:09:253 17:09:371:info] KnowledgAgent applying ChangeSet

[2009:09:253 17:09:371:debug] KnowledgeAgent subscribing to 
resource=[ClassPathResource path='mx/ecosur/multigame/impl/manantiales.drl']

[2009:09:253 17:09:371:debug] ResourceChangeNotification subscribing 
listener=org.drools.agent.impl.knowledgeagenti...@3ebfd8 to 
resource=[ClassPathResource path='mx/ecosur/multigame/impl/manantiales.drl']

[2009:09:253 17:09:372:debug] KnowledgeAgent ChangeSet requires 
KnowledgeBuilder

[2009:09:253 17:09:372:debug] KnowledgeAgent rebuilding KnowledgeBase 
using ChangeSet

[2009:09:253 17:09:373:debug] KnowledgeAgent building 
resource=[ClassPathResource path='mx/ecosur/multigame/impl/manantiales.drl']

[2009:09:253 17:09:420:info] KnowledgeAgent new KnowledgeBase now built 
and in use

 

Thanks!

 

best wishes,

 

Andrew

-

Andrew Waterman

San Cristóbal de las Casas, Chiapas, Mexico

 

 

 

 

 

 

 

 

 

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


Re: [rules-users] Looking for attributes on an element obtainedfroma Map

2009-08-21 Thread Pegram, Macon
Ok.. Think I've answered my own question.. (Just looking for confirmation at 
this point).  

Looks like it's:
rule "deal finder"
when
SearchItem($upc : upc != null)  // see if a UPC was provided
StockRoom($stock : stock)   // get a handle to the stock
HashMap ($item : this[$upc] != null) from $stock   
Item (onSale == true) from $item
then
// Buy stuff
End

 


-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Pegram, Macon
Sent: Friday, August 21, 2009 2:15 PM
To: Rules Users List
Subject: Re: [rules-users] Looking for attributes on an element obtainedfroma 
Map

The example below was a contrived one for the purposes of asking the question.  
What you've proposed is definitely the "right" way to do things.  

I realize accessing items from a map in the manner I'm inquiring about is a 
little contrary to "best practices" with Drools.  However, I would like to 
understand the syntax for doing what I inquired about for those edge cases 
where it is needed.

Thanks!

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: Friday, August 21, 2009 2:10 PM
To: Rules Users List
Subject: Re: [rules-users] Looking for attributes on an element obtainedfrom a 
Map

Do Items have a UPC?  Any reason why you can't insert the Items directly into 
working memory?  Then you could do this:

rule "deal finder" 
when
  SearchItem($upc : upc != null) 
  Item(onSale == true, upc == $upc) 
then
 Buy stuff 
end

--- On Fri, 8/21/09, Pegram, Macon  wrote:

> From: Pegram, Macon 
> Subject: [rules-users] Looking for attributes on an element obtained from a 
> Map
> To: "Rules Users List" 
> Date: Friday, August 21, 2009, 11:47 AM
> 
> 
> 
>  
>  
> 
>  
> 
>  
> 
> 
> 
> 
> 
> 
> 
>  
> 
> 
> 
> I was
> hoping the recent conversation
> regarding maps this would come up, but so far it
> hasn't. 
> 
> 
>   
> 
> How do I
> check for conditions on the
> element referenced in the map?   
> 
> 
>   
> 
> So given
> the following scenario:  
> 
> 
>   
> 
> SearchItem
> is the item being searched for
> by the user    
> 
> Item has
> the attributes:  UPC (String) and
> OnSale (Boolean) 
> 
> StockRoom
> has an attribute of stock which
> is  Stock = HashMap    (key value
> is UPC) 
> 
> 
>   
> 
> Now
> let's say I want to write a rule
> that says, "If the provided Item is in Stock, and on
>  Sale .. purchase it" 
> 
> 
>   
> 
> rule
> "deal finder" 
> 
> when
> 
> 
>    
> SearchItem($upc : upc != null)  // see
> if a UPC was provided 
> 
>    
> StockRoom($stock : stock)   // get a
> handle to the stock 
> 
>    
> HashMap (this[$upc] != null)   from
> $stock   // look for the UPC in stock 
> 
>     Item
> (onSale == true) from $item    //
> Where do I obtain the reference handle that is
> $item? 
> 
> then
> 
> 
>     //
> Buy stuff 
> 
> End
> 
> 
> 
>   
> 
> What
> I'm trying to understand syntactically
> is how do I obtain a reference handle to the
> "Item" found in the
> HashMap reference (IE: $item)  so that I can check
> additional attributes on
> that Item. 
> 
> 
>   
> 
> I
> haven't found any good examples of
> how to do this yet. 
> 
> 
>   
> 
> 
> 
> 
> 
> 
> 
> 
> 
> From:
> rules-users-boun...@lists.jboss.org
> [mailto:rules-users-boun...@lists.jboss.org] On
> Behalf Of Edson Tirelli
> 
> Sent: Friday,
> August 21, 2009 9:16
> AM
> 
> To: Rules
> Users List
> 
> Subject: Re:
> [rules-users] Maps in
> Drools 
> 
> 
> 
>    
> 
> 
>   
> 
> 
> 
> 2009/8/20 André Thieme 
> 
> 
> Would there not be an addition to the
> syntax needed, for the default
> 
> rule language? For mvel it would not require a change I
> guess. 
> 
> 
> 
> 
> 
> No, as I mentioned to you, the idea is for the DRL to
> remain the same, so that
> the rules author does not have to worry about what the IT
> guys are doing with
> the domain model. So, the rules author would write:
> 
> 
> 
> Customer( name == "bob" )
> 
> 
> 
> The IT guy would simply use a configuration to tell the
> engine: this object
> type uses a map format, that one is a POJO, that other is
> an XML entity, etc. 
> 
> For instance, if he wants to do that in DRL (he could also
> use API, or conf
> fi

Re: [rules-users] Looking for attributes on an element obtainedfrom a Map

2009-08-21 Thread Pegram, Macon
The example below was a contrived one for the purposes of asking the question.  
What you've proposed is definitely the "right" way to do things.  

I realize accessing items from a map in the manner I'm inquiring about is a 
little contrary to "best practices" with Drools.  However, I would like to 
understand the syntax for doing what I inquired about for those edge cases 
where it is needed.

Thanks!

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: Friday, August 21, 2009 2:10 PM
To: Rules Users List
Subject: Re: [rules-users] Looking for attributes on an element obtainedfrom a 
Map

Do Items have a UPC?  Any reason why you can't insert the Items directly into 
working memory?  Then you could do this:

rule "deal finder" 
when
  SearchItem($upc : upc != null) 
  Item(onSale == true, upc == $upc) 
then
 Buy stuff 
end

--- On Fri, 8/21/09, Pegram, Macon  wrote:

> From: Pegram, Macon 
> Subject: [rules-users] Looking for attributes on an element obtained from a 
> Map
> To: "Rules Users List" 
> Date: Friday, August 21, 2009, 11:47 AM
> 
> 
> 
>  
>  
> 
>  
> 
>  
> 
> 
> 
> 
> 
> 
> 
>  
> 
> 
> 
> I was
> hoping the recent conversation
> regarding maps this would come up, but so far it
> hasn't. 
> 
> 
>   
> 
> How do I
> check for conditions on the
> element referenced in the map?   
> 
> 
>   
> 
> So given
> the following scenario:  
> 
> 
>   
> 
> SearchItem
> is the item being searched for
> by the user    
> 
> Item has
> the attributes:  UPC (String) and
> OnSale (Boolean) 
> 
> StockRoom
> has an attribute of stock which
> is  Stock = HashMap    (key value
> is UPC) 
> 
> 
>   
> 
> Now
> let's say I want to write a rule
> that says, "If the provided Item is in Stock, and on
>  Sale .. purchase it" 
> 
> 
>   
> 
> rule
> "deal finder" 
> 
> when
> 
> 
>    
> SearchItem($upc : upc != null)  // see
> if a UPC was provided 
> 
>    
> StockRoom($stock : stock)   // get a
> handle to the stock 
> 
>    
> HashMap (this[$upc] != null)   from
> $stock   // look for the UPC in stock 
> 
>     Item
> (onSale == true) from $item    //
> Where do I obtain the reference handle that is
> $item? 
> 
> then
> 
> 
>     //
> Buy stuff 
> 
> End
> 
> 
> 
>   
> 
> What
> I'm trying to understand syntactically
> is how do I obtain a reference handle to the
> "Item" found in the
> HashMap reference (IE: $item)  so that I can check
> additional attributes on
> that Item. 
> 
> 
>   
> 
> I
> haven't found any good examples of
> how to do this yet. 
> 
> 
>   
> 
> 
> 
> 
> 
> 
> 
> 
> 
> From:
> rules-users-boun...@lists.jboss.org
> [mailto:rules-users-boun...@lists.jboss.org] On
> Behalf Of Edson Tirelli
> 
> Sent: Friday,
> August 21, 2009 9:16
> AM
> 
> To: Rules
> Users List
> 
> Subject: Re:
> [rules-users] Maps in
> Drools 
> 
> 
> 
>    
> 
> 
>   
> 
> 
> 
> 2009/8/20 André Thieme 
> 
> 
> Would there not be an addition to the
> syntax needed, for the default
> 
> rule language? For mvel it would not require a change I
> guess. 
> 
> 
> 
> 
> 
> No, as I mentioned to you, the idea is for the DRL to
> remain the same, so that
> the rules author does not have to worry about what the IT
> guys are doing with
> the domain model. So, the rules author would write:
> 
> 
> 
> Customer( name == "bob" )
> 
> 
> 
> The IT guy would simply use a configuration to tell the
> engine: this object
> type uses a map format, that one is a POJO, that other is
> an XML entity, etc. 
> 
> For instance, if he wants to do that in DRL (he could also
> use API, or conf
> files), he could do:
> 
> 
> 
> declare Customer
> 
>     @format( map )
> 
> end
> 
> 
> 
> declare Order
> 
>     @format( pojo )
> 
> end
> 
> 
> 
> So, we have a clear distinction between the technical
> aspects and the business
> aspects of the application.
> 
> 
> 
> Your clojure macro would generate always the same DRL code
> "Customer( name
> == "bob" )", but you said yourself that
> clojure is 100% java
> compatible, so imagine the enterprise had a domain model
> implemented as pojos
> already and as part of the new application some new
> entities are modeled in

[rules-users] Looking for attributes on an element obtained from a Map

2009-08-21 Thread Pegram, Macon
I was hoping the recent conversation regarding maps this would come up, but so 
far it hasn't.

 

How do I check for conditions on the element referenced in the map?  

 

So given the following scenario: 

 

SearchItem is the item being searched for by the user   

Item has the attributes:  UPC (String) and OnSale (Boolean)

StockRoom has an attribute of stock which is  Stock = HashMap
(key value is UPC)

 

Now let's say I want to write a rule that says, "If the provided Item is in 
Stock, and on Sale.. purchase it"

 

rule "deal finder"

when

SearchItem($upc : upc != null)  // see if a UPC was provided

StockRoom($stock : stock)   // get a handle to the stock

HashMap (this[$upc] != null)   from $stock   // look for the UPC in stock

Item (onSale == true) from $item// Where do I obtain the reference 
handle that is $item?

then

// Buy stuff

End

 

What I'm trying to understand syntactically is how do I obtain a reference 
handle to the "Item" found in the HashMap reference (IE: $item)  so that I can 
check additional attributes on that Item.

 

I haven't found any good examples of how to do this yet.

 



From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Friday, August 21, 2009 9:16 AM
To: Rules Users List
Subject: Re: [rules-users] Maps in Drools

 

 

2009/8/20 André Thieme 

Would there not be an addition to the syntax needed, for the default
rule language? For mvel it would not require a change I guess.


No, as I mentioned to you, the idea is for the DRL to remain the same, so that 
the rules author does not have to worry about what the IT guys are doing with 
the domain model. So, the rules author would write:

Customer( name == "bob" )

The IT guy would simply use a configuration to tell the engine: this object 
type uses a map format, that one is a POJO, that other is an XML entity, etc. 
For instance, if he wants to do that in DRL (he could also use API, or conf 
files), he could do:

declare Customer
@format( map )
end

declare Order
@format( pojo )
end

So, we have a clear distinction between the technical aspects and the business 
aspects of the application.

Your clojure macro would generate always the same DRL code "Customer( name == 
"bob" )", but you said yourself that clojure is 100% java compatible, so 
imagine the enterprise had a domain model implemented as pojos already and as 
part of the new application some new entities are modeled in clojure. The macro 
would generate always the same code, but you would configure some entities in 
the domain as POJOs and other entities as Maps.



Hmm, but the MVEL syntax can not magically eliminate the eval. Under the
hood the map accesses will still be inside an eval. Marc confirmed that
a few days ago.
MVEL only hides this from the user. This is what I will also do.
But under the hood it will become

  $a:Map()
  $b:Map()
  eval( $a.get("type") == "Customer" )
  eval( $b.get("type") == "DailyOrders" )


Here I think we have other misunderstanding. I will try to explain, but ideally 
you need to learn a bit about the Rete algorithm to see the whole picture. 
There are 2 types of eval(). Inline eval() and top level eval(). What you wrote 
above is a top level eval, meaning it will become a node in the rete network. 
So your example above generates an "execution plan" (making an analogy with 
SQL) that will get all Maps in the working memory, join them in tuples size 2, 
and then test each tuple for the 2 evals. So, you see why this will generate 
C(n,2) partial matches, while C(n,2) as we know is n!/(n-2)!, what is really 
bad for growing "n".

Now, the same thing could be written using inline evals as:

$a:Map( eval( $a.get("type") == "Customer" ) )
$b:Map( eval( $b.get("type") == "DailyOrders" ) )

  In this case, the inline eval() will generate an alpha constraint in the 
network, i.e., it will be applied BEFORE the joins. So, instead of doing all 
combinaions possible between all maps as above, it will first find all Customer 
maps and all DailyOrders maps and only after that will make a join between 
them. So you get Customers * DailyOrders partial matches. The above evals are 
semantically equivalent as:

$a:Map( this[ "type" ] == "Customer" ) 
$b:Map( this[ "type" ] == "DailyOrders" )

   
> But currently I am forced to produce this cross product, as there is no 
> direct support for Maps yet.

I hope that by the above you see that the problem of the cross products is not 
a problem with Maps support, but rather a question of how to write better 
rules. The same way you can write 2 completely different SQL queries that 
return the same result but one is fast and the other is completely heavy and 
slow, you can also write good rules and really bad rules.

   []s
   Edson

 

___

Re: [rules-users] Hooray! Re: Drools library - updating Drools jar

2009-08-20 Thread Pegram, Macon
I'm glad you found a solution that works for you.

Yes.. The Eclipse Editor gets unhappy when you do the switch.  You need
to use the Preferences menu to indicate that you've made a change to the
Drools Runtime, and as I suggested you will likely need to stop/restart
Eclipse.

I was able to follow the procedure I suggested earlier today and saw the
new MVEL in the Drools Library list.

Macon


-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of KDR
Sent: Thursday, August 20, 2009 1:16 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Hooray! Re: Drools library - updating Drools jar


Thanks Macon and Edson. Macon I did try the swapping out in the Drools
runtime folder (i.e. removing the 2.0.10 jars and adding in the
2.0.14_snapshot), but then Eclipse completely died (errors even with the
existing rules, because they no longer were able to resolve types). I
figure
that was because the plugin was still looking for 2.0.10 and wasn't
happy
that only 2.0.14_snapshot was on offer.

This is what I did before trying a new runtime folder:
- Downloaded 2.0.14_snapshot and saved it into my current Drools runtime
folder (both top level and lib for luck)
- Added 2.0.14_snapshot as an external JAR to my project's Java build
path
in Eclipse - it was at the top (as in the pic in one of my previous
posts).
- Didn't work (even on restarting Eclipse) so I guess it didn't use
2.0.14_snapshot even tho' it was at the top of the build path list.
Again,
because I think the plugin was looking for 2.0.10.

Then I did this, which worked! - I know it was probably a bit naughty of
me
because I really ought to be editing the POM and rebuilding it all as
Edson
suggested, but a workaround is a workaround...
- Closed Eclipse.
- Renamed the 2.0.10 to something else in top level and lib subfolders
of
the Drools Runtime folder
- Renamed 2.0.14_snapshot to the 2.0.10 name in both folders
- Restarted Eclipse
- It works! To be precise, because the bug I was trying to get the fix
for
was described in another thread, it is now accepts -
m: Map( this[$str] == 1 ) 
without any "org.drools.RuntimeDroolsException: Exception executing
predicate this[$str] == 1" - and the rule even runs as expected.

I'm waiting till tomorrow before really celebrating, just in case, but I
think that did it. If it reverts back to the old problem, I will try
your
brand new runtime folder suggestion then, Macon.

Thanks again for everyone's help.



Edson Tirelli-3 wrote:
> 
>Cool, living and learning! Thanks,
> 
>Edson
> 
> 2009/8/20 Pegram, Macon 
> 
>>  There's another way.
>>
>>
>>
>> In the Eclipse Plugin Preferences (Eclipse -> Preferences -> Drools
->
>> Installed Drools Runtime) you point to the location of the Drools
runtime
>> you want to use.  If you swap out the MVEL file at the location of
your
>> Drools Runtime it should pick up the right version of the MVEL.
>>
>>
>>
>> You could also duplicate the jar files in that folder into a "Patch"
>> folder, replace the MVEL jar in the PATCH copy, and setup a "Patch
Drools
>> Runtime" if you want to keep your original installation pristine.
>>
>>
>>
>> You will likely need/want to bounce Eclipse for this to take effect.
>>
> 

-- 
View this message in context:
http://www.nabble.com/Drools-library---updating-Drools-jar-tp25057905p25
066246.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] Drools library - updating Drools jar

2009-08-20 Thread Pegram, Macon
There's another way.

 

In the Eclipse Plugin Preferences (Eclipse -> Preferences -> Drools ->
Installed Drools Runtime) you point to the location of the Drools
runtime you want to use.  If you swap out the MVEL file at the location
of your Drools Runtime it should pick up the right version of the MVEL. 

 

You could also duplicate the jar files in that folder into a "Patch"
folder, replace the MVEL jar in the PATCH copy, and setup a "Patch
Drools Runtime" if you want to keep your original installation pristine.

 

You will likely need/want to bounce Eclipse for this to take effect.

 

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Thursday, August 20, 2009 12:12 PM
To: Rules Users List
Subject: Re: [rules-users] Drools library - updating Drools jar

 


   Does not matter the order in the "libraries" tab. You need to set
them in the "Order and Export" tab.

   []s
   Edson

2009/8/20 KDR 


Edson thank you very much for your suggestions.

I wonder if it didn't work because I used 2.0.13? - I did that because I
couldn't find 2.0.12 on the download page at
http://docs.codehaus.org/display/MVEL/Downloading+MVEL - as you can see
from
the attached pic I did try adding that jar to the project build path,
ahead
of the "standard" Drools library.

I'll download 2.0.14-SNAPSHOT and try it with that. Don't have the
strength
to rebuild etc right now! I'll report back. Thanks again for your help,
much
appreciated. :)

http://www.nabble.com/file/p25063132/drools3.png drools3.png



Edson Tirelli-3 wrote:
>
>I am no Eclipse expert, but:
>
> "The correct way" (TM): checkout the source code, change the pom.xml
to
> use
> the correct MVEL version, rebuild the plugin and re-install. When we
> release
> the next version, just update it.
>
> "The easy way" (TM): add the new mvel jar to your eclipse project
> classpath
> and move it up to be before the drools library in the eclipse project
> classpath order. You will have both in the classpath, but being first
in
> the
> classpath order will make eclipse use it.
>
>You must use 2.0.12 or 2.0.14-SNAPSHOT. When I tested 2.0.13 there
was
> a
> regression, if I remember correctly.
>
>[]s
>Edson
>

--
View this message in context:
http://www.nabble.com/Drools-library---updating-Drools-jar-tp25057905p25
063132.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




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com

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


[rules-users] Is "emptieness" supported in Drools 5 (LHS)

2009-08-18 Thread Pegram, Macon
According to MVEL they've added a convenience for checking the
"emptiness" of a value (see: http://mvel.codehaus.org/Value+Tests )

 

In MVEL you'd simply write:  myMap == empty

 

This seemed like a MUCH cleaner way to write some of the LHS of the
rules, so I thought I'd try it out.  

 

Given the following rule:

rule "Check Empties - Original"

when 

$grabBag : MyGrabBag(someMap != null)

eval ($grabBag.getSomeMap().size() == 0)

then

end

 

This could be rewritten:

 

rule "Check Empties - Simple"

when 

MyGrabBag(someMap == empty)

then

end

 

The IDE (Eclipse 3.4.2 w/ Drools plugin) seems to recognize "empty"  is
a keyword (it makes it bold), but the drools compiler in the IDE
reports:
BuildError: Unable to create restriction '[VariableRestriction: == empty
]' for field 'someMap' in the rule 'Check Empties - Simple'

BuildError: Unable to return Declaration for identifier 'empty'

 

Am I assuming incorrectly that the LHS is fully MVEL compliant?

 

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