Re: [rules-users] Smooks and Drools Pipeline

2009-03-02 Thread Mark Proctor

checkout the unit test test, hopefully that should help:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-pipeline/drools-transformer-smooks/src/test/java/org/drools/runtime/pipeline/impl/SmookStatefulSessionTest.java

Mark
Dave Macpherson wrote:


Hey guys (Drools newbie here)

I'm *attempting* to use the Drools/Smooks pipeline functionality to 
insert facts into my knowledgebase and I'm having a little trouble 
figuring out exactly how to do this. I've read the API docs for the 
5.0.0.M5 and looked at the test cases but I guess I'm still not quite 
getting it, so I'm hoping someone here can point me in the right 
direction.


I've got an XML file defined basically like this:


   
  xxx
   
   
  
  999
   
   
  
  999
   


Within the XML file, there is 1 and only 1 "facility" node and 
multiple "lineitem" nodes. I'd like to use the DroolsSmooks pipleline 
functionality to use Smooks to insert 1 "facility" fact and multiple 
"lineitem" facts into my knowledgbase.


The code I've written to do this is similar to the following (taken 
from sample test code I've seen in the Drools source):


StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
Action executeResultHandler = PipelineFactory.newExecuteResultHandler();
KnowledgeRuntimeCommand insertStage = 
PipelineFactory.newStatefulKnowledgeSessionInsert();

insertStage.setReceiver(executeResultHandler);
Smooks smooks = new Smooks("smooks-config.xml");
Transformer transformer = 
PipelineFactory.newSmooksFromSourceTransformer(smooks, "root");

transformer.setReceiver(insertStage);
Pipeline pipeline = 
PipelineFactory.newStatefulKnowledgeSessionPipeline(ksession);

pipeline.setReceiver(transformer);
ResultHandlerImpl resultHandler = new ResultHandlerImpl();
pipeline.insert(ResourceFactory.newClassPathResource("submission.xml"), 
resultHandler );


While stepping through the above code, the last line returns an NPE. 
I've tried playing with the "Transformer transformer - 
PipeLineFactory..." line, substituting "root" for something else and 
it goes into an infinite loop. What is the purpose of the "root" value 
being set in this line?


Can anyone tell me if I'm even on the right track here, or am I 
misunderstanding what the Smooks data loader can do for me?


Regards,

Dave



___
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] java.lang.NoClassDefFoundError: org/drools/spi/Consequence

2009-03-02 Thread Ojwang Wilson O

All,

I am getting the error below while passing DroolsAnt build pkg as a 
property to RuleAgent. I am using Java 6 update 12.


===
2009-03-02 16:48:59,363 Stdout ERROR callout.err  - RuleAgent(default) 
INFO (Mon Mar 02 16:48:59 CST 2009): Configuring package provider : 
FileScanner scanning: /home/nxuser/proxy/resource/iaoc/rules/Rules.pkg


java.lang.NoClassDefFoundError: org/drools/spi/Consequence
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
   at 
org.drools.rule.PackageCompilationData$PackageClassLoader.fastFindClass(PackageCompilationData.java:333)
   at 
org.drools.rule.PackageCompilationData$PackageClassLoader.loadClass(PackageCompilationData.java:353)

   at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
   at 
org.drools.common.DroolsObjectInputStream.resolveClass(DroolsObjectInputStream.java:79)
   at 
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
   at 
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)


==

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


[rules-users] query support in Drools 5

2009-03-02 Thread Michal Bali
Hi,

Is there a way to get the QueryResults from a StatefulKnowledgeSession in
Drools 5.0 ?

The old API has a getQueryResults method but I can't find it in the new API.

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


[rules-users] Smooks and Drools Pipeline

2009-03-02 Thread Dave Macpherson
Hey guys (Drools newbie here) 

I'm *attempting* to use the Drools/Smooks pipeline functionality to insert
facts into my knowledgebase and I'm having a little trouble figuring out
exactly how to do this. I've read the API docs for the 5.0.0.M5 and looked
at the test cases but I guess I'm still not quite getting it, so I'm hoping
someone here can point me in the right direction.

I've got an XML file defined basically like this: 

 

  xxx 


   
  999 


   
  999 

 

Within the XML file, there is 1 and only 1 "facility" node and multiple
"lineitem" nodes. I'd like to use the DroolsSmooks pipleline functionality
to use Smooks to insert 1 "facility" fact and multiple "lineitem" facts into
my knowledgbase.

