[rules-users] How can I write a rule that will only fire once for every object in the working memory

2008-01-23 Thread Waruzjan Shahbazian

Hallo,

I was wondering if it's possible to create a rule that can only be 
activated once. So if at a certain point the LHS is matching, it will be 
fired and deactivated immediately, so the rule never ever gets fired for 
the object it has updated, no matter if the LHS will matches after a few 
updates()'s at a later time.


The only way I can achieve this, is by manually evaluating in the LHS if 
the certain object has the certain values I am gonna set in the RHS, so 
if it has, I don't fire the rule. But this takes some unnessery time and 
I was wondering if it couldn't be more easier/faster.


Example:


$product : Product(title matches "(?i).*SOMEWORD.*", $productClasses : 
productClasses)

$activated : Boolean(booleanValue == false)
   from accumulate($productClass : ProductClass( 
schema.code == "DROOLS", code == "012345" ) from $productClasses,

 init(boolean activated = false;),
 action( activated = true;),
 result( activated ) )

then

Set the schema and code of the product

update($product)



So in the example above I am actually iterating over all the 
productClasses of the product and checking if they have the right codes. 
If I actually could just fire the rule on all the products
whose title matches "(?i).*SOMEWORD.*", and deactivate the rule for the 
instance of the $product, I wouldn't have to accumulate over the list of 
productClasses of the product to see if the rule

was fired before for this particulare product.

The "no-loop" attribute doesn't work here, because it gets ignored when 
another rule updates the product. So when this rule has fired, and 
updated the product, some other rule gets activated and updates the 
product, and than this rule gets fired, because the LHS still matches.


Any help is welcome,

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


[rules-users] from l18n syntax question

2007-12-17 Thread Waruzjan Shahbazian

Hi all,

I have the following problem:

There is an Product classe which contains localized title with the getter:

public Localized getTitle() {
   return _title;
   }

Localizes is a classe with private final Map _bindings; and 
has the public getter: public T get(Locale locale) {}


Now I want to check in the LHS of my rule if the title contains some 
substring. I can do that with matches(regular expression), but how can I 
best iterate in the localizede strings of the title?
I am now doing it with the following eval() way, but there must be a 
better solution:


There are 2 languages in Localizes, so I can check that with the public 
int size. There is also a methode get(Locale) to get the String of the 
given local, but how can I use that here?


$prd : Product()
$title : Localized(size == 2) from $prd.getTitle()
eval( matchesLocalTestString($title, "(?i).*SUBSTRING.*") )

function boolean matchesLocalTestString(Localized locString, String 
matchString) {

   String tmpStr = (String) locString.get(LocaleUtils.DUTCH);
   return tmpStr.matches(matchString) ;
}

The code above works, but I can't get the result of the eval and I don't 
think this is the fastest way. So can anyone please help me with this?


Thanks,

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


Re: [rules-users] Contains substring in the LHS with regular expression capturing groups?

2007-12-14 Thread Waruzjan Shahbazian
The pluggable operators example looks very cool  :-) , I just have one 
more question about the performance. I suppose that if I use eval() with 
indexOf(), there would be no caching? Isn't that one of the benefits of 
using the "drools" operators, since ( if they work on the same way as in 
the example in the trunk anyway) they do use caching. Anyway, if  I do 
some benchmarks about this I would let you now!


About the backwards compatibility: Thats cool, as long as what I did was 
not a not recommended way. The costes for the few possible changes in 
the feature are indeed affordable to pay.


Waruzjan

Edson Tirelli schreef:

   I really don't know about perf differences in this case. I guess best
thing would be for you do give a try (and let us know please). :) It
probably will depend on the java implementation of the matches() against
indexOf() method. I guess indexOf is faster, but don't know if it is
significant difference.
   Regarding pluggable operators, here you have one example:

http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/evaluators/MatchesEvaluatorsDefinition.java

Regarding using the descriptor classes, I would say it is the
recommended way for generated rules, since you avoid the "text
generation"+"parsing" cost of the rules. Although, as much as we try to keep
backward compatibility, we can't guarantee there will be no breaks, since we
are always adding new features and the descriptor model must usually change
to support them what may eventually break backward compatibility. Even with
that, I think it is an affordable cost to pay (fixing eventual breaks on
version updates) compared to your runtime application robustness.

   []s
   Edson



