Sanjay

  I already answered question number 1. Plz see my other e-mail.

  For question number 2, try:

rule "Item status cannot be null"

when

    itemMaint : ItemMaintWorkVo()

    oldItem : ItemVo( <constraints>) from itemMaint.getCurrentItem()

    newItem : ItemVo( <constraints> ) from itemMaint.getNewItem()

then

end


   Let us know if above works. When the method called by "from" returns a single non-Collection object, the dataprovider automatically wrapps the result in a singleton list.

   []s
   Edson


2007/4/6, Sanjay Singh - s0singh <Sanjay.Singh@wal-mart.com>:
Hello everybody,
 
I still have 2 of my questions pending and i would really appreciate if somebody could get back to me and help me out.
 
1.Calling dao in LHS when the method calls does not return collection and returns lets say a boolean .. Code is attached below for a quick look.

rule "Item should have a valid status"

when

ItemVo( statusCode : itemStatusCode != null)

ItemVo( statusCode == true ) from itemValidationDao.isValidItemStatus(statusCode)

then

System.out.println("Item Status Code is valid");

end

Caused by: org.drools.rule.InvalidRulePackage: unknown:32:28 Unexpected token 'itemValidationDao'

isValidItemStatus ()  method returns a boolean and i need to check if thats true than go to the RHS side ....  somehow it does not recognize itemValidationDao in LHS side .. RHS same call works ...  Can anybody suggest how to call database in LHS .. 

2.If I have a method with the signature
public ValidationErrorMap validateItemOrdEffDateMaintain(ItemVo oldItem, ItemVo newItem, ValidationErrorMap errors, UserVo user){ }
Is there a way that i can assert two objects of same type in my working memory ?? Like oldItem and newItem are same ItemVo's and they have exactly same fields .. How do i assert two same type objects so that i can deal with them in drl differently .. I have one ItemMaintVo which can give me oldItem and newItem and i can only assert ItemMaintVo but again how do i refer to two same type objects .. Here is the syntax ..
 

rule "Item status cannot be null"

when

oldItemMaint : ItemMaintWorkVo(oldItem : currentItem)

newItemMaint : ItemMaintWorkVo(newItem : newItem)

// I need to reach to the ItemVo (from old and new item) .. how do i do it here ?

then

System.out.println( "Item Status Code is "  + old or new item . getItemStatuscode()  );

end

 
This does not seem to work .. whats the way to operate on two different instances of same class in DRL files ....
 


From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Friday, April 06, 2007 8:53 AM
To: Rules Users List
Subject: Re: [rules-users] Checking OR condition in LHS

  Sanjay,

  You almost got it right. If you are using 3.1M1 or later, you can do:

item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE | == ItemVo.STATUS_DELETE )

   field connective constraints use a single "|" or "&".

   []s
   Edson

2007/4/4, Sanjay Singh - s0singh <Sanjay.Singh@wal-mart.com>:
While this is working

when
        item : ItemVo(itemStatusCode == ItemVo.STATUS_INACTIVE) or
ItemVo(itemStatusCode == ItemVo.STATUS_DELETE)

Is this the right way of doing it ?

thanks

-----Original Message-----
From: rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Sanjay Singh -
s0singh
Sent: Wednesday, April 04, 2007 2:12 PM
To: Rules Users List
Subject: [rules-users] Checking OR condition in LHS

when
        item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE ||
ItemVo.STATUS_DELETE )
when
        item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE ||
itemStatusCode == ItemVo.STATUS_DELETE )
when
        item : ItemVo ( (itemStatusCode == ItemVo.STATUS_ACTIVE ||
itemStatusCode == ItemVo.STATUS_DELETE) )
when
        item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE || ==
ItemVo.STATUS_DELETE )
when
        item : ItemVo ( ( itemStatusCode == ItemVo.STATUS_ACTIVE ) || (
itemStatusCode == ItemVo.STATUS_DELETE ) )
when
        item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE OR
itemStatusCode == ItemVo.STATUS_DELETE )

All of these when conditions fail for me ... Can somebody send the syntax
for two attributes check with OR condition ..

thanks


