dor-services 5.2.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/config/certs/robots-dor-dev.crt +29 -0
- data/config/certs/robots-dor-dev.key +27 -0
- data/config/config_defaults.yml +2 -0
- data/config/dev_console_env.rb +77 -0
- data/lib/dor-services.rb +31 -27
- data/lib/dor/config.rb +25 -19
- data/lib/dor/datastreams/administrative_metadata_ds.rb +19 -20
- data/lib/dor/datastreams/content_metadata_ds.rb +238 -177
- data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
- data/lib/dor/datastreams/default_object_rights_ds.rb +99 -16
- data/lib/dor/datastreams/desc_metadata_ds.rb +37 -34
- data/lib/dor/datastreams/embargo_metadata_ds.rb +16 -16
- data/lib/dor/datastreams/events_ds.rb +2 -2
- data/lib/dor/datastreams/geo_metadata_ds.rb +5 -10
- data/lib/dor/datastreams/identity_metadata_ds.rb +22 -22
- data/lib/dor/datastreams/rights_metadata_ds.rb +43 -32
- data/lib/dor/datastreams/role_metadata_ds.rb +5 -5
- data/lib/dor/datastreams/simple_dublin_core_ds.rb +13 -14
- data/lib/dor/datastreams/version_metadata_ds.rb +22 -23
- data/lib/dor/datastreams/workflow_definition_ds.rb +15 -15
- data/lib/dor/datastreams/workflow_ds.rb +64 -70
- data/lib/dor/exceptions.rb +0 -1
- data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +4 -4
- data/lib/dor/migrations/processable/unify_workflows.rb +1 -1
- data/lib/dor/models/admin_policy_object.rb +4 -4
- data/lib/dor/models/assembleable.rb +2 -3
- data/lib/dor/models/collection.rb +1 -1
- data/lib/dor/models/contentable.rb +113 -108
- data/lib/dor/models/describable.rb +136 -95
- data/lib/dor/models/editable.rb +205 -119
- data/lib/dor/models/embargoable.rb +16 -16
- data/lib/dor/models/eventable.rb +2 -2
- data/lib/dor/models/geoable.rb +3 -3
- data/lib/dor/models/governable.rb +25 -26
- data/lib/dor/models/identifiable.rb +66 -55
- data/lib/dor/models/item.rb +0 -1
- data/lib/dor/models/itemizable.rb +7 -8
- data/lib/dor/models/preservable.rb +7 -8
- data/lib/dor/models/processable.rb +76 -73
- data/lib/dor/models/publishable.rb +25 -30
- data/lib/dor/models/releaseable.rb +118 -155
- data/lib/dor/models/rightsable.rb +2 -3
- data/lib/dor/models/set.rb +1 -1
- data/lib/dor/models/shelvable.rb +8 -10
- data/lib/dor/models/upgradable.rb +5 -6
- data/lib/dor/models/versionable.rb +3 -4
- data/lib/dor/models/workflow_object.rb +15 -16
- data/lib/dor/services/cleanup_reset_service.rb +15 -16
- data/lib/dor/services/cleanup_service.rb +2 -4
- data/lib/dor/services/digital_stacks_service.rb +10 -13
- data/lib/dor/services/merge_service.rb +8 -9
- data/lib/dor/services/metadata_handlers/catalog_handler.rb +1 -1
- data/lib/dor/services/metadata_handlers/mdtoolkit_handler.rb +3 -3
- data/lib/dor/services/metadata_service.rb +19 -20
- data/lib/dor/services/registration_service.rb +80 -61
- data/lib/dor/services/reset_workspace_service.rb +6 -10
- data/lib/dor/services/sdr_ingest_service.rb +15 -16
- data/lib/dor/services/search_service.rb +18 -23
- data/lib/dor/services/suri_service.rb +6 -6
- data/lib/dor/services/technical_metadata_service.rb +27 -44
- data/lib/dor/utils/ng_tidy.rb +3 -3
- data/lib/dor/utils/sdr_client.rb +2 -3
- data/lib/dor/utils/solr_doc_helper.rb +1 -3
- data/lib/dor/version.rb +1 -1
- data/lib/dor/workflow/document.rb +43 -40
- data/lib/dor/workflow/graph.rb +26 -26
- data/lib/dor/workflow/process.rb +34 -35
- data/lib/tasks/rdoc.rake +5 -5
- metadata +129 -111
- data/lib/dor/models/presentable.rb +0 -146
data/lib/dor/models/eventable.rb
CHANGED
data/lib/dor/models/geoable.rb
CHANGED
@@ -13,16 +13,16 @@ module Dor
|
|
13
13
|
|
14
14
|
# @return [String, nil] XML
|
15
15
|
def fetch_geoMetadata_datastream
|
16
|
-
candidates =
|
16
|
+
candidates = datastreams['identityMetadata'].otherId.collect { |oid| oid.to_s }
|
17
17
|
metadata_id = Dor::MetadataService.resolvable(candidates).first
|
18
18
|
return nil if metadata_id.nil?
|
19
|
-
|
19
|
+
Dor::MetadataService.fetch(metadata_id.to_s)
|
20
20
|
end
|
21
21
|
|
22
22
|
def build_geoMetadata_datastream(ds)
|
23
23
|
content = fetch_geoMetadata_datastream
|
24
24
|
return nil if content.nil?
|
25
|
-
ds.dsLabel =
|
25
|
+
ds.dsLabel = label
|
26
26
|
ds.ng_xml = Nokogiri::XML(content)
|
27
27
|
ds.ng_xml.normalize_text!
|
28
28
|
ds.content = ds.ng_xml.to_xml
|
@@ -4,20 +4,20 @@ module Dor
|
|
4
4
|
include Rightsable
|
5
5
|
|
6
6
|
included do
|
7
|
-
belongs_to :admin_policy_object, :property => :is_governed_by, :class_name =>
|
8
|
-
has_and_belongs_to_many :collections, :property => :is_member_of_collection, :class_name =>
|
9
|
-
has_and_belongs_to_many :sets, :property => :is_member_of, :class_name =>
|
7
|
+
belongs_to :admin_policy_object, :property => :is_governed_by, :class_name => 'Dor::AdminPolicyObject'
|
8
|
+
has_and_belongs_to_many :collections, :property => :is_member_of_collection, :class_name => 'Dor::Collection'
|
9
|
+
has_and_belongs_to_many :sets, :property => :is_member_of, :class_name => 'Dor::Collection'
|
10
10
|
end
|
11
11
|
|
12
12
|
def initiate_apo_workflow(name)
|
13
|
-
|
13
|
+
initialize_workflow(name, !self.new_object?)
|
14
14
|
end
|
15
15
|
|
16
16
|
# Returns the default lane_id from the item's APO. Will return 'default' if the item does not have
|
17
17
|
# and APO, or if the APO does not have a default_lane
|
18
18
|
# @return [String] the lane id
|
19
19
|
def default_workflow_lane
|
20
|
-
return 'default' if
|
20
|
+
return 'default' if admin_policy_object.nil? # TODO: log warning?
|
21
21
|
|
22
22
|
admin_md = admin_policy_object.datastreams['administrativeMetadata']
|
23
23
|
return 'default' unless admin_md.respond_to? :default_workflow_lane
|
@@ -27,11 +27,11 @@ module Dor
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def reset_to_apo_default
|
30
|
-
|
30
|
+
rightsMetadata.content = admin_policy_object.rightsMetadata.ng_xml
|
31
31
|
end
|
32
32
|
|
33
33
|
def set_read_rights(rights)
|
34
|
-
|
34
|
+
rightsMetadata.set_read_rights(rights)
|
35
35
|
end
|
36
36
|
|
37
37
|
def add_collection(collection_or_druid)
|
@@ -41,12 +41,11 @@ module Dor
|
|
41
41
|
when Dor::Collection
|
42
42
|
collection_or_druid
|
43
43
|
end
|
44
|
-
|
45
|
-
|
44
|
+
collections << collection
|
45
|
+
sets << collection
|
46
46
|
end
|
47
47
|
|
48
48
|
def remove_collection(collection_or_druid)
|
49
|
-
|
50
49
|
collection = case collection_or_druid
|
51
50
|
when String
|
52
51
|
Dor::Collection.find(collection_or_druid)
|
@@ -54,17 +53,17 @@ module Dor
|
|
54
53
|
collection_or_druid
|
55
54
|
end
|
56
55
|
|
57
|
-
|
58
|
-
|
56
|
+
collections.delete(collection)
|
57
|
+
sets.delete(collection)
|
59
58
|
end
|
60
|
-
#set the rights metadata datastream to the content of the APO's default object rights
|
59
|
+
# set the rights metadata datastream to the content of the APO's default object rights
|
61
60
|
def reapplyAdminPolicyObjectDefaults
|
62
|
-
rightsMetadata.content=admin_policy_object.datastreams['defaultObjectRights'].content
|
61
|
+
rightsMetadata.content = admin_policy_object.datastreams['defaultObjectRights'].content
|
63
62
|
end
|
64
63
|
def rights
|
65
64
|
return nil unless self.respond_to? :rightsMetadata
|
66
|
-
return nil if
|
67
|
-
xml =
|
65
|
+
return nil if rightsMetadata.nil?
|
66
|
+
xml = rightsMetadata.ng_xml
|
68
67
|
return nil if xml.search('//rightsMetadata').length != 1 # ORLY?
|
69
68
|
if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1
|
70
69
|
'Stanford'
|
@@ -100,31 +99,31 @@ module Dor
|
|
100
99
|
def groups_which_view_metadata
|
101
100
|
['dor-administrator', 'sdr-administrator', 'dor-apo-manager', 'dor-apo-depositor', 'dor-viewer', 'sdr-viewer']
|
102
101
|
end
|
103
|
-
def intersect
|
104
|
-
|
102
|
+
def intersect(arr1, arr2)
|
103
|
+
(arr1 & arr2).length > 0
|
105
104
|
end
|
106
|
-
def can_manage_item?
|
105
|
+
def can_manage_item?(roles)
|
107
106
|
intersect roles, groups_which_manage_item
|
108
107
|
end
|
109
|
-
def can_manage_desc_metadata?
|
108
|
+
def can_manage_desc_metadata?(roles)
|
110
109
|
intersect roles, groups_which_manage_desc_metadata
|
111
110
|
end
|
112
|
-
def can_manage_system_metadata?
|
111
|
+
def can_manage_system_metadata?(roles)
|
113
112
|
intersect roles, groups_which_manage_system_metadata
|
114
113
|
end
|
115
|
-
def can_manage_content?
|
114
|
+
def can_manage_content?(roles)
|
116
115
|
intersect roles, groups_which_manage_content
|
117
116
|
end
|
118
|
-
def can_manage_rights?
|
117
|
+
def can_manage_rights?(roles)
|
119
118
|
intersect roles, groups_which_manage_rights
|
120
119
|
end
|
121
|
-
def can_manage_embargo?
|
120
|
+
def can_manage_embargo?(roles)
|
122
121
|
intersect roles, groups_which_manage_embargo
|
123
122
|
end
|
124
|
-
def can_view_content?
|
123
|
+
def can_view_content?(roles)
|
125
124
|
intersect roles, groups_which_view_content
|
126
125
|
end
|
127
|
-
def can_view_metadata?
|
126
|
+
def can_view_metadata?(roles)
|
128
127
|
intersect roles, groups_which_view_metadata
|
129
128
|
end
|
130
129
|
end
|
@@ -6,39 +6,39 @@ module Dor
|
|
6
6
|
include Upgradable
|
7
7
|
|
8
8
|
included do
|
9
|
-
has_metadata :name =>
|
10
|
-
has_metadata :name =>
|
9
|
+
has_metadata :name => 'DC', :type => SimpleDublinCoreDs, :label => 'Dublin Core Record for self object'
|
10
|
+
has_metadata :name => 'identityMetadata', :type => Dor::IdentityMetadataDS, :label => 'Identity Metadata'
|
11
11
|
end
|
12
12
|
|
13
13
|
module ClassMethods
|
14
14
|
attr_reader :object_type
|
15
|
-
def has_object_type
|
15
|
+
def has_object_type(str)
|
16
16
|
@object_type = str
|
17
17
|
Dor.registered_classes[str] = self
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize
|
21
|
+
def initialize(attrs = {})
|
22
22
|
if Dor::Config.suri.mint_ids && !attrs[:pid]
|
23
|
-
attrs = attrs.merge!({:pid=>Dor::SuriService.mint_id, :new_object => true})
|
23
|
+
attrs = attrs.merge!({:pid => Dor::SuriService.mint_id, :new_object => true})
|
24
24
|
end
|
25
25
|
super
|
26
26
|
end
|
27
27
|
|
28
28
|
# helper method to get the tags as an array
|
29
29
|
def tags
|
30
|
-
|
30
|
+
identityMetadata.tag
|
31
31
|
end
|
32
32
|
|
33
33
|
# helper method to get just the content type tag
|
34
34
|
def content_type_tag
|
35
|
-
content_tag=tags.select {|tag| tag.include?('Process : Content Type')}
|
36
|
-
content_tag.size == 1 ? content_tag[0].split(':').last.strip :
|
35
|
+
content_tag = tags.select {|tag| tag.include?('Process : Content Type')}
|
36
|
+
content_tag.size == 1 ? content_tag[0].split(':').last.strip : ''
|
37
37
|
end
|
38
38
|
|
39
39
|
# Syntactic sugar for identifying applied DOR Concerns
|
40
40
|
# e.g., obj.is_identifiable? is the same as obj.is_a?(Dor::Identifiable)
|
41
|
-
def method_missing
|
41
|
+
def method_missing(sym, *args)
|
42
42
|
if sym.to_s =~ /^is_(.+)\?$/
|
43
43
|
begin
|
44
44
|
klass = Dor.const_get $1.capitalize.to_sym
|
@@ -53,11 +53,11 @@ module Dor
|
|
53
53
|
|
54
54
|
## Module-level variables, shared between ALL mixin includers (and ALL *their* includers/extenders)!
|
55
55
|
## used for caching found values
|
56
|
-
@@collection_hash={}
|
57
|
-
@@apo_hash={}
|
56
|
+
@@collection_hash = {}
|
57
|
+
@@apo_hash = {}
|
58
58
|
|
59
|
-
def to_solr(solr_doc=
|
60
|
-
|
59
|
+
def to_solr(solr_doc = {}, *args)
|
60
|
+
assert_content_model
|
61
61
|
super(solr_doc, *args)
|
62
62
|
|
63
63
|
solr_doc[Dor::INDEX_VERSION_FIELD] = Dor::VERSION
|
@@ -66,24 +66,24 @@ module Dor
|
|
66
66
|
add_solr_value(solr_doc, 'ds_specs', ds.datastream_spec_string, :string, [:symbol]) unless ds.new?
|
67
67
|
end
|
68
68
|
|
69
|
-
add_solr_value(solr_doc, 'title_sort',
|
69
|
+
add_solr_value(solr_doc, 'title_sort', label, :string, [:stored_sortable])
|
70
70
|
|
71
|
-
rels_doc = Nokogiri::XML(
|
71
|
+
rels_doc = Nokogiri::XML(datastreams['RELS-EXT'].content)
|
72
72
|
apos = rels_doc.search('//rdf:RDF/rdf:Description/hydra:isGovernedBy', 'hydra' => 'http://projecthydra.org/ns/relations#', 'fedora' => 'info:fedora/fedora-system:def/relations-external#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
|
73
73
|
collections = rels_doc.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection', 'fedora' => 'info:fedora/fedora-system:def/relations-external#', 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
|
74
|
-
solrize_related_obj_titles(solr_doc, apos, @@apo_hash,
|
75
|
-
solrize_related_obj_titles(solr_doc, collections, @@collection_hash,
|
74
|
+
solrize_related_obj_titles(solr_doc, apos, @@apo_hash, 'apo_title', 'nonhydrus_apo_title', 'hydrus_apo_title')
|
75
|
+
solrize_related_obj_titles(solr_doc, collections, @@collection_hash, 'collection_title', 'nonhydrus_collection_title', 'hydrus_collection_title')
|
76
76
|
|
77
|
-
solr_doc[
|
78
|
-
|
77
|
+
solr_doc['metadata_source_ssi'] = identity_metadata_source
|
78
|
+
solr_doc
|
79
79
|
end
|
80
80
|
|
81
81
|
# @return [String] calculated value for Solr index
|
82
82
|
def identity_metadata_source
|
83
|
-
if
|
84
|
-
|
83
|
+
if identityMetadata.otherId('catkey').first ||
|
84
|
+
identityMetadata.otherId('barcode').first
|
85
85
|
'Symphony'
|
86
|
-
elsif
|
86
|
+
elsif identityMetadata.otherId('mdtoolkit').first
|
87
87
|
'Metadata Toolkit'
|
88
88
|
else
|
89
89
|
'DOR'
|
@@ -91,26 +91,26 @@ module Dor
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def set_source_id(source_id)
|
94
|
-
|
94
|
+
identityMetadata.sourceId = source_id
|
95
95
|
end
|
96
96
|
|
97
|
-
def add_other_Id(type,val)
|
98
|
-
if
|
99
|
-
raise 'There is an existing entry for '+type+', consider using update_other_Id().'
|
97
|
+
def add_other_Id(type, val)
|
98
|
+
if identityMetadata.otherId(type).length > 0
|
99
|
+
raise 'There is an existing entry for ' + type + ', consider using update_other_Id().'
|
100
100
|
end
|
101
|
-
|
101
|
+
identityMetadata.add_otherId(type + ':' + val)
|
102
102
|
end
|
103
103
|
|
104
|
-
def update_other_Id(type, new_val, val=nil)
|
105
|
-
|
106
|
-
.select{ |node| val.nil? || node.content == val }
|
104
|
+
def update_other_Id(type, new_val, val = nil)
|
105
|
+
identityMetadata.ng_xml.search('//otherId[@name=\'' + type + '\']')
|
106
|
+
.select { |node| val.nil? || node.content == val }
|
107
107
|
.each { |node| node.content = new_val }
|
108
108
|
.any?
|
109
109
|
end
|
110
110
|
|
111
|
-
def remove_other_Id(type, val=nil)
|
112
|
-
|
113
|
-
.select{ |node| val.nil? || node.content == val }
|
111
|
+
def remove_other_Id(type, val = nil)
|
112
|
+
identityMetadata.ng_xml.search('//otherId[@name=\'' + type + '\']')
|
113
|
+
.select { |node| val.nil? || node.content == val }
|
114
114
|
.each(&:remove)
|
115
115
|
.any?
|
116
116
|
end
|
@@ -118,17 +118,17 @@ module Dor
|
|
118
118
|
# turns a tag string into an array with one element per tag part.
|
119
119
|
# split on ":", disregard leading and trailing whitespace on tokens.
|
120
120
|
def split_tag_to_arr(tag_str)
|
121
|
-
|
121
|
+
tag_str.split(':').map {|str| str.strip}
|
122
122
|
end
|
123
123
|
|
124
124
|
# turn a tag array back into a tag string with a standard format
|
125
125
|
def normalize_tag_arr(tag_arr)
|
126
|
-
|
126
|
+
tag_arr.join(' : ')
|
127
127
|
end
|
128
128
|
|
129
129
|
# take a tag string and return a normalized tag string
|
130
130
|
def normalize_tag(tag_str)
|
131
|
-
|
131
|
+
normalize_tag_arr(split_tag_to_arr(tag_str))
|
132
132
|
end
|
133
133
|
|
134
134
|
# take a proposed tag string and a list of the existing tags for the object being edited. if
|
@@ -145,7 +145,7 @@ module Dor
|
|
145
145
|
raise "An existing tag (#{dupe_existing_tag}) is the same, consider using update_tag?"
|
146
146
|
end
|
147
147
|
|
148
|
-
|
148
|
+
normalized_tag
|
149
149
|
end
|
150
150
|
|
151
151
|
# Ensure that an administrative tag meets the proper mininum format
|
@@ -161,21 +161,21 @@ module Dor
|
|
161
161
|
if tag_arr.detect {|str| str.empty?}
|
162
162
|
raise ArgumentError, "Invalid tag structure: tag '#{tag_str}' contains empty elements"
|
163
163
|
end
|
164
|
-
|
164
|
+
tag_arr
|
165
165
|
end
|
166
166
|
|
167
167
|
# Add an administrative tag to an item, you will need to seperately save the item to write it to fedora
|
168
168
|
# @param tag [string] The tag you wish to add
|
169
169
|
def add_tag(tag)
|
170
|
-
|
171
|
-
|
172
|
-
|
170
|
+
identity_metadata_ds = identityMetadata
|
171
|
+
normalized_tag = validate_and_normalize_tag(tag, identity_metadata_ds.tags)
|
172
|
+
identity_metadata_ds.add_value(:tag, normalized_tag)
|
173
173
|
end
|
174
174
|
|
175
175
|
def remove_tag(tag)
|
176
176
|
normtag = normalize_tag(tag)
|
177
|
-
|
178
|
-
.select{ |node| normalize_tag(node.content) == normtag }
|
177
|
+
identityMetadata.ng_xml.search('//tag')
|
178
|
+
.select { |node| normalize_tag(node.content) == normtag }
|
179
179
|
.each(&:remove)
|
180
180
|
.any?
|
181
181
|
end
|
@@ -183,7 +183,7 @@ module Dor
|
|
183
183
|
# Removes all displayTypes from an item in preparation of adding a new display type
|
184
184
|
# @return Boolean True if displayTypes were removed, False if no displayTypes were removed
|
185
185
|
def remove_displayTypes
|
186
|
-
nodes =
|
186
|
+
nodes = identityMetadata.ng_xml.search('//displayType')
|
187
187
|
# NOTE: .each after search is different than normal ruby enumerator:
|
188
188
|
# ~ ng_xml.search('//nonexistant_tag').each(&:foo) == 0
|
189
189
|
# ~ [].each(&:foo) == []
|
@@ -193,40 +193,51 @@ module Dor
|
|
193
193
|
|
194
194
|
def update_tag(old_tag, new_tag)
|
195
195
|
normtag = normalize_tag(old_tag)
|
196
|
-
|
197
|
-
.select{ |node| normalize_tag(node.content) == normtag }
|
196
|
+
identityMetadata.ng_xml.search('//tag')
|
197
|
+
.select { |node| normalize_tag(node.content) == normtag }
|
198
198
|
.each { |node| node.content = normalize_tag(new_tag) }
|
199
199
|
.any?
|
200
200
|
end
|
201
201
|
|
202
202
|
def get_related_obj_display_title(related_obj, default_title)
|
203
203
|
if related_obj
|
204
|
-
if related_obj.datastreams[
|
205
|
-
return related_obj.datastreams[
|
204
|
+
if related_obj.datastreams['DC'] && related_obj.datastreams['DC'].title
|
205
|
+
return related_obj.datastreams['DC'].title
|
206
206
|
else
|
207
207
|
return related_obj.label
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
211
|
-
|
211
|
+
default_title
|
212
212
|
end
|
213
213
|
|
214
214
|
private
|
215
|
-
|
215
|
+
|
216
|
+
def solrize_related_obj_titles(solr_doc, relationships, title_hash, union_field_name, nonhydrus_field_name, hydrus_field_name)
|
217
|
+
# TODO: if you wanted to get a little fancier, you could also solrize a 2 level hierarchy and display using hierarchial facets, like
|
218
|
+
# ["SOURCE", "SOURCE : TITLE"] (e.g. ["Hydrus", "Hydrus : Special Collections"], see (exploded) tags in IdentityMetadataDS#to_solr).
|
216
219
|
title_type = :symbol # we'll get an _ssim because of the type
|
217
220
|
title_attrs = [:stored_searchable] # we'll also get a _tesim from this attr
|
218
221
|
relationships.each do |rel_node|
|
219
222
|
rel_druid = rel_node['rdf:resource']
|
220
223
|
next unless rel_druid # TODO: warning here would also be useful
|
221
224
|
rel_druid = rel_druid.gsub('info:fedora/', '')
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
+
|
226
|
+
# populate cache if necessary
|
227
|
+
unless title_hash.key?(rel_druid)
|
225
228
|
related_obj = Dor.find(rel_druid)
|
226
229
|
related_obj_title = get_related_obj_display_title(related_obj, rel_druid)
|
227
|
-
|
228
|
-
title_hash[rel_druid] = related_obj_title
|
230
|
+
is_from_hydrus = (related_obj && related_obj.tags.include?('Project : Hydrus'))
|
231
|
+
title_hash[rel_druid] = {'related_obj_title' => related_obj_title, 'is_from_hydrus' => is_from_hydrus}
|
232
|
+
end
|
233
|
+
|
234
|
+
# cache should definitely be populated, so just use that to write solr field
|
235
|
+
if title_hash[rel_druid]['is_from_hydrus']
|
236
|
+
add_solr_value(solr_doc, hydrus_field_name, title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
|
237
|
+
else
|
238
|
+
add_solr_value(solr_doc, nonhydrus_field_name, title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
|
229
239
|
end
|
240
|
+
add_solr_value(solr_doc, union_field_name, title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
|
230
241
|
end
|
231
242
|
end
|
232
243
|
end
|
data/lib/dor/models/item.rb
CHANGED
@@ -6,18 +6,18 @@ module Dor
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
has_metadata :name =>
|
9
|
+
has_metadata :name => 'contentMetadata', :type => Dor::ContentMetadataDS, :label => 'Content Metadata', :control_group => 'M'
|
10
10
|
end
|
11
11
|
|
12
12
|
DIFF_FILENAME = 'cm_inv_diff'
|
13
|
-
DIFF_QUERY = DIFF_FILENAME.
|
13
|
+
DIFF_QUERY = DIFF_FILENAME.tr('_', '-')
|
14
14
|
|
15
15
|
# Deletes all cm_inv_diff files in the workspace for the Item
|
16
16
|
def clear_diff_cache
|
17
17
|
if Dor::Config.stacks.local_workspace_root.nil?
|
18
18
|
raise ArgumentError, 'Missing Dor::Config.stacks.local_workspace_root'
|
19
19
|
end
|
20
|
-
druid = DruidTools::Druid.new(
|
20
|
+
druid = DruidTools::Druid.new(pid, Dor::Config.stacks.local_workspace_root)
|
21
21
|
diff_pattern = File.join(druid.temp_dir, DIFF_FILENAME + '.*')
|
22
22
|
FileUtils.rm_f Dir.glob(diff_pattern)
|
23
23
|
end
|
@@ -31,7 +31,7 @@ module Dor
|
|
31
31
|
if Dor::Config.stacks.local_workspace_root.nil?
|
32
32
|
raise Dor::ParameterError, 'Missing Dor::Config.stacks.local_workspace_root'
|
33
33
|
end
|
34
|
-
unless %w
|
34
|
+
unless %w(all shelve preserve publish).include?(subset.to_s)
|
35
35
|
raise Dor::ParameterError, "Invalid subset value: #{subset}"
|
36
36
|
end
|
37
37
|
|
@@ -40,17 +40,16 @@ module Dor
|
|
40
40
|
raise Dor::ParameterError, 'Missing Dor::Config.sdr.rest_client'
|
41
41
|
end
|
42
42
|
sdr_client = Dor::Config.sdr.rest_client
|
43
|
-
current_content =
|
43
|
+
current_content = datastreams['contentMetadata'].content
|
44
44
|
if current_content.nil?
|
45
|
-
raise Dor::Exception,
|
45
|
+
raise Dor::Exception, 'Missing contentMetadata datastream'
|
46
46
|
end
|
47
47
|
query_string = { :subset => subset.to_s }
|
48
48
|
query_string[:version] = version.to_s unless version.nil?
|
49
49
|
query_string = URI.encode_www_form(query_string)
|
50
|
-
sdr_query = "objects/#{
|
50
|
+
sdr_query = "objects/#{pid}/#{DIFF_QUERY}?#{query_string}"
|
51
51
|
response = sdr_client[sdr_query].post(current_content, :content_type => 'application/xml')
|
52
52
|
response
|
53
53
|
end
|
54
|
-
|
55
54
|
end
|
56
55
|
end
|