The code I've written to do this is similar to the following (taken from
sample test code I've seen in the Drools source):

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); 
Action executeResultHandler = PipelineFactory.newExecuteResultHandler(); 
KnowledgeRuntimeCommand insertStage =
PipelineFactory.newStatefulKnowledgeSessionInsert(); 
insertStage.setReceiver(executeResultHandler); 
Smooks smooks = new Smooks("smooks-config.xml"); 
Transformer transformer =
PipelineFactory.newSmooksFromSourceTransformer(smooks, "root"); 
transformer.setReceiver(insertStage); 
Pipeline pipeline =
PipelineFactory.newStatefulKnowledgeSessionPipeline(ksession); 
pipeline.setReceiver(transformer); 
ResultHandlerImpl resultHandler = new ResultHandlerImpl(); 
pipeline.insert(ResourceFactory.newClassPathResource("submission.xml"),
resultHandler ); 

While stepping through the above code, the last line returns an NPE. I've
tried playing with the "Transformer transformer - PipeLineFactory." line,
substituting "root" for something else and it goes into an infinite loop.
What is the purpose of the "root" value being set in this line?

Can anyone tell me if I'm even on the right track here, or am I
misunderstanding what the Smooks data loader can do for me?

Regards, 

Dave

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


Re: [rules-users] Ksession inside a executeWorkitem() ?

2009-03-02 Thread Cristiano Gavião

Hi Kris,

Hummm... Its true, after all Workitem stills been a java class with  
gets and sets... ;-)


Thanks

Cristiano

On 02/03/2009, at 10:38, Kris Verlaenen wrote:


Cristiano,

If the working memory is always different per work item, you could  
use a global and pass it as a parameter of the work item.


However, in general it does seem better to set this on the work item  
handler directly at construction time, as a parameter on your work  
item handler. Something like this:


StatefulKnowledgeSession session = ...
MyWorkItemHandler myWorkItemHandler = new MyWorkItemHandler();
session.getWorkItemManager().registerWorkItemHandler("...",  
myWorkItemHandler);

myWorkItemHandler.setSession(session);

If you have more than one possible session, you could inject a  
session locator instead of the session itself to locate the session  
at runtime.


Kris

- Original Message - From: "Cristiano Gavião" >

To: "Rules Users List" 
Sent: Monday, March 02, 2009 2:19 PM
Subject: [rules-users] Ksession inside a executeWorkitem() ?



Hi people,

Im trying to create a workitemhandler for use Drools Pipeline and   
Smooks to import data inside working memory and process it.


I want to share the working memory that was created for the main   
process that is calling the workitem for configure the Drools  
Pipeline  inside it.


What is the best approach to do that, use Globals to pass the  
knowledgesession?


any ideias?

Thanks in advance

_
Cristiano V. Gavião


___
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


_
Cristiano V. Gavião

É difícil acreditar que um homem esteja a dizer a verdade, quando você  
sabe muito bem que mentiria se estivesse no lugar dele. Henry Menken



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


Re: [rules-users] Timer isn't firing

2009-03-02 Thread Cristiano Gavião

It is so strange...

I could run this test with no errors, but I can't get any of my  
process completed if diagram has a timer...


Ok, I'll sent to you my project.

Thanks

On 02/03/2009, at 11:19, Kris Verlaenen wrote:


Cristiano,

There are some examples on processes using timers here:
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessTimerTest.java

If you need help, could you maybe send me the test project you are  
trying to execute, so I can take a look?


Kris

- Original Message -
From: Cristiano Gavião
To: Rules Users List
Sent: Monday, March 02, 2009 2:34 AM
Subject: [rules-users] Timer isn't firing

Hi,

I've created a simple process flow with a start node followed by a  
timer (with delay = 1 and period = 0), an workitem node, and an end  
node.


Its simple but isn't working properly. The problem is that process  
isn't getting out from the timer node. Nothing happens...


Its something more needed to get timer working?


This is the output generated:

BEFORE RULEFLOW STARTED process:ProcessoX[id=ProcessoX]
BEFORE RULEFLOW NODE TRIGGERED node:Start[id=20]  
process:ProcessoX[id=ProcessoX]

null process:ProcessoX[id=ProcessoX]
BEFORE RULEFLOW NODE TRIGGERED node:Timer[id=19]  
process:ProcessoX[id=ProcessoX]
AFTER RULEFLOW NODE TRIGGERED node:Timer[id=19]  
process:ProcessoX[id=ProcessoX]

