[rules-users] drrols type declaration and how are the equals and hashcode for those types implemented...

Edson Tirelli tirelli at post.com
Tue Feb 24 20:30:37 EST 2009


   Yap.

   This was one of the latest pieces of code I've been working on. Basically
Drools continues to support property setting in conf files, system
properties, and directly through the setProperty() method on
KnowledgeBaseConfiguration. What I added was type-safe configuration through
the Options API:

http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/conf/KnowledgeBaseConfigurationTest.java

    Quick example:

        KnowledgeBaseConfiguration kbconf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kbconf.setOption( AssertBehaviorOption.EQUALITY );
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( kbconf
);

    Feedback and help documenting, more than welcome... ;)

    []s
    Edson


2009/2/24 Zoltan Farkas <zoly at daxtechnologies.com>

>  Thanks
>
>
>
> Another thing, I checked the documentation on how to set the assert
> behaviour to equality:
>
>
>
> RuleBaseConfiguration conf = new RuleBaseConfiguration();
>
> conf.setAssertBehaviour( AssertBehaviour.IDENTITY );
>
> conf.setRemoveIdentities( true );
>
> RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
>
>
>
> I am assuming this is how it is done with the old api, how do you do it
> with the new api?
>
>
>
> I am assuming it is somehow done with the new enum AssertBehaviorOption.
> Any idea how is the new way?
>
>
>
> --zoly
>
>
>
>
>
>
>  ------------------------------
>
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Edson Tirelli
> *Sent:* Tuesday, February 24, 2009 1:59 PM
>
> *To:* Rules Users List
> *Subject:* Re: [rules-users] drrols type declaration and how are the
> equals and hashcode for those types implemented...
>
>
>
>
>    The documentation for "fusion" related metadata is in the fusion docs.
> Follow the same link, but look for drools-fusion docs instead of
> drools-expert docs. Feedback welcome, improvement patches welcome too.
>
>    I need to check with Michael what is the status of the support in
> guvnor, but the idea is obviously to support that in there too.
>
>    []s
>    Edson
>
> 2009/2/24 Zoltan Farkas <zoly at daxtechnologies.com>
>
> I could write a patch emphasizing the use of it, but first I would like to
> understand the metadata part.
>
>
>
> The following metadata that I saw on some blogs is also in my interest:
> @role, @timestamp, and the documentation misses them too, I found them only
> in some blog entries.
>
>
>
> Can you point me to any resource (blogs, code …) that can give me a better
> understanding so that I can write something of decent quality?
>
>
>
> Also it would be nice to have metadata support in the guvnor fact model
> builder.
>
>
>
> Thanks
>
>
>
> --zoly
>
>
>  ------------------------------
>
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Edson Tirelli
> *Sent:* Monday, February 23, 2009 7:49 PM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] drrols type declaration and how are the
> equals and hashcode for those types implemented...
>
>
>
>
>       We need to improve docs on that, as it is only mentioned briefly:
>
>
> https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-expert/html/ch07.html#d0e3206
>
>       The @key will do it for you:
>
> declare Person
>     name : String
>     ssn : BigDecimal @key
>     age : int
> end
>
>      Wanna write a quick patch for the docs emphasizing the use of it?
>
>      Thanks,
>
>      []s
>      Edson
>
> 2009/2/23 Zoltan Farkas <zoly at daxtechnologies.com>
>
> declare Person
>
>   name : String
>
>   ssn: BigDecimal
>
>   age : int
>
> end
>
>
>
>
>
> Is there a way to define what field/s identify a Person?
>
>
>
> In the example above I would like to define ssn as the unique indentifier
> for person, so person1 == person2 if person1.ssn == person2.ssn.
>
>
>
> In this case equals would use only the field ssn to determine if 2 person
> objects are equal.
>
> The hashcode should also be based only on the ssn field.
>
>
>
> I want to use Person with assertBehaviour equality…
>
>
>
> Thanks
>
>
>
> --zoly
>
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
>  Edson Tirelli
>  JBoss Drools Core Development
>  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
>
>
>
>
> --
>  Edson Tirelli
>  JBoss Drools Core Development
>  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
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 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/20090224/975f41d6/attachment.html 


More information about the rules-users mailing list