activefedora-aggregation 0.6.0 → 0.7.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: e4f1b581036f16e61c0a2ad437f0a9f056510eec
4
- data.tar.gz: 53f99afd97226cc78543ca0c3836b5976fdd4cd7
3
+ metadata.gz: 5d1dbe9ac23451faae6cff0a8249099b3f0a16fc
4
+ data.tar.gz: 898c460e4a8a953f275af28566c31c81aaabc45e
5
5
  SHA512:
6
- metadata.gz: 3b962fe055c52589673ad661b50097650316df71052c2389da488e63a9850932c2c227a947e71e2ee5710b5e5dd375f138ea2791e3c451fc72395d6aa2b12d7d
7
- data.tar.gz: e4e3da14538596e0616aefbc63aac94950df533de810ab915b11398d17626676482b381960e1ba1687bc4ac7138076ab33c3b26605bf895cc4d4dfff5e29b804
6
+ metadata.gz: 16db6ed94d16e66e200b6b50df6a828fcf939e85263bb7ac87acbd5831fb5324953b488c085a949c0235e2e29d59c1a21add23c2fb8eddf2ed766639b95c8f40
7
+ data.tar.gz: 50dd60edc92c86eb29ff2a3cf1187637f8e0fcff844d0a6c7e56f0c96e8fe261f4fac63a6d4e406a11180fb6b718acfee48e978a2273b6b1e2092b5e277cd99f
@@ -1,6 +1,7 @@
1
1
  module ActiveFedora
2
2
  module Aggregation
3
3
  class ListSource < ActiveFedora::Base
4
+ delegate :order_will_change!, to: :ordered_self
4
5
  property :head, predicate: ::RDF::Vocab::IANA['first'], multiple: false
5
6
  property :tail, predicate: ::RDF::Vocab::IANA.last, multiple: false
6
7
  property :nodes, predicate: ::RDF::DC::hasPart
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora
2
2
  module Aggregation
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -62,7 +62,18 @@ module ActiveFedora::Orders
62
62
  unless unordered_association.target.include?(record)
63
63
  unordered_association.concat(record)
64
64
  end
65
- target.insert_at(loc, record)
65
+ target.insert_at(loc, record, proxy_in: owner)
66
+ end
67
+
68
+ # Insert a target ID in a specific position
69
+ # @param [Integer] loc Position to insert record ID
70
+ # @param [String] id ID of record to insert.
71
+ def insert_target_id_at(loc, id)
72
+ raise ArgumentError.new "ID can not be nil" if id.nil?
73
+ unless unordered_association.ids_reader.include?(id)
74
+ raise ArgumentError.new "#{id} is not a part of #{unordered_association.reflection.name}"
75
+ end
76
+ target.insert_proxy_for_at(loc, ActiveFedora::Base.id_to_uri(id), proxy_in: owner)
66
77
  end
67
78
 
68
79
  # Delete whatever node is at a specific position
@@ -2,7 +2,7 @@ module ActiveFedora
2
2
  module Orders
3
3
  class CollectionProxy < ActiveFedora::Associations::CollectionProxy
4
4
  attr_reader :association
5
- delegate :append_target, :insert_target_at, :delete_at, to: :association
5
+ delegate :append_target, :insert_target_at, :insert_target_id_at, :delete_at, to: :association
6
6
  end
7
7
  end
8
8
  end
@@ -82,9 +82,23 @@ module ActiveFedora
82
82
 
83
83
  # @param [Integer] loc Location to insert target at
84
84
  # @param [ActiveFedora::Base] target Target to insert
85
- def insert_at(loc, target)
85
+ def insert_at(loc, target, proxy_in: nil)
86
86
  node = build_node(new_node_subject)
87
87
  node.target = target
88
+ node.proxy_in = proxy_in
89
+ if loc == 0
90
+ append_to(node, head)
91
+ else
92
+ append_to(node, ordered_reader.take(loc).last)
93
+ end
94
+ end
95
+
96
+ # @param [Integer] loc Location to insert target at
97
+ # @param [String] proxy_for proxyFor to add
98
+ def insert_proxy_for_at(loc, proxy_for, proxy_in: nil)
99
+ node = build_node(new_node_subject)
100
+ node.proxy_for = proxy_for
101
+ node.proxy_in = proxy_in
88
102
  if loc == 0
89
103
  append_to(node, head)
90
104
  else
@@ -123,6 +137,12 @@ module ActiveFedora
123
137
  @changed
124
138
  end
125
139
 
140
+ # Marks this ordered list as about to change. Useful for when changing
141
+ # proxies individually.
142
+ def order_will_change!
143
+ @changed = true
144
+ end
145
+
126
146
  # @return [::RDF::Graph] Graph representation of this list.
127
147
  def to_graph
128
148
  ::RDF::Graph.new.tap do |g|
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.6.0
4
+ version: 0.7.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-11-02 00:00:00.000000000 Z
11
+ date: 2015-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  version: '0'
217
217
  requirements: []
218
218
  rubyforge_project:
219
- rubygems_version: 2.4.5.1
219
+ rubygems_version: 2.5.0
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: Aggregations for active-fedora