[rules-users] check dups

Edson Tirelli tirelli at post.com
Sat Sep 1 14:01:07 EDT 2007


   Tim,

   It must work. If it is not working, you can provide me a zip with the
code you are using and I can check, but it is something really basic to not
work.

   Regarding iterating the list and asserting individual objects, there are
other options like using "from" to avoid the need of inserting individual
objects, but usually it is better to assert the individual objects.

   I'll not be on-line full time this week, so if you send me the example I
will try to look at it as soon as possible, but no promises.

   []s
   Edson

2007/8/31, Tim.Nguyen at expeditors.com <Tim.Nguyen at expeditors.com>:
>
> Thanks Edson
>
> The trick is that I have to use the list :(. So I iterate the list, then
> insert individual Reference object to the Working memory before I check if
> any dups, but no luck
>
>
>
>
> Best Regards,
> Tim Nguyen
>
>
>
>
>              "Edson Tirelli"
>              <tirelli at post.com
>              >                                                          To
>              Sent by:                  "Rules Users List"
>              rules-users-bounc         <rules-users at lists.jboss.org>
>              es at lists.jboss.or                                          cc
>              g
>                                                                    Subject
>                                        Re: [rules-users] check dups
>              08/31/2007 10:01
>              AM
>
>
>              Please respond to
>              Rules Users List
>              <rules-users at list
>                s.jboss.org>
>
>
>
>
>
>
>
>     Tim,
>
>     Your rule expects to get Reference objects from the working memory,
> and
> they are not there, since you are adding a List of them and not them.
> Insert individual references and it will work.
>
>     []s
>     Edson
>
> 2007/8/31, Tim.Nguyen at expeditors.com <Tim.Nguyen at expeditors.com>:
>
>
>   Here is my test
>
>               Reference ref_test2 = new Reference();
>               ref_test2.setReferenceType(new ReferenceType("MISC"));
>               ref_test2.setReferenceValue("111222");
>
>               Reference ref_test3 = new Reference();
>               ref_test3.setReferenceType(new ReferenceType("MISC"));
>               ref_test3.setReferenceValue("111222");
>
>               references.add(ref_test2);
>               references.add(ref_test2);
>
>
>
>               final StatefulSession session =
>   ruleBase.newStatefulSession();
>               session.insert(references);
>               session.fireAllRules();
>
>
>
>   Thanks!
>   Tim
>
>
>
>                "Edson Tirelli"
>                <tirelli at post.com
>                >
>   To
>                Sent by:                  "Rules Users List"
>                rules-users-bounc         <rules-users at lists.jboss.org>
>                es at lists.jboss.or
>   cc
>                g
>
>   Subject
>                                          Re: [rules-users] check dups
>                08/31/2007 08:57
>                AM
>
>
>                Please respond to
>                Rules Users List
>                <rules-users at list
>                  s.jboss.org >
>
>
>
>
>
>
>
>      Hey Tim,
>
>      Can you please provide a self contained test case? There is no reason
>   why it would not work.
>
>      Thanks
>       Edson
>
>   2007/8/31, Tim.Nguyen at expeditors.com <Tim.Nguyen at expeditors.com>:
>
>
>     Hi List,
>
>     I'd like to check if any duplicate exists in my collection as below:
>
>     rule "check Duplicate"
>           when
>                 ref1: Reference ($type1: referenceType, $value1:
>     referenceValue)
>                 ref2: Reference (this != ref1, referenceType ==
>     $referenceType,
>     referenceValue == $value1)
>
>           then
>                  errorHandler.record("Duplicate Reference is not
>   allowed.");
>     end
>
>
>     Both my referenceType and referenceValue are String. I didn't get any
>     error
>     but it didn't work. Any idea?
>     I am using 4.01 GA
>
>
>     Thanks,
>     Tim
>
>     _______________________________________________
>     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
>   _______________________________________________
>   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
>   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
> _______________________________________________
> 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
  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/20070901/34bc3fdc/attachment.html 


More information about the rules-users mailing list