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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcc04099064780ed9c6480ed010c5911fc7c6ab8
4
- data.tar.gz: 04b8654ad0ae1c2d61d65fcb67a8a76309e21a02
3
+ metadata.gz: f11250eb1074d38b5ebb2a39478405e8ac6bc524
4
+ data.tar.gz: 78b247bbe2eff3558ebb11a2f61be01bbce2a1ba
5
5
  SHA512:
6
- metadata.gz: 5a49301c71daa7a5f265623c259d3a6c1dd4127819771e345cb929e084c9b27b3204c1ed3ba25b4d29e8ff4d5f863c8909cb305b435308d06526c531961a6177
7
- data.tar.gz: e57cf0ab9b1d21e8b8ea06152c2a94541b4ff43aab5f8f48a7a30fcea3fc5e51be17d7a45328433bb234c6589ab1355a5007c0fc1a0f004e7a06bae5c1d7d70e
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
@@ -37,6 +37,7 @@ require 'reactor/cm/user'
37
37
  require 'reactor/cm/attribute'
38
38
  require 'reactor/cm/obj'
39
39
  require 'reactor/cm/obj_class'
40
+ require 'reactor/cm/attribute_group'
40
41
  require 'reactor/cm/link'
41
42
  require 'reactor/cm/group'
42
43
  require 'reactor/cm/editorial_group'
@@ -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.class, new_obj_class || self.obj_class)
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
- builtin_attr?(attr) || (self.class.send(:instance_variable_get,'@_o_allowed_attrs') || []).include?(key_to_attr(attr))
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
@@ -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
@@ -22,6 +22,10 @@ module Reactor
22
22
  @params[key.to_sym] = value
23
23
  end
24
24
 
25
+ def preset(attribute, value)
26
+ @preset_attrs[attribute] = value
27
+ end
28
+
25
29
  def take(attr_name, opts={})
26
30
  attr_name = attr_name.to_s
27
31
  @take_attrs << attr_name
@@ -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
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
- VERSION = "1.11.0.beta3"
3
+ VERSION = "1.12.0.beta1"
4
4
  end
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.11.0.beta3
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: 2014-11-18 00:00:00.000000000 Z
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