Show
Ignore:
Timestamp:
01/08/2009 09:03:22 PM (3 years ago)
Author:
gbooker
Message:

Switched the the next version of the metadata.
Fixes #264

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/CoreData/SapphireFrappliance/MetaData/SapphireMObjects/SapphireTVShow.m

    r622 r734  
    77#import "NSString-Extensions.h" 
    88#import "SapphireFileSorter.h" 
     9#import "SapphireTVTranslation.h" 
    910 
    1011@implementation SapphireTVShow 
     
    3839        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"showPath == %@", path]; 
    3940        return (SapphireTVShow *)doSingleFetchRequest(SapphireTVShowName, moc, predicate); 
     41} 
     42 
     43+ (void)upgradeV1ShowsFromContext:(NSManagedObjectContext *)oldMoc toContext:(NSManagedObjectContext *)newMoc 
     44{ 
     45        NSArray *oldShows = doFetchRequest(SapphireTVShowName, oldMoc, nil); 
     46        NSEnumerator *showEnum = [oldShows objectEnumerator]; 
     47        NSManagedObject *oldShow; 
     48        while((oldShow = [showEnum nextObject]) != nil) 
     49        { 
     50                SapphireTVShow *newShow = [NSEntityDescription insertNewObjectForEntityForName:SapphireTVShowName inManagedObjectContext:newMoc]; 
     51                newShow.name = [oldShow valueForKey:@"name"]; 
     52                newShow.showDescription = [oldShow valueForKey:@"showDescription"]; 
     53                newShow.showID = [oldShow valueForKey:@"showID"]; 
     54                newShow.showPath = [oldShow valueForKey:@"showPath"]; 
     55                 
     56                NSEnumerator *translationEnum = [[oldShow valueForKey:@"translations"] objectEnumerator]; 
     57                NSManagedObject *translation; 
     58                while((translation = [translationEnum nextObject]) != nil) 
     59                { 
     60                        [SapphireTVTranslation upgradeV1TVTranslation:translation toShow:newShow]; 
     61                } 
     62                 
     63                NSEnumerator *seasonEnum = [[oldShow valueForKey:@"seasons"] objectEnumerator]; 
     64                NSManagedObject *season; 
     65                while((season = [seasonEnum nextObject]) != nil) 
     66                { 
     67                        [SapphireSeason upgradeV1Season:season toShow:newShow];  
     68                } 
     69        } 
    4070} 
    4171