2 Copyright (C) 2000-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 <NGExtensions/EOFetchSpecification+plist.h>
23 #include <EOControl/EOControl.h>
26 @implementation EOFetchSpecification(plist)
28 - (id)initWithDictionary:(NSDictionary *)_dictionary {
29 if ((self = [self init])) {
32 if ((tmp = [_dictionary objectForKey:@"qualifier"])) {
33 if ([tmp isKindOfClass:[NSDictionary class]])
34 tmp = [EOQualifier qualifierToMatchAllValues:tmp];
36 tmp = [EOQualifier qualifierWithQualifierFormat:tmp];
38 [self setQualifier:tmp];
41 if ((tmp = [_dictionary objectForKey:@"sortOrderings"])) {
45 if ([tmp isKindOfClass:[NSArray class]]) {
46 NSMutableArray *result = nil;
47 NSEnumerator *objEnum;
50 objEnum = [tmp objectEnumerator];
51 result = [NSMutableArray arrayWithCapacity:8];
52 while ((obj = [objEnum nextObject])) {
53 so = [[EOSortOrdering alloc] initWithPropertyList:obj owner:nil];
56 [result addObject:so];
58 sos = [NSArray arrayWithArray:result];
61 so = [[[EOSortOrdering alloc] initWithPropertyList:tmp owner:nil]
65 sos = [NSArray arrayWithObject:so];
67 [self setSortOrderings:sos];
70 if ((tmp = [_dictionary objectForKey:@"fetchLimit"])) {
71 if ([tmp respondsToSelector:@selector(intValue)])
72 [self setFetchLimit:[tmp intValue]];
74 NSLog(@"%s: invalid fetchLimit key !", __PRETTY_FUNCTION__);
77 if ((tmp = [_dictionary objectForKey:@"hints"])) {
78 if ([tmp isKindOfClass:[NSDictionary class]])
81 NSLog(@"%s: invalid hints key !", __PRETTY_FUNCTION__);
84 if ([self->hints objectForKey:@"addDocumentsAsObserver"] == nil) {
85 NSMutableDictionary *hnts;
87 hnts = [[NSMutableDictionary alloc] initWithDictionary:self->hints];
88 [hnts setObject:[NSNumber numberWithBool:NO]
89 forKey:@"addDocumentsAsObserver"];
96 - (id)initWithString:(NSString *)_string {
99 q = [EOQualifier qualifierWithQualifierFormat:_string];
101 return [self initWithEntityName:nil
104 usesDistinct:NO isDeep:NO hints:nil];
107 - (id)initWithPropertyList:(id)_plist owner:(id)_owner {
108 if ([_plist isKindOfClass:[NSDictionary class]])
109 return [self initWithDictionary:_plist];
111 if ([_plist isKindOfClass:[NSString class]])
112 return [self initWithString:_plist];
114 if ([_plist isKindOfClass:[self class]]) {
116 return [_plist copy];
122 - (id)initWithPropertyList:(id)_plist {
123 return [self initWithPropertyList:_plist owner:nil];
126 @end /* EOFetchSpecification(plist) */