2007/12/14, Waruzjan Shahbazian <[EMAIL PROTECTED]>:
  

Hi,

Thanks for the reply. I wanted to be sure that there wasn't any more
efficient way to check a substring in a string, or do you think that
eval() with a indexOf() call would be more efficient than matches() with
regular expression?. Since I can't group the results, the speed is the
only issue here.

In my application I am creating the PackageDescr myself with some
"template" RuleDescr's (which are being filled in with the, limited,
user input in the Swing GUI) and the package is being build with the
builder. If the regular expression methode in the matches operator is
the best way to check a substring in a string, I can use variabeles
(which are the user inputs) to fill the regular expression. So I don't
really need a new operator for this. But I am interessted how the
development of a new operator would be, so maybe you could tell me where
I need to be to do so :-) .

In the attachment  is the classe diagram of the PackageDescr with the
linked classes as I have understood and used in my application. Of
course not every operation and attribute is included, but maybe this
could be helpfull for someone else who wants to create PackageDescr's
directly.

I suppose the public methodes used in this operation are going to be
supported by the following drools versions? Or should I have used the
DRL and XML ? =-O

Thanks,

Waruzjan

Edson Tirelli schreef:


   Yes, you may use matches. The other alternative is using an eval and
  

a


regular indexOf() call to check for the existance of the substring.
  

Drools


up to versions 4.0.x is JSE 1.4 compliant, so you can't use contains()
method.  In trunk, you may also develop your own operator and plug it
  

into


the engine... although, it is not documented yet, but if you want to
  

try, I


can guide you through. And if you want to contribute docs after that,
  

even


better. :)

   It is not possible to capture groups and reuse in the RHS. I'm
  

thinking


about a way to bind variables to arbitrary values in the LHS. If we
implement that, than it would be possible for you to do that, but not
possible at this moment.

   Edson

2007/12/14, Waruzjan Shahbazian <[EMAIL PROTECTED]>:

  

Hi,

I need to check in the LHS of my rule if  a given String contains an
given substring. What is the best way to do that? I can use regular
expression with matches, but is that the best (fastest) solution?
(STRING matches "(?i).*SUBSTRING.*"). And can I use regulare


expressions


capturing groups and than use the results of the groups in the RHS? If
not, what is the best methode to do that?

Thanks,

Waruzjan
___
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] Contains substring in the LHS with regular expression capturing groups?

2007-12-14 Thread Waruzjan Shahbazian

Hi,

Thanks for the reply. I wanted to be sure that there wasn't any more 
efficient way to check a substring in a string, or do you think that 
eval() with a indexOf() call would be more efficient than matches() with 
regular expression?. Since I can't group the results, the speed is the 
only issue here.


In my application I am creating the PackageDescr myself with some 
"template" RuleDescr's (which are being filled in with the, limited, 
user input in the Swing GUI) and the package is being build with the 
builder. If the regular expression methode in the matches operator is 
the best way to check a substring in a string, I can use variabeles 
(which are the user inputs) to fill the regular expression. So I don't 
really need a new operator for this. But I am interessted how the 
development of a new operator would be, so maybe you could tell me where 
I need to be to do so :-) .


In the attachment  is the classe diagram of the PackageDescr with the 
linked classes as I have understood and used in my application. Of 
course not every operation and attribute is included, but maybe this 
could be helpfull for someone else who wants to create PackageDescr's 
directly.


I suppose the public methodes used in this operation are going to be 
supported by the following drools versions? Or should I have used the 
DRL and XML ? =-O


Thanks,

Waruzjan

Edson Tirelli schreef:

   Yes, you may use matches. The other alternative is using an eval and a
regular indexOf() call to check for the existance of the substring. Drools
up to versions 4.0.x is JSE 1.4 compliant, so you can't use contains()
method.  In trunk, you may also develop your own operator and plug it into
the engine... although, it is not documented yet, but if you want to try, I
can guide you through. And if you want to contribute docs after that, even
better. :)

   It is not possible to capture groups and reuse in the RHS. I'm thinking
about a way to bind variables to arbitrary values in the LHS. If we
implement that, than it would be possible for you to do that, but not
possible at this moment.

   Edson