null process:ProcessoX[id=ProcessoX]
AFTER RULEFLOW NODE TRIGGERED node:Start[id=20]  
process:ProcessoX[id=ProcessoX]

AFTER RULEFLOW STARTED process:ProcessoX[id=ProcessoX]


thanks in advance

_
Cristiano V. Gavião





___
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



Cristiano Gavião

"O único lugar onde o sucesso vem antes do trabalho é no dicionário."  
Albert Einstein


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


Re: [rules-users] "not matches'' not working when string is null

2009-03-02 Thread Edson Tirelli
A null value on the field is supposed to evaluate to true only when
comparing with null. Otherwise, it should always evaluates to false.

[]s
Edson

2009/3/2 techy 

>
> Hello,
> I'm checking for condition ' field not matches ".*ABC.*" ` in my rule.
> when field value is null, rule does not fire. But if field value != null
> and
> != ABC, then rule fires.
> Is this expected output or bug? Please clarify.
>
> Thanks
>
> --
> View this message in context:
> http://www.nabble.com/%22not-matches%27%27-not-working-when-string-is-null-tp22292620p22292620.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, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Creating objects in WHEN clause

2009-03-02 Thread Greg Barton
Well, since the StatelessSession is basically a convenience wrapper around a 
StatefulSession I figure it should be possible.  On StatefulSession, which 
extends WorkingMemory, you just call setFocus() before firing the rules.  I'm 
not sure what the best way to do this with a StatelessSession would be.  I can 
think of some hacks, but would rather not lead you down a garden path. :)  Dev 
d00ds, any comment?

--- On Sun, 3/1/09, David Boaz  wrote:

> From: David Boaz 
> Subject: Re: [rules-users] Creating objects in WHEN clause
> To: rules-users@lists.jboss.org
> Date: Sunday, March 1, 2009, 5:03 AM
> Thanks Greg,
> I tried to apply your solution proposed bellow, but had
> problem setting the
> initial "agenda-group". I'm using Drools
> 5.0.0.M4 version, and working with
> a StatelessSession API.
> Can you please give an example how to set the initial
> "agenda-group" from
> the StatelessSession API?
> 
> BTW, regarding the discussion we had, whether to use FROM
> or WorkingMemory
> objects, is it applicable also when using a stateless
> session?
> 
> Thanks, David
> 
> 
> Greg Barton wrote:
> > 
> > I'd second this idea, and to get around the
> inconcenience of inserting the
> > Quantity objects from the calling application, use a
> rule that fires once
> > on initialization.
> > 
> > rule
> > no-loop true
> > when
> > //No condition
> > then 
> >   insert(new Quantity("m", 2));
> > end
> > 
> > This rule should fire first.  You could also put it in
> it's own
> > agenda-group (call it "initialization" or
> some such) and set focus to that
> > group when starting.
> > 
> > rule
> > agenda-group "initialization"
> > no-loop true
> > when
> > //No condition
> > then 
> >   insert(new Quantity("m", 2));
> >  
> drools.setFocus("whatever_your_next_group_is");
> > end
> > 
> > --- On Wed, 2/25/09, Mauricio Salatino
>  wrote:
> > 
> >> From: Mauricio Salatino 
> >> Subject: Re: [rules-users] Creating objects in
> WHEN clause
> >> To: "Rules Users List"
> 
> >> Date: Wednesday, February 25, 2009, 11:40 AM
> >> How about :
> >>  WHEN
> >> $quantity: Quantity(value == 2, unit ==
> "m")
> >> $Person($height == $quantity:)
> >> then
> >> ...
> >> 
> >> 
> >> 
> >> On Wed, Feb 25, 2009 at 2:27 PM, David Boaz
> >>  wrote:
> >> >
> >> > In my application, we often compare the
> fact's
> >> field values against a known
> >> > object. For example:
> >> > WHEN person(height> new Quantity(2,
> "m"))
> >> // the height is greater than 2
> >> > meters.
> >> > will DROOLS create a "singleton"
> Quantity
> >> object, or will it create one
> >> > object for each fact evaluation?
> >> >
> >> > We consider using anoter approach, using
> GLOBALS.
> >> Then, the Quantity object
> >> > will be created applicatively, and passed by
> the API
> >> to the engine.
> >> > something like:
> >> > GLOBAL Quantity 2meters
> >> > WHEN person(height > 2meters)
> >> > But this approach is combersom, because the
> rule
> >> author has to define part
> >> > of the information in the calling
> application, and
> >> part in the rule.
> >> >
> >> > Do you have a good practice how to handle
> these
> >> situations?
> >> >
> >> > Thanks, David
> >> > --
> >> > View this message in context:
> >>
> http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22207616.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
> >> >
> >> 
> >> 
> >> 
> >> -- 
> >>  - Salatino Mauricio -
> >> ___
> >> 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
> > 
> > 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Creating-objects-in-WHEN-clause-tp22207616p22271386.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] Creating objects in WHEN clause

2009-03-02 Thread Greg Barton
Ah, I thought the LHS was parsed into mvel by default.  OK, my bad.

--- On Sun, 3/1/09, Edson Tirelli  wrote:

> From: Edson Tirelli 
> Subject: Re: [rules-users] Creating objects in WHEN clause
> To: greg_bar...@yahoo.com
> Date: Sunday, March 1, 2009, 6:19 PM
> Hold on. :) We are talking about Drools, not java.
> 
> When you write a pattern:
> 
> SomeClass( foo < $otherFoo )
> 
>Drools will use its own implementation of
> "<" to make the comparison. It
> does not delegate that to java and so it must work. If does
> not work, it may
> be a bug, but our tests work for that:
> 
> http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-core/src/test/java/org/drools/base/EvaluatorFactoryTest.java
> 
>Take a look at testObject().
> 
>[]s
>Edson
> 
> 2009/3/1 Greg Barton 
> 
> > Oh, you dun thrown down the gauntlet now. :)
> >
> > The following will not compile with java6:
> >
> > public class ComparableFu {
> >
> >static class Foo implements
> Comparable {
> >
> >private int foo;
> >
> >public Foo(int foo) {
> >this.foo = foo;
> >}
> >
> >public int compareTo(Foo other) {
> >if(other.foo < foo) {
> >return -1;
> >} else if(other.foo == foo) {
> >return 0;
> >} else {
> >return 1;
> >}
> >}
> >}
> >
> >public static void main(String[] args) {
> >System.out.println(new Foo(1) < new
> Foo(2)); //Bad!
> >}
> > }
> >
> > Methinks the overloading of comparison operators for
> Comparables is an mvel
> > feature.
> >
> > --- On Sun, 3/1/09, Edson Tirelli
>  wrote:
> >
> > > From: Edson Tirelli 
> > > Subject: Re: [rules-users] Creating objects in
> WHEN clause
> > > To: greg_bar...@yahoo.com, "Rules Users
> List" <
> > rules-users@lists.jboss.org>
> > > Date: Sunday, March 1, 2009, 12:46 PM
> > > Just a comment:
> > >
> > > "There is no operator overloading in java,
> so the
> > > "<" operator must act on a
> > > numerical primitive. (int, double, etc.) "
> > >
> > > This is not true. Comparison operators will
> work on any
> > > "comparable"
> > > type. So if Quantity implements Comparable
> interface, it
> > > must work.
> > > Otherwise it is a bug.
> > >
> > > Although, remember that Drools always makes
> type
> > > coercion from the right
> > > to the left value, so, for that to actually work:
> > >
> > > Person( height < $2m )
> > >
> > > "height" must be comparable to $2m.
> > >
> > >  []s
> > >  Edson
> > >
> > >
> > > 2009/2/26 Greg Barton
> 
> > >
> > > > The problem is the "Person( height <
> $2m
> > > )" part.  There is no operator
> > > > overloading in java, so the "<"
> operator
> > > must act on a numerical primitive.
> > > > (int, double, etc.)  $2m is a Quantity.  As
> for why
> > > this doesn't error out,
> > > > I'm not sure, but it certainly won't
> execute.
> > > (Unless mvel has some
> > > > capabilities I'm not aware of.)
> > > >
> > > > Try
> > > >
> > > > Person( height < $2m.height )
> > > >
> > > > ...as long as Person.height and
> Quantity.height are
> > > both numerical types.
> > > >
> > > > If you want to specifically call compareTo()
> you
> > > should use an eval block:
> > > >
> > > > WHEN
> > > >  $meter:UoM( ) from
> > > UoMs.get("length","m")
> > > >  $2m:Quantity() from
> Quantities.get(2,$meter)
> > > >   $p: Person()
> > > >  eval($p.getHeight().compareTo($2m))
> > > >
> > > > However, even if this works, I hope
> you're not
> > > going to be putting too much
> > > > data through rules like this.  The way
> it's
> > > currently constructed it
> > > > completely circumvents all of drools'
> indexing
> > > ability. :)  The power of
> > > > rules comes from tracking the changes in a
> set of
> > > objects, and firing rules
> > > > based on only the changes observed.  (That
> set is the
> > > working memory.) The
> > > > "from" keyword allows you to have
> rules that
> > > draw objects from outside
> > > > working memory, but you pay for that
> convenience: the
> > > cost is not being able
> > > > to track changes.  As a result, objects
> gathered using
> > > "from" must be
> > > > reconsidered even if they haven't
> changed (i.e.
> > > every time the condition is
> > > > encountered) because drools has no way of
> knowing if
> > > they've changed or not.
> > > >
> > > > So, after this long winded spiel, here's
> my
> > > suggestion: get the rule(s) to
> > > > work using "from" but also try
> inserting the
> > > Quantity object in working
> > > > memory.  If you're processing enough
> data with the
> > > rules you will notice a
> > > > difference.
> > > >
> > > > --- On Thu, 2/26/09, David Boaz
> > >  wrote:
> > > >
> > > > > From: David Boaz
> 
> > > > > Subject: Re: [rules-users] Creating
>

[rules-users] "not matches'' not working when string is null

2009-03-02 Thread techy

Hello,
I'm checking for condition ' field not matches ".*ABC.*" ` in my rule. 
when field value is null, rule does not fire. But if field value != null and
!= ABC, then rule fires.
Is this expected output or bug? Please clarify.

