]> err.no Git - sope/commitdiff
more work on EO compatibility
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sat, 6 Aug 2005 17:49:49 +0000 (17:49 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sat, 6 Aug 2005 17:49:49 +0000 (17:49 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@978 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-core/EOCoreData/ChangeLog
sope-core/EOCoreData/GNUmakefile
sope-core/EOCoreData/NSAttributeDescription+EO.h [new file with mode: 0644]
sope-core/EOCoreData/NSAttributeDescription+EO.m [new file with mode: 0644]
sope-core/EOCoreData/NSEntityDescription+EO.h
sope-core/EOCoreData/NSEntityDescription+EO.m
sope-core/EOCoreData/NSManagedObject+KVC.m [new file with mode: 0644]
sope-core/EOCoreData/NSRelationshipDescription+EO.h [new file with mode: 0644]
sope-core/EOCoreData/NSRelationshipDescription+EO.m [new file with mode: 0644]
sope-core/EOCoreData/Version

index 4cfdc70a5ea85375082b7056764f6e27106ad7e4..d6d3c700e75c9c3f07aba4a893b6b1bb92199dae 100644 (file)
@@ -1,3 +1,16 @@
+2005-08-06  Helge Hess  <helge.hess@opengroupware.org>
+
+       * v4.5.8
+       
+       * NSEntityDescription+EO.m: added -isReadOnly, -classPropertyNames,
+         -primaryKeyAttributeNames, -relationships, -attributes
+       
+       * added NSAttributeDescription+EO category containing the -width
+         and -allowsNull methods
+
+       * added NSRelationshipDescription+EO category containing the
+         -sourceAttributes method
+       
 2005-08-04  Helge Hess  <helge.hess@opengroupware.org>
 
        * EOCoreDataSource.m: print a warning if no object-context was decoded
index 9834c46ba20813f957005ecf3f96a12d15dd3f6e..f86d5ffa861c2cfdb0b587489012e3f4c0ae1e52 100644 (file)
@@ -11,19 +11,28 @@ libEOCoreData_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBMINOR_VERSION)
 libEOCoreData_HEADER_FILES_DIR         = .
 libEOCoreData_HEADER_FILES_INSTALL_DIR = /EOCoreData
 
-libEOCoreData_HEADER_FILES = \
+
+# headers
+
+libEOCoreData_HEADER_FILES += \
        EOCoreData.h    \
        EOCoreDataSource.h              \
        \
        EOFetchSpecification+CoreData.h \
        EOQualifier+CoreData.h          \
        EOSortOrdering+CoreData.h       \
-       \
+
+libEOCoreData_HEADER_FILES += \
        NSExpression+EO.h               \
        NSPredicate+EO.h                \
        NSEntityDescription+EO.h        \
+       NSAttributeDescription+EO.h     \
+       NSRelationshipDescription+EO.h  \
+
 
-libEOCoreData_OBJC_FILES = \
+# implementations
+
+libEOCoreData_OBJC_FILES += \
        EOCoreDataSource.m                      \
        \
        EOFetchSpecification+CoreData.m         \
@@ -32,10 +41,15 @@ libEOCoreData_OBJC_FILES = \
        EOKeyValueQualifier+CoreData.m          \
        EOKeyComparisonQualifier+CoreData.m     \
        EOCompoundQualifiers.m                  \
-       \
+
+libEOCoreData_OBJC_FILES += \
        NSExpression+EO.m                       \
        NSPredicate+EO.m                        \
        NSEntityDescription+EO.m                \
+       NSAttributeDescription+EO.m             \
+       NSRelationshipDescription+EO.m          \
+       NSManagedObject+KVC.m                   \
+
 
 -include GNUmakefile.preamble
 include $(GNUSTEP_MAKEFILES)/library.make
diff --git a/sope-core/EOCoreData/NSAttributeDescription+EO.h b/sope-core/EOCoreData/NSAttributeDescription+EO.h
new file mode 100644 (file)
index 0000000..467edea
--- /dev/null
@@ -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 __NSAttributeDescription_EO_H__
+#define __NSAttributeDescription_EO_H__
+
+#import <CoreData/NSAttributeDescription.h>
+
+/*
+  NSAttributeDescription(EO)
+  
+  Make an NSAttributeDescription behave like an EOAttribute. This is mostly to
+  make the CoreData model objects work with DirectToWeb and EO at the same 
+  time.
+*/
+
+@interface NSAttributeDescription(EO)
+
+- (unsigned)width;
+- (BOOL)allowsNull;
+
+@end
+
+#endif /* __NSAttributeDescription_EO_H__ */
diff --git a/sope-core/EOCoreData/NSAttributeDescription+EO.m b/sope-core/EOCoreData/NSAttributeDescription+EO.m
new file mode 100644 (file)
index 0000000..88b64fb
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+  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 "NSAttributeDescription+EO.h"
+#import <Foundation/NSComparisonPredicate.h>
+#include "common.h"
+
+@implementation NSAttributeDescription(EO)
+
+- (unsigned)width {
+  /* 
+     This scans for a validation predicate checking for the maximum length. The
+     code looks for:
+     - an NSComparisonPredicate
+     - which has the operator <=
+     - and a keypath LHS with the keypath 'length'
+     
+     Note: only scans one level, does not walk NSCompoundPredicates
+  */
+  NSArray  *preds;
+  unsigned i, count;
+  
+  if ((preds = [self validationPredicates]) == nil)
+    return 0;
+  
+  if ((count = [preds count]) == 0)
+    return 0;
+
+  for (i = 0; i < count; i++) {
+    NSComparisonPredicate *p;
+    
+    p = [preds objectAtIndex:i];
+    if (![p isKindOfClass:[NSComparisonPredicate class]])
+      continue;
+    
+    if ([p predicateOperatorType] != NSLessThanOrEqualToPredicateOperatorType)
+      continue;
+    
+    if (![[[p leftExpression] keyPath] isEqualToString:@"length"])
+      continue;
+    
+    /* found it! */
+    return [[[p rightExpression] constantValue] unsignedIntValue];
+  }
+  return 0;
+}
+
+- (BOOL)allowsNull {
+  return [self isOptional];
+}
+
+@end /* NSAttributeDescription(EO) */
index 965dcc3e7877a4c6cee23531b625353c347addc0..184ecb4baa7e2a2579490f476c1a4034ecf18e38 100644 (file)
@@ -23,6 +23,7 @@
 #define __NSEntityDescription_EO_H__
 
 #import <CoreData/NSEntityDescription.h>
+
 /*
   NSEntityDescription(EO)
   
   the CoreData model objects work with DirectToWeb and EO at the same time.
 */
 
+@class NSString, NSArray;
+
 @interface NSEntityDescription(EO)
 
 - (id)relationshipNamed:(NSString *)_name;
 - (id)attributeNamed:(NSString *)_name;
+- (NSArray *)relationships;
+- (NSArray *)attributes;
+
+- (BOOL)isReadOnly;
+
+- (NSArray *)classPropertyNames;
+- (NSArray *)primaryKeyAttributeNames;
 
 @end
 
index 4151cf027d394d889ddfebfef7091ca182f8fae0..8294855f781be1750923a09be77971348a0f741f 100644 (file)
   return [[self attributesByName] objectForKey:_qname];
 }
 