2007/12/14, Waruzjan Shahbazian <[EMAIL PROTECTED]>:
  

Hi,

I need to check in the LHS of my rule if  a given String contains an
given substring. What is the best way to do that? I can use regular
expression with matches, but is that the best (fastest) solution?
(STRING matches "(?i).*SUBSTRING.*"). And can I use regulare expressions
capturing groups and than use the results of the groups in the RHS? If
not, what is the best methode to do that?

Thanks,

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






  



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


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


[rules-users] Contains substring in the LHS with regular expression capturing groups?

2007-12-14 Thread Waruzjan Shahbazian

Hi,

I need to check in the LHS of my rule if  a given String contains an 
given substring. What is the best way to do that? I can use regular 
expression with matches, but is that the best (fastest) solution? 
(STRING matches "(?i).*SUBSTRING.*"). And can I use regulare expressions 
capturing groups and than use the results of the groups in the RHS? If 
not, what is the best methode to do that?


Thanks,

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


Re: [rules-users] BRMS Insurance Sample - Invalid Class Exception -> Solved

2007-11-27 Thread Waruzjan Shahbazian
I found the solution, the mvel in drools-jbrms library is indeed 
mvel14-1.2.10.jar, but probably the compilation of the model wasn't done 
with that version in the classpath?


Anyway, you need to compile the package  org.acme.insurance.base in a 
.jar file and upload it as the model in the BRMS ( after you 
successfully imported repository_export.xml ) . Than you can deploy the 
package in brms and the test units should work fine.


Waruzjan Shahbazian schreef:

I am having the same problem. Has anyone got this working?

I have tried using mvel version 1.2.8 and 1.2.10 in the classpath of 
drools-insurance ( where the jUnit tests are ) and by both the
serialVersionUID is different. So can anyone tell me which version of 
mvel is needed to get this working?


Thx,

Waruzjan

John Nader schreef:

I am seeing the same issue.  My configuration is slightly different in
that I am using Drools 4.0.3 and JBoss 4.2.2GA with Java 5.  I have been
searching very hard to find where these two different version of
AbstractParser are coming from.   This class comes out of the MVEL.  The
jar in the drools-jbrms is mvel14-1.2.10.jar.  I only see this jar
within the deployment.

 


My thought is that a serialized version of the class is stored in a file
somewhere in the demo project or the BRMS itself, and that it is from an
older version mvel.

 

 


-J

 


--Original Message-

Folks,
 
Using BRMS 4.0.2 and examples 4.02 as downloaded from the 'official 
release' site.
 
Working my way through the Drools Insurance Sample (on BRMS). I'm 
deploying BRMS successfully on JBoss 4.2.1 with Java 1.6.0_02. I can 
import the repository_export.xml ok and see the files. I leave this part


of the sample running as per the instructions.
 
When I go to the 2nd part of the example I have a problem running the 
unit tests: within /drools-examples/drools-insurance I run: mvn clean 
package. I get the error(1) at the bottom of this email. I do *not* 
get the output as per the documentaiton. I skip the tests, build and 
deploy the drools-insurance.war
 
When deploying the war I see the following error (2) in the JBoss logs .


However main drools insurance page loads ok as per the screenshot in the

documentation):
 22:43:13,576 INFO  [WebappClassLoader] 
validateJarFile(C:\software\jboss-4-2-1\server\default\.\tmp\deploy\tmp2

6632drool
s-insurance-exp.war\WEB-INF\lib\servlet-api-2.3.jar) - jar not 
loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: 
javax/servlet/Servlet.class
 
I enter some values in the web app (make sure there are no nulls) 
press 'continue' then get the same error (3)
22:48:55,294 ERROR [STDERR] java.io.InvalidClassException: 
org.mvel.AbstractParser; local class incompatible: stream cla
ssdesc serialVersionUID = 256028721591955695, local class 
serialVersionUID = -7464517220700761297
22:48:55,310 ERROR [STDERR] at 
java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
 
As an aside , when I look for the latest BRMS , as mentioned in the docs


(http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules) - I get a 
'Invalid File or Directory'
 
Is there anything I should try to resolve this?
 
Paul
 
 
 
 
 
