infopark_reactor 1.11.0.beta3 → 1.12.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/rails_connector/obj_class.rb +10 -0
- data/lib/infopark_reactor.rb +1 -0
- data/lib/reactor/attributes.rb +33 -8
- data/lib/reactor/cm/attribute_group.rb +113 -0
- data/lib/reactor/migration.rb +6 -0
- data/lib/reactor/plans/common_attribute_group.rb +42 -0
- data/lib/reactor/plans/common_obj_class.rb +4 -0
- data/lib/reactor/plans/create_attribute_group.rb +28 -0
- data/lib/reactor/plans/delete_attribute_group.rb +28 -0
- data/lib/reactor/plans/update_attribute_group.rb +29 -0
- data/lib/reactor/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f11250eb1074d38b5ebb2a39478405e8ac6bc524
|
4
|
+
data.tar.gz: 78b247bbe2eff3558ebb11a2f61be01bbce2a1ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24eb0e3129bd243babbbaf8aea970b79dbc8495d7a0d435af025a83989f76b93aba5363f4bada7073e357d4beff9e60a3eba659a25edc687cfde8f0858db2d4e
|
7
|
+
data.tar.gz: 94aac0a1070407ffdef59e7cede02e819004862cc59a7f69b422442c175bf0e91fd661a7162f7c207566779f0b4fc4aa80d0eab63430bbcba0f1d304f76129f8
|
@@ -25,6 +25,16 @@ module RailsConnector
|
|
25
25
|
@blob_data['titles'] || {}
|
26
26
|
end
|
27
27
|
|
28
|
+
def attribute_groups
|
29
|
+
load_blob_data
|
30
|
+
@blob_data['attributeGroups'] || []
|
31
|
+
end
|
32
|
+
|
33
|
+
def valid_sub_obj_classes
|
34
|
+
load_blob_data
|
35
|
+
@blob_data['validSubObjClasses'] || []
|
36
|
+
end
|
37
|
+
|
28
38
|
# returns channel feature is_activate?
|
29
39
|
def can_create_news_items?
|
30
40
|
load_blob_data
|
data/lib/infopark_reactor.rb
CHANGED
data/lib/reactor/attributes.rb
CHANGED
@@ -125,6 +125,14 @@ module Reactor
|
|
125
125
|
EOC
|
126
126
|
end
|
127
127
|
|
128
|
+
# if a handler for this obj class has been defined previously, purge its methods
|
129
|
+
if Reactor::AttributeHandlers.const_defined?("Handler__#{obj_class.name}")
|
130
|
+
mod = Reactor::AttributeHandlers.const_get("Handler__#{obj_class.name}")
|
131
|
+
mod.instance_methods.each do |method|
|
132
|
+
mod.send(:remove_method, method)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
128
136
|
Reactor.class_eval <<-EOC
|
129
137
|
class AttributeHandlers
|
130
138
|
module Handler__#{obj_class.name}
|
@@ -201,6 +209,10 @@ module Reactor
|
|
201
209
|
set(:channels, value)
|
202
210
|
end
|
203
211
|
|
212
|
+
def suppress_export=(value)
|
213
|
+
set(:suppress_export, value)
|
214
|
+
end
|
215
|
+
|
204
216
|
def channels
|
205
217
|
self[:channels] || []
|
206
218
|
end
|
@@ -251,20 +263,25 @@ module Reactor
|
|
251
263
|
crul_obj.set_link(key, target_path.to_s)
|
252
264
|
end
|
253
265
|
|
254
|
-
|
255
|
-
protected
|
256
|
-
attr_accessor :uploaded
|
257
|
-
|
258
266
|
def reload_attributes(new_obj_class=nil)
|
259
|
-
Reactor::AttributeHandlers.reinstall_attributes(self.
|
267
|
+
Reactor::AttributeHandlers.reinstall_attributes(self.singleton_class, new_obj_class || self.obj_class)
|
260
268
|
end
|
261
269
|
|
270
|
+
protected
|
271
|
+
attr_accessor :uploaded
|
262
272
|
def builtin_attr?(attr)
|
263
|
-
[:channels, :valid_from, :valid_until, :name, :obj_class, :content_type, :body, :blob, :permalink, :title].include?(attr)
|
273
|
+
[:channels, :valid_from, :valid_until, :name, :obj_class, :content_type, :body, :blob, :suppress_export, :permalink, :title].include?(attr)
|
264
274
|
end
|
265
275
|
|
266
276
|
def allowed_attr?(attr)
|
267
|
-
|
277
|
+
return true if builtin_attr?(attr)
|
278
|
+
|
279
|
+
custom_attrs =
|
280
|
+
self.singleton_class.send(:instance_variable_get, '@_o_allowed_attrs') ||
|
281
|
+
self.class.send(:instance_variable_get, '@_o_allowed_attrs') ||
|
282
|
+
[]
|
283
|
+
|
284
|
+
custom_attrs.include?(key_to_attr(attr))
|
268
285
|
end
|
269
286
|
|
270
287
|
def resolve_attribute_alias(key)
|
@@ -277,6 +294,7 @@ module Reactor
|
|
277
294
|
:valid_until => :validUntil,
|
278
295
|
:valid_from => :validFrom,
|
279
296
|
:content_type => :contentType,
|
297
|
+
:suppress_export => :suppressExport,
|
280
298
|
:obj_class => :objClass
|
281
299
|
}
|
282
300
|
|
@@ -337,7 +355,7 @@ module Reactor
|
|
337
355
|
def attribute_type(attr)
|
338
356
|
return :html if [:body, :blob].include?(attr.to_sym)
|
339
357
|
return :date if [:valid_from, :valid_until, :last_changed].include?(attr.to_sym)
|
340
|
-
return :string if [:name, :title, :obj_class, :permalink].include?(attr.to_sym)
|
358
|
+
return :string if [:name, :title, :obj_class, :permalink, :suppress_export].include?(attr.to_sym)
|
341
359
|
return :multienum if [:channels].include?(attr.to_sym)
|
342
360
|
|
343
361
|
custom_attr = self.obj_class_def.try(:custom_attributes).try(:[],attr.to_s)
|
@@ -368,6 +386,13 @@ module Reactor
|
|
368
386
|
obj_class_def = RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class) #RailsConnector::ObjClass.where(:obj_class_name => obj_class).first
|
369
387
|
obj_class_def ? obj_class_def.mandatory_attribute_names(:only_custom_attributes => true) : []
|
370
388
|
end
|
389
|
+
|
390
|
+
def reload_attributes(new_obj_class=nil)
|
391
|
+
new_obj_class ||= self.name
|
392
|
+
raise ArgumentError, "Cannot reload attributes because obj_class is unknown, provide one as a parameter" if new_obj_class.nil?
|
393
|
+
|
394
|
+
Reactor::AttributeHandlers.reinstall_attributes(self, new_obj_class)
|
395
|
+
end
|
371
396
|
end
|
372
397
|
end
|
373
398
|
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'reactor/cm/object_base'
|
2
|
+
|
3
|
+
module Reactor
|
4
|
+
module Cm
|
5
|
+
class AttributeGroup < ObjectBase
|
6
|
+
set_base_name 'attributeGroup'
|
7
|
+
|
8
|
+
attribute :obj_class, name: :objClass
|
9
|
+
attribute :name
|
10
|
+
attribute :title
|
11
|
+
|
12
|
+
attribute :attributes, :except => [:set], :type => :list
|
13
|
+
attribute :index
|
14
|
+
|
15
|
+
# virtual attribute!
|
16
|
+
primary_key :identifier
|
17
|
+
|
18
|
+
def identifier
|
19
|
+
primary_key_value
|
20
|
+
end
|
21
|
+
|
22
|
+
def identifier=(val)
|
23
|
+
primary_key_value_set(val)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.exists?(pk_val)
|
27
|
+
request = XmlRequest.prepare do |xml|
|
28
|
+
xml.where_key_tag!(base_name, primary_key, pk_val)
|
29
|
+
xml.get_key_tag!(base_name, :name)
|
30
|
+
end
|
31
|
+
|
32
|
+
response = request.execute!
|
33
|
+
|
34
|
+
return response.ok?
|
35
|
+
|
36
|
+
rescue XmlRequestError => e
|
37
|
+
return false
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def self.create(obj_class, name, index=nil)
|
42
|
+
pk = [obj_class, name].join('.')
|
43
|
+
attributes = {
|
44
|
+
objClass: obj_class,
|
45
|
+
name: name
|
46
|
+
}
|
47
|
+
attributes[:index] = index if index
|
48
|
+
|
49
|
+
super(pk, attributes)
|
50
|
+
end
|
51
|
+
|
52
|
+
def add_attributes(attributes)
|
53
|
+
add_or_remove_attributes(attributes, 'add')
|
54
|
+
end
|
55
|
+
|
56
|
+
def remove_attributes(attributes)
|
57
|
+
add_or_remove_attributes(attributes, 'remove')
|
58
|
+
end
|
59
|
+
|
60
|
+
def move_attribute(attribute, index)
|
61
|
+
request = XmlRequest.prepare do |xml|
|
62
|
+
xml.where_key_tag!(base_name, primary_key, primary_key_value)
|
63
|
+
xml.tag!("#{base_name}-moveAttribute") do
|
64
|
+
xml.tag!('attribute') do
|
65
|
+
xml.text!(attribute.to_s)
|
66
|
+
end
|
67
|
+
xml.tag!('index') do
|
68
|
+
xml.text!(index.to_s)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
response = request.execute!
|
75
|
+
|
76
|
+
response.ok? && reload
|
77
|
+
end
|
78
|
+
|
79
|
+
def set(attr, value)
|
80
|
+
self.send(:"#{attr}=", value)
|
81
|
+
end
|
82
|
+
|
83
|
+
protected
|
84
|
+
def primary_key_value
|
85
|
+
"#{self.obj_class}.#{self.name}"
|
86
|
+
end
|
87
|
+
|
88
|
+
def primary_key_value_set(value)
|
89
|
+
a = value.split('.')
|
90
|
+
self.obj_class = a.first
|
91
|
+
self.name = a.last
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_or_remove_attributes(attributes, add_or_remove)
|
95
|
+
request = XmlRequest.prepare do |xml|
|
96
|
+
xml.where_key_tag!(base_name, primary_key, primary_key_value)
|
97
|
+
xml.tag!("#{base_name}-#{add_or_remove}Attributes") do
|
98
|
+
attributes.each do |attribute|
|
99
|
+
xml.tag!('listitem') do
|
100
|
+
xml.text!(attribute)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
response = request.execute!
|
108
|
+
|
109
|
+
response.ok? && reload
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/lib/reactor/migration.rb
CHANGED
@@ -9,6 +9,9 @@ require 'reactor/plans/rename_obj_class'
|
|
9
9
|
require 'reactor/plans/create_attribute'
|
10
10
|
require 'reactor/plans/delete_attribute'
|
11
11
|
require 'reactor/plans/update_attribute'
|
12
|
+
require 'reactor/plans/create_attribute_group'
|
13
|
+
require 'reactor/plans/delete_attribute_group'
|
14
|
+
require 'reactor/plans/update_attribute_group'
|
12
15
|
require 'reactor/plans/create_group'
|
13
16
|
require 'reactor/plans/update_group'
|
14
17
|
require 'reactor/plans/delete_group'
|
@@ -29,6 +32,9 @@ module Reactor
|
|
29
32
|
:create_attribute => Plans::CreateAttribute,
|
30
33
|
:delete_attribute => Plans::DeleteAttribute,
|
31
34
|
:update_attribute => Plans::UpdateAttribute,
|
35
|
+
:create_attribute_group => Plans::CreateAttributeGroup,
|
36
|
+
:delete_attribute_group => Plans::DeleteAttributeGroup,
|
37
|
+
:update_attribute_group => Plans::UpdateAttributeGroup,
|
32
38
|
:create_group => Plans::CreateGroup,
|
33
39
|
:delete_group => Plans::DeleteGroup,
|
34
40
|
:update_group => Plans::UpdateGroup,
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Reactor
|
3
|
+
module Plans
|
4
|
+
class CommonAttributeGroup
|
5
|
+
include Prepared
|
6
|
+
|
7
|
+
ALLOWED_PARAMS = [:title, :index]
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@params = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def set(key,value)
|
14
|
+
@params[key.to_sym] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_attributes(attributes)
|
18
|
+
@add_attributes = attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
def remove_attributes(attributes)
|
22
|
+
@remove_attributes = attributes
|
23
|
+
end
|
24
|
+
|
25
|
+
def migrate!
|
26
|
+
raise "#{self.class.name} did not implement migrate!"
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
def prepare_params!(attribute=nil)
|
31
|
+
@params.keys.each{|k| error("unknown parameter: #{k}") unless ALLOWED_PARAMS.include? k}
|
32
|
+
end
|
33
|
+
|
34
|
+
def migrate_params!(attribute)
|
35
|
+
attribute.add_attributes(@add_attributes) if @add_attributes
|
36
|
+
attribute.remove_attributes(@remove_attributes) if @remove_attributes
|
37
|
+
@params.each{|k,v|attribute.set(k,v)}
|
38
|
+
attribute.save!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'reactor/plans/common_attribute_group'
|
3
|
+
|
4
|
+
module Reactor
|
5
|
+
module Plans
|
6
|
+
class CreateAttributeGroup < CommonAttributeGroup
|
7
|
+
def initialize(*args)
|
8
|
+
super()
|
9
|
+
(obj_class, name, index), options = separate_arguments(*args)
|
10
|
+
@name = name || options[:name]
|
11
|
+
@obj_class = obj_class || options[:obj_class]
|
12
|
+
@index = index || options[:index]
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepare!
|
16
|
+
error("name ist nil") if @name.nil?
|
17
|
+
error("obj_class is nil") if @obj_class.nil?
|
18
|
+
prepare_params!(nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
def migrate!
|
22
|
+
attrib = Reactor::Cm::AttributeGroup.create(@obj_class, @name, @index)
|
23
|
+
migrate_params!(attrib)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'reactor/plans/common_attribute_group'
|
3
|
+
|
4
|
+
module Reactor
|
5
|
+
module Plans
|
6
|
+
class DeleteAttributeGroup < CommonAttributeGroup
|
7
|
+
def initialize(*args)
|
8
|
+
super()
|
9
|
+
(obj_class, name), options = separate_arguments(*args)
|
10
|
+
@name = name || options[:name]
|
11
|
+
@obj_class = obj_class || options[:obj_class]
|
12
|
+
@pk = "#{@obj_class}.#{@name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepare!
|
16
|
+
error("name ist nil") if @name.nil?
|
17
|
+
error("obj_class is nil") if @obj_class.nil?
|
18
|
+
error("attribute group #{@pk} does not exist") if not Reactor::Cm::AttributeGroup.exists?(@pk)
|
19
|
+
end
|
20
|
+
|
21
|
+
def migrate!
|
22
|
+
attrib = Reactor::Cm::AttributeGroup.get(@pk)
|
23
|
+
attrib.delete!
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'reactor/plans/common_attribute_group'
|
3
|
+
|
4
|
+
module Reactor
|
5
|
+
module Plans
|
6
|
+
class UpdateAttributeGroup < CommonAttributeGroup
|
7
|
+
def initialize(*args)
|
8
|
+
super()
|
9
|
+
(obj_class, name), options = separate_arguments(*args)
|
10
|
+
@name = name || options[:name]
|
11
|
+
@obj_class = obj_class || options[:obj_class]
|
12
|
+
@pk = "#{@obj_class}.#{@name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def prepapre!
|
16
|
+
error("name ist nil") if @name.nil?
|
17
|
+
error("obj_class is nil") if @obj_class.nil?
|
18
|
+
error("attribute group #{@pk} does not exist") if not Reactor::Cm::AttributeGroup.exists?(ok)
|
19
|
+
prepare_params!(nil)
|
20
|
+
end
|
21
|
+
|
22
|
+
def migrate!
|
23
|
+
attrib = Reactor::Cm::AttributeGroup.get(@pk)
|
24
|
+
migrate_params!(attrib)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/reactor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_reactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Przedmojski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/reactor/cache/permission.rb
|
124
124
|
- lib/reactor/cache/user.rb
|
125
125
|
- lib/reactor/cm/attribute.rb
|
126
|
+
- lib/reactor/cm/attribute_group.rb
|
126
127
|
- lib/reactor/cm/bridge.rb
|
127
128
|
- lib/reactor/cm/channel.rb
|
128
129
|
- lib/reactor/cm/editorial_group.rb
|
@@ -159,15 +160,18 @@ files:
|
|
159
160
|
- lib/reactor/permission.rb
|
160
161
|
- lib/reactor/persistence.rb
|
161
162
|
- lib/reactor/plans/common_attribute.rb
|
163
|
+
- lib/reactor/plans/common_attribute_group.rb
|
162
164
|
- lib/reactor/plans/common_channel.rb
|
163
165
|
- lib/reactor/plans/common_group.rb
|
164
166
|
- lib/reactor/plans/common_obj_class.rb
|
165
167
|
- lib/reactor/plans/create_attribute.rb
|
168
|
+
- lib/reactor/plans/create_attribute_group.rb
|
166
169
|
- lib/reactor/plans/create_channel.rb
|
167
170
|
- lib/reactor/plans/create_group.rb
|
168
171
|
- lib/reactor/plans/create_obj.rb
|
169
172
|
- lib/reactor/plans/create_obj_class.rb
|
170
173
|
- lib/reactor/plans/delete_attribute.rb
|
174
|
+
- lib/reactor/plans/delete_attribute_group.rb
|
171
175
|
- lib/reactor/plans/delete_channel.rb
|
172
176
|
- lib/reactor/plans/delete_group.rb
|
173
177
|
- lib/reactor/plans/delete_obj.rb
|
@@ -176,6 +180,7 @@ files:
|
|
176
180
|
- lib/reactor/plans/rename_group.rb
|
177
181
|
- lib/reactor/plans/rename_obj_class.rb
|
178
182
|
- lib/reactor/plans/update_attribute.rb
|
183
|
+
- lib/reactor/plans/update_attribute_group.rb
|
179
184
|
- lib/reactor/plans/update_group.rb
|
180
185
|
- lib/reactor/plans/update_obj.rb
|
181
186
|
- lib/reactor/plans/update_obj_class.rb
|