[rules-users] Natural Language

2010-02-23 Thread Amit Kumar
Hi All,

As you might have understood with my so many questions :) I am looking at
the capabilities of Drools and our team is looking at a comparitive analysis
between Drools and ILOG
One of the feature which is greatly desired is natural language editor. So I
am planning to create my own DSL creator "Poor man's version" which will
introspect the class and generate some DSLs for our need.
An old Blog
http://blog.athico.com/2007/03/standards-based-approach-to-natural.html points
to an interesting article. Does anybody knows where this item is in the
roadmap.

Another suggestion I had was on the Roles and Permissions for the users.
There is a option in drools to permit access for a user to a package and
category. It would be good to add Status to the mix so that the novide user
is prevented from moving rules to production. Small change.. big gain :)

Does anybody has a pointer to a demo of drools showing its capabilities. Or
a comparitive analysis with ILOG.

We are able to show lot of good use for the tool.. but the data model we
have is causing us big headaches in writing easily understandable rules.
The scenario is that we have a "lot" of attributes of a fact. And as part of
model extension lot of attributes are constantly added to the fact.
To make this easier so that we do not have to update the model - we have put
a (key value pair) for the attributes.

So the model structure is

MainFact
   mainAttr1 String
   mainAttr2 String
   List additionalAttrs = new
ArrayList();

AdditionalAttributes
   attrName String
   attrValue String


So now in guided editor or DSl editor it becomes a nightmare to write a
rule.. and our rule writers will beat us up if we ask them to write a rule
like
aa: AdditionalAttributes (attrName == "var1", val : attrValue)
a: MainFact (mainAttr1 == "mainVal", additionalAttrs contains aa)

Any easy solution for this :)


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


Re: [rules-users] AGE problem

2010-02-23 Thread Pavel Tavoda
Try to do this in bank application. People come 1 hour after they date
expired and try to charge them for sooner withdrawal because you
calculate with 365.25 not 365 days. You will be kicked, believe me.

Pavel


2010/2/23 Wolfgang Laun :
> On Tue, Feb 23, 2010 at 8:07 AM, djb  wrote:
>>
>> I think though that the majority of uses for a rules engine is in a
>> business
>> context, where they don't use astronomical time.
>>
>> If the doctor's orders are:
>> "You cannot get out of bed for 2 months"
>>
>> This means 59 days if he told you February 1st, and it means 62 days if he
>> told you July 1st.
>>
>
> This is a particularly bad example, because doctors can't say that - at
> least not one I'd trust ;-)
>
> I'm arguing that you cannot expect a computer program to relieve you from
> the burden of defining what you mean by a "duration of one year" (or month).
> Some legal rules require a person to have a certain age, and it is (for
> humans)
> more convenient to decide this on a person's birthday YMD plus an increment
> in the Y number. If  your application requires you to use an increment in
> the year
> component of the YMDhms representation of a point in time, then you are
> indeed stuck with Calendar and the resulting overhead. (Memoizing
> the results of YMDhms +/- n years might speed things up, for the usual
> price.)
>
> But many applications would be satisfied with using a fixed duration for
> a year in terms of 365 or 365.25 or some such value. If, for instance, you
> have a  library, and you must decide to move a book into deep storage
> "if it has  not been requested for more than a year" you might calculate
> this (faster) by adding 356*24*60*60 to the clock value of the last return.
>
> -W
>
>> So at least for me, I am going to have to work out a plan that involves
>> GregorianCalendar.
>>
>> --
>> View this message in context:
>> http://n3.nabble.com/AGE-problem-tp215215p354847.html
>> Sent from the Drools - User mailing list archive at Nabble.com.
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>

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


Re: [rules-users] rules-users Digest, Vol 39, Issue 62

2010-02-23 Thread Nilima R
Hi,

Could you please explain the use of XML and word docs uploaded , some 
examples ,can I refer these files in the rules which I write in Guvnor .

Hi,

When you upload files to Guvnor XML and .properties files are stored 
under XML, properties and everything else for example Word files or PDF 
files go to Other assets, documentation.

Toni

Nilima R wrote:
>
> Can you please explain the use of "*XML,properties*" and "*Other 
> assets ,documentation*" links available in Guvnor.
>
>
>
> Thanks,


Nilima 



From:
rules-users-requ...@lists.jboss.org
To:
rules-users@lists.jboss.org
Date:
02/23/2010 02:11 PM
Subject:
rules-users Digest, Vol 39, Issue 62
Sent by:
rules-users-boun...@lists.jboss.org



Send rules-users mailing list submissions to
 rules-users@lists.jboss.org

To subscribe or unsubscribe via the World Wide Web, visit
 https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
 rules-users-requ...@lists.jboss.org

You can reach the person managing the list at
 rules-users-ow...@lists.jboss.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."


Today's Topics:

   1. Dynamicc Declarative model in Guvnor (Nilima R)
   2. Comparing Date with || OR operator (dhari)
   3. Drools Guvnor (Nilima R)
   4. Re: AGE problem (djb)
   5. Re: Drools Guvnor (Toni Rikkola)
   6. Re: AGE problem (Wolfgang Laun)
   7. Natural Language (Amit Kumar)
   8. Re: AGE problem (Pavel Tavoda)


--

Message: 1
Date: Tue, 23 Feb 2010 11:11:26 +0530
From: Nilima R 
Subject: [rules-users] Dynamicc Declarative model in Guvnor
To: rules-users@lists.jboss.org
Message-ID:
 
Content-Type: text/plain; charset="us-ascii"

Hi All,


Can we have a dynamic declarative model build in Drools Guvnor. 
For example if I have certain tables in database say employee, company, 
address ,can we have a drop down for these tables so that end user can 
select any one one and  based on that selection model in Guvnor is 
created.
At present we specify the names of the model say employee and then add 
fields into it. say employee ID etc.