RuleAgent(insuranceconfig) INFO (Thu Oct 18 22:37:44 BST 2007): 
Configuring package provider : URLScanner monitoring URL
s:  
http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acm

e.insurance.base/InsuranceDemo
RuleAgent(insuranceconfig) EXCEPTION (Thu Oct 18 22:37:45 BST 2007): 
org.mvel.AbstractParser; local class incompatible:
stream classdesc serialVersionUID = 256028721591955695, local class 
serialVersionUID = -7464517220700761297. Stack trace

 should follow..io.ObjectStreamClass.initNonProxy(Unknown Source)
java.io.InvalidClassException: org.mvel.AbstractParser; local class 
incompatible: stream classdesc serialVersionUID = 25

6028721591955695, local class serialVersionUID = -7464517220700761297
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)rce)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)urce)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)rce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readO

Re: [rules-users] BRMS Insurance Sample - Invalid Class Exception

2007-11-26 Thread Waruzjan Shahbazian

I am having the same problem. Has anyone got this working?

I have tried using mvel version 1.2.8 and 1.2.10 in the classpath of 
drools-insurance ( where the jUnit tests are ) and by both the
serialVersionUID is different. So can anyone tell me which version of 
mvel is needed to get this working?


Thx,

Waruzjan

John Nader schreef:

I am seeing the same issue.  My configuration is slightly different in
that I am using Drools 4.0.3 and JBoss 4.2.2GA with Java 5.  I have been
searching very hard to find where these two different version of
AbstractParser are coming from.   This class comes out of the MVEL.  The
jar in the drools-jbrms is mvel14-1.2.10.jar.  I only see this jar
within the deployment.

 


My thought is that a serialized version of the class is stored in a file
somewhere in the demo project or the BRMS itself, and that it is from an
older version mvel.

 

 


-J

 


--Original Message-

Folks,
 
Using BRMS 4.0.2 and examples 4.02 as downloaded from the 'official 
release' site.
 
Working my way through the Drools Insurance Sample (on BRMS). I'm 
deploying BRMS successfully on JBoss 4.2.1 with Java 1.6.0_02. I can 
import the repository_export.xml ok and see the files. I leave this part


of the sample running as per the instructions.
 
When I go to the 2nd part of the example I have a problem running the 
unit tests: within /drools-examples/drools-insurance I run: mvn clean 
package. I get the error(1) at the bottom of this email. I do *not* get 
the output as per the documentaiton. I skip the tests, build and deploy 
the drools-insurance.war
 
When deploying the war I see the following error (2) in the JBoss logs .


However main drools insurance page loads ok as per the screenshot in the

documentation):
 22:43:13,576 INFO  [WebappClassLoader] 
validateJarFile(C:\software\jboss-4-2-1\server\default\.\tmp\deploy\tmp2

6632drool
s-insurance-exp.war\WEB-INF\lib\servlet-api-2.3.jar) - jar not loaded. 
See Servlet Spec 2.3, section 9.7.2. Offending class: 
javax/servlet/Servlet.class
 
I enter some values in the web app (make sure there are no nulls) press 
'continue' then get the same error (3)
22:48:55,294 ERROR [STDERR] java.io.InvalidClassException: 
org.mvel.AbstractParser; local class incompatible: stream cla
ssdesc serialVersionUID = 256028721591955695, local class 
serialVersionUID = -7464517220700761297
22:48:55,310 ERROR [STDERR] at 
java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
 
As an aside , when I look for the latest BRMS , as mentioned in the docs


