• 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: eogen takeStoredValueForKey(toManyArray, relationshipName)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: eogen takeStoredValueForKey(toManyArray, relationshipName)


  • Subject: Re: eogen takeStoredValueForKey(toManyArray, relationshipName)
  • From: Ray Kiddy <email@hidden>
  • Date: Mon, 9 Mar 2009 10:06:13 -0700


Cool code-ness.... We probably want to keep this out of Project Wonder so that it can maintain its svelte code size and laser-like focus. Can't just throw any old thing in, can we now? :-)


cheers - ray

On Mar 5, 2009, at 12:21 PM, Kieran Kelleher wrote:

In the past I have written something like this to "diff/merge" the array param with the current relationship array. For example:

<snip>
public void setDataRecordsRelationship( NSArray<CTDataRecord> dataRecordsToSet ) {
if ( dataRecordsToSet == null ) {
NSArray<CTDataRecord> currentDataRecords = dataRecords().immutableClone();
for (CTDataRecord dataRecord : currentDataRecords) {
removeFromDataRecordsRelationship(dataRecord);


dataRecord.deleteIfOrphan();
}
} else if (countDataRecords().intValue() == 0) {
addObjectsToBothSidesOfRelationshipWithKey(dataRecordsToSet, KEY_DATA_RECORDS);


} else {
// Get list of records in relationship that are not in new set
NSArray<CTDataRecord> eosToDelete = ERXArrayUtilities.arrayMinusArray(dataRecords().immutableClone(), dataRecordsToSet);


// Get list of ones to add
NSArray<CTDataRecord> eosToAdd = ERXArrayUtilities .arrayMinusArray (dataRecordsToSet.immutableClone(),dataRecords().immutableClone());


// Perform adds
addObjectsToBothSidesOfRelationshipWithKey(eosToAdd, KEY_DATA_RECORDS);


           // Perform removes/deletes
           for (CTDataRecord dataRecord : eosToDelete) {
               removeFromDataRecordsRelationship(dataRecord);

               dataRecord.deleteIfOrphan();
           }

       }
   }
</snip>




On Mar 5, 2009, at 2:32 PM, Chuck Hill wrote:


On Mar 5, 2009, at 11:00 AM, Anjo Krank wrote:

I have yet to see *one* case where setting an array is actually useful, since AFAIK you can't simply create an array, add a new EO, set this array and expect to get a reasonable object graph.

I think you can actually. I can think of several times that I have done this.





I *did* have a special NSArray class especially for relationships that was "linked" to the EO, in that you could someEO.someRelationship().addObject() to it and it would call up someEO.addObjectToBothSides() for you, but it was a bitch to write (like the two-side relationship stuff).

Cheers, Anjo

Am 03.03.2009 um 04:51 schrieb Chuck Hill:


On Mar 2, 2009, at 7:09 PM, Dan Faber wrote:

I have noticed that the default _wonder.java template does not produce a method to assign an array to a toMany relationship, as:

public void setMyMany(NSArray value) {
	takeStoredValueForKey(value, "myMany");
}

Is there a problem with doing so? Should I change my method to delete all the current relationships, and then loop through the updated array and use "addTo${relationship.capitalizedName}" instead?

Thanks

Dan Faber
email@hidden

This is more of a Wonder question. It is safe WRT to EOF to do this. BUT ERXGenericRecord has some fancy relationship automagic manipulation that may not work. It may work, I don't use it and I don't recall offhand.


Chuck

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden



-- Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >eogen takeStoredValueForKey(toManyArray, relationshipName) (From: Dan Faber <email@hidden>)
 >Re: eogen takeStoredValueForKey(toManyArray, relationshipName) (From: Chuck Hill <email@hidden>)
 >Re: eogen takeStoredValueForKey(toManyArray, relationshipName) (From: Anjo Krank <email@hidden>)
 >Re: eogen takeStoredValueForKey(toManyArray, relationshipName) (From: Chuck Hill <email@hidden>)
 >Re: eogen takeStoredValueForKey(toManyArray, relationshipName) (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Re: Digging up a Session object from an EOGenericRecord
  • Next by Date: Re: Finding eomodels in Eclipse/WOLips
  • Previous by thread: Re: eogen takeStoredValueForKey(toManyArray, relationshipName)
  • Next by thread: Per Session model connection and EOCooperatingObjectStore
  • Index(es):
    • Date
    • Thread