• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Limiting EOGenericRecord Relationship with a Session Value?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Limiting EOGenericRecord Relationship with a Session Value?


  • Subject: Re: Limiting EOGenericRecord Relationship with a Session Value?
  • From: arturo <email@hidden>
  • Date: Tue, 25 Nov 2003 11:10:04 -0500

----- Original Message -----
From: "Paul Mathews" <email@hidden>
To: <email@hidden>
Sent: Tuesday, November 25, 2003 10:27 AM
Subject: Limiting EOGenericRecord Relationship with a Session Value?


> Hi all
>
> I was hoping for some advice, being somewhat new to webobjects.
>
> I have a model that is in the form
>
>    Building    <--->>   Room
>          ^                         ^
>           |                          |
>          v                         v
>          v                         v
>    Person_Building     Person_Room
>           ^                           ^
>           ^                           ^
>            |                            |
>            -- >  Person  <----
>
> Basically a there are many buildings with many rooms in each. A Person can
be
> granted access to a Building and a limit number of rooms within the
building.

Your model above has a denormalization in it.  You know what buildings a
person
has been granted access to because that person has access to a room within
it.
Given this I don't see why you need Person_Building.

>
> No in displaying this I was using a Repetition to display the Buldings in
a
> list and setting the masterObject to the Person logged in. The Person
object
> is kept in the Session object.
>
> The problem is when I use a second repetition to display the Rooms for the
> build (well that part is easy) but to limit the list of room to the Person
> that is logged in is where I am comming apart.
>
> 1. Is there a better way to structure this model ?

See above.

>
> 2 I have tried adding a custom routine to the Building.java class module.
The
> problem there if I try and access the session().PersionID() routine it
> complains about session being unknown. The routine is as follows...

If PersonID is the primary key for person then you're definitely headed down
the
wrong path.  You should have an EO named Person.  That should be stored in
session.  With a relationship  from Person to Room you don't need a fetch
spec.
You just traverse by writing something like
        NSArray roomsAvailable = aPerson.myRooms();

Then you can get buildings by doing something like (pseudo-codish)
        NSMutableSet bldgs = new NSMutableSet();
        //iterate over rooms from roomsAvailable.
        for (int i = 0; i < roomsAvailable.count(); i++)

bldgs.add(((Building)roomsAvailable.objectAtIndex(i)).building());

No fetch specs necessary.  Too databasey.  Use the model, Paul :-)
>
> public class Building extends EOGenericRecord {
>  ...
>
>     /** @TypeInfo Room */
>     public NSArray myRooms() {
>         NSMutableDictionary d = new NSMutableDictionary();
>
> ->        // Session s = (Session) session(); !!! Error !!!
>
> ->        d.takeValueForKey(s.PersonID, "personName");
>         d.takeValueForKey(this.roomName(), "roomName");
>
>         EOModelGroup mg = EOModelGroup.defaultGroup();
>         EOFetchSpecification fs =
mg.fetchSpecificationNamed("myrooms","Room");
>         fs = fs.fetchSpecificationWithQualifierBindings(d);
>
>         EOEditingContext ec = this.editingContext();
>
>         return (NSArray)ec.objectsWithFetchSpecification(fs);
>     }
> ...
>
> I know know that session() can not be used in a EOGenericRecord, so I was
> wondering if anyone has any other ideas?
>
> Thanks all
>
> These things are hard to describe in a short message, so if more info is
> needed just hammer me with it.
> _______________________________________________
> webobjects-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Limiting EOGenericRecord Relationship with a Session Value? (From: "Paul Mathews" <email@hidden>)

  • Prev by Date: Re: Limiting EOGenericRecord Relationship with a Session Value?
  • Next by Date: Re: Sava a page in session
  • Previous by thread: Limiting EOGenericRecord Relationship with a Session Value?
  • Next by thread: Re: Limiting EOGenericRecord Relationship with a Session Value?
  • Index(es):
    • Date
    • Thread