dor-services 5.2.0 → 5.3.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 +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
@@ -6,45 +6,128 @@ module Dor
|
|
6
6
|
t.copyright :path => 'copyright/human', :index_as => [:symbol]
|
7
7
|
t.use_statement :path => '/use/human[@type=\'useAndReproduction\']', :index_as => [:symbol]
|
8
8
|
|
9
|
-
t.use do
|
10
|
-
|
11
|
-
|
12
|
-
end
|
9
|
+
# t.use do
|
10
|
+
# t.machine
|
11
|
+
# t.human
|
12
|
+
# end
|
13
13
|
|
14
|
-
t.creative_commons :path => '/use/machine', :type => 'creativeCommons'
|
14
|
+
t.creative_commons :path => '/use/machine[@type=\'creativeCommons\']', :type => 'creativeCommons' do
|
15
|
+
t.uri :path => '@uri'
|
16
|
+
end
|
15
17
|
t.creative_commons_human :path => '/use/human[@type=\'creativeCommons\']'
|
18
|
+
t.open_data_commons :path => '/use/machine[@type=\'openDataCommons\']', :type => 'openDataCommons' do
|
19
|
+
t.uri :path => '@uri'
|
20
|
+
end
|
21
|
+
t.open_data_commons_human :path => '/use/human[@type=\'openDataCommons\']'
|
16
22
|
end
|
17
23
|
|
18
24
|
define_template :creative_commons do |xml|
|
19
25
|
xml.use {
|
20
|
-
xml.human(:type =>
|
21
|
-
xml.machine(:type =>
|
26
|
+
xml.human(:type => 'creativeCommons')
|
27
|
+
xml.machine(:type => 'creativeCommons', :uri => '')
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
define_template :open_data_commons do |xml|
|
32
|
+
xml.use {
|
33
|
+
xml.human(:type => 'openDataCommons')
|
34
|
+
xml.machine(:type => 'openDataCommons', :uri => '')
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
define_template :copyright do |xml|
|
39
|
+
xml.copyright {
|
40
|
+
xml.human
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
define_template :use_statement do |xml|
|
45
|
+
xml.use {
|
46
|
+
xml.human(type: 'useAndReproduction')
|
22
47
|
}
|
23
48
|
end
|
24
49
|
|
25
50
|
def self.xml_template
|
26
51
|
Nokogiri::XML::Builder.new do |xml|
|
27
|
-
xml.rightsMetadata{
|
28
|
-
xml.access(:type => 'discover'){
|
29
|
-
xml.machine{
|
52
|
+
xml.rightsMetadata {
|
53
|
+
xml.access(:type => 'discover') {
|
54
|
+
xml.machine {
|
30
55
|
xml.world
|
31
56
|
}
|
32
57
|
}
|
33
|
-
xml.access(:type => 'read'){
|
34
|
-
xml.machine{
|
58
|
+
xml.access(:type => 'read') {
|
59
|
+
xml.machine {
|
35
60
|
xml.world
|
36
61
|
}
|
37
62
|
}
|
38
|
-
xml.use{
|
63
|
+
xml.use {
|
39
64
|
xml.human(:type => 'useAndReproduction')
|
40
|
-
xml.human(:type =>
|
41
|
-
xml.machine(:type =>
|
65
|
+
xml.human(:type => 'creativeCommons')
|
66
|
+
xml.machine(:type => 'creativeCommons', :uri => '')
|
67
|
+
xml.human(:type => 'openDataCommons')
|
68
|
+
xml.machine(:type => 'openDataCommons', :uri => '')
|
42
69
|
}
|
43
|
-
xml.copyright{
|
70
|
+
xml.copyright {
|
44
71
|
xml.human
|
45
72
|
}
|
46
73
|
}
|
47
74
|
end.doc
|
48
75
|
end
|
76
|
+
|
77
|
+
# Ensures that the template is present for the given term
|
78
|
+
def initialize_term!(term)
|
79
|
+
return unless find_by_terms(term).length < 1
|
80
|
+
ng_xml_will_change!
|
81
|
+
add_child_node(ng_xml.root, term)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Assigns the defaultObjectRights object's term with the given value. Supports setting value to nil
|
85
|
+
def update_term!(term, val)
|
86
|
+
ng_xml_will_change!
|
87
|
+
if val.blank?
|
88
|
+
update_values({ [ term ] => nil })
|
89
|
+
else
|
90
|
+
initialize_term! term
|
91
|
+
update_values({ [ term ] => val })
|
92
|
+
end
|
93
|
+
normalize!
|
94
|
+
end
|
95
|
+
|
96
|
+
def content
|
97
|
+
ng_xml.human
|
98
|
+
end
|
99
|
+
|
100
|
+
# Purge the XML of any empty or duplicate elements -- keeps <rightsMetadata> clean
|
101
|
+
def normalize!
|
102
|
+
ng_xml_will_change!
|
103
|
+
doc = ng_xml
|
104
|
+
if doc.xpath('/rightsMetadata/use').length > 1
|
105
|
+
# <use> node needs consolidation
|
106
|
+
nodeset = doc.xpath('/rightsMetadata/use')
|
107
|
+
nodeset[1..-1].each do |node|
|
108
|
+
node.children.each do |child|
|
109
|
+
nodeset[0] << child # copy over to first <use> element
|
110
|
+
end
|
111
|
+
node.remove
|
112
|
+
end
|
113
|
+
fail unless doc.xpath('/rightsMetadata/use').length == 1
|
114
|
+
end
|
115
|
+
|
116
|
+
# Call out to the general purpose XML normalization service
|
117
|
+
::Normalizer.new.tap do |norm|
|
118
|
+
norm.remove_empty_attributes(doc.root)
|
119
|
+
# cleanup ordering is important here
|
120
|
+
doc.xpath('//machine/text()').each { |node| node.content = node.content.strip }
|
121
|
+
doc.xpath('//human')
|
122
|
+
.tap { |nodeset| norm.clean_linefeeds(nodeset) }
|
123
|
+
.each do |node|
|
124
|
+
norm.trim_text(node)
|
125
|
+
norm.remove_empty_nodes(node)
|
126
|
+
end
|
127
|
+
doc.xpath('/rightsMetadata/copyright').each { |node| norm.remove_empty_nodes(node) }
|
128
|
+
doc.xpath('/rightsMetadata/use').each { |node| norm.remove_empty_nodes(node) }
|
129
|
+
end
|
130
|
+
self.content = doc.human
|
131
|
+
end
|
49
132
|
end
|
50
133
|
end
|
@@ -1,42 +1,45 @@
|
|
1
1
|
module Dor
|
2
|
-
class DescMetadataDS < ActiveFedora::OmDatastream
|
2
|
+
class DescMetadataDS < ActiveFedora::OmDatastream
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
MODS_NS = 'http://www.loc.gov/mods/v3'
|
5
|
+
set_terminology do |t|
|
6
|
+
t.root :path => 'mods', :xmlns => MODS_NS, :index_as => [:not_searchable]
|
7
|
+
t.originInfo :index_as => [:not_searchable] do
|
8
|
+
t.publisher :index_as => [:stored_searchable]
|
9
|
+
t.date_created :path => 'dateCreated', :index_as => [:stored_searchable]
|
10
|
+
t.place :index_as => [:not_searchable] do
|
11
|
+
t.placeTerm :attributes => {:type => 'text'}, :index_as => [:stored_searchable]
|
12
|
+
end
|
12
13
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
t.subject(:index_as => [:not_searchable]) do
|
15
|
+
t.geographic :index_as => [:symbol, :stored_searchable]
|
16
|
+
t.topic :index_as => [:symbol, :stored_searchable]
|
17
|
+
t.temporal :index_as => [:stored_searchable]
|
18
|
+
end
|
19
|
+
t.title_info(:path => 'titleInfo') {
|
20
|
+
t.main_title(:index_as => [:symbol], :path => 'title', :label => 'title') {
|
21
|
+
t.main_title_lang(:path => {:attribute => 'xml:lang'})
|
22
|
+
}
|
22
23
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
t.language {
|
25
|
+
t.languageTerm :attributes => {:type => 'code', :authority => 'iso639-2b'}, :index_as => [:not_searchable]
|
26
|
+
}
|
27
|
+
t.coordinates :index_as => [:symbol]
|
28
|
+
t.extent :index_as => [:symbol]
|
29
|
+
t.scale :index_as => [:symbol]
|
30
|
+
t.topic :index_as => [:symbol, :stored_searchable]
|
31
|
+
t.abstract :index_as => [:stored_searchable]
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def self.xml_template
|
35
|
+
Nokogiri::XML::Builder.new do |xml|
|
36
|
+
xml.mods( 'xmlns' => MODS_NS, 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', :version => '3.3', 'xsi:schemaLocation' => 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd') {
|
37
|
+
xml.titleInfo {
|
38
|
+
xml.title
|
39
|
+
}
|
36
40
|
}
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
41
|
+
end.doc
|
42
|
+
end
|
40
43
|
|
41
|
-
end
|
44
|
+
end
|
42
45
|
end
|
@@ -4,13 +4,13 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
4
4
|
before_create :ensure_non_versionable
|
5
5
|
|
6
6
|
set_terminology do |t|
|
7
|
-
t.root(:path =>
|
7
|
+
t.root(:path => 'embargoMetadata')
|
8
8
|
t.status
|
9
9
|
t.embargo_status(:path => 'status', :index_as => [:symbol])
|
10
|
-
t.release_date(:path =>
|
11
|
-
t.release_access(:path =>
|
12
|
-
t.twenty_pct_status(
|
13
|
-
t.twenty_pct_release_date(:path =>
|
10
|
+
t.release_date(:path => 'releaseDate', :index_as => [:dateable])
|
11
|
+
t.release_access(:path => 'releaseAccess')
|
12
|
+
t.twenty_pct_status(:path => 'twentyPctVisibilityStatus', :index_as => [:symbol])
|
13
|
+
t.twenty_pct_release_date(:path => 'twentyPctVisibilityReleaseDate')
|
14
14
|
end
|
15
15
|
|
16
16
|
# Default EmbargoMetadataDS xml
|
@@ -24,21 +24,21 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
24
24
|
xml.twentyPctVisibilityReleaseDate
|
25
25
|
}
|
26
26
|
end
|
27
|
-
|
27
|
+
builder.doc
|
28
28
|
end
|
29
29
|
|
30
|
-
def to_solr
|
30
|
+
def to_solr(solr_doc = {}, *args)
|
31
31
|
super
|
32
32
|
#::Solrizer.insert_field(solr_doc, field_name, value, *index_types)
|
33
|
-
rd1 =
|
34
|
-
rd20 =
|
33
|
+
rd1 = release_date
|
34
|
+
rd20 = twenty_pct_release_date
|
35
35
|
::Solrizer.insert_field(solr_doc, 'embargo_release', rd1.utc.strftime('%FT%TZ'), :dateable) unless rd1.nil?
|
36
36
|
::Solrizer.insert_field(solr_doc, 'twenty_pct_visibility_release', rd20.utc.strftime('%FT%TZ'), :dateable) unless rd20.nil?
|
37
37
|
solr_doc
|
38
38
|
end
|
39
39
|
|
40
40
|
def ensure_non_versionable
|
41
|
-
self.versionable =
|
41
|
+
self.versionable = 'false'
|
42
42
|
end
|
43
43
|
|
44
44
|
#################################################################################
|
@@ -56,16 +56,16 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
56
56
|
|
57
57
|
# Sets the release date. Converts the date to beginning-of-day, UTC to help with Solr indexing
|
58
58
|
# @param [Time] rd A Time object represeting the release date. By default, it is set to now
|
59
|
-
def release_date=(rd=Time.now)
|
59
|
+
def release_date=(rd = Time.now.utc)
|
60
60
|
update_values([:release_date] => rd.beginning_of_day.utc.xmlschema)
|
61
|
-
self.content=
|
61
|
+
self.content = ng_xml.to_s
|
62
62
|
end
|
63
63
|
|
64
64
|
# Current releaseDate value
|
65
65
|
# @return [Time]
|
66
66
|
def release_date
|
67
67
|
rd = term_values(:release_date).first
|
68
|
-
|
68
|
+
(rd.nil? || rd.empty?) ? nil : Time.parse(rd)
|
69
69
|
end
|
70
70
|
|
71
71
|
def twenty_pct_status=(new_status)
|
@@ -79,7 +79,7 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
79
79
|
|
80
80
|
# Sets the 20% visibility release date. Converts the date to beginning-of-day, UTC to help with Solr indexing
|
81
81
|
# @param [Time] rd A Time object represeting the release date. By default, it is set to now
|
82
|
-
def twenty_pct_release_date=(rd=Time.now)
|
82
|
+
def twenty_pct_release_date=(rd = Time.now.utc)
|
83
83
|
update_values([:twenty_pct_release_date] => rd.beginning_of_day.utc.xmlschema)
|
84
84
|
content_will_change!
|
85
85
|
end
|
@@ -88,7 +88,7 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
88
88
|
# @return [Time]
|
89
89
|
def twenty_pct_release_date
|
90
90
|
rd = term_values(:twenty_pct_release_date).first
|
91
|
-
|
91
|
+
(rd.nil? || rd.empty?) ? nil : Time.parse(rd)
|
92
92
|
end
|
93
93
|
|
94
94
|
# @return [Nokogiri::XML::Element] The releaseAccess node
|
@@ -100,7 +100,7 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
100
100
|
# @param [Nokogiri::XML::Document] new_doc Document that will replace the existing releaseAccess node
|
101
101
|
def release_access_node=(new_doc)
|
102
102
|
if (new_doc.root.name != 'releaseAccess')
|
103
|
-
raise
|
103
|
+
raise 'Trying to replace releaseAccess with a non-releaseAccess document'
|
104
104
|
end
|
105
105
|
|
106
106
|
term_value_delete(:select => '//embargoMetadata/releaseAccess')
|
@@ -17,7 +17,7 @@ class EventsDS < ActiveFedora::OmDatastream
|
|
17
17
|
builder = Nokogiri::XML::Builder.new do |xml|
|
18
18
|
xml.events
|
19
19
|
end
|
20
|
-
|
20
|
+
builder.doc
|
21
21
|
end
|
22
22
|
|
23
23
|
def ensure_non_versionable
|
@@ -30,7 +30,7 @@ class EventsDS < ActiveFedora::OmDatastream
|
|
30
30
|
# @param [String] message what happened. Sets the content of the event with this message
|
31
31
|
def add_event(type, who, message)
|
32
32
|
ev = ng_xml.create_element 'event', message,
|
33
|
-
:type => type, :who => who, :when => Time.now.xmlschema
|
33
|
+
:type => type, :who => who, :when => Time.now.utc.xmlschema
|
34
34
|
ng_xml.root.add_child(ev)
|
35
35
|
ng_xml_will_change!
|
36
36
|
end
|
@@ -20,7 +20,7 @@ module Dor
|
|
20
20
|
}
|
21
21
|
|
22
22
|
# hash with all namespaces
|
23
|
-
XMLNS = Hash[NS.map {|k,v| ["xmlns:#{k}", v]}]
|
23
|
+
XMLNS = Hash[NS.map {|k, v| ["xmlns:#{k}", v]}]
|
24
24
|
|
25
25
|
# schema locations
|
26
26
|
NS_XSD = NS.keys.collect {|k| "#{NS[k]} #{NS[k]}/#{k}.xsd"}
|
@@ -40,11 +40,8 @@ module Dor
|
|
40
40
|
# or nil if not provided
|
41
41
|
def feature_catalogue
|
42
42
|
root = ng_xml.xpath('/rdf:RDF/rdf:Description/gfc:FC_FeatureCatalogue', XMLNS)
|
43
|
-
if root.nil? || root.empty?
|
44
|
-
|
45
|
-
else
|
46
|
-
Nokogiri::XML(root.first.to_xml)
|
47
|
-
end
|
43
|
+
return nil if root.nil? || root.empty? # Feature catalog is optional
|
44
|
+
Nokogiri::XML(root.first.to_xml)
|
48
45
|
end
|
49
46
|
|
50
47
|
# @return [Nokogiri::XML::Document] Contains skeleton geoMetadata XML
|
@@ -54,7 +51,7 @@ module Dor
|
|
54
51
|
Nokogiri::XML::Builder.new do |xml|
|
55
52
|
xml['rdf'].RDF XMLNS,
|
56
53
|
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
57
|
-
|
54
|
+
'xsi:schemaLocation' => NS_XSD.join(' ') do
|
58
55
|
xml['rdf'].Description 'rdf:about' => nil do
|
59
56
|
xml['gmd'].MD_Metadata
|
60
57
|
end
|
@@ -69,9 +66,7 @@ module Dor
|
|
69
66
|
# with .w, .e, .n., .s for west, east, north, south as floats
|
70
67
|
def to_bbox
|
71
68
|
params = { 'xmlns:gmd' => NS[:gmd], 'xmlns:gco' => NS[:gco] }
|
72
|
-
bb = metadata.xpath(
|
73
|
-
'//gmd:EX_Extent/gmd:geographicElement' +
|
74
|
-
'/gmd:EX_GeographicBoundingBox', params).first
|
69
|
+
bb = metadata.xpath('//gmd:EX_Extent/gmd:geographicElement/gmd:EX_GeographicBoundingBox', params).first
|
75
70
|
Struct.new(:w, :e, :n, :s).new(
|
76
71
|
bb.xpath('gmd:westBoundLongitude/gco:Decimal', params).text.to_f,
|
77
72
|
bb.xpath('gmd:eastBoundLongitude/gco:Decimal', params).text.to_f,
|
@@ -3,7 +3,7 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
3
3
|
include SolrDocHelper
|
4
4
|
|
5
5
|
set_terminology do |t|
|
6
|
-
t.root(:path=>
|
6
|
+
t.root(:path => 'identityMetadata')
|
7
7
|
t.objectId :index_as => [:symbol]
|
8
8
|
t.objectType :index_as => [:symbol]
|
9
9
|
t.objectLabel
|
@@ -19,7 +19,7 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
19
19
|
t.adminPolicy :index_as => [:not_searchable]
|
20
20
|
end
|
21
21
|
|
22
|
-
define_template :value do |builder,name,value,attrs|
|
22
|
+
define_template :value do |builder, name, value, attrs|
|
23
23
|
builder.send(name.to_sym, value, attrs)
|
24
24
|
end
|
25
25
|
|
@@ -27,21 +27,21 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
27
27
|
Nokogiri::XML('<identityMetadata/>')
|
28
28
|
end
|
29
29
|
|
30
|
-
def add_value(name, value, attrs={})
|
30
|
+
def add_value(name, value, attrs = {})
|
31
31
|
add_child_node(ng_xml.root, :value, name, value, attrs)
|
32
32
|
end
|
33
33
|
|
34
34
|
def objectId
|
35
|
-
|
35
|
+
find_by_terms(:objectId).text
|
36
36
|
end
|
37
37
|
|
38
38
|
def sourceId
|
39
|
-
node =
|
40
|
-
node ? [node['source'],node.text].join(':') : nil
|
39
|
+
node = find_by_terms(:sourceId).first
|
40
|
+
node ? [node['source'], node.text].join(':') : nil
|
41
41
|
end
|
42
42
|
|
43
43
|
def sourceId=(value)
|
44
|
-
node =
|
44
|
+
node = find_by_terms(:sourceId).first
|
45
45
|
unless value.present? # so setting it to '' is the same as removal: worth documenting maybe?
|
46
46
|
node.remove unless node.nil?
|
47
47
|
return nil
|
@@ -55,13 +55,13 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def tags
|
58
|
-
|
58
|
+
ng_xml.search('//tag').collect(&:content)
|
59
59
|
end
|
60
60
|
|
61
61
|
def otherId(type = nil)
|
62
|
-
result =
|
62
|
+
result = find_by_terms(:otherId).to_a
|
63
63
|
if type.nil?
|
64
|
-
result.collect { |n| [n['name'],n.text].join(':') }
|
64
|
+
result.collect { |n| [n['name'], n.text].join(':') }
|
65
65
|
else
|
66
66
|
result.select { |n| n['name'] == type }.collect { |n| n.text }
|
67
67
|
end
|
@@ -75,7 +75,7 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
75
75
|
node
|
76
76
|
end
|
77
77
|
|
78
|
-
def to_solr(solr_doc=
|
78
|
+
def to_solr(solr_doc = {}, *args)
|
79
79
|
super(solr_doc, *args)
|
80
80
|
|
81
81
|
if digital_object.respond_to?(:profile)
|
@@ -86,22 +86,22 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
86
86
|
|
87
87
|
if sourceId.present?
|
88
88
|
(name, id) = sourceId.split(/:/, 2)
|
89
|
-
add_solr_value(solr_doc,
|
90
|
-
add_solr_value(solr_doc,
|
91
|
-
add_solr_value(solr_doc,
|
89
|
+
add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
|
90
|
+
add_solr_value(solr_doc, 'identifier', sourceId, :symbol, [:stored_searchable])
|
91
|
+
add_solr_value(solr_doc, 'source_id', sourceId, :symbol, [])
|
92
92
|
end
|
93
93
|
otherId.compact.each { |qid|
|
94
94
|
# this section will solrize barcode and catkey, which live in otherId
|
95
95
|
(name, id) = qid.split(/:/, 2)
|
96
|
-
add_solr_value(solr_doc,
|
97
|
-
add_solr_value(solr_doc,
|
96
|
+
add_solr_value(solr_doc, 'dor_id', id, :symbol, [:stored_searchable])
|
97
|
+
add_solr_value(solr_doc, 'identifier', qid, :symbol, [:stored_searchable])
|
98
98
|
add_solr_value(solr_doc, "#{name}_id", id, :symbol, [])
|
99
99
|
}
|
100
100
|
|
101
101
|
# do some stuff to make tags in general and project tags specifically more easily searchable and facetable
|
102
|
-
|
102
|
+
find_by_terms(:tag).each { |tag|
|
103
103
|
(prefix, rest) = tag.text.split(/:/, 2)
|
104
|
-
prefix = prefix.downcase.strip.gsub(/\s/,'_')
|
104
|
+
prefix = prefix.downcase.strip.gsub(/\s/, '_')
|
105
105
|
unless rest.nil?
|
106
106
|
# this part will index a value in a field specific to the tag, e.g. registered_by_tag_*,
|
107
107
|
# book_tag_*, project_tag_*, remediated_by_tag_*, etc. project_tag_* and registered_by_tag_*
|
@@ -116,13 +116,13 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
116
116
|
tag_parts = tag.text.split(/:/)
|
117
117
|
progressive_tag_prefix = ''
|
118
118
|
tag_parts.each_with_index do |part, index|
|
119
|
-
progressive_tag_prefix +=
|
119
|
+
progressive_tag_prefix += ' : ' if index > 0
|
120
120
|
progressive_tag_prefix += part.strip
|
121
|
-
add_solr_value(solr_doc,
|
121
|
+
add_solr_value(solr_doc, 'exploded_tag', progressive_tag_prefix, :symbol, [])
|
122
122
|
end
|
123
123
|
}
|
124
124
|
|
125
|
-
|
125
|
+
solr_doc
|
126
126
|
end
|
127
|
-
end #class
|
127
|
+
end # class
|
128
128
|
end
|