(http://cruisecontrol.jboss.com/cc/artifacts/jboss-rules) - I get a 
'Invalid File or Directory'
 
Is there anything I should try to resolve this?
 
Paul
 
 
 
 
 
RuleAgent(insuranceconfig) INFO (Thu Oct 18 22:37:44 BST 2007): 
Configuring package provider : URLScanner monitoring URL
s:  
http://localhost:8080/drools-jbrms/org.drools.brms.JBRMS/package/org.acm

e.insurance.base/InsuranceDemo
RuleAgent(insuranceconfig) EXCEPTION (Thu Oct 18 22:37:45 BST 2007): 
org.mvel.AbstractParser; local class incompatible:
stream classdesc serialVersionUID = 256028721591955695, local class 
serialVersionUID = -7464517220700761297. Stack trace

 should follow..io.ObjectStreamClass.initNonProxy(Unknown Source)
java.io.InvalidClassException: org.mvel.AbstractParser; local class 
incompatible: stream classdesc serialVersionUID = 25

6028721591955695, local class serialVersionUID = -7464517220700761297
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)rce)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)urce)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)rce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)ce)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(

Re: [rules-users] Initialize Global

2007-10-30 Thread Waruzjan Shahbazian
Oke I get it. I am using the globals just for temporary immutable 
values, first to be set by a rule and then to be used by the other rules.


I just have another question, how can I declare an array as a global?

When I try

   global int[] type;
   global String[] test;

and then in the RHS
   $type = new int[4];

Eclipse complains:

   Multiple markers at this line
   - Syntax error on token "}", delete this token
   - Syntax error on token "[", delete this token
   - Syntax error on token "}", delete this token

and i get errrors during the compilation too.

Ofcourse I can make an object with an String and/or int array in it and 
use that, but is this the expected behavior?


Thanks,

Waruzjan

Anstis, Michael (M.) schreef:

This is in essence already catered for - you need a LHS fact.

A global is just a holder for some (immutable) set of values\functions to
make life easier for common (immutable) values\functions your rule may need.

If you want to start making the global mutable for RETE to "use" the changes
they become facts.

  

rule "Start"
salience 101
when
then
MyGlobalObject myGlobal = new MyGlobalObject();
ArrayList objectList = new ArrayList() ;
objectList.add("1");
objectList.add("2");   
myGlobal.setList(objectList);
System.out.println("Start objectList:" + objectList); 
insert(myGlobal);

end

rule "end"
salience 97
when
$g : MyGlobalObject( list != null )
then
System.out.println("End objectList: " + $g.getList());
end
  



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Waruzjan
Shahbazian
Sent: 30 October 2007 09:31
To: Rules Users List
Subject: Re: [rules-users] Initialize Global

Thanks, that sounds logical to me. I guess I just have to "trust" that 
the rule where the array gets initialised activates earlier than the 
rule where I need the array. That shouldn't be a problem since I use 
salience and to avoid nullpoint exceptions I can use the if(objectList 
!= null)  in the "Then" part of the rule where I need the array.


Maybe an idea for the drools developers to create an "update" function 
for the globals so we can eval on them too...in the future.


vdelbart schreef:
  

It's normal.

Globally, the rule engine works in two steps :
 - first : the activation (the "when" statement)
 - second : the execution (the "then" statement) with salience, ruleflow


...
  

In your test, you have in the first step objectList = null and in the


second
  

step objectList = [1, 2].

If you want to re-activate your rule, you have to do an


update/insert/remove
  

action... But you can't do that with globals. So you need to use the WM
facts.



Waruzjan Shahbazian-2 wrote:
  

I have the same "problem", but eval(objectList == null) doesn't work. If 
I don't execute "drools.getWorkingMemory().setGlobal()" it "works fine", 
as if the rule activates and the object is null.


global List objectList;

rule "Start"
salience 101
when
#conditions
then
objectList = new ArrayList() ;
objectList.add("1");
objectList.add("2");   
System.out.println("Start objectList:"+objectList); 
//drools.getWorkingMemory().setGlobal("objectList", objectList);

end

rule "end"
salience 97
when
eval (objectList == null)
then
System.out.println("End objectList: "+objectList);
end
   
gives:
   
Start objectList:[1, 2]

End objectList: null

Next I uncomment the "drools.getWorkingMemory().setGlobal("objectList", 
objectList);" and run the rule again an get:


Start objectList:[1, 2]
End objectList: [1, 2]

so the objectList isn't null, but the rule still activates...

Kris Verlaenen schreef:

  
That initialized my global but the rule still runs every execution.  
Can I

disable the rule after the first execution?

  
What do you mean by "every execution".  A rule should only be executed 
once, unless it gets reactivated (which should not be the case in this 
situation).


  

I would like to use (if (objectList==null)).  My list is not 
immutable. Can

I make a similar rule for the LHS?

  
You can test whether the global is null using eval( objectList == null 
)  in the LHS of the rule.


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


_

Re: [rules-users] Initialize Global

