]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WODisplayGroup.m
minor improvement to WOHttpAdaptor, bumped framework revisions
[sope] / sope-appserver / NGObjWeb / WODisplayGroup.m
index b727b80b3f7d2bb80575718587d8188ef99d433c..ae3e58ef406217d1613da8b395c84f83217298b1 100644 (file)
@@ -324,10 +324,10 @@ static NSArray  *uint0Array = nil;
 - (id)selectNext {
   unsigned int idx;
   
-  if ([self->displayObjects count] == 0)
+  if (![self->displayObjects isNotEmpty])
     return nil;
   
-  if ([self->selectionIndexes count] == 0) {
+  if (![self->selectionIndexes isNotEmpty]) {
     [self setSelectionIndexes:uint0Array];
     return nil;
   }
@@ -348,10 +348,10 @@ static NSArray  *uint0Array = nil;
 - (id)selectPrevious {
   unsigned int idx;
   
-  if ([self->displayObjects count] == 0)
+  if (![self->displayObjects isNotEmpty])
     return nil;
   
-  if ([self->selectionIndexes count] == 0) {
+  if (![self->selectionIndexes isNotEmpty]) {
     [self setSelectionIndexes:uint0Array];
     return nil;
   }
@@ -511,9 +511,8 @@ static NSArray  *uint0Array = nil;
   
   /* should try to restore selection */
   [self clearSelection];
-  if ([_objects count] > 0 && [self selectsFirstObjectAfterFetch]) {
+  if ([_objects isNotEmpty] && [self selectsFirstObjectAfterFetch])
     [self setSelectionIndexes:uint0Array];
-  }
 }
  
 - (NSArray *)allObjects {
@@ -543,11 +542,11 @@ static NSArray  *uint0Array = nil;
   }
 
   [self updateDisplayedObjects];
-
+  
   if ([self selectsFirstObjectAfterFetch]) {
     [self clearSelection];
     
-    if ([objs count] > 0)
+    if ([objs isNotEmpty])
       [self setSelectedObject:[objs objectAtIndex:0]];
   }
   
@@ -631,7 +630,7 @@ static NSArray  *uint0Array = nil;
   /* construct qualifier for all query-match entries */
   
   keys = [qm keyEnumerator];
-  while ((key = [keys nextObject])) {
+  while ((key = [keys nextObject]) != nil) {
     NSString *op;
     SEL      ops;
     id       value;
@@ -684,13 +683,13 @@ static NSArray  *uint0Array = nil;
   }
 
   /* construct max qualifiers */
-
+  
   keys = [qmax keyEnumerator];
   while ((key = [keys nextObject]) != nil) {
     EOQualifier *q;
     id value;
     
-    value = [qmin objectForKey:key];
+    value = [qmax objectForKey:key];
 
     q = [[EOKeyValueQualifier alloc]
                               initWithKey:key
@@ -700,7 +699,7 @@ static NSArray  *uint0Array = nil;
     [q release];
   }
 
-  if ([quals count] == 0)
+  if (![quals isNotEmpty])
     return nil;
   if ([quals count] == 1)
     return [quals objectAtIndex:0];
@@ -809,36 +808,64 @@ static NSArray  *uint0Array = nil;
 - (void)qualifyDataSource {
   EODataSource *ds;
   EOQualifier  *q;
+  NSDictionary *bindings;
 
-  ds = [self dataSource];
+  if ((ds = [self dataSource]) == nil)
+    [self warnWithFormat:@"no datasource set: %@", NSStringFromSelector(_cmd)];
+
+  /* build qualifier */
   
   if ((q = [self qualifierFromQueryValues]) != nil)
     [self setQualifier:q];
-
-  if ([ds respondsToSelector:@selector(setAuxiliaryQualifier:)])
+  
+  /* set qualifier in datasource */
+  
+  if ([ds respondsToSelector:@selector(setAuxiliaryQualifier:)]) {
     [ds setAuxiliaryQualifier:[self qualifier]];
+    //[self logWithFormat:@"set aux qualifier in %@: %@", ds,[self qualifier]];
+  }
   else if ([ds respondsToSelector:@selector(setQualifier:)])
     [ds setQualifier:[self qualifier]];
   else {
     /* could not qualify ds */
+    [self warnWithFormat:@"could not qualify datasource: %@", ds];
   }
   
-  if ([ds respondsToSelector:@selector(setQualifierBindings:)])
-    [ds setQualifierBindings:[self queryBindings]];
+  /* set bindings in datasource */
+
+  if ([(bindings = [self queryBindings]) isNotEmpty]) {
+    if ([ds respondsToSelector:@selector(setQualifierBindings:)])
+      [ds setQualifierBindings:bindings];
+    else {
+      [self warnWithFormat:@"could not set bindings in datasource %@: %@", 
+             ds, bindings];
+    }
+  }
   
+  /* perform fetch */
+  
+  /* action method, returns 'nil' to stay on page */
   [self fetch];
   
   if ([self inQueryMode])
     [self setInQueryMode:NO];
 }
 
+- (id)qualifyDataSourceAndReturnDisplayCount {
+  /* 
+     This is a 'hack' created because we can't bind (and therefore 'call')
+     'void' methods in .wod files.
+  */
+  [self qualifyDataSource];
+  return [NSNumber numberWithUnsignedInt:[[self displayedObjects] count]];
+}
 
 /* object creation */
 
 - (id)insert {
   unsigned idx;
 
-  idx = [self->selectionIndexes count] > 0
+  idx = [self->selectionIndexes isNotEmpty]
     ? ([[self->selectionIndexes objectAtIndex:0] unsignedIntValue] + 1)
     : [self->objects count];