/*
        Copyright (c) 1996, NeXT Software, Inc.
        All rights reserved.

        You may freely copy, distribute and reuse the code in this example.
        NeXT disclaims any warranty of any kind, expressed or implied,
        as to its fitness for any particular use.
*/
#import <BusinessLogic/GamePlayer.h>

@implementation GamePlayer

- (NSString *)name {
    return name;
}

- (void)dealloc
{
    [name release];
    [super dealloc];
}

- (void)awakeFromInsertionInEditingContext:(EOEditingContext *)editingContext
{
    // set up default values
    if(!rentalTerms) {
        static EOGlobalID *gid = nil;

        // Fetch default rental terms for new GamePlayers
        if(!gid) {
            EOFetchSpecification *fetchSpec;
            NSArray *results;

            // look up the global ID of the rental term with ID = 14
            fetchSpec = [EOFetchSpecification fetchSpecificationWithEntityName:@"RentalTerms"
                        qualifier:[EOQualifier qualifierWithQualifierFormat:@"rentalTermID = 14"]
                                                                 sortOrderings:nil];

            results = [editingContext objectsWithFetchSpecification:fetchSpec
                                                     editingContext:editingContext];
            gid = [editingContext globalIDForObject:[results objectAtIndex:0]];
        }
        rentalTerms = [[editingContext faultForGlobalID:gid editingContext:editingContext] retain];
    }
}

@end
