infopark_reactor 1.14.0.beta2 → 1.15.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: 0d31c45363fc66e4fa2e33a596a28f961273a77f
4
- data.tar.gz: 6d6bf3a3de71313b9e2b23f7431e528f2f88f3c0
3
+ metadata.gz: a56b31ba2e29489af380f651342ddc82f3b542d3
4
+ data.tar.gz: 9ed150774b911bb3dfb2c311d7a84dff1dc4fd72
5
5
  SHA512:
6
- metadata.gz: 3fd880bf792f8a5677169c4bb1864fd29411d92756ff1c833eddf1ce43268f921ce6f30c0d35293d70412497a0d6b93fd223cd7ac0e88c124e6880e5008c6936
7
- data.tar.gz: 8ada3be23e66e43a73f0f2d3075553b15787cd34112826cf702203c918e585a9d2d88ff84671dff83fe516210e8693eb82097f160aba9a803cdbd07f07691a97
6
+ metadata.gz: 78174cc1ebf120f5f844e1ebcb26c1f1e4245cb63bd03540bca50a380e455717c11580e4607a62e2406f1392991f1686670e7d39b5930259b598f3290dc3b134
7
+ data.tar.gz: 4faab19e5c534b811533d7a106057c03ed9fc2cff51fc70013a1743d2460db98e05ca12aa8d04bae89bedea2e4c3c3defc9004eb1afb2a2dd0884eeeba889ca4
@@ -8,5 +8,9 @@ module RailsConnector
8
8
  def self.get_fingerprint(name)
9
9
  find_by_blob_name(name).fingerprint
10
10
  end
11
+
12
+ def self.get_fingerprint_map(blob_names)
13
+ Hash[self.where(:blob_name => blob_names).select([:blob_name, :fingerprint]).map {|b| [b.blob_name, b.fingerprint] }]
14
+ end
11
15
  end
12
16
  end
@@ -69,6 +69,9 @@ require 'reactor/already_released'
69
69
  require 'reactor/no_working_version'
70
70
  require 'reactor/not_permitted'
71
71
 
72
+ # require eager loader
73
+ require 'rails_connector/meta/eager_loader'
74
+
72
75
  # require components
73
76
  require 'reactor/main'
74
77
  require 'reactor/rc_independent'
@@ -0,0 +1,91 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'singleton'
3
+ require 'set'
4
+
5
+ module RailsConnector
6
+ module Meta
7
+ class EagerLoader
8
+ include Singleton
9
+ attr_reader :obj_classes
10
+
11
+ def initialize
12
+ # Rails.logger.debug "EagerLoader: I am eager to start working"
13
+ @obj_classes = {}
14
+ # Rails 3.1 contains a bug that screws attribute loading
15
+ # attributes are set to assigned classes
16
+ if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 1
17
+ RailsConnector::ObjClass.all.each do |obj_class|
18
+ obj_class.custom_attributes
19
+ @obj_classes[obj_class.name] = obj_class
20
+ end
21
+ else
22
+ RailsConnector::ObjClass.includes(:custom_attributes_raw).all.each do |obj_class|
23
+ @obj_classes[obj_class.name] = obj_class
24
+ end
25
+ preload_attribute_blobs
26
+ end
27
+ end
28
+
29
+ def obj_class(name)
30
+ name = name.to_s
31
+ if !@obj_classes.fetch(name, nil).nil?
32
+ @obj_classes[name]
33
+ else
34
+ # TODO: preload_attribute_blobs for obj_class
35
+ @obj_classes[name] ||= RailsConnector::ObjClass.find_by_obj_class_name(name)
36
+ end
37
+ end
38
+
39
+ def forget_obj_class(name)
40
+ @obj_classes.delete(name.to_s)
41
+ end
42
+
43
+ protected
44
+ def preload_attribute_blobs
45
+ attribute_names = Set.new
46
+ @obj_classes.each do |_, obj_class|
47
+ obj_class.custom_attributes.each do |attribute_name, _|
48
+ attribute_names << attribute_name
49
+ end
50
+ end
51
+
52
+ blob_names = attribute_names.map {|attribute_name| "#{attribute_name}.jsonAttributeDict" }
53
+ # Fiona >= 6.8
54
+ if RailsConnector::BlobMapping.exists?
55
+ blob_names = attribute_names.map {|attribute_name| "#{attribute_name}.jsonAttributeDict" }
56
+ fingerprint_map = RailsConnector::BlobMapping.get_fingerprint_map(blob_names)
57
+ blob_fingerprints = fingerprint_map.values
58
+ # NOTE: this is correct!
59
+ blobs = RailsConnector::Blob.where(:blob_name => blob_fingerprints).to_a
60
+ blob_map = Hash[blobs.map {|b| [b.blob_name, b]}]
61
+
62
+ @obj_classes.each do |_, obj_class|
63
+ obj_class.custom_attributes.each do |_, attribute|
64
+ blob_name = "#{attribute.name}.jsonAttributeDict"
65
+ fingerprint = fingerprint_map[blob_name]
66
+ blob = blob_map[fingerprint]
67
+
68
+ next unless blob && blob.blob_data?
69
+ attribute.instance_variable_set(:@blob_data, ::JSON.parse(blob.blob_data))
70
+ end
71
+ end
72
+ # Fiona = 6.7
73
+ else
74
+ blob_names = attribute_names.map {|attribute_name| "#{attribute_name}.jsonAttributeDict" }
75
+ blobs = RailsConnector::Blob.where(:blob_name => blob_names).to_a
76
+ blob_map = Hash[blobs.map {|b| [b.blob_name, b]}]
77
+
78
+ @obj_classes.each do |_, obj_class|
79
+ obj_class.custom_attributes.each do |_, attribute|
80
+ blob_name = "#{attribute.name}.jsonAttributeDict"
81
+ blob = blob_map[blob_name]
82
+
83
+ next unless blob && blob.blob_data?
84
+ attribute.instance_variable_set(:@blob_data, ::JSON.parse(blob.blob_data))
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -41,7 +41,7 @@ module Reactor
41
41
  end