Thanks

-- 
View this message in context: 
http://www.nabble.com/%22not-matches%27%27-not-working-when-string-is-null-tp22292620p22292620.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


Re: [rules-users] Help on using Drools with embedded objects

2009-03-02 Thread Greg Barton
You've answered your own question.  The method is non-static.  You must call it 
on a particular instance.  You can pass the instance in as a global variable or 
match on it in the rule.

global com.test.serviceImpl.StaffingFormMailingServiceImpl foo;

or

when
  $s:StaffingForm(...)
  $f:StaffingFormMailingServiceImpl()
then
  ...
end

Unless you have multiple StaffingFormMailingServiceImpl instances, the first 
option is best.

--- On Mon, 3/2/09, D1vy@@Ind1@  wrote:

> From: D1vy@@Ind1@ 
> Subject: Re: [rules-users] Help on using Drools with embedded objects
> To: rules-users@lists.jboss.org
> Date: Monday, March 2, 2009, 3:07 AM
> I have still not found a solution to the problem.
> 
> The problem is that I have a non static function in my
> service class and i
> have to call thhat from my drools rule file.
> 
> The function basically accepts a mail id and if a mailing
> list returns an
> arraylist of the individual mail ids in the mailing list.
> 
> my drl file looks like this:
> 
> 
> package com.test.ams.rule
> 
> dialect "java"
> 
> import java.util.ArrayList;
> import org.json.JSONArray;
> import java.net.HttpURLConnection;
> import java.net.URL;
> import java.io.InputStream;
> import java.io.InputStreamReader;
> import java.io.BufferedReader;
> 
> import com.test.domobjects.StaffingForm;
> import com.test.domobjects.StaffingFormOfferDetails;
> import com.test.domobjects.OfferResponseType;
> import function
> com.test.serviceImpl.StaffingFormMailingServiceImpl.expandTheMailingList;
> 
> global java.util.HashMap myOSFRecipientsMap;
> 
> rule "Part A"
>   salience 20
>   no-loop true
>   when
>   $s:StaffingForm(staffingFormOfferDetails.offerValue==
> true && 
>   
> staffingFormOfferDetails.offerResponseType.offerResponseTypeName
> ==
> "Accepted")
>   then
>   
> $s.setPartARecipients((ArrayList)expandTheMailingList((String)myOSFRecipientsMap.get("PART_A_EXEC_COMMITTEE")));
>   
> $s.setPartARecipients((String)myOSFRecipientsMap.get("PART_A_CONFIDENTIAL"));
>   
> $s.setPartARecipients((String)myOSFRecipientsMap.get("PART_A_PAYROLL"));
>   update($s);
>   end
> 
> 
> 
> This gives me an exception -- java.lang.RuntimeException:
> Unable to compile
> "the.drl".
> 
> Please let me know what is the problem here.
> 
> 
> Thanks
> -D
> 
> 
> 
> D1vy@@Ind1@ wrote:
> > 
> > A couple of more questions,
> > 
> > I am calling my rules engine from a service and into
> the session i am
> > inserting the business object.
> > 
> > In my service class, I have a few helper functions,
> which I need to call
> > from my drl file.
> > 
> > How can I do that ?
> > 
> > Thanks
> > -D
> > 
> > 
> > 
> > Corneil du Plessis wrote:
> >> 
> >> You should initialise your globals and then pass
> them into the session.
> >> Your rule file will have:
> >> 
> >> global java.lang.String recipients
> >> global java.lang.String to
> >> global java.lang.String cc
> >> 
> >> 
> >> On Mon, 2009-02-23 at 06:23 -0800, D1vy@@Ind1@
> wrote:
> >> 
> >>> Thanks for your help , Sudhir, 
> >>> 
> >>> I used 
> >>> 
> >>> rule
> >>> when $a:A(b.z.s=="test");
> >>> then
> >>> end
> >>> 
> >>> And that solved my problem.
> >>> 
> >>> But I would like to know one more information
> about global variables.
> >>> 
> >>> package...
> >>> dialect java
> >>> import ..,
> >>> 
> >>> global java.lang.String
> recipients="di...@gmail.com"
> >>> global java.lang.String
> to="x...@yahoo.com"
> >>> global java.lang.String
> cc="a...@gmail.com"
> >>> 
> >>> rule
> >>> when when $a:A(b.z.s=="divya");
> >>> then
> >>> $a.setRecipients(recipients);
> >>> $a.setTo(to);
> >>> $a.setCC(cc);
> >>> update($a)
> >>> end
> >>> 
> >>> Is this feasible with Drools. I get 
> >>> 
> >>> unable to comile myfile.drl file
> >>> [9,40]: unknown:9:40 mismatched token:
> [...@49,201:201='=',<71>,9:40];
> >>> E
> >>> 
> >>> exception. Could you please help me with this
> too.
> >>> 
> >>> 
> >>> Thanks
> >>> -D
> >>> 
> >>> 
> >>> 
> >>> 
> >>> 
> >>> 
> >>> 
> >>> 
> >>> Sudhir M-2 wrote:
> >>> > 
> >>> > Hi D,
> >>> > I don't know which version of drools
> are you using. If u are using
> >>> drools
> >>> > 4
> >>> > or higher you can use 'from'  to
> write rules on nested objects. All u
> >>> need
> >>> > to do is insert the root pbject in the
> working memory
> >>> > 
> >>> > Regards,
> >>> > sudhir.
> >>> > 
> >>> > On Mon, Feb 23, 2009 at 2:56 PM, Divya
> Rajendranath <
> >>> > divya.rajendran...@gmail.com> wrote:
> >>> > 
> >>> >> Hi,
> >>> >>
> >>> >> I am planning to use Drools - JBoss
> Rules Engine. My requirement is
> >>> to
> >>> >> disburse mails from my application to
> different groups based on
> >>> various
> >>> >> criteria. I want to use Drools here.
> >>> >>
> >>> >> My object structure is as follows:
> >>> >>
> >>> >> class A{
> >>> >>

Re: [rules-users] Timer isn't firing

2009-03-02 Thread Kris Verlaenen
Cristiano,

There are some examples on processes using timers here:
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/ProcessTimerTest.java

If you need help, could you maybe send me the test project you are trying to 
execute, so I can take a look?

Kris

  - Original Message - 
  From: Cristiano Gavião 
  To: Rules Users List 
  Sent: Monday, March 02, 2009 2:34 AM
  Subject: [rules-users] Timer isn't firing


  Hi, 


  I've created a simple process flow with a start node followed by a timer 
(with delay = 1 and period = 0), an workitem node, and an end node.


  Its simple but isn't working properly. The problem is that process isn't 
getting out from the timer node. Nothing happens...


  Its something more needed to get timer working?




  This is the output generated:


  BEFORE RULEFLOW STARTED process:ProcessoX[id=ProcessoX]
  BEFORE RULEFLOW NODE TRIGGERED node:Start[id=20] 
process:ProcessoX[id=ProcessoX]
  null process:ProcessoX[id=ProcessoX]
  BEFORE RULEFLOW NODE TRIGGERED node:Timer[id=19] 
process:ProcessoX[id=ProcessoX]
  AFTER RULEFLOW NODE TRIGGERED node:Timer[id=19] 
process:ProcessoX[id=ProcessoX]
  null process:ProcessoX[id=ProcessoX]
  AFTER RULEFLOW NODE TRIGGERED node:Start[id=20] 
process:ProcessoX[id=ProcessoX]
  AFTER RULEFLOW STARTED process:ProcessoX[id=ProcessoX]




  thanks in advance


  _
  Cristiano V. Gavião








--


  ___
  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] Ksession inside a executeWorkitem() ?