2007-10-30 Thread Waruzjan Shahbazian
Thanks, that sounds logical to me. I guess I just have to "trust" that 
the rule where the array gets initialised activates earlier than the 
rule where I need the array. That shouldn't be a problem since I use 
salience and to avoid nullpoint exceptions I can use the if(objectList 
!= null)  in the "Then" part of the rule where I need the array.


Maybe an idea for the drools developers to create an "update" function 
for the globals so we can eval on them too...in the future.


vdelbart schreef:

It's normal.

Globally, the rule engine works in two steps :
 - first : the activation (the "when" statement)
 - second : the execution (the "then" statement) with salience, ruleflow ...

In your test, you have in the first step objectList = null and in the second
step objectList = [1, 2].

If you want to re-activate your rule, you have to do an update/insert/remove
action... But you can't do that with globals. So you need to use the WM
facts.



Waruzjan Shahbazian-2 wrote:
  
I have the same "problem", but eval(objectList == null) doesn't work. If 
I don't execute "drools.getWorkingMemory().setGlobal()" it "works fine", 
as if the rule activates and the object is null.


global List objectList;

rule "Start"
salience 101
when
#conditions
then
objectList = new ArrayList() ;
objectList.add("1");
objectList.add("2");   
System.out.println("Start objectList:"+objectList); 
//drools.getWorkingMemory().setGlobal("objectList", objectList);

end

rule "end"
salience 97
when
eval (objectList == null)
then
System.out.println("End objectList: "+objectList);
end
   
gives:
   
Start objectList:[1, 2]

End objectList: null

Next I uncomment the "drools.getWorkingMemory().setGlobal("objectList", 
objectList);" and run the rule again an get:


Start objectList:[1, 2]
End objectList: [1, 2]

so the objectList isn't null, but the rule still activates...

Kris Verlaenen schreef:

That initialized my global but the rule still runs every execution.  
Can I

disable the rule after the first execution?

What do you mean by "every execution".  A rule should only be executed 
once, unless it gets reactivated (which should not be the case in this 
situation).


  
I would like to use (if (objectList==null)).  My list is not 
immutable. Can

I make a similar rule for the LHS?

You can test whether the global is null using eval( objectList == null 
)  in the LHS of the rule.


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

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





  


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


Re: [rules-users] Initialize Global

2007-10-30 Thread Waruzjan Shahbazian
I have the same "problem", but eval(objectList == null) doesn't work. If 
I don't execute "drools.getWorkingMemory().setGlobal()" it "works fine", 
as if the rule activates and the object is null.


global List objectList;

rule "Start"
   salience 101
   when
   #conditions
   then
   objectList = new ArrayList() ;
   objectList.add("1");
   objectList.add("2");   
   System.out.println("Start objectList:"+objectList); 
   //drools.getWorkingMemory().setGlobal("objectList", objectList);

end

rule "end"
   salience 97
   when
   eval (objectList == null)
   then
   System.out.println("End objectList: "+objectList);
end
  
gives:
  
   Start objectList:[1, 2]

   End objectList: null

Next I uncomment the "drools.getWorkingMemory().setGlobal("objectList", 
objectList);" and run the rule again an get:


   Start objectList:[1, 2]
   End objectList: [1, 2]

so the objectList isn't null, but the rule still activates...

Kris Verlaenen schreef:
That initialized my global but the rule still runs every execution.  
Can I

disable the rule after the first execution?
What do you mean by "every execution".  A rule should only be executed 
once, unless it gets reactivated (which should not be the case in this 
situation).


I would like to use (if (objectList==null)).  My list is not 
immutable. Can

I make a similar rule for the LHS?
You can test whether the global is null using eval( objectList == null 
)  in the LHS of the rule.


Kris
___
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] About rules firing

2007-10-08 Thread Waruzjan Shahbazian
As mentioned in the documentation ( 
http://downloads.jboss.com/drools/docs/4.0.1.14754GA/html/ch06s05.html#d0e2928 
) you can use activation-group's. So you need to give your both rules 
the same activation-group name, so when the one rule is being activated, 
the other will not be fired. You could use salience to set the priority 
of those rules, so you can give the rule 1 a higher priority, so it will 
be checked first.


Was that what you where looking for?

[EMAIL PROTECTED] schreef:

Hi
 
