]> err.no Git - sope/blob - sope-gdl1/FrontBase2/FrontBase2Adaptor.m
corrected a wrong (intermediary) committed version, updated ChangeLog this time ;-)
[sope] / sope-gdl1 / FrontBase2 / FrontBase2Adaptor.m
1 /* 
2    FBAdaptor.m
3
4    Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
5
6    Author: Helge Hess (helge.hess@mdlink.de)
7
8    This file is part of the FB Adaptor Library
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Library General Public
12    License as published by the Free Software Foundation; either
13    version 2 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Library General Public License for more details.
19
20    You should have received a copy of the GNU Library General Public
21    License along with this library; see the file COPYING.LIB.
22    If not, write to the Free Software Foundation,
23    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25 // $Id: FrontBase2Adaptor.m 1 2004-08-20 10:38:46Z znek $
26
27 #import "common.h"
28
29 NSString *FBNotificationName = @"FBNotification";
30
31 @interface FrontBase2Adaptor(FetchUserTypes)
32 - (void)_fetchUserTypes;
33 @end
34
35 @implementation FrontBase2Adaptor
36
37 + (void)initialize {
38   static BOOL isInitialized = NO;
39
40   if (!isInitialized) {
41     void __init_FBValues(void);
42     isInitialized = YES;
43     __init_FBValues();
44   }
45 }
46
47 - (id)initWithName:(NSString *)_name {
48   if ((self = [super initWithName:_name])) {
49   }
50   return self;
51 }
52
53 #if !LIB_FOUNDATION_BOEHM_GC
54 - (void)dealloc {
55   if (self->typeNameToCode) {
56     NSFreeMapTable(self->typeNameToCode);
57     self->typeCodeToName = NULL;
58   }
59   if (self->typeCodeToName) {
60     NSFreeMapTable(self->typeCodeToName);
61     self->typeCodeToName = NULL;
62   }
63   [super dealloc];
64 }
65 #endif
66
67 /* NSCopying methods */
68
69 - (id)copyWithZone:(NSZone *)_zone {
70   // copy is needed during creation of NSNotification object
71   return RETAIN(self); 
72 }
73
74 /* connections */
75
76 - (NSString *)serverName {
77   NSString *serverName;
78
79   serverName = [[self connectionDictionary] objectForKey:@"hostName"];
80
81   return AUTORELEASE([serverName copy]);
82 }
83 - (NSString *)loginName {
84   return AUTORELEASE([[[self connectionDictionary]
85                              objectForKey:@"userName"] copy]);
86 }
87 - (NSString *)loginPassword {
88   return AUTORELEASE([[[self connectionDictionary]
89                              objectForKey:@"password"] copy]);
90 }
91 - (NSString *)databaseName {
92   return AUTORELEASE([[[self connectionDictionary]
93                              objectForKey:@"databaseName"] copy]);
94 }
95 - (NSString *)databasePassword {
96   return AUTORELEASE([[[self connectionDictionary]
97                              objectForKey:@"databasePassword"] copy]);
98 }
99
100 - (NSString *)transactionIsolationLevel {
101   return AUTORELEASE([[[self connectionDictionary]
102                              objectForKey:@"transactionIsolationLevel"] copy]);
103 }
104 - (NSString *)lockingDiscipline {
105   return AUTORELEASE([[[self connectionDictionary]
106                              objectForKey:@"lockingDiscipline"] copy]);
107 }
108
109 /* key generation */
110
111 - (NSString *)newKeyExpression {
112   return AUTORELEASE([[[self pkeyGeneratorDictionary]
113                              objectForKey:@"newKeyExpression"]
114                              copy]);
115 }
116
117 /* formatting values */
118
119 - (NSString *)formatAttribute:(EOAttribute *)_attribute {
120   return [NSString stringWithFormat:@"\"%s\"",
121                      [[_attribute columnName] cString]];
122 }
123
124 - (NSString *)lowerExpressionForTextAttributeNamed:(NSString *)_attrName {
125   return  [NSString stringWithFormat:@"LOWER(%@)", _attrName];
126 }
127
128 - (NSString *)expressionForTextValue:(id)_value {
129   return [_value lowercaseString];
130 }
131
132 - (NSString *)charConvertExpressionForAttributeNamed:(NSString *)_attrName {
133   return [NSString stringWithFormat:@"CAST(%@ AS VARCHAR(255))", _attrName];
134 }
135
136 - (id)formatValue:(id)value forAttribute:(EOAttribute *)attribute {
137   int      fbType;
138   NSString *result;
139
140   fbType = [self typeCodeForExternalName:[attribute externalType]];
141   result = [value stringValueForFrontBaseType:fbType
142                   attribute:attribute];
143
144 #if 0
145   NSLog(@"formatting value %@ result %@", value, result);
146   NSLog(@"  value class %@ attr %@ attr type %@",
147                [value class], attribute, [attribute externalType]);
148 #endif
149   return result;
150 }
151
152 /* adaptor info */
153
154 - (Class)adaptorContextClass {
155   return [FrontBaseContext class];
156 }
157 - (Class)adaptorChannelClass {
158   return [FrontBaseChannel class];
159 }
160
161 - (Class)expressionClass {
162   return [FBSQLExpression class];
163 }
164
165 @end /* FrontBase2Adaptor */