2009-03-02 Thread Kris Verlaenen

Cristiano,

If the working memory is always different per work item, you could use a 
global and pass it as a parameter of the work item.


However, in general it does seem better to set this on the work item handler 
directly at construction time, as a parameter on your work item handler. 
Something like this:


StatefulKnowledgeSession session = ...
MyWorkItemHandler myWorkItemHandler = new MyWorkItemHandler();
session.getWorkItemManager().registerWorkItemHandler("...", 
myWorkItemHandler);

myWorkItemHandler.setSession(session);

If you have more than one possible session, you could inject a session 
locator instead of the session itself to locate the session at runtime.


Kris

- Original Message - 
From: "Cristiano Gavião" 

To: "Rules Users List" 
Sent: Monday, March 02, 2009 2:19 PM
Subject: [rules-users] Ksession inside a executeWorkitem() ?



Hi people,

Im trying to create a workitemhandler for use Drools Pipeline and  Smooks 
to import data inside working memory and process it.


I want to share the working memory that was created for the main  process 
that is calling the workitem for configure the Drools Pipeline  inside it.


What is the best approach to do that, use Globals to pass the 
knowledgesession?


any ideias?

Thanks in advance

_
Cristiano V. Gavião


___
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 Flow Trigger process by ruleset

2009-03-02 Thread Kris Verlaenen