I am using Drools 4.0.
I have two rules in my rule file.The "when" condition of my first rule 
is satisfying.Now please tell me that what should i do if i don't want 
to execute the second rule?
 
Thanks.
 
/*With Regards*/

/*Prateek*/

The information contained in this electronic message and any 
attachments to this message are intended for the exclusive use of the 
addressee(s) and may contain proprietary, confidential or privileged 
information. If you are not the intended recipient, you should not 
disseminate, distribute or copy this e-mail. Please notify the sender 
immediately and destroy all copies of this message and any attachments.


WARNING: Computer viruses can be transmitted via email. The recipient 
should check this email and any attachments for the presence of 
viruses. The company accepts no liability for any damage caused by any 
virus transmitted by this email.


www.wipro.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] eclipse drools builder doesn't recognize functions ...?

2007-09-25 Thread Waruzjan Shahbazian
If you want to execute the test() methode of the Object() you are 
checking on on the LHS, you need to save the instance of it into a variable:


rule "test"
when
$o : Object()
then
$o.test();
end

greets,

Waruzjan

Manukyan, Sergey schreef:


Getting error reports by drools builder in 4.0.1 telling “The method 
test() is undefined” … is this a known bug?


**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain
legally privileged, confidential or proprietary
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of
this message to the intended recipient(s), you are
hereby notified that any dissemination, distribution
or copying of this E-mail message is strictly
prohibited. If you have received this message in
error, please immediately notify the sender and
delete this E-mail message from your computer.



___
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] eclipse drools builder doesn't recognize functions ...?

2007-09-25 Thread Waruzjan Shahbazian

ekke schreef:

manukyan,

I noticed a problem if the function has the same name as the package,
please rename your function and try again.

ekke
btw: please always open a new thread for a new topic

Manukyan, Sergey wrote:
  
 


Getting error reports by drools builder in 4.0.1 telling "The method
test() is undefined" ... is this a known bug?

 







  
You are right, I didn't noticed the function test() in the drl...sorry 
for the reply...

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


[rules-users] architectural question about saving the static data

2007-09-24 Thread Waruzjan Shahbazian
Hi,

I have a question regarding the way of saving the values of some static
data, wich will be used by the drools engine to calculate the price for some
product. I will explain it with the following example:

I have an website where the user can fill a form where he can choose between
different kind of tables, and other specifications regarding to the table.
Lets say we have 3 sort of tables in our store and the user can choose
between them:

1) 80x40
2) 100x60
3) 90x50

For each of these types we know, it's a static information wich will not be
calculated on basis of another value, what the price of it is and how long
it will take to produce it. So lets say that we have the following options:

Option1:
Type:80x40
Price:$40
Duration:5 hours

Option2:
Type:100x60
Price:$60
Duration:8 hours

Option3:
Type:90x50
Price:$50
Duration:7 hours

The question is, whats the best way to save the rest of the data ( so the
price and the duration, since the user can only chooses the type) into the
application, so it will be easy to extand the options in the future and it
will be easy to change it by the administrator?

I can think of 3 different ways:

1) Make 3 rules ( in drl ), each for every option and check in the LFS wich
option it's chosen and use the setter for the Price and Duration variabele
of the object Table.
2) Create in the java code 3 different instances of table which will have 3
different values for the variabeles, so instance1 will have Type="90x50",
Price="$50", Duration="7" and instance2 will have the values of option2 and
instance3 the values of option3. Then the java application can check what
the user has choosen and insert that into the working memory. So the .drl
file doesn't has set those variabeles of the object, so it can use them in
the rest of the rules.So it doesn't has to know anything about these values.
3) Make a spreadsheet with these 3 differen type tables which will represent
the rules of the value of the Price and Duration on basis of the chosen
Type. So if the application starts, it will compile the spreadsheet so it
can have the latest values for every type of table. So it can use that in
combination with the rest of the rules wich are defined in the .drl file.

These of course with a look in the future extanding of the options, so wich
will be the best practice way to implement. Also its important the the
administrator will be able to easaly change the values of these options.

 Will it be easier to add a rule, or will it be easier to add an instance of
the type table on basis of the chosen type in the java code.

If someone has a suggestion about another way of doing these, I will be
glade to hear too!

Thanks,

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