[rules-users] RE: how to find duplicate inlineeval

Edson Tirelli tirelli at post.com
Wed Nov 14 06:48:02 EST 2007


   Sorry, you lost me. What is the error message?
   Can you send us a self contained test showing the problem you are having?

   []s
   Edson

2007/11/14, Sikkandar Nawabjan <Sikkandar.Nawabjan at ust-global.com>:
>
> Edson,
>
> As you said i used inline eval. But am getting erroe message like this
> can't be used in static context.am using statelesssession to assert my
> objects.
>
> i also put eval(this!=obj1) as follows.
>
>   $obj1:Object1($id:id,$name:name)
>   $obj2:Object1(id==$id,$name:name==$name, eval( this!=$obj1
> ))  eval($obj2!=  $obj1)
>
> Though my references are different the rule is not firing
>
>
> Thanks and Regs
>
> Basha
>
> From: rules-users-bounces at lists.jboss.org on behalf of Edson Tirelli
> Sent: Tue 11/13/2007 9:35 PM
> To: Rules Users List
> Subject: Re: [rules-users] RE: how to find duplicate
>
>
>
>
>    Sikkandar,
>
>    The only way to check for identity is to use an inline eval and use
> java code to check that:
>
> when
>         $obj1:Object1($id:id,$name:name)
>         $obj2:Object1(id==$id,$name:name==$name, eval( this!=$obj1 ))
> then
>
>    Another option is to configure your rulebase to not allow the same
> object to be matched by more than one pattern in your rules. To do that you
> can either set a system property:
>
> drools.removeIdentities = true
>
>     Or you can use drools API:
>
> RuleBaseConfiguration conf = new RuleBaseConfiguration();
> conf.setRemoveIdentities( true );
> RuleBase rulebase = RuleBaseFactory.newRuleBase( conf );
>
>     If you do that, your rule can be written as this:
>
> when
>         $obj1:Object1($id:id,$name:name)
>         $obj2:Object1(id==$id,$name:name==$name)
> then
>
>    Since the engine will never allow the same fact to simultaneously match
> both patterns.
>
>    []s
>    Edson
>
>
>
>
>
> 2007/11/13, Sikkandar Nawabjan <Sikkandar.Nawabjan at ust-global.com>:
>
>         Hi,
>         am passing list of objects to working memory. i want to fire the
> rule if there is any duplicate objects in the list
>
>         i write code like this
>
>         when
>                 $obj1:Object1($id:id,$name:name)
>                 $obj2:Object1(id==$id,$name:name==$name,this!=$obj1)
>         then
>           fire rule
>
>         Now the problem lies at this!=objj1(a highlighted check). i put
> this to avoid a object check with itself.
>         But this is internally calling equals method of the corresponding
> object and always return true. Because i overriden equals method in the
> Object itself
>         so at the end the rule won't fire even if there is a duplicate
> object. how i can solve this
>
>         equals(Object obj){
>         if(this.id=obj.id&& this.name==obj.name)
>           return true;
>         else
>           return false;
>         }
>
>
>
>
>         ________________________________
>
>         From: rules-users-bounces at lists.jboss.org on behalf of
> rules-users-request at lists.jboss.org
>         Sent: Tue 11/13/2007 2:04 AM
>         To: rules-users at lists.jboss.org
>         Subject: rules-users Digest, Vol 12, Issue 27
>
>
>
>         Send rules-users mailing list submissions to
>                 rules-users at 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-request at lists.jboss.org <mailto:
> rules-users-request at lists.jboss.org>
>
>         You can reach the person managing the list at
>                 rules-users-owner at 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. Re: Drools and jBPM integration (Fabian Weisensee)
>            2. Re: java.lang.OutOfMemoryError: Java heap space (Edson
> Tirelli)
>            3. Re: Drools and jBPM integration (Mark Proctor)
>            4. Re: Drools and jBPM integration (Mark Proctor)
>
>
>
>         ----------------------------------------------------------------------
>
>         Message: 1
>         Date: Mon, 12 Nov 2007 18:23:06 +0100
>         From: Fabian Weisensee <fabian at weisensee.net>
>         Subject: Re: [rules-users] Drools and jBPM integration
>         To: Rules Users List < rules-users at lists.jboss.org <mailto:
> rules-users at lists.jboss.org> >
>         Message-ID: <47388BFA.3010009 at weisensee.net>
>         Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
>         Yes, thanks for your help. I'll try your suggestion for #2.
>
>         I resolved the deployment problem by myself. It was just a mistake
> with
>         the JBoss ESB deploying...
>
>         But now I have another problem. The rule file is found, but there
> seem
>         to be some problems with the parser.
>
>         The FireRulesActionHandler class from the jbpm wiki uses the
> following code:
>         RuleBaseImpl ruleBase = new RuleBaseImpl();
>         ruleBase.addPackage(pkg);
>
>         But the RuleBaseImpl class doesn't seem to be part of drools
> anymore. I
>         looked at the javadocs to find a replacement. I've found the
>         RuleBaseLoader class which looked like what I needed. I replaced
> the two
>         lines with this:
>         RuleBaseLoader rbl = RuleBaseLoader.getInstance();
>         RuleBase ruleBase = rbl.loadFromReader(reader);
>         ruleBase.addPackage(pkg);
>
>         but when I run this I get the following error:
>
>         ERROR [GraphElement] action threw exception: Unable to parser
> Reader
>         java.lang.RuntimeException : Unable to parser Reader
>                 at org.drools.compiler.DrlParser.getParser(DrlParser.java
> :209)
>                 at org.drools.compiler.DrlParser.parse(DrlParser.java:60)
>                 at
>         org.drools.compiler.PackageBuilder.addPackageFromDrl (
> PackageBuilder.java:165)
>                 at
>         org.drools.compiler.RuleBaseLoader.loadFromReader(
> RuleBaseLoader.java:38)
>                 at
>         rechnung.kontrolle.FireRulesActionHandler.readRule(
> FireRulesActionHandler.java:92)
>                 at
>         rechnung.kontrolle.FireRulesActionHandler.execute(
> FireRulesActionHandler.java:49)
>
>         Of course I thought my rule file would be syntacticaly incorrect,
> but
>         even this rule file didn't work:
>
>         package rechnung.kontrolle
>
>         rule "test rule 1"
>                 when
>                 then
>                         System.out.println("rule fired!");
>         end
>
>         What am I doing wrong? Is RulesBaseLoader the right class?
>         Are there any other Informations about integrating jBPM and
> Drools?
>
>         --Fabian
>
>
>
>         Aziz Boxwala schrieb:
>         > Fabian,
>         >
>         > Response to #1: I believe the rule file needs to reside in the
> root
>         > directory of the archive/directory of the example application. I
> have
>         > not tried that out so not sure.
>         >
>         > With Drools 4.0.x, you have the option of having your rules be
> located
>         > in the BRMS.
>         >
>         > Response to #2: You should be able to do so using one
> decision-node.
>         > Associate the rule action handler with either the Before Signal
> or Node
>         > Enter event and specify your decision conditions on the
> transitions out
>         > of that node..
>         >
>         > --Aziz
>         >
>         > ----- Original Message ----
>         > From: Fabian Weisensee <fabian at weisensee.net>
>         > To: rules-users at lists.jboss.org
>         > Sent: Monday, November 12, 2007 7:35:02 AM
>         > Subject: [rules-users] Drools and jBPM integration
>         >
>         > Hi there
>         >
>         > I have some questions concerning Drools and jBPM integration.
>         > I know there is this wiki page:
>         > http://wiki.jboss.org/wiki/Wiki.jsp?page=JbpmAndDrools
>         > but first it's not really detailed and second does it seem to be
> outdated.
>         >
>         > 1) I changed the FireRulesActionHandler from the wiki to reflect
> the
>         > API-changes, that at least it's compileable. In the jBPM process
>         > definition the rule file is simply passed as parameter like
> this:
>         > "/Shipper.drl". To which directory does this relative path
> apply? So
>         > where do I have to deploy this rule file? I tried several
> locations in
>         > the application server, but even with an absolute path every
> time
>         > FireRulesActionHandler tries to read the rule it crashes:
>         >
>         > ERROR [GraphElement] action threw exception: null
>         > java.lang.NullPointerException
>         >     at java.io <http://java.io/>  <http://java.io.Re <
> http://java.io.re/>  < http://java.io.re/ <http://java.io.re/> >
> >.Reader.<init>(Unknown Source)
>         >     at java.io <http://java.io/>  <http://java.io.In <
> http://java.io.in/>  <http://java.io.in/ >
> >.InputStreamReader.<init>(Unknown Source)
>         >     at
>         > rechnung.kontrolle.FireRulesActionHandler.readRule(
> FireRulesActionHandler.java:83)
>         >     at
>         > rechnung.kontrolle.FireRulesActionHandler.execute (
> FireRulesActionHandler.java:50)
>         >
>         > 2) As I understood the example in the wiki you have to create a
> node
>         > which executes the rule and then a decision-node which routes
> the
>         > process flow according to the rule results.
>         > Is it possible to do this with just one node?
>         > But perhaps I should ask this at the jBPM forums.
>         >
>         > Every help would be appreciated. Thanks in advance.
>         >
>         > Fabian Weisensee
>         > _______________________________________________
>         > rules-users mailing list
>         > rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>         > https://lists.jboss.org/mailman/listinfo/rules-users
>         >
>         >
>         >
> ------------------------------------------------------------------------
>         >
>         > _______________________________________________
>         > rules-users mailing list
>         > rules-users at lists.jboss.org
>         > https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>         ------------------------------
>
>         Message: 2
>         Date: Mon, 12 Nov 2007 16:35:56 -0200
>         From: "Edson Tirelli" <tirelli at post.com>
>         Subject: Re: [rules-users] java.lang.OutOfMemoryError: Java heap
> space
>         To: "Rules Users List" <rules-users at lists.jboss.org>
>         Message-ID:
>                 <
> e6dd5ba30711121035j634309ebq14f21d73ad68ce36 at mail.gmail.com <mailto:
> e6dd5ba30711121035j634309ebq14f21d73ad68ce36 at mail.gmail.com> >
>         Content-Type: text/plain; charset="iso-8859-1"
>
>            Thanks for reporting and providing workaround. I will look into
> fixing
>         that.
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071114/e9000e48/attachment.html 


More information about the rules-users mailing list