libs-gdl2/EOAccess/EOAttribute.m

1555 lines
38 KiB
Mathematica
Raw Normal View History

/**
EOAttribute.m <title>EOAttribute Class</title>
Copyright (C) 2000-2002 Free Software Foundation, Inc.
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
Date: February 2000
Author: Manuel Guesdon <mguesdon@orange-concept.com>
Date: October 2000
$Revision$
$Date$
<abstract></abstract>
This file is part of the GNUstep Database Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
#include <ctype.h>
#include <string.h>
#ifdef GNUSTEP
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <Foundation/NSUtilities.h>
#include <Foundation/NSArchiver.h>
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSException.h>
#include <Foundation/NSTimeZone.h>
#include <Foundation/NSData.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSDecimalNumber.h>
#include <Foundation/NSValue.h>
#include <Foundation/NSCalendarDate.h>
#include <Foundation/NSDebug.h>
#else
#include <Foundation/Foundation.h>
#endif
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#include <GNUstepBase/GSObjCRuntime.h>
* EOAccess/EOAdaptor.m: Include GNUstep-specific headers for non-GNUstep systems. * EOAccess/EOAdaptorChannel.m: Ditto. * EOAccess/EOAdaptorContext.m: Ditto. * EOAccess/EOAttribute.m: Ditto. * EOAccess/EODatabaseChannel.m: Ditto. * EOAccess/EODatabaseDataSource.m: Ditto. * EOAccess/EOEntity.m: Ditto. * EOAccess/EOModel.m: Ditto. * EOAccess/EOModelGroup.m: Ditto. * EOAccess/EORelationship.m: Ditto. * EOAccess/EOSQLQualifier.m: Ditto. * EOAccess/EOUtilities.m: Ditto. * EOControl/EOAndQualifier.m: Ditto. * EOControl/EOClassDescription.m: Ditto. * EOControl/EODataSource.m: Ditto. * EOControl/EOEditingContext.m: Ditto. * EOControl/EOFault.m: Ditto. * EOControl/EOFaultHandler.m: Ditto. * EOControl/EOFetchSpecification.m: Ditto. * EOControl/EOKeyValueArchiver.m: Ditto. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EOMutableKnownKeyDictionary.m: Ditto. * EOControl/EONSAddOns.m: Ditto. * EOControl/EOObjectStore.m: Ditto. * EOControl/EOObjectStoreCoordinator.m: Ditto. * EOControl/EOObserver.m: Ditto. * EOControl/EOOrQualifier.m: Ditto. * EOControl/EOQualifier.m: Ditto. * EOControl/EOUndoManager.m: Ditto. * EOModeler/EOModelExtensions.m: Ditto. * EOAccess/EOModel.h/m (+/-[EOModel version]) Remove. ([EOModel init]): Handle version internally. ([EOModel encodeTableOfContentsIntoPropertyList:]): Ditto. ([EOModel encodeIntoPropertyList:]): Ditto. * EOAccess/EODatabaseContext.m ([EODatabaseContext dealloc]): Use NSCountHashTable instead of NSCountMapTable on hash table. * EOAccess/EOAttribute.m ([EOAttribute newValueForBytes:length:]): Added casts to avoid warnings. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@18500 72102866-910b-0410-8b05-ffd578937521
2004-01-29 13:23:22 +00:00
#include <GNUstepBase/GSCategories.h>
#endif
2003-03-30 David Ayers <d.ayers@inode.at> * *.h/m, *.h/m): Used #include instead of depricated #import. Avoid including entire library headers. Use export macro where applicable. * EOControl/GNUmakefile: Removed EOKeyValueCodingBase.m/h and EOUndoMananger.h. Added EOArrayDataSource.m/h, EODefines.h and EODepricated.h. * EOControl/EODefines.h: Updated for GDL2 & gnustep-make. * EOControl/EODebug.h: Updated. * EOControl/EODepricated.h: Updated for current state of GDL2. ([NSObject +flushClassKeyBindings]): Added declaration. ([EOClassDescription +setDelegate:]): Added declaration. ([EOClassDescription +delegate]): Added declaration. (EOUndoManager): Moved declaration of interface here. * EOControl/EOKeyValueCoding.m ([EOClassDescription +flushClassKeyBindings]): Added empty implementation. ([NSObject takeStoredValuesFromDictionary:]): Cache EONull instance and use it instead of isKindOfClass:. * EOControl/EOEditingContext.m ([EOEditingContext +initialize]): Tidied. ([EOEditingContest -deleteObject]): Use NSUndoManager instead of EOUndoManager. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Added minor optimization tweak. * EOControl/EOClassDescription.m: Removed inactive commented code. Added private declerations of EOAccess methods to avoid compiler warnings. ([EOClassDescription +initialize]): Tidied. ([EOClassDescription -classDescriptionForClass:]): Use GSObjCName() instead of objc runtime routines. * EOControl/EOFault.m: Exchanged direct usages of ObjC runtime routines with NS/GSObjCRuntime abstraction API. ([EOFault +superclass]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -respondsToSelector:]): Ditto. ([EOFault +initialize]): Cache static class variable. ([EOFault +isKindOfClass]): Use static class variable. ([EOFault +handlerForFault:]): Ditto. ([EOFault +targetClassForFault:]): Ditto. ([EOFault -dealloc]): Ditto. * EOControl/EOGenericRecord.m: ([EOGenericRecord +initialize]): Tidied. * EOControl/EOKeyComparisonQualifier.m: Tidied documentation. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EONSAddOns.h/m: Added declarations to surpress compiler warnings. ([NSObject -eoCompareOnName:]): Adjusted casts to surpress compiler warnings. (GSUseStrictWO451Compatibility): Added function. (GDL2GlobalLock, GDL2GlobalRecursive): Ditto. * EOControl/EONull: Remove implementations for foundation libraries without key value coding and fully rely on NSNull. Added assertions in all intance methods as instances should never be created. ([EONull +allocWithZone:]) Corrected method name so it will actually be used. * EOControl/EOSortOrdering.m ([NSArray sortedArrayUsingKeyOrderArray:]): Tidied. ([NSMutableArray sortUsingKeyOrderArray:]): Ditto. ([EONull compareAscending:]): Sync with referencs implementation. ([EONull compareDescending:]): Ditto. ([EONull compareCaseInsensitiveAscending:]): Ditto. ([EONull compareCaseInsensitiveDescending:]): Ditto. * EOAccess/EOAdaptor.h: Added comment about API compatibility. * EOAccess/EOAdaptor.m ([EOAdaptor -contexts]): Return array of adaptor contexts rather tham GC-wrapper objects containing adaptor contexts. ([EOAdaptor -databaseEncoding]): Use GSEncodingName() instead of GetEncodingName(). * EOAccess/EODatabaseContext.m ([EODatabaseContext -_turnFault:gid:editingContext:isComplete:]): Use GSObjCClass() instead of trying to access isa by dereferencing from id with incorrect member. * EOAccess/EOModel.m ([EOModel -entityNames]): Sort returned array to insure comparable output. * EOAccess/EOSQLExpression.m ([EOSQLExpression sqlStringForArrayOfQualifiers:operation:]): Added cast to surpress compiler warning. * EOAccess/EOUtilities.m ([EOObjectStoreCoordinator setModelGroup:]): Ditto. * EOAccess/EORelationship.h ([EORelationship -docComment]): Added declaration. * EOAccess/GNUmakefile: Added EODefines.h and EODepricated.h. * Tools/*.m: Use RCS_ID macro. * Tools/EOAttribute+GSDoc.h: ([EOAttribute gsdocContentWithTagName:idPtr:]): Corrected Typo. * Tools/EOModel+GSDoc.h/m: ([EOModel gsdocContentSplittedByEntities:idPtr:]): Ditto. * Tools/EORelationship+GSDoc.m: ([EORelationship gsdocContentWithTagName:idPtr:]): Change variable type to supress compiler warnings. * Tools/eoutil.m (dump): Initialize variables to supress compiler warnings. * Tools/gsdoc-model.m: Include GSCategories.h to supress compiler warnings. (main): Added cast to supress compiler warning. Fixed typo in method invocation. 2003-03-25 Stephane Corthesy <stephane@sente.ch> * EOControl/EODefines.h: Added new file for export/win32 support. * EOControl/EODepricated.h: Added new file for depricated features. * EOControl/EOControl.h: Added EOArrayDataSource.h and EODefines.h. * EOControl/EOArrayDataSource.h/m: Added new files. Some methods (<NSCoding> and qualifier bindings) are empty stubs. * EOControl/EODebug.h: Use export macro instead of explicit extern for function and symbol declarations. * EOControl/EOGlobalID.h: Ditto. * EOControl/EONull.h: Ditto. * EOControl/EOObjectStore.h: Ditto. * EOControl/EOOrQualifier.m: Replaced autorelease by AUTORELEASE and fixed typo. * EOControl/EOQualifier.m ([NSArray -filteredArrayUsingQualifier:]): Implemented. * EOControl/EONSAddOns.m: Use volatile in some exception handlers (man longjmp for more info). * EOControl/EOSortOrdering.h/m ([EOSortOrdering -copyWithZone:]): Implemented <NSCopying>. ([EOSortOrdering -encodeWithKeyValueArchiver:]): Implemented. * EOAccess/EODefines.h: Added new file for export/win32 support. * EOAccess/EODepricated.h: Added new file for depricated features. * EOAccess/EOAccess.h: Added EODefines.h. * EOAccess/EOSQLExpression.h/m: Fixed typo for EOPrimaryKeyConstraintKey. * EOAccess/EOExpressionArray.h/m: Use volatile for variables usein in exception handlers. (man longjmp for more info) * EOAccess/EODatabase.h: Use export macro instead of explicit extern for function and symbol declarations. * EOAccess/EOEntity.h: Ditto. * EOAccess/EOModel.h: Ditto. * EOAccess/EOSchemaGeneration.h: Ditto. * EOAccess/EOSQLExpression.h: Ditto. * EOAccess/EOUtilities.h: Ditto. * Tools/eoutil.m (dump): Implemented use of -postinstall option. Corrected bug when getting adaptor's expression class. Renamed symbol EOPrimaryKeyContraintsKey into EOPrimaryKeyConstraintsKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16298 72102866-910b-0410-8b05-ffd578937521
2003-03-31 00:24:15 +00:00
#include <EOControl/EONull.h>
#include <EOControl/EOObserver.h>
#include <EOControl/EODebug.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOStoredProcedure.h>
#include <EOAccess/EORelationship.h>
#include <EOAccess/EOExpressionArray.h>
#include <string.h>
* EOAccess/EOAccessFault.m: Include privat headers locally. * EOAccess/EOAdaptor.m: Ditto. * EOAccess/EOAdaptorChannel.m: Ditto. * EOAccess/EOAdaptorContext.m: Ditto. * EOAccess/EOAttribute.m: Ditto. * EOAccess/EODatabaseChannel.m: Ditto. * EOAccess/EODatabaseContext.m: Ditto. * EOAccess/EODatabaseOperation.m: Ditto. * EOAccess/EOModel.m: Ditto. * EOAccess/EORelationship.m: Ditto. * EOAccess/EOSQLExpression.m: Ditto. * EOAccess/EOSQLQualifier.m: Ditto. * EOAccess/EOEntity.h: Remove declarations of privat methods. Reorder declaraions. (+[entity], +[entityWithPropertyList:owner:]): Deprecate. (-[sharedObjectFetchSpecificationNames]): New method. (-[setSharedObjectFetchSpecificationsByName:]: Ditto. (-[addSharedObjectFetchSpecificationByName:]: Ditto. (-[removeSharedObjectFetchSpecificationByName:]: Ditto. * EOAccess/EOEntityPriv.h: Add declarations of privat methods. Reorder declarations. * EOAccess/EOEntity.m: Reorder implementations according to headers. Include privat headers locally. (+[entity], +[entityWithPropertyList:owner:]): Deprecate. (-[sharedObjectFetchSpecificationNames]): New method. (-[setSharedObjectFetchSpecificationsByName:]: Ditto. (-[addSharedObjectFetchSpecificationByName:]: Ditto. (-[removeSharedObjectFetchSpecificationByName:]: Ditto. * EOAccess/EOEntity.m: Adapt usage of deprecated -[entity...] and privat methods. * EOAccess/EOModel.m: Ditto. * EOAdaptors/Postgres95/Postgres95SQLExpression.m: Ditto. * TODO: Add comment. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@19772 72102866-910b-0410-8b05-ffd578937521
2004-07-23 18:33:29 +00:00
#include "EOEntityPriv.h"
#include "EOAttributePriv.h"
@implementation EOAttribute
static EONull *null = nil;
static Class NSStringClass;
static Class NSNumberClass;
static Class NSDecimalNumberClass;
static Class NSDataClass;
static Class NSDateClass;
static Class NSCalendarDateClass;
+ (void)initialize
{
if (null == nil)
{
null = [EONull null];
NSStringClass = [NSString class];
NSNumberClass = [NSNumber class];
NSDecimalNumberClass = [NSDecimalNumber class];
NSDataClass = [NSData class];
NSDateClass = [NSDate class];
NSCalendarDateClass = [NSCalendarDate class];
}
}
+ (id) attributeWithPropertyList: (NSDictionary *)propertyList
owner: (id)owner
{
return [[[self alloc] initWithPropertyList: propertyList
owner: owner] autorelease];
}
- (id) initWithPropertyList: (NSDictionary *)propertyList
owner: (id)owner
{
if ((self = [self init]))
{
//OK
NSString *tmpString;
id tmpObject = nil;
[self setName: [propertyList objectForKey: @"name"]];
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs(@"gsdb", @"Attribute parent=%p %@",
owner, [(EOEntity *)owner name]);
[self setParent: owner];
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
// EOFLOGObjectLevel(@"gsdb", @"Attribute Entity=%@", [self entity]);
[self setExternalType: [propertyList objectForKey: @"externalType"]];
tmpString = [propertyList objectForKey: @"allowsNull"];
if (tmpString)
[self setAllowsNull: [tmpString isEqual: @"Y"]];
[self setValueType: [propertyList objectForKey: @"valueType"]];
[self setValueClassName: [propertyList objectForKey: @"valueClassName"]];
tmpString = [propertyList objectForKey: @"writeFormat"];
if (tmpString)
[self setWriteFormat: tmpString];
else
{
tmpString = [propertyList objectForKey: @"updateFormat"];
if (tmpString)
[self setWriteFormat: tmpString];
else
{
tmpString = [propertyList objectForKey: @"insertFormat"];
if (tmpString)
[self setWriteFormat: tmpString];
}
}
tmpString = [propertyList objectForKey: @"readFormat"];
if (tmpString)
[self setReadFormat: tmpString];
else
{
tmpString = [propertyList objectForKey: @"selectFormat"];
[self setReadFormat: tmpString];
}
/*
tmpString = [propertyList objectForKey: @"maximumLength"];
if (tmpString)
[self setMaximumLength: [tmpString intValue]];
*/
tmpString = [propertyList objectForKey: @"width"];
if (tmpString)
[self setWidth: [tmpString intValue]];
tmpString = [propertyList objectForKey: @"valueFactoryMethodName"];
if (tmpString)
[self setValueFactoryMethodName: tmpString];
tmpString = [propertyList objectForKey: @"adaptorValueConversionMethodName"];
if (tmpString)
[self setAdaptorValueConversionMethodName: tmpString];
tmpString = [propertyList objectForKey: @"factoryMethodArgumentType"];
if(tmpString)
{
EOFactoryMethodArgumentType argType = EOFactoryMethodArgumentIsBytes;
if ([tmpString isEqual: @"EOFactoryMethodArgumentIsNSData"])
argType = EOFactoryMethodArgumentIsNSData;
else if ([tmpString isEqual: @"EOFactoryMethodArgumentIsNSString"])
argType = EOFactoryMethodArgumentIsNSString;
[self setFactoryMethodArgumentType: argType];
}
tmpString = [propertyList objectForKey: @"precision"];
if (tmpString)
[self setPrecision: [tmpString intValue]];
tmpString = [propertyList objectForKey: @"scale"];
if (tmpString)
[self setScale: [tmpString intValue]];
tmpString = [propertyList objectForKey: @"serverTimeZone"];
if (tmpString)
[self setServerTimeZone: [NSTimeZone timeZoneWithName: tmpString]];
tmpString = [propertyList objectForKey: @"parameterDirection"];
if (tmpString)
{
if ([tmpString isKindOfClass: NSNumberClass])
{
[self setParameterDirection: [tmpString intValue]];
}
else
{
EOParameterDirection eDirection = EOVoid;
if ([tmpString isEqual: @"in"])
eDirection = EOInParameter;
else if ([tmpString isEqual: @"out"])
eDirection = EOOutParameter;
else if ([tmpString isEqual: @"inout"])
eDirection = EOInOutParameter;
[self setParameterDirection: eDirection];
}
}
tmpObject = [propertyList objectForKey: @"userInfo"];
if (tmpObject)
[self setUserInfo: tmpObject];
else
{
tmpObject = [propertyList objectForKey: @"userDictionary"];
if (tmpObject)
[self setUserInfo: tmpObject];
}
tmpObject = [propertyList objectForKey: @"internalInfo"];
if (tmpObject)
[self setInternalInfo: tmpObject];
tmpString = [propertyList objectForKey: @"docComment"];
if (tmpString)
[self setDocComment: tmpString];
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs(@"gsdb", @"Attribute name=%@", _name);
tmpString = [propertyList objectForKey: @"isReadOnly"];
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs(@"gsdb", @"tmpString=%@", tmpString);
[self setReadOnly: [tmpString isEqual: @"Y"]];
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
EOFLOGObjectLevelArgs(@"gsdb", @"tmpString=%@", tmpString);
}
return self;
}
- (void)awakeWithPropertyList: (NSDictionary *)propertyList
{
//Seems OK
NSString *definition;
NSString *columnName;
NSString *tmpString;
definition = [propertyList objectForKey: @"definition"];
if (definition)
[self setDefinition: definition];
columnName = [propertyList objectForKey: @"columnName"];
if (columnName)
[self setColumnName: columnName];
tmpString = [propertyList objectForKey: @"prototypeName"];
if (tmpString)
{
EOAttribute *attr = [[_parent model] prototypeAttributeNamed: tmpString];
if (attr)
[self setPrototype: attr];
}
EOFLOGObjectLevelArgs(@"gsdb", @"Attribute %@ awakeWithPropertyList:%@",
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
self, propertyList);
}
- (void)encodeIntoPropertyList: (NSMutableDictionary *)propertyList
{
if (_name)
[propertyList setObject: _name forKey: @"name"];
if (_prototype)
[propertyList setObject: [_prototype name] forKey: @"prototypeName"];
if (_serverTimeZone)
[propertyList setObject: [_serverTimeZone name]
forKey: @"serverTimeZone"];
if (_columnName)
[propertyList setObject: _columnName forKey: @"columnName"];
if (_definitionArray)
[propertyList setObject: [_definitionArray definition]
forKey: @"definition"];
if (_externalType)
[propertyList setObject: _externalType forKey: @"externalType"];
if (_valueClassName)
[propertyList setObject: _valueClassName forKey: @"valueClassName"];
if (_valueType)
[propertyList setObject: _valueType forKey: @"valueType"];
if (_valueFactoryMethodName)
{
NSString *methodArg;
[propertyList setObject: _valueFactoryMethodName
forKey: @"valueFactoryMethodName"];
switch (_argumentType)
{
case EOFactoryMethodArgumentIsNSData:
methodArg = @"EOFactoryMethodArgumentIsNSData";
break;
case EOFactoryMethodArgumentIsNSString:
methodArg = @"EOFactoryMethodArgumentIsNSString";
break;
case EOFactoryMethodArgumentIsBytes:
methodArg = @"EOFactoryMethodArgumentIsBytes";
break;
default:
methodArg = nil;
[NSException raise: NSInternalInconsistencyException
format: @"%@ -- %@ 0x%x: Invalid value for _argumentType:%d",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self, _argumentType];
}
[propertyList setObject: methodArg
forKey: @"factoryMethodArgumentType"];
}
if (_adaptorValueConversionMethodName)
[propertyList setObject: _adaptorValueConversionMethodName
forKey: @"adaptorValueConversionMethodName"];
if (_readFormat)
[propertyList setObject: _readFormat forKey: @"readFormat"];
if (_writeFormat)
[propertyList setObject: _writeFormat forKey: @"writeFormat"];
if (_width > 0)
[propertyList setObject: [NSString stringWithFormat:@"%u", _width]
forKey: @"width"];
if (_precision > 0)
[propertyList setObject: [NSString stringWithFormat:@"%hu", _precision]
forKey: @"precision"];
if (_scale != 0)
[propertyList setObject: [NSString stringWithFormat:@"%h<>", _scale]
forKey: @"scale"];
if (_parameterDirection != 0)
[propertyList setObject: [NSString stringWithFormat:@"%d",
(int)_parameterDirection]
forKey: @"parameterDirection"];
if (_userInfo)
[propertyList setObject: _userInfo forKey: @"userInfo"];
if (_docComment)
[propertyList setObject: _docComment forKey: @"docComment"];
if (_flags.isReadOnly)
[propertyList setObject: @"Y"
forKey: @"isReadOnly"];
if (_flags.allowsNull)
[propertyList setObject: @"Y"
forKey: @"allowsNull"];
}
- (void)dealloc
{
DESTROY(_name);
DESTROY(_prototype);
DESTROY(_columnName);
DESTROY(_externalType);
DESTROY(_valueType);
DESTROY(_valueClassName);
DESTROY(_readFormat);
DESTROY(_writeFormat);
DESTROY(_serverTimeZone);
DESTROY(_valueFactoryMethodName);
DESTROY(_adaptorValueConversionMethodName);
DESTROY(_sourceToDestinationKeyMap);
DESTROY(_userInfo);
DESTROY(_internalInfo);
DESTROY(_docComment);
[super dealloc];
}
- (void)gcDecrementRefCountOfContainedObjects
{
EOFLOGObjectFnStart();
[_parent gcDecrementRefCount];
EOFLOGObjectLevel(@"gsdb", @"prototype gcDecrementRefCount");
[_prototype gcDecrementRefCount];
EOFLOGObjectLevel(@"gsdb", @"definitionArray gcDecrementRefCount");
[(id)_definitionArray gcDecrementRefCount];
EOFLOGObjectLevel(@"gsdb", @"realAttribute gcDecrementRefCount");
[_realAttribute gcDecrementRefCount];
EOFLOGObjectFnStop();
}
- (BOOL)gcIncrementRefCountOfContainedObjects
{
if (![super gcIncrementRefCountOfContainedObjects])
return NO;
[_parent gcIncrementRefCount];
[_prototype gcIncrementRefCount];
[(id)_definitionArray gcIncrementRefCount];
[_realAttribute gcIncrementRefCount];
[_parent gcIncrementRefCountOfContainedObjects];
[_prototype gcIncrementRefCountOfContainedObjects];
[(id)_definitionArray gcIncrementRefCountOfContainedObjects];
[_realAttribute gcIncrementRefCountOfContainedObjects];
return YES;
}
- (unsigned)hash
{
return [_name hash];
}
- (NSString *)description
{
NSString *dscr = [NSString stringWithFormat: @"<%s %p - name=%@ entity=%@ columnName=%@ definition=%@ ",
object_get_class_name(self),
(void*)self,
[self name],
[[self entity] name],
[self columnName],
[self definition]];
dscr = [dscr stringByAppendingFormat: @"valueClassName=%@ valueType=%@ externalType=%@ isReadOnly=%s isDerived=%s isFlattened=%s>",
[self valueClassName],
[self valueType],
[self externalType],
([self isReadOnly] ? "YES" : "NO"),
([self isDerived] ? "YES" : "NO"),
([self isFlattened] ? "YES" : "NO")];
return dscr;
}
/* We override GCObjects default implementation
as attributes cannot be copied */
- (id)copyWithZone:(NSZone *)zone
{
[self notImplemented: _cmd];
return nil;
}
- (EOEntity *)entity
{
if (_flags.isParentAnEOEntity)
return _parent;
else
return nil;
}
- (NSString *)name
{
return _name;
}
- (NSString *)columnName
{
if (_columnName)
return _columnName;
return [_prototype columnName];
}
- (NSString *)definition
{
NSString *definition = nil;
// EOFLOGObjectFnStart();
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
// EOFLOGObjectLevel(@"gsdb",@"_definitionArray:%@",_definitionArray);
definition = [_definitionArray valueForSQLExpression: nil];
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
// EOFLOGObjectLevel(@"gsdb",@"definition:%@",definition);
// EOFLOGObjectFnStop();
return definition;
}
- (NSString *)readFormat
{
if (_readFormat)
return _readFormat;
return [_prototype readFormat];
}
- (NSString *)writeFormat
{
if (_writeFormat)
return _writeFormat;
return [_prototype writeFormat];
}
- (NSDictionary *)userInfo
{
return _userInfo;
}
- (NSString *)docComment
{
return _docComment;
}
- (int)scale
{
if (_scale)
return _scale;
if (_prototype)
return [_prototype scale];
return 0;
}
- (unsigned)precision
{
if (_precision)
return _precision;
if (_prototype)
return [_prototype precision];
return 0;
}
- (unsigned)width
{
if (_width)
return _width;
if (_prototype)
return [_prototype width];
return 0;
}
- (id)parent
{
return _parent;
}
- (EOAttribute *)prototype
{
return _prototype;
}
- (NSString *)prototypeName
{
return [_prototype name];
}
- (EOParameterDirection)parameterDirection
{
return _parameterDirection;
}
- (BOOL)allowsNull
{
if (_flags.allowsNull)
return _flags.allowsNull;
if (_prototype)
return [_prototype allowsNull];
return NO;
}
- (BOOL)isKeyDefinedByPrototype:(NSString *)key
{
return NO; // TODO
}
- (EOStoredProcedure *)storedProcedure
{
if ([_parent isKindOfClass: [EOStoredProcedure class]])
return _parent;
return nil;
}
- (BOOL)isReadOnly
{
//call isDerived
if (_flags.isReadOnly)
return _flags.isReadOnly;
if (_prototype)
return [_prototype isReadOnly];
return NO;
}
/**
* Return NO when the attribute corresponds to one SQL column in its entity
* associated table return YES otherwise.
* An attribute with a definition such as
* "anotherAttributeName * 2" is derived.
* A Flattened attribute is also a derived attributes.
**/
- (BOOL)isDerived
{
//Seems OK
if(_definitionArray)
return YES;
return NO;
}
/**
* Returns YES if the attribute is flattened, NO otherwise.
* A flattened attribute is an attribute with a definition
* using a relationship to another entity.
* A Flattened attribute is also a derived attribute.
**/
- (BOOL)isFlattened
{
BOOL isFlattened = NO;
// Seems OK
if(_definitionArray)
isFlattened = [_definitionArray isFlattened];
return isFlattened;
}
- (NSString *)valueClassName
{
if (_valueClassName)
return _valueClassName;
if ([self isFlattened])
return [[_definitionArray realAttribute] valueClassName];
return [_prototype valueClassName];
}
- (NSString *)externalType
{
if (_externalType)
return _externalType;
if ([self isFlattened])
return [[_definitionArray realAttribute] externalType];
return [_prototype externalType];
}
- (NSString *)valueType
{
if (_valueType)
return _valueType;
if([self isFlattened])
return [[_definitionArray realAttribute] valueType];
return [_prototype valueType];
}
@end
@implementation EOAttribute (EOAttributeSQLExpression)
/**
* Returns the value to use in an EOSQLExpression.
**/
- (NSString *) valueForSQLExpression: (EOSQLExpression *)sqlExpression
{
NSString *value=nil;
2003-01-31 Manuel Guesdon <mguesdon@orange-concept.com> * EOAccess/EOAdaptorChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EOAttribute.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs * EOAccess/EODatabaseChannel.m: o replaced NSDebugMLLog by EOFLOGObjectLevel/EOFLOGObjectLevelArgs o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EODatabaseContext.m: o Move registration for EODatabaseChannelNeddedNotification from +load to +initialize. (David Ayers <d.ayers@inode.at>) * EOAccess/EOEntity.m: o in - (void) _setIsEdited, autorelease instead of destroy * EOAccess/EORelationship.m o -validateValue: don't raise not implemented exception o initialize variables in -foreignKeyInDestination * EOAccess/EOSQLExpression.m: o added NSAsserts o use anyRelationshipNamed: instead of relationshipNamed: to find hidden relationships * EOControl/EOClassDescription.m o -displayNameForKey: use -stringWithCapacity instead of +alloc -initWithCapacity (missing autorelease) o -validationExceptionWithFormat: initialize variables o -aggregateExceptionWithExceptions: initialize variables o -aggregateExceptionWithExceptions: autorelease copied value o -exceptionAddingEntriesToUserInfo: initialize variables o -exceptionAddingEntriesToUserInfo: autorelease copied userInfo o -snapshot autorelease copied value o -updateFromSnapshot: autorelease copied value * EOControl/EOFetchSpecification.h: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: * EOControl/EOFetchSpecification.m: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct:isDeep:hints: o added +fetchSpecificationWithEntityName:qualifier:sortOrderings:usesDistinct: o removed +fetchSpecificationNamed:entityNamed: (implemented in EOUtilities) o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOGenericRecord.m o in -eoFormatSizeDictionary: handle /0 o in +eoCalculateAllSizeWith: don't de-fault objects o in +eoCalculateAllSizeWith: manage a local autorelease pool * EOControl/EOKeyValueCoding.h: o added -smartTakeValue:forKey: o -smartTakeValue:forKeyPath: o -storedValuesForKeyPaths: * EOControl/EOGlobalID.m: o Insure that EODatabaseContext is initialized early. (David Ayers <d.ayers@inode.at>) * EOControl/EOQualifier.m: o +operatorSelectorForString:]): Parse 'doesContain' instead of 'contains' (David Ayers <d.ayers@inode.at>) * EOControl/EODebug.m: o include NSDebug.h git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15845 72102866-910b-0410-8b05-ffd578937521
2003-02-01 15:19:56 +00:00
// EOFLOGObjectLevel(@"gsdb",@"EOAttribute %p",self);
NSEmitTODO(); //TODO
if (_definitionArray)
value = [_definitionArray valueForSQLExpression: sqlExpression];
else
value = [self name];
return value;
}
@end
@implementation EOAttribute (EOAttributeEditing)
- (NSException *)validateName:(NSString *)name
{
NSArray *storedProcedures;
const char *p, *s = [name cString];
int exc = 0;
if (!name || ![name length]) exc++;
if (!exc)
{
p = s;
while (*p)
{
if (!isalnum(*p) &&
*p != '@' && *p != '#' && *p != '_' && *p != '$')
{
exc++;
break;
}
p++;
}
if (!exc && *s == '$')
exc++;
if ([[self entity] attributeNamed:name])
exc++;
else if ([[self entity] relationshipNamed:name])
exc++;
else if ((storedProcedures = [[[self entity] model] storedProcedures]))
{
NSEnumerator *stEnum = [storedProcedures objectEnumerator];
EOStoredProcedure *st;
while ((st = [stEnum nextObject]))
{
NSEnumerator *attrEnum;
EOAttribute *attr;
attrEnum = [[st arguments] objectEnumerator];
while ((attr = [attrEnum nextObject]))
{
if ([name isEqualToString: [attr name]])
{
exc++;
break;
}
}
if (exc) break;
}
}
}
if (exc)
return [NSException exceptionWithName: NSInvalidArgumentException
reason: [NSString stringWithFormat:@"%@ -- %@ 0x%x: argument \"%@\" contains invalid chars",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
name]
userInfo: nil];
return nil;
}
- (void)setName: (NSString *)name
{
[[self validateName: name] raise];
ASSIGN(_name, name);
if (_flags.isParentAnEOEntity)
{
[_parent _setIsEdited];
}
}
- (void)setPrototype: (EOAttribute *)prototype
{
ASSIGN(_prototype, prototype);
}
- (void)setColumnName: (NSString *)columnName
{
//seems OK
[self willChange];
ASSIGN(_columnName, columnName);
DESTROY(_definitionArray);
[_parent _setIsEdited];
[self _setOverrideForKeyEnum:1];
}
- (void)_setDefinitionWithoutFlushingCaches: (NSString *)definition
{
EOExpressionArray *expressionArray=nil;
[self willChange];
expressionArray = [_parent _parseDescription: definition
isFormat: NO
arguments: NULL];
expressionArray = [self _normalizeDefinition: expressionArray
path: nil];
/*
//TODO finish
l un est code
entity primaryKeyAttributes (code)
??
[self _removeFromEntityArray:code selector:setPrimaryKeyAttributes:
*/
ASSIGN(_definitionArray, expressionArray);
}
-(id)_normalizeDefinition: (EOExpressionArray*)definition
path: (id)path
{
//TODO
/*
definition _isPropertyPath //NO
count
object atindex
self _normalizeDefinition:ret path:NSArray()
adddobject
if attribute
if isderived //NO
??
ret attr
return nexexp
*/
return definition;
}
- (void)setDefinition:(NSString *)definition
{
if(definition)
{
[self _setDefinitionWithoutFlushingCaches: definition];
[_parent _setIsEdited];
DESTROY(_columnName);//??
}
}
- (void)setReadOnly: (BOOL)yn
{
if(!yn && ([self isDerived] && ![self isFlattened]))
[NSException raise: NSInvalidArgumentException
format: @"%@ -- %@ 0x%x: cannot set to NO while the attribute is derived but not flattened.",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self];
_flags.isReadOnly = yn;
}
- (void)setExternalType: (NSString *)type
{
//OK
[self willChange];
ASSIGN(_externalType, type);
[_parent _setIsEdited];
[self _setOverrideForKeyEnum: 0];//TODO
}
- (void)setValueType: (NSString *)type
{
//OK
[self willChange];
ASSIGN(_valueType, type);
[self _setOverrideForKeyEnum: 4];//TODO
}
- (void)setValueClassName: (NSString *)name
{
//OK
[self willChange];
ASSIGN(_valueClassName, name);
_valueClass = NSClassFromString(_valueClassName);//TODO Do it later !
[self _setOverrideForKeyEnum: 3];//TODO
}
- (void)setWidth: (unsigned)length
{
_width = length;
}
- (void)setPrecision: (unsigned)precision
{
_precision = precision;
}
- (void)setScale: (int)scale
{
_scale = scale;
}
- (void)setAllowsNull: (BOOL)allowsNull
{
//OK
[self willChange];
_flags.allowsNull = allowsNull;
[self _setOverrideForKeyEnum: 15];//TODO
}
- (void)setWriteFormat: (NSString *)string
{
ASSIGN(_writeFormat, string);
}
- (void)setReadFormat: (NSString *)string
{
ASSIGN(_readFormat, string);
}
- (void)setParameterDirection: (EOParameterDirection)parameterDirection
{
_parameterDirection = parameterDirection;
}
- (void)setUserInfo: (NSDictionary *)dictionary
{
//OK
[self willChange];
ASSIGN(_userInfo, dictionary);
[_parent _setIsEdited];
[self _setOverrideForKeyEnum: 10];//TODO
}
- (void)setInternalInfo: (NSDictionary *)dictionary
{
//OK
[self willChange];
ASSIGN(_internalInfo, dictionary);
[_parent _setIsEdited];
[self _setOverrideForKeyEnum: 10]; //TODO
}
- (void)setDocComment: (NSString *)docComment
{
//OK
[self willChange];
ASSIGN(_docComment, docComment);
[_parent _setIsEdited];
}
@end
@implementation EOAttribute (EOBeautifier)
/*+ Make the name conform to the Next naming style
NAME -> name, FIRST_NAME -> firstName +*/
- (void)beautifyName
{
NSArray *listItems;
NSString *newString=[NSMutableString string];
int anz,i;
EOFLOGObjectFnStartOrCond2(@"ModelingClasses", @"EOAttribute");
// Makes the receiver's name conform to a standard convention. Names that conform to this style are all lower-case except for the initial letter of each embedded word other than the first, which is upper case. Thus, "NAME" becomes "name", and "FIRST_NAME" becomes "firstName".
if ((_name) && ([_name length]>0))
{
listItems = [_name componentsSeparatedByString: @"_"];
newString = [newString stringByAppendingString:
[[listItems objectAtIndex: 0] lowercaseString]];
anz = [listItems count];
for(i = 1; i < anz; i++)
{
newString = [newString stringByAppendingString:
[[listItems objectAtIndex: i]
capitalizedString]];
}
//#warning erg<EFBFBD>nzen um alle components (attributes, ...)
// Exception abfangen
NS_DURING
{
[self setName: newString];
}
NS_HANDLER
{
NSLog(@"%@ in Class: EOAttribute , Method: beautifyName >> error : %@",
[localException name], [localException reason]);
}
NS_ENDHANDLER;
}
EOFLOGObjectFnStopOrCond2(@"ModelingClasses", @"EOAttribute");
}
@end
@implementation EOAttribute (EOCalendarDateSupport)
- (NSTimeZone *)serverTimeZone
{
if (_serverTimeZone)
return _serverTimeZone;
return [_prototype serverTimeZone];
}
@end
@implementation EOAttribute (EOCalendarDateSupportEditing)
- (void)setServerTimeZone: (NSTimeZone *)tz
{
ASSIGN(_serverTimeZone, tz);
}
@end
@implementation EOAttribute (EOAttributeValueCreation)
/**
* Returns an NSString or a custom-class value object
* from the supplied set of bytes.
* The Adaptor calls this method during value creation
* when fetching objects from the database.
* For efficiency, the returned value is NOT autoreleased.
**/
- (id)newValueForBytes: (const void *)bytes
length: (int)length
{
NSMethodSignature *aSignature;
NSInvocation *anInvocation;
NSData *value = nil;
Class valueClass = [self _valueClass];
if (valueClass != Nil && valueClass != NSDataClass)
{
switch (_argumentType)
{
case EOFactoryMethodArgumentIsNSData:
value = [[NSData alloc] initWithBytes:bytes length: length]; //For efficiency reasons, the returned value is NOT autoreleased !
if(_valueFactoryMethod != NULL)
* EOAccess/EOAdaptor.m: Include GNUstep-specific headers for non-GNUstep systems. * EOAccess/EOAdaptorChannel.m: Ditto. * EOAccess/EOAdaptorContext.m: Ditto. * EOAccess/EOAttribute.m: Ditto. * EOAccess/EODatabaseChannel.m: Ditto. * EOAccess/EODatabaseDataSource.m: Ditto. * EOAccess/EOEntity.m: Ditto. * EOAccess/EOModel.m: Ditto. * EOAccess/EOModelGroup.m: Ditto. * EOAccess/EORelationship.m: Ditto. * EOAccess/EOSQLQualifier.m: Ditto. * EOAccess/EOUtilities.m: Ditto. * EOControl/EOAndQualifier.m: Ditto. * EOControl/EOClassDescription.m: Ditto. * EOControl/EODataSource.m: Ditto. * EOControl/EOEditingContext.m: Ditto. * EOControl/EOFault.m: Ditto. * EOControl/EOFaultHandler.m: Ditto. * EOControl/EOFetchSpecification.m: Ditto. * EOControl/EOKeyValueArchiver.m: Ditto. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EOMutableKnownKeyDictionary.m: Ditto. * EOControl/EONSAddOns.m: Ditto. * EOControl/EOObjectStore.m: Ditto. * EOControl/EOObjectStoreCoordinator.m: Ditto. * EOControl/EOObserver.m: Ditto. * EOControl/EOOrQualifier.m: Ditto. * EOControl/EOQualifier.m: Ditto. * EOControl/EOUndoManager.m: Ditto. * EOModeler/EOModelExtensions.m: Ditto. * EOAccess/EOModel.h/m (+/-[EOModel version]) Remove. ([EOModel init]): Handle version internally. ([EOModel encodeTableOfContentsIntoPropertyList:]): Ditto. ([EOModel encodeIntoPropertyList:]): Ditto. * EOAccess/EODatabaseContext.m ([EODatabaseContext dealloc]): Use NSCountHashTable instead of NSCountMapTable on hash table. * EOAccess/EOAttribute.m ([EOAttribute newValueForBytes:length:]): Added casts to avoid warnings. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@18500 72102866-910b-0410-8b05-ffd578937521
2004-01-29 13:23:22 +00:00
value = [(id)valueClass performSelector: _valueFactoryMethod
withObject: [value autorelease]];
break;
case EOFactoryMethodArgumentIsBytes:
value = [valueClass alloc];//For efficiency reasons, the returned value is NOT autoreleased !
aSignature =
[valueClass
instanceMethodSignatureForSelector: _valueFactoryMethod];
anInvocation = [NSInvocation
invocationWithMethodSignature: aSignature];
[anInvocation setSelector: _valueFactoryMethod];
[anInvocation setTarget: value];
[anInvocation setArgument: &bytes atIndex: 2];
[anInvocation setArgument: &length atIndex: 3];
[anInvocation invoke];
break;
case EOFactoryMethodArgumentIsNSString:
break;
}
}
if(!value)
value = [[NSData alloc] initWithBytes: bytes length: length];//For efficiency reasons, the returned value is NOT autoreleased !
return value;
}
/**
* Returns a NSString or a custom-class value object
* from the supplied set of bytes using encoding.
* The Adaptor calls this method during value creation
* when fetching objects from the database.
* For efficiency, the returned value is NOT autoreleased.
**/
- (id)newValueForBytes: (const void *)bytes
length: (int)length
encoding: (NSStringEncoding)encoding
{
NSMethodSignature *aSignature;
NSInvocation *anInvocation;
id value = nil;
Class valueClass = [self _valueClass];
if (valueClass != Nil && valueClass != NSStringClass)
{
switch (_argumentType)
{
case EOFactoryMethodArgumentIsNSString:
value = [[NSString alloc] initWithData: [NSData dataWithBytes: bytes
length: length]
encoding: encoding];//For efficiency reasons, the returned value is NOT autoreleased !
* EOAccess/EOAdaptor.m: Include GNUstep-specific headers for non-GNUstep systems. * EOAccess/EOAdaptorChannel.m: Ditto. * EOAccess/EOAdaptorContext.m: Ditto. * EOAccess/EOAttribute.m: Ditto. * EOAccess/EODatabaseChannel.m: Ditto. * EOAccess/EODatabaseDataSource.m: Ditto. * EOAccess/EOEntity.m: Ditto. * EOAccess/EOModel.m: Ditto. * EOAccess/EOModelGroup.m: Ditto. * EOAccess/EORelationship.m: Ditto. * EOAccess/EOSQLQualifier.m: Ditto. * EOAccess/EOUtilities.m: Ditto. * EOControl/EOAndQualifier.m: Ditto. * EOControl/EOClassDescription.m: Ditto. * EOControl/EODataSource.m: Ditto. * EOControl/EOEditingContext.m: Ditto. * EOControl/EOFault.m: Ditto. * EOControl/EOFaultHandler.m: Ditto. * EOControl/EOFetchSpecification.m: Ditto. * EOControl/EOKeyValueArchiver.m: Ditto. * EOControl/EOKeyValueQualifier.m: Ditto. * EOControl/EOMutableKnownKeyDictionary.m: Ditto. * EOControl/EONSAddOns.m: Ditto. * EOControl/EOObjectStore.m: Ditto. * EOControl/EOObjectStoreCoordinator.m: Ditto. * EOControl/EOObserver.m: Ditto. * EOControl/EOOrQualifier.m: Ditto. * EOControl/EOQualifier.m: Ditto. * EOControl/EOUndoManager.m: Ditto. * EOModeler/EOModelExtensions.m: Ditto. * EOAccess/EOModel.h/m (+/-[EOModel version]) Remove. ([EOModel init]): Handle version internally. ([EOModel encodeTableOfContentsIntoPropertyList:]): Ditto. ([EOModel encodeIntoPropertyList:]): Ditto. * EOAccess/EODatabaseContext.m ([EODatabaseContext dealloc]): Use NSCountHashTable instead of NSCountMapTable on hash table. * EOAccess/EOAttribute.m ([EOAttribute newValueForBytes:length:]): Added casts to avoid warnings. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@18500 72102866-910b-0410-8b05-ffd578937521
2004-01-29 13:23:22 +00:00
value = [(id)valueClass performSelector: _valueFactoryMethod
withObject: [value autorelease]];
break;
case EOFactoryMethodArgumentIsBytes:
value = [valueClass alloc];//For efficiency reasons, the returned value is NOT autoreleased !
aSignature =
[valueClass
instanceMethodSignatureForSelector: _valueFactoryMethod];
anInvocation = [NSInvocation
invocationWithMethodSignature: aSignature];
[anInvocation setSelector: _valueFactoryMethod];
[anInvocation setTarget: value];
[anInvocation setArgument: &bytes atIndex: 2];
[anInvocation setArgument: &length atIndex: 3];
[anInvocation setArgument: &encoding atIndex: 4];
[anInvocation invoke];
break;
case EOFactoryMethodArgumentIsNSData:
break;
}
}
if(!value)
value = [[NSString alloc]
initWithData: [NSData dataWithBytes: bytes length: length]
encoding: encoding];//For efficiency reasons, the returned value is NOT autoreleased !
return value;
}
/**
* Returns an NSCalendarDate object
* from the supplied time information.
* The Adaptor calls this method during value creation
* when fetching objects from the database.
* For efficiency, the returned value is NOT autoreleased.
**/
- (NSCalendarDate *)newDateForYear: (int)year
month: (unsigned)month
day: (unsigned)day
hour: (unsigned)hour
minute: (unsigned)minute
second: (unsigned)second
millisecond: (unsigned)millisecond
timezone: (NSTimeZone *)timezone
zone: (NSZone *)zone
{
NSCalendarDate *date;
//For efficiency reasons, the returned value is NOT autoreleased !
date = [[NSCalendarDateClass allocWithZone: zone]
initWithYear: year
month: month
day: day
hour: hour
minute: minute
second: second
timeZone: timezone];
// TODO milliseconds ??
return date;
}
- (NSString *)valueFactoryMethodName
{
return _valueFactoryMethodName;
}
- (SEL)valueFactoryMethod
{
return _valueFactoryMethod;
}
/**
* Depending on -adaptorValueType this method checks whether the value
* is a NSNumber, NSString, NSData or NSDate instance respectively.
* If not, it attempts to retrieve the -adaptorValueConversionMethod
* which should be used to convert the value accordingly. If none
* has been specified and the -adaptorValueType is EOAdaptorBytesType,
* it tries to convert the value by invoking -archiveData.
* The EONull instance is not converted.
* Returns the converted value.
* Note: This implementation currently raises if -adaptorValueType is of
* an unknown type or if conversion is necessary but not possible. This
* maybe contrary to the reference implementation but it seems like useful
* behavior. If this is causing problems please submit a bug report.
*/
- (id)adaptorValueByConvertingAttributeValue: (id)value
{
BOOL convert = NO;
EOAdaptorValueType adaptorValueType = [self adaptorValueType];
switch (adaptorValueType)
{
case EOAdaptorNumberType:
convert = [value isKindOfClass: NSNumberClass] ? NO : YES;
break;
case EOAdaptorCharactersType:
convert = [value isKindOfClass: NSStringClass] ? NO : YES;
break;
case EOAdaptorBytesType:
convert = [value isKindOfClass: NSDataClass] ? NO : YES;
break;
case EOAdaptorDateType:
convert = [value isKindOfClass: NSDateClass] ? NO : YES;
break;
default:
[NSException raise: NSInvalidArgumentException
format: @"Illegal adaptorValueType: %d",
adaptorValueType];
}
convert = (value == null) ? NO : convert;
if (convert)
{
SEL sel;
sel = [self adaptorValueConversionMethod];
if (sel == 0)
{
if (adaptorValueType == EOAdaptorBytesType)
{
value = [value archiveData];
}
else
{
/* This exception might not be conformant, but seems helpful. */
[NSException raise: NSInvalidArgumentException
format: @"Value of class: %@ needs conversion "
@"yet no conversion method specified.",
NSStringFromClass([value class])];
}
}
else
{
value = [value performSelector: sel];
}
}
return value;
}
- (NSString *)adaptorValueConversionMethodName
{
return _adaptorValueConversionMethodName;
}
- (SEL)adaptorValueConversionMethod
{
return _adaptorValueConversionMethod;
}
- (EOAdaptorValueType)adaptorValueType
{
Class adaptorClasses[] = { NSNumberClass,
NSStringClass,
NSDateClass };
EOAdaptorValueType values[] = { EOAdaptorNumberType,
EOAdaptorCharactersType,
EOAdaptorDateType };
Class valueClass;
int i;
for ( i = 0; i < 3; i++)
{
for ( valueClass = [self _valueClass];
valueClass != Nil;
valueClass = GSObjCSuper(valueClass))
{
if (valueClass == adaptorClasses[i])
return values[i];
}
}
return EOAdaptorBytesType;
}
- (EOFactoryMethodArgumentType)factoryMethodArgumentType
{
return _argumentType;
}
@end
@implementation EOAttribute (EOAttributeValueCreationEditing)
- (void)setValueFactoryMethodName: (NSString *)factoryMethodName
{
ASSIGN(_valueFactoryMethodName, factoryMethodName);
_valueFactoryMethod = NSSelectorFromString(_valueFactoryMethodName);
}
- (void)setAdaptorValueConversionMethodName: (NSString *)conversionMethodName
{
ASSIGN(_adaptorValueConversionMethodName, conversionMethodName);
_adaptorValueConversionMethod = NSSelectorFromString(_adaptorValueConversionMethodName);
}
- (void)setFactoryMethodArgumentType: (EOFactoryMethodArgumentType)argumentType
{
_argumentType = argumentType;
}
@end
@implementation EOAttribute (EOAttributeValueMapping)
- (NSException *)validateValue: (id*)valueP
{
NSException *exception=nil;
NSAssert(valueP, @"No value pointer");
if (*valueP == nil && [self allowsNull] == NO)
exception = [NSException validationExceptionWithFormat: @"attribute '%@' cannot be nil", [self name]];
else if (*valueP)
{
//call self valueClassName
*valueP = [self adaptorValueByConvertingAttributeValue: *valueP];
//call attribute width
//end !
//TODO: revoir
{
//EOEntity *entity = [self entity];
//NSArray *pkAttributes = [entity primaryKeyAttributes];
//TODO wowhat
if (*valueP)
{
Class valueClass = [self _valueClass];
if ([*valueP isKindOfClass: valueClass] == NO)
{
if ([*valueP isKindOfClass: NSStringClass])
{
if (valueClass == NSNumberClass)
{
if ([[self valueType] isEqualToString: @"i"] == YES)
*valueP = [NSNumber numberWithInt:
[*valueP intValue]];
else if ([_valueType isEqualToString: @"I"] == YES)
*valueP = [NSNumber numberWithUnsignedInt:
[*valueP unsignedIntValue]];
else if ([_valueType isEqualToString: @"c"] == YES)
*valueP = [NSNumber numberWithChar:
[*valueP intValue]];
else if ([_valueType isEqualToString: @"C"] == YES)
*valueP = [NSNumber numberWithUnsignedChar:
[*valueP unsignedIntValue]];
else if ([_valueType isEqualToString: @"s"] == YES)
*valueP = [NSNumber numberWithShort:
[*valueP shortValue]];
else if ([_valueType isEqualToString: @"S"] == YES)
*valueP = [NSNumber numberWithUnsignedShort:
[*valueP unsignedShortValue]];
else if ([_valueType isEqualToString: @"l"] == YES)
*valueP = [NSNumber numberWithLong:
[*valueP longValue]];
else if ([_valueType isEqualToString: @"L"] == YES)
*valueP = [NSNumber numberWithUnsignedLong:
[*valueP unsignedLongValue]];
else if ([_valueType isEqualToString: @"u"] == YES)
*valueP = [NSNumber numberWithLongLong:
[*valueP longLongValue]];
else if ([_valueType isEqualToString: @"U"] == YES)
*valueP = [NSNumber numberWithUnsignedLongLong:
[*valueP unsignedLongLongValue]];
else if ([_valueType isEqualToString: @"f"] == YES)
*valueP = [NSNumber numberWithFloat:
[*valueP floatValue]];
else
*valueP = [NSNumber numberWithDouble:
[*valueP doubleValue]];
}
else if (valueClass == NSDecimalNumberClass)
*valueP = [NSDecimalNumber
decimalNumberWithString: *valueP];
else if (valueClass == NSDataClass)
*valueP = [*valueP
dataUsingEncoding: NSASCIIStringEncoding
allowLossyConversion: YES];
else if (valueClass == NSCalendarDateClass)
*valueP = [[[NSCalendarDateClass alloc]
initWithString: *valueP]
autorelease];
}
}
else
{
if ([*valueP isKindOfClass: NSStringClass])
{
unsigned width = [self width];
if (width && [*valueP length] > width)
{
const char *buf;
buf = [*valueP cString];
*valueP = [NSString stringWithCString: buf
length: width];
}
}
else if ([*valueP isKindOfClass: NSNumberClass])
{
// TODO ??
}
}
}
}
}
return exception;
}
@end
@implementation NSObject (EOCustomClassArchiving)
+ objectWithArchiveData: (NSData *)data
{
return [NSUnarchiver unarchiveObjectWithData:data];
}
- (NSData *)archiveData
{
return [NSArchiver archivedDataWithRootObject:self];
}
@end
@implementation EOAttribute (EOAttributePrivate)
- (void)setParent: (id)parent
{
//OK
[self willChange];
_parent = parent;
_flags.isParentAnEOEntity = [_parent isKindOfClass: [EOEntity class]];//??
}
- (EOAttribute *)realAttribute
{
return _realAttribute;
}
- (GCMutableArray *)_definitionArray
{
return _definitionArray;
}
- (Class)_valueClass
{
if (_valueClass)
return _valueClass;
if ([self isFlattened])
return [[_definitionArray realAttribute] _valueClass];
return [_prototype _valueClass];
}
@end
@implementation EOAttribute (EOAttributePrivate2)
- (BOOL) _hasAnyOverrides
{
[self notImplemented: _cmd]; //TODO
return NO;
}
- (void) _resetPrototype
{
[self notImplemented: _cmd]; //TODO
}
- (void) _updateFromPrototype
{
[self notImplemented: _cmd]; //TODO
}
- (void) _setOverrideForKeyEnum: (int)keyEnum
{
//[self notImplemented:_cmd]; //TODO
}
- (BOOL) _isKeyEnumOverriden: (int)param0
{
[self notImplemented: _cmd]; //TODO
return NO;
}
- (BOOL) _isKeyEnumDefinedByPrototype: (int)param0
{
[self notImplemented: _cmd]; //TODO
return NO;
}
@end