mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-02-21 02:20:55 +00:00
([EOObjectStoreCoordinator -setModelGroup:]): moved from EOControl/ EOObjectStoreCoordinator.m * EOAccess/EOUtilities.m|.h ([EOFetchSpecification +fetchSpecificationNamed:entityNamed:]): moved from EOControl/ EOFetchSpecification.m * EOControl/EOFetchSpecification.m ([EOFetchSpecification +fetchSpecificationNamed:entityNamed:]): return nil. * EOAccess/EOAccessFault.m|.h ([EOFault -databaseContext]): moved from EOControl/EOFault.m * EOControl/EOEditingContext.m ([EOEditingContext -tryToSaveChanges]), ([EOEditingContext -saveChanges:]): use respondsToSelector: git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15431 72102866-910b-0410-8b05-ffd578937521
231 lines
5.2 KiB
Objective-C
231 lines
5.2 KiB
Objective-C
/**
|
|
EOStoredProcedure.m <title>EOStoredProcedure Class</title>
|
|
|
|
Copyright (C) 2000 Free Software Foundation, Inc.
|
|
|
|
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
|
|
Date: February 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$")
|
|
|
|
#import <Foundation/NSException.h>
|
|
#import <Foundation/NSDebug.h>
|
|
|
|
#import <gnustep/base/GCObject.h>
|
|
|
|
#import <EOAccess/EOStoredProcedure.h>
|
|
#import <EOAccess/EOAttribute.h>
|
|
#import <EOAccess/EOModel.h>
|
|
|
|
#import <EOControl/EODebug.h>
|
|
|
|
|
|
@implementation EOStoredProcedure
|
|
|
|
- (EOStoredProcedure *)initWithName:(NSString *)name
|
|
{
|
|
self = [super init];
|
|
|
|
[self setName:name];
|
|
_userInfo = [NSDictionary new];
|
|
_internalInfo = [NSDictionary new];
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)gcDecrementRefCountOfContainedObjects
|
|
{
|
|
EOFLOGObjectFnStart();
|
|
|
|
EOFLOGObjectLevel(@"gsdb", @"model gcDecrementRefCount");
|
|
|
|
[(id)_model gcDecrementRefCount];
|
|
[(id)_arguments gcDecrementRefCount];
|
|
|
|
EOFLOGObjectFnStop();
|
|
}
|
|
|
|
- (BOOL)gcIncrementRefCountOfContainedObjects
|
|
{
|
|
if (![super gcIncrementRefCountOfContainedObjects])
|
|
return NO;
|
|
|
|
[(id)_model gcIncrementRefCount];
|
|
[(id)_arguments gcIncrementRefCount];
|
|
|
|
[(id)_model gcIncrementRefCountOfContainedObjects];
|
|
[(id)_arguments gcIncrementRefCountOfContainedObjects];
|
|
|
|
return YES;
|
|
}
|
|
|
|
+ (EOStoredProcedure *)storedProcedureWithPropertyList: (NSDictionary *)propertyList
|
|
owner: (id)owner
|
|
{
|
|
return [[[self alloc] initWithPropertyList: propertyList
|
|
owner: owner] autorelease];
|
|
}
|
|
|
|
- initWithPropertyList: (NSDictionary *)propertyList owner: (id)owner
|
|
{
|
|
NSArray *array;
|
|
NSEnumerator *enumerator;
|
|
id attributePList;
|
|
|
|
_model = [owner retain];
|
|
|
|
[self setName: [propertyList objectForKey: @"name"]];
|
|
[self setExternalName: [propertyList objectForKey: @"externalName"]];
|
|
[self setUserInfo: [propertyList objectForKey: @"userInfo"]];
|
|
|
|
if (!_userInfo)
|
|
[self setUserInfo:[propertyList objectForKey:@"userInfo"]];
|
|
|
|
array = [propertyList objectForKey:@"attributes"];
|
|
if ([array count])
|
|
{
|
|
_arguments = [[GCMutableArray alloc] initWithCapacity: [array count]];
|
|
|
|
enumerator = [array objectEnumerator];
|
|
while ((attributePList = [enumerator nextObject]))
|
|
{
|
|
EOAttribute *attribute = [EOAttribute
|
|
attributeWithPropertyList: attributePList
|
|
owner: self];
|
|
|
|
[(GCMutableArray *)_arguments addObject: attribute];
|
|
}
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)awakeWithPropertyList: (NSDictionary *)propertyList
|
|
{
|
|
NSEnumerator *argsEnum;
|
|
EOAttribute *attribute;
|
|
|
|
argsEnum = [_arguments objectEnumerator];
|
|
while ((attribute = [argsEnum nextObject]))
|
|
[attribute awakeWithPropertyList: propertyList];
|
|
}
|
|
|
|
- (void)encodeIntoPropertyList: (NSMutableDictionary *)propertyList
|
|
{
|
|
return;
|
|
}
|
|
|
|
- (NSString *)name
|
|
{
|
|
return _name;
|
|
}
|
|
|
|
- (NSString *)externalName
|
|
{
|
|
return _externalName;
|
|
}
|
|
|
|
- (EOModel *)model
|
|
{
|
|
return _model;
|
|
}
|
|
|
|
- (NSArray *)arguments
|
|
{
|
|
return _arguments;
|
|
}
|
|
|
|
- (NSDictionary *)userInfo
|
|
{
|
|
return _userInfo;
|
|
}
|
|
|
|
- (void)setName: (NSString *)name
|
|
{
|
|
ASSIGN(_name, name);
|
|
}
|
|
|
|
- (void)setExternalName: (NSString *)name
|
|
{
|
|
ASSIGN(_externalName, name);
|
|
}
|
|
|
|
- (void)setArguments: (NSArray *)arguments
|
|
{
|
|
if ([arguments isKindOfClass: [GCArray class]]
|
|
|| [arguments isKindOfClass: [GCMutableArray class]])
|
|
ASSIGN(_arguments, arguments);
|
|
else
|
|
_arguments = [[GCArray alloc] initWithArray: arguments];
|
|
}
|
|
|
|
- (void)setUserInfo: (NSDictionary *)dictionary
|
|
{
|
|
ASSIGN(_userInfo, dictionary);
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
@implementation EOStoredProcedure (EOModelBeautifier)
|
|
|
|
- (void)beautifyName
|
|
{
|
|
NSArray *listItems;
|
|
NSString *newString = [NSMutableString string];
|
|
int anz, i;
|
|
|
|
EOFLOGObjectFnStartOrCond2(@"ModelingClasses", @"EOStoredProcedure");
|
|
|
|
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]];
|
|
}
|
|
|
|
NS_DURING
|
|
[self setName: newString];
|
|
NS_HANDLER
|
|
NSLog(@"%@ in Class: EOStoredProcedure , Method: beautifyName >> error : %@",
|
|
[localException name], [localException reason]);
|
|
NS_ENDHANDLER;
|
|
}
|
|
|
|
EOFLOGObjectFnStopOrCond2(@"ModelingClasses", @"EOStoredProcedure");
|
|
}
|
|
|
|
@end
|