[rules-users] Re: Infinite Recursion, with no-loop also -- HELP

2007-08-22 Thread Arjun Dhar
Arjun Dhar  yahoo.com> writes:

> 
> Hi,
>  This problem needs to be solved conceptually before technically.
> Assuming (I can't use Agenda Groups in decision tables).
> 
> SUMMARY
> ---
> Some rules evaluate some logic and pass it to a rule which aggregates the 
logic 
> to give the final outcome. Now that requires use of update. (or insert)

Details are there in previous post; but this is really important. WOuld 
appreciate some help on this!

Thanks,
Arjun

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


[rules-users] AgendaFilter not working as expected

2007-08-22 Thread Brian Enderle
I have many rules in which I have named the various rules by the level at 
which the rules are to be fired, for instance:

rule "LevelOne: Name cannot be null"
   when
  Person(firstNm == null)
   then
  
end

rule "LevelTwo: Street cannot be null"
   when
  Person(street== null)
   then
  
end

Within my Java code I first insert all objects into a statefulSession, then 
add all my globals.  I then use a switch statement to call different methods 
to perform the various levels of validation (ie: performLevelOneValidation(), 
performLevelTwoValidation(), etc.).  Each of these methods calls a common 
method, performValidation(String validationLevel) which I want to use to fire 
the rules of just the validation level supplied.  I am doing this with:

statefulSession.fireAllRules(new RuleNameStartsWithAgendaFilter
(validationLevel));

In some cases I need to perform multiple levels of validation (if anything 
over Level One validation is called, all preceding levels also need to be 
validated) and need to perform them in order for reporting purposes.  My code 
correctly calls my performaValidation() method with the correct 
validationLevel but the only rules that fire are those with "LevelOne" in the 
rule name.  

I know the data, the rules, the globals, etc are all present for firing rules 
in a level other than level one and that I should get some mathces to my rules 
but I am not getting anything to match outside of Level One.

I can only assume that the rules other than Level One are not firing and that 
I am missing something within my code that fires the rules for other levels.  
Am I misunderstanding how the AgendaFilter works?  Should I be using something 
else like agenda-group to accomplish this segregation of rules?

Also, my rules and data objects do not change as the rules are run.  I simply 
display a list of errors found.  Would it benefit me to use sequential mode 
and would this help me in trying to segerate the rules into various levels?

Thanks in advance,
Brian Enderle

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


Re: [rules-users] use EObject for facts?

2007-08-22 Thread Mark Proctor
FactTemplates where an experimental feature that are still in the 
engine, just unsupported. I wasn't happy with what we had and in order 
to get 4.0 out hand to punt. Having this working is becoming a higher 
priority now. We actually want to be able to support pluggeable data 
objects, so while it may not be possible now if they don't follow the 
JavaBean spec, you can certainly help us get the pluggeable data objects 
implementation correct.


Mark
jack wu wrote:
Hi, I am wondering if it is possible to use the EMF EObject, instead 
of java beans as facts. or does it require a lot of effort to make 
that happen.


what EObject has is very similar to what the Fact interface requires:
Object getFieldValue(String name);
void setFieldValue(String name,
   Object value);

when a java beans got passed in as fact, do we internally instantiate 
a Fact object to represent the java bean? at runetime, when rules are 
evaluated, do all the calls to get fact field values go through the 
Fact interface? using getFieldValue()?


thanks.

jack.


Pinpoint customers 
who 
are looking for what you sell.



___
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] Working Memory View

2007-08-22 Thread Mark Proctor
StatelessSession does not implement or extending Working Memory, it 
intead has it as a member variable. So you need to select that member 
variable for those views to work.


Mark
hypnosat7 wrote:

Hi,

   Why the Working Memory and the agenda Views didn't work with a
StatelessSession ?
Thanks
  


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


[rules-users] use EObject for facts?

2007-08-22 Thread jack wu
Hi, I am wondering if it is possible to use the EMF EObject, instead of java 
beans as facts. or does it require a lot of effort to make that happen.

what EObject has is very similar to what the Fact interface requires:
Object getFieldValue(String name);
void setFieldValue(String name,
   Object value);

when a java beans got passed in as fact, do we internally instantiate a Fact 
object to represent the java bean? at runetime, when rules are evaluated, do 
all the calls to get fact field values go through the Fact interface? using 
getFieldValue()? 

thanks.

jack.




   

Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] help, Unable to create Field Extractor for ....

2007-08-22 Thread Edson Tirelli
   DRL rule is case sensitive, so you should write, according to the
javabean spec:

   v : validaciones(cantSegundos == 0)
   Please note the lower case 'c' on cantSegundos.

   []s
   Edson

2007/8/22, grupo cft ing sostware <[EMAIL PROTECTED]>:
>
>
> I meet working a simple example to interiorize with jboss rules and I
> obtain the following error:
>
>
> Exception in thread "main" org.drools.rule.InvalidRulePackage: Unable to
> create Field Extractor for 'CantSegundos' : [Rule name=Valida Duracion nula,
> agendaGroup=MAIN, salience=0, no-loop=false]
>
> *org.drools.RuntimeDroolsException*
> : *org.drools.RuntimeDroolsException *:
> java.lang.NullPointerExceptionUnable to create Field Extractor for
> 'CantSegundos' : [Rule name=valida Duracion , agendaGroup=MAIN, salience=0,
> no-loop=false]*
>
> org.drools.RuntimeDroolsException
> *: *org.drools.RuntimeDroolsException*: *java.lang.NullPointerException*
>
> at org.drools.rule.Package.checkValidity(
> *Package.java:408*)
>
> at org.drools.common.AbstractRuleBase.addPackage(
> *AbstractRuleBase.java:288*)
>
> at prototipo.Prueba.main(
> *Prueba.java:27*)
>
> the class main is:
> *
>
> public
> * *static* *final* *void* main(String[] args) *throws* Exception {
>
> * final* PackageBuilder builder = *new* PackageBuilder();
>
> **builder.addPackageFromDrl(
> *new* InputStreamReader( Prueba.*class *.getResourceAsStream( "regla.drl") ) 
> );
>
> *final* RuleBase ruleBase = RuleBaseFactory.*newRuleBase*();
>
> *   ruleBase*.addPackage( builder.getPackage() );
>
> *final* StatefulSession session = ruleBase.newStatefulSession();
>
>
> *  *Integer segundos =
> *new* Integer(5);
>
> **validaciones valida =
> *new* validaciones();
>
> *   *valida.setCantSegundos(segundos);
>
> *  *session.insert( valida);
>
> *   *session.fireAllRules();
>
> *in the rules is:*
> * *
>
> *package*
> prototipo
>
> *import* prototipo.validaciones;
>
> *rule* "Valida Duracion nula"
>
> *when
>
> *   v : validaciones(CantSegundos == 0)
>
> *then*
>
>   v.setResultado(
> "I");
>
>  System.out.println(
> "obtenemos" + v.getResultado() );
>
> *end
>
> **rule* "valida Duracion "* when
>
> *  v : validaciones(CantSegundos > 0)
>
> *then*
>
>v.setResultado(
> "S");
>
> System.out.println(
> "obtenemos" + v.getResultado());
>
> *end**
>
> Thank you for helping me.
>
> ***
>
>  **
>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] Can't merge packages with different names. -- PackageException

2007-08-22 Thread Edson Tirelli
   Krishnan,

   As your files have different package names:

com.company.a;
com.company.b;

   You need to use different package builders for them. I.e., you can use
the same PackageBuilder to build multiple files only if the files share the
same package name.

[]s
Edson


