lorj 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +39 -579
- data/Rakefile +7 -0
- data/example/students_1/student_v1.md +115 -0
- data/example/students_1/students.rb +8 -2
- data/example/students_2/process/students.rb +5 -5
- data/example/students_2/student_v2.md +90 -0
- data/example/students_2/students.rb +6 -6
- data/example/students_3/controller/yaml_students.rb +23 -73
- data/example/students_3/controller/yaml_students_code.rb +106 -0
- data/example/students_3/controller/yaml_students_def.rb +69 -0
- data/example/students_3/process/students.rb +23 -157
- data/example/students_3/student_v3.md +283 -0
- data/example/students_3/students.rb +26 -83
- data/example/students_4/controller/yaml_students.rb +51 -0
- data/example/students_4/controller/yaml_students_code.rb +109 -0
- data/example/students_4/controller/yaml_students_def.rb +72 -0
- data/example/students_4/process/students/code/students.rb +103 -0
- data/example/students_4/process/students/definition/students.rb +60 -0
- data/example/students_4/process/students.rb +29 -0
- data/example/students_4/student_v4.md +191 -0
- data/example/students_4/students.rb +65 -0
- data/example/students_5/controller/yaml_students.rb +106 -0
- data/example/{students_3 → students_5}/controller/yaml_students_controller.rb +5 -3
- data/example/students_5/process/students.rb +182 -0
- data/example/students_5/student_v5.md +382 -0
- data/example/students_5/students.rb +119 -0
- data/example/yaml_students/students.rb +1 -1
- data/example/yaml_students/yaml_students.rb +102 -23
- data/lib/concept.md +3 -3
- data/lib/core/core.rb +15 -15
- data/lib/core/core_controller.rb +49 -24
- data/lib/core/core_internal.rb +2 -2
- data/lib/core/core_model.rb +13 -7
- data/lib/core/core_object_data.rb +18 -18
- data/lib/core/core_object_params.rb +75 -34
- data/lib/core/core_process.rb +104 -59
- data/lib/core/core_process_setup.rb +11 -11
- data/lib/core/core_setup_ask.rb +24 -14
- data/lib/core/core_setup_encrypt.rb +17 -15
- data/lib/core/core_setup_init.rb +19 -15
- data/lib/core/core_setup_list.rb +12 -12
- data/lib/core/definition.rb +20 -20
- data/lib/core/definition_internal.rb +20 -10
- data/lib/core/lorj_basecontroller.rb +8 -8
- data/lib/core/lorj_basedefinition.rb +47 -126
- data/lib/core/lorj_baseprocess.rb +81 -57
- data/lib/core/lorj_data.rb +28 -27
- data/lib/core/lorj_keypath.rb +1 -1
- data/lib/core_process/cloud/process/flavor.rb +3 -2
- data/lib/core_process/cloud/process/keypairs.rb +5 -4
- data/lib/core_process/cloud/process/network.rb +4 -3
- data/lib/core_process/cloud/process/public_ip.rb +3 -2
- data/lib/core_process/cloud/process/rules.rb +7 -6
- data/lib/core_process/cloud/process/security_groups.rb +1 -1
- data/lib/core_process/cloud/process/server.rb +1 -1
- data/lib/core_process/cloud/process/server_log.rb +1 -1
- data/lib/core_process/cloud/process/subnetwork.rb +4 -1
- data/lib/core_process/cloud_process.rb +1 -1
- data/lib/logging.rb +41 -48
- data/lib/lorj/version.rb +1 -1
- data/lib/lorj.rb +7 -0
- data/lib/lorj_account.rb +3 -3
- data/lib/lorj_config.rb +1 -1
- data/lib/lorj_defaults.rb +222 -26
- data/lib/overview.md +120 -0
- data/lib/prc.rb +97 -24
- data/lib/prc_core_config.rb +134 -52
- data/lib/providers/hpcloud/compute.rb +3 -3
- data/lib/providers/hpcloud/hpcloud.rb +14 -14
- data/lib/providers/hpcloud/network.rb +4 -4
- data/lib/providers/hpcloud/security_groups.rb +1 -1
- data/lib/providers/mock/mock.rb +3 -3
- data/lib/providers/openstack/openstack.rb +12 -12
- data/lib/providers/templates/compute.rb +6 -6
- data/lib/rh.rb +7 -5
- data/spec/04_prc_core_config_spec.rb +52 -0
- data/spec/11_lorj_config_spec.rb +1 -1
- metadata +21 -3
data/lib/core/core_setup_ask.rb
CHANGED
@@ -54,6 +54,10 @@ module Lorj
|
|
54
54
|
|
55
55
|
@config.set(data, value)
|
56
56
|
|
57
|
+
section = _get_account_section(data)
|
58
|
+
@config.set(data, value, :name =>
|
59
|
+
'account', :section => section) unless section.nil?
|
60
|
+
|
57
61
|
break if options[:post_step_function].nil?
|
58
62
|
|
59
63
|
proc = options[:post_step_function]
|
@@ -89,8 +93,9 @@ module Lorj
|
|
89
93
|
when :process_call
|
90
94
|
result = _setup_list_from_process_call(obj_to_load, list_options)
|
91
95
|
else
|
92
|
-
runtime_fail "'%s' invalid.
|
93
|
-
|
96
|
+
PrcLib.runtime_fail "%s: '%s' invalid query type. valid is: '%s'.",
|
97
|
+
obj_to_load, list_options[:values_type],
|
98
|
+
[:controller_call, :query_call, :process_call]
|
94
99
|
end
|
95
100
|
result
|
96
101
|
end
|
@@ -158,7 +163,7 @@ module Lorj
|
|
158
163
|
say_msg = format("Select '%s' from the list:", desc)
|
159
164
|
say_msg += format(' |%s|', default) unless default.nil?
|
160
165
|
say(say_msg)
|
161
|
-
value = choose do |
|
166
|
+
value = choose do |q|
|
162
167
|
q.choices(*list)
|
163
168
|
q.default = default if default
|
164
169
|
end
|
@@ -187,23 +192,27 @@ module Lorj
|
|
187
192
|
default = options[:default_value] if default.nil?
|
188
193
|
default = @config.get(data, default)
|
189
194
|
|
190
|
-
validate_proc = options[:validate_function]
|
195
|
+
# validate_proc = options[:validate_function]
|
191
196
|
proc_ask = options[:ask_function]
|
192
197
|
|
193
198
|
if proc_ask.nil?
|
194
|
-
proc_method = _ask
|
199
|
+
# proc_method = _ask(desc, default, valid_regex,
|
200
|
+
# is_encrypted, is_required)
|
201
|
+
value = _ask(desc, default, valid_regex,
|
202
|
+
is_encrypted, is_required)
|
195
203
|
else
|
196
|
-
proc_method = @process.method(proc_ask)
|
204
|
+
# proc_method = @process.method(proc_ask)
|
205
|
+
value = @process.method(proc_ask)
|
197
206
|
end
|
198
207
|
|
199
|
-
loop do
|
200
|
-
|
201
|
-
|
202
|
-
|
208
|
+
# loop do
|
209
|
+
# value = proc_method.call(desc, default, valid_regex,
|
210
|
+
# is_encrypted, is_required)
|
211
|
+
# break if validate_proc.nil?
|
203
212
|
|
204
|
-
|
205
|
-
|
206
|
-
end
|
213
|
+
# validate_method = @process.method(validate_proc)
|
214
|
+
# break if validate_method.call(value)
|
215
|
+
# end
|
207
216
|
value
|
208
217
|
end
|
209
218
|
|
@@ -223,11 +232,12 @@ module Lorj
|
|
223
232
|
# *raise*:
|
224
233
|
#
|
225
234
|
def _ask(sDesc, default, rValidate, bEncrypted, bRequired)
|
235
|
+
value = nil
|
226
236
|
loop do
|
227
237
|
if bEncrypted
|
228
238
|
value = _ask_encrypted(sDesc, default)
|
229
239
|
else
|
230
|
-
value = ask(format('Enter %s:
|
240
|
+
value = ask(format('Enter %s:', sDesc)) do |q|
|
231
241
|
q.default = default unless default.nil?
|
232
242
|
q.validate = rValidate unless rValidate.nil?
|
233
243
|
end
|
@@ -52,7 +52,10 @@ module Lorj
|
|
52
52
|
}
|
53
53
|
|
54
54
|
Lorj.debug(2, "Writing '%s' key file", key_file)
|
55
|
-
|
55
|
+
PrcLib.ensure_dir_exists(
|
56
|
+
PrcLib.pdata_path
|
57
|
+
) unless PrcLib.dir_exists?(PrcLib.pdata_path)
|
58
|
+
File.open(key_file, 'w+') do |out|
|
56
59
|
out.write(Base64.encode64(entr.to_yaml))
|
57
60
|
end
|
58
61
|
else
|
@@ -81,16 +84,15 @@ module Lorj
|
|
81
84
|
value_hidden = ''
|
82
85
|
begin
|
83
86
|
value_hidden = '*' * Encryptor.decrypt(
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
:value => Base64.strict_decode64(enc_value),
|
88
|
+
:key => entr[:key],
|
89
|
+
:iv => Base64.strict_decode64(entr[:iv]),
|
90
|
+
:salt => entr[:salt]
|
88
91
|
).length
|
89
92
|
rescue
|
90
|
-
|
91
|
-
|
93
|
+
PrcLib.error('Unable to decrypt your %s. You will need to re-enter it.',
|
94
|
+
sDesc)
|
92
95
|
else
|
93
|
-
value_hidden = format('[%s]', value_hidden)
|
94
96
|
PrcLib.message("'%s' is already set. If you want to keep it,"\
|
95
97
|
' just press Enter', sDesc)
|
96
98
|
end
|
@@ -119,7 +121,7 @@ module Lorj
|
|
119
121
|
value_free = ''
|
120
122
|
while value_free == ''
|
121
123
|
# ask for encrypted data.
|
122
|
-
value_free = ask(format('Enter %s:
|
124
|
+
value_free = ask(format('Enter %s: |%s|', sDesc, value_hidden)) do |q|
|
123
125
|
q.echo = '*'
|
124
126
|
end
|
125
127
|
if value_free == '' && enc_value
|
@@ -134,12 +136,12 @@ module Lorj
|
|
134
136
|
end
|
135
137
|
end
|
136
138
|
Base64.strict_encode64(
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
Encryptor.encrypt(
|
140
|
+
:value => value_free,
|
141
|
+
:key => entr[:key],
|
142
|
+
:iv => Base64.strict_decode64(entr[:iv]),
|
143
|
+
:salt => entr[:salt]
|
144
|
+
)
|
143
145
|
)
|
144
146
|
end
|
145
147
|
end
|
data/lib/core/core_setup_init.rb
CHANGED
@@ -37,9 +37,9 @@ module Lorj
|
|
37
37
|
# * *Raises* :
|
38
38
|
#
|
39
39
|
def _setup_load
|
40
|
-
ask_steps = Lorj.defaults.
|
40
|
+
ask_steps = Lorj.defaults.data.rh_get(:setup, :ask_step)
|
41
41
|
setup_steps = []
|
42
|
-
ask_steps.each do |
|
42
|
+
ask_steps.each do |value|
|
43
43
|
setup_steps << {
|
44
44
|
:desc => value[:desc],
|
45
45
|
:explanation => value[:explanation],
|
@@ -63,12 +63,12 @@ module Lorj
|
|
63
63
|
# * *Raises* :
|
64
64
|
#
|
65
65
|
def _setup_check_additional(setup_steps)
|
66
|
-
setup_steps.each_index do |
|
66
|
+
setup_steps.each_index do |step|
|
67
67
|
value = setup_steps[step]
|
68
68
|
next unless value.rh_exist?(:add)
|
69
69
|
|
70
70
|
datas_to_add = value.rh_get(:add)
|
71
|
-
datas_to_add.each do |
|
71
|
+
datas_to_add.each do |data_to_add|
|
72
72
|
order_array = setup_steps[step][:order]
|
73
73
|
next if _setup_attr_already_added?(order_array, data_to_add)
|
74
74
|
|
@@ -145,11 +145,13 @@ module Lorj
|
|
145
145
|
Lorj.debug(2, 'Ask step %s:', step)
|
146
146
|
puts ANSI.bold(setup_step[:desc]) unless setup_step[:desc].nil?
|
147
147
|
begin
|
148
|
-
erb_msg = ANSI.yellow(
|
148
|
+
erb_msg = ANSI.yellow(
|
149
|
+
erb(setup_step[:explanation])
|
150
|
+
) unless setup_step[:explanation].nil?
|
149
151
|
rescue => e
|
150
|
-
PrcLib.
|
152
|
+
PrcLib.error "setup step '%d/:explanation' : %s", step, e.message
|
151
153
|
end
|
152
|
-
puts format("%s\n\n", erb_msg) unless
|
154
|
+
puts format("%s\n\n", erb_msg) unless erb_msg.nil?
|
153
155
|
end
|
154
156
|
|
155
157
|
# internal setup function to display step information
|
@@ -172,14 +174,14 @@ module Lorj
|
|
172
174
|
data,
|
173
175
|
erb(options[:explanation]))
|
174
176
|
rescue => e
|
175
|
-
PrcLib.
|
177
|
+
PrcLib.error "setup key '%s/:explanation' : %s", data, e.message
|
176
178
|
end
|
177
179
|
end
|
178
180
|
|
179
181
|
begin
|
180
182
|
desc = erb(options[:desc]) unless options[:desc].nil?
|
181
183
|
rescue => e
|
182
|
-
PrcLib.
|
184
|
+
PrcLib.error "setup key '%s/:desc' : %s", data, e.message
|
183
185
|
end
|
184
186
|
|
185
187
|
desc
|
@@ -202,22 +204,24 @@ module Lorj
|
|
202
204
|
#
|
203
205
|
def _setup_ask(setup_steps)
|
204
206
|
# Ask for user input
|
205
|
-
|
206
|
-
|
207
|
+
# TODO: Enhance to support section::data to avoid duplicated data name
|
208
|
+
# against sections.
|
209
|
+
setup_steps.each_index do |iStep|
|
210
|
+
_setup_display_step(setup_steps[iStep], iStep)
|
207
211
|
|
208
212
|
order_array = setup_steps[iStep][:order]
|
209
213
|
|
210
|
-
order_array.each_index do |
|
214
|
+
order_array.each_index do |iIndex|
|
211
215
|
Lorj.debug(2, 'Ask order %s:', iIndex)
|
212
|
-
order_array[iIndex].each do |
|
213
|
-
options =
|
216
|
+
order_array[iIndex].each do |data|
|
217
|
+
options = _get_meta_data_auto(data)
|
214
218
|
options = {} if options.nil?
|
215
219
|
|
216
220
|
data_desc = _setup_display_data(data, options)
|
217
221
|
|
218
222
|
if options[:pre_step_function]
|
219
223
|
proc = options[:pre_step_function]
|
220
|
-
next unless @
|
224
|
+
next unless @process.method(proc).call(data)
|
221
225
|
end
|
222
226
|
|
223
227
|
_setup_ask_data(data_desc, data, options)
|
data/lib/core/core_setup_list.rb
CHANGED
@@ -43,23 +43,23 @@ module Lorj
|
|
43
43
|
PrcLib.message("Loading #{obj_to_load}.")
|
44
44
|
|
45
45
|
object = @object_data[obj_to_load, :ObjectData]
|
46
|
-
object =
|
46
|
+
object = process_create(obj_to_load) if object.nil?
|
47
47
|
return nil if object.nil?
|
48
48
|
|
49
49
|
params = ObjectData.new
|
50
50
|
params.add(object)
|
51
51
|
params << list_options[:query_params]
|
52
52
|
|
53
|
-
runtime_fail '%s: query_type => :controller_call '\
|
53
|
+
PrcLib.runtime_fail '%s: query_type => :controller_call '\
|
54
54
|
'requires missing :query_call declaration'\
|
55
55
|
' (Controller function)',
|
56
|
-
|
56
|
+
data if list_options[:query_call].nil?
|
57
57
|
|
58
58
|
proc = list_options[:query_call]
|
59
59
|
begin
|
60
60
|
list = @controller.method(proc).call(obj_to_load, params)
|
61
61
|
rescue => e
|
62
|
-
runtime_fail "Error during call of '%s':\n%s", proc, e.message
|
62
|
+
PrcLib.runtime_fail "Error during call of '%s':\n%s", proc, e.message
|
63
63
|
end
|
64
64
|
{ :list => list, :default_value => nil }
|
65
65
|
end
|
@@ -83,10 +83,10 @@ module Lorj
|
|
83
83
|
query_hash = list_options[:query_params]
|
84
84
|
query_hash = {} if query_hash.nil?
|
85
85
|
|
86
|
-
object_list =
|
86
|
+
object_list = process_query(obj_to_load, query_hash)
|
87
87
|
|
88
88
|
list = []
|
89
|
-
object_list.each { |
|
89
|
+
object_list.each { |oElem| list << oElem[list_options[:value]] }
|
90
90
|
|
91
91
|
{ :list => list.sort!, :default_value => nil }
|
92
92
|
end
|
@@ -94,11 +94,11 @@ module Lorj
|
|
94
94
|
def _setup_build_process_params(option_params, params)
|
95
95
|
return if option_params.nil?
|
96
96
|
|
97
|
-
option_params.each do |
|
97
|
+
option_params.each do |key, value|
|
98
98
|
match_res = value.match(/lorj::config\[(.*)\]/)
|
99
99
|
if match_res
|
100
100
|
extract = match_res[1].split(', ')
|
101
|
-
extract.map! { |
|
101
|
+
extract.map! { |v| v[1..-1].to_sym if v[0] == ':' }
|
102
102
|
params << { key => config[extract] }
|
103
103
|
else
|
104
104
|
params << { key => value }
|
@@ -120,10 +120,10 @@ module Lorj
|
|
120
120
|
# * *Raises* :
|
121
121
|
#
|
122
122
|
def _setup_list_from_process_call(obj_to_load, list_options)
|
123
|
-
runtime_fail '%s: query_type => :process_call'\
|
123
|
+
PrcLib.runtime_fail '%s: query_type => :process_call'\
|
124
124
|
' requires missing :query_call declaration'\
|
125
125
|
' (Provider function)',
|
126
|
-
|
126
|
+
data if list_options[:query_call].nil?
|
127
127
|
proc = list_options[:query_call]
|
128
128
|
obj_to_load = list_options[:object]
|
129
129
|
PrcLib.debug(2, "Running process '#{proc}' on '#{obj_to_load}'.")
|
@@ -138,8 +138,8 @@ module Lorj
|
|
138
138
|
proc_method = @process.method(proc)
|
139
139
|
result = proc_method.call(obj_to_load, params)
|
140
140
|
rescue => e
|
141
|
-
runtime_fail "Error during call of '%s':\n%s",
|
142
|
-
|
141
|
+
PrcLib.runtime_fail "Error during call of '%s':\n%s",
|
142
|
+
proc, e.message
|
143
143
|
end
|
144
144
|
|
145
145
|
if result.is_a?(Hash)
|
data/lib/core/definition.rb
CHANGED
@@ -68,7 +68,7 @@ module Lorj
|
|
68
68
|
PrcLib.model.heap true
|
69
69
|
supported_options = [:use_controller]
|
70
70
|
unless hOptions.nil?
|
71
|
-
hOptions.each_key do |
|
71
|
+
hOptions.each_key do |key|
|
72
72
|
case key
|
73
73
|
when :use_controller
|
74
74
|
value = hOptions.rh_get(:use_controller)
|
@@ -127,7 +127,7 @@ module Lorj
|
|
127
127
|
lorj_object = PrcLib.model.meta_obj.rh_get(obj_type_name)
|
128
128
|
|
129
129
|
# Checking handlers_options data
|
130
|
-
|
130
|
+
_verify_handlers(obj_type_name, lorj_object, handlers)
|
131
131
|
|
132
132
|
if lorj_object.nil?
|
133
133
|
lorj_object = _define_obj_initialize(obj_type_name, handlers)
|
@@ -241,10 +241,10 @@ module Lorj
|
|
241
241
|
key_path = KeyPath.new(key)
|
242
242
|
|
243
243
|
PrcLib.model.meta_obj.rh_set(nil, PrcLib.model.object_context,
|
244
|
-
:returns, key_path.
|
244
|
+
:returns, key_path.fpath)
|
245
245
|
PrcLib.model.attribute_context key_path
|
246
246
|
Lorj.debug(4, "%s: Undefining attribute mapping '%s'",
|
247
|
-
PrcLib.model.object_context, key_path.
|
247
|
+
PrcLib.model.object_context, key_path.fpath)
|
248
248
|
|
249
249
|
_query_mapping(key, nil)
|
250
250
|
end
|
@@ -315,7 +315,7 @@ module Lorj
|
|
315
315
|
value = { data => { :options => hOptions } }
|
316
316
|
|
317
317
|
PrcLib.model.predefine_data_value.rh_set(value,
|
318
|
-
key_path.
|
318
|
+
key_path.fpath, :values)
|
319
319
|
end
|
320
320
|
|
321
321
|
# function to interpret a template data, and use ERBConfig as data context.
|
@@ -376,11 +376,11 @@ module Lorj
|
|
376
376
|
|
377
377
|
return nil unless _decl_data_valid?(value, map)
|
378
378
|
|
379
|
-
object_type = PrcLib.model.object_context
|
379
|
+
object_type = PrcLib.model.object_context
|
380
380
|
|
381
381
|
key_path = PrcLib.model.attribute_context __callee__
|
382
382
|
|
383
|
-
keypath = key_path.
|
383
|
+
keypath = key_path.fpath
|
384
384
|
Lorj.debug(2, "%s-%s: Attribute value mapping '%s' => '%s'",
|
385
385
|
object_type, key_path.to_s, value, map)
|
386
386
|
PrcLib.model.meta_obj.rh_set(map,
|
@@ -437,7 +437,7 @@ module Lorj
|
|
437
437
|
|
438
438
|
object_type = PrcLib.model.object_context(fct_context)
|
439
439
|
|
440
|
-
key_access = KeyPath.new(attr_name).
|
440
|
+
key_access = KeyPath.new(attr_name).fpath
|
441
441
|
|
442
442
|
# PrcLib.model.meta_obj://<Object>/:params/:keys/<keypath> must exist.
|
443
443
|
object_param = PrcLib.model.meta_obj.rh_get(object_type,
|
@@ -468,8 +468,8 @@ module Lorj
|
|
468
468
|
|
469
469
|
PrcLib.model.attribute_context key_path
|
470
470
|
|
471
|
-
PrcLib.model.meta_obj.rh_set(map_path_obj.
|
472
|
-
:query_mapping, key_path.
|
471
|
+
PrcLib.model.meta_obj.rh_set(map_path_obj.fpath, object_type,
|
472
|
+
:query_mapping, key_path.fpath)
|
473
473
|
end
|
474
474
|
|
475
475
|
# Internal function to store object attribute and mapping information
|
@@ -485,14 +485,14 @@ module Lorj
|
|
485
485
|
|
486
486
|
map_path_obj = KeyPath.new(map)
|
487
487
|
|
488
|
-
PrcLib.model.meta_obj.rh_set(map_path_obj.
|
489
|
-
:returns, key_path_obj.
|
488
|
+
PrcLib.model.meta_obj.rh_set(map_path_obj.fpath, object_type,
|
489
|
+
:returns, key_path_obj.fpath)
|
490
490
|
|
491
491
|
PrcLib.model.attribute_context key_path_obj
|
492
492
|
|
493
493
|
return if options[:not_queriable] == true
|
494
494
|
query_mapping(key, map)
|
495
|
-
[key_path_obj.
|
495
|
+
[key_path_obj.fpath, map_path_obj.fpath]
|
496
496
|
end
|
497
497
|
|
498
498
|
# Internal section detection
|
@@ -516,8 +516,8 @@ module Lorj
|
|
516
516
|
# Internal model data validation
|
517
517
|
# return true if valid. false otherwise.
|
518
518
|
def self._decl_data_valid?(value, map)
|
519
|
-
return false
|
520
|
-
return false
|
519
|
+
return false unless [String, Symbol].include?(value.class)
|
520
|
+
return false unless [NilClass, Symbol, String].include?(map.class)
|
521
521
|
true
|
522
522
|
end
|
523
523
|
|
@@ -535,7 +535,7 @@ module Lorj
|
|
535
535
|
:params)
|
536
536
|
|
537
537
|
PrcLib.model.attribute_context KeyPath.new(name)
|
538
|
-
key_access = PrcLib.model.attribute_context.
|
538
|
+
key_access = PrcLib.model.attribute_context.fpath
|
539
539
|
|
540
540
|
unless top_param_obj[:keys].key?(key_access)
|
541
541
|
top_param_obj[:keys][key_access] = {}
|
@@ -551,10 +551,10 @@ module Lorj
|
|
551
551
|
|
552
552
|
case type
|
553
553
|
when :data
|
554
|
-
return _obj_needs_data(params[:keys][attribute.
|
554
|
+
return _obj_needs_data(params[:keys][attribute.fpath],
|
555
555
|
msg_action, options)
|
556
556
|
when :CloudObject, :object
|
557
|
-
return _obj_needs_object(params[:keys][attribute.
|
557
|
+
return _obj_needs_object(params[:keys][attribute.fpath],
|
558
558
|
options)
|
559
559
|
end
|
560
560
|
PrcLib.dcl_fail("%s: Object parameter type '%s' unknown.",
|
@@ -651,8 +651,8 @@ module Lorj
|
|
651
651
|
return handlers if object.nil?
|
652
652
|
|
653
653
|
handlers_list = object[:lambdas].keys.join(', ')
|
654
|
-
handlers.each_key do |
|
655
|
-
next if
|
654
|
+
handlers.each_key do |key|
|
655
|
+
next if object.rh_exist?(:lambdas, key)
|
656
656
|
|
657
657
|
PrcLib.dcl_fail("'%s' parameter is invalid. Use '%s'",
|
658
658
|
key, handlers_list)
|
@@ -34,6 +34,16 @@ module Lorj
|
|
34
34
|
meta_default.merge!(meta)
|
35
35
|
end
|
36
36
|
|
37
|
+
def _get_meta_data_auto(key)
|
38
|
+
return nil if key.nil?
|
39
|
+
Lorj.defaults.get_meta_auto(key)
|
40
|
+
end
|
41
|
+
|
42
|
+
def _get_account_section(key)
|
43
|
+
return nil if key.nil?
|
44
|
+
Lorj.defaults.get_meta_section(key)
|
45
|
+
end
|
46
|
+
|
37
47
|
# internal runtime function for process call
|
38
48
|
# Get the controller result and map controller object data to
|
39
49
|
# lorj object attributes, using controller mapping function.
|
@@ -67,7 +77,7 @@ module Lorj
|
|
67
77
|
value = _call_controller_map(map_handler, oControlerObject,
|
68
78
|
map_obj.tree)
|
69
79
|
value = _mapping_data(object_type, key_obj, object_opts, value)
|
70
|
-
attr_value.rh_set(value,
|
80
|
+
attr_value.rh_set(value, key_obj.tree)
|
71
81
|
end
|
72
82
|
attr_value
|
73
83
|
end
|
@@ -152,15 +162,15 @@ module Lorj
|
|
152
162
|
def _mapping_data(object_type, key_obj, object_opts, value)
|
153
163
|
value_mapping = object_opts.rh_get(:value_mapping, key_obj.fpath)
|
154
164
|
if value_mapping && !value.nil?
|
155
|
-
value_mapping.each do |
|
165
|
+
value_mapping.each do |map_key, map_value|
|
156
166
|
next unless value == map_value
|
157
167
|
Lorj.debug(5, "Object '%s' value mapped '%s': '%s' => '%s'",
|
158
168
|
object_type, key_obj.tree,
|
159
169
|
value, map_value)
|
160
170
|
return map_key
|
161
171
|
end
|
162
|
-
runtime_fail("'%s.%s': No controller value mapping for '%s'.",
|
163
|
-
|
172
|
+
PrcLib.runtime_fail("'%s.%s': No controller value mapping for '%s'.",
|
173
|
+
object_type, key_obj.tree, value)
|
164
174
|
end
|
165
175
|
|
166
176
|
Lorj.debug(5, "Object '%s' value '%s' extracted: '%s'",
|
@@ -198,9 +208,9 @@ module Lorj
|
|
198
208
|
object_missing << object_type
|
199
209
|
end
|
200
210
|
|
201
|
-
attr_paths.each do |
|
211
|
+
attr_paths.each do |attr_path, attr_options|
|
202
212
|
next if attr_options[:for] && !attr_options[:for].include?(sEventType)
|
203
|
-
_check_required_attr(object_missing,
|
213
|
+
_check_required_attr(object_missing, attr_path, attr_options, fname)
|
204
214
|
end
|
205
215
|
object_missing
|
206
216
|
end
|
@@ -212,16 +222,16 @@ module Lorj
|
|
212
222
|
#
|
213
223
|
# *parameters*:
|
214
224
|
# - +object_missing+ : Array of missing object for process caller.
|
215
|
-
# - +
|
216
|
-
# - +attr_options+ :
|
217
|
-
# - +fname+ :
|
225
|
+
# - +attr_path+ : String. Attribute/data path (See KeyPath.fpath)
|
226
|
+
# - +attr_options+ : Hash. Attribute options
|
227
|
+
# - +fname+ : String. Caller function
|
218
228
|
#
|
219
229
|
# *return*:
|
220
230
|
#
|
221
231
|
# *raise*:
|
222
232
|
# - runtime error if required data is not set. (empty or nil)
|
223
233
|
#
|
224
|
-
def _check_required_attr(object_missing,
|
234
|
+
def _check_required_attr(object_missing, attr_path, attr_options, fname)
|
225
235
|
attr_obj = KeyPath.new(attr_path)
|
226
236
|
|
227
237
|
attr_name = attr_obj.key
|
@@ -31,37 +31,37 @@ module Lorj
|
|
31
31
|
# Default handlers which needs to be defined by the controller,
|
32
32
|
# called by BaseDefinition Create functions.
|
33
33
|
def connect(_sObjectType, _hParams)
|
34
|
-
|
34
|
+
controller_error 'connect has not been redefined by the controller.'
|
35
35
|
end
|
36
36
|
|
37
37
|
# Default handlers which needs to be defined by the controller,
|
38
38
|
# called by BaseDefinition Create functions.
|
39
39
|
def create(_sObjectType, _hParams)
|
40
|
-
|
40
|
+
controller_error 'create_object has not been redefined by the controller.'
|
41
41
|
end
|
42
42
|
|
43
43
|
# Default handlers which needs to be defined by the controller,
|
44
44
|
# called by BaseDefinition Delete functions.
|
45
45
|
def delete(_sObjectType, _hParams)
|
46
|
-
|
46
|
+
controller_error 'delete_object has not been redefined by the controller.'
|
47
47
|
end
|
48
48
|
|
49
49
|
# Default handlers which needs to be defined by the controller,
|
50
50
|
# called by BaseDefinition Get functions.
|
51
51
|
def get(_sObjectType, _sUniqId, _hParams)
|
52
|
-
|
52
|
+
controller_error 'get_object has not been redefined by the controller.'
|
53
53
|
end
|
54
54
|
|
55
55
|
# Default handlers which needs to be defined by the controller,
|
56
56
|
# called by BaseDefinition Query functions.
|
57
57
|
def query(_sObjectType, _sQuery, _hParams)
|
58
|
-
|
58
|
+
controller_error 'query_object has not been redefined by the controller.'
|
59
59
|
end
|
60
60
|
|
61
61
|
# Default handlers which needs to be defined by the controller,
|
62
62
|
# called by BaseDefinition Update functions.
|
63
63
|
def update(_sObjectType, _oObject, _hParams)
|
64
|
-
|
64
|
+
controller_error 'update_object has not been redefined by the controller.'
|
65
65
|
end
|
66
66
|
|
67
67
|
# Simply raise an error
|
@@ -74,7 +74,7 @@ module Lorj
|
|
74
74
|
# - Lorj::PrcError
|
75
75
|
def controller_error(msg, *p)
|
76
76
|
msg = format(msg, *p)
|
77
|
-
|
77
|
+
fail Lorj::PrcError.new, format('%s: %s', self.class, msg)
|
78
78
|
end
|
79
79
|
|
80
80
|
# check if required data is loaded. raise an error if not
|
@@ -89,7 +89,7 @@ module Lorj
|
|
89
89
|
def required?(oParams, *key)
|
90
90
|
return if oParams.exist?(key)
|
91
91
|
|
92
|
-
|
92
|
+
controller_error '%s is not set.', key
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|