Theodore,

I'm not familiar with D2W so my understanding of the rules is very basic.

Yes, the idea is to use sortedBooks as a list of possible book for a person. 

I would not compute it in awakeFromFetch though because it will be computed 
every time the EO is fetched even just to display it's name on a list. I would 
create a sortedBooks() method instead.

Samuel


> Le 2015-02-02 à 14:21, Theodore Petrosky <tedp...@yahoo.com> a écrit :
> 
> Samuel,
> 
> Ok this gets me in the ball park. In my person entity, I created in my Person 
> entity:
> 
>       NSArray<Book> pertinentBooks = null;
>       NSArray<Book> sortedBooks = null;
> 
> 
>       @Override
>       public void awakeFromFetch(EOEditingContext editingContext) {
>               // TODO Auto-generated method stub
>               super.awakeFromFetch(editingContext);
> 
>               NSArray<Show> shows = 
> PersonShow.SHOW.arrayValueInObject(personShows());
> 
>               @SuppressWarnings("unchecked")
>               NSArray<Book> showBooks = 
> ERXArrayUtilities.flatten(Show.BOOKS.arrayValueInObject(shows));
>               
>               pertinentBooks = 
> Book.INSTRUMENT_FAMILY.eq(this.instrumentFamily()).filtered(showBooks);
>               
>               sortedBooks = Book.BOOK_TITLE.ascs().sorted(pertinentBooks);
>       }
> 
> I put some logs and when a Person is edited, I can get the pertinentBooks 
> array in the person entity. But I have a toMany to BookPerson:
> 
> 100 : pageConfiguration = 'CreateEmbeddedBookPerson' => displayPropertyKeys = 
> ("book",  "isPrimaryPlayer") [com.webobjects.directtoweb.Assignment]
> 100 : (pageConfiguration = 'CreateEmbeddedBookPerson' and propertyKey = 
> 'book') => componentName = "ERD2WEditToOneRelationship" 
> [com.webobjects.directtoweb.Assignment]
> 
> and of course:
> 
> 100 : (propertyType = 'r' and relationship.destinationEntity.name = 'Book') 
> => keyWhenRelationship = "showBook" [com.webobjects.directtoweb.Assignment]
> 
> So I need the list of this relationship to be the sortedBooks from Person. Or 
> maybe send the sortedBooks array as the list element?
> 
> 
> On Feb 2, 2015, at 11:23 AM, Samuel Pelletier <sam...@samkar.com 
> <mailto:sam...@samkar.com>> wrote:
> 
>> Hi,
>> 
>> I would do it in code in the person class using ERXKeys and let EOF do the 
>> required fetched.
>> 
>> // Get all shows for a person
>> NSArray<Show> shows = this.shows();
>> 
>> // Get all book for the person shows, flatten is required because the 
>> initial result is an array of array
>> NSArray<Book> showsBooks = 
>> ERXArrayUtilities.flatten(Show.BOOKS.arrayValueInObject(shows));
>> 
>> //Filter the book for the person Instrument
>> NSArray<Book> pertinentBooks = 
>> Book.INSTRUMENT.eq(this.instrument()).filtered(showsBooks);
>> 
>> // Sort the array before display
>> NSArray<Book> sortedBooks = Book.TITLE.ascs().sorted(pertinentBooks);
>> 
>> Samuel
>> 
>> 
>>> Le 2015-01-29 à 09:12, Theodore Petrosky <tedp...@yahoo.com 
>>> <mailto:tedp...@yahoo.com>> a écrit :
>>> 
>>> I have an Entity Person that has a toMany to Book.
>>> 
>>> When I click the ‘new’ button in my EditRelationshipEmbeddedBookPerson I 
>>> want to limit the popupButton to only those books that this person should 
>>> see.
>>> 
>>> The Person has an instrument. The Book has an instrument. so the popup list 
>>> should be only those books with the same instrument.
>>> 
>>> But one layer deeper. a Person is assigned to one or many Shows. the Books 
>>> belong to a show. So if Person 1 only play one show and plays viola (I know 
>>> its a handicapped Person), the popup list only shows that one book as 
>>> available to assign.
>>> 
>>> I don’t see how to create a fetch spec that i can pass in my Person and 
>>> limit the popup list.
>>> 
>>> Am I clear? We could change the instrument if thinking its a Viola makes 
>>> one squeamish!
>>> 
>>> Ted
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com 
>>> <mailto:Webobjects-dev@lists.apple.com>)
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com 
>>> <https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com>
>>> 
>>> This email sent to sam...@samkar.com
>> 
> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to