2007/8/22, Krishnan <[EMAIL PROTECTED]>:
>
>
> Hi All,
>
> When I migrated to use the latest 4.0 GA release jars, loading of my rule
> files fails.
>
> I have basically split my rule files into hierarchies as below :-
>
> Directory structure
>
> rules\a\A.drl
> rules\b\B.drl
>
> A.drl
>
> com.company.a;
>
> some rules ...
>
> B.drl
>
> com.company.b;
>
> some rules ...
>
> Java code to load the rules
>
> //read in the source
> final Reader source = new InputStreamReader(new
> FileInputStream(ruleFile));
>
> //this will parse and compile in one step
> //NOTE: There are 2 methods here, the one argument one is for normal DRL.
> builder.addPackageFromDrl (source);
>
> builder is created as follows :-
>
> private PackageBuilder getPackageBuilder() {
> //Use package builder to build up a rule package.
> //An alternative lower level class called "DrlParser" can also be used...
>
> PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
> JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
> conf.getDialectConfiguration( "java" );
> javaConf.setJavaLanguageLevel ("1.5");
> PackageBuilder builder = new PackageBuilder(conf);
>
> return builder;
> }
>
> Exception I get is as follows :-
>
> EXCEPTION [org.drools.compiler.PackageBuilder$PackageMergeException: Can't
> merge packages with different names. This package:
> com.makesys.fs.is.dnpiac.vendorBehaviour.snmp - New package:
> com.makesys.fs.is.dnpiac.vendorBehaviour.cli]
> STACK [org.drools.compiler.PackageBuilder$PackageMergeException: Can't
> merge packages with different names. This package:
> com.makesys.fs.is.dnpiac.vendorBehaviour.snmp - New package:
> com.makesys.fs.is.dnpiac.vendorBehaviour.cli
> at org.drools.compiler.PackageBuilder.validatePackageName (
> PackageBuilder.java:299)
> at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:226)
> at org.drools.compiler.PackageBuilder.addPackageFromDrl(
> PackageBuilder.java:160)
> at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.loadRuleFile (
> DNPIACConfigReaderHelper.java:359)
> at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.loadRuleFiles(
> DNPIACConfigReaderHelper.java:426)
> at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.loadRuleFiles(
> DNPIACConfigReaderHelper.java :380)
> at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.initializeParams(
> DNPIACConfigReaderHelper.java:531)
> at com.makesys.fs.is.dnpiac.DNPIAutoConfigurationAdapter.collect(
> DNPIAutoConfigurationAdapter.java:61)
> at com.makesys.fs.app.adapter.BaseAdapter.activate(BaseAdapter.java:177)
> at com.makesys.fs.app.adapter.UnicastAdapterImpl.activate(
> UnicastAdapterImpl.java:109)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java :585)
> at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
> at sun.rmi.transport.Transport$1.run(Transport.java:153)
> at java.security.AccessController.doPrivileged(Native Method)
> at sun.rmi.transport.Transport.serviceCall (Transport.java:149)
> at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java
> :466)
> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(
> TCPTransport.java:707)
> at java.lang.Thread.run(Thread.java :595)
> ]
>
>
> Not sure what the issue is. Any ideas ?
>
> TIA,
> Krishnan
>
> --
> Sivaramakrishna Iyer Krishnan (Anand)
>
> Never assume the obvious is true.
> - William Safire
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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


[rules-users] help, Unable to create Field Extractor for ....

2007-08-22 Thread grupo cft ing sostware
I meet working a simple example to interiorize with jboss rules and I obtain
the following error:


Exception in thread "main" org.drools.rule.InvalidRulePackage: Unable to
create Field Extractor for 'CantSegundos' : [Rule name=Valida Duracion nula,
agendaGroup=MAIN, salience=0, no-loop=false]

*org.drools.RuntimeDroolsException*: *org.drools.RuntimeDroolsException*:
java.lang.NullPointerExceptionUnable to create Field Extractor for
'CantSegundos' : [Rule name=valida Duracion , agendaGroup=MAIN, salience=0,
no-loop=false]
*

org.drools.RuntimeDroolsException*: *org.drools.RuntimeDroolsException*: *
java.lang.NullPointerException
*

at org.drools.rule.Package.checkValidity(*Package.java:408*)

at org.drools.common.AbstractRuleBase.addPackage(*AbstractRuleBase.java:288*
)

at prototipo.Prueba.main(*Prueba.java:27*)

the class main is:
*

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

* final* PackageBuilder builder = *new* PackageBuilder();

**builder.addPackageFromDrl( *new* InputStreamReader( Prueba.*
class*.getResourceAsStream( "regla.drl" ) ) );

*final* RuleBase ruleBase = RuleBaseFactory.*newRuleBase*();

*   ruleBase*.addPackage( builder.getPackage() );

*final* StatefulSession session = ruleBase.newStatefulSession();

*  *Integer segundos = *new* Integer(5);

**validaciones valida = *new* validaciones();

*   *valida.setCantSegundos(segundos);

*  *session.insert( valida);

*   *session.fireAllRules();

*in the rules is:*
*

package prototipo

import prototipo.validaciones;

rule "Valida Duracion nula"

when

   v : validaciones(CantSegundos == 0)

then

  v.setResultado("I");

 System.out.println( "obtenemos" + v.getResultado() );

end

rule "valida Duracion "when

  v : validaciones(CantSegundos > 0)

then

   v.setResultado("S");

System.out.println( "obtenemos" + v.getResultado());

end
**

Thank you for helping me.

***

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


[rules-users] Can't merge packages with different names. -- PackageException

2007-08-22 Thread Krishnan
Hi All,

When I migrated to use the latest 4.0 GA release jars, loading of my rule
files fails.

I have basically split my rule files into hierarchies as below :-

Directory structure

rules\a\A.drl
rules\b\B.drl

A.drl

com.company.a;

some rules ...

B.drl

com.company.b;

some rules ...

Java code to load the rules

//read in the source
final Reader source = new InputStreamReader(new FileInputStream(ruleFile));

//this will parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for normal DRL.
builder.addPackageFromDrl(source);

builder is created as follows :-

private PackageBuilder getPackageBuilder() {
//Use package builder to build up a rule package.
//An alternative lower level class called "DrlParser" can also be used...

PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
conf.getDialectConfiguration( "java" );
javaConf.setJavaLanguageLevel("1.5");
PackageBuilder builder = new PackageBuilder(conf);

return builder;
}

Exception I get is as follows :-

EXCEPTION [org.drools.compiler.PackageBuilder$PackageMergeException: Can't
merge packages with different names. This package:
com.makesys.fs.is.dnpiac.vendorBehaviour.snmp - New package:
com.makesys.fs.is.dnpiac.vendorBehaviour.cli]
STACK [org.drools.compiler.PackageBuilder$PackageMergeException: Can't merge
packages with different names. This package:
com.makesys.fs.is.dnpiac.vendorBehaviour.snmp - New package:
com.makesys.fs.is.dnpiac.vendorBehaviour.cli
at org.drools.compiler.PackageBuilder.validatePackageName(
PackageBuilder.java:299)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:226)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java
:160)
at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.loadRuleFile(
DNPIACConfigReaderHelper.java:359)
at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.loadRuleFiles(
DNPIACConfigReaderHelper.java:426)
at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.loadRuleFiles(
DNPIACConfigReaderHelper.java:380)
at com.makesys.fs.is.dnpiac.DNPIACConfigReaderHelper.initializeParams(
DNPIACConfigReaderHelper.java:531)
at com.makesys.fs.is.dnpiac.DNPIAutoConfigurationAdapter.collect(
DNPIAutoConfigurationAdapter.java:61)
at com.makesys.fs.app.adapter.BaseAdapter.activate(BaseAdapter.java:177)
at com.makesys.fs.app.adapter.UnicastAdapterImpl.activate(
UnicastAdapterImpl.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(
TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
]


Not sure what the issue is. Any ideas ?

TIA,
Krishnan

-- 
Sivaramakrishna Iyer Krishnan (Anand)

Never assume the obvious is true.
- William Safire
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Simple rulebase not behaving as expected

2007-08-22 Thread Dean Jones
Hi Edson,

Thanks for the response. I was just writing a quick test as we have a
problem with some rules which contain negated rule columns (probably
just a local issue) and what you see are the simplest tests I could
write to check the behaviour of negated rule columns.

Thanks again,

Dean.

On 8/22/07, Edson Tirelli <[EMAIL PROTECTED]> wrote:
>
>Well, I'm not sure why are you constraining your rule using the class
> Object. What is happening is that the engine always inserts a fact into the
> engine known as InitialFact, that as all objects in java, is a subclass of
> Object, and that is why the rule fires.
>If instead of Object, you use a different class, like Integer for
> instance, to constrain your rule, you will get the behavior you are looking
> for.
>
>[]s
>Edson
>
> 2007/8/22, Dean Jones < [EMAIL PROTECTED]>:
> >
> > Hi,
> >
> > I have the following simple rulebase:
> >
> > package org.drools.examples
> > rule "Hello World"
> > when
> > o : Object( )
> > then
> > System.out.println("Hello world (o=" + o + ")");
> > end
> > rule "Goodbye World"
> > when
> > not Object( )
> > then
> > System.out.println("Goodbye cruel world");
> > end
> >
> > and the following code:
> >
> > public class TestReadRuleFile {
> >
> > public static void main(String[] args) throws Exception {
> >   PackageBuilder builder = new PackageBuilder();
> >   builder.addPackageFromDrl(
> > new InputStreamReader(
> > TestReadRuleFile.class.getResourceAsStream
> ("test.drl")));
> >   Package pkg = builder.getPackage();
> >   RuleBase rulebase = RuleBaseFactory.newRuleBase();
> >   rulebase.addPackage(pkg);
> >   StatefulSession session = rulebase.newStatefulSession();
> >session.fireAllRules();
> > }
> >
> > }
> >
> > which produces the following output:
> >
> > Hello world
> ([EMAIL PROTECTED])
> >
> > I expected the "Goodbye World" rule to fire, as there should not be
> > any Objects in the working memory. If I change my code to insert an
> > object into the working memory as follows:
> >
> >   session.insert(new Object());
> >
> > I now get the following output:
> >
> > Hello world ([EMAIL PROTECTED]
> )
> > Hello world ([EMAIL PROTECTED])
> >
> > In this case, I expected the "Hello World" rule to fire only once. Any
> > thoughts on what I'm doing wrong here?
> >
> > Thanks,
> >
> > Dean.
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
>
>
> --
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   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
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Migration guide

2007-08-22 Thread Edson Tirelli
  Yes, use the halt() method. The execution would re-start only if you were
re-using the working memory, what seems not to be the case.

2007/8/22, Krishnan <[EMAIL PROTECTED]>:
>
> Hi Edson,
>
> Thanks for your suggestions. The facts are produced as the rules are
> executed. Once the "interesting" fact has been produced which
> involves a rule to be executed, I am done but this does not mean the
> production of facts is done. So, I used clearAgenda(). Also, I use a new
> workingmemory for every new thread (multi-threaded environment). So, if I
> use halt() is this equivalent to clearAgenda() ?.
>
> From my understanding, the execution starts again only if you use the same
> working memory ?.
>
> Thanks,
> Krishnan.
>
> On 8/22/07, Edson Tirelli <[EMAIL PROTECTED]> wrote:
> >
> >
> >Krishnan
> >
> >clearAgenda() was not a safe method of doing that. The safe way to
> > stop the rules firing for the engine is calling the halt() method:
> >
> > drools.halt();
> >
> >Although, it is important to note that halt() will only stop the
> > rules firing but will NOT clear the agenda. i.e., if you call
> > fireAllRules() again, the engine will continue executing from the point it
> > stopped when halt() was called.
> > If you think you know what your are doing and really wants to clear
> > the agenda, you can still do:
> >
> > drools.getWorkingMemory().clearAgenda();
> >
> > But again, this is not something that should be used inside rules.
> >
> > []s
> > Edson
> >
> >
> > 2007/8/22, Krishnan < [EMAIL PROTECTED]>:
> > >
> > >
> > > Hi all,
> > >
> > > Is there a migration guide from 4.0 MR2 to 4.0 GA ?. I had got the
> > > code working in 4.0 MR2 and thought it would be
> > > as easy as just changing the jars. But it is not. Many things have
> > > changed.
> > >
> > > (a) I modified the assert() into insert()
> > >
> > > Is there anything else I should know about ?
> > >
> > > One of my failure is for the method clearAgenda() is undefined for the
> > > type KnowledgeHelper.
> > >
> > > Previously, in the rules file (.drl), once a rule has executed and I
> > > know I am done, I would call drools.clearAgenda() to
> > > expedite the processing, this does not work anymore. Has the
> > > functionality changed ?
> > >
> > > Any help will be appreciated ?.
> > >
> > > thanks,
> > > Krishnan.
> > >
> > >
> > > --
> > > Sivaramakrishna Iyer Krishnan (Anand)
> > >
> > > Never assume the obvious is true.
> > > - William Safire
> > > ___
> > > rules-users mailing list
> > > rules-users@lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> > >
> >
> >
> > --
> >   Edson Tirelli
> >   Software Engineer - JBoss Rules Core Developer
> >   Office: +55 11 3529-6000
> >   Mobile: +55 11 9287-5646
> >   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
> >
> >
>
>
> --
> Sivaramakrishna Iyer Krishnan (Anand)
>
> Never assume the obvious is true.
> - William Safire
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] Migration guide

