From: helge Date: Tue, 2 Aug 2005 22:17:20 +0000 (+0000) Subject: map EOControl to CoreData X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff7fae33959e41ebda7ab1f68f4b274b04df7e0b;p=sope map EOControl to CoreData git-svn-id: http://svn.opengroupware.org/SOPE/trunk@959 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/mod_ngobjweb/handler.c b/sope-appserver/mod_ngobjweb/handler.c index ce100333..1476b29a 100644 --- a/sope-appserver/mod_ngobjweb/handler.c +++ b/sope-appserver/mod_ngobjweb/handler.c @@ -266,7 +266,7 @@ int ngobjweb_handler(request_rec *r) { uri = r->uri; requestContentLength = 0; requestBody = NULL; - + #ifndef AP_VERSION_1 if (r->handler == NULL) return DECLINED; diff --git a/sope-appserver/samples/CoreDataBlog/ChangeLog b/sope-appserver/samples/CoreDataBlog/ChangeLog index 7aeb8c50..bbb6ed54 100644 --- a/sope-appserver/samples/CoreDataBlog/ChangeLog +++ b/sope-appserver/samples/CoreDataBlog/ChangeLog @@ -1,3 +1,7 @@ +2005-08-03 Helge Hess + + * added classes to map EOControl objects to CoreData ones + 2005-08-01 Helge Hess * started CoreData demo diff --git a/sope-appserver/samples/CoreDataBlog/EOFetchSpecification+CoreData.h b/sope-appserver/samples/CoreDataBlog/EOFetchSpecification+CoreData.h new file mode 100644 index 00000000..6d143e6e --- /dev/null +++ b/sope-appserver/samples/CoreDataBlog/EOFetchSpecification+CoreData.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __EOFetchSpecification_CoreData_H__ +#define __EOFetchSpecification_CoreData_H__ + +#include + +/* + EOFetchSpecification(CoreData) + + Convert an libEOControl EOFetchSpecification to a CoreData compliant fetch + specification. + + A major difference is that a CoreData NSFetchRequest takes the entity object + while in EOF we just pass the name of it. +*/ + +@class NSArray; +@class NSFetchRequest, NSManagedObjectModel; + +@interface EOFetchSpecification(CoreData) + +- (NSFetchRequest *)fetchRequestWithModel:(NSManagedObjectModel *)_model; +- (NSArray *)sortOrderingsAsSortDescriptors; + +@end + +#endif /* __EOFetchSpecification_CoreData_H__ */ diff --git a/sope-appserver/samples/CoreDataBlog/EOFetchSpecification+CoreData.m b/sope-appserver/samples/CoreDataBlog/EOFetchSpecification+CoreData.m new file mode 100644 index 00000000..be52a1ba --- /dev/null +++ b/sope-appserver/samples/CoreDataBlog/EOFetchSpecification+CoreData.m @@ -0,0 +1,65 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "EOFetchSpecification+CoreData.h" +#include "EOSortOrdering+CoreData.h" +#include "EOQualifier+CoreData.h" +#include "common.h" + + +@implementation EOFetchSpecification(CoreData) + +- (NSArray *)sortOrderingsAsSortDescriptors { + NSMutableArray *ma; + NSArray *a; + unsigned i, count; + + if ((a = [self sortOrderings]) == nil) + return nil; + if ((count = [a count]) == 0) + return nil; + + if (count == 1) /* common, optimization */ + return [NSArray arrayWithObject:[[a objectAtIndex:0] asSortDescriptor]]; + + ma = [NSMutableArray arrayWithCapacity:count]; + for (i = 0; i < count; i++) + [ma addObject:[[a objectAtIndex:i] asSortDescriptor]]; + return ma; +} + +- (NSFetchRequest *)fetchRequestWithModel:(NSManagedObjectModel *)_model { + NSFetchRequest *fr; + NSString *s; + + fr = [[[NSFetchRequest alloc] init] autorelease]; + + if ((s = [self entityName]) != nil) + [fr setEntity:[[_model entitiesByName] objectForKey:s]]; + + [fr setFetchLimit:[self fetchLimit]]; + [fr setPredicate:[[self qualifier] asPredicate]]; + [fr setSortDescriptors:[self sortOrderingsAsSortDescriptors]]; + + return fr; +} + +@end /* EOFetchSpecification(CoreData) */ diff --git a/sope-appserver/samples/CoreDataBlog/EOQualifier+CoreData.h b/sope-appserver/samples/CoreDataBlog/EOQualifier+CoreData.h new file mode 100644 index 00000000..b47887bc --- /dev/null +++ b/sope-appserver/samples/CoreDataBlog/EOQualifier+CoreData.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __EOQualifier_CoreData_H__ +#define __EOQualifier_CoreData_H__ + +#include + +/* + EOQualifier(CoreData) + + Convert an libEOControl EOQualifier to a CoreData compliant NSPredicate + object. +*/ + +@class NSPredicate; + +@interface EOQualifier(CoreData) + +- (NSPredicate *)asPredicate; + +@end + +#endif /* __EOQualifier_CoreData_H__ */ diff --git a/sope-appserver/samples/CoreDataBlog/EOQualifier+CoreData.m b/sope-appserver/samples/CoreDataBlog/EOQualifier+CoreData.m new file mode 100644 index 00000000..2b7ea032 --- /dev/null +++ b/sope-appserver/samples/CoreDataBlog/EOQualifier+CoreData.m @@ -0,0 +1,33 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "EOQualifier+CoreData.h" +#include "common.h" + +@implementation EOQualifier(CoreData) + +- (NSPredicate *)asPredicate { +#warning IMPLEMENT ME + [self logWithFormat:@"TODO: AS PREDICATE ..."]; + return nil; +} + +@end /* EOQualifier(CoreData) */ diff --git a/sope-appserver/samples/CoreDataBlog/EOSortOrdering+CoreData.h b/sope-appserver/samples/CoreDataBlog/EOSortOrdering+CoreData.h new file mode 100644 index 00000000..c0aa76ea --- /dev/null +++ b/sope-appserver/samples/CoreDataBlog/EOSortOrdering+CoreData.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __EOSortOrdering_CoreData_H__ +#define __EOSortOrdering_CoreData_H__ + +#include + +/* + EOSortOrdering(CoreData) + + Convert an libEOControl EOSortOrdering to a CoreData compliant + NSSortDescriptor object. +*/ + +@class NSSortDescriptor; + +@interface EOSortOrdering(CoreData) + +- (NSSortDescriptor *)asSortDescriptor; + +@end + +#endif /* __EOSortOrdering_CoreData_H__ */ diff --git a/sope-appserver/samples/CoreDataBlog/EOSortOrdering+CoreData.m b/sope-appserver/samples/CoreDataBlog/EOSortOrdering+CoreData.m new file mode 100644 index 00000000..c52c94b4 --- /dev/null +++ b/sope-appserver/samples/CoreDataBlog/EOSortOrdering+CoreData.m @@ -0,0 +1,32 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of SOPE. + + SOPE is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + SOPE is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with SOPE; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "EOSortOrdering+CoreData.h" +#include "common.h" + +@implementation EOSortOrdering(CoreData) + +- (NSSortDescriptor *)asSortDescriptor { + [self logWithFormat:@"TODO: AS SORT DESCRIPTOR ..."]; + return nil; +} + +@end /* EOSortOrdering(CoreData) */ diff --git a/sope-appserver/samples/CoreDataBlog/GNUmakefile b/sope-appserver/samples/CoreDataBlog/GNUmakefile index 5b1cb2d3..a0e1f1a3 100644 --- a/sope-appserver/samples/CoreDataBlog/GNUmakefile +++ b/sope-appserver/samples/CoreDataBlog/GNUmakefile @@ -6,8 +6,11 @@ include $(GNUSTEP_MAKEFILES)/common.make WOAPP_NAME = CoreDataBlog CoreDataBlog_OBJC_FILES += \ - WOCoreDataApplication.m \ - WOSession+CoreData.m \ + WOCoreDataApplication.m \ + WOSession+CoreData.m \ + EOFetchSpecification+CoreData.m \ + EOQualifier+CoreData.m \ + EOSortOrdering+CoreData.m \ \ CoreDataBlog.m \ Session.m \