Garrett,

The 3rd option you describe is currently possible in the core engine, 
however support has not yet been added to the graphical designer for this. 
You can however manually add it in the XML directly for now.  If you look at 
the XSD it should look something like this:



 
   
 p:Person()
 
 
   
 


As you can see you can also specify additional parameters (that are passed 
in as variables to the process instance), either by relating them to a 
parameter of the rule or by specifying an explicit value.


Note that it is internally simply translated to your 2nd option.

We'll try to add the editor for this property for the Drools.5.0.0.GA 
release.


Kris

- Original Message - 
From: "Garrett Conaty" 

To: "Rules Users List" 
Sent: Saturday, February 28, 2009 2:51 AM
Subject: [rules-users] Drools Flow Trigger process by ruleset



___
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] Ksession inside a executeWorkitem() ?

2009-03-02 Thread Cristiano Gavião

Hi people,

Im trying to create a workitemhandler for use Drools Pipeline and  
Smooks to import data inside working memory and process it.


I want to share the working memory that was created for the main  
process that is calling the workitem for configure the Drools Pipeline  
inside it.


What is the best approach to do that, use Globals to pass the  
knowledgesession?


any ideias?

Thanks in advance

_
Cristiano V. Gavião


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


Re: [rules-users] Help on using Drools with embedded objects

