[rules-users] Rules Pattern Map['key'] does not work in trunk

Edson Tirelli tirelli at post.com
Fri Jan 18 11:12:32 EST 2008


   I did not ran your code, but looking at your rules file, I don't see you
updating your container class after changing it's map attribute values:

rule "modify"
#enabled false
ruleflow-group "modify"
salience 20
    when
        c : MyContainer( $map : map  )
    then
        list.add("test" );
        $map.put("test1","test1" );
        $map.put("test2","test2" );
        $map.put("test3","test3" );
        $map.put("test4","test4" );
        System.out.println( drools.getRule());
end

    After you insert values in the map, you must update your container fact
in order for other rules to "see" the changes:

update( c );

    []s
    Edson

2008/1/18, Philokratis <philokratis at gmail.com>:
>
> Hi Edson,
>
>
> I  have not debugged or looked drools internals yet so I am not sure what
> the problem is.
> Please find attached a rules project containing a test Case.
>
> Thanks
>
> On Jan 18, 2008 4:17 PM, Edson Tirelli <tirelli at post.com> wrote:
>
> >
> >    What problem are you seeing?
> >
> >    We do have a few tests for that and they are working in trunk, so,
> > maybe you can provide us the code snippet you are using to test that so that
> > I can reproduce the problem in my local machine?
> >
> >    []s
> >    Edson
> >
> > 2008/1/18, Philokratis <philokratis at gmail.com>:
> > >
> > >   Hi guys,
> > >
> > > I have the following rule that does not give the expected result,
> > > I have succesfully tried to bind the map[key] to a variable but again
> > >  '==' does not work as expected.
> > >
> > > Is there any error in the rule or the way Map is used ?
> > >
> > > Thanks
> > > *
> > >
> > > rule
> > > *"report3"
> > >
> > >
> > > *when*
> > >
> > > MyContainer( map[
> > >
> > > 'test1'] == "test1" )
> > >
> > > *then*
> > >
> > > System.out.println( drools.getRule());
> > >
> > > *end*
> > >
> > >
> > >
> > > *MyContainer definition is *
> > >
> > > *public*
> > > *class* MyContainer
> > >
> > > *implements*
> > >
> > > *Serializable {*
> > >
> > > *private Map<String, String> map;*
> > >
> > > *public* Map<String, String> getMap() {
> > >
> > > *return* *this*.map ;
> > >
> > > }
> > >
> > > *public* *void* setMap(Map<String, String> map) {
> > >
> > > *this*.map = map;
> > >
> > > }
> > >
> > > }
> > >
> > > _______________________________________________
> > > rules-users mailing list
> > > rules-users at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/rules-users
> > >
> > >
> >
> >
> > --
> >   Edson Tirelli
> >   JBoss Drools Core Development
> >   Office: +55 11 3529-6000
> >   Mobile: +55 11 9287-5646
> >   JBoss, a division of Red Hat @ www.jboss.com
> > _______________________________________________
> > 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
>
>
>


-- 
  Edson Tirelli
  JBoss Drools Core Development
  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/20080118/a8dc7871/attachment.html 


More information about the rules-users mailing list