+2005-08-04 Helge Hess <helge.hess@skyrix.com>
+
+ * NSPredicate+EO.m: also check 'selectorName' key during unarchiving
+ (v4.5.5)
+
2005-08-04 Helge Hess <helge.hess@opengroupware.org>
* NSExpression+EO.m: added EOKeyValueArchiving (v4.5.4)
/* custom selector */
- selName = [_unarchiver decodeObjectForKey:@"selector"];
+ if ((selName = [_unarchiver decodeObjectForKey:@"selectorName"]) != nil) {
+ if (![selName hasSuffix:@":"])
+ selName = [selName stringByAppendingString:@":"];
+ }
+ else
+ selName = [_unarchiver decodeObjectForKey:@"selector"];
if ([selName length] > 0) {
return [self initWithLeftExpression:left rightExpression:right
- customSelector:NSSelectorFromString(selName)];
+ customSelector:selName ? NSSelectorFromString(selName):NULL];
}
/* modifier */
+2005-08-04 Helge Hess <helge.hess@skyrix.com>
+
+ * NGRuleEngine.subproj/NGRuleContext.m: added new method
+ -allPossibleValuesForKey: to calculate all possible values for a
+ given key, not just the first matching one (v4.5.169)
+
2005-08-04 Helge Hess <helge.hess@opengroupware.org>
* EOFilterDataSource.m, EOCompoundDataSource.m: code cleanups
- (id)valueForKey:(NSString *)_key;
- (id)inferredValueForKey:(NSString *)_key;
+- (NSArray *)allPossibleValuesForKey:(NSString *)_key;
- (NSArray *)valuesForKeyPath:(NSString *)_kp
takingSuccessiveValues:(NSArray *)_values
return nil;
}
+- (NSArray *)allPossibleValuesForKey:(NSString *)_key {
+ NSMutableArray *values;
+ NSArray *rules;
+ unsigned i, count;
+
+ if (self->debugOn)
+ [self debugWithFormat:@"calculate all values for key: '%@'", _key];
+
+ /* select candidates */
+ rules = [[self model] candidateRulesForKey:_key];
+ if (self->debugOn)
+ [self debugWithFormat:@" candidate rules: %@", rules];
+
+ values = [NSMutableArray arrayWithCapacity:16];
+
+ /* check qualifiers */
+ for (i = 0, count = [rules count]; i < count; i++) {
+ NGRule *rule;
+
+ rule = [rules objectAtIndex:i];
+ if ([(id<EOQualifierEvaluation>)[rule qualifier] evaluateWithObject:self]){
+ id v;
+
+ if (self->debugOn)
+ [self debugWithFormat:@" rule %i matches: %@", i, rule];
+
+ v = [[rule action] fireInContext:self];
+ [values addObject:(v ? v : [NSNull null])];
+ }
+ }
+ if (self->debugOn)
+ [self debugWithFormat:@" %d rules matched.", [values count]];
+ return values;
+}
+
- (id)valueForKey:(NSString *)_key {
id v;
+
+ // TODO: add rule cache?
/* look for constants */
- if ((v = [self->storedValues objectForKey:_key]))
+ if ((v = [self->storedValues objectForKey:_key]) != nil)
return v;
/* look into rule system */
- if ((v = [self inferredValueForKey:_key]))
+ if ((v = [self inferredValueForKey:_key]) != nil)
return v;
return nil;