2009-03-02 Thread D1vy@@Ind1@

I have still not found a solution to the problem.

The problem is that I have a non static function in my service class and i
have to call thhat from my drools rule file.

The function basically accepts a mail id and if a mailing list returns an
arraylist of the individual mail ids in the mailing list.

my drl file looks like this:


package com.test.ams.rule

dialect "java"

import java.util.ArrayList;
import org.json.JSONArray;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;

import com.test.domobjects.StaffingForm;
import com.test.domobjects.StaffingFormOfferDetails;
import com.test.domobjects.OfferResponseType;
import function
com.test.serviceImpl.StaffingFormMailingServiceImpl.expandTheMailingList;

global java.util.HashMap myOSFRecipientsMap;

rule "Part A"
salience 20
no-loop true
when
$s:StaffingForm(staffingFormOfferDetails.offerValue== true && 

staffingFormOfferDetails.offerResponseType.offerResponseTypeName ==
"Accepted")
then

$s.setPartARecipients((ArrayList)expandTheMailingList((String)myOSFRecipientsMap.get("PART_A_EXEC_COMMITTEE")));

$s.setPartARecipients((String)myOSFRecipientsMap.get("PART_A_CONFIDENTIAL"));

$s.setPartARecipients((String)myOSFRecipientsMap.get("PART_A_PAYROLL"));
update($s);
end



