* EOAccess/EOAttribute.m ([EOAttribute -awakeWithPropertyList:]): set

the prototype.
([EOAttribute -encodeIntoPropertyList:]): likewise.
([EOAttribute -serverTimeZone]): return the value from the prototype.
([EOAttribute -columnName]): likewise.
([EOAttribute -readFormat]): likewise.
([EOAttribute -writeFormat]): likewise.
([EOAttribute -scale]): likewise.
([EOAttribute -precision]): likewise.
([EOAttribute -width]): likewise.
([EOAttribute -allowsNull]): likewise.
([EOAttribute -isReadOnly]): likewise.
([EOAttribute -valueClassName]): likewise.
([EOAttribute -externalType]): likewise.
([EOAttribute -valueType]): likewise.

* EOAccess/EOAttribute.h: removed ivar _prototypeName.

* EOAccess/EOModel.m ([EOModel -prototypeAttributeNamed:]): implemented.

* EOAccess/EOAdaptor.m|.h ([EOAdaptor -prototypeAttributes]): renamed
from +prototypes and implemented.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16483 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Mirko Viviani 2003-04-18 19:01:06 +00:00
parent 1443198f62
commit 19ea7ea1fc
7 changed files with 217 additions and 37 deletions

View file

@ -1,3 +1,27 @@
2003-04-18 Mirko Viviani <mirko@objectlab.org>
* EOAccess/EOAttribute.m ([EOAttribute -awakeWithPropertyList:]): set
the prototype.
([EOAttribute -encodeIntoPropertyList:]): likewise.
([EOAttribute -serverTimeZone]): return the value from the prototype.
([EOAttribute -columnName]): likewise.
([EOAttribute -readFormat]): likewise.
([EOAttribute -writeFormat]): likewise.
([EOAttribute -scale]): likewise.
([EOAttribute -precision]): likewise.
([EOAttribute -width]): likewise.
([EOAttribute -allowsNull]): likewise.
([EOAttribute -isReadOnly]): likewise.
([EOAttribute -valueClassName]): likewise.
([EOAttribute -externalType]): likewise.
([EOAttribute -valueType]): likewise.
* EOAccess/EOAttribute.h: removed ivar _prototypeName.
* EOAccess/EOModel.m ([EOModel -prototypeAttributeNamed:]): implemented.
* EOAccess/EOAdaptor.m|.h ([EOAdaptor -prototypeAttributes]): renamed
from +prototypes and implemented.
2003-04-15 Mirko Viviani <mirko@objectlab.org>
* EOAccess/EOAdaptorContext.h: include EODefines.h and NSString.h

View file

@ -83,7 +83,7 @@ GDL2ACCESS_EXPORT NSString *EOGeneralAdaptorException;
+ (EOLoginPanel *)sharedLoginPanelInstance;
+ (NSArray *)availableAdaptorNames;
+ (NSArray *)prototypes;
- (NSArray *)prototypeAttributes;
- initWithName:(NSString *)name;

View file

@ -71,12 +71,12 @@ RCS_ID("$Id$")
#include <EOAccess/EOAdaptor.h>
#include <EOAccess/EOAdaptorPriv.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOSQLExpression.h>
#include <EOAccess/EOAdaptor.h>
#include <EOAccess/EOAdaptorContext.h>
#include <EOAccess/EOAdaptorChannel.h>
#include <EOAccess/EOAttribute.h>
#include <EOAccess/EOEntity.h>
#include <EOAccess/EOModel.h>
#include <EOAccess/EOSQLExpression.h>
NSString *EOGeneralAdaptorException = @"EOGeneralAdaptorException";
@ -322,11 +322,46 @@ NSString *EOGeneralAdaptorException = @"EOGeneralAdaptorException";
return adaptorNames;
}
+ (NSArray *)prototypes
- (NSArray *)prototypeAttributes
{
// TODO
[self notImplemented: _cmd];
return nil;
NSBundle *bundle;
NSString *path;
NSString *modelName;
EOModel *model;
NSMutableArray *attributes = nil;
EOFLOGObjectFnStart();
bundle = [NSBundle bundleForClass: [self class]];
modelName = [NSString stringWithFormat: @"EO%@Prototypes.eomodeld", _name];
path = [[bundle resourcePath] stringByAppendingPathComponent: modelName];
model = [[EOModel alloc] initWithContentsOfFile: path];
if (model)
{
NSArray *entities;
int i, count;
attributes = [NSMutableArray arrayWithCapacity: 20];
entities = [model entities];
count = [entities count];
for (i = 0; i < count; i++)
{
EOEntity *entity = [entities objectAtIndex: i];
[attributes addObjectsFromArray: [entity attributes]];
}
RELEASE(model);
}
EOFLOGObjectFnStop();
return attributes;
}
- initWithName:(NSString *)name

View file

@ -74,7 +74,6 @@ typedef enum {
@interface EOAttribute : GCObject <EOPropertyListEncoding>
{
NSString *_name;
NSString *_prototypeName;
NSString *_columnName;
NSString *_externalType;
NSString *_valueType;
@ -175,7 +174,7 @@ typedef enum {
- (void)setName: (NSString *)name;
- (void)setPrototypeName: (NSString *)prototypeName;
- (void)setPrototype: (EOAttribute *)prototype;
- (void)setReadOnly: (BOOL)yn;

View file

@ -101,10 +101,6 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
[self setParent: owner];
// EOFLOGObjectLevel(@"gsdb", @"Attribute Entity=%@", [self entity]);
tmpString = [propertyList objectForKey: @"prototypeName"];
if (tmpString)
[self setPrototypeName: tmpString];
[self setExternalType: [propertyList objectForKey: @"externalType"]];
tmpString = [propertyList objectForKey: @"allowsNull"];
@ -234,8 +230,9 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (void)awakeWithPropertyList: (NSDictionary *)propertyList
{
//Seems OK
NSString *definition = nil;
NSString *columnName = nil;
NSString *definition;
NSString *columnName;
NSString *tmpString;
definition = [propertyList objectForKey: @"definition"];
@ -247,7 +244,17 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
if (columnName)
[self setColumnName: columnName];
EOFLOGObjectLevelArgs(@"gsdb", @"Attribute %@ awakeWithPropertyList:%@",
tmpString = [propertyList objectForKey: @"prototypeName"];
if (tmpString)
{
EOAttribute *attr = [[_parent model] prototypeAttributeNamed: tmpString];
if (attr)
[self setPrototype: attr];
}
EOFLOGObjectLevelArgs(@"gsdb", @"Attribute %@ awakeWithPropertyList:%@",
self, propertyList);
}
@ -255,6 +262,8 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
{
if (_name)
[propertyList setObject: _name forKey: @"name"];
if (_prototype)
[propertyList setObject: [_prototype name] forKey: @"prototypeName"];
if (_serverTimeZone)
[propertyList setObject: [_serverTimeZone name]
forKey: @"serverTimeZone"];
@ -286,7 +295,7 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (void)dealloc
{
DESTROY(_name);
DESTROY(_prototypeName);
DESTROY(_prototype);
DESTROY(_columnName);
DESTROY(_externalType);
DESTROY(_valueType);
@ -381,12 +390,18 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (NSTimeZone *)serverTimeZone
{
return _serverTimeZone;
if (_serverTimeZone)
return _serverTimeZone;
return [_prototype serverTimeZone];
}
- (NSString *)columnName
{
return _columnName;
if (_columnName)
return _columnName;
return [_prototype columnName];
}
- (NSString *)definition
@ -396,7 +411,7 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
// EOFLOGObjectFnStart();
// EOFLOGObjectLevel(@"gsdb",@"_definitionArray:%@",_definitionArray);
definition=[_definitionArray valueForSQLExpression: nil];
definition = [_definitionArray valueForSQLExpression: nil];
// EOFLOGObjectLevel(@"gsdb",@"definition:%@",definition);
// EOFLOGObjectFnStop();
@ -406,12 +421,18 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (NSString *)readFormat
{
return _readFormat;
if (_readFormat)
return _readFormat;
return [_prototype readFormat];
}
- (NSString *)writeFormat
{
return _writeFormat;
if (_writeFormat)
return _writeFormat;
return [_prototype writeFormat];
}
- (NSDictionary *)userInfo
@ -426,17 +447,35 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (int)scale
{
return _scale;
if (_scale)
return _scale;
if (_prototype)
return [_prototype scale];
return 0;
}
- (unsigned)precision
{
return _precision;
if (_precision)
return _precision;
if (_prototype)
return [_prototype precision];
return 0;
}
- (unsigned)width
{
return _width;
if (_width)
return _width;
if (_prototype)
return [_prototype width];
return 0;
}
- (id)parent
@ -446,12 +485,12 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (EOAttribute *)prototype
{
return nil; // TODO
return _prototype;
}
- (NSString *)prototypeName
{
return _prototypeName;
return [_prototype name];
}
- (EOParameterDirection)parameterDirection
@ -461,7 +500,13 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (BOOL)allowsNull
{
return _flags.allowsNull;
if (_flags.allowsNull)
return _flags.allowsNull;
if (_prototype)
return [_prototype allowsNull];
return NO;
}
- (BOOL)isKeyDefinedByPrototype:(NSString *)key
@ -480,7 +525,13 @@ static NSString *defaultCalendarFormat = @"%b %d %Y %H:%M";
- (BOOL)isReadOnly
{
//call isDerived
return _flags.isReadOnly;
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.
@ -492,6 +543,7 @@ A Flattened attribute is also a derived attributes.
//Seems OK
if(_definitionArray)
return YES;
return NO;
}
@ -517,15 +569,21 @@ A Flattened attribute is also a derived attributes.
if (!_valueClassName && [self isFlattened])
return [[_definitionArray realAttribute] valueClassName];
return _valueClassName;
if (_valueClassName)
return _valueClassName;
return [_prototype valueClassName];
}
-(NSString *)externalType
- (NSString *)externalType
{
if (!_externalType && [self isFlattened])
return [[_definitionArray realAttribute] externalType];
return _externalType;
if (_externalType)
return _externalType;
return [_prototype externalType];
}
- (NSString *)valueType
@ -533,7 +591,10 @@ A Flattened attribute is also a derived attributes.
if(!_valueType && [self isFlattened])
return [[_definitionArray realAttribute] valueType];
return _valueType;
if (_valueType)
return _valueType;
return [_prototype valueType];
}
@end
@ -633,9 +694,9 @@ A Flattened attribute is also a derived attributes.
ASSIGN(_name, name);
}
- (void)setPrototypeName: (NSString *)prototypeName
- (void)setPrototype: (EOAttribute *)prototype
{
ASSIGN(_prototypeName, prototypeName);
ASSIGN(_prototype, prototype);
}
- (void)setColumnName: (NSString *)columnName

View file

@ -43,6 +43,7 @@
@class NSDictionary;
@class EOEntity;
@class EOAttribute;
@class EOModelGroup;
@class EOStoredProcedure;
@ -111,6 +112,8 @@
- (EOModelGroup *)modelGroup;
- (EOAttribute *)prototypeAttributeNamed: (NSString *)attributeName;
@end
@interface EOModel (EOModelFileAccess)

View file

@ -67,6 +67,8 @@ RCS_ID("$Id$")
#include <EOAccess/EOStoredProcedure.h>
#include <EOAccess/EOModelGroup.h>
#include <EOAccess/EOAccessFault.h>
#include <EOAccess/EOAdaptor.h>
#include <EOAccess/EOAttribute.h>
NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
@ -485,6 +487,62 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
return 2;
}
- (EOAttribute *)prototypeAttributeNamed: (NSString *)attributeName
{
NSString *entityName;
EOEntity *entity;
NSArray *attributes;
EOAttribute *attribute = nil;
int i, count;
EOFLOGObjectFnStart();
EOFLOGObjectLevelArgs(@"gsdb", @"attrName=%@", attributeName);
entityName = [NSString stringWithFormat: @"EO%@Prototypes", _adaptorName];
EOFLOGObjectLevelArgs(@"gsdb", @"entityName=%@", entityName);
entity = [self entityNamed: entityName];
if (!entity)
entity = [_group entityNamed: entityName];
if (!entity)
entity = [_group entityNamed: @"EOPrototypes"];
if (!entity && _adaptorName && [_adaptorName length] > 0)
{
EOAdaptor *adaptor;
adaptor = [EOAdaptor adaptorWithName: _adaptorName];
attributes = [adaptor prototypeAttributes];
}
else
attributes = [entity attributes];
EOFLOGObjectLevelArgs(@"gsdb", @"entity=%@ - attributes=%@",
entity, attributes);
if (attributes)
{
count = [attributes count];
for (i = 0; i < count; i++)
{
attribute = [attributes objectAtIndex: i];
if ([[attribute name]
isEqualToString: attributeName])
break;
}
}
EOFLOGObjectLevelArgs(@"gsdb", @"attribute=%@", attribute);
EOFLOGObjectFnStop();
return attribute;
}
@end