2007-08-22 Thread Krishnan
Hi Edson,

Thanks for your suggestions. The facts are produced as the rules are
executed. Once the "interesting" fact has been produced which
involves a rule to be executed, I am done but this does not mean the
production of facts is done. So, I used clearAgenda(). Also, I use a new
workingmemory for every new thread (multi-threaded environment). So, if I
use halt() is this equivalent to clearAgenda() ?.

>From my understanding, the execution starts again only if you use the same
working memory ?.

Thanks,
Krishnan.

On 8/22/07, Edson Tirelli <[EMAIL PROTECTED]> wrote:
>
>
>Krishnan
>
>clearAgenda() was not a safe method of doing that. The safe way to stop
> the rules firing for the engine is calling the halt() method:
>
> drools.halt();
>
>Although, it is important to note that halt() will only stop the rules
> firing but will NOT clear the agenda. i.e., if you call fireAllRules()
> again, the engine will continue executing from the point it stopped when
> halt() was called.
> If you think you know what your are doing and really wants to clear
> the agenda, you can still do:
>
> drools.getWorkingMemory().clearAgenda();
>
> But again, this is not something that should be used inside rules.
>
> []s
> Edson
>
>
> 2007/8/22, Krishnan < [EMAIL PROTECTED]>:
> >
> >
> > Hi all,
> >
> > Is there a migration guide from 4.0 MR2 to 4.0 GA ?. I had got the code
> > working in 4.0 MR2 and thought it would be
> > as easy as just changing the jars. But it is not. Many things have
> > changed.
> >
> > (a) I modified the assert() into insert()
> >
> > Is there anything else I should know about ?
> >
> > One of my failure is for the method clearAgenda() is undefined for the
> > type KnowledgeHelper.
> >
> > Previously, in the rules file (.drl), once a rule has executed and I
> > know I am done, I would call drools.clearAgenda() to
> > expedite the processing, this does not work anymore. Has the
> > functionality changed ?
> >
> > Any help will be appreciated ?.
> >
> > thanks,
> > Krishnan.
> >
> >
> > --
> > Sivaramakrishna Iyer Krishnan (Anand)
> >
> > Never assume the obvious is true.
> > - William Safire
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
>
> --
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   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
>
>


-- 
Sivaramakrishna Iyer Krishnan (Anand)

Never assume the obvious is true.
- William Safire
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rules with 'From' condition with another not using From causes problem

2007-08-22 Thread Edson Tirelli
   Yes, please post a JIRA for that.

2007/8/22, Arjun Dhar <[EMAIL PROTECTED]>:
>
> Test case:
>
> Write a Rule that uses a From clause and on another object does not use a
> from
> clause:
> example:
> #From row number: 28
> rule "Rules_28"
>
> when
> cntct: Contact(initialized==true)
> config: BooleanConfiguration(value==true) from
> meta.getConfiguration(cntct.getClient(), "Param1")
> pref: Relation(contact==cntct, type=="old") or (eval
> (false==true)  and not Relation(contact==cntct, origin=="old"))
> then
>  System.out.println("Fired 28");
> end
>
> If All 3 are true:
> 1. Delete Condition 2 --> Rule fires
> 2. Delete COnditon 3 (But keep 2) --> Rule fires
> 3. Keep 2 & 3 (with 1) --> Rule does not fire
>
> Whats strage is that conditon 1 does not use from and it works with
> condition 2
> without any problem, but when 2 & 3 are there together the rule does not
> work.
>
> Please see if it is a bug
> Am posting on JIRA
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] Migration guide

2007-08-22 Thread Edson Tirelli
   Krishnan

   clearAgenda() was not a safe method of doing that. The safe way to stop
the rules firing for the engine is calling the halt() method:

drools.halt();

   Although, it is important to note that halt() will only stop the rules
firing but will NOT clear the agenda. i.e., if you call fireAllRules()
again, the engine will continue executing from the point it stopped when
halt() was called.
If you think you know what your are doing and really wants to clear the
agenda, you can still do:

drools.getWorkingMemory().clearAgenda();

But again, this is not something that should be used inside rules.

[]s
Edson


2007/8/22, Krishnan <[EMAIL PROTECTED]>:
>
>
> Hi all,
>
> Is there a migration guide from 4.0 MR2 to 4.0 GA ?. I had got the code
> working in 4.0 MR2 and thought it would be
> as easy as just changing the jars. But it is not. Many things have
> changed.
>
> (a) I modified the assert() into insert()
>
> Is there anything else I should know about ?
>
> One of my failure is for the method clearAgenda() is undefined for the
> type KnowledgeHelper.
>
> Previously, in the rules file (.drl), once a rule has executed and I know
> I am done, I would call drools.clearAgenda() to
> expedite the processing, this does not work anymore. Has the functionality
> changed ?
>
> Any help will be appreciated ?.
>
> thanks,
> Krishnan.
>
>
> --
> Sivaramakrishna Iyer Krishnan (Anand)
>
> Never assume the obvious is true.
> - William Safire
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] How to limit results from a collect statement

2007-08-22 Thread Edson Tirelli
   I do suggest you open a JIRA and attach your test case. I will need to do
some debugging to understand what is happening.

   []s
   Edson

