You may need to check your implementation of the interface methods.

For example, I typically copy attributes using one of the EOCopyable utilities and selectively copy relationships that make sense. For each entity, you still have to think through the mechanics of what "copy" actually means for the entity you are dealing with. Chuck Hill is best

For example I have a simple mailing address entity as follows (irrelevant methods removed for clarity of EOCopyable implementation) and that is folloowed by another entity example:

public class CTAddress extends _CTAddress implements GeocodedMailingAddress, GeocodeLevel, EOCopyable, GeoPoint {
.
.
.
    /** EOCopyable interface */
    public EOEnterpriseObject copy() {
        return copy( new NSMutableDictionary() );
    }

    /** EOCopyable interface */
public EOEnterpriseObject copy( NSMutableDictionary copiedObjects ) { return EOCopyable.DefaultImplementation.copy( copiedObjects, this );
    }

    /** EOCopyable interface
        We just copy the CTDataList and related CTDataRecords. */
public EOEnterpriseObject duplicate( NSMutableDictionary copiedObjects ) {
        // First make a copy with attributes only
EOEnterpriseObject theCopy = EOCopyable.Utility.newInstance ( this );
        EOCopyable.Utility.copyAttributes( this , theCopy );

        return theCopy;
    }
.
.
.

}



/** A campaign represents a direct mail campaign. */
public class CTCampaign extends _CTCampaign implements EOCopyable, CampaignBehaviour {
.
.
.
.

    /** EOCopyable interface */
    public EOEnterpriseObject copy() {
        return copy( new NSMutableDictionary() );
    }

    /** EOCopyable interface */
public EOEnterpriseObject copy( NSMutableDictionary copiedObjects ) { return EOCopyable.DefaultImplementation.copy( copiedObjects, this );
    }

    /** EOCopyable interface
        We just copy the CTDataList and related CTDataRecords. */
public EOEnterpriseObject duplicate( NSMutableDictionary copiedObjects ) {
        // First make a copy with attributes only
EOEnterpriseObject theCopy = EOCopyable.Utility.newInstance ( this );
        EOCopyable.Utility.copyAttributes( this, theCopy);

theCopy.addObjectToBothSidesOfRelationshipWithKey( program (), "program" ); theCopy.addObjectToBothSidesOfRelationshipWithKey( location (), "location" ); theCopy.addObjectToBothSidesOfRelationshipWithKey ( mediaTemplate(), "mediaTemplate" );

        // Initialize attributes that should be initialized and not copied
        theCopy.takeValueForKey( null, "campaignCode" );
        theCopy.takeValueForKey( null, "recAddTime" );
        theCopy.takeValueForKey( null, "recAddUser" );
        theCopy.takeValueForKey( null, "recModTime" );
        theCopy.takeValueForKey( null, "recModUser" );
theCopy.takeValueForKey( WORKFLOW_INITIATED_STATE, KEY_WORKFLOW_STATE );

        // Begin Jobsite radius attributes
        // Now here after STrategy implementation
        EOCopyable.Utility.deepCopyRelationship( copiedObjects,
                this,
                theCopy,
                "centroidAddress" );

        EOCopyable.Utility.deepCopyRelationship( copiedObjects,
                this,
                theCopy,
                "centroidPerson" );

        // END Jobsite Radius attributes
if ( log.isDebugEnabled() ) log.debug("Copy = " + theCopy.valueForKey( "toLongString" ) );

        return theCopy;
    }

.
.
.

}



On Jul 4, 2007, at 10:03 AM, David Avendasora wrote:

Hi all,

I've implemented EOCopyable from Practical WebObjects so I can easily clone some of my complicated classes.

The problem is that when I call copy(new NSMutableDictionary()); I get nothing back. If I call EOEnityCopier(ec,this) it works just fine.

Are there any known problems with using this interface?

Thanks!

Dave


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists% 40mac.com

This email sent to [EMAIL PROTECTED]

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

This email sent to [EMAIL PROTECTED]

Reply via email to