Show
Ignore:
Timestamp:
05/26/2009 08:33:44 AM (3 years ago)
Author:
gbooker
Message:

If no filter is being used, just fetch all entities in the virtual directories. Since auto-pruning is now in place, we don't have to worry about empty directories.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/CoreData/SapphireFrappliance/FRAppliance/SapphireApplianceController.m

    r838 r841  
    412412NSArray *showEntityFetch(NSManagedObjectContext *moc, NSPredicate *filterPredicate) 
    413413{ 
    414         NSPredicate *fetchPredicate = [NSPredicate predicateWithFormat:@"tvEpisode != nil"]; 
    415         NSPredicate *finalPred; 
    416         if(filterPredicate == nil) 
    417                 finalPred = fetchPredicate; 
    418         else 
    419                 finalPred = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:filterPredicate, fetchPredicate, nil]]; 
    420         NSArray *files = doFetchRequest(SapphireFileMetaDataName, moc, finalPred); 
    421  
    422         NSSet *epIds = [NSSet setWithArray:[files valueForKeyPath:@"tvEpisode.objectID"]]; 
    423         NSPredicate *epPred = [NSPredicate predicateWithFormat:@"SELF IN %@", epIds]; 
    424         NSArray *episodes = doFetchRequest(SapphireEpisodeName, moc, epPred); 
    425  
    426         NSSet *showIds = [NSSet setWithArray:[episodes valueForKeyPath:@"tvShow.objectID"]]; 
    427         NSPredicate *showPred = [NSPredicate predicateWithFormat:@"SELF IN %@", showIds]; 
    428  
     414        NSPredicate *showPred = nil; 
     415        if(filterPredicate != nil) 
     416        { 
     417                NSPredicate *fetchPredicate = [NSPredicate predicateWithFormat:@"tvEpisode != nil"]; 
     418                NSPredicate *finalPred; 
     419                if(filterPredicate == nil) 
     420                        finalPred = fetchPredicate; 
     421                else 
     422                        finalPred = [NSCompoundPredicate andPredicateWithSubpredicates:[NSArray arrayWithObjects:filterPredicate, fetchPredicate, nil]]; 
     423                NSArray *files = doFetchRequest(SapphireFileMetaDataName, moc, finalPred); 
     424                 
     425                NSSet *epIds = [NSSet setWithArray:[files valueForKeyPath:@"tvEpisode.objectID"]]; 
     426                NSPredicate *epPred = [NSPredicate predicateWithFormat:@"SELF IN %@", epIds]; 
     427                NSArray *episodes = doFetchRequest(SapphireEpisodeName, moc, epPred); 
     428                 
     429                NSSet *showIds = [NSSet setWithArray:[episodes valueForKeyPath:@"tvShow.objectID"]]; 
     430                showPred = [NSPredicate predicateWithFormat:@"SELF IN %@", showIds]; 
     431        } 
    429432        return doFetchRequest(SapphireTVShowName, moc, showPred); 
    430433}