2007/8/22, pentarious <[EMAIL PROTECTED]>:
>
>
> I hope you can help me find a solution. In the meantime I've tried your
> workaround, adding an addOption() method with no success. When I use that
> method in the rule I get the following exception (and I can't understand
> why):
> java.lang.ClassNotFoundException: org.test.ItemShadowProxy
> org.test.Item is the full qualified name of the bean Item. Any idea?
>
> Regards,
>
> CG
>
>
> Edson Tirelli-3 wrote:
> >
> >I think I know what is happening. The getOptions() method is
> returning
> > the shadowed options collections, i.e., when you are adding the option,
> > you
> > are adding to the shadow instead of the real object.
> >
> >Now, I'm not sure how we should handle such thing, since we do need
> to
> > shadow the options collection.
> >
> >Mark, any idea?
> >
> >A workaround is: create an addOption() method to the Item class to
> add
> > options, instead of doing getOptions().add(). This way the shadow proxy
> > will
> > delegate the call to your real class, instead of adding it to the
> shadow.
> >
> >[]s
> >Edson
> >
> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
> >>
> >>
> >> Actually, before opening a JIRA I would like to show you my actual
> >> code...
> >> Here it is:
> >>
> >> rule "My Rule"
> >>  no-loop true
> >> when
> >> $list : ArrayList() from collect( Item( type == "MY TYPE" ) )
> >> then
> >> Item item = (Item) $list.get(0);
> >> ItemOption option = new ItemOption( item, "MY OPTION" );
> >> item.setType("MY NEW TYPE");
> >> item.getOptions().add( option );
> >> insert(option);
> >> update(item);
> >> end
> >>
> >> Basically we have some items (Item) and we need to take into
> >> considerations
> >> just items of type "MY TYPE", adding a new option "MY OPTION" to the
> list
> >> of
> >> the options of the first item in $list. Item is a bean with a field as
> >> follows:
> >>  private Collection options = new
> >> ArrayList();
> >> I thought it was worth writing again before opening a JIRA, as I've
> >> looked
> >> further into the problem and I found out another interesting thing. As
> >> you
> >> may have noticed I put two lines in my code:
> >> item.setType("MY NEW TYPE");
> >> item.getOptions().add( option );
> >> It's interesting to notice that the first line works as expected (i.e.
> >> after
> >> executing the rule the item has a new type called "MY NEW TYPE"), while
> >> the
> >> second line doesn't (i.e. after executing the rule the item doesn't
> have
> >> a
> >> new option in its option list). So, do you think I should definitively
> >> open
> >> a JIRA (I've never opened one before, can you give a link just in
> case?)
> >> or
> >> I'm just missing something and there is a trivial solution to this
> issue?
> >>
> >> Regards,
> >>
> >> CG
> >>
> >>
> >> Edson Tirelli-3 wrote:
> >> >
> >> > Well, it must work. Can you open a JIRA with a self contained
> test
> >> > case
> >> > please? I will investigate.
> >> >
> >> >[]s
> >> >Edson
> >> >
> >> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
> >> >>
> >> >>
> >> >> I know. Actually I didn't put any update or insert statement in the
> >> code
> >> >> just
> >> >> to make it simpler. The actual code looks like:
> >> >> when
> >> >>   $itemList : ArrayList() from collect( Item( category ==
> "VIDEO"
> >> )
> >> )
> >> >> then
> >> >>   ItemDiscount disc = new ItemDiscount(10);
> >> >>   insert(disc);
> >> >>   $myFirstItem = (Item)$itemList.get(0);
> >> >>   $mySecondItem = (Item)$itemList.get(1);
> >> >>   $myFirstItem.addDiscount(disc);
> >> >>   $mySecondItem.addDiscount(disc);
> >> >>   update($myFirstItem);
> >> >>   update($mySecondItem);
> >> >> Now, why this doesn't work at all? It does work if I write a rule
> for
> >> >> each
> >> >> item using in the when clause $item  : Item from $itemList, but as I
> >> said
> >> >> I
> >> >> need to write a list-oriented rule.
> >> >>
> >> >> Regards,
> >> >>
> >> >> CG
> >> >>
> >> >>
> >> >> Edson Tirelli-3 wrote:
> >> >> >
> >> >> >If you want the "engine to see" your changes, in a way you
> affect
> >> >> other
> >> >> > rules, you must call update( object ) for the object you are
> >> changing.
> >> >> > Otherwise, the change will happen to the original object, but not
> to
> >> >> the
> >> >> > shadow proxy that the engine uses to ensure consistency.
> >> >> >
> >> >> >[]s
> >> >> >Edson
> >> >> >
> >> >> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
> >> >> >>
> >> >> >>
> >> >> >> Ok, I'm still working on that, I'll publish my solution asap. In
> >> the
> >> >> >> meantime
> >> >> >> it turns out our requirements need something more than that. We
> >> have
> >> >> an
> >> >> >> ordered list of beans (items) and we have to be able to modif

Re: [rules-users] Simple rulebase not behaving as expected

2007-08-22 Thread Edson Tirelli
   Well, I'm not sure why are you constraining your rule using the class
Object. What is happening is that the engine always inserts a fact into the
engine known as InitialFact, that as all objects in java, is a subclass of
Object, and that is why the rule fires.
   If instead of Object, you use a different class, like Integer for
instance, to constrain your rule, you will get the behavior you are looking
for.

   []s
   Edson

2007/8/22, Dean Jones <[EMAIL PROTECTED]>:
>
> Hi,
>
> I have the following simple rulebase:
>
> package org.drools.examples
> rule "Hello World"
> when
> o : Object( )
> then
> System.out.println("Hello world (o=" + o + ")");
> end
> rule "Goodbye World"
> when
> not Object( )
> then
> System.out.println("Goodbye cruel world");
> end
>
> and the following code:
>
> public class TestReadRuleFile {
>
> public static void main(String[] args) throws Exception {
>   PackageBuilder builder = new PackageBuilder();
>   builder.addPackageFromDrl(
> new InputStreamReader(
> TestReadRuleFile.class.getResourceAsStream("test.drl")));
>   Package pkg = builder.getPackage();
>   RuleBase rulebase = RuleBaseFactory.newRuleBase();
>   rulebase.addPackage(pkg);
>   StatefulSession session = rulebase.newStatefulSession();
>   session.fireAllRules();
> }
>
> }
>
> which produces the following output:
>
> Hello world ([EMAIL PROTECTED])
>
> I expected the "Goodbye World" rule to fire, as there should not be
> any Objects in the working memory. If I change my code to insert an
> object into the working memory as follows:
>
>   session.insert(new Object());
>
> I now get the following output:
>
> Hello world ([EMAIL PROTECTED])
> Hello world ([EMAIL PROTECTED])
>
> In this case, I expected the "Hello World" rule to fire only once. Any
> thoughts on what I'm doing wrong here?
>
> Thanks,
>
> Dean.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] DRL & Year of Date

2007-08-22 Thread Edson Tirelli
   In your case, best seems to be to use a return value restriction:

MyClass( $brotherDOB : brotherDOB != null,  yearBorn < (date.yearOfDate($
brotherDOB)-{years}) )

   []s
   Edson

2007/8/22, Saleem Lakhani <[EMAIL PROTECTED]>:
>
>  Hi,
>
>
>
> What is the best way of writing such a rule in drools 4.0 without using
> eval ? In the following rule 'date' is a global variable for my own dateUtil
> class and {year} is the variable I will pass.
>
>
>
> brotherDOB != null, $brotherDOB : brotherDOB
>
>
>
> eval(boy.getYearBorn() < (date.yearOfDate($brotherDOB)-{years}))
>
>
>
> Saleem Lakhani
>
>
>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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


[rules-users] Migration guide

2007-08-22 Thread Krishnan
Hi all,

Is there a migration guide from 4.0 MR2 to 4.0 GA ?. I had got the code
working in 4.0 MR2 and thought it would be
as easy as just changing the jars. But it is not. Many things have changed.

(a) I modified the assert() into insert()

Is there anything else I should know about ?

One of my failure is for the method clearAgenda() is undefined for the type
KnowledgeHelper.

Previously, in the rules file (.drl), once a rule has executed and I know I
am done, I would call drools.clearAgenda() to
expedite the processing, this does not work anymore. Has the functionality
changed ?

Any help will be appreciated ?.

thanks,
Krishnan.


-- 
Sivaramakrishna Iyer Krishnan (Anand)

Never assume the obvious is true.
- William Safire
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Rules with 'From' condition with another not using From causes problem

2007-08-22 Thread Arjun Dhar
Test case:

Write a Rule that uses a From clause and on another object does not use a from 
clause:
example:
#From row number: 28
rule "Rules_28"

when
cntct: Contact(initialized==true)
config: BooleanConfiguration(value==true) from 
meta.getConfiguration(cntct.getClient(), "Param1")
pref: Relation(contact==cntct, type=="old") or (eval
(false==true)  and not Relation(contact==cntct, origin=="old"))
then
 System.out.println("Fired 28");
end

If All 3 are true:
 1. Delete Condition 2 --> Rule fires
 2. Delete COnditon 3 (But keep 2) --> Rule fires
 3. Keep 2 & 3 (with 1) --> Rule does not fire

Whats strage is that conditon 1 does not use from and it works with condition 2 
without any problem, but when 2 & 3 are there together the rule does not work.

Please see if it is a bug
Am posting on JIRA

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


Re: [rules-users] How to limit results from a collect statement

2007-08-22 Thread pentarious

I hope you can help me find a solution. In the meantime I've tried your
workaround, adding an addOption() method with no success. When I use that
method in the rule I get the following exception (and I can't understand
why):
 java.lang.ClassNotFoundException: org.test.ItemShadowProxy
org.test.Item is the full qualified name of the bean Item. Any idea?

Regards,

CG 


