lardawge-rfm 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rfm_error.rb DELETED
@@ -1,252 +0,0 @@
1
- require "set"
2
-
3
- # These classes wrap the filemaker error codes. FileMakerError is the base class of this hierarchy.
4
- #
5
- # One could get a FileMakerError by doing:
6
- # err = Rfm::Error::FileMakerError.getError(102)
7
- #
8
- # The above code would return a FieldMissingError instance. Your could use this instance to raise that appropriate
9
- # exception:
10
- #
11
- # raise err
12
- #
13
- # You could access the specific error code by accessing:
14
- #
15
- # err.code
16
- #
17
- # Author:: Mufaddal Khumri
18
- # Copyright:: Copyright (c) 2007 Six Fried Rice, LLC and Mufaddal Khumri
19
- # License:: See MIT-LICENSE for details
20
- module Rfm::Error
21
-
22
- class RfmError < StandardError
23
- end
24
-
25
- class CommunicationError < RfmError
26
- end
27
-
28
- class ParameterError < RfmError
29
- end
30
-
31
- class AuthenticationError < RfmError
32
- end
33
-
34
- # Base class for all FileMaker errors
35
- class FileMakerError < RfmError
36
- attr_accessor :code
37
-
38
- # Default filemaker error message map
39
- @@default_messages = {}
40
-
41
- # This method instantiates and returns the appropriate FileMakerError object depending on the error code passed to it. It
42
- # also accepts an optional message.
43
- def self.getError(code, message = nil)
44
- if @@default_messages == nil or @@default_messages.size == 0
45
- (0..99).each{|i| @@default_messages[i] = 'SystemError occurred.'}
46
- (100..199).each{|i| @@default_messages[i] = 'MissingError occurred.'}
47
- @@default_messages[102] = 'FieldMissingError occurred.'
48
- @@default_messages[104] = 'ScriptMissingError occurred.'
49
- @@default_messages[105] = 'LayoutMissingError occurred.'
50
- @@default_messages[106] = 'TableMissingError occurred.'
51
- (200..299).each{|i| @@default_messages[i] = 'SecurityError occurred.'}
52
- @@default_messages[200] = 'RecordAccessDeniedError occurred.'
53
- @@default_messages[201] = 'FieldCannotBeModifiedError occurred.'
54
- @@default_messages[202] = 'FieldAccessIsDeniedError occurred.'
55
- (300..399).each{|i| @@default_messages[i] = 'ConcurrencyError occurred.'}
56
- @@default_messages[301] = 'RecordInUseError occurred.'
57
- @@default_messages[302] = 'TableInUseError occurred.'
58
- @@default_messages[306] = 'RecordModIdDoesNotMatchError occurred.'
59
- (400..499).each{|i| @@default_messages[i] = 'GeneralError occurred.'}
60
- @@default_messages[401] = 'NoRecordsFoundError occurred.'
61
- (500..599).each{|i| @@default_messages[i] = 'ValidationError occurred.'}
62
- @@default_messages[500] = 'DateValidationError occurred.'
63
- @@default_messages[501] = 'TimeValidationError occurred.'
64
- @@default_messages[502] = 'NumberValidationError occurred.'
65
- @@default_messages[503] = 'RangeValidationError occurred.'
66
- @@default_messages[504] = 'UniqueValidationError occurred.'
67
- @@default_messages[505] = 'ExistingValidationError occurred.'
68
- @@default_messages[506] = 'ValueListValidationError occurred.'
69
- @@default_messages[507] = 'ValidationCalculationError occurred.'
70
- @@default_messages[508] = 'InvalidFindModeValueError occurred.'
71
- @@default_messages[511] = 'MaximumCharactersValidationError occurred.'
72
- (800..899).each{|i| @@default_messages[i] = 'FileError occurred.'}
73
- @@default_messages[802] = 'UnableToOpenFileError occurred.'
74
- end
75
-
76
- message = @@default_messages[code] if message == nil || message.strip == ''
77
- message += " (FileMaker Error ##{code})"
78
-
79
- if 0 <= code and code <= 99
80
- err = SystemError.new(message)
81
- elsif 100 <= code and code <= 199
82
- if code == 101
83
- err = RecordMissingError.new(message)
84
- elsif code == 102
85
- err = FieldMissingError.new(message)
86
- elsif code == 104
87
- err = ScriptMissingError.new(message)
88
- elsif code == 105
89
- err = LayoutMissingError.new(message)
90
- elsif code == 106
91
- err = TableMissingError.new(message)
92
- else
93
- err = MissingError.new(message)
94
- end
95
- elsif 200 <= code and code <= 299
96
- if code == 200
97
- err = RecordAccessDeniedError.new(message)
98
- elsif code == 201
99
- err = FieldCannotBeModifiedError.new(message)
100
- elsif code == 202
101
- err = FieldAccessIsDeniedError.new(message)
102
- else
103
- err = SecurityError.new(message)
104
- end
105
- elsif 300 <= code and code <= 399
106
- if code == 301
107
- err = RecordInUseError.new(message)
108
- elsif code == 302
109
- err = TableInUseError.new(message)
110
- elsif code == 306
111
- err = RecordModIdDoesNotMatchError.new(message)
112
- else
113
- err = ConcurrencyError.new(message)
114
- end
115
- elsif 400 <= code and code <= 499
116
- if code == 401
117
- err = NoRecordsFoundError.new(message)
118
- else
119
- err = GeneralError.new(message)
120
- end
121
- elsif 500 <= code and code <= 599
122
- if code == 500
123
- err = DateValidationError.new(message)
124
- elsif code == 501
125
- err = TimeValidationError.new(message)
126
- elsif code == 502
127
- err = NumberValidationError.new(message)
128
- elsif code == 503
129
- err = RangeValidationError.new(message)
130
- elsif code == 504
131
- err = UniqueValidationError.new(message)
132
- elsif code == 505
133
- err = ExistingValidationError.new(message)
134
- elsif code == 506
135
- err = ValueListValidationError.new(message)
136
- elsif code == 507
137
- err = ValidationCalculationError.new(message)
138
- elsif code == 508
139
- err = InvalidFindModeValueError.new(message)
140
- elsif code == 511
141
- err = MaximumCharactersValidationError.new(message)
142
- else
143
- err = ValidationError.new(message)
144
- end
145
- elsif 800 <= code and code <= 899
146
- if code == 802
147
- err = UnableToOpenFileError.new(message)
148
- else
149
- err = FileError.new(message)
150
- end
151
- else
152
- # called for code == -1 or any other code not handled above.
153
- err = UnknownError.new(message)
154
- end
155
- err.code = code
156
- return err
157
- end
158
- end
159
-
160
- class UnknownError < FileMakerError
161
- end
162
-
163
- class SystemError < FileMakerError
164
- end
165
-
166
- class MissingError < FileMakerError
167
- end
168
-
169
- class RecordMissingError < MissingError
170
- end
171
-
172
- class FieldMissingError < MissingError
173
- end
174
-
175
- class ScriptMissingError < MissingError
176
- end
177
-
178
- class LayoutMissingError < MissingError
179
- end
180
-
181
- class TableMissingError < MissingError
182
- end
183
-
184
- class SecurityError < FileMakerError
185
- end
186
-
187
- class RecordAccessDeniedError < SecurityError
188
- end
189
-
190
- class FieldCannotBeModifiedError < SecurityError
191
- end
192
-
193
- class FieldAccessIsDeniedError < SecurityError
194
- end
195
-
196
- class ConcurrencyError < FileMakerError
197
- end
198
-
199
- class RecordInUseError < ConcurrencyError
200
- end
201
-
202
- class TableInUseError < ConcurrencyError
203
- end
204
-
205
- class RecordModIdDoesNotMatchError < ConcurrencyError
206
- end
207
-
208
- class GeneralError < FileMakerError
209
- end
210
-
211
- class NoRecordsFoundError < GeneralError
212
- end
213
-
214
- class ValidationError < FileMakerError
215
- end
216
-
217
- class DateValidationError < ValidationError
218
- end
219
-
220
- class TimeValidationError < ValidationError
221
- end
222
-
223
- class NumberValidationError < ValidationError
224
- end
225
-
226
- class RangeValidationError < ValidationError
227
- end
228
-
229
- class UniqueValidationError < ValidationError
230
- end
231
-
232
- class ExistingValidationError < ValidationError
233
- end
234
-
235
- class ValueListValidationError < ValidationError
236
- end
237
-
238
- class ValidationCalculationError < ValidationError
239
- end
240
-
241
- class InvalidFindModeValueError < ValidationError
242
- end
243
-
244
- class MaximumCharactersValidationError < ValidationError
245
- end
246
-
247
- class FileError < FileMakerError
248
- end
249
-
250
- class UnableToOpenFileError < FileError
251
- end
252
- end
data/lib/rfm_factory.rb DELETED
@@ -1,82 +0,0 @@
1
- # The classes in this module are used internally by RFM and are not intended for outside
2
- # use.
3
- #
4
- # Author:: Geoff Coffey (mailto:gwcoffey@gmail.com)
5
- # Copyright:: Copyright (c) 2007 Six Fried Rice, LLC and Mufaddal Khumri
6
- # License:: See MIT-LICENSE for details
7
-
8
- module Rfm::Factory # :nodoc: all
9
- class DbFactory < Rfm::Util::CaseInsensitiveHash
10
-
11
- def initialize(server)
12
- @server = server
13
- @loaded = false
14
- end
15
-
16
- def [](dbname)
17
- super or (self[dbname] = Rfm::Database.new(dbname, @server))
18
- end
19
-
20
- def all
21
- if !@loaded
22
- Rfm::Result::ResultSet.new(@server, @server.do_action(@server.state[:account_name], @server.state[:password], '-dbnames', {}).body).each {|record|
23
- name = record['DATABASE_NAME']
24
- self[name] = Rfm::Database.new(name, @server) if self[name] == nil
25
- }
26
- @loaded = true
27
- end
28
- self.values
29
- end
30
-
31
- end
32
-
33
- class LayoutFactory < Rfm::Util::CaseInsensitiveHash
34
-
35
- def initialize(server, database)
36
- @server = server
37
- @database = database
38
- @loaded = false
39
- end
40
-
41
- def [](layout_name)
42
- super or (self[layout_name] = Rfm::Layout.new(layout_name, @database))
43
- end
44
-
45
- def all
46
- if !@loaded
47
- Rfm::Result::ResultSet.new(@server, @server.do_action(@server.state[:account_name], @server.state[:password], '-layoutnames', {"-db" => @database.name}).body).each {|record|
48
- name = record['LAYOUT_NAME']
49
- self[name] = Rfm::Layout.new(name, @database) if self[name] == nil
50
- }
51
- @loaded = true
52
- end
53
- self.values
54
- end
55
-
56
- end
57
-
58
- class ScriptFactory < Rfm::Util::CaseInsensitiveHash
59
-
60
- def initialize(server, database)
61
- @server = server
62
- @database = database
63
- @loaded = false
64
- end
65
-
66
- def [](script_name)
67
- super or (self[script_name] = Rfm::Script.new(script_name, @database))
68
- end
69
-
70
- def all
71
- if !@loaded
72
- Rfm::Result::ResultSet.new(@server, @server.do_action(@server.state[:account_name], @server.state[:password], '-scriptnames', {"-db" => @database.name}).body).each {|record|
73
- name = record['SCRIPT_NAME']
74
- self[name] = Rfm::Script.new(name, @database) if self[name] == nil
75
- }
76
- @loaded = true
77
- end
78
- self.values
79
- end
80
-
81
- end
82
- end