/*
        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/GameMedia.h>

@implementation GameMedia

- (NSString *)name {
    return name;
}

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

- (void)awakeFromInsertionInEditingContext:(EOEditingContext *)editingContext
{
    if(!rentalTerms) {
        static EOGlobalID *gid = nil;

        // I'd like to setup some default for rental terms here
        if(!gid) {
            EOFetchSpecification *fetchSpec;
            NSArray *results;

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

            results = [editingContext objectsWithFetchSpecification:fetchSpec
                                                     editingContext:editingContext];

            gid = [editingContext globalIDForObject:[results objectAtIndex:0]];
        }
        rentalTerms = [[editingContext faultForGlobalID:gid
                                         editingContext:editingContext] retain];
    }
}
@end