Many Thanks,

Nilima 

=-=-=
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


-- next part --
An HTML attachment was scrubbed...
URL: 
http://lists.jboss.org/pipermail/rules-users/attachments/20100223/ffe4d373/attachment-0001.html
 


--

Message: 2
Date: Mon, 22 Feb 2010 22:15:08 -0800 (PST)
From: dhari 
Subject: [rules-users] Comparing Date with || OR operator
To: rules-users@lists.jboss.org
Message-ID: <1266905708400-347656.p...@n3.nabble.com>
Content-Type: text/plain; charset="utf-8"


The following code generates NPE in ReteTuple.java 

rule 
 when
  Membership ( $regDate : regDate)
  Segment ( startDate < $regDate || startDate > endDate )
then
  System.err.print(?Invalid start date?);
end


I am new in Drools and don?t know much about DRL scripting. It works fine 
I
use && operator instead.
-- 
View this message in context: 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p347656.html
Sent from the Drools - User mailing list archive at Nabble.com.
-- next part --
An HTML attachment was scrubbed...
URL: 
http://lists.jboss.org/pipermail/rules-users/attachments/20100222/dc6db21e/attachment-0001.html
 


--

Message: 3
Date: Tue, 23 Feb 2010 11:48:19 +0530
From: Nilima R 
Subject: [rules-users] Drools Guvnor
To: rules-users@lists.jboss.org
Message-ID:
 
Content-Type: text/plain; charset="us-ascii"

Can you please explain the use of "XML,properties" and "Other assets 
,documentation" links available in Guvnor.



Thanks,
Nilima 
=-=-=
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have recei

Re: [rules-users] Process with subprocesses don't continue after finish work items in the subprocesses

2010-02-23 Thread Dirk

Hey Kris,

I run the test and had some problems:

1. First I had empty workitems. I fix it by adding this line after creating
and loading the session:
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
handler);
But how could the test passed in your environment without this lines? 

2. To use it I had to rearrage the order of the variable-definition.
3. The test fails at the last line: 
assertNull( processInstance );
Is this a problem? I'm not sure...

Now I try to downsize my own prozess for this test...
-- 
View this message in context: 
http://n3.nabble.com/Process-with-subprocesses-don-t-continue-after-finish-work-items-in-the-subprocesses-tp326801p378414.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread Swindells, Thomas
If it works fine with an and operator then I’d imagine that startDate < 
$regDate returns false, with an && this would abort evaluation immediately but 
with an or it would mean that startDate > endDate is evaluated and so 
presumably it is this bit that is throwing the NPE.  I’d imagine that the most 
likely reason for this would be that endDate is null.

Try changing it too

Segment ( startDate < $regDate || (endDate != null && startDate > endDate) )
And see whether you loose the NPE.

Thomas

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of dhari
Sent: 23 February 2010 06:15
To: rules-users@lists.jboss.org
Subject: [rules-users] Comparing Date with || OR operator

The following code generates NPE in ReteTuple.java

rule

   when

  Membership ( $regDate : regDate)

  Segment ( startDate < $regDate || startDate > endDate )

then

System.err.print(“Invalid start date”);

end
I am new in Drools and don’t know much about DRL scripting. It works fine I use 
&& operator instead.

View this message in context: Comparing Date with || OR 
operator
Sent from the Drools - User mailing list 
archive at Nabble.com.



**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**


This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.

An NDS Group Limited company. www.nds.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread dhari


Hi Thomas

 

Thanks your prompt reply. I am sure all three attributes are NOT null. I have 
tested them before sending question to mailing list. If you want, I can send 
complete sample code and you can try it at your end.

 

Regards,

Dhari


 


Date: Tue, 23 Feb 2010 02:50:08 -0800
From: ml-node+379447-1511987735-80...@n3.nabble.com
To: sdh...@hotmail.com
Subject: Re: Comparing Date with || OR operator





If it works fine with an and operator then I’d imagine that startDate < 
$regDate returns false, with an && this would abort evaluation immediately but 
with an or it would mean that startDate > endDate is evaluated and so 
presumably it is this bit that is throwing the NPE.  I’d imagine that the most 
likely reason for this would be that endDate is null.
 
Try changing it too Segment ( startDate < $regDate || (endDate != null && 
startDate > endDate) )
And see whether you loose the NPE.
 
Thomas
 



From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
Sent: 23 February 2010 06:15
To: [hidden email]
Subject: [rules-users] Comparing Date with || OR operator
 
The following code generates NPE in ReteTuple.java rulewhen 
 Membership ( $regDate : regDate)  Segment ( startDate < $regDate 
|| startDate > endDate )thenSystem.err.print(“Invalid start 
date”);end
I am new in Drools and don’t know much about DRL scripting. It works fine I use 
&& operator instead. 



View this message in context: Comparing Date with || OR operator
Sent from the Drools - User mailing list archive at Nabble.com.



**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the [hidden email] 
and delete it from your system as well as any copies. The content of e-mails as 
well as traffic data may be monitored by NDS for employment and security 
purposes. To protect the environment please do not print this e-mail unless 
necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**



This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the [hidden email] 
and delete it from your system as well as any copies. The content of e-mails as 
well as traffic data may be monitored by NDS for employment and security 
purposes.
To protect the environment please do not print this e-mail unless necessary.

An NDS Group Limited company. www.nds.com

___ 
rules-users mailing list 
[hidden email] 
https://lists.jboss.org/mailman/listinfo/rules-users





View message @ 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html 
To unsubscribe from Drools - Java Rules Engine, click here. 
  
