2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "EOFetchSpecification+CoreData.h"
23 #include "EOSortOrdering+CoreData.h"
24 #include "EOQualifier+CoreData.h"
28 @implementation EOFetchSpecification(CoreData)
30 - (id)initWithFetchRequest:(NSFetchRequest *)_fr {
35 - (NSArray *)sortOrderingsAsSortDescriptors {
40 if ((a = [self sortOrderings]) == nil)
42 if ((count = [a count]) == 0)
45 if (count == 1) /* common, optimization */
46 return [NSArray arrayWithObject:[[a objectAtIndex:0] asSortDescriptor]];
48 ma = [NSMutableArray arrayWithCapacity:count];
49 for (i = 0; i < count; i++)
50 [ma addObject:[[a objectAtIndex:i] asSortDescriptor]];
54 - (NSFetchRequest *)fetchRequestWithEntity:(NSEntityDescription *)_entity {
57 fr = [[[NSFetchRequest alloc] init] autorelease];
58 [fr setEntity:_entity];
59 [fr setFetchLimit:[self fetchLimit]];
60 [fr setPredicate:[[self qualifier] asPredicate]];
61 [fr setSortDescriptors:[self sortOrderingsAsSortDescriptors]];
65 - (NSFetchRequest *)fetchRequestWithModel:(NSManagedObjectModel *)_model {
66 NSEntityDescription *entity;
69 entity = ((s = [self entityName]) != nil)
70 ? [[_model entitiesByName] objectForKey:s]
73 return [self fetchRequestWithEntity:entity];
76 @end /* EOFetchSpecification(CoreData) */