42
42
 
43
43
  def regenerate_attribute_handler(obj_class_name)
44
- generate_attribute_handler(RailsConnector::ObjClass.find_by_name(obj_class_name))
44
+ generate_attribute_handler(RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class_name))
45
45
  end
46
46
 
47
47
  protected
@@ -55,7 +55,7 @@ module Reactor
55
55
  end
56
56
 
57
57
  def generate_attribute_handlers
58
- RailsConnector::ObjClass.all.each do |obj_class|
58
+ RailsConnector::Meta::EagerLoader.instance.obj_classes.each do |_, obj_class|
59
59
  # Rails.logger.debug "Reactor::AttributeHandlers: preparing obj class #{obj_class.name}"
60
60
  generate_attribute_handler(obj_class) if obj_class.name =~ /^[A-Z]/
61
61
  end
@@ -58,7 +58,12 @@ module Reactor
58
58
  result = [result] unless result.kind_of?(Array)
59
59
  result.map do |dictitem|
60
60
  key = dictitem.children.detect {|c| c.name == 'key'}.text
61
- value = dictitem.children.detect {|c| c.name == 'value'}.text
61
+ raw_value = dictitem.children.detect {|c| c.name == 'value'}
62
+ if raw_value.children.detect {|c| c.kind_of?(::REXML::Text) }
63
+ value = raw_value.text
64
+ else
65
+ value = raw_value.children.map {|c| c.text }
66
+ end
62
67
  {key => value}
63
68
  end.inject({}, &:merge)
64
69
  end
@@ -86,7 +91,15 @@ module Reactor
86
91
  xml.text!(key.to_s)
87
92
  end
88
93
  xml.tag!('value') do
89
- xml.text!(value.to_s)
94
+ if value.kind_of?(Array)
95
+ value.each do |item|
96
+ xml.tag!('listitem') do
97
+ xml.text!(item.to_s)
98
+ end
99
+ end
100
+ else
101
+ xml.text!(value.to_s)
102
+ end
90
103
  end
91
104
  end
92
105
  end
@@ -3,6 +3,9 @@ module Reactor
3
3
  class Configuration
4
4
  class << self
5
5
  attr_accessor :xml_access
6
+ attr_accessor :sanitize_obj_name
6
7
  end
8
+
9
+ self.sanitize_obj_name = true
7
10
  end
8
11
  end
@@ -481,12 +481,16 @@ module Reactor
481
481
  end
482
482
  module ClassMethods
483
483
  def sanitize_name(old_name)