-----Original Message-----
From: rules-users-bounces@lists.jboss.org
[mailto: rules-users-bounces@lists.jboss.org] On Behalf Of Sanjay Singh -
s0singh
Sent: Wednesday, April 04, 2007 8:13 AM
To: Rules Users List
Subject: RE: [rules-users] NullPointer in LHS dao calls ..

Thanks Rahul
Yes i was setting it in working memory thats why it was working in RHS
.....

workingMemory.setGlobal("itemValidationDao", itemValidationDao);
and then in the DRL
global com.walmart.itemfile.item.dao.ItemValidationDao
itemValidationDao;

I think i am missing something very basic ..

thanks

-----Original Message-----
From: rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Rahul Phadnis
Sent: Tuesday, April 03, 2007 5:42 PM
To: Rules Users List
Subject: Re: [rules-users] NullPointer in LHS dao calls ..

Did you set the global in the WorkingMemory?

You can do that using the API at

http://labs.jboss.com/file-access/default/members/jbossrules/freezone/do
cs/3.0.5/apidocs/index.html
and yes that is for 3.0.5. I am sure there is an
equivalent for the version that you are using.

-Rahul


--- Sanjay Singh - s0singh < Sanjay.Singh@wal-mart.com>
wrote:

> Since i could not get the earlier code running i
> tried using eval in LHS
> side for Dao calls but i keep on getting
> NullPointerException ..
>
> rule "Item should have a valid status"
>
> when
>
> ItemVo (statusCode : itemStatusCode != null)
>
> eval(
> !itemValidationDao.isValidItemStatus(statusCode) )
>
> then
>
>
errors.addValidationError("invalidtemStatusCode","Item
> Status Code is
> invalid ");
>
> end
>
> Exception data: org.drools.RuntimeDroolsException :
> java.lang.NullPointerException
>
> at org.drools.rule.EvalCondition.isAllowed(Unknown
> Source)
>
> at
>
org.drools.reteoo.EvalConditionNode.assertTuple(Unknown
> Source)
>
> at
>
org.drools.reteoo.LeftInputAdapterNode.createAndAssertTuple(Unknown
> Source)
>
> at
>
org.drools.reteoo.LeftInputAdapterNode.assertObject(Unknown
> Source)
>
> at
>
org.drools.reteoo.ObjectSource.propagateAssertObject(Unknown
> Source)
>
> Can somebody please help .. thanks
>
> ________________________________
>
> From: Sanjay Singh - s0singh
> Sent: Tuesday, April 03, 2007 11:01 AM
> To: 'Anstis, Michael (M.)'; Rules Users List
> Subject: RE: Hi.
>
>
>
> Thanks for getting back to me Mike and Edson and
> Sorry for the delayed
> response.
>
> I looked at your examples Mike and i felt better as
> you said that we can
> make dao calls in LHS .. And Edson suggested not to
> be afraid of
> suggesting the same constraint for more than one
> rule .. i guess i was
> looking at it more procedural way and dint want any
> repetition of those
> conditions as the top level IF block but looks like
> it won't hurt to
> mention these constraints in all the rules related
> to this check ...so i
> can include this check in all the rules .. hmm ..
>
> Here is a quick test i was trying to do for calling
> the dao in LHS but
> it fails ... what am i missing ..
>
> package com.walmart.itemfile.item.rules
>
> import com.walmart.itemfile.item.vo.ItemVo;
>
> import com.walmart.itemfile.item.dao.ItemDao;
>
> import
> com.walmart.itemfile.item.dao.ItemValidationDao ;
>
> import java.lang.String;
>
> global
> com.walmart.itemfile.item.dao.ItemValidationDao
> itemValidationDao;
>
> global com.walmart.itemfile.rules.ValidationErrorMap
> errors;
>
> rule "Item should have a valid status"
>
> when
>
> ItemVo( statusCode : itemStatusCode != null)
>
> ItemVo( statusCode == true ) from
> itemValidationDao.isValidItemStatus (statusCode) ..
> my isValidItemStatus
> method returns a boolean (not collection of codes)
> and i need to check
> if thats true than go to the RHS side .. is the line
> in green even right
> ... in any case it does not recognize
> itemValidationDao to begin with in
> LHS side .. RHS same call works ..
>
> then
>
> errors.addValidationError("nullItemStatusCode","Item
> Status Code is
> null");
>
> System.out.println("Item Base Defaults Called" +
> itemValidationDao.isValidItemStatus(statusCode));
>
> System.out.println("Item Status Code is null");
>
> end
>
> Caused by: org.drools.rule.InvalidRulePackage:
> unknown:32:28 Unexpected
> token 'itemValidationDao'
>
>
> thanks for the help guys ..
>
> Sanjay
>
> ________________________________
>
> From: Anstis, Michael (M.)
> [mailto:manstis1@ford.com]
> Sent: Monday, March 26, 2007 8:57 AM
> To: Rules Users List
> Cc: Sanjay Singh - s0singh
> Subject: RE: Hi.
>
>
> Hi Sanjay,
>
> To firstly answer your questions (in my opinion):
> 1. You can't do nested whens in the LHS but you can
> do nested if / else
> in the RHS (although you'd fore go the benefits of a
> RETE-based
> inference engine; but possible if you've got very
> few rules and
> facts...). I believe that there is work to have an
> "otherwise" statement
> for rule syntax, how progressed this is and how it
> will work I don't
> know - over to Mark and team?!?
> 2. Yes, take a look at the "from" statement (new for
> 3.1-M1, see
>
http://wiki.jboss.org/wiki/Wiki.jsp?page=3.1M1ReleaseNotes )
> 3. Yes, take a look at rule-flow at
>
http://labs.jboss.com/portal/index.html?ctrl:cmd=render&ctrl:window=defa
>
ult.blog.PrjBlogPortletWindowDefaultBlog&project=jbossrules&from=1&link=
>
RuleFlow_%28Kris_Verlaenen%29#RuleFlow_%28Kris_Verlaenen%29
> (although I
> don't know if this is complete if 3.1-M1 - I think
> it's not). Although I
> don't think your rules really need rule-flow; you
> just need to identify
> and isolate the patterns (IF's) that would cause
> each "Do Something" to
> be ran and create a rule for each - this has the
> benefit of separating
> each action into a separate rule making maintenance
> a whole bunch
> easier).
>
> Anyway, I'd try some rules like the following
> examples (the rest are
> based upon these):-
>
> Rule "Rule 1"
> when
>     NewItem ( itemStatusCode == null)
> then
>     //do something
> end
>
> Rule "Rule 2"
> when
>     $u : User( )
>     $ni : NewItem ( $isc : itemStatusCode != null )
>     not Codes ( codes contains $isc ) from
> valDao.getValidItemStatusCodesForUser($u)
> then
>     //Do something
> end
>
> Rule "Rule 3"
> when
>
=== message truncated ===>
_______________________________________________
> 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 email and any files transmitted with it are confidential
and intended solely for the individual or entity to whom they are
addressed. If you have received this email in error destroy it
immediately. ******************************************************
**************** Wal-Mart Confidential ****************************
******************************************


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

-----------------------------------------
*******************************************************************
*** This email and any files transmitted with it are confidential
and intended solely for the individual or entity to whom they are
addressed. If you have received this email in error destroy it
immediately. ******************************************************
**************** Wal-Mart Confidential ****************************
******************************************


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

-----------------------------------------
*******************************************************************
*** This email and any files transmitted with it are confidential
and intended solely for the individual or entity to whom they are
addressed. If you have received this email in error destroy it
immediately. ******************************************************
**************** Wal-Mart Confidential ****************************
******************************************


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



--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3124-6000
  Mobile: +55 11 9218-4151
  JBoss, a division of Red Hat @ www.jboss.com




*******************************************************************
*** This email and any files transmitted with it are confidential
and intended solely for the individual or entity to whom they are
addressed. If you have received this email in error destroy it
immediately. ******************************************************
**************** Wal-Mart Confidential ****************************
******************************************


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




--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3124-6000
  Mobile: +55 11 9218-4151
  JBoss, a division of Red Hat @ www.jboss.com