Re: [rules-users] Guvnor Integration with BPEL

2011-09-12 Thread Rabindra Kumar Srivastava
Hi,

 

I am using guvnor to create rules and access it through java code in my
application.

I have create pachage Mypackage and one rule Myrule inside the
package.

 

The code to access the rules is -

 

public SubnetDTO getValidSubnet(SubnetDTO dto) {

ClassLoader old =
Thread.currentThread().getContextClassLoader();

try {

  

  System.out.println(reading working business rules
--  );

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

  RuleAgent agent =
RuleAgent.newRuleAgent(/subnet.properties);

RuleBase ruleBase = agent.getRuleBase();



 

WorkingMemory workingMemory = ruleBase.newStatefulSession();

workingMemory.insert(dto);

 

workingMemory.fireAllRules();

 

for (Iterator i = workingMemory.iterateObjects();
i.hasNext();) 

{

System.out.println(getCanonicalName  
+i.next().getClass().getCanonicalName());

}



return dto;

} catch (Throwable t) {

  t.printStackTrace();

}

finally

{

  Thread.currentThread().setContextClassLoader(old);

}

return null;

  }

 

Subnet.properties contains url as - 

url=http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/Mypack
age/LATEST

 

Now I have created Myrule1 in the package Mypackage and tried to
access the both rule with the same url in the properties file.

But it is only validating the first rule only.

So let me know what changes I have to make to access both rules from the
package.

If any other approach is possible then suggest that also.

 

Thanks

 

 Rabindra Kumar Srivastava | ATT04 | Tech Mahindra
Hinjewadi, Pune 411 057, INDIA