484
- character_map = {'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss', 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue'}
485
- new_name = old_name.gsub(/[^-$a-zA-Z0-9]/) {|char| character_map[char] || '_'}.
486
- gsub(/__+/,'_').
487
- gsub(/^_+/,'').
488
- gsub(/_+$/,'')
489
- new_name
484
+ if Reactor::Configuration.sanitize_obj_name
485
+ character_map = {'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss', 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue'}
486
+ new_name = old_name.gsub(/[^-$a-zA-Z0-9]/) {|char| character_map[char] || '_'}.
487
+ gsub(/__+/,'_').
488
+ gsub(/^_+/,'').
489
+ gsub(/_+$/,'')
490
+ new_name
491
+ else
492
+ old_name
493
+ end
490
494
  end
491
495
 
492
496
  if Reactor.rails4_x?
@@ -10,7 +10,14 @@ class Reactor::Session
10
10
  include Observable
11
11
 
12
12
  def self.instance
13
- self.new
13
+ self.for(Reactor::Configuration.xml_access[:username])
14
+ end
15
+
16
+ def self.for(user_name)
17
+ self.new.tap do |instance|
18
+ instance.instance_variable_set(:@user_name, user_name)
19
+ instance.send(:proper_notify_observers, user_name, false)
20
+ end
14
21
  end
15
22
 
16
23
  def marshal_dump
data/lib/reactor/sudo.rb CHANGED
@@ -2,11 +2,12 @@
2
2
  module Reactor
3
3
  module Sudo
4
4
  def self.su(other_user_name, &block)
5
- current_user_name = Reactor::Session.instance.user_name
6
- Reactor::Session.instance.user_name = other_user_name
5
+ rsession = Reactor::Session.instance
6
+ current_user_name = rsession.user_name
7
+ rsession.user_name = other_user_name
7
8
  yield
8
9
  ensure
9
- Reactor::Session.instance.user_name = current_user_name || 'root'
10
+ rsession.user_name = current_user_name || 'root'
10
11
  end
11
12
  end
12
13
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Reactor
3
- VERSION = "1.14.0.beta2"
3
+ VERSION = "1.15.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.14.0.beta2
4
+ version: 1.15.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: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -105,7 +105,6 @@ files:
105
105
  - app/models/rails_connector/blob_mapping.rb
106
106
  - app/models/rails_connector/channel.rb
107
107
  - app/models/rails_connector/content.rb
108
- - app/models/rails_connector/meta/eager_loader.rb
109
108
  - app/models/rails_connector/obj_class.rb
110
109
  - app/models/rails_connector/obj_class_attr.rb
111
110
  - app/models/rails_connector/object_with_meta_data.rb
@@ -115,6 +114,7 @@ files:
115
114
  - lib/generators/cm/migration/migration_generator.rb
116
115
  - lib/generators/cm/migration/templates/template.rb
117
116
  - lib/infopark_reactor.rb
117
+ - lib/rails_connector/meta/eager_loader.rb
118
118
  - lib/reactor/already_released.rb
119
119
  - lib/reactor/attributes.rb
120
120
  - lib/reactor/attributes/date_serializer.rb
@@ -1,41 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- require 'singleton'
3
-
4
- module RailsConnector
5
- module Meta
6
- class EagerLoader
7
- include Singleton
8
- def initialize
9
- # Rails.logger.debug "EagerLoader: I am eager to start working"
10
- @obj_classes = {}
11
- # Rails 3.1 contains a bug that screws attribute loading
12
- # attributes are set to assigned classes
13
- if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR == 1
14
- RailsConnector::ObjClass.all.each do |obj_class|
15
- obj_class.custom_attributes
16
- @obj_classes[obj_class.name] = obj_class
17
- end
18
- else
19
- RailsConnector::ObjClass.includes(:custom_attributes_raw).all.each do |obj_class|
20
- @obj_classes[obj_class.name] = obj_class
21
- end
22
- end
23
- end
24
-
25
- def obj_class(name)
26
- name = name.to_s
27
- if !@obj_classes.fetch(name, nil).nil?
28
- # puts "EagerLoader: I've already loaded it: #{name}"
29
- @obj_classes[name]
30
- else
31
- # puts "EagerLoader: NO HAVE: #{name}"
32
- @obj_classes[name] ||= RailsConnector::ObjClass.find_by_obj_class_name(name)
33
- end
34
- end
35
-
36
- def forget_obj_class(name)
37
- @obj_classes.delete(name.to_s)
38
- end
39
- end
40
- end
41
- end