_
Looking for a place to rent, share or buy? Find your next place with ninemsn 
Property
http://clk.atdmt.com/NMN/go/157631292/direct/01/
-- 
View this message in context: 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p383423.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread Swindells, Thomas
Have you got the stack trace, that may give a clue? Also what are the actual 
values of start date and end date?

Thomas


From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of dhari
Sent: 23 February 2010 11:30
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Comparing Date with || OR operator

Hi Thomas

Thanks your prompt reply. I am sure all three attributes are NOT null. I have 
tested them before sending question to mailing list. If you want, I can send 
complete sample code and you can try it at your end.

Regards,
Dhari



Date: Tue, 23 Feb 2010 02:50:08 -0800
From: [hidden 
email]
To: [hidden 
email]
Subject: Re: Comparing Date with || OR operator

If it works fine with an and operator then I’d imagine that startDate < 
$regDate returns false, with an && this would abort evaluation immediately but 
with an or it would mean that startDate > endDate is evaluated and so 
presumably it is this bit that is throwing the NPE.  I’d imagine that the most 
likely reason for this would be that endDate is null.



Try changing it too

Segment ( startDate < $regDate || (endDate != null && startDate > endDate) )

And see whether you loose the NPE.



Thomas



From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
Sent: 23 February 2010 06:15
To: [hidden email]
Subject: [rules-users] Comparing Date with || OR operator



The following code generates NPE in ReteTuple.java

rule

   when

  Membership ( $regDate : regDate)

  Segment ( startDate < $regDate || startDate > endDate )

then

System.err.print(“Invalid start date”);

end

I am new in Drools and don’t know much about DRL scripting. It works fine I use 
&& operator instead.



View this message in context: Comparing Date with || OR operator
Sent from the Drools - User mailing list archive at Nabble.com.



**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the [hidden email] 
and delete it from your system as well as any copies. The content of e-mails as 
well as traffic data may be monitored by NDS for employment and security 
purposes. To protect the environment please do not print this e-mail unless 
necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**

This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the [hidden email] 
and delete it from your system as well as any copies. The content of e-mails as 
well as traffic data may be monitored by NDS for employment and security 
purposes.
To protect the environment please do not print this e-mail unless necessary.

An NDS Group Limited company. www.nds.com

___
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


View message @ 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html
To unsubscribe from Drools - Java Rules Engine, click here.


Find your next place with Ninemsn property Looking for a place to rent, share 
or buy?

View this message in context: RE: Comparing Date with || OR 
operator
Sent from the Drools - User mailing list 
archive at Nabble.com.



**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**


Th

Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread Wolfgang Laun
Please try this rewrite of the 2nd CE:
   Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate )
and report the outcome to the list, together with the Dools version
you are using.
Thank you.


2010/2/23 dhari :
> Hi Thomas
>
> Thanks your prompt reply. I am sure all three attributes are NOT null. I
> have tested them before sending question to mailing list. If you want, I can
> send complete sample code and you can try it at your end.
>
> Regards,
> Dhari
>
>
> 
> Date: Tue, 23 Feb 2010 02:50:08 -0800
> From: [hidden email]
> To: [hidden email]
> Subject: Re: Comparing Date with || OR operator
>
> If it works fine with an and operator then I’d imagine that startDate <
> $regDate returns false, with an && this would abort evaluation immediately
> but with an or it would mean that startDate > endDate is evaluated and so
> presumably it is this bit that is throwing the NPE.  I’d imagine that the
> most likely reason for this would be that endDate is null.
>
>
>
> Try changing it too
>
> Segment ( startDate < $regDate || (endDate != null && startDate > endDate) )
>
> And see whether you loose the NPE.
>
>
>
> Thomas
>
>
>
> From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
> Sent: 23 February 2010 06:15
> To: [hidden email]
> Subject: [rules-users] Comparing Date with || OR operator
>
>
>
> The following code generates NPE in ReteTuple.java
>
> rule
>
>    when
>
>   Membership ( $regDate : regDate)
>
>   Segment ( startDate < $regDate || startDate > endDate )
>
>     then
>
>     System.err.print(“Invalid start date”);
>
> end
>
> I am new in Drools and don’t know much about DRL scripting. It works fine I
> use && operator instead.
>
> 
>
> View this message in context: Comparing Date with || OR operator
> Sent from the Drools - User mailing list archive at Nabble.com.
>
> 
> **
> This message is confidential and intended only for the addressee. If you
> have received this message in error, please immediately notify the [hidden
> email] and delete it from your system as well as any copies. The content of
> e-mails as well as traffic data may be monitored by NDS for employment and
> security purposes. To protect the environment please do not print this
> e-mail unless necessary.
>
> NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
> 4EX, United Kingdom. A company registered in England and Wales. Registered
> no. 3080780. VAT no. GB 603 8808 40-00
> **
>
> 
> This message is confidential and intended only for the addressee. If you
> have received this message in error, please immediately notify the [hidden
> email] and delete it from your system as well as any copies. The content of
> e-mails as well as traffic data may be monitored by NDS for employment and
> security purposes.
> To protect the environment please do not print this e-mail unless necessary.
>
> An NDS Group Limited company. www.nds.com
>
> ___
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> 
> View message @
> http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html
> To unsubscribe from Drools - Java Rules Engine, click here.
>
> 
> Find your next place with Ninemsn property Looking for a place to rent,
> share or buy?
> 
> View this message in context: RE: Comparing Date with || OR operator
> 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] Using Collections in LHS

2010-02-23 Thread dhari

In this scenario I do have typical Order and Items data structure. I want to
implement various business rules where I want to check both Order attributes
and Item attributes together.

Order [ Date, Discount, Amount, Customer, Type, Items]
Item [ Quantity, Rate, ExpiresDate, Grade ]