Edson Tirelli-3 wrote:
> 
>I think I know what is happening. The getOptions() method is returning
> the shadowed options collections, i.e., when you are adding the option,
> you
> are adding to the shadow instead of the real object.
> 
>Now, I'm not sure how we should handle such thing, since we do need to
> shadow the options collection.
> 
>Mark, any idea?
> 
>A workaround is: create an addOption() method to the Item class to add
> options, instead of doing getOptions().add(). This way the shadow proxy
> will
> delegate the call to your real class, instead of adding it to the shadow.
> 
>[]s
>Edson
> 
> 2007/8/22, pentarious <[EMAIL PROTECTED]>:
>>
>>
>> Actually, before opening a JIRA I would like to show you my actual
>> code...
>> Here it is:
>>
>> rule "My Rule"
>>  no-loop true
>> when
>> $list : ArrayList() from collect( Item( type == "MY TYPE" ) )
>> then
>> Item item = (Item) $list.get(0);
>> ItemOption option = new ItemOption( item, "MY OPTION" );
>> item.setType("MY NEW TYPE");
>> item.getOptions().add( option );
>> insert(option);
>> update(item);
>> end
>>
>> Basically we have some items (Item) and we need to take into
>> considerations
>> just items of type "MY TYPE", adding a new option "MY OPTION" to the list
>> of
>> the options of the first item in $list. Item is a bean with a field as
>> follows:
>>  private Collection options = new
>> ArrayList();
>> I thought it was worth writing again before opening a JIRA, as I've
>> looked
>> further into the problem and I found out another interesting thing. As
>> you
>> may have noticed I put two lines in my code:
>> item.setType("MY NEW TYPE");
>> item.getOptions().add( option );
>> It's interesting to notice that the first line works as expected (i.e.
>> after
>> executing the rule the item has a new type called "MY NEW TYPE"), while
>> the
>> second line doesn't (i.e. after executing the rule the item doesn't have
>> a
>> new option in its option list). So, do you think I should definitively
>> open
>> a JIRA (I've never opened one before, can you give a link just in case?)
>> or
>> I'm just missing something and there is a trivial solution to this issue?
>>
>> Regards,
>>
>> CG
>>
>>
>> Edson Tirelli-3 wrote:
>> >
>> > Well, it must work. Can you open a JIRA with a self contained test
>> > case
>> > please? I will investigate.
>> >
>> >[]s
>> >Edson
>> >
>> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
>> >>
>> >>
>> >> I know. Actually I didn't put any update or insert statement in the
>> code
>> >> just
>> >> to make it simpler. The actual code looks like:
>> >> when
>> >>   $itemList : ArrayList() from collect( Item( category == "VIDEO"
>> )
>> )
>> >> then
>> >>   ItemDiscount disc = new ItemDiscount(10);
>> >>   insert(disc);
>> >>   $myFirstItem = (Item)$itemList.get(0);
>> >>   $mySecondItem = (Item)$itemList.get(1);
>> >>   $myFirstItem.addDiscount(disc);
>> >>   $mySecondItem.addDiscount(disc);
>> >>   update($myFirstItem);
>> >>   update($mySecondItem);
>> >> Now, why this doesn't work at all? It does work if I write a rule for
>> >> each
>> >> item using in the when clause $item  : Item from $itemList, but as I
>> said
>> >> I
>> >> need to write a list-oriented rule.
>> >>
>> >> Regards,
>> >>
>> >> CG
>> >>
>> >>
>> >> Edson Tirelli-3 wrote:
>> >> >
>> >> >If you want the "engine to see" your changes, in a way you affect
>> >> other
>> >> > rules, you must call update( object ) for the object you are
>> changing.
>> >> > Otherwise, the change will happen to the original object, but not to
>> >> the
>> >> > shadow proxy that the engine uses to ensure consistency.
>> >> >
>> >> >[]s
>> >> >Edson
>> >> >
>> >> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
>> >> >>
>> >> >>
>> >> >> Ok, I'm still working on that, I'll publish my solution asap. In
>> the
>> >> >> meantime
>> >> >> it turns out our requirements need something more than that. We
>> have
>> >> an
>> >> >> ordered list of beans (items) and we have to be able to modify a
>> >> specific
>> >> >> subset of the list (adding a discount). Now I tried to solve this
>> >> problem
>> >> >> by
>> >> >> working directly on the list of items. But I can't understand why
>> this
>> >> >> doesn't work:
>> >> >> when
>> >> >>  $itemList : ArrayList() from collect( Item( category ==
>> "VIDEO"
>> )
>> >> )
>> >> >> then
>> >> >>  ItemDiscount disc = new ItemDiscount(10);
>> >> >>  $myFirstItem = (Item)$itemList.get(0);
>> >> >>  $mySecondItem = (Item)$itemL

[rules-users] Simple rulebase not behaving as expected

2007-08-22 Thread Dean Jones
Hi,

I have the following simple rulebase:

package org.drools.examples
rule "Hello World"
when
o : Object( )
then
System.out.println("Hello world (o=" + o + ")");
end
rule "Goodbye World"
when
not Object( )
then
System.out.println("Goodbye cruel world");
end

and the following code:

public class TestReadRuleFile {

public static void main(String[] args) throws Exception {
  PackageBuilder builder = new PackageBuilder();
  builder.addPackageFromDrl(
new InputStreamReader(
TestReadRuleFile.class.getResourceAsStream("test.drl")));
  Package pkg = builder.getPackage();
  RuleBase rulebase = RuleBaseFactory.newRuleBase();
  rulebase.addPackage(pkg);
  StatefulSession session = rulebase.newStatefulSession();
  session.fireAllRules();
}

}

which produces the following output:

Hello world ([EMAIL PROTECTED])

I expected the "Goodbye World" rule to fire, as there should not be
any Objects in the working memory. If I change my code to insert an
object into the working memory as follows:

  session.insert(new Object());

I now get the following output:

Hello world ([EMAIL PROTECTED])
Hello world ([EMAIL PROTECTED])

In this case, I expected the "Hello World" rule to fire only once. Any
thoughts on what I'm doing wrong here?

Thanks,

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


[rules-users] DRL & Year of Date

2007-08-22 Thread Saleem Lakhani
Hi,

 

What is the best way of writing such a rule in drools 4.0 without using
eval ? In the following rule 'date' is a global variable for my own
dateUtil class and {year} is the variable I will pass.

 

brotherDOB != null, $brotherDOB : brotherDOB

 

eval(boy.getYearBorn() < (date.yearOfDate($brotherDOB)-{years}))

 

Saleem Lakhani

 

 

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


[rules-users] Working Memory View

2007-08-22 Thread hypnosat7

Hi,

   Why the Working Memory and the agenda Views didn't work with a
StatelessSession ?
Thanks
-- 
View this message in context: 
http://www.nabble.com/Working-Memory-View-tf4312013.html#a12276049
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] How to limit results from a collect statement

2007-08-22 Thread Edson Tirelli
   I think I know what is happening. The getOptions() method is returning
the shadowed options collections, i.e., when you are adding the option, you
are adding to the shadow instead of the real object.

   Now, I'm not sure how we should handle such thing, since we do need to
shadow the options collection.

   Mark, any idea?

   A workaround is: create an addOption() method to the Item class to add
options, instead of doing getOptions().add(). This way the shadow proxy will
delegate the call to your real class, instead of adding it to the shadow.

   []s
   Edson