This gives me an exception -- java.lang.RuntimeException: Unable to compile
"the.drl".

Please let me know what is the problem here.


Thanks
-D



D1vy@@Ind1@ wrote:
> 
> A couple of more questions,
> 
> I am calling my rules engine from a service and into the session i am
> inserting the business object.
> 
> In my service class, I have a few helper functions, which I need to call
> from my drl file.
> 
> How can I do that ?
> 
> Thanks
> -D
> 
> 
> 
> Corneil du Plessis wrote:
>> 
>> You should initialise your globals and then pass them into the session.
>> Your rule file will have:
>> 
>> global java.lang.String recipients
>> global java.lang.String to
>> global java.lang.String cc
>> 
>> 
>> On Mon, 2009-02-23 at 06:23 -0800, D1vy@@Ind1@ wrote:
>> 
>>> Thanks for your help , Sudhir, 
>>> 
>>> I used 
>>> 
>>> rule
>>> when $a:A(b.z.s=="test");
>>> then
>>> end
>>> 
>>> And that solved my problem.
>>> 
>>> But I would like to know one more information about global variables.
>>> 
>>> package...
>>> dialect java
>>> import ..,
>>> 
>>> global java.lang.String recipients="di...@gmail.com"
>>> global java.lang.String to="x...@yahoo.com"
>>> global java.lang.String cc="a...@gmail.com"
>>> 
>>> rule
>>> when when $a:A(b.z.s=="divya");
>>> then
>>> $a.setRecipients(recipients);
>>> $a.setTo(to);
>>> $a.setCC(cc);
>>> update($a)
>>> end
>>> 
>>> Is this feasible with Drools. I get 
>>> 
>>> unable to comile myfile.drl file
>>> [9,40]: unknown:9:40 mismatched token: [...@49,201:201='=',<71>,9:40];
>>> E
>>> 
>>> exception. Could you please help me with this too.
>>> 
>>> 
>>> Thanks
>>> -D
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Sudhir M-2 wrote:
>>> > 
>>> > Hi D,
>>> > I don't know which version of drools are you using. If u are using
>>> drools
>>> > 4
>>> > or higher you can use 'from'  to write rules on nested objects. All u
>>> need
>>> > to do is insert the root pbject in the working memory
>>> > 
>>> > Regards,
>>> > sudhir.
>>> > 
>>> > On Mon, Feb 23, 2009 at 2:56 PM, Divya Rajendranath <
>>> > divya.rajendran...@gmail.com> wrote:
>>> > 
>>> >> Hi,
>>> >>
>>> >> I am planning to use Drools - JBoss Rules Engine. My requirement is
>>> to
>>> >> disburse mails from my application to different groups based on
>>> various
>>> >> criteria. I want to use Drools here.
>>> >>
>>> >> My object structure is as follows:
>>> >>
>>> >> class A{
>>> >>
>>> >> String B = "";
>>> >>
>>> >> B b;
>>> >>
>>> >> C c;
>>> >> }
>>> >>
>>> >> Hence Obj A has embedded objects within it, and obj B and C further
>>> has
>>> >> embedded objects.
>>> >>
>>> >> class B {
>>> >>
>>> >> String X;
>>> >>
>>> >> Z z;
>>> >>
>>> >> }
>>> >>
>>> >> class Z{
>>> >>
>>> >> String t;
>>> >>
>>> >> String s;
>>> >>
>>> >> }
>>> >>
>>> >> The decision on sending the mails based on the fields in embedded
>>> objects
>>> >> of A. I pass instance of A to Drools
>>> >>
>>> >> Format of drl file:
>>> >>
>>> >> package...;
>>> >>
>>> >> import ..;
>>> >>
>>> >> rule "Test"
>>> >>
>>> >> when $a:A(B(Z(s == "testvalue")))
>>> >>
>>> >> then
>>> >>
>>> >> $a.setSomething();
>>> >>
>>> >> update($a);
>>> >>
>>> >> end
>>> >>
>>> >> I wanted to know if this (accessing fields in embedded/child object)
>>> is
>>> >> feasible with Drools.
>>> >>
>>> >> I get an error saying "UNable to compile myfile.drl when i try to fo
>>> >> this.
>>> >>
>>> >> Could some one look in