I am trying to implements following rules but all gives me syntax error. I
wondering if someone can help me in.


rule “one”
when
Order  ( $discount : Discount, $items : Items)
Item ($discount > 10 && Grade > 3) from $items
then
System.err.print(“Discount is not allowed with items having grade 3 or
higher)
end

rule “two”
when
Order  ( $discount : Discount, $items : Items)
Item ($discount  > 20 || Quantity < 5 ) from $items
then
//do some thinge
end
-- 
View this message in context: 
http://n3.nabble.com/Using-Collections-in-LHS-tp386923p386923.html
Sent from the Drools - User mailing list archive at Nabble.com.

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


Re: [rules-users] Using Collections in LHS

2010-02-23 Thread Wolfgang Laun
Discount is a field of Order and must not appear in an Item(...).
Probably you want:
   Order  ( $discount : Discount > 10,...

Also, most likely, all your fields need to be written with a lower case
initial letter,
   Order  ( $discount : discount > 10, $items : items)

-W

On Tue, Feb 23, 2010 at 1:11 PM, dhari  wrote:

>
> In this scenario I do have typical Order and Items data structure. I want
> to
> implement various business rules where I want to check both Order
> attributes
> and Item attributes together.
>
> Order [ Date, Discount, Amount, Customer, Type, Items]
> Item [ Quantity, Rate, ExpiresDate, Grade ]
>
> I am trying to implements following rules but all gives me syntax error. I
> wondering if someone can help me in.
>
>
> rule “one”
>when
>Order  ( $discount : Discount, $items : Items)
>Item ($discount > 10 && Grade > 3) from $items
>then
>System.err.print(“Discount is not allowed with items having grade 3
> or
> higher)
> end
>
> rule “two”
>when
>Order  ( $discount : Discount, $items : Items)
>Item ($discount  > 20 || Quantity < 5 ) from $items
>then
>//do some thinge
> end
> --
> View this message in context:
> http://n3.nabble.com/Using-Collections-in-LHS-tp386923p386923.html
> Sent from the Drools - User mailing list archive at Nabble.com.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] AGE problem

2010-02-23 Thread Jason Smith
Hey, I haven't been following this thread, but you can use Joda Time to get 
much better, easier results.  For instance, you can add 1 month to a DateTime 
by using a new Period("P1M") [that is, a period of 1 month] - all done 
according to ISO8601 standards, so it works flawlessly, including adjustments 
for things like daylight savings time (so you don't have to think about it 
much).

In business, we live and die by precise time calculations.  Think of it as 
being like a check writing program that "estimates" a salary, and then pays the 
employee that amount.  Get your torches and pitchforks!

Jason Smith

From: rules-users-boun...@lists.jboss.org [rules-users-boun...@lists.jboss.org] 
On Behalf Of Pavel Tavoda [pavel.tav...@gmail.com]
Sent: Tuesday, February 23, 2010 1:30 AM
To: Rules Users List
Subject: Re: [rules-users] AGE problem

Try to do this in bank application. People come 1 hour after they date
expired and try to charge them for sooner withdrawal because you
calculate with 365.25 not 365 days. You will be kicked, believe me.

Pavel


2010/2/23 Wolfgang Laun :
> On Tue, Feb 23, 2010 at 8:07 AM, djb  wrote:
>>
>> I think though that the majority of uses for a rules engine is in a
>> business
>> context, where they don't use astronomical time.
>>
>> If the doctor's orders are:
>> "You cannot get out of bed for 2 months"
>>
>> This means 59 days if he told you February 1st, and it means 62 days if he
>> told you July 1st.
>>
>
> This is a particularly bad example, because doctors can't say that - at
> least not one I'd trust ;-)
>
> I'm arguing that you cannot expect a computer program to relieve you from
> the burden of defining what you mean by a "duration of one year" (or month).
> Some legal rules require a person to have a certain age, and it is (for
> humans)
> more convenient to decide this on a person's birthday YMD plus an increment
> in the Y number. If  your application requires you to use an increment in
> the year
> component of the YMDhms representation of a point in time, then you are
> indeed stuck with Calendar and the resulting overhead. (Memoizing
> the results of YMDhms +/- n years might speed things up, for the usual
> price.)
>
> But many applications would be satisfied with using a fixed duration for
> a year in terms of 365 or 365.25 or some such value. If, for instance, you
> have a  library, and you must decide to move a book into deep storage
> "if it has  not been requested for more than a year" you might calculate
> this (faster) by adding 356*24*60*60 to the clock value of the last return.
>
> -W
>
>> So at least for me, I am going to have to work out a plan that involves
>> GregorianCalendar.
>>
>> --
>> View this message in context:
>> http://n3.nabble.com/AGE-problem-tp215215p354847.html
>> Sent from the Drools - User mailing list archive at Nabble.com.
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>

___
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] Starting a Drool Flow from Another Application

2010-02-23 Thread ramram

Hi All,

   I have the following issue that the Drools Flow and the GWT console are
delpoyed on a JBOSS server and I have my own application running on a Tomcat
server. Is there a way so that I can run a Drool Flow process from my
application that is running on another application server than that
containing the Drool Flow engine. I was thinking of a webservice call. is
there another way?? thanks for the help.


Regards,
Ram
-- 
View this message in context: 
http://n3.nabble.com/Starting-a-Drool-Flow-from-Another-Application-tp401224p401224.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Process with subprocesses don't continue after finish work items in the subprocesses

2010-02-23 Thread Dirk

Hey Kris,

I created a little demo-process with two subprocesses which covers my
problem. The flow should be Start - Super - Sub1 - Sub2 - Sub1 - Super -
End. But at runtime it is only Start - Super - Sub1 - End.
I think the test case is self-explanatory.

