Re: Implementing an ordered tree

"YL" <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <008701c6211a$d0d71260$6400a8c0@grace>
Although I don't have bad experiences about validateForSave even done some set..methods in it,  I'm thinking of moving thing out there:-)

I've things similar to ordered tree and I'm caching tree path in nodes for searching convenience. 
I also have a hyper relationship  eo<<-->ownerEO specified by two keys: (oidOwner, ownerClassName). when I say anEO.addOwner(ownerEO), I need some general approach of key assigning. since one or both anEO and ownerEO may be newly created (with temp globalID). all these sync problems are better treated right before saveChanges(). 

Thanks

  ----- Original Message ----- 
  From: Joshua Marker 
  To: YL 
  Cc: Karoly Szantai ; WebObjects-Developer List ; [email protected] 
  Sent: Tuesday, January 24, 2006 1:07 AM
  Subject: Re: Implementing an ordered tree


  Except you can't call any set... methods in validateForSave without incurring the wrath of the gods. (Please don't call set methods in validation code. . . I can't believe I got to say this before Chuck Hill responded.)  


  Wrapper methods that perform the behavior you want are what you're after here, I think. Skiena's Algorithm Design Handbook may cover this.






  On Jan 23, 2006, at 9:18, YL wrote:


    validateForSave() is where i would put the logic for re-ordering.

    the idea:
    implement methods
    (1) checkChildrenOrder() that returns false if children array has order
    problem
    (2) resetChildrenOrder() that loop over its children array and set each
    one's order attribute to its index in the array.

    in  validateForSave(), you say

    validateForSave() {
        super().validateForSave();
        if(!checkChildrenOrder()) {
              resetChildrenOrder();
        }
    }

    ----- Original Message -----
    From: "Karoly Szantai" <[email protected]>
    To: <[email protected]>; <[email protected]>
    Sent: Monday, January 23, 2006 4:32 AM
    Subject: Implementing an ordered tree


    > Hello,
    >
    > I have a Category entity. Each Category has zero or more subcategories,
    > which are ordered. There is a root Category (called main category)
    > which has no parent.
    > I have created this EO model:
    >
    > oid
    > oidParentCategory
    > name
    > ordinalNumber
    >
    > parentCategory (oidParentCategory --> oid)
    > subcategories (oid -->> oidParentCategory)
    >
    >
    > I need some hints on how to implement the following operations
    > (methods) with "ordered way":
    >
    > -add a category
    > -delete a category
    > -cut & paste a category (and its subcategories) from one level to
    > another level
    > -reorder categories (move a category in its level)
    > etc.
    >
    > My big headache is manipulating the ordinalNumber attribute in "EO way".
    >
    >
    > Regards,
    > Karoly
    >
    >
    >
    >
    >
    >
    > _______________________________________________
    > WebObjects-dev mailing list
    > [email protected]
    > http://www.omnigroup.com/mailman/listinfo/webobjects-dev
    >
    >
    >
    > --
    > No virus found in this incoming message.
    > Checked by AVG Free Edition.
    > Version: 7.1.375 / Virus Database: 267.14.21/236 - Release Date: 1/20/2006
    >
    >

    _______________________________________________
    WebObjects-dev mailing list
    [email protected]
    http://www.omnigroup.com/mailman/listinfo/webobjects-dev






  ________________________________________________________________
  This message could have been secured by PGP Universal. To secure
  future messages from this sender, please click this link:

  https://keys.pgp.com/b/b.e?r=elim%40pdtnetworks.net&n=y%2Fo%2F74SeZXsPTMAi0k5UUA%3D%3D 


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


  No virus found in this incoming message.
  Checked by AVG Free Edition.
  Version: 7.1.375 / Virus Database: 267.14.22/238 - Release Date: 1/23/2006

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.