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
@@ -133,10 +133,10 @@ module Lorj
|
|
133
133
|
# nothing
|
134
134
|
def add(oDataObject)
|
135
135
|
# Requires to be a valid framework object.
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
unless oDataObject.is_a?(Lorj::Data)
|
137
|
+
PrcLib.runtime_fail "Invalid Framework object type '%s'.",
|
138
|
+
oDataObject.class
|
139
|
+
end
|
140
140
|
object_data_add(oDataObject)
|
141
141
|
oDataObject.register
|
142
142
|
end
|
@@ -185,10 +185,10 @@ module Lorj
|
|
185
185
|
# * *Raises* :
|
186
186
|
# PrcError
|
187
187
|
def exist?(*key) # rubocop: disable Metrics/MethodLength
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
188
|
+
unless [Array, String, Symbol].include?(key.class)
|
189
|
+
PrcLib.runtime_fail 'ObjectData: key is not list of values '\
|
190
|
+
'(string/symbol or array)'
|
191
|
+
end
|
192
192
|
key = [key] if key.is_a?(Symbol) || key.is_a?(String)
|
193
193
|
|
194
194
|
key = key.flatten
|
@@ -200,7 +200,7 @@ module Lorj
|
|
200
200
|
object_data_exist?(object, key)
|
201
201
|
else
|
202
202
|
# By default true if found key hierarchy
|
203
|
-
@params.rh_exist?(key)
|
203
|
+
@params.rh_exist?(*key)
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -222,11 +222,12 @@ module Lorj
|
|
222
222
|
:DataObject if @params[key].type == :object
|
223
223
|
end
|
224
224
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
225
|
+
def to_s
|
226
|
+
str = "-- Lorj::ObjectData --\n"
|
227
|
+
str += "Usage internal\n" if @internal
|
228
|
+
@params.each { |key, data| str += format("%s:\n%s\n", key, data.to_s) }
|
229
|
+
str
|
230
|
+
end
|
230
231
|
|
231
232
|
private
|
232
233
|
|
@@ -304,10 +305,9 @@ module Lorj
|
|
304
305
|
# * *Raises* :
|
305
306
|
# nothing
|
306
307
|
def object_data_delete(obj)
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
obj.class) unless obj.is_a?(Lorj::Data)
|
308
|
+
PrcLib.runtime_fail 'ObjectData: delete error. obj is not a'\
|
309
|
+
" framework data Object. Is a '%s'",
|
310
|
+
obj.class unless obj.is_a?(Lorj::Data)
|
311
311
|
if obj.type == :list
|
312
312
|
@params.rh_set(nil, :query, obj.object_type?)
|
313
313
|
else
|
@@ -27,27 +27,33 @@ module Lorj
|
|
27
27
|
# - +new_params+ : Parameters ObjectData
|
28
28
|
# - +param_object+ : parameter object
|
29
29
|
# - +param_options+ : parameter options
|
30
|
-
# - +predefined_params+ : predefined parameters.
|
31
30
|
#
|
32
31
|
# *return*:
|
33
|
-
# - value : return the parameter value.
|
32
|
+
# - value : return the parameter value added.
|
33
|
+
# The value comes :
|
34
|
+
# - from an existing param value if the param_options defines
|
35
|
+
# :extract_from
|
36
|
+
# - from config layers if exist
|
37
|
+
# - from param_option[:default_value] if set
|
38
|
+
# OR
|
39
|
+
# - nil : if not found
|
34
40
|
#
|
35
41
|
# *raise*:
|
36
42
|
#
|
37
|
-
def _build_data(new_params, param_obj, param_options
|
43
|
+
def _build_data(new_params, param_obj, param_options)
|
38
44
|
param_name = param_obj.key
|
39
|
-
value = nil
|
40
|
-
|
41
|
-
default = param_options.rh_get(:default_value)
|
42
45
|
|
43
|
-
|
46
|
+
unless param_options[:extract_from].nil?
|
44
47
|
value = new_params[param_options[:extract_from]]
|
48
|
+
new_params[param_obj.tree] = value
|
49
|
+
return value
|
45
50
|
end
|
46
51
|
|
47
|
-
return
|
48
|
-
|
49
|
-
value = @config.get(param_name, default) if value.nil?
|
52
|
+
return nil unless param_options.key?(:default_value) ||
|
53
|
+
@config.exist?(param_name)
|
50
54
|
|
55
|
+
default = param_options.rh_get(:default_value)
|
56
|
+
value = @config.get(param_name, default)
|
51
57
|
new_params[param_obj.tree] = value
|
52
58
|
|
53
59
|
value
|
@@ -76,10 +82,10 @@ module Lorj
|
|
76
82
|
attr_name = param_obj.key
|
77
83
|
|
78
84
|
# Mapping from Object/data definition
|
79
|
-
if value_mapping
|
80
|
-
runtime_fail("'%s.%s': No value mapping for '%s'",
|
81
|
-
|
82
|
-
|
85
|
+
if value_mapping.is_a?(Hash)
|
86
|
+
PrcLib.runtime_fail("'%s.%s': No value mapping for '%s'",
|
87
|
+
object_type, attr_name,
|
88
|
+
value) unless value_mapping.key?(value)
|
83
89
|
value = value_mapping[value]
|
84
90
|
end
|
85
91
|
|
@@ -102,7 +108,6 @@ module Lorj
|
|
102
108
|
# - +new_params+ : ObjectData. Parameters ObjectData
|
103
109
|
# - +param_path+ : Symbol. parameter name
|
104
110
|
# - +param_options+ : Hash. parameter options
|
105
|
-
# - +predefined_params+ : Hash. predefined parameters.
|
106
111
|
#
|
107
112
|
#
|
108
113
|
# *return*:
|
@@ -110,21 +115,18 @@ module Lorj
|
|
110
115
|
#
|
111
116
|
# *raise*:
|
112
117
|
#
|
113
|
-
def _build_param(new_params,
|
114
|
-
param_obj, param_options, predefined_value)
|
115
|
-
|
118
|
+
def _build_param(new_params, param_obj, param_options)
|
116
119
|
param_name = param_obj.key
|
117
120
|
|
118
121
|
case param_options[:type]
|
119
122
|
when :data
|
120
|
-
return _build_data(new_params, param_obj, param_options
|
121
|
-
predefined_value)
|
123
|
+
return _build_data(new_params, param_obj, param_options)
|
122
124
|
when :CloudObject
|
123
125
|
if param_options[:required] &&
|
124
126
|
@object_data.type?(param_name) != :DataObject
|
125
|
-
|
126
|
-
|
127
|
-
|
127
|
+
PrcLib.runtime_fail "Object '%s/%s' is not defined. '%s' "\
|
128
|
+
'requirement failed.',
|
129
|
+
self.class, param_name, fname
|
128
130
|
end
|
129
131
|
if @object_data.exist?(param_name)
|
130
132
|
new_params.add(@object_data[param_name, :ObjectData])
|
@@ -137,6 +139,46 @@ module Lorj
|
|
137
139
|
nil
|
138
140
|
end
|
139
141
|
|
142
|
+
# internal runtime function for process call
|
143
|
+
# Build a process parameters object (ObjectData)
|
144
|
+
#
|
145
|
+
# *parameters*:
|
146
|
+
# - +object_type+ : object type requiring parameters.
|
147
|
+
# - +sEventType+ : event type used to call the process
|
148
|
+
# - +fname+ : caller function
|
149
|
+
#
|
150
|
+
# *return*:
|
151
|
+
# - ObjectData : list of data and objects wanted by the process or
|
152
|
+
# the controller. In case of the controller, hdata
|
153
|
+
# controller map is also added.
|
154
|
+
#
|
155
|
+
# *raise*:
|
156
|
+
# - runtime error if required data is not set. (empty or nil)
|
157
|
+
#
|
158
|
+
def _get_process_params(object_type, sEventType, fname)
|
159
|
+
_get_object_params(object_type, sEventType, fname, false)
|
160
|
+
end
|
161
|
+
|
162
|
+
# internal runtime function for process call
|
163
|
+
# Build a controller parameters object (ObjectData)
|
164
|
+
#
|
165
|
+
# *parameters*:
|
166
|
+
# - +object_type+ : object type requiring parameters.
|
167
|
+
# - +sEventType+ : event type used to call the process
|
168
|
+
# - +fname+ : caller function
|
169
|
+
#
|
170
|
+
# *return*:
|
171
|
+
# - ObjectData : list of data and objects wanted by the process or
|
172
|
+
# the controller. In case of the controller, hdata
|
173
|
+
# controller map is also added.
|
174
|
+
#
|
175
|
+
# *raise*:
|
176
|
+
# - runtime error if required data is not set. (empty or nil)
|
177
|
+
#
|
178
|
+
def _get_controller_params(object_type, sEventType, fname)
|
179
|
+
_get_object_params(object_type, sEventType, fname, true)
|
180
|
+
end
|
181
|
+
|
140
182
|
# internal runtime function for process call
|
141
183
|
# Build a process/controller parameters object (ObjectData)
|
142
184
|
#
|
@@ -144,8 +186,8 @@ module Lorj
|
|
144
186
|
# - +object_type+ : object type requiring parameters.
|
145
187
|
# - +sEventType+ : event type used to call the process
|
146
188
|
# - +fname+ : caller function
|
147
|
-
# - +as_controller+ :
|
148
|
-
#
|
189
|
+
# - +as_controller+ : true to store parameters for controller.
|
190
|
+
# false to store parameters for process.
|
149
191
|
#
|
150
192
|
# *return*:
|
151
193
|
# - ObjectData : list of data and objects wanted by the process or
|
@@ -155,26 +197,25 @@ module Lorj
|
|
155
197
|
# *raise*:
|
156
198
|
# - runtime error if required data is not set. (empty or nil)
|
157
199
|
#
|
158
|
-
def _get_object_params(object_type, sEventType,
|
159
|
-
as_controller = false, predefined_params = {})
|
200
|
+
def _get_object_params(object_type, sEventType, fname, as_controller)
|
160
201
|
# Building handler parameters
|
161
202
|
# hdata is built for controller. ie, ObjectData is NOT internal.
|
162
203
|
|
163
204
|
obj_params = PrcLib.model.meta_obj.rh_get(object_type, :params, :keys)
|
164
205
|
|
165
|
-
|
166
|
-
|
206
|
+
PrcLib.runtime_fail "%s:'%s' Object data needs not set. Forgot "\
|
207
|
+
'obj_needs?', fname, object_type if obj_params.nil?
|
167
208
|
|
168
209
|
new_params = _obj_param_init(object_type, sEventType, as_controller)
|
169
210
|
|
170
|
-
obj_params.each do |
|
171
|
-
|
211
|
+
obj_params.each do |param_path, param_options|
|
212
|
+
if param_options.key?(:for)
|
213
|
+
next unless param_options[:for].include?(sEventType)
|
214
|
+
end
|
172
215
|
|
173
216
|
param_obj = KeyPath.new(param_path)
|
174
|
-
param_name = param_obj.key
|
175
217
|
|
176
|
-
value = _build_param(new_params,
|
177
|
-
predefined_params[param_name])
|
218
|
+
value = _build_param(new_params, param_obj, param_options)
|
178
219
|
|
179
220
|
if as_controller && !value.nil?
|
180
221
|
_build_hdata(object_type, new_params, param_obj, param_options, value)
|
data/lib/core/core_process.rb
CHANGED
@@ -38,7 +38,9 @@ module Lorj
|
|
38
38
|
# creation.
|
39
39
|
#
|
40
40
|
# * *Returns* :
|
41
|
-
#
|
41
|
+
# - +Object+ : Lorj::Data object of type +ObjectType+ created.
|
42
|
+
# OR
|
43
|
+
# - Lorj::Data empty.
|
42
44
|
#
|
43
45
|
# * *Raises* :
|
44
46
|
# - Warning if the create_e process handler did not return any data. (nil)
|
@@ -49,65 +51,53 @@ module Lorj
|
|
49
51
|
# data. (nil) - Loop detection.
|
50
52
|
# - Error if the create_e process handler raise an error.
|
51
53
|
#
|
52
|
-
def process_create(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
# hConfig.rh_set(nil, sKey)
|
61
|
-
# end
|
62
|
-
# if hConfig.length > 0
|
63
|
-
# PrcLib.warning("'%s' has been passed but not declared to '%s'"\
|
64
|
-
# ' object. Those are ignored until you add it in the'\
|
65
|
-
# " model definition of '%s'",
|
66
|
-
# hConfig.keys, sObjectType, sObjectType)
|
67
|
-
# end
|
68
|
-
# end
|
69
|
-
|
70
|
-
return nil unless sObjectType
|
71
|
-
|
72
|
-
unless PrcLib.model.meta_obj.rh_exist?(sObjectType)
|
73
|
-
runtime_fail "%s.Create: '%s' is not a known object type.",
|
74
|
-
self.class, sObjectType
|
54
|
+
def process_create(object_type, hConfig = nil)
|
55
|
+
return nil unless object_type
|
56
|
+
|
57
|
+
_add_instant_config(hConfig)
|
58
|
+
|
59
|
+
unless PrcLib.model.meta_obj.rh_exist?(object_type)
|
60
|
+
PrcLib.runtime_fail "%s.%s: '%s' is not a known object type.",
|
61
|
+
self.class, __callee__, object_type
|
75
62
|
end
|
76
|
-
proc = PrcLib.model.meta_obj.rh_get(
|
63
|
+
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :create_e)
|
77
64
|
|
78
65
|
# Check required parameters
|
79
66
|
_process_load_dependencies(object_type, proc, :create_e, __callee__)
|
80
67
|
|
81
68
|
# Context: Default object used
|
82
|
-
@runtime_context[:oCurrentObj] =
|
69
|
+
@runtime_context[:oCurrentObj] = object_type
|
83
70
|
|
84
71
|
if proc.nil?
|
85
72
|
# This object is a meta object, without any data.
|
86
73
|
# Used to build other kind of objects.
|
87
74
|
object = Lorj::Data.new
|
88
|
-
object.set({},
|
75
|
+
object.set({}, object_type) {}
|
89
76
|
else
|
90
77
|
# build Function params to pass to the event handler.
|
91
|
-
params =
|
92
|
-
Lorj.debug(2, "Create Object '%s' - Running '%s'",
|
78
|
+
params = _get_process_params(object_type, :create_e, proc)
|
79
|
+
Lorj.debug(2, "Create Object '%s' - Running '%s'", object_type, proc)
|
93
80
|
|
94
81
|
# Call the process function.
|
95
82
|
# At some point, the process will call the controller, via the framework
|
96
83
|
# This controller call via the framework has the role to
|
97
84
|
# create an ObjectData well formatted, with _return_map function
|
98
85
|
# See Definition.connect/create/update/query/get functions (lowercase)
|
99
|
-
object = @process.method(proc).call(
|
86
|
+
object = @process.method(proc).call(object_type, params)
|
100
87
|
# return usually is the main object that the process called should
|
101
88
|
# provide.
|
102
89
|
# Save Object if the object has been created by the process, without
|
103
90
|
# controller
|
104
91
|
end
|
105
92
|
|
93
|
+
_remove_instant_config(hConfig)
|
94
|
+
|
106
95
|
if object.nil?
|
107
96
|
PrcLib.warning("'%s' has returned no data for object Lorj::Data '%s'!",
|
108
|
-
proc,
|
97
|
+
proc, object_type)
|
98
|
+
Lorj::Data.new
|
109
99
|
else
|
110
|
-
query_cleanup(
|
100
|
+
query_cleanup(object_type)
|
111
101
|
@object_data.add(object)
|
112
102
|
end
|
113
103
|
end
|
@@ -133,12 +123,14 @@ module Lorj
|
|
133
123
|
# data. (nil) - Loop detection.
|
134
124
|
# - Error if the query_e process handler raise an error.
|
135
125
|
#
|
136
|
-
def process_delete(object_type, hConfig =
|
126
|
+
def process_delete(object_type, hConfig = nil)
|
137
127
|
return nil unless object_type
|
138
128
|
|
129
|
+
_add_instant_config(hConfig)
|
130
|
+
|
139
131
|
unless PrcLib.model.meta_obj.rh_exist?(object_type)
|
140
|
-
runtime_fail "%s
|
141
|
-
|
132
|
+
PrcLib.runtime_fail "%s.%s: '%s' is not a known object type.",
|
133
|
+
self.class, __callee__, object_type
|
142
134
|
end
|
143
135
|
|
144
136
|
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :delete_e)
|
@@ -152,11 +144,13 @@ module Lorj
|
|
152
144
|
@runtime_context[:oCurrentObj] = object_type
|
153
145
|
|
154
146
|
# build Function params to pass to the event handler.
|
155
|
-
params =
|
147
|
+
params = _get_process_params(object_type, :delete_e, proc)
|
156
148
|
|
157
149
|
state = @process.method(proc).call(object_type, params)
|
158
150
|
# return usually is the main object that the process called should provide
|
159
151
|
|
152
|
+
_remove_instant_config(hConfig)
|
153
|
+
|
160
154
|
@object_data.delete(object_type) if state
|
161
155
|
end
|
162
156
|
|
@@ -204,15 +198,20 @@ module Lorj
|
|
204
198
|
#
|
205
199
|
# * *Returns* :
|
206
200
|
# Lorj::Data of type :list
|
201
|
+
# OR
|
202
|
+
# - Lorj::Data empty.
|
207
203
|
#
|
208
204
|
# * *Raises* :
|
209
205
|
#
|
210
206
|
#
|
211
|
-
def process_query(object_type, hQuery, hConfig =
|
207
|
+
def process_query(object_type, hQuery, hConfig = nil)
|
212
208
|
return nil unless object_type
|
209
|
+
|
210
|
+
_add_instant_config(hConfig)
|
211
|
+
|
213
212
|
unless PrcLib.model.meta_obj.rh_exist?(object_type)
|
214
|
-
runtime_fail "%s
|
215
|
-
|
213
|
+
PrcLib.runtime_fail "%s.%s: '%s' is not a known object type.",
|
214
|
+
self.class, __callee__, object_type
|
216
215
|
end
|
217
216
|
|
218
217
|
# Check if we can re-use a previous query
|
@@ -230,7 +229,7 @@ module Lorj
|
|
230
229
|
@runtime_context[:oCurrentObj] = object_type
|
231
230
|
|
232
231
|
# build Function params to pass to the Process Event handler.
|
233
|
-
params =
|
232
|
+
params = _get_process_params(object_type, :query_e, proc)
|
234
233
|
|
235
234
|
# Call the process function.
|
236
235
|
# At some point, the process will call the controller, via the framework.
|
@@ -238,10 +237,14 @@ module Lorj
|
|
238
237
|
# create an ObjectData well formatted, with _return_map function
|
239
238
|
# See Definition.connect/create/update/query/get functions (lowercase)
|
240
239
|
object = @process.method(proc).call(object_type, hQuery, params)
|
240
|
+
|
241
|
+
_remove_instant_config(hConfig)
|
242
|
+
|
241
243
|
# return usually is the main object that the process called should provide
|
242
244
|
if object.nil?
|
243
245
|
PrcLib.warning("'%s' returned no collection of objects Lorj::Data "\
|
244
246
|
"for '%s'", proc, object_type)
|
247
|
+
Lorj::Data.new
|
245
248
|
else
|
246
249
|
# Save Object if the object has been created by the process, without
|
247
250
|
# controller
|
@@ -274,7 +277,9 @@ module Lorj
|
|
274
277
|
# getting.
|
275
278
|
#
|
276
279
|
# * *Returns* :
|
277
|
-
#
|
280
|
+
# - Lorj::Data of type :object
|
281
|
+
# OR
|
282
|
+
# - Lorj::Data empty.
|
278
283
|
#
|
279
284
|
# * *Raises* :
|
280
285
|
# - Warning if the Config data passed are not required by the meta object
|
@@ -284,11 +289,14 @@ module Lorj
|
|
284
289
|
# data. (nil) - Loop detection.
|
285
290
|
# - Error if the get_e process handler raise an error.
|
286
291
|
#
|
287
|
-
def process_get(object_type, sUniqId, hConfig =
|
292
|
+
def process_get(object_type, sUniqId, hConfig = nil)
|
288
293
|
return nil unless object_type
|
294
|
+
|
295
|
+
_add_instant_config(hConfig)
|
296
|
+
|
289
297
|
unless PrcLib.model.meta_obj.rh_exist?(object_type)
|
290
|
-
runtime_fail "$s
|
291
|
-
|
298
|
+
PrcLib.runtime_fail "$s.: '%s' is not a known object type.",
|
299
|
+
self.class, __callee__, object_type
|
292
300
|
end
|
293
301
|
|
294
302
|
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :get_e)
|
@@ -302,7 +310,7 @@ module Lorj
|
|
302
310
|
@runtime_context[:oCurrentObj] = object_type
|
303
311
|
|
304
312
|
# build Function params to pass to the Process Event handler.
|
305
|
-
params =
|
313
|
+
params = _get_process_params(object_type, :get_e, proc)
|
306
314
|
|
307
315
|
# Call the process function.
|
308
316
|
# At some point, the process will call the controller, via the framework.
|
@@ -312,9 +320,15 @@ module Lorj
|
|
312
320
|
object = @process.method(proc).call(object_type, sUniqId, params)
|
313
321
|
# return usually is the main object that the process called should provide
|
314
322
|
|
315
|
-
|
316
|
-
|
317
|
-
|
323
|
+
_remove_instant_config(hConfig)
|
324
|
+
|
325
|
+
if object.nil?
|
326
|
+
PrcLib.warning("'%s' has returned no data for object Lorj::Data '%s'!",
|
327
|
+
proc, object_type)
|
328
|
+
Lorj::Data.new
|
329
|
+
else
|
330
|
+
@object_data.add(object)
|
331
|
+
end
|
318
332
|
end
|
319
333
|
|
320
334
|
# Function to execute a update process. This function returns a Lorj::Data
|
@@ -326,7 +340,9 @@ module Lorj
|
|
326
340
|
# updating.
|
327
341
|
#
|
328
342
|
# * *Returns* :
|
329
|
-
#
|
343
|
+
# - Lorj::Data of type :object
|
344
|
+
# OR
|
345
|
+
# - Lorj::Data empty.
|
330
346
|
#
|
331
347
|
# * *Raises* :
|
332
348
|
# - Warning if the Config data passed are not required by the meta object
|
@@ -336,12 +352,14 @@ module Lorj
|
|
336
352
|
# data. (nil) - Loop detection.
|
337
353
|
# - Error if the get_e process handler raise an error.
|
338
354
|
#
|
339
|
-
def process_update(object_type, hConfig =
|
355
|
+
def process_update(object_type, hConfig = nil)
|
340
356
|
return nil unless object_type
|
341
357
|
|
358
|
+
_add_instant_config(hConfig)
|
359
|
+
|
342
360
|
unless PrcLib.model.meta_obj.rh_exist?(object_type)
|
343
|
-
runtime_fail "$s
|
344
|
-
|
361
|
+
PrcLib.runtime_fail "$s.%s: '%s' is not a known object type.",
|
362
|
+
self.class, __callee__, object_type
|
345
363
|
end
|
346
364
|
|
347
365
|
proc = PrcLib.model.meta_obj.rh_get(object_type, :lambdas, :update_e)
|
@@ -354,14 +372,41 @@ module Lorj
|
|
354
372
|
@runtime_context[:oCurrentObj] = object_type
|
355
373
|
|
356
374
|
# build Function params to pass to the event handler.
|
357
|
-
params =
|
375
|
+
params = _get_process_params(object_type, :update_e, proc)
|
358
376
|
|
359
377
|
object = @process.method(proc).call(object_type, params)
|
360
378
|
# return usually is the main object that the process called should provide
|
361
379
|
|
362
|
-
|
363
|
-
|
364
|
-
|
380
|
+
_remove_instant_config(hConfig)
|
381
|
+
|
382
|
+
if object.nil?
|
383
|
+
PrcLib.warning("'%s' has returned no data for object Lorj::Data '%s'!",
|
384
|
+
proc, object_type)
|
385
|
+
Lorj::Data.new
|
386
|
+
else
|
387
|
+
@object_data.add(object)
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
# Adding private process core functions.
|
393
|
+
class BaseDefinition
|
394
|
+
private
|
395
|
+
|
396
|
+
def _add_instant_config(hConfig)
|
397
|
+
return unless hConfig.is_a?(Hash)
|
398
|
+
|
399
|
+
config = PRC::BaseConfig.new hConfig
|
400
|
+
options = { :name => hConfig.object_id.to_s, :config => config,
|
401
|
+
:set => false }
|
402
|
+
|
403
|
+
@config.layer_add PRC::CoreConfig.define_layer(options)
|
404
|
+
end
|
405
|
+
|
406
|
+
def _remove_instant_config(hConfig)
|
407
|
+
return unless hConfig.is_a?(Hash)
|
408
|
+
|
409
|
+
@config.layer_remove :name => hConfig.object_id.to_s
|
365
410
|
end
|
366
411
|
|
367
412
|
def _process_load_dependencies(object_type, proc, handler_name,
|
@@ -378,13 +423,13 @@ module Lorj
|
|
378
423
|
end
|
379
424
|
|
380
425
|
unless process_create(elem)
|
381
|
-
runtime_fail "Unable to create Object '%s'", elem
|
426
|
+
PrcLib.runtime_fail "Unable to create Object '%s'", elem
|
382
427
|
end
|
383
428
|
|
384
429
|
missing_obj = _check_required(object_type, handler_name, proc).reverse
|
385
|
-
runtime_fail "loop detection: '%s' is required but"\
|
430
|
+
PrcLib.runtime_fail "loop detection: '%s' is required but"\
|
386
431
|
" #{function_name}(%s) did not loaded it.",
|
387
|
-
|
432
|
+
elem, elem if missing_obj.include?(elem)
|
388
433
|
end
|
389
434
|
end
|
390
435
|
end
|
@@ -119,7 +119,7 @@ module Lorj
|
|
119
119
|
#
|
120
120
|
def process_setup(sObjectType, sAccountName = nil)
|
121
121
|
unless PrcLib.model.meta_obj.rh_exist?(sObjectType)
|
122
|
-
runtime_fail "Setup: '%s' not a valid object type."
|
122
|
+
PrcLib.runtime_fail "Setup: '%s' not a valid object type."
|
123
123
|
end
|
124
124
|
|
125
125
|
setup_steps = _setup_load
|
@@ -156,11 +156,11 @@ module Lorj
|
|
156
156
|
def _setup_data_insert(setup_steps, data_to_add, step, order_index)
|
157
157
|
level_index = 0
|
158
158
|
|
159
|
-
_setup_data_after(data_to_add).each do |sAfterKey
|
159
|
+
_setup_data_after(data_to_add).each do |sAfterKey|
|
160
160
|
setup_steps.each_index do |iStepToCheck|
|
161
161
|
order_array = setup_steps[iStepToCheck][:order]
|
162
162
|
|
163
|
-
order_array.each_index do |
|
163
|
+
order_array.each_index do |iLevelToCheck|
|
164
164
|
data_to_ask = order_array[iLevelToCheck]
|
165
165
|
order_to_check = data_to_ask.index(sAfterKey)
|
166
166
|
|
@@ -191,7 +191,7 @@ module Lorj
|
|
191
191
|
# * *Raises* :
|
192
192
|
#
|
193
193
|
def _setup_data_after(data_to_check)
|
194
|
-
meta =
|
194
|
+
meta = _get_meta_data_auto(data_to_check)
|
195
195
|
return [] unless meta.rh_exist?(:after)
|
196
196
|
|
197
197
|
datas_after = meta[:after]
|
@@ -206,7 +206,7 @@ module Lorj
|
|
206
206
|
# - +order_array+ : Array of data classified per level/order
|
207
207
|
# - +data_to_check+ : data to check
|
208
208
|
def _setup_attr_already_added?(order_array, data_to_check)
|
209
|
-
order_array.each_index do |
|
209
|
+
order_array.each_index do |order_index|
|
210
210
|
attributes = order_array[order_index]
|
211
211
|
return true unless attributes.index(data_to_check).nil?
|
212
212
|
end
|
@@ -240,7 +240,7 @@ module Lorj
|
|
240
240
|
return false
|
241
241
|
end
|
242
242
|
|
243
|
-
meta =
|
243
|
+
meta = _get_meta_data_auto(attr_name)
|
244
244
|
return false unless meta.is_a?(Hash)
|
245
245
|
|
246
246
|
ask_step = 0
|
@@ -250,8 +250,8 @@ module Lorj
|
|
250
250
|
order_array = setup_steps[ask_step][:order]
|
251
251
|
|
252
252
|
unless meta[:account].is_a?(TrueClass)
|
253
|
-
Lorj.debug(2, "'%s'
|
254
|
-
' :account = true not set.', attr_name
|
253
|
+
Lorj.debug(2, "'%s' won't be asked during setup."\
|
254
|
+
' :account = true not set.', attr_name)
|
255
255
|
return false
|
256
256
|
end
|
257
257
|
|
@@ -263,7 +263,7 @@ module Lorj
|
|
263
263
|
level = _setup_attr_add(order_array[level_index], attr_name, meta,
|
264
264
|
level_index)
|
265
265
|
Lorj.debug(3, "S%s/L%s/%s: '%s' added in setup list. ",
|
266
|
-
ask_step, level,
|
266
|
+
ask_step, level, level_index, attr_name)
|
267
267
|
|
268
268
|
true
|
269
269
|
end
|
@@ -300,12 +300,12 @@ module Lorj
|
|
300
300
|
order_index = meta[:ask_sort]
|
301
301
|
_setup_attr_add_at(level_array, attr_name, order_index)
|
302
302
|
Lorj.debug(3, "S%s/L%s/O%s: '%s' added in setup list. ",
|
303
|
-
ask_step, level_index, order_index, attr_name)
|
303
|
+
meta[:ask_step], level_index, order_index, attr_name)
|
304
304
|
"O#{level_index}"
|
305
305
|
else
|
306
306
|
level_array << attr_name
|
307
307
|
Lorj.debug(3, "S%s/L%s/Last: '%s' added in setup list.",
|
308
|
-
ask_step, level_index, attr_name)
|
308
|
+
meta[:ask_step], level_index, attr_name)
|
309
309
|
'Last'
|
310
310
|
end
|
311
311
|
end
|