Thank you for your efforts!

Regards
Dirk http://n3.nabble.com/file/n404348/testcaseSubprocesses.zip
testcaseSubprocesses.zip 
-- 
View this message in context: 
http://n3.nabble.com/Process-with-subprocesses-don-t-continue-after-finish-work-items-in-the-subprocesses-tp326801p404348.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] AGE problem

2010-02-23 Thread Greg Barton
I was about to suggest this. :)  And one advantage of using joda time is that 
version 1.6 is already included as a dependency of drools.

--- On Tue, 2/23/10, Jason Smith  wrote:

> From: Jason Smith 
> Subject: Re: [rules-users] AGE problem
> To: "Rules Users List" 
> Date: Tuesday, February 23, 2010, 7:45 AM
> Hey, I haven't been following this
> thread, but you can use Joda Time to get much better, easier
> results.  For instance, you can add 1 month to a
> DateTime by using a new Period("P1M") [that is, a period of
> 1 month] - all done according to ISO8601 standards, so it
> works flawlessly, including adjustments for things like
> daylight savings time (so you don't have to think about it
> much).
> 
> In business, we live and die by precise time
> calculations.  Think of it as being like a check
> writing program that "estimates" a salary, and then pays the
> employee that amount.  Get your torches and
> pitchforks!
> 
> Jason Smith
> 
> From: rules-users-boun...@lists.jboss.org
> [rules-users-boun...@lists.jboss.org]
> On Behalf Of Pavel Tavoda [pavel.tav...@gmail.com]
> Sent: Tuesday, February 23, 2010 1:30 AM
> To: Rules Users List
> Subject: Re: [rules-users] AGE problem
> 
> Try to do this in bank application. People come 1 hour
> after they date
> expired and try to charge them for sooner withdrawal
> because you
> calculate with 365.25 not 365 days. You will be kicked,
> believe me.
> 
> Pavel
> 
> 
> 2010/2/23 Wolfgang Laun :
> > On Tue, Feb 23, 2010 at 8:07 AM, djb 
> wrote:
> >>
> >> I think though that the majority of uses for a
> rules engine is in a
> >> business
> >> context, where they don't use astronomical time.
> >>
> >> If the doctor's orders are:
> >> "You cannot get out of bed for 2 months"
> >>
> >> This means 59 days if he told you February 1st,
> and it means 62 days if he
> >> told you July 1st.
> >>
> >
> > This is a particularly bad example, because doctors
> can't say that - at
> > least not one I'd trust ;-)
> >
> > I'm arguing that you cannot expect a computer program
> to relieve you from
> > the burden of defining what you mean by a "duration of
> one year" (or month).
> > Some legal rules require a person to have a certain
> age, and it is (for
> > humans)
> > more convenient to decide this on a person's birthday
> YMD plus an increment
> > in the Y number. If  your application requires
> you to use an increment in
> > the year
> > component of the YMDhms representation of a point in
> time, then you are
> > indeed stuck with Calendar and the resulting overhead.
> (Memoizing
> > the results of YMDhms +/- n years might speed things
> up, for the usual
> > price.)
> >
> > But many applications would be satisfied with using a
> fixed duration for
> > a year in terms of 365 or 365.25 or some such value.
> If, for instance, you
> > have a  library, and you must decide to move a
> book into deep storage
> > "if it has  not been requested for more than a
> year" you might calculate
> > this (faster) by adding 356*24*60*60 to the clock
> value of the last return.
> >
> > -W
> >
> >> So at least for me, I am going to have to work out
> a plan that involves
> >> GregorianCalendar.
> >>
> >> --
> >> View this message in context:
> >> http://n3.nabble.com/AGE-problem-tp215215p354847.html
> >> Sent from the Drools - User mailing list archive
> at Nabble.com.
> >> ___
> >> rules-users mailing list
> >> rules-users@lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
> 
> ___
> 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] memberOf mvel list

2010-02-23 Thread Swindells, Thomas
Am I being blind or are "in" and "not in" not actually documented in the drools 
expert user guide? In particular the fact that the syntax for the list is to 
put it in round brackets (1,2,3) and not the square brackets [1,2,3] which you 
would expect from the mvel documentation.

Also why can't memberOf work off an inline mvel list anyway?

Thomas