2007/8/22, pentarious <[EMAIL PROTECTED]>:
>
>
> Actually, before opening a JIRA I would like to show you my actual code...
> Here it is:
>
> rule "My Rule"
>  no-loop true
> when
> $list : ArrayList() from collect( Item( type == "MY TYPE" ) )
> then
> Item item = (Item) $list.get(0);
> ItemOption option = new ItemOption( item, "MY OPTION" );
> item.setType("MY NEW TYPE");
> item.getOptions().add( option );
> insert(option);
> update(item);
> end
>
> Basically we have some items (Item) and we need to take into
> considerations
> just items of type "MY TYPE", adding a new option "MY OPTION" to the list
> of
> the options of the first item in $list. Item is a bean with a field as
> follows:
>  private Collection options = new
> ArrayList();
> I thought it was worth writing again before opening a JIRA, as I've looked
> further into the problem and I found out another interesting thing. As you
> may have noticed I put two lines in my code:
> item.setType("MY NEW TYPE");
> item.getOptions().add( option );
> It's interesting to notice that the first line works as expected (i.e.
> after
> executing the rule the item has a new type called "MY NEW TYPE"), while
> the
> second line doesn't (i.e. after executing the rule the item doesn't have a
> new option in its option list). So, do you think I should definitively
> open
> a JIRA (I've never opened one before, can you give a link just in case?)
> or
> I'm just missing something and there is a trivial solution to this issue?
>
> Regards,
>
> CG
>
>
> Edson Tirelli-3 wrote:
> >
> > Well, it must work. Can you open a JIRA with a self contained test
> > case
> > please? I will investigate.
> >
> >[]s
> >Edson
> >
> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
> >>
> >>
> >> I know. Actually I didn't put any update or insert statement in the
> code
> >> just
> >> to make it simpler. The actual code looks like:
> >> when
> >>   $itemList : ArrayList() from collect( Item( category == "VIDEO" )
> )
> >> then
> >>   ItemDiscount disc = new ItemDiscount(10);
> >>   insert(disc);
> >>   $myFirstItem = (Item)$itemList.get(0);
> >>   $mySecondItem = (Item)$itemList.get(1);
> >>   $myFirstItem.addDiscount(disc);
> >>   $mySecondItem.addDiscount(disc);
> >>   update($myFirstItem);
> >>   update($mySecondItem);
> >> Now, why this doesn't work at all? It does work if I write a rule for
> >> each
> >> item using in the when clause $item  : Item from $itemList, but as I
> said
> >> I
> >> need to write a list-oriented rule.
> >>
> >> Regards,
> >>
> >> CG
> >>
> >>
> >> Edson Tirelli-3 wrote:
> >> >
> >> >If you want the "engine to see" your changes, in a way you affect
> >> other
> >> > rules, you must call update( object ) for the object you are
> changing.
> >> > Otherwise, the change will happen to the original object, but not to
> >> the
> >> > shadow proxy that the engine uses to ensure consistency.
> >> >
> >> >[]s
> >> >Edson
> >> >
> >> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
> >> >>
> >> >>
> >> >> Ok, I'm still working on that, I'll publish my solution asap. In the
> >> >> meantime
> >> >> it turns out our requirements need something more than that. We have
> >> an
> >> >> ordered list of beans (items) and we have to be able to modify a
> >> specific
> >> >> subset of the list (adding a discount). Now I tried to solve this
> >> problem
> >> >> by
> >> >> working directly on the list of items. But I can't understand why
> this
> >> >> doesn't work:
> >> >> when
> >> >>  $itemList : ArrayList() from collect( Item( category == "VIDEO"
> )
> >> )
> >> >> then
> >> >>  ItemDiscount disc = new ItemDiscount(10);
> >> >>  $myFirstItem = (Item)$itemList.get(0);
> >> >>  $mySecondItem = (Item)$itemList.get(1);
> >> >>  $myFirstItem.addDiscount(disc);
> >> >>  $mySecondItem.addDiscount(disc);
> >> >>
> >> >> After executing this rule it's like nothing happened! I mean no
> >> discount
> >> >> has
> >> >> been added to the two items! The problem seems to be related to
> >> >> extracting
> >> >> items from the list. Apparently, every time we get an item from the
> >> list,
> >> >> it
> >> >> looses its link with the original item (I don't know if it's a copy
> of
> >> >> the
> >> >> original item or whatever), so that every update doesn't affect the
> >> >> original

[rules-users] Serialize/Deserialize Rule Object

2007-08-22 Thread Jin, Ming
I found that the org.drools.rule.Rule object could be serialized by
itself (without the parent Package object) but could not be
de-serialized. Received a class not found exception from a possible
proxy class.  Is it by design or a problem?

Thanks,
-Ming

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


Re: [rules-users] error in the manual ?

2007-08-22 Thread Mark Proctor

stateless :) can you please open a jira for this, so we don't forget.

Thanks

Mark
hypnosat7 wrote:

Hi,

  I see on :
file:///C:/Utils/Drools%204/drools-4.0.0-bin/documentation/manual/html/index.html

in the sequential mode : "Sequential mode can only be used with a
StatefulSession and is off by default. ..."

Is it statefulSession or stateless ?
  


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


Re: [rules-users] How to limit results from a collect statement

2007-08-22 Thread pentarious

Actually, before opening a JIRA I would like to show you my actual code...
Here it is:

rule "My Rule"
 no-loop true
when
$list : ArrayList() from collect( Item( type == "MY TYPE" ) )
then
Item item = (Item) $list.get(0);
ItemOption option = new ItemOption( item, "MY OPTION" );
item.setType("MY NEW TYPE");
item.getOptions().add( option );
insert(option);
update(item);
end

Basically we have some items (Item) and we need to take into considerations
just items of type "MY TYPE", adding a new option "MY OPTION" to the list of
the options of the first item in $list. Item is a bean with a field as
follows:
 private Collection options = new ArrayList();
I thought it was worth writing again before opening a JIRA, as I've looked
further into the problem and I found out another interesting thing. As you
may have noticed I put two lines in my code:
item.setType("MY NEW TYPE");
item.getOptions().add( option );
It's interesting to notice that the first line works as expected (i.e. after
executing the rule the item has a new type called "MY NEW TYPE"), while the
second line doesn't (i.e. after executing the rule the item doesn't have a
new option in its option list). So, do you think I should definitively open
a JIRA (I've never opened one before, can you give a link just in case?) or
I'm just missing something and there is a trivial solution to this issue?

Regards,

CG


Edson Tirelli-3 wrote:
> 
> Well, it must work. Can you open a JIRA with a self contained test
> case
> please? I will investigate.
> 
>[]s
>Edson
> 
> 2007/8/22, pentarious <[EMAIL PROTECTED]>:
>>
>>
>> I know. Actually I didn't put any update or insert statement in the code
>> just
>> to make it simpler. The actual code looks like:
>> when
>>   $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )
>> then
>>   ItemDiscount disc = new ItemDiscount(10);
>>   insert(disc);
>>   $myFirstItem = (Item)$itemList.get(0);
>>   $mySecondItem = (Item)$itemList.get(1);
>>   $myFirstItem.addDiscount(disc);
>>   $mySecondItem.addDiscount(disc);
>>   update($myFirstItem);
>>   update($mySecondItem);
>> Now, why this doesn't work at all? It does work if I write a rule for
>> each
>> item using in the when clause $item  : Item from $itemList, but as I said
>> I
>> need to write a list-oriented rule.
>>
>> Regards,
>>
>> CG
>>
>>
>> Edson Tirelli-3 wrote:
>> >
>> >If you want the "engine to see" your changes, in a way you affect
>> other
>> > rules, you must call update( object ) for the object you are changing.
>> > Otherwise, the change will happen to the original object, but not to
>> the
>> > shadow proxy that the engine uses to ensure consistency.
>> >
>> >[]s
>> >Edson
>> >
>> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
>> >>
>> >>
>> >> Ok, I'm still working on that, I'll publish my solution asap. In the
>> >> meantime
>> >> it turns out our requirements need something more than that. We have
>> an
>> >> ordered list of beans (items) and we have to be able to modify a
>> specific
>> >> subset of the list (adding a discount). Now I tried to solve this
>> problem
>> >> by
>> >> working directly on the list of items. But I can't understand why this
>> >> doesn't work:
>> >> when
>> >>  $itemList : ArrayList() from collect( Item( category == "VIDEO" )
>> )
>> >> then
>> >>  ItemDiscount disc = new ItemDiscount(10);
>> >>  $myFirstItem = (Item)$itemList.get(0);
>> >>  $mySecondItem = (Item)$itemList.get(1);
>> >>  $myFirstItem.addDiscount(disc);
>> >>  $mySecondItem.addDiscount(disc);
>> >>
>> >> After executing this rule it's like nothing happened! I mean no
>> discount
>> >> has
>> >> been added to the two items! The problem seems to be related to
>> >> extracting
>> >> items from the list. Apparently, every time we get an item from the
>> list,
>> >> it
>> >> looses its link with the original item (I don't know if it's a copy of
>> >> the
>> >> original item or whatever), so that every update doesn't affect the
>> >> original
>> >> item any more. But of course that's what we're interested in! We want
>> to
>> >> modify original items in the rule session. Am I missing something? Or
>> Is
>> >> it
>> >> a bug?
>> >>
>> >> Regards,
>> >>
>> >> CG
>> >>
>> >>
>> >>
>> >> Edson Tirelli-3 wrote:
>> >> >
>> >> > Please, share with us! Send to the list!
>> >> >
>> >> > Edson
>> >> >
>> >> > 2007/8/21, pentarious <[EMAIL PROTECTED]>:
>> >> >>
>> >> >>
>> >> >> I found an interesting implementation to do that. If anyone is
>> >> interested
>> >> >> I
>> >> >> could share my solution.
>> >> >>
>> >> >> Regards,
>> >> >>
>> >> >> CG
>> >> >>
>> >> >>
>> >> >> Mark Proctor wrote:
>> >> >> >
>> >> >> > There is no supported way to do this. You could use an
>> inline-eval
>> >> >> > against a global, but that is very clunkey. However it does seem
>> >> like
>> >> a
>> >> >> > good feature idea for a

Re: [rules-users] How to limit results from a collect statement

2007-08-22 Thread Edson Tirelli
Well, it must work. Can you open a JIRA with a self contained test case
please? I will investigate.

   []s
   Edson

