dor-services 4.19.2 → 4.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dor/datastreams/version_metadata_ds.rb +29 -10
- data/lib/dor/models/versionable.rb +4 -1
- data/lib/dor/utils/sdr_client.rb +23 -0
- data/lib/dor/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4729eacae4302a64db9ac7e92b4f8adbc6e8311e
|
4
|
+
data.tar.gz: c87321714b6cde55d3a2b62c9125827c5b8bd8aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2065d971335d18534df20609c96fa684c56a0e31d895255279c301195cf04b86fbc63f7deeb8649705dd75f3080618ca91d07fca2e637b33207f2836d45ca4f3
|
7
|
+
data.tar.gz: a3ea926e1f85ed29e5dbb1bbc623fb9ce8082df73b71fb3122b0a59e20b6489beb598edd11de09a3a49629175e58fa9ab264a1f548d77929a8dabb2713165d68
|
@@ -107,7 +107,7 @@ module Dor
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
# @return [
|
110
|
+
# @return [String] value of the most current versionId
|
111
111
|
def current_version_id
|
112
112
|
current_version=current_version_node
|
113
113
|
if current_version.nil?
|
@@ -151,11 +151,6 @@ module Dor
|
|
151
151
|
self.content = ng_xml.to_s
|
152
152
|
end
|
153
153
|
|
154
|
-
# @return [String] The value of the greatest versionId
|
155
|
-
def current_version_id
|
156
|
-
current_version_node[:versionId].to_s
|
157
|
-
end
|
158
|
-
|
159
154
|
# @return [Boolean] returns true if the current version has a tag and a description, false otherwise
|
160
155
|
def current_version_closeable?
|
161
156
|
current = current_version_node
|
@@ -168,9 +163,9 @@ module Dor
|
|
168
163
|
|
169
164
|
# @return [String] The tag for the newest version
|
170
165
|
def current_tag
|
171
|
-
current_version_node[:tag].to_s
|
166
|
+
current_version_node[:tag].to_s
|
172
167
|
end
|
173
|
-
|
168
|
+
|
174
169
|
def tag_for_version(versionId)
|
175
170
|
nodes=self.ng_xml.search('//version[@versionId=\''+versionId+'\']')
|
176
171
|
if nodes.length == 1
|
@@ -179,6 +174,7 @@ module Dor
|
|
179
174
|
''
|
180
175
|
end
|
181
176
|
end
|
177
|
+
|
182
178
|
# @return [String] The description for the specified version, or empty string if there is no description
|
183
179
|
def description_for_version(versionId)
|
184
180
|
nodes=self.ng_xml.search('//version[@versionId=\''+versionId+'\']')
|
@@ -188,7 +184,7 @@ module Dor
|
|
188
184
|
''
|
189
185
|
end
|
190
186
|
end
|
191
|
-
|
187
|
+
|
192
188
|
# @return [String] The description for the current version
|
193
189
|
def current_description
|
194
190
|
desc_node=current_version_node.at_xpath('description')
|
@@ -197,7 +193,29 @@ module Dor
|
|
197
193
|
end
|
198
194
|
''
|
199
195
|
end
|
200
|
-
|
196
|
+
|
197
|
+
# Compares the current_version with the passed in known_version (usually SDRs version)
|
198
|
+
# If the known_version is greater than the current version, then all version nodes greater than the known_version are removed,
|
199
|
+
# then the current_version is incremented. This repairs the case where a previous call to open a new verison
|
200
|
+
# updates the versionMetadata datastream, but versioningWF is not initiated. Prevents the versions from getting
|
201
|
+
# out of synch with SDR
|
202
|
+
#
|
203
|
+
# @param [Integer] known_version object version you wish to synch to, usually SDR's version
|
204
|
+
# @param [Hash] opts optional parameters
|
205
|
+
# @option opts [String] :description describes the version change
|
206
|
+
# @option opts [Symbol] :significance which part of the version tag to increment
|
207
|
+
def sync_then_increment_version known_version, opts = {}
|
208
|
+
cv = current_version_id.to_i
|
209
|
+
raise Dor::Exception.new("Cannot sync to a version greater than current: #{cv}, requested #{known_version}") if cv < known_version
|
210
|
+
|
211
|
+
while cv != known_version &&
|
212
|
+
current_version_node.remove
|
213
|
+
cv = current_version_id.to_i
|
214
|
+
end
|
215
|
+
|
216
|
+
increment_version(opts[:description], opts[:significance])
|
217
|
+
end
|
218
|
+
|
201
219
|
private
|
202
220
|
|
203
221
|
# @return [Nokogiri::XML::Node] Node representing the current version
|
@@ -210,5 +228,6 @@ module Dor
|
|
210
228
|
tags = find_by_terms(:version, :tag)
|
211
229
|
tags.map{|t| VersionTag.parse(t.value)}.max
|
212
230
|
end
|
231
|
+
|
213
232
|
end
|
214
233
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'dor/utils/sdr_client'
|
2
|
+
|
1
3
|
module Dor
|
2
4
|
module Versionable
|
3
5
|
extend ActiveSupport::Concern
|
@@ -24,9 +26,10 @@ module Dor
|
|
24
26
|
raise Dor::Exception, 'Object already opened for versioning' if(new_version_open?)
|
25
27
|
raise Dor::Exception, 'Object currently being accessioned' if(Dor::WorkflowService.get_active_lifecycle('dor', pid, 'submitted'))
|
26
28
|
|
29
|
+
sdr_version = Sdr::Client.current_version pid
|
27
30
|
|
28
31
|
vmd_ds = datastreams['versionMetadata']
|
29
|
-
vmd_ds.
|
32
|
+
vmd_ds.sync_then_increment_version sdr_version
|
30
33
|
vmd_ds.content = vmd_ds.ng_xml.to_s
|
31
34
|
vmd_ds.save unless self.new_object?
|
32
35
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Sdr
|
2
|
+
|
3
|
+
module Client
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# @param [String] druid id of the object you want the version of
|
7
|
+
# @returns [Integer] the current version from SDR
|
8
|
+
def current_version druid
|
9
|
+
sdr_client = Dor::Config.sdr.rest_client
|
10
|
+
xml = sdr_client["objects/#{druid}/current_version"].get
|
11
|
+
|
12
|
+
begin
|
13
|
+
doc = Nokogiri::XML xml
|
14
|
+
raise if doc.root.name != 'currentVersion'
|
15
|
+
return Integer(doc.text)
|
16
|
+
rescue => e
|
17
|
+
raise "Unable to parse XML from SDR current_version API call: #{xml}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/dor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-04-
|
15
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: active-fedora
|
@@ -611,6 +611,7 @@ files:
|
|
611
611
|
- lib/dor/services/tei2dc.xslt
|
612
612
|
- lib/dor/utils/ng_tidy.rb
|
613
613
|
- lib/dor/utils/predicate_patch.rb
|
614
|
+
- lib/dor/utils/sdr_client.rb
|
614
615
|
- lib/dor/utils/solr_doc_helper.rb
|
615
616
|
- lib/dor/utils/utc_date_field_mapper.rb
|
616
617
|
- lib/dor/version.rb
|