> -Original Message-
> From: rules-users-boun...@lists.jboss.org [mailto:rules-users-
> boun...@lists.jboss.org] On Behalf Of Ansgar Konermann
> Sent: 21 February 2010 22:37
> To: Rules Users List
> Subject: Re: [rules-users] memberOf mvel list
>
> Hi Adam,
>
> try operator "in" instead of "memberOf". AFAIK, "in" deals with list
> literals (which is what you want) whereas "memberof" can be used to
> check whether some value is part of a collection given as variable
> reference.
>
> Kind regards
>
> Ansgar
>
> Am 21.02.2010 23:14, schrieb deaddowney:
> > I'm using a map because this is a legacy class that is quite dynamic and can
> > contain arbitrary tag/values.  Ideally, if I knew all the attributes I would
> > declare them as fields, but I'm stuck with this map at the moment.
> > Regardless, using your explanation, why does
> >
> > when
> > $person : Person(
> > props[“AGE”]>  20,
> > (props[“NAME”] =="Fred" || props["NAME"]
> > == "Barney || props["NAME"] == "Wilma"])
> > )
> >
> > work?
> >
> >
> > Corneil du Plessis-2 wrote:
> >
> >> You are expecting map values to be elevated somehow from Object to Integer
> >> and String.
> >> By using typed attributes in the Person class you can overcome your
> >> problem.
> >>
> >> Sent from my HTC (Android)
> >>
> >> On Feb 21, 2010 9:28 PM, "Adam Krieg"  wrote:
> >>
> >> I’m new to Drools and having trouble accessing my Domain object which is
> >> basically a container around a map.
> >>
> >> class Person {
> >> Map props;
> >> public Map getProps();
> >> …. Extra stuff
> >> }
> >>
> >>
> >> I want to create a rule that will match when Age is greater than 20 and
> >> name
> >> is one of “Fred”, “Barney”, or “Wilma”.  These  entries are stored in the
> >> Map props, so that to get age, you would call person.getProps().get(“AGE”)
> >>
> >>
> >>
> >> rule "My Rule"
> >> dialect "mvel"
> >> when
> >> $person : Person(
> >> props[“AGE”]>  20,
> >> props[“NAME”] memberOf [“Fred”,
> >> “Wilma”,
> >> “Barney”]
> >> )
> >> then
> >> System.out.println("found match”+$person);
> >>
> >> End
> >>
> >> But I am running into a parsing error:
> >> no viable alternative at input ')' in rule "My Rule" in pattern Person.
> >>
> >> The second condition seems to be the problem.  Can I check for membership
> >> inside a List I create inline in mvel?
> >>
> >>
> >> ___
> >> 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


**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**

This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.

An NDS Group Limited company. www.nds.com

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


[rules-users] Deploying a package to Guvnor

2010-02-23 Thread spamcontrol
Is there a way to import a package file (as built by ant) into Guvnor?  I can 
see how to import rules and jars, but I'd like to upload a complete package 
(POJO's + rules) in a single step to Guvnor.  Is this currently possible?
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Using Collections in LHS

2010-02-23 Thread Shabbir Dhari



Hi W



I know about case sensitivity issue. How can I combine both Order and Item in
one condition. I tried all possibilities but getting syntax error.



For example: 
Order ($items : items, $discount : discount > 10, Item(grade > 3)
from $items) // gives error


Can please code this condition correctly for me?

Dhari



Date: Tue, 23 Feb 2010 13:43:01 +0100
From: wolfgang.l...@gmail.com
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Using Collections in LHS

Discount is a field of Order and must not appear in an Item(...).
Probably you want:
   Order  ( $discount : Discount > 10,...

Also, most likely, all your fields need to be written with a lower case initial 
letter,

   Order  ( $discount : discount > 10, $items : items)

-W

On Tue, Feb 23, 2010 at 1:11 PM, dhari  wrote:



In this scenario I do have typical Order and Items data structure. I want to

implement various business rules where I want to check both Order attributes

and Item attributes together.



Order [ Date, Discount, Amount, Customer, Type, Items]

Item [ Quantity, Rate, ExpiresDate, Grade ]



I am trying to implements following rules but all gives me syntax error. I

wondering if someone can help me in.





rule “one”

when

Order  ( $discount : Discount, $items : Items)

Item ($discount > 10 && Grade > 3) from $items

then

System.err.print(“Discount is not allowed with items having grade 3 or

higher)

end



rule “two”

when

Order  ( $discount : Discount, $items : Items)

Item ($discount  > 20 || Quantity < 5 ) from $items

then

//do some thinge

end

--

View this message in context: 
http://n3.nabble.com/Using-Collections-in-LHS-tp386923p386923.html

Sent from the Drools - User mailing list archive at Nabble.com.



___

rules-users mailing list

rules-users@lists.jboss.org

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


  
_
Link all your email accounts and social updates with Hotmail. Find out now
http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread Shabbir Dhari

Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate ) 
even does not work. I am using verstion 5.0.1. All dates are java.util.Date and 
values in sample fact are:

regDate = Fri Aug 01 00:00:00 BST 2008
startDate =  Tue Sep 01 00:00:00 BST 2009
endDate = Fri Jul 30 00:00:00 BST 2010

Stack trace: 

java.lang.NullPointerException
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265)
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
at 
org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320)
at 
org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305)
at 
org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78)
at 
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at 
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192)
at 
au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57)


> Date: Tue, 23 Feb 2010 12:54:46 +0100
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
> Subject: Re: [rules-users] Comparing Date with || OR operator
> 
> Please try this rewrite of the 2nd CE:
>Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate 
> )
> and report the outcome to the list, together with the Dools version
> you are using.
> Thank you.
> 
> 
> 2010/2/23 dhari :
> > Hi Thomas
> >
> > Thanks your prompt reply. I am sure all three attributes are NOT null. I
> > have tested them before sending question to mailing list. If you want, I can
> > send complete sample code and you can try it at your end.
> >
> > Regards,
> > Dhari
> >
> >
> > 
> > Date: Tue, 23 Feb 2010 02:50:08 -0800
> > From: [hidden email]
> > To: [hidden email]
> > Subject: Re: Comparing Date with || OR operator
> >
> > If it works fine with an and operator then I’d imagine that startDate <
> > $regDate returns false, with an && this would abort evaluation immediately
> > but with an or it would mean that startDate > endDate is evaluated and so
> > presumably it is this bit that is throwing the NPE.  I’d imagine that the
> > most likely reason for this would be that endDate is null.
> >
> >
> >
> > Try changing it too
> >
> > Segment ( startDate < $regDate || (endDate != null && startDate > endDate) )
> >
> > And see whether you loose the NPE.
> >
> >
> >
> > Thomas
> >
> >
> >
> > From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
> > Sent: 23 February 2010 06:15
> > To: [hidden email]
> > Subject: [rules-users] Comparing Date with || OR operator
> >
> >
> >
> > The following code generates NPE in ReteTuple.java
> >
> > rule
> >
> >when
> >
> >   Membership ( $regDate : regDate)
> >
> >   Segment ( startDate < $regDate || startDate > endDate )
> >
> > then
> >
> > System.err.print(“Invalid start date”);
> >
> > end
> >
> > I am new in Drools and don’t know much about DRL scripting. It works fine I
> > use && operator instead.
> >
> > 
> >
> > View this message in context: Comparing Date with || OR operator
> > Sent from the Drools - User mailing list archive at Nabble.com.
> >
> > 
> > **
> > This message is confidential and intended only for the addressee. If you
> > have received this message in error, please immediately notify the [hidden
> > email] and delete it from your system as well as any copies. The content of
> > e-mails as well as traffic data may be monitored by NDS for employment and
> > security purposes. To protect the environment please do not print this
> > e-mail unless necessary.
> >
> > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
> > 4EX, United Kingdom. A company registered in England and Wales. Registered
> > no. 3080780. VAT no. GB 603 8808 40-00
> > **