2007/8/22, pentarious <[EMAIL PROTECTED]>:
>
>
> I know. Actually I didn't put any update or insert statement in the code
> just
> to make it simpler. The actual code looks like:
> when
>   $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )
> then
>   ItemDiscount disc = new ItemDiscount(10);
>   insert(disc);
>   $myFirstItem = (Item)$itemList.get(0);
>   $mySecondItem = (Item)$itemList.get(1);
>   $myFirstItem.addDiscount(disc);
>   $mySecondItem.addDiscount(disc);
>   update($myFirstItem);
>   update($mySecondItem);
> Now, why this doesn't work at all? It does work if I write a rule for each
> item using in the when clause $item  : Item from $itemList, but as I said
> I
> need to write a list-oriented rule.
>
> Regards,
>
> CG
>
>
> Edson Tirelli-3 wrote:
> >
> >If you want the "engine to see" your changes, in a way you affect
> other
> > rules, you must call update( object ) for the object you are changing.
> > Otherwise, the change will happen to the original object, but not to the
> > shadow proxy that the engine uses to ensure consistency.
> >
> >[]s
> >Edson
> >
> > 2007/8/22, pentarious <[EMAIL PROTECTED]>:
> >>
> >>
> >> Ok, I'm still working on that, I'll publish my solution asap. In the
> >> meantime
> >> it turns out our requirements need something more than that. We have an
> >> ordered list of beans (items) and we have to be able to modify a
> specific
> >> subset of the list (adding a discount). Now I tried to solve this
> problem
> >> by
> >> working directly on the list of items. But I can't understand why this
> >> doesn't work:
> >> when
> >>  $itemList : ArrayList() from collect( Item( category == "VIDEO" )
> )
> >> then
> >>  ItemDiscount disc = new ItemDiscount(10);
> >>  $myFirstItem = (Item)$itemList.get(0);
> >>  $mySecondItem = (Item)$itemList.get(1);
> >>  $myFirstItem.addDiscount(disc);
> >>  $mySecondItem.addDiscount(disc);
> >>
> >> After executing this rule it's like nothing happened! I mean no
> discount
> >> has
> >> been added to the two items! The problem seems to be related to
> >> extracting
> >> items from the list. Apparently, every time we get an item from the
> list,
> >> it
> >> looses its link with the original item (I don't know if it's a copy of
> >> the
> >> original item or whatever), so that every update doesn't affect the
> >> original
> >> item any more. But of course that's what we're interested in! We want
> to
> >> modify original items in the rule session. Am I missing something? Or
> Is
> >> it
> >> a bug?
> >>
> >> Regards,
> >>
> >> CG
> >>
> >>
> >>
> >> Edson Tirelli-3 wrote:
> >> >
> >> > Please, share with us! Send to the list!
> >> >
> >> > Edson
> >> >
> >> > 2007/8/21, pentarious <[EMAIL PROTECTED]>:
> >> >>
> >> >>
> >> >> I found an interesting implementation to do that. If anyone is
> >> interested
> >> >> I
> >> >> could share my solution.
> >> >>
> >> >> Regards,
> >> >>
> >> >> CG
> >> >>
> >> >>
> >> >> Mark Proctor wrote:
> >> >> >
> >> >> > There is no supported way to do this. You could use an inline-eval
> >> >> > against a global, but that is very clunkey. However it does seem
> >> like
> >> a
> >> >> > good feature idea for a future release, open a jira and I'll look
> >> into
> >> >> > getting it included.
> >> >> >
> >> >> > Mark
> >> >> > pentarious wrote:
> >> >> >> Does anyone know a method to limit the number of results from a
> >> >> collect
> >> >> >> statement? I was just wondering how to do something like this:
> >> >> >> $myList : List() from collect( MyObject(myField == "something") )
> >> >> limit
> >> >> 3
> >> >> >> //it should put in $myList just the first 3 objects retrieved
> >> >> >> I'm quite sure there is nothing in Drools which can natively
> >> support
> >> >> >> something like that. So, how to do that, if needed? I tried this,
> >> but
> >> >> it
> >> >> >> seems not to be working (I can't understand why, though):
> >> >> >> $myList : List() from collect( MyObject(myField == "something") )
> >> >> >> $myObject : MyObject() from $myList
> >> >> >> eval( $myList.indexOf($myObject) < 3 )
> >> >> >> Indeed, it doesn't work because the link beetween $myList and
> >> >> $myObject
> >> >> >> seems to be released during any execution of the rule (In fact
> >> >> >> $myList.contains($myObject) returns false! Again, I can't
> >> understand
> >> >> >> why...)
> >> >> >>
> >> >> >> Any advice would be really appreciated!
> >> >> >>
> >> >> >> Regards,
> >> >> >>
> >> >> >> CG
> >> >> >>
> >> >> >
> >> >> > ___
> >> >> > 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/How-

Re: [rules-users] Are rules with time windows supported? Thanks.

2007-08-22 Thread Edson Tirelli
Yes, this is my personal top priority for the next major release, but
still requires research to be done right.

Answering Anh, there is an old blog entry on a way to do such things:

http://blog.athico.com/search/label/Time-Sensitive

   But again, this is a general way of working with time sensitive rules and
to manually manage time windows while we don't have built-in support. With
built-in support, things get a lot easier and more declarative than the
examples showed there.

   []s
   Edson

2007/8/21, Ming Fang <[EMAIL PROTECTED]>:
>
> I too am very interested in this type of capability.  I'm current using a
> combination of Esper and Drools but would prefer to use a single product.
>
> --ming
> Sent from my iPhone
>
> On Aug 21, 2007, at 9:24 AM, Edson Tirelli <[EMAIL PROTECTED]> wrote:
>
>
>You are right. Time windows are not yet supported in Drools 4. It is a
> feature that will be included in the next major versions.
>You can "emulate" time windows using Time objects, but of course it
> will require more work as compared to built in time window support.
>
> Edson
>
> 2007/8/20, Anh Vuong < <[EMAIL PROTECTED]>[EMAIL PROTECTED]>:
> >
> > Hi,
> > My understanding is that time window rule is not supported yet in 4.0after 
> > checking the manual and followed some blogs regarding SEP/CEP.  I
> > wonder if some workaround can be done for simple case such as collect some
> > similar events over 1 minute. Will time window feature be included soon?
> >
> > Thanks,
> > anh
> >
> > --
> > Be a better Globetrotter. Get better travel answers
> > from
> > someone who knows.
> > Yahoo! Answers - Check it out.
> >
> >
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > 
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
>
> --
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   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
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] How to limit results from a collect statement

2007-08-22 Thread pentarious

I know. Actually I didn't put any update or insert statement in the code just
to make it simpler. The actual code looks like:
when
  $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )
then
  ItemDiscount disc = new ItemDiscount(10);
  insert(disc);
  $myFirstItem = (Item)$itemList.get(0);
  $mySecondItem = (Item)$itemList.get(1);
  $myFirstItem.addDiscount(disc);
  $mySecondItem.addDiscount(disc);
  update($myFirstItem);
  update($mySecondItem);
Now, why this doesn't work at all? It does work if I write a rule for each
item using in the when clause $item  : Item from $itemList, but as I said I
need to write a list-oriented rule.

Regards,

CG


