dor-services 5.1.1 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/dor-services.rb +1 -2
- data/lib/dor/config.rb +5 -6
- data/lib/dor/datastreams/content_metadata_ds.rb +17 -20
- data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
- data/lib/dor/datastreams/desc_metadata_ds.rb +7 -7
- data/lib/dor/datastreams/embargo_metadata_ds.rb +2 -7
- data/lib/dor/datastreams/events_ds.rb +9 -9
- data/lib/dor/datastreams/identity_metadata_ds.rb +29 -34
- data/lib/dor/datastreams/rights_metadata_ds.rb +1 -1
- data/lib/dor/datastreams/role_metadata_ds.rb +0 -1
- data/lib/dor/datastreams/simple_dublin_core_ds.rb +12 -13
- data/lib/dor/datastreams/version_metadata_ds.rb +11 -15
- data/lib/dor/datastreams/workflow_definition_ds.rb +18 -22
- data/lib/dor/datastreams/workflow_ds.rb +24 -36
- data/lib/dor/migrations/identifiable/assert_adminPolicy.rb +1 -1
- data/lib/dor/migrations/identifiable/fix_model_assertions.rb +1 -1
- data/lib/dor/migrations/identifiable/record_remediation.rb +2 -2
- data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +1 -1
- data/lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb +1 -1
- data/lib/dor/migrations/processable/unify_workflows.rb +4 -4
- data/lib/dor/migrations/versionable/add_missing_version_md.rb +2 -2
- data/lib/dor/models/assembleable.rb +2 -2
- data/lib/dor/models/collection.rb +1 -0
- data/lib/dor/models/contentable.rb +3 -3
- data/lib/dor/models/describable.rb +16 -13
- data/lib/dor/models/editable.rb +3 -3
- data/lib/dor/models/embargoable.rb +2 -2
- data/lib/dor/models/eventable.rb +2 -2
- data/lib/dor/models/geoable.rb +14 -18
- data/lib/dor/models/governable.rb +1 -1
- data/lib/dor/models/identifiable.rb +36 -57
- data/lib/dor/models/itemizable.rb +6 -6
- data/lib/dor/models/presentable.rb +12 -12
- data/lib/dor/models/preservable.rb +2 -5
- data/lib/dor/models/processable.rb +19 -25
- data/lib/dor/models/publishable.rb +2 -2
- data/lib/dor/models/releaseable.rb +165 -212
- data/lib/dor/models/shelvable.rb +10 -14
- data/lib/dor/models/upgradable.rb +11 -11
- data/lib/dor/models/versionable.rb +16 -21
- data/lib/dor/models/workflow_object.rb +3 -3
- data/lib/dor/services/cleanup_reset_service.rb +32 -27
- data/lib/dor/services/digital_stacks_service.rb +3 -3
- data/lib/dor/services/merge_service.rb +4 -8
- data/lib/dor/services/metadata_handlers/catalog_handler.rb +1 -1
- data/lib/dor/services/metadata_handlers/mdtoolkit_handler.rb +4 -6
- data/lib/dor/services/metadata_service.rb +20 -22
- data/lib/dor/services/registration_service.rb +6 -8
- data/lib/dor/services/reset_workspace_service.rb +14 -16
- data/lib/dor/services/sdr_ingest_service.rb +2 -6
- data/lib/dor/services/search_service.rb +3 -3
- data/lib/dor/services/suri_service.rb +2 -3
- data/lib/dor/services/technical_metadata_service.rb +2 -3
- data/lib/dor/utils/ng_tidy.rb +6 -6
- data/lib/dor/utils/predicate_patch.rb +1 -1
- data/lib/dor/utils/solr_doc_helper.rb +2 -2
- data/lib/dor/version.rb +1 -1
- data/lib/dor/workflow/document.rb +27 -33
- data/lib/dor/workflow/graph.rb +34 -37
- data/lib/dor/workflow/process.rb +8 -8
- data/lib/tasks/rdoc.rake +5 -5
- metadata +4 -11
- data/bin/dor-indexer +0 -108
- data/bin/dor-indexerd +0 -73
- data/config/certs/robots-dor-dev.crt +0 -29
- data/config/certs/robots-dor-dev.key +0 -27
- data/config/dev_console_env.rb +0 -78
@@ -15,9 +15,7 @@ module Dor
|
|
15
15
|
|
16
16
|
# @param [String] raw_tag the value of the tag attribute from a Version node
|
17
17
|
def self.parse(raw_tag)
|
18
|
-
unless
|
19
|
-
return nil
|
20
|
-
end
|
18
|
+
return nil unless raw_tag =~ /(\d+)\.(\d+)\.(\d+)/
|
21
19
|
VersionTag.new $1, $2, $3
|
22
20
|
end
|
23
21
|
|
@@ -45,7 +43,7 @@ module Dor
|
|
45
43
|
end
|
46
44
|
|
47
45
|
def to_s
|
48
|
-
"#{@major
|
46
|
+
"#{@major}.#{@minor}.#{admin}"
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
@@ -81,7 +79,7 @@ module Dor
|
|
81
79
|
# @param [Symbol] significance optional which part of the version tag to increment
|
82
80
|
# :major, :minor, :admin (see VersionTag#increment)
|
83
81
|
def increment_version(description = nil, significance = nil)
|
84
|
-
if( find_by_terms(:version).size == 0)
|
82
|
+
if ( find_by_terms(:version).size == 0)
|
85
83
|
v = ng_xml.create_element "version",
|
86
84
|
:versionId => '1', :tag => '1.0.0'
|
87
85
|
d = ng_xml.create_element "description", "Initial Version"
|
@@ -94,13 +92,13 @@ module Dor
|
|
94
92
|
current_tag = VersionTag.parse(current[:tag])
|
95
93
|
|
96
94
|
v = ng_xml.create_element "version", :versionId => (current_id + 1).to_s
|
97
|
-
if
|
95
|
+
if significance && current_tag
|
98
96
|
v[:tag] = current_tag.increment(significance).to_s
|
99
97
|
end
|
100
98
|
ng_xml.root['objectId'] = pid
|
101
99
|
ng_xml.root.add_child(v)
|
102
100
|
|
103
|
-
if
|
101
|
+
if description
|
104
102
|
d = ng_xml.create_element "description", description
|
105
103
|
v.add_child d
|
106
104
|
end
|
@@ -126,18 +124,18 @@ module Dor
|
|
126
124
|
return if find_by_terms(:version).size == 1
|
127
125
|
return if opts.empty?
|
128
126
|
current = current_version_node
|
129
|
-
if
|
127
|
+
if opts.include? :description
|
130
128
|
d = current.at_xpath('description')
|
131
|
-
if
|
129
|
+
if d
|
132
130
|
d.content = opts[:description]
|
133
131
|
else
|
134
132
|
d_node = ng_xml.create_element "description", opts[:description]
|
135
133
|
current.add_child d_node
|
136
134
|
end
|
137
135
|
end
|
138
|
-
if
|
136
|
+
if opts.include? :significance
|
139
137
|
# tricky because if there is no tag, we have to find the newest
|
140
|
-
if
|
138
|
+
if current[:tag].nil?
|
141
139
|
current[:tag] = newest_tag.increment(opts[:significance]).to_s
|
142
140
|
else
|
143
141
|
# get rid of the current tag
|
@@ -154,7 +152,7 @@ module Dor
|
|
154
152
|
# @return [Boolean] returns true if the current version has a tag and a description, false otherwise
|
155
153
|
def current_version_closeable?
|
156
154
|
current = current_version_node
|
157
|
-
if
|
155
|
+
if current[:tag] && current.at_xpath('description')
|
158
156
|
return true
|
159
157
|
else
|
160
158
|
return false
|
@@ -188,9 +186,7 @@ module Dor
|
|
188
186
|
# @return [String] The description for the current version
|
189
187
|
def current_description
|
190
188
|
desc_node=current_version_node.at_xpath('description')
|
191
|
-
if desc_node
|
192
|
-
return desc_node.content
|
193
|
-
end
|
189
|
+
return desc_node.content if desc_node
|
194
190
|
''
|
195
191
|
end
|
196
192
|
|
@@ -1,17 +1,15 @@
|
|
1
1
|
module Dor
|
2
|
-
class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
2
|
+
class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
3
3
|
include SolrDocHelper
|
4
|
-
|
4
|
+
|
5
5
|
set_terminology do |t|
|
6
6
|
t.root(:path => "workflow-def", :index_as => [:not_searchable])
|
7
7
|
t.process(:index_as => [:not_searchable])
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
define_template :process do |builder,workflow,attrs|
|
11
11
|
prereqs = attrs.delete('prerequisite')
|
12
|
-
if prereqs.is_a?(String)
|
13
|
-
prereqs = prereqs.split(/\s*,\s*/)
|
14
|
-
end
|
12
|
+
prereqs = prereqs.split(/\s*,\s*/) if prereqs.is_a?(String)
|
15
13
|
attrs.keys.each { |k| attrs[k.to_s.dasherize.to_sym] = attrs.delete(k) }
|
16
14
|
builder.process(attrs) do |node|
|
17
15
|
Array(prereqs).each do |prereq|
|
@@ -20,7 +18,7 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
20
18
|
prereq_name = repo
|
21
19
|
repo = nil
|
22
20
|
end
|
23
|
-
if
|
21
|
+
if repo == workflow.repo && wf = workflow.name
|
24
22
|
repo = nil
|
25
23
|
wf = nil
|
26
24
|
end
|
@@ -33,15 +31,15 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
33
31
|
def self.xml_template
|
34
32
|
Nokogiri::XML('<workflow-def/>')
|
35
33
|
end
|
36
|
-
|
34
|
+
|
37
35
|
def add_process(attributes)
|
38
36
|
add_child_node(ng_xml.at_xpath('/workflow-def'), :process, self, attributes)
|
39
37
|
end
|
40
|
-
|
38
|
+
|
41
39
|
def graph(parent = nil)
|
42
40
|
Workflow::Graph.from_processes(self.repo, self.name, self.processes, parent)
|
43
41
|
end
|
44
|
-
|
42
|
+
|
45
43
|
def processes
|
46
44
|
ng_xml.xpath('/workflow-def/process').collect do |node|
|
47
45
|
Workflow::Process.new(self.repo, self.name, node)
|
@@ -51,7 +49,7 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
51
49
|
def name
|
52
50
|
ng_xml.at_xpath('/workflow-def/@id').to_s
|
53
51
|
end
|
54
|
-
|
52
|
+
|
55
53
|
def repo
|
56
54
|
ng_xml.at_xpath('/workflow-def/@repository').to_s
|
57
55
|
end
|
@@ -63,17 +61,15 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
63
61
|
processes.each { |process| result[process.name] = process.to_hash }
|
64
62
|
result
|
65
63
|
end
|
66
|
-
|
64
|
+
|
67
65
|
def configuration=(hash)
|
68
66
|
self.ng_xml = Nokogiri::XML(%{<workflow-def id="#{hash['name']}" repository="#{hash['repository']}"/>})
|
69
67
|
i = 0
|
70
|
-
hash.each_pair do |k,v|
|
71
|
-
if v.is_a?(Hash)
|
72
|
-
add_process(v.merge({:name => k, :sequence => i+=1}))
|
73
|
-
end
|
68
|
+
hash.each_pair do |k,v|
|
69
|
+
add_process(v.merge({:name => k, :sequence => i+=1})) if v.is_a?(Hash)
|
74
70
|
end
|
75
71
|
end
|
76
|
-
|
72
|
+
|
77
73
|
# Creates the xml used by Dor::WorkflowService.create_workflow
|
78
74
|
# @return [String] An object's initial workflow as defined by the <workflow-def> in content
|
79
75
|
def initial_workflow
|
@@ -83,7 +79,7 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
83
79
|
processes.each { |proc|
|
84
80
|
doc.create_element 'process' do |node|
|
85
81
|
node['name'] = proc.name
|
86
|
-
if
|
82
|
+
if proc.status
|
87
83
|
node['status'] = proc.status
|
88
84
|
node['attempts'] = '1'
|
89
85
|
else
|
@@ -95,19 +91,19 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
95
91
|
}
|
96
92
|
Nokogiri::XML(doc.to_xml) { |x| x.noblanks }.to_xml { |config| config.no_declaration }
|
97
93
|
end
|
98
|
-
|
94
|
+
|
99
95
|
def to_solr(solr_doc=Hash.new,*args)
|
100
96
|
super(solr_doc,*args)
|
101
|
-
add_solr_value(solr_doc, "workflow_name", self.name, :symbol, [:
|
97
|
+
add_solr_value(solr_doc, "workflow_name", self.name, :symbol, [:symbol])
|
102
98
|
processes.each do |p|
|
103
99
|
add_solr_value(solr_doc, "process", "#{p.name}|#{p.label}", :symbol, [:displayable])
|
104
100
|
end
|
105
101
|
solr_doc
|
106
102
|
end
|
107
|
-
|
103
|
+
|
108
104
|
def to_yaml
|
109
105
|
YAML.dump(self.configuration)
|
110
106
|
end
|
111
|
-
|
107
|
+
|
112
108
|
end
|
113
109
|
end
|
@@ -8,7 +8,7 @@ class WorkflowDs < ActiveFedora::OmDatastream
|
|
8
8
|
t.process {
|
9
9
|
t.name_(:path=>{:attribute=>"name"}, :index_as => [:displayable, :not_searchable])
|
10
10
|
t.status(:path=>{:attribute=>"status"}, :index_as => [:displayable, :not_searchable])
|
11
|
-
t.timestamp(:path=>{:attribute=>"datetime"}, :index_as => [:displayable, :not_searchable])#, :data_type => :date)
|
11
|
+
t.timestamp(:path=>{:attribute=>"datetime"}, :index_as => [:displayable, :not_searchable]) #, :data_type => :date)
|
12
12
|
t.elapsed(:path=>{:attribute=>"elapsed"}, :index_as => [:displayable, :not_searchable])
|
13
13
|
t.lifecycle(:path=>{:attribute=>"lifecycle"}, :index_as => [:displayable, :not_searchable])
|
14
14
|
t.attempts(:path=>{:attribute=>"attempts"}, :index_as => [:displayable, :not_searchable])
|
@@ -16,24 +16,18 @@ class WorkflowDs < ActiveFedora::OmDatastream
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
def get_workflow
|
20
|
-
xml=Dor::WorkflowService.get_workflow_xml(repo, self.pid, wf)
|
21
|
-
xml=Nokogiri::XML(xml)
|
22
|
-
if xml.xpath('workflow').length == 0
|
23
|
-
|
24
|
-
else
|
25
|
-
Workflow::Document.new(xml.to_s)
|
26
|
-
end
|
19
|
+
def get_workflow(wf, repo = 'dor')
|
20
|
+
xml = Dor::WorkflowService.get_workflow_xml(repo, self.pid, wf)
|
21
|
+
xml = Nokogiri::XML(xml)
|
22
|
+
return nil if xml.xpath('workflow').length == 0
|
23
|
+
Workflow::Document.new(xml.to_s)
|
27
24
|
end
|
28
25
|
|
29
26
|
def [](wf)
|
30
|
-
xml=Dor::WorkflowService.get_workflow_xml('dor', self.pid, wf)
|
31
|
-
xml=Nokogiri::XML(xml)
|
32
|
-
if xml.xpath('workflow').length == 0
|
33
|
-
|
34
|
-
else
|
35
|
-
Workflow::Document.new(xml.to_s)
|
36
|
-
end
|
27
|
+
xml = Dor::WorkflowService.get_workflow_xml('dor', self.pid, wf)
|
28
|
+
xml = Nokogiri::XML(xml)
|
29
|
+
return nil if xml.xpath('workflow').length == 0
|
30
|
+
Workflow::Document.new(xml.to_s)
|
37
31
|
end
|
38
32
|
|
39
33
|
def ensure_xml_loaded
|
@@ -46,33 +40,27 @@ class WorkflowDs < ActiveFedora::OmDatastream
|
|
46
40
|
end
|
47
41
|
|
48
42
|
def content
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
xml.root.add_child(ds_content.root)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
@content ||= xml.to_xml
|
43
|
+
@content ||= Dor::WorkflowService.get_workflow_xml 'dor', self.pid, nil
|
44
|
+
rescue RestClient::ResourceNotFound
|
45
|
+
xml = Nokogiri::XML(%{<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<workflows objectId="#{self.pid}"/>})
|
46
|
+
self.digital_object.datastreams.keys.each do |dsid|
|
47
|
+
next unless dsid =~ /WF$/
|
48
|
+
ds_content = Nokogiri::XML(Dor::WorkflowService.get_workflow_xml 'dor', self.pid, dsid)
|
49
|
+
xml.root.add_child(ds_content.root)
|
60
50
|
end
|
51
|
+
@content ||= xml.to_xml
|
61
52
|
end
|
62
53
|
|
63
54
|
def workflows
|
64
55
|
@workflows ||= self.workflow.nodeset.collect { |wf_node| Workflow::Document.new wf_node.to_xml }
|
65
56
|
end
|
66
57
|
|
67
|
-
def graph(dir=nil)
|
58
|
+
def graph(dir = nil)
|
68
59
|
result = GraphViz.digraph(self.pid)
|
69
60
|
sg = result.add_graph('rank') { |g| g[:rank => 'same'] }
|
70
|
-
workflows.each do |wf|
|
71
|
-
|
72
|
-
unless
|
73
|
-
g = wf.graph(result)
|
74
|
-
sg.add_node(g.root.id) unless g.nil?
|
75
|
-
end
|
61
|
+
workflows.reject(&:nil?).each do |wf|
|
62
|
+
g = wf.graph(result)
|
63
|
+
sg.add_node(g.root.id) unless g.nil?
|
76
64
|
end
|
77
65
|
result['rankdir'] = dir || 'TB'
|
78
66
|
result
|
@@ -82,8 +70,8 @@ class WorkflowDs < ActiveFedora::OmDatastream
|
|
82
70
|
#
|
83
71
|
# @return [Integer] value of the priority. Defaults to 0 if none of the workflows are expedited
|
84
72
|
def current_priority
|
85
|
-
cp = workflows.detect {|wf| wf.expedited? }
|
86
|
-
return 0 if
|
73
|
+
cp = workflows.detect { |wf| wf.expedited? }
|
74
|
+
return 0 if cp.nil?
|
87
75
|
cp.priority.to_i
|
88
76
|
end
|
89
77
|
|
@@ -4,7 +4,7 @@ Dor::Identifiable.on_upgrade '3.6.1', 'Assert correct models' do |obj|
|
|
4
4
|
obj.remove_relationship :has_model, 'info:fedora/hydra:commonMetadata'
|
5
5
|
applied = true
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
unless obj.relationships.predicates.any? { |p| p.to_s == 'info:fedora/fedora-system:def/model#hasModel' }
|
9
9
|
obj.assert_content_model
|
10
10
|
applied = true
|
@@ -5,11 +5,11 @@ Dor::Processable.on_upgrade '3.5.0', 'Replace individual *WF datastreams with un
|
|
5
5
|
obj.workflows.content
|
6
6
|
run = true
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# Remove individual *WF datastreams
|
10
|
-
obj.datastreams.each_pair do |dsid,ds|
|
11
|
-
if ds.controlGroup == 'E'
|
12
|
-
ds.delete
|
10
|
+
obj.datastreams.each_pair do |dsid,ds|
|
11
|
+
if ds.controlGroup == 'E' && dsid =~ /WF$/
|
12
|
+
ds.delete
|
13
13
|
run = true
|
14
14
|
end
|
15
15
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Dor::Versionable.on_upgrade '3.12.2', 'Add missing versionMetadata' do |obj|
|
2
2
|
run = false
|
3
3
|
vm = obj.datastreams['versionMetadata']
|
4
|
-
if
|
4
|
+
if vm.content.nil? || vm.content.strip == '' || vm.new? # We do not have a versionMetadata ds
|
5
5
|
vm.content = vm.ng_xml.to_s
|
6
6
|
run = true
|
7
7
|
end
|
8
8
|
run
|
9
|
-
end
|
9
|
+
end
|
@@ -153,7 +153,7 @@ module Dor
|
|
153
153
|
# determine whether the file in question is present in the object's workspace.
|
154
154
|
def is_file_in_workspace? filename
|
155
155
|
druid_obj = DruidTools::Druid.new(self.pid, Dor::Config.stacks.local_workspace_root)
|
156
|
-
return druid_obj.find_content(filename)
|
156
|
+
return !druid_obj.find_content(filename).nil?
|
157
157
|
end
|
158
158
|
|
159
159
|
# Appends contentMetadata file resources from the source objects to this object
|
@@ -178,7 +178,7 @@ module Dor
|
|
178
178
|
resource_copy.xpath('file').each do |secondary_file|
|
179
179
|
secondary_file['id'] = new_secondary_file_name(secondary_file['id'], max_sequence)
|
180
180
|
|
181
|
-
if primary_cm.at_xpath("//file[@id = '#{secondary_file[
|
181
|
+
if primary_cm.at_xpath("//file[@id = '#{secondary_file['id']}']")
|
182
182
|
raise Dor::Exception.new "File '#{secondary_file['id']}' from secondary object #{src_pid} already exist in primary object: #{self.pid}"
|
183
183
|
end
|
184
184
|
end
|
@@ -230,4 +230,4 @@ module Dor
|
|
230
230
|
add_tag "Decommissioned : #{tag}"
|
231
231
|
end
|
232
232
|
end
|
233
|
-
end
|
233
|
+
end
|
@@ -32,12 +32,11 @@ module Dor
|
|
32
32
|
|
33
33
|
def build_descMetadata_datastream(ds)
|
34
34
|
content = fetch_descMetadata_datastream
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
35
|
+
return nil if content.nil?
|
36
|
+
ds.dsLabel = 'Descriptive Metadata'
|
37
|
+
ds.ng_xml = Nokogiri::XML(content)
|
38
|
+
ds.ng_xml.normalize_text!
|
39
|
+
ds.content = ds.ng_xml.to_xml
|
41
40
|
end
|
42
41
|
|
43
42
|
# Generates Dublin Core from the MODS in the descMetadata datastream using the LoC mods2dc stylesheet
|
@@ -54,7 +53,7 @@ module Dor
|
|
54
53
|
dc_doc = xslt.transform(desc_md)
|
55
54
|
# Remove empty nodes
|
56
55
|
dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]').remove
|
57
|
-
if
|
56
|
+
if dc_doc.root.nil? || dc_doc.root.children.size == 0
|
58
57
|
raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml:\n#{dc_doc.to_xml}"
|
59
58
|
end
|
60
59
|
dc_doc
|
@@ -158,11 +157,17 @@ module Dor
|
|
158
157
|
def to_solr(solr_doc=Hash.new, *args)
|
159
158
|
super solr_doc, *args
|
160
159
|
mods_sources = {
|
160
|
+
'sw_language_ssim' => :sw_language_facet,
|
161
161
|
'sw_language_tesim' => :sw_language_facet,
|
162
|
+
'sw_genre_ssim' => :sw_genre,
|
162
163
|
'sw_genre_tesim' => :sw_genre,
|
164
|
+
'sw_format_ssim' => :format_main, # basically sw_typeOfResource_ssim
|
163
165
|
'sw_format_tesim' => :format_main, # basically sw_typeOfResource_tesim
|
166
|
+
'sw_subject_temporal_ssim' => :era_facet,
|
164
167
|
'sw_subject_temporal_tesim' => :era_facet,
|
168
|
+
'sw_subject_geographic_ssim' => :geographic_facet,
|
165
169
|
'sw_subject_geographic_tesim' => :geographic_facet,
|
170
|
+
'mods_typeOfResource_ssim' => [:term_values, :typeOfResource],
|
166
171
|
'mods_typeOfResource_tesim' => [:term_values, :typeOfResource]
|
167
172
|
}
|
168
173
|
keys = mods_sources.keys.concat(%w[ metadata_format_ssim ])
|
@@ -194,7 +199,7 @@ module Dor
|
|
194
199
|
mods = self.stanford_mods
|
195
200
|
mods_sources.each_pair do |solr_key, meth|
|
196
201
|
vals = meth.is_a?(Array) ? mods.send(meth.shift, *meth) : mods.send(meth)
|
197
|
-
solr_doc[solr_key].push *vals unless
|
202
|
+
solr_doc[solr_key].push *vals unless vals.nil? || vals.empty?
|
198
203
|
# asterisk to avoid multi-dimensional array: push values, not the array
|
199
204
|
end
|
200
205
|
solr_doc['sw_pub_date_sort_ssi' ] = mods.pub_date_sort # e.g. '0800'
|
@@ -203,14 +208,12 @@ module Dor
|
|
203
208
|
# some fields get explicit "(none)" placeholder values, mostly for faceting
|
204
209
|
%w[sw_language_tesim sw_genre_tesim sw_format_tesim].each { |key| solr_doc[key] = ['(none)'] if solr_doc[key].empty? }
|
205
210
|
# otherwise remove empties
|
206
|
-
keys.each{ |key| solr_doc.delete(key) if
|
211
|
+
keys.each{ |key| solr_doc.delete(key) if solr_doc[key].nil? || solr_doc[key].empty?}
|
207
212
|
solr_doc
|
208
213
|
end
|
209
214
|
|
210
215
|
def update_title(new_title)
|
211
|
-
|
212
|
-
raise 'Descriptive metadata has no title to update!'
|
213
|
-
end
|
216
|
+
raise 'Descriptive metadata has no title to update!' unless update_simple_field('mods:mods/mods:titleInfo/mods:title', new_title)
|
214
217
|
end
|
215
218
|
def add_identifier(type, value)
|
216
219
|
ds_xml=self.descMetadata.ng_xml
|
@@ -252,7 +255,7 @@ module Dor
|
|
252
255
|
xml=obj.descMetadata.ng_xml
|
253
256
|
title=''
|
254
257
|
title_node = xml.at_xpath('//mods:mods/mods:titleInfo/mods:title','mods' => 'http://www.loc.gov/mods/v3')
|
255
|
-
if
|
258
|
+
if title_node
|
256
259
|
title = title_node.content
|
257
260
|
subtitle=xml.at_xpath('//mods:mods/mods:titleInfo/mods:subTitle','mods' => 'http://www.loc.gov/mods/v3')
|
258
261
|
title += " (#{subtitle.content})" if subtitle
|