Re: [rules-users] Using Collections in LHS

2010-02-23 Thread Jeffrey Schneller
I think what you are looking for is the following.  Someone please
correct me if I am incorrect.

 

when

Order($discount : discount > 10, $items: items)

Item(grade > 3) from $items

then

System.err.print("Discount is not allowed with items having grade 3 or
higher");

 

 

This would fire when an Order has a discount greater than 10 and an
item with a grade greater than 3.

Not sure why you even need the $discount variable.  You could just do
Order(discount > 10, $items : items) for the first line of the when
clause.

 

 

From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Shabbir Dhari
Sent: Tuesday, February 23, 2010 5:27 PM
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Using Collections in LHS

 

Hi W

I know about case sensitivity issue. How can I combine both Order and
Item in one condition. I tried all possibilities but getting syntax
error.

For example: 

Order ($items : items, $discount : discount > 10, Item(grade > 3) from
$items) // gives error

 

Can please code this condition correctly for me?

 

Dhari

 



Date: Tue, 23 Feb 2010 13:43:01 +0100
From: wolfgang.l...@gmail.com
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Using Collections in LHS

Discount is a field of Order and must not appear in an Item(...).
Probably you want:
   Order  ( $discount : Discount > 10,...

Also, most likely, all your fields need to be written with a lower case
initial letter,
   Order  ( $discount : discount > 10, $items : items)

-W

On Tue, Feb 23, 2010 at 1:11 PM, dhari  wrote:


In this scenario I do have typical Order and Items data structure. I
want to
implement various business rules where I want to check both Order
attributes
and Item attributes together.

Order [ Date, Discount, Amount, Customer, Type, Items]
Item [ Quantity, Rate, ExpiresDate, Grade ]

I am trying to implements following rules but all gives me syntax error.
I
wondering if someone can help me in.


rule one
   when
   Order  ( $discount : Discount, $items : Items)
   Item ($discount > 10 && Grade > 3) from $items
   then
   System.err.print(Discount is not allowed with items having grade
3 or
higher)
end

rule two
   when
   Order  ( $discount : Discount, $items : Items)
   Item ($discount  > 20 || Quantity < 5 ) from $items
   then
   //do some thinge
end
--
View this message in context:
http://n3.nabble.com/Using-Collections-in-LHS-tp386923p386923.html
Sent from the Drools - User mailing list archive at Nabble.com.

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

 



Find out now Link all your email accounts and social updates with
Hotmail.
 

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


Re: [rules-users] Using Collections in LHS

2010-02-23 Thread dhari




Thanks Jeffery. 
I'll try this but what if I have more complex condition e.g. 



Order ($discount : discount, $items : items)

Item(grade > 3 && (quantity < 5 || $discount > 10)) from $items


Date: Tue, 23 Feb 2010 15:14:18 -0800
From: ml-node+412055-2130217977-80...@n3.nabble.com
To: sdh...@hotmail.com
Subject: Re: Using Collections in LHS



















I think what you are looking for is the following.  Someone
please correct me if I am incorrect.

 

when

Order($discount : discount
> 10, $items: items)

Item(grade > 3) from
$items

then

System.err.print(“Discount is not
allowed with items having grade 3 or higher”);

 

 

This would fire when an Order has a discount greater than 10 and
an  item with a grade greater than 3.

Not sure why you even need the $discount variable.  You
could just do Order(discount > 10, $items : items) for the first line of the
when clause.

 

 





From:
[hidden email]
[mailto:[hidden email]] On Behalf Of Shabbir Dhari

Sent: Tuesday, February 23, 2010 5:27 PM

To: [hidden email]

Subject: Re: [rules-users] Using Collections in LHS





 

Hi W



I know about case sensitivity issue. How can I combine both Order and Item in
one condition. I tried all possibilities but getting syntax error.



For example: 

Order ($items : items, $discount : discount > 10,
Item(grade > 3) from $items) // gives error

 

Can please code this condition correctly for me?

 

Dhari

 







Date: Tue, 23 Feb 2010 13:43:01 +0100

From: [hidden email]

To: [hidden email]

Subject: Re: [rules-users] Using Collections in LHS



Discount is a field of Order and must not appear in an Item(...).

Probably you want:

   Order  ( $discount : Discount > 10,...



Also, most likely, all your fields need to be written with a lower case initial
letter,

   Order  ( $discount : discount > 10, $items : items)



-W



On
Tue, Feb 23, 2010 at 1:11 PM, dhari <[hidden email]>
wrote:



In this scenario I do have typical Order and Items data structure. I want to

implement various business rules where I want to check both Order attributes

and Item attributes together.



Order [ Date, Discount, Amount, Customer, Type, Items]

Item [ Quantity, Rate, ExpiresDate, Grade ]



I am trying to implements following rules but all gives me syntax error. I

wondering if someone can help me in.





rule one

   when

   Order  ( $discount : Discount, $items : Items)

   Item ($discount > 10 && Grade > 3)
from $items

   then

   System.err.print(Discount is not allowed with items
having grade 3 or

higher)

end



rule two

   when

   Order  ( $discount : Discount, $items : Items)

   Item ($discount  > 20 || Quantity < 5 )
from $items

   then

   //do some thinge

end

--

View this message in context: 
http://n3.nabble.com/Using-Collections-in-LHS-tp386923p386923.html

Sent from the Drools - User mailing list archive at Nabble.com.



___

rules-users mailing list

[hidden email]

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



 







Find
out now Link all your email accounts and social updates with Hotmail.







___

rules-users mailing list

[hidden email]

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






View message @ 
http://n3.nabble.com/Using-Collections-in-LHS-tp386923p412055.html


To unsubscribe from Drools - Java Rules Engine, click here.


  
_
Find a great deal on your next car. Get straight to the Point.
http://clk.atdmt.com/NMN/go/157637060/direct/01/
-- 
View this message in context: 
http://n3.nabble.com/Using-Collections-in-LHS-tp386923p412081.html
Sent from the Drools - User mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread Shabbir Dhari



I tried
with some thing different and it worked but I don’t want this as I have many
collections in my data structure.


//this works
Membership ( $regDate : regDate)
Segment ( $endDate : endDate )
Segment ( startDate < $regDate || startDate > $endDate )

//this does NOT work
Membership ( $regDate : regDate)
Segment ($endDate : endDate, startDate < $regDate || startDate > $endDate )

From: sdh...@hotmail.com
To: rules-users@lists.jboss.org
Date: Tue, 23 Feb 2010 23:09:50 +
Subject: Re: [rules-users] Comparing Date with || OR operator








Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate ) 
even does not work. I am using verstion 5.0.1. All dates are java.util.Date and 
values in sample fact are:

regDate = Fri Aug 01 00:00:00 BST 2008
startDate =  Tue Sep 01 00:00:00 BST 2009
endDate = Fri Jul 30 00:00:00 BST 2010

Stack trace: 

java.lang.NullPointerException
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265)
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
at 
org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320)
at 
org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305)
at 
org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78)
at 
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at 
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192)
at 
au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57)