( Office: +91 20 4225 | Mobile: +91 9892232699| Ext: 253918

Email: rs0090...@techmahindra.com

www.techmahindra.com http://www.techmahindra.com/ 

 


Disclaimer:
  This message and the information contained herein is proprietary and 
confidential and subject to the Tech Mahindra policy statement, you may review 
the policy at a 
href=http://www.techmahindra.com/Disclaimer.html;http://www.techmahindra.com/Disclaimer.html/a
 externally and a 
href=http://tim.techmahindra.com/Disclaimer.html;http://tim.techmahindra.com/Disclaimer.html/a
 internally within Tech 
Mahindra.
image001.png___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be resolved: Keeping running total

2011-09-12 Thread Swindells, Thomas
If you dump out the xml it converts the spreadsheet to you can see what the 
resulting DRL is.
Mantis is right in what the output is – if you don’t merge the condition column 
you’ll get a drl as below (If there exists a Condition (c1) such that its 
payment  $param(1) AND there exists a Condition (c2) such that its payment = 
$param(2).
If you merge the condition column the constraints apply to the same Condition 
object with the comma being the implicit and (if there exists a Condition c1 
such that its payment  $param(1) AND its payment = $param(2).

Thomas

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of john@oa
Sent: 09 September 2011 16:28
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be 
resolved: Keeping running total

Thanks Manstis

Actually I found that the issue was caused by me having incorrectly placed the 
RuleTable statement in the spreadsheet, I believe the CONDITION's in the 
columns are by default: AND joined.
On Fri, Sep 9, 2011 at 3:57 PM, manstis [via Drools] [hidden 
email]/user/SendEmail.jtp?type=nodenode=3323194i=0 wrote:
Does your Condition span the two columns with the payment $param? e.g.

| Condition  |
|-+--|
|payment  $param | payment = $param|
|-+--|

Otherwise you are creating rules that check the following:-

when
Condition(payment  )
then
...

when
Condition(payment  1000)
then
...

Whereas you really require:-

when
Condition(payment 0, payment = 1000)
then
...

etc
2011/9/9 john@oa [hidden 
email]http://user/SendEmail.jtp?type=nodenode=3323110i=0
Thanks Iaune

That is really helpful.  Yes, I need the ranges to be mutually exclusive, what 
is the easiest way to do that?  Feel a bit cheeky asking another question, but 
you seem to know what you are talking about! I have tried adding two conditions 
to enforce the range, but that doesn't seem to work - see below.  I still get 
multiple rules firing.  Also can you recommend any good resources for learning 
all of this, apart from the online documentation?  Would you know if any of the 
Drools books are any good?
payment  $param

payment = $param

Payment Greater Than

Payment Less Than or Equal To


0

0

1500

1500

2000

2000

3000

3000

4000







On Fri, Sep 9, 2011 at 2:22 PM, laune [via Drools] [hidden 
email]http://user/SendEmail.jtp?type=nodenode=3323074i=0 wrote:
The error you get is due to the second condition (application: Application()) 
not being included in the generated rules. Empty cell means: the column's 
snippet is not included in the rule.

Since you don't have a constraint for Application() you can employ a trick: 
remove the column and prefix the text application: Application() to the text in 
cell C7.

In Rule 1, do you really want to test whether a payment is not greater than 
zero?

Do you realize that Rules 2 and 3 would both fire for certain payment amounts?

You can update a String field. To concatenate, use
   x.setString( x.getString() + whatever );

-W
On 9 September 2011 14:08, john@oa [hidden 
email]http://user/SendEmail.jtp?type=nodenode=3322896i=0 wrote:
Guvnor: guvnor-5.2.0.Final-tomcat-6.0

Hi

I am a Drools Newbie and I have an integer field called score that I need to
add to when a rule matches in a spreadsheet decision table.  i.e. the score
field should hold a running total of all scores that are matched.  However,
I can't even update the field in the table.  I have attached the spreadsheet
for review.  In this spreadsheet I am simply trying to set the score, and
that is failing with:

DScoringTable] Rule Compilation error application cannot be resolved

My goal is to have different decision tables that will all need to update
the same score, and keep a running total of the total score.

Any help very much appreciated!  I hope that I am just missing something
obvious.
http://drools.46999.n3.nabble.com/file/n3322713/demo-score-sheet.xls
demo-score-sheet.xlshttp://drools.46999.n3.nabble.com/file/n3322713/demo-score-sheet.xls%0Ademo-score-sheet.xls

In future I may wish to also update a String field and keep concatenating to
that field, is this possible?

John


--
View this message in context: 
http://drools.46999.n3.nabble.com/Spreadsheet-Rule-Compilation-error-xxx-cannot-be-resolved-Keeping-running-total-tp3322713p3322713.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
[hidden email]http://user/SendEmail.jtp?type=nodenode=3322896i=1

https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
[hidden email]http://user/SendEmail.jtp?type=nodenode=3322896i=2
https://lists.jboss.org/mailman/listinfo/rules-users


If you reply to this email, your message will be added to the discussion 

Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be resolved: Keeping running total

2011-09-12 Thread Wolfgang Laun
2011/9/12 Swindells, Thomas tswinde...@nds.com

  If you dump out the xml


Why XML?
 import org.drools.decisiontable.SpreadsheetCompiler;

 private void testSpreadsheet(){
File dtf = new File( dtPath );
InputStream is;
try {
  is = new FileInputStream( dtf );
  SpreadsheetCompiler ssComp = new SpreadsheetCompiler();
  String s = ssComp.compile( is, InputType.XLS );
  System.out.println( === Begin generated DRL === );
  System.out.println( s );
  System.out.println( === End generated DRL === );
} catch (IOException e) {
  e.printStackTrace();
}
  }


it converts the spreadsheet to you can see what the resulting DRL is.

 Mantis is right in what the output is – if you don’t merge the condition
 column you’ll get a drl as below (If there exists a Condition (c1) such that
 its payment  $param(1) AND there exists a Condition (c2) such that its
 payment = $param(2).

 If you merge the condition column the constraints apply to the same
 Condition object with the comma being the implicit and (if there exists a
 Condition c1 such that its payment  $param(1) AND its payment = $param(2).


All correct, but the problem with this approach is the necessity of
providing identical values in two places - once as an upper limit and once
as a lower limit. By using the keyword Sequential true rules will be made
to fire from top to bottom. Adding a uniform constraint that guarantees that
the value-to-be-set hasn't been set yet (==null), a single constraint using
the value as an upper limit is sufficient.

-W



 ** **

 Thomas

 ** **

 *From:* rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] *On Behalf Of *john@oa
 *Sent:* 09 September 2011 16:28
 *To:* rules-users@lists.jboss.org
 *Subject:* Re: [rules-users] Spreadsheet: Rule Compilation error (xxx)
 cannot be resolved: Keeping running total

 ** **

 Thanks Manstis

 Actually I found that the issue was caused by me having incorrectly placed
 the RuleTable statement in the spreadsheet, I believe the CONDITION's in
 the columns are by default: AND joined.

 On Fri, Sep 9, 2011 at 3:57 PM, manstis [via Drools] [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323194i=0
 wrote:

 Does your Condition span the two columns with the payment $param? e.g.

 | Condition  |
 |-+--|
 |payment  $param | payment = $param|
 |-+--|

 Otherwise you are creating rules that check the following:-

 when
 Condition(payment  )
 then
 ...

 when
 Condition(payment  1000)
 then
 ...

 Whereas you really require:-

 when
 Condition(payment 0, payment = 1000)
 then
 ...

 etc

 2011/9/9 john@oa [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323110i=0
 

 Thanks Iaune

 That is really helpful.  Yes, I need the ranges to be mutually exclusive,
 what is the easiest way to do that?  Feel a bit cheeky asking another
 question, but you seem to know what you are talking about! I have tried
 adding two conditions to enforce the range, but that doesn't seem to work -
 see below.  I still get multiple rules firing.  Also can you recommend any
 good resources for learning all of this, apart from the online
 documentation?  Would you know if any of the Drools books are any good?***
 *

 payment  $param

 payment = $param

 Payment Greater Than

 Payment Less Than or Equal To

 0

 0

 1500

 1500

 2000

 2000

 3000

 3000

 4000

 ** **

 On Fri, Sep 9, 2011 at 2:22 PM, laune [via Drools] [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323074i=0
 wrote:

  The error you get is due to the second condition (application:
 Application()) not being included in the generated rules. Empty cell means:
 the column's snippet is not included in the rule.

 Since you don't have a constraint for Application() you can employ a trick:
 remove the column and prefix the text application: Application() to the text
 in cell C7.

 In Rule 1, do you really want to test whether a payment is not greater than
 zero?

 Do you realize that Rules 2 and 3 would both fire for certain payment
 amounts?

 You can update a String field. To concatenate, use
x.setString( x.getString() + whatever );

 -W

 On 9 September 2011 14:08, john@oa [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3322896i=0
 wrote:

  Guvnor: guvnor-5.2.0.Final-tomcat-6.0

 Hi

 I am a Drools Newbie and I have an integer field called score that I need
 to
 add to when a rule matches in a spreadsheet decision table.  i.e. the score
 field should hold a running total of all scores that are matched.  However,
 I can't even update the field in the table.  I have attached the
 spreadsheet
 for review.  In this spreadsheet I am simply trying to set the score, and
 that is failing with:

 DScoringTable] Rule Compilation error application cannot be resolved

 My goal is to 

Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be resolved: Keeping running total

2011-09-12 Thread john@oa
Ah Okay,

That kind of makes sense, although I can't seem to find any documentation on
how to merge the condition column, i.e. to have to parameters in one
column:  Tried this to no avail (using the , as the implicit AND)

 Payment  value  $param1, value = $param2  Payment In Range

 0, 1500  1500, 2000  2000, 3000  3000, 4000  4000, 5000  5000, 1  1,
15000  15000, 2  2

On Mon, Sep 12, 2011 at 8:21 AM, Swindells, Thomas [via Drools] 
ml-node+s46999n3328970...@n3.nabble.com wrote:

  If you dump out the xml it converts the spreadsheet to you can see what
 the resulting DRL is.

 Mantis is right in what the output is – if you don’t merge the condition
 column you’ll get a drl as below (If there exists a Condition (c1) such that
 its payment  $param(1) AND there exists a Condition (c2) such that its
 payment = $param(2).

 If you merge the condition column the constraints apply to the same
 Condition object with the comma being the implicit and (if there exists a
 Condition c1 such that its payment  $param(1) AND its payment = $param(2).
 

 ** **

 Thomas

 ** **

 *From:* [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3328970i=0[mailto:[hidden
 email] http://user/SendEmail.jtp?type=nodenode=3328970i=1] *On Behalf
 Of *john@oa
 *Sent:* 09 September 2011 16:28
 *To:* [hidden email]http://user/SendEmail.jtp?type=nodenode=3328970i=2
 *Subject:* Re: [rules-users] Spreadsheet: Rule Compilation error (xxx)
 cannot be resolved: Keeping running total

 ** **

 Thanks Manstis

 Actually I found that the issue was caused by me having incorrectly placed
 the RuleTable statement in the spreadsheet, I believe the CONDITION's in
 the columns are by default: AND joined.

 On Fri, Sep 9, 2011 at 3:57 PM, manstis [via Drools] [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323194i=0
 wrote:

 Does your Condition span the two columns with the payment $param? e.g.

 | Condition  |
 |-+--|
 |payment  $param | payment = $param|
 |-+--|

 Otherwise you are creating rules that check the following:-

 when
 Condition(payment  )
 then
 ...

 when
 Condition(payment  1000)
 then
 ...

 Whereas you really require:-

 when
 Condition(payment 0, payment = 1000)
 then
 ...

 etc

 2011/9/9 john@oa [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323110i=0
 

 Thanks Iaune

 That is really helpful.  Yes, I need the ranges to be mutually exclusive,
 what is the easiest way to do that?  Feel a bit cheeky asking another
 question, but you seem to know what you are talking about! I have tried
 adding two conditions to enforce the range, but that doesn't seem to work -
 see below.  I still get multiple rules firing.  Also can you recommend any
 good resources for learning all of this, apart from the online
 documentation?  Would you know if any of the Drools books are any good?***
 *

 payment  $param

 payment = $param

 Payment Greater Than

 Payment Less Than or Equal To

 0

 0

 1500

 1500

 2000

 2000

 3000

 3000

 4000

 ** **

 On Fri, Sep 9, 2011 at 2:22 PM, laune [via Drools] [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323074i=0
 wrote:

  The error you get is due to the second condition (application:
 Application()) not being included in the generated rules. Empty cell means:
 the column's snippet is not included in the rule.

 Since you don't have a constraint for Application() you can employ a trick:
 remove the column and prefix the text application: Application() to the text
 in cell C7.

 In Rule 1, do you really want to test whether a payment is not greater than
 zero?

 Do you realize that Rules 2 and 3 would both fire for certain payment
 amounts?

 You can update a String field. To concatenate, use
x.setString( x.getString() + whatever );

 -W

 On 9 September 2011 14:08, john@oa [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3322896i=0
 wrote:

  Guvnor: guvnor-5.2.0.Final-tomcat-6.0

 Hi

 I am a Drools Newbie and I have an integer field called score that I need
 to
 add to when a rule matches in a spreadsheet decision table.  i.e. the score
 field should hold a running total of all scores that are matched.  However,
 I can't even update the field in the table.  I have attached the
 spreadsheet
 for review.  In this spreadsheet I am simply trying to set the score, and
 that is failing with:

 DScoringTable] Rule Compilation error application cannot be resolved

 My goal is to have different decision tables that will all need to update
 the same score, and keep a running total of the total score.

 Any help very much appreciated!  I hope that I am just missing something
 obvious.
 http://drools.46999.n3.nabble.com/file/n3322713/demo-score-sheet.xls
 demo-score-sheet.xls

 In future I may wish to also update a String field and keep concatenating
 to
 that field, is 

Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be resolved: Keeping running total

2011-09-12 Thread Michael Anstis
@john,

Merging cells should be supported in your spreadsheet program of choice (I
know Microsoft Excel and Open\Libre Office derivatives provide it).

2011/9/12 Swindells, Thomas tswinde...@nds.com

  I’ve no idea why I said xml rather than drl – still too early in the
 morning.

 ** **

 It should be there in the documentation, you use $1 and $2 (etc). But in
 this case why do you want to it’s easier for people to insert the values
 into two separate columns.

 ** **

 You want something like the following

 ** **

 NAME

 CONDITION

 CONDITION

  

 f : Fact

  

 value  $param

 Value = $param

 Rule Name

 Payment More than

 Payment max

 rule

 1

 1500

 ** **

 This also has the benefit you can add catchall rules for the top and bottom
 by leaving the appropriate column empty  - eg payment = 0, or payment 
 2

 ** **

 Thomas

 ** **

 *From:* rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] *On Behalf Of *john@oa
 *Sent:* 12 September 2011 11:12

 *To:* rules-users@lists.jboss.org
 *Subject:* Re: [rules-users] Spreadsheet: Rule Compilation error (xxx)
 cannot be resolved: Keeping running total

  ** **

 Ah Okay,

 That kind of makes sense, although I can't seem to find any documentation
 on how to merge the condition column, i.e. to have to parameters in one
 column:  Tried this to no avail (using the , as the implicit AND)

 Payment

 value  $param1, value = $param2

 Payment In Range

 0, 1500

 1500, 2000

 2000, 3000

 3000, 4000

 4000, 5000

 5000, 1

 1, 15000

 15000, 2

 2

 ** **

 On Mon, Sep 12, 2011 at 8:21 AM, Swindells, Thomas [via Drools] [hidden
 email] http://user/SendEmail.jtp?type=nodenode=3329292i=0 wrote:

 If you dump out the xml it converts the spreadsheet to you can see what the
 resulting DRL is.

 Mantis is right in what the output is – if you don’t merge the condition
 column you’ll get a drl as below (If there exists a Condition (c1) such that
 its payment  $param(1) AND there exists a Condition (c2) such that its
 payment = $param(2).

 If you merge the condition column the constraints apply to the same
 Condition object with the comma being the implicit and (if there exists a
 Condition c1 such that its payment  $param(1) AND its payment = $param(2).
 

  

 Thomas

  

 *From:* [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3328970i=0[mailto:[hidden
 email] http://user/SendEmail.jtp?type=nodenode=3328970i=1] *On Behalf
 Of *john@oa
 *Sent:* 09 September 2011 16:28
 *To:* [hidden email]http://user/SendEmail.jtp?type=nodenode=3328970i=2
 *Subject:* Re: [rules-users] Spreadsheet: Rule Compilation error (xxx)
 cannot be resolved: Keeping running total

  

 Thanks Manstis

 Actually I found that the issue was caused by me having incorrectly placed
 the RuleTable statement in the spreadsheet, I believe the CONDITION's in
 the columns are by default: AND joined.

 On Fri, Sep 9, 2011 at 3:57 PM, manstis [via Drools] [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323194i=0
 wrote:

 Does your Condition span the two columns with the payment $param? e.g.

 | Condition  |
 |-+--|
 |payment  $param | payment = $param|
 |-+--|

 Otherwise you are creating rules that check the following:-

 when
 Condition(payment  )
 then
 ...

 when
 Condition(payment  1000)
 then
 ...

 Whereas you really require:-

 when
 Condition(payment 0, payment = 1000)
 then
 ...

 etc

 2011/9/9 john@oa [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323110i=0
 

 Thanks Iaune

 That is really helpful.  Yes, I need the ranges to be mutually exclusive,
 what is the easiest way to do that?  Feel a bit cheeky asking another
 question, but you seem to know what you are talking about! I have tried
 adding two conditions to enforce the range, but that doesn't seem to work -
 see below.  I still get multiple rules firing.  Also can you recommend any
 good resources for learning all of this, apart from the online
 documentation?  Would you know if any of the Drools books are any good?***
 *

 payment  $param

 payment = $param

 Payment Greater Than

 Payment Less Than or Equal To

 0

 0

 1500

 1500

 2000

 2000

 3000

 3000

 4000

  

 On Fri, Sep 9, 2011 at 2:22 PM, laune [via Drools] [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=3323074i=0
 wrote:

  The error you get is due to the second condition (application:
 Application()) not being included in the generated rules. Empty cell means:
 the column's snippet is not included in the rule.

 Since you don't have a constraint for Application() you can employ a trick:
 remove the column and prefix the text application: Application() to 

Re: [rules-users] Spreadsheet: Rule Compilation error (xxx) cannot be resolved: Keeping running total

2011-09-12 Thread Wolfgang Laun
2011/9/12 Swindells, Thomas tswinde...@nds.com
[snip]

  still too early in the morning.





 NAME

 CONDITION

 CONDITION



 f : Fact



 value  $param

 Value = $param

 Rule Name

 Payment More than

 Payment max

 rule

 1

 1500



 To handle payment == 1, put a '0' into the cell below Payment More than

Still, having to repeat 1500 in the next rule, etc., gives the impression
that the programmer dumps work onto the user. All right - as long it isn't
me ;-)
-W
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Exception cannot determine ruleInfo when trying to debug a rule

2011-09-12 Thread skasab2s
Hello,

I'm using Eclipse 3.6.2 (Helios) and the Eclipse Plugin JBoss Tools
3.2.1.Final Stable Release.

When I try to set a breakpoint within the rule concequence, I get the above
mentioned exception. The breakpoint appers, but it is disregarded when
debugging.

Here you can see the whole description and error behaviour:

http://drools.46999.n3.nabble.com/file/n3329759/debug_exception.png 

Do you know how to avoid this exception? Where can I set this ruleInfo
data ?

Many thanks for any idea / advice!

Svetlomir.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Exception-cannot-determine-ruleInfo-when-trying-to-debug-a-rule-tp3329759p3329759.html
Sent from the Drools: User forum 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] rules for promotional offers

2011-09-12 Thread Sandeep Bandela
wolfgang,
I didnt get it, so does that mean that all CE will be re-evaluated on every
change of workingmemory no matter which rule fired? even when executing RHS.
I didnt test it with copy of list yet. I will do it and see.

On Sun, Sep 11, 2011 at 11:28 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 The result of the collect CE is changed due to the modify. You have to
 copy the list and use the copy in the loop.
 -W

 2011/9/9 Sandeep Bandela gibsos...@gmail.com:
  Thanks wolfgang, for the info and that workaround.
  I think there is some off by one error in for loop, or may be some
 mistake
  that I didnt notice in my code. the following rule with 3 objects gives
  index out of bound error. I am attaching java  drl file (package
  com.example.drools.testing). I am using 5.2.0 final release.
 
  rule Buy X units of Product A and Get Y units of Product B Free
  when
  $itemsA : ArrayList( $a : size = 2 ) from collect( CartItem(
  productId == A, processed == false) )
  $itemsB : ArrayList( $b : size = 1 ) from collect( CartItem(
  productId == B, processed == false) )
  $m : RuleMessage()
   then
   $m.addMessage(sizes- A=+$a +  B=+$b);
   int $x = 2;
  int $y = 1;
  $m.addMessage(sizes- X=+$x +  Y=+$y);
  for(int i=0 ; i  $x ; i++){
   CartItem $ci = (CartItem) $itemsA.get(i);
   $m.addMessage( $ci.getId()+)Found item:
 +$ci.getProductId());
   modify((CartItem)$ci){
  setProcessed(true),
  setPromoItemDiscount(0D),
  setPromoId(2),
  setBundleId(bundler.getId()),
  setAggregatorId(1)
  };
   };
   for(int i=0 ; i  $y  ; i++){
   CartItem $ci = (CartItem) $itemsB.get(i);
   $m.addMessage( $ci.getId()+)Found item:
 +$ci.getProductId());
   modify((CartItem)$ci){
  setProcessed(true),
  setPromoItemDiscount($ci.getPrice()),
  setPromoId(2),
  setBundleId(bundler.getId()),
  setAggregatorId(2)
  };
   };
  bundler.increment();
  end
 
 
  error
  Exception in thread main org.drools.runtime.rule.ConsequenceException:
  rule: Buy X units of Product A and Get Y units of Product B Free
 
  at
 
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
  org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:916)
  at
 org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:845)
  at
 org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1056)
  at
 
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)
  at
 
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
  at
 
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
  at com.example.drools.testing.Main.main(Main.java:52)
  Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
  at java.util.ArrayList.RangeCheck(ArrayList.java:547)
  at java.util.ArrayList.get(ArrayList.java:322)
  at
 
 com.example.drools.testing.Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0.defaultConsequence(Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0.java:12)
  at
 
 com.example.drools.testing.Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0DefaultConsequenceInvoker.evaluate(Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0DefaultConsequenceInvoker.java:44)
  at
  org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:906)
  ... 6 more
 
 
  2011/9/9 Wolfgang Laun wolfgang.l...@gmail.com
 
  If the declared type of productId and getProductId() is String, it
 should
  be compared to a string literal. (A conversion might be made, but don't
 rely
  on that.)
 
  You cannot access components of a global in RHS code using the
 simplified
  notation (not unless you use mvel - but don't do that.) Here, all
 accesses
  should be written the usual Java way, with getter and setter calls.
 
  The problem you have with modify(ci) is a bug (fixed for 5.3.0). As a
  workaround,use
 
  modify( (CartItem)ci ){ ... }
 
  -W
 
 
  2011/9/9 Sandeep Bandela gibsos...@gmail.com
 
  some more info for the modify() problem, the CartItem is an interface
 and
  the implementation is CartItemImpl. if this info leads to some clues.
 
 
  On Fri, Sep 9, 2011 at 1:28 PM, Sandeep Bandela gibsos...@gmail.com
  wrote:
 
  Hi here is the same thing converted to mvl
 
  // this Bundler.java has integer member that keeps incrementing
  global Bundler bundler
 
  rule Apply 10% discount if you purchase 2 items
  when
  $s1 : CartItem( productId == 219759, processed == false)
  $s2 : CartItem( 

Re: [rules-users] rules for promotional offers

2011-09-12 Thread Wolfgang Laun
2011/9/12 Sandeep Bandela gibsos...@gmail.com

 wolfgang,
 I didnt get it, so does that mean that all CE will be re-evaluated on every
 change of workingmemory no matter which rule fired?


Not all CE, only the ones that are affected by the changed WME.


 even when executing RHS. I didnt test it with copy of list yet. I will do
 it and see.


By all means, do so.
-W



 On Sun, Sep 11, 2011 at 11:28 AM, Wolfgang Laun 
 wolfgang.l...@gmail.comwrote:

 The result of the collect CE is changed due to the modify. You have to
 copy the list and use the copy in the loop.
 -W

 2011/9/9 Sandeep Bandela gibsos...@gmail.com:
  Thanks wolfgang, for the info and that workaround.
  I think there is some off by one error in for loop, or may be some
 mistake
  that I didnt notice in my code. the following rule with 3 objects gives
  index out of bound error. I am attaching java  drl file (package
  com.example.drools.testing). I am using 5.2.0 final release.
 
  rule Buy X units of Product A and Get Y units of Product B Free
  when
  $itemsA : ArrayList( $a : size = 2 ) from collect( CartItem(
  productId == A, processed == false) )
  $itemsB : ArrayList( $b : size = 1 ) from collect( CartItem(
  productId == B, processed == false) )
  $m : RuleMessage()
   then
   $m.addMessage(sizes- A=+$a +  B=+$b);
   int $x = 2;
  int $y = 1;
  $m.addMessage(sizes- X=+$x +  Y=+$y);
  for(int i=0 ; i  $x ; i++){
   CartItem $ci = (CartItem) $itemsA.get(i);
   $m.addMessage( $ci.getId()+)Found item:
 +$ci.getProductId());
   modify((CartItem)$ci){
  setProcessed(true),
  setPromoItemDiscount(0D),
  setPromoId(2),
  setBundleId(bundler.getId()),
  setAggregatorId(1)
  };
   };
   for(int i=0 ; i  $y  ; i++){
   CartItem $ci = (CartItem) $itemsB.get(i);
   $m.addMessage( $ci.getId()+)Found item:
 +$ci.getProductId());
   modify((CartItem)$ci){
  setProcessed(true),
  setPromoItemDiscount($ci.getPrice()),
  setPromoId(2),
  setBundleId(bundler.getId()),
  setAggregatorId(2)
  };
   };
  bundler.increment();
  end
 
 
  error
  Exception in thread main org.drools.runtime.rule.ConsequenceException:
  rule: Buy X units of Product A and Get Y units of Product B Free
 
  at
 
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
  org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:916)
  at
 org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:845)
  at
 org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1056)
  at
 
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:733)
  at
 
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699)
  at
 
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
  at com.example.drools.testing.Main.main(Main.java:52)
  Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
  at java.util.ArrayList.RangeCheck(ArrayList.java:547)
  at java.util.ArrayList.get(ArrayList.java:322)
  at
 
 com.example.drools.testing.Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0.defaultConsequence(Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0.java:12)
  at
 
 com.example.drools.testing.Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0DefaultConsequenceInvoker.evaluate(Rule_Buy_X_units_of_Product_A_and_Get_Y_units_of_Product_B_Free_0DefaultConsequenceInvoker.java:44)
  at
  org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:906)
  ... 6 more
 
 
  2011/9/9 Wolfgang Laun wolfgang.l...@gmail.com
 
  If the declared type of productId and getProductId() is String, it
 should
  be compared to a string literal. (A conversion might be made, but don't
 rely
  on that.)
 
  You cannot access components of a global in RHS code using the
 simplified
  notation (not unless you use mvel - but don't do that.) Here, all
 accesses
  should be written the usual Java way, with getter and setter calls.
 
  The problem you have with modify(ci) is a bug (fixed for 5.3.0). As a
  workaround,use
 
  modify( (CartItem)ci ){ ... }
 
  -W
 
 
  2011/9/9 Sandeep Bandela gibsos...@gmail.com
 
  some more info for the modify() problem, the CartItem is an interface
 and
  the implementation is CartItemImpl. if this info leads to some clues.
 
 
  On Fri, Sep 9, 2011 at 1:28 PM, Sandeep Bandela gibsos...@gmail.com
  wrote:
 
  Hi here is the same thing converted to mvl
 
  // this Bundler.java has integer member that keeps incrementing
  global Bundler bundler
 
  rule 

Re: [rules-users] Exception cannot determine ruleInfo when trying to debug a rule

2011-09-12 Thread Mauricio Salatino
Can you share with us which version of drools are you using? the runtime and
the drools plugin.
CHeers

On Mon, Sep 12, 2011 at 11:29 AM, skasab2s skasa...@smail.inf.fh-brs.dewrote:

 Hello,

 I'm using Eclipse 3.6.2 (Helios) and the Eclipse Plugin JBoss Tools
 3.2.1.Final Stable Release.

 When I try to set a breakpoint within the rule concequence, I get the above
 mentioned exception. The breakpoint appers, but it is disregarded when
 debugging.

 Here you can see the whole description and error behaviour:

 http://drools.46999.n3.nabble.com/file/n3329759/debug_exception.png

 Do you know how to avoid this exception? Where can I set this ruleInfo
 data ?

 Many thanks for any idea / advice!

 Svetlomir.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Exception-cannot-determine-ruleInfo-when-trying-to-debug-a-rule-tp3329759p3329759.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
 - CTO @ http://www.plugtree.com
 - MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jugargentina.org
 - Co-Founder @ http://www.jbug.com.ar

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