/**
EOSchemaGeneration.m
EOSchemaGeneration Class
Copyright (C) 2006 Free Software Foundation, Inc.
Author: David Ayers
Date: February 2006
$Revision: 23653 $
$Date: 2006-09-28 17:25:30 +0200 (Don, 28 Sep 2006) $
This file is part of the GNUstep Database Library.
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 3 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,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "config.h"
#include
#ifdef GNUSTEP
#include
#include
#include
#include
#else
#include
#endif
#ifndef GNUSTEP
#include
#include
#include
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
NSString *EOCreateTablesKey = @"EOCreateTablesKey";
NSString *EODropTablesKey = @"EODropTablesKey";
NSString *EOCreatePrimaryKeySupportKey = @"EOCreatePrimaryKeySupportKey";
NSString *EODropPrimaryKeySupportKey = @"EODropPrimaryKeySupportKey";
NSString *EOPrimaryKeyConstraintsKey = @"EOPrimaryKeyConstraintsKey";
NSString *EOForeignKeyConstraintsKey = @"EOForeignKeyConstraintsKey";
NSString *EOCreateDatabaseKey = @"EOCreateDatabaseKey";
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];
/* TODO: ayers
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