mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-22 12:55:44 +00:00
* EOAccess/EOAdaptor.h/m: New globals for GDL2 specific
administrative key handling. ([EOAdaptor sharedLoginPanelInstance]): Implemented. * EOAccess/EOSQLExpression.m ([EOSQLExpression _administrativeDatabaseStatementsForSelector:forEntityGroup:], [EOSQLExpression _dropDatabaseStatementsForEntityGroups:], [EOSQLExpression _createDatabaseStatementsForEntityGroups:]): Implemented new private support methods. ([EOSQLExpression schemaCreationStatementsForEntities:options:]): Added support for EODropDatabaseKey and EOCreateDatabaseKey. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@18638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
07452f7ec4
commit
0c411f61c5
4 changed files with 176 additions and 6 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2003-02-22 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* EOAccess/EOAdaptor.h/m: New globals for GDL2 specific
|
||||
administrative key handling.
|
||||
([EOAdaptor sharedLoginPanelInstance]): Implemented.
|
||||
* EOAccess/EOSQLExpression.m ([EOSQLExpression
|
||||
_administrativeDatabaseStatementsForSelector:forEntityGroup:],
|
||||
[EOSQLExpression _dropDatabaseStatementsForEntityGroups:],
|
||||
[EOSQLExpression _createDatabaseStatementsForEntityGroups:]):
|
||||
Implemented new private support methods.
|
||||
([EOSQLExpression schemaCreationStatementsForEntities:options:]):
|
||||
Added support for EODropDatabaseKey and EOCreateDatabaseKey.
|
||||
|
||||
2003-02-19 David Ayers <d.ayers@inode.at>
|
||||
|
||||
* EOControl/Makefile.postamble: Remove obsolete dependency and
|
||||
|
|
|
@ -187,5 +187,12 @@ fetchedValueForValue: (id)value
|
|||
|
||||
@end /* NSObject (EOAdaptorDelegate) */
|
||||
|
||||
/* GDL2 Extensions */
|
||||
GDL2ACCESS_EXPORT NSString *EOAdministrativeConnectionDictionaryNeededNotification;
|
||||
GDL2ACCESS_EXPORT NSString *EOAdaptorKey;
|
||||
GDL2ACCESS_EXPORT NSString *EOModelKey;
|
||||
GDL2ACCESS_EXPORT NSString *EOConnectionDictionaryKey;
|
||||
GDL2ACCESS_EXPORT NSString *EOAdministrativeConnectionDictionaryKey;
|
||||
|
||||
|
||||
#endif /* __EOAdaptor_h__*/
|
||||
|
|
|
@ -86,6 +86,13 @@ RCS_ID("$Id$")
|
|||
|
||||
NSString *EOGeneralAdaptorException = @"EOGeneralAdaptorException";
|
||||
|
||||
NSString *EOAdministrativeConnectionDictionaryNeededNotification
|
||||
= @"EOAdministrativeConnectionDictionaryNeededNotification";
|
||||
NSString *EOAdaptorKey = @"EOAdaptorKey";
|
||||
NSString *EOModelKey = @"EOModelKey";
|
||||
NSString *EOConnectionDictionaryKey = "EOConnectionDictionaryKey";
|
||||
NSString *EOAdministrativeConnectionDictionaryKey
|
||||
= @"EOAdministrativeConnectionDictionaryKey";
|
||||
|
||||
@implementation EOAdaptor
|
||||
|
||||
|
@ -256,9 +263,25 @@ NSString *EOGeneralAdaptorException = @"EOGeneralAdaptorException";
|
|||
|
||||
+ (EOLoginPanel *)sharedLoginPanelInstance
|
||||
{
|
||||
// TODO
|
||||
[self notImplemented: _cmd];
|
||||
return nil;
|
||||
static EOLoginPanel *panel = nil;
|
||||
|
||||
if (panel == nil
|
||||
&& NSClassFromString(@"NSApplication") != nil)
|
||||
{
|
||||
NSBundle *adaptorFramework;
|
||||
NSBundle *loginBundle;
|
||||
NSString *path;
|
||||
Class loginClass;
|
||||
|
||||
adaptorFramework = [NSBundle bundleForClass: self];
|
||||
path = [adaptorFramework pathForResource: @"LoginPanel"
|
||||
ofType: @"bundle"];
|
||||
loginBundle = [NSBundle bundleWithPath: path];
|
||||
loginClass = [loginBundle principalClass];
|
||||
panel = [loginClass new];
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
+ (NSArray *)availableAdaptorNames
|
||||
|
|
|
@ -44,6 +44,7 @@ RCS_ID("$Id$")
|
|||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSSet.h>
|
||||
#include <Foundation/NSUtilities.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
|
@ -63,6 +64,7 @@ RCS_ID("$Id$")
|
|||
#include <EOControl/EODebug.h>
|
||||
#include <EOControl/EONull.h>
|
||||
|
||||
#include <EOAccess/EOModel.h>
|
||||
#include <EOAccess/EOEntity.h>
|
||||
#include <EOAccess/EOAttribute.h>
|
||||
#include <EOAccess/EOAttributePriv.h>
|
||||
|
@ -2483,6 +2485,126 @@ NSString *EODropDatabaseKey = @"EODropDatabaseKey";
|
|||
|
||||
@implementation EOSQLExpression (EOSchemaGeneration)
|
||||
|
||||
+ (NSArray *)_administrativeDatabaseStatementsForSelector:(SEL) sel
|
||||
forEntityGroup:(NSArray *)group
|
||||
{
|
||||
EOEntity *entity;
|
||||
EOModel *model;
|
||||
NSDictionary *connDict;
|
||||
NSDictionary *admDict;
|
||||
NSArray *stmts;
|
||||
NSString *notifName;
|
||||
NSMutableDictionary *notifDict;
|
||||
|
||||
entity = [group lastObject];
|
||||
model = [entity model];
|
||||
connDict = [model connectionDictionary];
|
||||
|
||||
notifDict = (id)[NSMutableDictionary dictionaryWithCapacity: 2];
|
||||
[notifDict setObject: model forKey: EOModelKey];
|
||||
notifName = EOAdministrativeConnectionDictionaryNeededNotification;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName: notifName
|
||||
object: notifDict];
|
||||
admDict = [notifDict objectForKey: EOAdministrativeConnectionDictionaryKey];
|
||||
|
||||
if (admDict == nil && [admDict count] == 0)
|
||||
{
|
||||
EOAdaptor *adaptor;
|
||||
EOLoginPanel *panel;
|
||||
|
||||
adaptor = [EOAdaptor adaptorWithModel: model];
|
||||
panel = [[adaptor class] sharedLoginPanelInstance];
|
||||
admDict = [panel administrativeConnectionDictionaryForAdaptor: adaptor];
|
||||
}
|
||||
|
||||
stmts = [self performSelector: sel
|
||||
withObject: connDict
|
||||
withObject: admDict];
|
||||
|
||||
return stmts;
|
||||
}
|
||||
|
||||
+ (NSArray *)_dropDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
|
||||
{
|
||||
NSMutableArray *cumStmts;
|
||||
NSArray *stmts;
|
||||
NSArray *group;
|
||||
unsigned i,n;
|
||||
SEL sel;
|
||||
|
||||
sel = @selector(dropDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
|
||||
|
||||
n = [entityGroups count];
|
||||
cumStmts = [NSMutableArray arrayWithCapacity: n];
|
||||
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
EOSQLExpression *expr;
|
||||
unsigned j,m;
|
||||
|
||||
group = [entityGroups objectAtIndex: i];
|
||||
stmts = [self _administrativeDatabaseStatementsForSelector: sel
|
||||
forEntityGroup: group];
|
||||
for (j=0, m=[stmts count]; j<m; j++)
|
||||
{
|
||||
NSArray *rawStmts;
|
||||
NSString *stmt;
|
||||
|
||||
rawStmts = [cumStmts valueForKey:@"statement"];
|
||||
expr = [stmts objectAtIndex: j];
|
||||
stmt = [expr statement];
|
||||
|
||||
if ([rawStmts containsObject: stmt] == NO)
|
||||
{
|
||||
[cumStmts addObject: expr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray: cumStmts];
|
||||
}
|
||||
|
||||
+ (NSArray *)_createDatabaseStatementsForEntityGroups: (NSArray *)entityGroups
|
||||
{
|
||||
NSMutableArray *cumStmts;
|
||||
NSArray *stmts;
|
||||
NSArray *group;
|
||||
unsigned i,n;
|
||||
SEL sel;
|
||||
|
||||
sel = @selector(createDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:);
|
||||
|
||||
n = [entityGroups count];
|
||||
cumStmts = [NSMutableArray arrayWithCapacity: n];
|
||||
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
EOSQLExpression *expr;
|
||||
unsigned j,m;
|
||||
|
||||
group = [entityGroups objectAtIndex: i];
|
||||
stmts = [self _administrativeDatabaseStatementsForSelector: sel
|
||||
forEntityGroup: group];
|
||||
|
||||
for (j=0, m=[stmts count]; j<m; j++)
|
||||
{
|
||||
NSArray *rawStmts;
|
||||
NSString *stmt;
|
||||
|
||||
rawStmts = [cumStmts valueForKey:@"statement"];
|
||||
expr = [stmts objectAtIndex: j];
|
||||
stmt = [expr statement];
|
||||
|
||||
if ([rawStmts containsObject: stmt] == NO)
|
||||
{
|
||||
[cumStmts addObject: expr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [NSArray arrayWithArray: cumStmts];
|
||||
}
|
||||
|
||||
+ (NSArray *)foreignKeyConstraintStatementsForRelationship: (EORelationship *)relationship
|
||||
{
|
||||
NSMutableArray *array, *sourceColumns, *destColumns;
|
||||
|
@ -2884,6 +3006,10 @@ struct _schema
|
|||
@selector(dropPrimaryKeySupportStatementsForEntityGroups:)},
|
||||
{EODropTablesKey , @"YES",
|
||||
@selector(dropTableStatementsForEntityGroups:)},
|
||||
{EODropDatabaseKey , @"NO",
|
||||
@selector(_dropDatabaseStatementsForEntityGroups:)},
|
||||
{EOCreateDatabaseKey , @"NO",
|
||||
@selector(_createDatabaseStatementsForEntityGroups:)},
|
||||
{EOCreateTablesKey , @"YES",
|
||||
@selector(createTableStatementsForEntityGroups:)},
|
||||
{EOCreatePrimaryKeySupportKey, @"YES",
|
||||
|
@ -2927,9 +3053,10 @@ struct _schema
|
|||
|
||||
if ([value isEqual: @"YES"] == YES)
|
||||
{
|
||||
[array addObjectsFromArray:
|
||||
[self performSelector: defaults[i].selector
|
||||
withObject: groups]];
|
||||
NSArray *stmts;
|
||||
stmts = [self performSelector: defaults[i].selector
|
||||
withObject: groups];
|
||||
[array addObjectsFromArray: stmts];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue