activefedora-aggregation 0.5.0 → 0.6.0

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: 3e412a6567468dcb49dab1daa8bc699ea2205812
4
- data.tar.gz: e41e914e33fc66e39fcb2b64fdd528d41364a8ee
3
+ metadata.gz: e4f1b581036f16e61c0a2ad437f0a9f056510eec
4
+ data.tar.gz: 53f99afd97226cc78543ca0c3836b5976fdd4cd7
5
5
  SHA512:
6
- metadata.gz: 52481ea56a4dec434bd0da1affc85137d9212db3832fcce27cfaf24ac300393ff31fdb26eb0f0385d0c7f52fe044df2fff3e26f1d6e12458e77a1e66e122c0e9
7
- data.tar.gz: 429d9ec648f2391f8a013bb3a459c5e78f3cdcd972d0ed85fe15f71c1ee1f14bf2d959476085545c7980854f11f712150df7b99c2bb2ccce5173f10aee88b247
6
+ metadata.gz: 3b962fe055c52589673ad661b50097650316df71052c2389da488e63a9850932c2c227a947e71e2ee5710b5e5dd375f138ea2791e3c451fc72395d6aa2b12d7d
7
+ data.tar.gz: e4e3da14538596e0616aefbc63aac94950df533de810ab915b11398d17626676482b381960e1ba1687bc4ac7138076ab33c3b26605bf895cc4d4dfff5e29b804
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /jetty
11
+ logfile.log
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.add_dependency 'activesupport'
20
20
  spec.add_dependency 'active-fedora', '~> 9.5'
21
21
  spec.add_dependency 'rdf-vocab', '~> 0.8.1'
22
- # Lock to RDF 1.1.16 because 1.1.17 causes a bug from ruby 2.2
22
+ # Avoid RDF 1.1.17 because of a bug from ruby 2.2
23
23
  # https://github.com/ruby-rdf/rdf/pull/213
24
- spec.add_dependency 'rdf', '~>1.1.16.0'
24
+ spec.add_dependency 'rdf', '~> 1.1', '>= 1.1.17.1'
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.8"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
@@ -11,11 +11,18 @@ module ActiveFedora
11
11
  super
12
12
  end
13
13
 
14
+ # Overriding so that we don't track previously_changed, which was
15
+ # rather expensive.
16
+ def clear_changed_attributes
17
+ @changed_attributes.clear
18
+ end
19
+
14
20
  def changed?
15
21
  super || ordered_self.changed?
16
22
  end
17
23
 
18
24
  # Ordered list representation of proxies in graph.
25
+ # @return [Array<ListNode>]
19
26
  def ordered_self
20
27
  @ordered_self ||= ordered_list_factory.new(resource, head_subject, tail_subject)
21
28
  end
@@ -32,10 +39,7 @@ module ActiveFedora
32
39
  # @note This method is used by ActiveFedora::Base upstream for indexing,
33
40
  # at https://github.com/projecthydra/active_fedora/blob/master/lib/active_fedora/profile_indexing_service.rb.
34
41
  def serializable_hash(options=nil)
35
- options ||= {}
36
- options[:except] ||= []
37
- options[:except] += [:head, :tail, :nodes]
38
- super
42
+ {}
39
43
  end
40
44
 
41
45
  def to_solr(solr_doc={})
@@ -45,13 +49,29 @@ module ActiveFedora
45
49
  })
46
50
  end
47
51
 
52
+ # Not useful and slows down indexing.
53
+ def create_date
54
+ nil
55
+ end
56
+
57
+ # Not useful, slows down indexing.
58
+ def modified_date
59
+ nil
60
+ end
61
+
62
+ # Not useful, slows down indexing.
63
+ def has_model
64
+ ["ActiveFedora::Aggregation::ListSource"]
65
+ end
66
+
48
67
  private
49
68
 
50
69
  def persist_ordered_self
51
70
  nodes_will_change!
52
71
  # Delete old statements
53
- ordered_list_factory.new(resource, head_subject, tail_subject).to_graph.statements.each do |s|
54
- resource.delete s
72
+ subj = resource.subjects.to_a.select{|x| x.to_s.split("/").last.to_s.include?("#g")}
73
+ subj.each do |s|
74
+ resource.delete [s, nil, nil]
55
75
  end
56
76
  # Assert head and tail
57
77
  self.head = ordered_self.head.next.rdf_subject
@@ -67,7 +87,7 @@ module ActiveFedora
67
87
  end
68
88
 
69
89
  def has_unpersisted_proxy_for?
70
- ordered_self.flat_map(&:target).compact.select(&:new_record?).find{|x| x.respond_to?(:uri)}
90
+ ordered_self.select(&:new_record?).map(&:target).find{|x| x.respond_to?(:uri)}
71
91
  end
72
92
 
73
93
  def head_subject
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora
2
2
  module Aggregation
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -6,6 +6,10 @@ module ActiveFedora::Orders
6
6
  @target = find_target
