ginjo-rfm 2.0.2 → 2.1.0.pre02
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rfm.rb +4 -0
- data/lib/rfm/VERSION +1 -1
- data/lib/rfm/base.rb +19 -2
- data/lib/rfm/database.rb +33 -13
- data/lib/rfm/layout.rb +56 -18
- data/lib/rfm/metadata/field.rb +6 -6
- data/lib/rfm/record.rb +38 -15
- data/lib/rfm/resultset.rb +79 -59
- data/lib/rfm/server.rb +48 -26
- data/lib/rfm/utilities/config.rb +60 -36
- data/lib/rfm/utilities/core_ext.rb +67 -1
- data/lib/rfm/utilities/factory.rb +44 -27
- data/lib/rfm/utilities/fmpxmlresult.rb +167 -0
- data/lib/rfm/utilities/fmresultset.rb +153 -0
- data/lib/rfm/utilities/xml_parser.rb +12 -0
- metadata +41 -37
data/lib/rfm.rb
CHANGED
@@ -32,6 +32,10 @@ module Rfm
|
|
32
32
|
autoload :Factory, 'rfm/utilities/factory'
|
33
33
|
autoload :CompoundQuery,'rfm/utilities/compound_query'
|
34
34
|
autoload :VERSION, 'rfm/version'
|
35
|
+
autoload :Fmresultset, 'rfm/utilities/fmresultset.rb'
|
36
|
+
autoload :Fmpxmlresult, 'rfm/utilities/fmpxmlresult.rb'
|
37
|
+
autoload :Fmpdsoresult, 'rfm/utilities/fmpdsoresult.rb'
|
38
|
+
autoload :Fmpxmllayout, 'rfm/utilities/fmpxmllayout.rb'
|
35
39
|
|
36
40
|
module Metadata
|
37
41
|
autoload :Script, 'rfm/metadata/script'
|
data/lib/rfm/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.1.0.pre02
|
data/lib/rfm/base.rb
CHANGED
@@ -43,6 +43,9 @@ module Rfm
|
|
43
43
|
class Layout
|
44
44
|
|
45
45
|
class SubLayout < DelegateClass(Layout)
|
46
|
+
# Added by wbr to give config heirarchy: layout -> model -> sublayout
|
47
|
+
include Config
|
48
|
+
|
46
49
|
include Layout::LayoutModule
|
47
50
|
attr_accessor :model, :parent_layout
|
48
51
|
|
@@ -79,6 +82,10 @@ module Rfm
|
|
79
82
|
@layout = layout_obj
|
80
83
|
end
|
81
84
|
@model = model_class
|
85
|
+
|
86
|
+
# Added by wbr to give config heirarchy: layout -> model -> sublayout
|
87
|
+
model.config :parent=>'@layout.parent_layout'
|
88
|
+
config :parent=>'model'
|
82
89
|
end
|
83
90
|
sub.model.to_s.constantize
|
84
91
|
rescue StandardError, SyntaxError
|
@@ -172,7 +179,7 @@ module Rfm
|
|
172
179
|
end
|
173
180
|
|
174
181
|
def initialize(record={}, resultset_obj=[], field_meta='', layout_obj=self.class.layout, portal=nil)
|
175
|
-
if resultset_obj == [] and !record.has_key? 'field'
|
182
|
+
if resultset_obj == [] and !record.respond_to?(:columns) #.has_key? 'field'
|
176
183
|
@mods = Rfm::CaseInsensitiveHash.new
|
177
184
|
@layout = layout_obj
|
178
185
|
@resultset = Resultset.allocate
|
@@ -219,10 +226,20 @@ module Rfm
|
|
219
226
|
return @layout if @layout
|
220
227
|
cnf = get_config
|
221
228
|
return unless cnf[:layout]
|
222
|
-
@layout = Rfm::Factory.layout(
|
229
|
+
@layout = Rfm::Factory.layout(cnf).sublayout
|
230
|
+
|
231
|
+
# Added by wbr to give config heirarchy: layout -> model -> sublayout
|
232
|
+
config :parent=>'parent_layout'
|
233
|
+
@layout.config :parent=>'model'
|
234
|
+
|
223
235
|
@layout.model = self
|
224
236
|
@layout
|
225
237
|
end
|
238
|
+
|
239
|
+
# Access the parent layout of this model
|
240
|
+
def parent_layout
|
241
|
+
layout.parent_layout
|
242
|
+
end
|
226
243
|
|
227
244
|
# Just like Layout#find, but searching by record_id will return a record, not a resultset.
|
228
245
|
def find(find_criteria, options={})
|
data/lib/rfm/database.rb
CHANGED
@@ -58,6 +58,7 @@ module Rfm
|
|
58
58
|
# * *name* is the name of this database
|
59
59
|
# * *state* is a hash of all server options used to initialize this server
|
60
60
|
class Database
|
61
|
+
include Config
|
61
62
|
|
62
63
|
# Initialize a database object. You never really need to do this. Instead, just do this:
|
63
64
|
#
|
@@ -65,21 +66,40 @@ module Rfm
|
|
65
66
|
# myDatabase = myServer["Customers"]
|
66
67
|
#
|
67
68
|
# This sample code gets a database object representing the Customers database on the FileMaker server.
|
68
|
-
def initialize(name, server_obj, acnt=nil, pass=nil
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
69
|
+
def initialize(*args) #name, server_obj, acnt=nil, pass=nil
|
70
|
+
options = get_config(*args)
|
71
|
+
rfm_metaclass.instance_variable_set :@server, (options[:objects].delete_at(0) || options[:server_object])
|
72
|
+
options = get_config(options)
|
73
|
+
|
74
|
+
config sanitize_config(options, {}, true)
|
75
|
+
config :parent=> 'server'
|
76
|
+
config :database=> options[:strings].delete_at(0) || options[:database]
|
77
|
+
config :account_name=> options[:strings].delete_at(0) || options[:account_name]
|
78
|
+
config :password=> options[:strings].delete_at(0) || options[:password]
|
79
|
+
|
80
|
+
raise Rfm::Error::RfmError.new(0, "New instance of Rfm::Database has no name. Attempted name '#{state[:database]}'.") if state[:database].to_s == ''
|
81
|
+
|
82
|
+
@layouts = Rfm::Factory::LayoutFactory.new(server, self)
|
83
|
+
@scripts = Rfm::Factory::ScriptFactory.new(server, self)
|
76
84
|
end
|
77
85
|
|
78
86
|
meta_attr_reader :server
|
79
|
-
|
80
|
-
|
81
|
-
attr_writer :account_name, :password
|
82
|
-
|
87
|
+
attr_reader :layouts, :scripts
|
88
|
+
# Not sure if these writers are ever used
|
89
|
+
#attr_writer :account_name, :password
|
90
|
+
# Legacy methods
|
91
|
+
alias_method :layout, :layouts
|
92
|
+
alias_method :script, :scripts
|
93
|
+
|
94
|
+
def name; state[:database].to_s; end
|
95
|
+
def account_name; state[:account_name]; end
|
96
|
+
def account_name=(x); config :account_name=>x; end
|
97
|
+
def password; state[:password]; end
|
98
|
+
def password=(x); config :password=>x; end
|
99
|
+
|
100
|
+
def state(*args)
|
101
|
+
get_config(*args)
|
102
|
+
end
|
83
103
|
|
84
104
|
# Access the Layout object representing a layout in this database. For example:
|
85
105
|
#
|
@@ -95,7 +115,7 @@ module Rfm
|
|
95
115
|
# def [](layout_name)
|
96
116
|
# self.layout[layout_name]
|
97
117
|
# end
|
98
|
-
def_delegator :
|
118
|
+
def_delegator :layouts, :[]
|
99
119
|
|
100
120
|
end
|
101
121
|
end
|
data/lib/rfm/layout.rb
CHANGED
@@ -119,6 +119,7 @@ module Rfm
|
|
119
119
|
# list that is attached to any field on the layout
|
120
120
|
|
121
121
|
class Layout
|
122
|
+
include Config
|
122
123
|
|
123
124
|
# Initialize a layout object. You never really need to do this. Instead, just do this:
|
124
125
|
#
|
@@ -133,32 +134,44 @@ module Rfm
|
|
133
134
|
#
|
134
135
|
# myServer = Rfm::Server.new(...)
|
135
136
|
# myLayout = myServer["Customers"]["Details"]
|
136
|
-
def initialize(name, db_obj
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
def initialize(*args) #name, db_obj
|
138
|
+
options = get_config(*args)
|
139
|
+
rfm_metaclass.instance_variable_set :@db, (options[:objects].delete_at(0) || options[:database_object])
|
140
|
+
config :parent=> 'db'
|
141
|
+
options = get_config(options)
|
142
|
+
|
143
|
+
config sanitize_config(options, {}, true)
|
144
|
+
config :layout => options[:strings].delete_at(0) || options[:layout]
|
145
|
+
|
146
|
+
raise Rfm::Error::RfmError.new(0, "New instance of Rfm::Layout has no name. Attempted name '#{state[:layout]}'.") if state[:layout].to_s == ''
|
147
|
+
|
141
148
|
@loaded = false
|
142
149
|
@field_controls = Rfm::CaseInsensitiveHash.new
|
143
150
|
@value_lists = Rfm::CaseInsensitiveHash.new
|
144
|
-
#
|
145
|
-
#
|
146
|
-
|
151
|
+
# @portal_meta = nil
|
152
|
+
# @field_names = nil
|
153
|
+
#@ignore_bad_data = (db_obj.server.state[:ignore_bad_data] rescue nil)
|
147
154
|
end
|
148
155
|
|
149
156
|
meta_attr_reader :db
|
150
|
-
attr_reader :name #, :db
|
157
|
+
#attr_reader :name #, :db
|
151
158
|
attr_writer :field_names, :portal_meta, :table
|
152
159
|
def_delegator :db, :server
|
153
160
|
alias_method :database, :db
|
154
|
-
|
161
|
+
|
162
|
+
# This method may be obsolete, since the option can now be set with #config.
|
163
|
+
def ignore_bad_data(val = nil)
|
164
|
+
(config :ignore_bad_data => val) unless val.nil?
|
165
|
+
state[:ignore_bad_data]
|
166
|
+
end
|
155
167
|
|
156
168
|
# These methods are to be inclulded in Layout and SubLayout, so that
|
157
|
-
# they have their own
|
169
|
+
# they have their own discrete 'self' in the master class and the subclass.
|
158
170
|
# This means these methods will not get forwarded, and will talk to the correct
|
159
171
|
# variables & objects of the correct self.
|
160
172
|
# Do not get or set instance variables in Layout from other objects directly,
|
161
173
|
# always use getter & setter methods.
|
174
|
+
# This all means that any chain of methods that want to refer ultimately to Sublayout, must all be defined or included in Sublayout
|
162
175
|
module LayoutModule
|
163
176
|
|
164
177
|
# Returns a ResultSet object containing _every record_ in the table associated with this layout.
|
@@ -251,9 +264,13 @@ module Rfm
|
|
251
264
|
end
|
252
265
|
|
253
266
|
def get_records(action, extra_params = {}, options = {})
|
267
|
+
# The grammar stuff here won't work properly until you handle config between models/sublayouts/layout/server.
|
268
|
+
grammar_option = state(options)[:grammar]
|
269
|
+
options.merge!(:grammar=>grammar_option) if grammar_option
|
254
270
|
include_portals = options[:include_portals] ? options.delete(:include_portals) : nil
|
255
|
-
xml_response =
|
256
|
-
Rfm::Resultset.new(db.server, xml_response, self, include_portals)
|
271
|
+
xml_response = server.connect(state[:account_name], state[:password], action, params.merge(extra_params), options).body
|
272
|
+
#Rfm::Resultset.new(db.server, xml_response, self, include_portals)
|
273
|
+
Rfm::Resultset.new(xml_response, self, include_portals)
|
257
274
|
end
|
258
275
|
|
259
276
|
def params
|
@@ -281,9 +298,35 @@ module Rfm
|
|
281
298
|
end
|
282
299
|
hash
|
283
300
|
end
|
301
|
+
|
302
|
+
def name; state[:layout].to_s; end
|
284
303
|
|
304
|
+
def state(*args)
|
305
|
+
get_config(*args)
|
306
|
+
end
|
307
|
+
|
285
308
|
end # LayoutModule
|
309
|
+
|
286
310
|
include LayoutModule
|
311
|
+
|
312
|
+
|
313
|
+
###
|
314
|
+
def view_meta
|
315
|
+
@view_meta ||= view
|
316
|
+
end
|
317
|
+
def date_format
|
318
|
+
@date_format ||= view_meta.date_format
|
319
|
+
end
|
320
|
+
def time_format
|
321
|
+
@time_format ||= view_meta.time_format
|
322
|
+
end
|
323
|
+
def timestamp_format
|
324
|
+
@timestamp_format ||= view_meta.timestamp_format
|
325
|
+
end
|
326
|
+
def field_meta
|
327
|
+
@field_meta ||= view_meta.field_meta
|
328
|
+
end
|
329
|
+
###
|
287
330
|
|
288
331
|
|
289
332
|
def field_controls
|
@@ -377,11 +420,6 @@ module Rfm
|
|
377
420
|
@field_controls.freeze
|
378
421
|
end
|
379
422
|
|
380
|
-
def ignore_bad_data(val = nil)
|
381
|
-
(@ignore_bad_data = val) unless val.nil?
|
382
|
-
@ignore_bad_data
|
383
|
-
end
|
384
|
-
|
385
423
|
private :load, :get_records, :params
|
386
424
|
|
387
425
|
|
data/lib/rfm/metadata/field.rb
CHANGED
@@ -64,11 +64,11 @@ module Rfm
|
|
64
64
|
# Initializes a field object. You'll never need to do this. Instead, get your Field objects from
|
65
65
|
# ResultSet::fields
|
66
66
|
def initialize(field)
|
67
|
-
@name = field['name']
|
68
|
-
@result = field['result']
|
69
|
-
@type = field['type']
|
70
|
-
@max_repeats = field['max-repeats']
|
71
|
-
@global = field['global']
|
67
|
+
@name = field.name #['name']
|
68
|
+
@result = field.result #['result']
|
69
|
+
@type = field.type #['type']
|
70
|
+
@max_repeats = field.max_repeats #['max-repeats']
|
71
|
+
@global = field.global #['global']
|
72
72
|
end
|
73
73
|
|
74
74
|
# Coerces the text value from an +fmresultset+ document into proper Ruby types based on the
|
@@ -76,7 +76,7 @@ module Rfm
|
|
76
76
|
# access field data through the Record object.
|
77
77
|
def coerce(value, resultset)
|
78
78
|
return nil if (value.nil? or value.empty?)
|
79
|
-
case self.result
|
79
|
+
case self.result.downcase
|
80
80
|
when "text" then value
|
81
81
|
when "number" then BigDecimal.new(value)
|
82
82
|
when "date" then Date.strptime(value, resultset.date_format)
|
data/lib/rfm/record.rb
CHANGED
@@ -114,27 +114,26 @@ module Rfm
|
|
114
114
|
def_delegators :layout, :db, :database, :server
|
115
115
|
|
116
116
|
def initialize(record, resultset_obj, field_meta, layout_obj, portal=nil)
|
117
|
-
|
117
|
+
|
118
118
|
@layout = layout_obj
|
119
119
|
@resultset = resultset_obj
|
120
|
-
@record_id = record
|
121
|
-
@mod_id = record
|
120
|
+
@record_id = record.record_id rescue nil
|
121
|
+
@mod_id = record.mod_id rescue nil
|
122
122
|
@mods = {}
|
123
123
|
@portals ||= Rfm::CaseInsensitiveHash.new
|
124
124
|
|
125
|
-
relatedsets = !portal && resultset_obj.instance_variable_get(:@include_portals) ? record
|
126
|
-
|
127
|
-
record
|
125
|
+
relatedsets = !portal && resultset_obj.instance_variable_get(:@include_portals) ? record.portals : []
|
126
|
+
|
127
|
+
record.columns.each do |field|
|
128
128
|
next unless field
|
129
|
-
field_name = field
|
129
|
+
field_name = field.name
|
130
130
|
field_name.gsub!(Regexp.new(portal + '::'), '') if portal
|
131
131
|
datum = []
|
132
|
-
|
133
|
-
data = field['data']; data = data.is_a?(Hash) ? [data] : data
|
132
|
+
data = field.data #['data']; data = data.is_a?(Hash) ? [data] : data
|
134
133
|
data.each do |x|
|
135
134
|
next unless field_meta[field_name]
|
136
135
|
begin
|
137
|
-
datum.push(field_meta[field_name].coerce(x['__content__'], resultset_obj))
|
136
|
+
datum.push(field_meta[field_name].coerce(x, resultset_obj)) #(x['__content__'], resultset_obj))
|
138
137
|
rescue StandardError => error
|
139
138
|
self.errors.add(field_name, error) if self.respond_to? :errors
|
140
139
|
raise error unless @layout.ignore_bad_data
|
@@ -153,9 +152,9 @@ module Rfm
|
|
153
152
|
unless relatedsets.empty?
|
154
153
|
relatedsets.each do |relatedset|
|
155
154
|
next if relatedset.blank?
|
156
|
-
tablename, records = relatedset
|
155
|
+
tablename, records = relatedset.table, []
|
157
156
|
|
158
|
-
relatedset
|
157
|
+
relatedset.records.each do |record|
|
159
158
|
next unless record
|
160
159
|
records << self.class.new(record, resultset_obj, resultset_obj.portal_meta[tablename], layout_obj, tablename)
|
161
160
|
end
|
@@ -223,15 +222,39 @@ module Rfm
|
|
223
222
|
super
|
224
223
|
end
|
225
224
|
|
226
|
-
|
227
225
|
def []=(key, value)
|
228
226
|
key_string = key.to_s.downcase
|
229
227
|
return super unless @loaded # is this needed?
|
230
228
|
raise Rfm::ParameterError, "You attempted to modify a field that does not exist in the current Filemaker layout." unless self.key?(key_string)
|
231
|
-
@mods[key_string] = value
|
229
|
+
# @mods[key_string] = value
|
230
|
+
# TODO: This needs cleaning up.
|
231
|
+
# TODO: can we get field_type from record instead?
|
232
|
+
@mods[key_string] = if [Date, Time, DateTime].member?(value.class)
|
233
|
+
field_type = layout.field_meta[key_string.to_sym].result
|
234
|
+
case field_type
|
235
|
+
when 'time'; val.strftime(layout.time_format)
|
236
|
+
when 'date'; val.strftime(layout.date_format)
|
237
|
+
when 'timestamp'; val.strftime(layout.timestamp_format)
|
238
|
+
else value
|
239
|
+
end
|
240
|
+
else value
|
241
|
+
end
|
232
242
|
super(key, value)
|
233
243
|
end
|
234
|
-
|
244
|
+
#
|
245
|
+
# alias_method :old_setter, '[]='
|
246
|
+
# def []=(key,val)
|
247
|
+
# old_setter(key,val)
|
248
|
+
# return val unless [Date, Time, DateTime].member? val.class
|
249
|
+
# field_type = layout.field_meta[key.to_sym].result
|
250
|
+
# @mods[key] = case field_type
|
251
|
+
# when 'time'; val.strftime(layout.time_format)
|
252
|
+
# when 'date'; val.strftime(layout.date_format)
|
253
|
+
# when 'timestamp'; val.strftime(layout.timestamp_format)
|
254
|
+
# else val
|
255
|
+
# end
|
256
|
+
# end
|
257
|
+
|
235
258
|
def field_names
|
236
259
|
resultset.field_names rescue layout.field_names
|
237
260
|
end
|
data/lib/rfm/resultset.rb
CHANGED
@@ -36,12 +36,18 @@ module Rfm
|
|
36
36
|
# it provides metadata about the portals in the ResultSet and the Fields on those portals
|
37
37
|
|
38
38
|
class Resultset < Array
|
39
|
+
include Config
|
39
40
|
|
40
|
-
attr_reader :layout, :server
|
41
|
-
attr_reader :field_meta, :portal_meta
|
41
|
+
attr_reader :layout, :database, :server, :caller, :doc
|
42
|
+
attr_reader :field_meta, :portal_meta, :include_portals, :datasource
|
42
43
|
attr_reader :date_format, :time_format, :timestamp_format
|
43
44
|
attr_reader :total_count, :foundset_count, :table
|
44
|
-
def_delegators :layout, :db, :database
|
45
|
+
#def_delegators :layout, :db, :database
|
46
|
+
alias_method :db, :database
|
47
|
+
|
48
|
+
class << self
|
49
|
+
alias_method :load_data, :new
|
50
|
+
end
|
45
51
|
|
46
52
|
# Initializes a new ResultSet object. You will probably never do this your self (instead, use the Layout
|
47
53
|
# object to get various ResultSet obejects).
|
@@ -64,53 +70,72 @@ module Rfm
|
|
64
70
|
# * *portals* is a hash (with table occurrence names for keys and Field objects for values). If your
|
65
71
|
# layout contains portals, you can find out what fields they contain here. Again, if it's the data you're
|
66
72
|
# after, you want to look at the Record object.
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
@include_portals = portals
|
73
|
+
def initialize(*args) # xml_response, caller, portals
|
74
|
+
#Was (server_obj, xml_response, layout_obj, portals=nil)
|
75
|
+
|
76
|
+
options = args.rfm_extract_options!
|
77
|
+
config :parent=>'caller'
|
78
|
+
config sanitize_config(options, {}, true)
|
74
79
|
|
75
|
-
|
80
|
+
xml_response = args[0] || options[:xml_response]
|
81
|
+
doc = XmlParser.parse(xml_response, :namespace=>false, :parser=>(state[:parser] rescue nil))
|
76
82
|
|
77
|
-
error = doc
|
83
|
+
error = doc.error
|
78
84
|
check_for_errors(error, (server.state[:raise_on_401] rescue nil))
|
85
|
+
|
86
|
+
@doc = doc
|
87
|
+
@caller = args[1] || options[:caller]
|
88
|
+
@layout = (@caller.class.ancestors.include? Rfm::Layout::LayoutModule) ? @caller : options[:layout_object]
|
89
|
+
@database = (@layout.database rescue nil) || (@caller.class == Rfm::Database ? @caller : options[:database_object])
|
90
|
+
@server = (@database.server rescue nil) || (@caller.class == Rfm::Server ? @caller : options[:server_object])
|
91
|
+
@field_meta ||= Rfm::CaseInsensitiveHash.new
|
92
|
+
@portal_meta ||= Rfm::CaseInsensitiveHash.new
|
93
|
+
@include_portals = args[2] || options[:include_portals]
|
79
94
|
|
80
|
-
@datasource = doc
|
81
|
-
meta = doc
|
82
|
-
resultset = doc
|
95
|
+
@datasource = doc.datasource
|
96
|
+
meta = doc.meta
|
97
|
+
resultset = doc.resultset
|
83
98
|
|
84
|
-
@date_format =
|
85
|
-
@time_format =
|
86
|
-
@timestamp_format =
|
99
|
+
@date_format = doc.date_format
|
100
|
+
@time_format = doc.time_format
|
101
|
+
@timestamp_format = doc.timestamp_format
|
87
102
|
|
88
|
-
@foundset_count =
|
89
|
-
@total_count =
|
90
|
-
@table =
|
91
|
-
|
103
|
+
@foundset_count = doc.foundset_count
|
104
|
+
@total_count = doc.total_count
|
105
|
+
@table = doc.table
|
106
|
+
|
92
107
|
(layout.table = @table) if layout and layout.table_no_load.blank?
|
93
108
|
|
94
|
-
parse_fields(
|
109
|
+
parse_fields(doc)
|
95
110
|
|
96
111
|
# This will always load portal meta, even if :include_portals was not specified.
|
97
112
|
# See Record for control of portal data loading.
|
98
|
-
parse_portals(
|
113
|
+
parse_portals(doc)
|
99
114
|
|
100
115
|
# These were added for loading resultset from file
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
116
|
+
# Kind of a hack. This should ideally condense down to just another option on the main @layout = ...
|
117
|
+
# unless @layout
|
118
|
+
# @layout = @datasource['layout']
|
119
|
+
# @layout.instance_variable_set '@database', @datasource['database']
|
120
|
+
# @layout.instance_eval do
|
121
|
+
# def database
|
122
|
+
# @database
|
123
|
+
# end
|
124
|
+
# end
|
125
|
+
# end
|
110
126
|
|
111
|
-
return if
|
112
|
-
Rfm::Record.build_records(
|
127
|
+
return if doc.records.blank?
|
128
|
+
Rfm::Record.build_records(doc.records, self, @field_meta, @layout)
|
113
129
|
end
|
130
|
+
|
131
|
+
# Load Resultset data from file-spec or string
|
132
|
+
# def self.load_data(file_or_string)
|
133
|
+
# self.new(file_or_string, nil)
|
134
|
+
# end
|
135
|
+
|
136
|
+
def state(*args)
|
137
|
+
get_config(*args)
|
138
|
+
end
|
114
139
|
|
115
140
|
def field_names
|
116
141
|
field_meta.collect{|k,v| v.name}
|
@@ -120,34 +145,29 @@ module Rfm
|
|
120
145
|
portal_meta.keys
|
121
146
|
end
|
122
147
|
|
123
|
-
# Load Resultset data from file-spec or string
|
124
|
-
def self.load_data(file_or_string)
|
125
|
-
self.new(nil, file_or_string, nil)
|
126
|
-
end
|
127
|
-
|
128
148
|
private
|
129
149
|
|
130
150
|
def check_for_errors(code, raise_401)
|
131
151
|
raise Rfm::Error.getError(code) if code != 0 && (code != 401 || raise_401)
|
132
152
|
end
|
133
153
|
|
134
|
-
def parse_fields(
|
135
|
-
return if
|
154
|
+
def parse_fields(doc)
|
155
|
+
return if doc.fields.blank?
|
136
156
|
|
137
|
-
|
138
|
-
@field_meta[field
|
157
|
+
doc.fields.each do |field|
|
158
|
+
@field_meta[field.name] = Rfm::Metadata::Field.new(field)
|
139
159
|
end
|
140
160
|
(layout.field_names = field_names) if layout and layout.field_names_no_load.blank?
|
141
161
|
end
|
142
162
|
|
143
|
-
def parse_portals(
|
144
|
-
return if
|
145
|
-
|
163
|
+
def parse_portals(doc)
|
164
|
+
return if doc.portals.blank?
|
165
|
+
doc.portals.each do |relatedset|
|
146
166
|
next if relatedset.blank?
|
147
|
-
table, fields = relatedset
|
167
|
+
table, fields = relatedset.table, {}
|
148
168
|
|
149
|
-
relatedset
|
150
|
-
name = field
|
169
|
+
relatedset.fields.each do |field|
|
170
|
+
name = field.name.to_s.gsub(Regexp.new(table + '::'), '')
|
151
171
|
fields[name] = Rfm::Metadata::Field.new(field)
|
152
172
|
end
|
153
173
|
|
@@ -156,15 +176,15 @@ module Rfm
|
|
156
176
|
(layout.portal_meta = @portal_meta) if layout and layout.portal_meta_no_load.blank?
|
157
177
|
end
|
158
178
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
179
|
+
# def convert_date_time_format(fm_format)
|
180
|
+
# fm_format.gsub!('MM', '%m')
|
181
|
+
# fm_format.gsub!('dd', '%d')
|
182
|
+
# fm_format.gsub!('yyyy', '%Y')
|
183
|
+
# fm_format.gsub!('HH', '%H')
|
184
|
+
# fm_format.gsub!('mm', '%M')
|
185
|
+
# fm_format.gsub!('ss', '%S')
|
186
|
+
# fm_format
|
187
|
+
# end
|
168
188
|
|
169
189
|
end
|
170
190
|
end
|