mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-24 12:11:18 +00:00
* Examples/WebBookStore1/Application.h, * Examples/WebBookStore1/Application.m, * Examples/WebBookStore1/DirectAction.h, * Examples/WebBookStore1/DirectAction.m, * Examples/WebBookStore1/GNUmakefile, * Examples/WebBookStore1/Main.h, * Examples/WebBookStore1/Main.m, * Examples/WebBookStore1/Session.h, * Examples/WebBookStore1/Session.m, * Examples/WebBookStore1/WebBookStore1_main.m, * Examples/WebBookStore1/BookStore.eomodeld/Author.plist, * Examples/WebBookStore1/BookStore.eomodeld/Book.plist, * Examples/WebBookStore1/BookStore.eomodeld/Customer.plist, * Examples/WebBookStore1/BookStore.eomodeld/Order.plist, * Examples/WebBookStore1/BookStore.eomodeld/OrderPos.plist, * Examples/WebBookStore1/BookStore.eomodeld/index.eomodeld, * Examples/WebBookStore1/Main.gswc/Main.gswd, * Examples/WebBookStore1/Main.gswc/Main.gswi, * Examples/WebBookStore1/Main.gswc/Main.html, * Examples/WebBookStore1/WebServerResources/Insert.png, * Examples/WebBookStore1/WebServerResources/Save.png, * Examples/WebBookStore1/WebServerResources/Delete.png, * Examples/WebBookStore1/WebServerResources/CreateTables.png, * Examples/WebBookStore1/WebServerResources/DropTables.png: New files. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@20316 72102866-910b-0410-8b05-ffd578937521
98 lines
2.6 KiB
Objective-C
98 lines
2.6 KiB
Objective-C
#include <EOControl/EOControl.h>
|
|
#include <EOAccess/EOAccess.h>
|
|
|
|
#include "Main.h"
|
|
|
|
@implementation Main
|
|
|
|
- (void)selectObject
|
|
{
|
|
[authorDG selectObject: author];
|
|
}
|
|
|
|
- (void)saveChanges
|
|
{
|
|
[[[self session] defaultEditingContext] saveChanges];
|
|
}
|
|
|
|
- (void)createTables
|
|
{
|
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
|
EODatabaseDataSource *dataSource = (id)[authorDG dataSource];
|
|
EOEntity *entity = [dataSource entity];
|
|
EOModel *model = [entity model];
|
|
NSArray *entities = [model entities];
|
|
EOAdaptor *adaptor = [EOAdaptor adaptorWithModel: model];
|
|
Class exprClass = [adaptor expressionClass];
|
|
NSDictionary *createOptDict
|
|
= [NSDictionary dictionaryWithObjectsAndKeys:
|
|
@"NO", @"EODropTablesKey",
|
|
@"NO", @"EODropPrimaryKeySupportKey", nil];
|
|
|
|
EOAdaptorContext *context = [adaptor createAdaptorContext];
|
|
EOAdaptorChannel *channel = [context createAdaptorChannel];
|
|
NSArray *exprs;
|
|
EOSQLExpression *expr;
|
|
unsigned i,c;
|
|
|
|
exprs = [exprClass schemaCreationStatementsForEntities: entities
|
|
options: createOptDict];
|
|
|
|
[channel openChannel];
|
|
for (i=0, c=[exprs count]; i<c; i++)
|
|
{
|
|
expr = [exprs objectAtIndex: i];
|
|
[channel evaluateExpression: expr];
|
|
}
|
|
[channel closeChannel];
|
|
|
|
[pool release];
|
|
}
|
|
|
|
- (void)dropTables
|
|
{
|
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
|
EODatabaseDataSource *dataSource = (id)[authorDG dataSource];
|
|
EOEntity *entity = [dataSource entity];
|
|
EOModel *model = [entity model];
|
|
NSArray *entities = [model entities];
|
|
EOAdaptor *adaptor = [EOAdaptor adaptorWithModel: model];
|
|
Class exprClass = [adaptor expressionClass];
|
|
NSDictionary *dropOptDict
|
|
= [NSDictionary dictionaryWithObjectsAndKeys:
|
|
@"NO", @"EOPrimaryKeyConstraintsKey",
|
|
@"NO", @"EOCreatePrimaryKeySupportKey",
|
|
@"NO", @"EOCreateTablesKey",
|
|
nil];
|
|
|
|
EOAdaptorContext *context = [adaptor createAdaptorContext];
|
|
EOAdaptorChannel *channel = [context createAdaptorChannel];
|
|
NSArray *exprs;
|
|
EOSQLExpression *expr;
|
|
unsigned i,c;
|
|
|
|
exprs = [exprClass schemaCreationStatementsForEntities: entities
|
|
options: dropOptDict];
|
|
|
|
[channel openChannel];
|
|
for (i=0, c=[exprs count]; i<c; i++)
|
|
{
|
|
expr = [exprs objectAtIndex: i];
|
|
[channel evaluateExpression: expr];
|
|
}
|
|
[channel closeChannel];
|
|
|
|
[pool release];
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
/* These variables were set via EOKeyValueCoding (KVC) from
|
|
the gswi initialization or */
|
|
DESTROY(author);
|
|
DESTROY(authorDG);
|
|
|
|
[super dealloc];
|
|
}
|
|
|
|
@end
|