Re: ideas to dupe an EO
Re: ideas to dupe an EO
- Subject: Re: ideas to dupe an EO
- From: David Avendasora <email@hidden>
- Date: Sat, 16 Feb 2013 04:52:43 +0800
Hi Ted,
On Feb 16, 2013, at 2:11 AM, Theodore Petrosky <email@hidden> wrote:
> @Override
> public Agenda duplicate(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) {
> Agenda duplicate = ERXCopyable.Utility.modelCopy(copiedObjects, (Agenda) this);
> return duplicate;
> }
Whoops! My Javadoc has lead you astray. Change the "modelCopy" call to "deepCopy". So:
@Override
public Agenda duplicate(NSMutableDictionary<EOGlobalID, ERXCopyable<?>> copiedObjects) {
Agenda duplicate = ERXCopyable.Utility.deepCopy(copiedObjects, (Agenda) this);
return duplicate;
}
In order to use the "modelCopy" method, you need to add entries Agenda's UserInfo dictionary in your EOModel which I'm guessing you haven't done.
Once you've done that, calling anInstanceOfAgenda.copy() will create a new instance of Agenda EO in the same EC as anInstanceOfAgenda and then copy all the attributes and relationships from anInstanceOfAgenda to the new instance. You then need to make all the related Entities implement ERXCopyable as well.
The deepCopy assumes that you want copies of all of Agenda's related EOs also, which may or may not be true (probably not). If it is not true, you will need to change the duplicate method to do what is correct for Agenda and its related EOs. If you have Practical WebObjects, read Chapter 9, with special attention to the Tweaking the Copy Process section on page 264.
Basically, you are going to want to use some combination of the various ERXCopyable.Utility.xxxxCopyRelationship methods where xxxx could be reference, shallow or deep. See the javadoc for an explanation of what each will do.
I hope that helps you!
Dave
>
> I am trying to add a method to my version of the ERMODInspectPage that will create and save a new copy the object().
>
> i'm stuck with the method that fires to duplicate the EO. Could you point me to some code that actually copies?
>
> Ted
>
>
> --- On Fri, 2/15/13, David LeBer <email@hidden> wrote:
>
>> From: David LeBer <email@hidden>
>> Subject: Re: ideas to dupe an EO
>> To: "Theodore Petrosky" <email@hidden>
>> Cc: "WebObjects Development" <email@hidden>
>> Date: Friday, February 15, 2013, 10:51 AM
>> You probably want ERXCopyable.
>>
>> http://www.mail-archive.com/email@hidden/msg52084.html
>>
>> D
>>
>> On 2013-02-15, at 10:42 AM, Theodore Petrosky <email@hidden>
>> wrote:
>>
>>> I am looking for an idea on duping an EO. I've thought
>> of putting a hyperlink on the listPage then I thought of
>> putting a button on the editPage (i am toying with that
>> now).
>>>
>>> I duped ERMODInspectPage and I added a button. If I
>> create a localInstance in a new EC, how can I save this
>> 'new' EO. it isn't a new EO yet just a duplicate in a new
>> editing context. I am looking at ERXEOControlUtilities to
>> see if there are any methods to create a new EO from my old
>> one.
>>>
>>> but some pointing in the right direction would be
>> appreciated.
>>>
>>> Ted
>>> _______________________________________________
>>> 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
>>
>>
>
>
—————————————————————————————
WebObjects - so easy that even Dave Avendasora can do it!™
—————————————————————————————
David Avendasora
Senior Software Abuser
Kaiten, Inc.
_______________________________________________
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