> Date: Tue, 23 Feb 2010 12:54:46 +0100
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
> Subject: Re: [rules-users] Comparing Date with || OR operator
> 
> Please try this rewrite of the 2nd CE:
>Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate 
> )
> and report the outcome to the list, together with the Dools version
> you are using.
> Thank you.
> 
> 
> 2010/2/23 dhari :
> > Hi Thomas
> >
> > Thanks your prompt reply. I am sure all three attributes are NOT null. I
> > have tested them before sending question to mailing list. If you want, I can
> > send complete sample code and you can try it at your end.
> >
> > Regards,
> > Dhari
> >
> >
> > 
> > Date: Tue, 23 Feb 2010 02:50:08 -0800
> > From: [hidden email]
> > To: [hidden email]
> > Subject: Re: Comparing Date with || OR operator
> >
> > If it works fine with an and operator then I’d imagine that startDate <
> > $regDate returns false, with an && this would abort evaluation immediately
> > but with an or it would mean that startDate > endDate is evaluated and so
> > presumably it is this bit that is throwing the NPE.  I’d imagine that the
> > most likely reason for this would be that endDate is null.
> >
> >
> >
> > Try changing it too
> >
> > Segment ( startDate < $regDate || (endDate != null && startDate > endDate) )
> >
> > And see whether you loose the NPE.
> >
> >
> >
> > Thomas
> >
> >
> >
> > From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
> > Sent: 23 February 2010 06:15
> > To: [hidden email]
> > Subject: [rules-users] Comparing Date with || OR operator
> >
> >
> >
> > The following code generates NPE in ReteTuple.java
> >
> > rule
> >
> >when
> >
> >   Membership ( $regDate : regDate)
> >
> >   Segment ( startDate < $regDate || startDate > endDate )
> >
> > then
> >
> > System.err.print(“Invalid start date”);
> >
> > end
> >
> > I am new in Drools and don’t know much about DRL scripting. It works fine I
> > use && operator instead.
> >
> > 
> >
> > View this message in context: Comparing Date with || OR operator
> > Sent from the Drools - User mailing list archive at Nabble.com.
> >
> > 
> > **
> > This message is confidential and intended only for the addressee. If you
> > have received this

Re: [rules-users] Using Collections in LHS

2010-02-23 Thread Wolfgang Laun
You really ought to read all the pertaining sections in the Drools Expert
manual and experiment. Nobody can write complex rules without some exercise.

2010/2/24 dhari 

> Thanks Jeffery.  I'll try this but what if I have more complex condition
> e.g.
>
>
> Order ($discount : discount, $items : items)
> Item(grade > 3 && (quantity < 5 || $discount > 10)) from $items
>

Again, you are using a condition on discount not next to the field in the
fact where it occurs (i.e., Order); it's just not possible to write it this
way.

Order( discount > 10, $items : items )   # all Orders where discount > 10
Item( grade > 3, quantity < 5 ) from $items # and each of its Items where
grade > 3 and quantity < 5

There is no need to use && to combine two conditions for the same fact.

Now if you need to detect Order Items with grade > 3 where either the
quantitiy of the Item is < 5, or  the Order's discount > 10, (or both) you'd
have to write

Order( $discount : discount, $items : items )   # all Orders
Item( grade > 3, $quantity : quantity) from $items # and each of its Items
where grade > 3
eval( $discount > 10 || $quantitiy < 5 ) # and discount > 10 or quantity < 5
(or both)

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