[rules-users] RE: how to find duplicate

Sikkandar Nawabjan Sikkandar.Nawabjan at ust-global.com
Mon Nov 12 22:09:19 EST 2007


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;
}
 
 
 
 
Sikkandar Basha	   	
Tech Lead                         WPEPDS
  	
	
 UST Global<http://intranet.ustri.com/email/UST-logo.jpg> 	B5N 144, Bhavani
Technopark, Trivandrum, India
sikkandar.nawabjan at ust-global.com <mailto:sikkandar.nawabjan at ust-global.com> 
T: +91-471-2335777 Extn: 6802036
M: +91-9946555330
F:  +91-471-2527276

________________________________

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

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>
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.Re <http://java.io.re/> >.Reader.<init>(Unknown Source)
>     at java.io <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>
Content-Type: text/plain; charset="iso-8859-1"

   Thanks for reporting and providing workaround. I will look into fixing
that.

2007/11/12, vdelbart <delbart.v at mipih.fr>:
>
>
> Hello,
>
> I add this 4 lines in my code before the session.dispose() and the problem
> disapear :
>
>         session.removeEventListener((WorkingMemoryEventListener)logger);
>         session.removeEventListener((AgendaEventListener)logger);
>         session.removeEventListener((RuleFlowEventListener)logger);
>         session.removeEventListener((RuleBaseEventListener)logger);
>
> regards,
>
> V.
>
>
>
> vdelbart wrote:
> >
> > Good morning,
> >
> > I found a workaround : don't use the WorkingMemoryFileLogger !
> >
> > I create an issue : http://jira.jboss.com/jira/browse/JBRULES-1325
> >
> > regards,
> >
> > V.
> >
> >
> > vdelbart wrote:
> >>
> >> Hello,
> >>
> >> In my tests of the 4.0.3, I have some :  java.lang.OutOfMemoryError.
> >>
> >> So, I try a simple test with 10.000 sequential execution of 1 rule with
> >> no context and just a workingmemorylogger and I have the error :
> >> java.lang.OutOfMemoryError: Java heap space
> >>
> >> My code is :
> >>
> >> public class ExecReglesMemotyTest
> >> {
> >>
> >>      private static final Reader DRL = new
> >> InputStreamReader(ExecReglesMemotyTest.class
> >>                      .getResourceAsStream("/rules/exemple.drl"));
> >>
> >>      private static final String FICHIER_LOG = "session";
> >>
> >>      /**
> >>       * @param args
> >>       */
> >>      public static void main(String[] args)
> >>      {
> >>              try
> >>              {
> >>                      PackageBuilder builder = new PackageBuilder();
> >>                      builder.addPackageFromDrl(DRL);
> >>                      RuleBase ruleBase = RuleBaseFactory.newRuleBase();
> >>                      ruleBase.addPackage(builder.getPackage());
> >>                      for (int i = 0; i < 10000; i++)
> >>                      {
> >>                              StatefulSession session =
> ruleBase.newStatefulSession();
> >>                              WorkingMemoryFileLogger logger = new
> >> WorkingMemoryFileLogger(session);
> >>                              logger.setFileName(FICHIER_LOG);
> >>                              session.fireAllRules();
> >>                              logger.writeToDisk();
> >>                              session.dispose();
> >>                      }
> >>
> >>              }
> >>              catch (Exception e)
> >>              {
> >>                      // TODO Auto-generated catch block
> >>                      e.printStackTrace();
> >>              }
> >>      }
> >> }
> >>
> >> with this rule (doesn't matter):
> >> #created on: Fri Nov 09 15:48:45 CET 2007
> >> package initPackage
> >>
> >> #list any import classes here.
> >>
> >> rule "ERG9"
> >> when
> >>
> >> then
> >>
> >> end
> >>
> >> I try this in 4.0.1, and it's working (no OutOfMemoryError)
> >>
> >> What's the problem ?
> >>
> >> thanks for any information,
> >>
> >> V.
> >>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/java.lang.OutOfMemoryError%3A-Java-heap-space-tf4779030.html#a13702134
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> 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/20071112/1f1c3a71/attachment-0001.html

------------------------------

Message: 3
Date: Mon, 12 Nov 2007 20:30:14 +0000
From: Mark Proctor <mproctor at codehaus.org>
Subject: Re: [rules-users] Drools and jBPM integration
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID: <4738B7D6.6060306 at codehaus.org>
Content-Type: text/plain; charset="iso-8859-1"

Aziz Boxwala wrote:
> 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.
We just take a Reader, so the file can be anywhere. In our examples we
tend to put stuff in the classpath as it makes for very easy loading.
>
> 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.Re <http://java.io.re/> >.Reader.<init>(Unknown Source)
>     at java.io <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
>  

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

------------------------------

Message: 4
Date: Mon, 12 Nov 2007 20:33:59 +0000
From: Mark Proctor <mproctor at codehaus.org>
Subject: Re: [rules-users] Drools and jBPM integration
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID: <4738B8B7.2050309 at codehaus.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Fabian Weisensee wrote:
> 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);
You should read the Drools docuemtation, heck every example we have
shows how to do this, and every example will show
RuleBase ruleBase = RuleBaseFactory.newRuleBase()
ruleBase.addPackage( pkg )

Where the pkg is created from the PackageBuilder class, again this is
all documented with full examples. What you are using, and someone
wrongly documented, was an internal implementation class, you should be
using the interface.
>
> 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.Re <http://java.io.re/> >.Reader.<init>(Unknown Source)
>>     at java.io <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
> _______________________________________________
> rules-users mailing list
> 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


End of rules-users Digest, Vol 12, Issue 27
*******************************************


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 29854 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20071113/dcd216a6/attachment.bin 


More information about the rules-users mailing list