Sanjay,<br><br> You almost got it right. If you are using 3.1M1 or later, you can do:<br><br>item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE | == ItemVo.STATUS_DELETE )<br><br> field connective constraints use a single "|" or "&".
<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2007/4/4, Sanjay Singh - s0singh <<a href="mailto:Sanjay.Singh@wal-mart.com">Sanjay.Singh@wal-mart.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
While this is working<br><br>when<br> item : ItemVo(itemStatusCode == ItemVo.STATUS_INACTIVE) or<br>ItemVo(itemStatusCode == ItemVo.STATUS_DELETE)<br><br>Is this the right way of doing it ?<br><br>thanks<br><br>-----Original Message-----
<br>From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Sanjay Singh -
<br>s0singh<br>Sent: Wednesday, April 04, 2007 2:12 PM<br>To: Rules Users List<br>Subject: [rules-users] Checking OR condition in LHS<br><br> when<br> item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE ||<br>ItemVo.STATUS_DELETE
)<br> when<br> item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE ||<br>itemStatusCode == ItemVo.STATUS_DELETE )<br> when<br> item : ItemVo ( (itemStatusCode == ItemVo.STATUS_ACTIVE ||<br>itemStatusCode ==
ItemVo.STATUS_DELETE) )<br> when<br> item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE || ==<br>ItemVo.STATUS_DELETE )<br> when<br> item : ItemVo ( ( itemStatusCode == ItemVo.STATUS_ACTIVE ) || (<br>itemStatusCode ==
ItemVo.STATUS_DELETE ) )<br> when<br> item : ItemVo ( itemStatusCode == ItemVo.STATUS_ACTIVE OR<br>itemStatusCode == ItemVo.STATUS_DELETE )<br><br>All of these when conditions fail for me .. Can somebody send the syntax
<br>for two attributes check with OR condition ..<br><br>thanks<br><br><br>-----Original Message-----<br>From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a><br>[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">
rules-users-bounces@lists.jboss.org</a>] On Behalf Of Sanjay Singh -<br>s0singh<br>Sent: Wednesday, April 04, 2007 8:13 AM<br>To: Rules Users List<br>Subject: RE: [rules-users] NullPointer in LHS dao calls ..<br><br>Thanks Rahul
<br>Yes i was setting it in working memory thats why it was working in RHS<br>.....<br><br>workingMemory.setGlobal("itemValidationDao", itemValidationDao);<br>and then in the DRL<br>global com.walmart.itemfile.item.dao.ItemValidationDao
<br>itemValidationDao;<br><br>I think i am missing something very basic ..<br><br>thanks<br><br>-----Original Message-----<br>From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>
<br>[mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Rahul Phadnis<br>Sent: Tuesday, April 03, 2007 5:42 PM<br>To: Rules Users List<br>Subject: Re: [rules-users] NullPointer in LHS dao calls ..
<br><br>Did you set the global in the WorkingMemory?<br><br>You can do that using the API at<br><br><a href="http://labs.jboss.com/file-access/default/members/jbossrules/freezone/do">http://labs.jboss.com/file-access/default/members/jbossrules/freezone/do
</a><br>cs/3.0.5/apidocs/index.html<br>and yes that is for 3.0.5. I am sure there is an<br>equivalent for the version that you are using.<br><br>-Rahul<br><br><br>--- Sanjay Singh - s0singh <<a href="mailto:Sanjay.Singh@wal-mart.com">
Sanjay.Singh@wal-mart.com</a>><br>wrote:<br><br>> Since i could not get the earlier code running i<br>> tried using eval in LHS<br>> side for Dao calls but i keep on getting<br>> NullPointerException ..<br>
><br>> rule "Item should have a valid status"<br>><br>> when<br>><br>> ItemVo (statusCode : itemStatusCode != null)<br>><br>> eval(<br>> !itemValidationDao.isValidItemStatus(statusCode) )
<br>><br>> then<br>><br>><br>errors.addValidationError("invalidtemStatusCode","Item<br>> Status Code is<br>> invalid ");<br>><br>> end<br>><br>> Exception data: org.drools.RuntimeDroolsException
:<br>> java.lang.NullPointerException<br>><br>> at org.drools.rule.EvalCondition.isAllowed(Unknown<br>> Source)<br>><br>> at<br>><br>org.drools.reteoo.EvalConditionNode.assertTuple(Unknown<br>> Source)
<br>><br>> at<br>><br>org.drools.reteoo.LeftInputAdapterNode.createAndAssertTuple(Unknown<br>> Source)<br>><br>> at<br>><br>org.drools.reteoo.LeftInputAdapterNode.assertObject(Unknown<br>> Source)<br>
><br>> at<br>><br>org.drools.reteoo.ObjectSource.propagateAssertObject(Unknown<br>> Source)<br>><br>> Can somebody please help .. thanks<br>><br>> ________________________________<br>><br>> From: Sanjay Singh - s0singh
<br>> Sent: Tuesday, April 03, 2007 11:01 AM<br>> To: 'Anstis, Michael (M.)'; Rules Users List<br>> Subject: RE: Hi.<br>><br>><br>><br>> Thanks for getting back to me Mike and Edson and<br>> Sorry for the delayed
<br>> response.<br>><br>> I looked at your examples Mike and i felt better as<br>> you said that we can<br>> make dao calls in LHS .. And Edson suggested not to<br>> be afraid of<br>> suggesting the same constraint for more than one
<br>> rule .. i guess i was<br>> looking at it more procedural way and dint want any<br>> repetition of those<br>> conditions as the top level IF block but looks like<br>> it won't hurt to<br>> mention these constraints in all the rules related
<br>> to this check ...so i<br>> can include this check in all the rules .. hmm ..<br>><br>> Here is a quick test i was trying to do for calling<br>> the dao in LHS but<br>> it fails .. what am i missing ..
<br>><br>> package com.walmart.itemfile.item.rules<br>><br>> import com.walmart.itemfile.item.vo.ItemVo;<br>><br>> import com.walmart.itemfile.item.dao.ItemDao;<br>><br>> import<br>> com.walmart.itemfile.item.dao.ItemValidationDao
;<br>><br>> import java.lang.String;<br>><br>> global<br>> com.walmart.itemfile.item.dao.ItemValidationDao<br>> itemValidationDao;<br>><br>> global com.walmart.itemfile.rules.ValidationErrorMap<br>
> errors;<br>><br>> rule "Item should have a valid status"<br>><br>> when<br>><br>> ItemVo( statusCode : itemStatusCode != null)<br>><br>> ItemVo( statusCode == true ) from<br>> itemValidationDao.isValidItemStatus
(statusCode) ..<br>> my isValidItemStatus<br>> method returns a boolean (not collection of codes)<br>> and i need to check<br>> if thats true than go to the RHS side .. is the line<br>> in green even right<br>
> ... in any case it does not recognize<br>> itemValidationDao to begin with in<br>> LHS side .. RHS same call works ..<br>><br>> then<br>><br>> errors.addValidationError("nullItemStatusCode","Item
<br>> Status Code is<br>> null");<br>><br>> System.out.println("Item Base Defaults Called" +<br>> itemValidationDao.isValidItemStatus(statusCode));<br>><br>> System.out.println("Item Status Code is null");
<br>><br>> end<br>><br>> Caused by: org.drools.rule.InvalidRulePackage:<br>> unknown:32:28 Unexpected<br>> token 'itemValidationDao'<br>><br>><br>> thanks for the help guys ..<br>><br>
> Sanjay<br>><br>> ________________________________<br>><br>> From: Anstis, Michael (M.)<br>> [mailto:<a href="mailto:manstis1@ford.com">manstis1@ford.com</a>]<br>> Sent: Monday, March 26, 2007 8:57 AM
<br>> To: Rules Users List<br>> Cc: Sanjay Singh - s0singh<br>> Subject: RE: Hi.<br>><br>><br>> Hi Sanjay,<br>><br>> To firstly answer your questions (in my opinion):<br>> 1. You can't do nested whens in the LHS but you can
<br>> do nested if / else<br>> in the RHS (although you'd fore go the benefits of a<br>> RETE-based<br>> inference engine; but possible if you've got very<br>> few rules and<br>> facts...). I believe that there is work to have an
<br>> "otherwise" statement<br>> for rule syntax, how progressed this is and how it<br>> will work I don't<br>> know - over to Mark and team?!?<br>> 2. Yes, take a look at the "from" statement (new for
<br>> 3.1-M1, see<br>><br><a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=3.1M1ReleaseNotes">http://wiki.jboss.org/wiki/Wiki.jsp?page=3.1M1ReleaseNotes</a>)<br>> 3. Yes, take a look at rule-flow at<br>><br><a href="http://labs.jboss.com/portal/index.html?ctrl:cmd=render&ctrl:window=defa">
http://labs.jboss.com/portal/index.html?ctrl:cmd=render&ctrl:window=defa</a><br>><br>ult.blog.PrjBlogPortletWindowDefaultBlog&project=jbossrules&from=1&link=<br>><br>RuleFlow_%28Kris_Verlaenen%29#RuleFlow_%28Kris_Verlaenen%29
<br>> (although I<br>> don't know if this is complete if 3.1-M1 - I think<br>> it's not). Although I<br>> don't think your rules really need rule-flow; you<br>> just need to identify<br>> and isolate the patterns (IF's) that would cause
<br>> each "Do Something" to<br>> be ran and create a rule for each - this has the<br>> benefit of separating<br>> each action into a separate rule making maintenance<br>> a whole bunch<br>> easier).
<br>><br>> Anyway, I'd try some rules like the following<br>> examples (the rest are<br>> based upon these):-<br>><br>> Rule "Rule 1"<br>> when<br>> NewItem ( itemStatusCode == null)
<br>> then<br>> //do something<br>> end<br>><br>> Rule "Rule 2"<br>> when<br>> $u : User( )<br>> $ni : NewItem ( $isc : itemStatusCode != null )<br>> not Codes ( codes contains $isc ) from
<br>> valDao.getValidItemStatusCodesForUser($u)<br>> then<br>> //Do something<br>> end<br>><br>> Rule "Rule 3"<br>> when<br>><br>=== message truncated ===><br>_______________________________________________
<br>> rules-users mailing list<br>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br>><br><br><br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br>-----------------------------------------<br>*******************************************************************<br>*** This email and any files transmitted with it are confidential
<br>and intended solely for the individual or entity to whom they are<br>addressed. If you have received this email in error destroy it<br>immediately. ******************************************************<br>**************** Wal-Mart Confidential ****************************
<br>******************************************<br><br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br>-----------------------------------------<br>*******************************************************************<br>*** This email and any files transmitted with it are confidential
<br>and intended solely for the individual or entity to whom they are<br>addressed. If you have received this email in error destroy it<br>immediately. ******************************************************<br>**************** Wal-Mart Confidential ****************************
<br>******************************************<br><br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br><br>-----------------------------------------<br>*******************************************************************<br>*** This email and any files transmitted with it are confidential
<br>and intended solely for the individual or entity to whom they are<br>addressed. If you have received this email in error destroy it<br>immediately. ******************************************************<br>**************** Wal-Mart Confidential ****************************
<br>******************************************<br><br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3124-6000<br> Mobile: +55 11 9218-4151
<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>