Edson Tirelli-3 wrote:
> 
>If you want the "engine to see" your changes, in a way you affect other
> rules, you must call update( object ) for the object you are changing.
> Otherwise, the change will happen to the original object, but not to the
> shadow proxy that the engine uses to ensure consistency.
> 
>[]s
>Edson
> 
> 2007/8/22, pentarious <[EMAIL PROTECTED]>:
>>
>>
>> Ok, I'm still working on that, I'll publish my solution asap. In the
>> meantime
>> it turns out our requirements need something more than that. We have an
>> ordered list of beans (items) and we have to be able to modify a specific
>> subset of the list (adding a discount). Now I tried to solve this problem
>> by
>> working directly on the list of items. But I can't understand why this
>> doesn't work:
>> when
>>  $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )
>> then
>>  ItemDiscount disc = new ItemDiscount(10);
>>  $myFirstItem = (Item)$itemList.get(0);
>>  $mySecondItem = (Item)$itemList.get(1);
>>  $myFirstItem.addDiscount(disc);
>>  $mySecondItem.addDiscount(disc);
>>
>> After executing this rule it's like nothing happened! I mean no discount
>> has
>> been added to the two items! The problem seems to be related to
>> extracting
>> items from the list. Apparently, every time we get an item from the list,
>> it
>> looses its link with the original item (I don't know if it's a copy of
>> the
>> original item or whatever), so that every update doesn't affect the
>> original
>> item any more. But of course that's what we're interested in! We want to
>> modify original items in the rule session. Am I missing something? Or Is
>> it
>> a bug?
>>
>> Regards,
>>
>> CG
>>
>>
>>
>> Edson Tirelli-3 wrote:
>> >
>> > Please, share with us! Send to the list!
>> >
>> > Edson
>> >
>> > 2007/8/21, pentarious <[EMAIL PROTECTED]>:
>> >>
>> >>
>> >> I found an interesting implementation to do that. If anyone is
>> interested
>> >> I
>> >> could share my solution.
>> >>
>> >> Regards,
>> >>
>> >> CG
>> >>
>> >>
>> >> Mark Proctor wrote:
>> >> >
>> >> > There is no supported way to do this. You could use an inline-eval
>> >> > against a global, but that is very clunkey. However it does seem
>> like
>> a
>> >> > good feature idea for a future release, open a jira and I'll look
>> into
>> >> > getting it included.
>> >> >
>> >> > Mark
>> >> > pentarious wrote:
>> >> >> Does anyone know a method to limit the number of results from a
>> >> collect
>> >> >> statement? I was just wondering how to do something like this:
>> >> >> $myList : List() from collect( MyObject(myField == "something") )
>> >> limit
>> >> 3
>> >> >> //it should put in $myList just the first 3 objects retrieved
>> >> >> I'm quite sure there is nothing in Drools which can natively
>> support
>> >> >> something like that. So, how to do that, if needed? I tried this,
>> but
>> >> it
>> >> >> seems not to be working (I can't understand why, though):
>> >> >> $myList : List() from collect( MyObject(myField == "something") )
>> >> >> $myObject : MyObject() from $myList
>> >> >> eval( $myList.indexOf($myObject) < 3 )
>> >> >> Indeed, it doesn't work because the link beetween $myList and
>> >> $myObject
>> >> >> seems to be released during any execution of the rule (In fact
>> >> >> $myList.contains($myObject) returns false! Again, I can't
>> understand
>> >> >> why...)
>> >> >>
>> >> >> Any advice would be really appreciated!
>> >> >>
>> >> >> Regards,
>> >> >>
>> >> >> CG
>> >> >>
>> >> >
>> >> > ___
>> >> > 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/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025
>> >> 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
>> >   Software Engineer - JBoss Rules Core Developer
>> >   Office: +55 11 3529-6000
>> >   Mobile: +

Re: [rules-users] How to limit results from a collect statement

2007-08-22 Thread Edson Tirelli
   If you want the "engine to see" your changes, in a way you affect other
rules, you must call update( object ) for the object you are changing.
Otherwise, the change will happen to the original object, but not to the
shadow proxy that the engine uses to ensure consistency.

   []s
   Edson

2007/8/22, pentarious <[EMAIL PROTECTED]>:
>
>
> Ok, I'm still working on that, I'll publish my solution asap. In the
> meantime
> it turns out our requirements need something more than that. We have an
> ordered list of beans (items) and we have to be able to modify a specific
> subset of the list (adding a discount). Now I tried to solve this problem
> by
> working directly on the list of items. But I can't understand why this
> doesn't work:
> when
>  $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )
> then
>  ItemDiscount disc = new ItemDiscount(10);
>  $myFirstItem = (Item)$itemList.get(0);
>  $mySecondItem = (Item)$itemList.get(1);
>  $myFirstItem.addDiscount(disc);
>  $mySecondItem.addDiscount(disc);
>
> After executing this rule it's like nothing happened! I mean no discount
> has
> been added to the two items! The problem seems to be related to extracting
> items from the list. Apparently, every time we get an item from the list,
> it
> looses its link with the original item (I don't know if it's a copy of the
> original item or whatever), so that every update doesn't affect the
> original
> item any more. But of course that's what we're interested in! We want to
> modify original items in the rule session. Am I missing something? Or Is
> it
> a bug?
>
> Regards,
>
> CG
>
>
>
> Edson Tirelli-3 wrote:
> >
> > Please, share with us! Send to the list!
> >
> > Edson
> >
> > 2007/8/21, pentarious <[EMAIL PROTECTED]>:
> >>
> >>
> >> I found an interesting implementation to do that. If anyone is
> interested
> >> I
> >> could share my solution.
> >>
> >> Regards,
> >>
> >> CG
> >>
> >>
> >> Mark Proctor wrote:
> >> >
> >> > There is no supported way to do this. You could use an inline-eval
> >> > against a global, but that is very clunkey. However it does seem like
> a
> >> > good feature idea for a future release, open a jira and I'll look
> into
> >> > getting it included.
> >> >
> >> > Mark
> >> > pentarious wrote:
> >> >> Does anyone know a method to limit the number of results from a
> >> collect
> >> >> statement? I was just wondering how to do something like this:
> >> >> $myList : List() from collect( MyObject(myField == "something") )
> >> limit
> >> 3
> >> >> //it should put in $myList just the first 3 objects retrieved
> >> >> I'm quite sure there is nothing in Drools which can natively support
> >> >> something like that. So, how to do that, if needed? I tried this,
> but
> >> it
> >> >> seems not to be working (I can't understand why, though):
> >> >> $myList : List() from collect( MyObject(myField == "something") )
> >> >> $myObject : MyObject() from $myList
> >> >> eval( $myList.indexOf($myObject) < 3 )
> >> >> Indeed, it doesn't work because the link beetween $myList and
> >> $myObject
> >> >> seems to be released during any execution of the rule (In fact
> >> >> $myList.contains($myObject) returns false! Again, I can't understand
> >> >> why...)
> >> >>
> >> >> Any advice would be really appreciated!
> >> >>
> >> >> Regards,
> >> >>
> >> >> CG
> >> >>
> >> >
> >> > ___
> >> > 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/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025
> >> 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
> >   Software Engineer - JBoss Rules Core Developer
> >   Office: +55 11 3529-6000
> >   Mobile: +55 11 9287-5646
> >   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
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12270505
> 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
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org

[rules-users] error in the manual ?

2007-08-22 Thread hypnosat7

Hi,

  I see on :
file:///C:/Utils/Drools%204/drools-4.0.0-bin/documentation/manual/html/index.html

in the sequential mode : "Sequential mode can only be used with a
StatefulSession and is off by default. ..."

Is it statefulSession or stateless ?
-- 
View this message in context: 
http://www.nabble.com/error-in-the-manual---tf4310800.html#a12272046
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] statelessSession and rule flow

2007-08-22 Thread Shahad Ahmed
I asked this question on Aug 10 and got a reply from Mark Proctor saying the
only way to currently do this is as follows:

"you would have to call drools.getWorkingMemory().startProcess(id) from
inside of a consequence."

This means that you would have to create a rule that is always guaranteed to
fire first e.g. with a "when" condition of true and a salience that is
higher than all the other rules. The "then" part of the rule will be a call
to drools.getWorkingMemory().startProcess(id).

Personally I don't like this, as there should really be an API option to set
a ruleflow to a stateless session. Do a search for statelesssession +
ruleflow in the rules-users archives for a the original thread (started on
Aug 10).

Regards
Shahad



On 8/22/07, hypnosat7 <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> Is there any way to use rule flows with a statelessSession ?
> Thanks
> --
> View this message in context:
> http://www.nabble.com/statelessSession-and-rule-flow-tf4310262.html#a12270501
> 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


[rules-users] statelessSession and rule flow

2007-08-22 Thread hypnosat7

Hi,

  Is there any way to use rule flows with a statelessSession ?
Thanks
-- 
View this message in context: 
http://www.nabble.com/statelessSession-and-rule-flow-tf4310262.html#a12270501
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] How to limit results from a collect statement

2007-08-22 Thread pentarious

Ok, I'm still working on that, I'll publish my solution asap. In the meantime
it turns out our requirements need something more than that. We have an
ordered list of beans (items) and we have to be able to modify a specific
subset of the list (adding a discount). Now I tried to solve this problem by
working directly on the list of items. But I can't understand why this
doesn't work:
when
 $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )
then
 ItemDiscount disc = new ItemDiscount(10);
 $myFirstItem = (Item)$itemList.get(0);
 $mySecondItem = (Item)$itemList.get(1);
 $myFirstItem.addDiscount(disc);
 $mySecondItem.addDiscount(disc);

After executing this rule it's like nothing happened! I mean no discount has
been added to the two items! The problem seems to be related to extracting
items from the list. Apparently, every time we get an item from the list, it
looses its link with the original item (I don't know if it's a copy of the
original item or whatever), so that every update doesn't affect the original
item any more. But of course that's what we're interested in! We want to
modify original items in the rule session. Am I missing something? Or Is it
a bug?

Regards,

CG



Edson Tirelli-3 wrote:
> 
> Please, share with us! Send to the list!
> 
> Edson
> 
> 2007/8/21, pentarious <[EMAIL PROTECTED]>:
>>
>>
>> I found an interesting implementation to do that. If anyone is interested
>> I
>> could share my solution.
>>
>> Regards,
>>
>> CG
>>
>>
>> Mark Proctor wrote:
>> >
>> > There is no supported way to do this. You could use an inline-eval
>> > against a global, but that is very clunkey. However it does seem like a
>> > good feature idea for a future release, open a jira and I'll look into
>> > getting it included.
>> >
>> > Mark
>> > pentarious wrote:
>> >> Does anyone know a method to limit the number of results from a
>> collect
>> >> statement? I was just wondering how to do something like this:
>> >> $myList : List() from collect( MyObject(myField == "something") )
>> limit
>> 3
>> >> //it should put in $myList just the first 3 objects retrieved
>> >> I'm quite sure there is nothing in Drools which can natively support
>> >> something like that. So, how to do that, if needed? I tried this, but
>> it
>> >> seems not to be working (I can't understand why, though):
>> >> $myList : List() from collect( MyObject(myField == "something") )
>> >> $myObject : MyObject() from $myList
>> >> eval( $myList.indexOf($myObject) < 3 )
>> >> Indeed, it doesn't work because the link beetween $myList and
>> $myObject
>> >> seems to be released during any execution of the rule (In fact
>> >> $myList.contains($myObject) returns false! Again, I can't understand
>> >> why...)
>> >>
>> >> Any advice would be really appreciated!
>> >>
>> >> Regards,
>> >>
>> >> CG
>> >>
>> >
>> > ___
>> > 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/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025
>> 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
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   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
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12270505
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