+- (BOOL)isReadOnly {
+  return NO; /* always read/write, no? */
+}
+- (NSArray *)classPropertyNames {
+  return [[self propertiesByName] allKeys];
+}
+- (NSArray *)primaryKeyAttributeNames {
+  /* such are transparent with CoreData */
+  return nil;
+}
+
+- (NSArray *)attributes {
+  return [[self attributesByName] allValues];
+}
+- (NSArray *)relationships {
+  return [[self relationshipsByName] allValues];
+}
+
 @end /* NSEntityDescription(EO) */
diff --git a/sope-core/EOCoreData/NSManagedObject+KVC.m b/sope-core/EOCoreData/NSManagedObject+KVC.m
new file mode 100644 (file)
index 0000000..3adbf0b
--- /dev/null
@@ -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.
+*/
+
+#import <CoreData/CoreData.h> // Note: just including NSManagedObject is a nogo
+#include "common.h"
+
+@implementation NSManagedObject(KVC)
+
+- (void)takeValue:(id)_value forKey:(NSString *)_key {
+  /* Yes, I know, deprecated. But hey, don't do this to us! */
+  [self setValue:_value forKey:_key];
+}
+
+@end /* NSManagedObject(KVC) */
diff --git a/sope-core/EOCoreData/NSRelationshipDescription+EO.h b/sope-core/EOCoreData/NSRelationshipDescription+EO.h
new file mode 100644 (file)
index 0000000..9fd3881
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+  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 __NSRelationshipDescription_EO_H__
+#define __NSRelationshipDescription_EO_H__
+
+#import <CoreData/NSRelationshipDescription.h>
+
+/*
+  NSRelationshipDescription(EO)
+  
+  Make an NSRelationshipDescription behave like an EORelationship. This is
+  mostly to make the CoreData model objects work with DirectToWeb and EO at 
+  the same time.
+*/
+
+@class NSArray;
+
+@interface NSRelationshipDescription(EO)
+
+- (NSArray *)sourceAttributes;
+
+@end
+
+#endif /* __NSRelationshipDescription_EO_H__ */
diff --git a/sope-core/EOCoreData/NSRelationshipDescription+EO.m b/sope-core/EOCoreData/NSRelationshipDescription+EO.m
new file mode 100644 (file)
index 0000000..9a82aec
--- /dev/null
@@ -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 "NSRelationshipDescription+EO.h"
+#include "common.h"
+
+@implementation NSRelationshipDescription(EO)
+
+- (NSArray *)sourceAttributes {
+  /* such are transparent with CoreData */
+  return nil;
+}
+
+@end /* NSRelationshipDescription(EO) */
index e25d74084dc4c2e2906959e41a066ffe108ef7ca..46a90fece8d9225fe5e08bb0a71cc5146b9dcdf2 100644 (file)
@@ -1,3 +1,3 @@
 # version file
 
-SUBMINOR_VERSION:=7
+SUBMINOR_VERSION:=8