7
7
  end
8
8
 
9
+ def inspect
10
+ "#<ActiveFedora::Orders::Association:#{object_id}>"
11
+ end
12
+
9
13
  def reader(*args)
10
14
  @proxy ||= ActiveFedora::Orders::CollectionProxy.new(self)
11
15
  super
@@ -41,7 +41,7 @@ module ActiveFedora::Orders
41
41
  # @return [ActiveFedora::Orders::ListNode::Resource]
42
42
  def to_graph
43
43
  g = Resource.new(rdf_subject)
44
- g.proxy_for = target.try(:uri)
44
+ g.proxy_for = ActiveFedora::Base.id_to_uri(target_id)
45
45
  g.proxy_in = proxy_in.try(:uri)
46
46
  g.next = self.next.try(:rdf_subject)
47
47
  g.prev = self.prev.try(:rdf_subject)
@@ -101,18 +101,20 @@ module ActiveFedora
101
101
  node.prev.next = next_node
102
102
  node.next.prev = prev_node
103
103
  @changed = true
104
+ node
105
+ else
106
+ nil
104
107
  end
105
- self
106
108
  end
107
109
 
108
110
  # @param [Integer] loc Index of node to delete.
109
111
  def delete_at(loc)
110
- return self if loc == nil
112
+ return nil if loc == nil
111
113
  arr = ordered_reader.take(loc+1)
112
114
  if arr.length == loc+1
113
115
  delete_node(arr.last)
114
116
  else
115
- self
117
+ nil
116
118
  end
117
119
  end
118
120
 
@@ -19,6 +19,18 @@ module ActiveFedora
19
19
  self
20
20
  end
21
21
 
22
+ def insert_at(loc, record)
23
+ association.insert_target_at(loc, record)
24
+ self
25
+ end
26
+
27
+ def delete_at(loc)
28
+ result = association.delete_at(loc)
29
+ if result
30
+ result.target
31
+ end
32
+ end
33
+
22
34
  def clear
23
35
  while to_ary.present?
24
36
  association.delete_at(0)
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+ puts "Loading environment..."
3
+ lib = File.expand_path('../../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'active_fedora/aggregation'
6
+ require 'byebug'
7
+ puts "Ready"
8
+ ActiveFedora::Base.logger = Logger.new('logfile.log')
9
+
10
+ # When the log level is set to debug, log all LDP HTTP API traffic
11
+ class LogSubscriber < ActiveSupport::LogSubscriber
12
+ def initialize
13
+ super
14
+ @odd = false
15
+ end
16
+
17
+ def http(event)
18
+ return unless logger.debug?
19
+
20
+ payload = event.payload
21
+
22
+ name = "#{payload[:name]} (#{event.duration.round(1)}ms)"
23
+ url = payload[:url] || "[no url]"
24
+
25
+ if odd?
26
+ name = color(name, CYAN, true)
27
+ url = color(url, nil, true)
28
+ else
29
+ name = color(name, MAGENTA, true)
30
+ end
31
+
32
+ debug " #{name} #{url} Service: #{payload[:ldp_client]}"
33
+ end
34
+
35
+ def odd?
36
+ @odd = !@odd
37
+ end
38
+
39
+ def logger
40
+ ActiveFedora::Base.logger
41
+ end
42
+ end
43
+
44
+ LogSubscriber.attach_to :ldp
45
+
46
+
47
+ class Foo < ActiveFedora::Base
48
+ ordered_aggregation :members,
49
+ has_member_relation: ::RDF::DC.hasPart,
50
+ class_name: 'ActiveFedora::Base',
51
+ through: :list_source
52
+ end
53
+ class Bar < ActiveFedora::Base
54
+ end
55
+
56
+ i = Foo.create!
57
+
58
+ iterations = 30
59
+ require 'benchmark'
60
+
61
+ iterations.times do |n|
62
+ time = Benchmark.measure do |x|
63
+ # byebug if n > 10
64
+ image = Foo.find(i.id)
65
+ fs = Bar.create!
66
+ image.ordered_members << fs
67
+ image.save!
68
+ end
69
+
70
+ puts "#{n} - #{time.real}"
71
+ end
72
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefedora-aggregation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2015-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -58,14 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.16.0
61
+ version: '1.1'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.1.17.1
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - "~>"
67
70
  - !ruby/object:Gem::Version
68
- version: 1.1.16.0
71
+ version: '1.1'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.1.17.1
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: bundler
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +195,7 @@ files:
189
195
  - lib/active_fedora/orders/ordered_list.rb
190
196
  - lib/active_fedora/orders/reflection.rb
191
197
  - lib/active_fedora/orders/target_proxy.rb
198
+ - script/load_test.rb
192
199
  homepage: http://github.org/curationexperts/activefedora-aggregation
193
200
  licenses:
194
201
  - APACHE2