dor-services 5.1.0 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/config/dev_console_env.rb +45 -32
- data/lib/dor-services.rb +52 -49
- data/lib/dor/datastreams/administrative_metadata_ds.rb +2 -2
- data/lib/dor/datastreams/content_metadata_ds.rb +114 -144
- data/lib/dor/datastreams/default_object_rights_ds.rb +10 -12
- data/lib/dor/datastreams/desc_metadata_ds.rb +4 -4
- data/lib/dor/datastreams/events_ds.rb +8 -8
- data/lib/dor/datastreams/identity_metadata_ds.rb +40 -23
- data/lib/dor/datastreams/rights_metadata_ds.rb +109 -0
- data/lib/dor/datastreams/role_metadata_ds.rb +4 -4
- data/lib/dor/datastreams/simple_dublin_core_ds.rb +6 -6
- data/lib/dor/datastreams/version_metadata_ds.rb +29 -10
- data/lib/dor/models/admin_policy_object.rb +3 -3
- data/lib/dor/models/describable.rb +5 -4
- data/lib/dor/models/editable.rb +29 -33
- data/lib/dor/models/embargoable.rb +1 -12
- data/lib/dor/models/governable.rb +4 -27
- data/lib/dor/models/identifiable.rb +60 -58
- data/lib/dor/models/item.rb +5 -9
- data/lib/dor/models/presentable.rb +15 -2
- data/lib/dor/models/processable.rb +34 -30
- data/lib/dor/models/publishable.rb +5 -14
- data/lib/dor/models/{releasable.rb → releaseable.rb} +59 -15
- data/lib/dor/models/rightsable.rb +25 -0
- data/lib/dor/models/versionable.rb +6 -3
- data/lib/dor/models/workflow_object.rb +4 -4
- data/lib/dor/services/cleanup_reset_service.rb +1 -2
- data/lib/dor/services/cleanup_service.rb +1 -1
- data/lib/dor/services/registration_service.rb +0 -3
- data/lib/dor/services/sdr_ingest_service.rb +1 -1
- data/lib/dor/services/search_service.rb +1 -1
- data/lib/dor/utils/sdr_client.rb +23 -0
- data/lib/dor/version.rb +1 -1
- data/lib/dor/workflow/document.rb +23 -22
- data/lib/tasks/rdoc.rake +4 -4
- metadata +113 -96
- data/config/environments/development.rb +0 -84
- data/config/environments/development.rb.old +0 -84
- data/config/environments/test.rb +0 -84
- data/lib/tasks/dor.rake +0 -39
@@ -10,7 +10,7 @@ module Dor
|
|
10
10
|
has_many :things, :property => :is_governed_by, :inbound => :true, :class_name => "ActiveFedora::Base"
|
11
11
|
has_object_type 'adminPolicy'
|
12
12
|
has_metadata :name => "administrativeMetadata", :type => Dor::AdministrativeMetadataDS, :label => 'Administrative Metadata'
|
13
|
-
has_metadata :name => "roleMetadata",
|
14
|
-
has_metadata :name => "defaultObjectRights",
|
13
|
+
has_metadata :name => "roleMetadata", :type => Dor::RoleMetadataDS, :label => 'Role Metadata'
|
14
|
+
has_metadata :name => "defaultObjectRights", :type => Dor::DefaultObjectRightsDS, :label => 'Default Object Rights'
|
15
15
|
end
|
16
|
-
end
|
16
|
+
end
|
@@ -125,8 +125,8 @@ module Dor
|
|
125
125
|
collection_title = Dor::Describable.get_collection_title(collection_obj)
|
126
126
|
related_item_node=Nokogiri::XML::Node.new('relatedItem',doc)
|
127
127
|
related_item_node['type']='host'
|
128
|
-
title_info_node=Nokogiri::XML::Node.new('titleInfo',doc)
|
129
|
-
title_node=Nokogiri::XML::Node.new('title',doc)
|
128
|
+
title_info_node = Nokogiri::XML::Node.new('titleInfo',doc)
|
129
|
+
title_node = Nokogiri::XML::Node.new('title',doc)
|
130
130
|
title_node.content=collection_title
|
131
131
|
|
132
132
|
id_node=Nokogiri::XML::Node.new('identifier',doc)
|
@@ -185,7 +185,7 @@ module Dor
|
|
185
185
|
title=node.text
|
186
186
|
end
|
187
187
|
creator_title=creator+title
|
188
|
-
add_solr_value(solr_doc, 'creator_title', creator_title , :string, [:
|
188
|
+
add_solr_value(solr_doc, 'creator_title', creator_title , :string, [:stored_sortable])
|
189
189
|
rescue CrosswalkError => e
|
190
190
|
ActiveFedora.logger.warn "Cannot index #{self.pid}.descMetadata: #{e.message}"
|
191
191
|
end
|
@@ -197,7 +197,8 @@ module Dor
|
|
197
197
|
solr_doc[solr_key].push *vals unless (vals.nil? || vals.empty?)
|
198
198
|
# asterisk to avoid multi-dimensional array: push values, not the array
|
199
199
|
end
|
200
|
-
solr_doc['sw_pub_date_sort_ssi'] = mods.pub_date_sort
|
200
|
+
solr_doc['sw_pub_date_sort_ssi' ] = mods.pub_date_sort # e.g. '0800'
|
201
|
+
solr_doc['sw_pub_date_facet_ssi'] = mods.pub_date_facet # e.g. '9th century'
|
201
202
|
end
|
202
203
|
# some fields get explicit "(none)" placeholder values, mostly for faceting
|
203
204
|
%w[sw_language_tesim sw_genre_tesim sw_format_tesim].each { |key| solr_doc[key] = ['(none)'] if solr_doc[key].empty? }
|
data/lib/dor/models/editable.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
|
-
module Dor
|
1
|
+
module Dor
|
2
|
+
|
3
|
+
## This is basically used just by APOs. Arguably "editable" is the wrong name.
|
2
4
|
module Editable
|
3
5
|
extend ActiveSupport::Concern
|
4
6
|
|
5
7
|
included do
|
6
8
|
belongs_to :agreement_object, :property => :referencesAgreement, :class_name => "Dor::Item"
|
7
9
|
end
|
8
|
-
|
10
|
+
|
9
11
|
def to_solr(solr_doc=Hash.new, *args)
|
10
12
|
super(solr_doc, *args)
|
11
|
-
add_solr_value(solr_doc, "default_rights", default_rights, :string, [:
|
12
|
-
add_solr_value(solr_doc, "agreement", agreement, :string, [:
|
13
|
+
add_solr_value(solr_doc, "default_rights", default_rights, :string, [:symbol])
|
14
|
+
add_solr_value(solr_doc, "agreement", agreement, :string, [:symbol]) if agreement_object
|
13
15
|
solr_doc
|
14
16
|
end
|
17
|
+
|
15
18
|
#Adds a person or group to a role in the APO role metadata datastream
|
16
19
|
#
|
17
|
-
#@param role
|
20
|
+
#@param role [String] the role the group or person will be filed under, ex. dor-apo-manager
|
18
21
|
#@param entity [String] the name of the person or group, ex dlss:developers or sunetid:someone
|
19
|
-
#@param type
|
22
|
+
#@param type [Symbol] :workgroup for a group or :person for a person
|
20
23
|
def add_roleplayer role, entity, type=:workgroup
|
21
24
|
xml=self.roleMetadata.ng_xml
|
22
25
|
group = type == :workgroup ? 'group' : 'person'
|
@@ -41,8 +44,9 @@ module Dor
|
|
41
44
|
end
|
42
45
|
self.roleMetadata.content=xml.to_s
|
43
46
|
end
|
47
|
+
|
44
48
|
#remove all people groups and roles from the APO role metadata datastream
|
45
|
-
def purge_roles
|
49
|
+
def purge_roles
|
46
50
|
self.roleMetadata.ng_xml.search('/roleMetadata/role').each do |node|
|
47
51
|
node.remove
|
48
52
|
end
|
@@ -56,10 +60,10 @@ module Dor
|
|
56
60
|
end
|
57
61
|
#get all collections listed for this APO, used during registration
|
58
62
|
#@return [Array] array of pids
|
59
|
-
def default_collections
|
63
|
+
def default_collections
|
60
64
|
return administrativeMetadata.term_values(:registration, :default_collection)
|
61
65
|
end
|
62
|
-
#Add a collection to the listing of collections for items governed by this apo.
|
66
|
+
#Add a collection to the listing of collections for items governed by this apo.
|
63
67
|
#@param val [String] pid of the collection, ex. druid:ab123cd4567
|
64
68
|
def add_default_collection val
|
65
69
|
xml = self.administrativeMetadata.ng_xml
|
@@ -73,7 +77,7 @@ module Dor
|
|
73
77
|
reg.add_child(node)
|
74
78
|
self.administrativeMetadata.content=xml.to_s
|
75
79
|
end
|
76
|
-
|
80
|
+
|
77
81
|
def remove_default_collection val
|
78
82
|
xml = self.administrativeMetadata.ng_xml
|
79
83
|
xml.search('//administrativeMetadata/registration/collection[@id=\''+val+'\']').remove
|
@@ -91,7 +95,7 @@ module Dor
|
|
91
95
|
end
|
92
96
|
roles
|
93
97
|
end
|
94
|
-
def metadata_source
|
98
|
+
def metadata_source
|
95
99
|
self.administrativeMetadata.metadata_source.first
|
96
100
|
end
|
97
101
|
def metadata_source=(val)
|
@@ -131,23 +135,18 @@ module Dor
|
|
131
135
|
self.defaultObjectRights.add_child_node(self.defaultObjectRights.ng_xml.root, :creative_commons)
|
132
136
|
end
|
133
137
|
self.defaultObjectRights.update_values({[:creative_commons_human] => val})
|
134
|
-
|
135
138
|
end
|
136
139
|
#@return [String] A description of the rights defined in the default object rights datastream. Can be 'Stanford', 'World', 'Dark' or 'None'
|
137
140
|
def default_rights
|
138
141
|
xml=self.defaultObjectRights.ng_xml
|
139
142
|
if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1
|
140
143
|
'Stanford'
|
144
|
+
elsif xml.search('//rightsMetadata/access[@type=\'read\']/machine/world').length ==1
|
145
|
+
'World'
|
146
|
+
elsif xml.search('//rightsMetadata/access[@type=\'discover\']/machine/none').length == 1
|
147
|
+
'Dark'
|
141
148
|
else
|
142
|
-
|
143
|
-
'World'
|
144
|
-
else
|
145
|
-
if xml.search('//rightsMetadata/access[@type=\'discover\']/machine/none').length == 1
|
146
|
-
'Dark'
|
147
|
-
else
|
148
|
-
'None'
|
149
|
-
end
|
150
|
-
end
|
149
|
+
'None'
|
151
150
|
end
|
152
151
|
end
|
153
152
|
#Set the rights in default object rights
|
@@ -157,36 +156,33 @@ module Dor
|
|
157
156
|
rights_xml = self.defaultObjectRights.ng_xml
|
158
157
|
rights_xml.search('//rightsMetadata/access[@type=\'discover\']/machine').each do |node|
|
159
158
|
node.children.remove
|
160
|
-
|
161
|
-
|
162
|
-
node.add_child(world_node)
|
163
|
-
else
|
164
|
-
world_node=Nokogiri::XML::Node.new('world',rights_xml)
|
165
|
-
node.add_child(world_node)
|
166
|
-
end
|
159
|
+
world_node=Nokogiri::XML::Node.new((rights=='dark' ? 'none' : 'world'),rights_xml)
|
160
|
+
node.add_child(world_node)
|
167
161
|
end
|
168
162
|
rights_xml.search('//rightsMetadata/access[@type=\'read\']').each do |node|
|
169
163
|
node.children.remove
|
170
164
|
machine_node=Nokogiri::XML::Node.new('machine',rights_xml)
|
171
|
-
if
|
165
|
+
if rights == 'world'
|
172
166
|
world_node=Nokogiri::XML::Node.new(rights,rights_xml)
|
173
167
|
node.add_child(machine_node)
|
174
168
|
machine_node.add_child(world_node)
|
175
|
-
elsif rights=='stanford'
|
169
|
+
elsif rights == 'stanford'
|
176
170
|
world_node=Nokogiri::XML::Node.new(rights,rights_xml)
|
177
171
|
node.add_child(machine_node)
|
178
172
|
group_node=Nokogiri::XML::Node.new('group',rights_xml)
|
179
173
|
group_node.content="Stanford"
|
180
174
|
node.add_child(machine_node)
|
181
175
|
machine_node.add_child(group_node)
|
182
|
-
elsif rights=='none' || rights == 'dark'
|
176
|
+
elsif rights == 'none' || rights == 'dark'
|
183
177
|
none_node=Nokogiri::XML::Node.new('none',rights_xml)
|
184
178
|
node.add_child(machine_node)
|
185
179
|
machine_node.add_child(none_node)
|
180
|
+
else
|
181
|
+
raise ArgumentError, "Unrecognized rights value '#{rights}'"
|
186
182
|
end
|
187
183
|
end
|
188
184
|
end
|
189
|
-
|
185
|
+
|
190
186
|
def desc_metadata_format
|
191
187
|
self.administrativeMetadata.metadata_format.first
|
192
188
|
end
|
@@ -220,7 +216,7 @@ module Dor
|
|
220
216
|
wfs
|
221
217
|
else
|
222
218
|
[]
|
223
|
-
end
|
219
|
+
end
|
224
220
|
end
|
225
221
|
#set a single default workflow
|
226
222
|
#@param wf [String] the name of the workflow, ex. 'digitizationWF'
|
@@ -39,17 +39,6 @@ module Dor
|
|
39
39
|
datastreams['events'].add_event("embargo", release_agent, "Embargo released")
|
40
40
|
end
|
41
41
|
|
42
|
-
def world_doc
|
43
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
44
|
-
xml.access(:type => 'read') {
|
45
|
-
xml.machine {
|
46
|
-
xml.world
|
47
|
-
}
|
48
|
-
}
|
49
|
-
end
|
50
|
-
return builder.doc
|
51
|
-
end
|
52
|
-
|
53
42
|
def release_20_pct_vis_embargo(release_agent="unknown")
|
54
43
|
# Set status to released
|
55
44
|
embargo_md = datastreams['embargoMetadata']
|
@@ -73,7 +62,7 @@ module Dor
|
|
73
62
|
|
74
63
|
def update_embargo(new_date)
|
75
64
|
if embargoMetadata.status != 'embargoed'
|
76
|
-
raise ArgumentError, 'You cannot change the embargo date of an item
|
65
|
+
raise ArgumentError, 'You cannot change the embargo date of an item that is not embargoed.'
|
77
66
|
end
|
78
67
|
if new_date.past?
|
79
68
|
raise ArgumentError, 'You cannot set the embargo date to a past date.'
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Dor
|
2
2
|
module Governable
|
3
3
|
extend ActiveSupport::Concern
|
4
|
+
include Rightsable
|
4
5
|
|
5
6
|
included do
|
6
7
|
belongs_to :admin_policy_object, :property => :is_governed_by, :class_name => "Dor::AdminPolicyObject"
|
@@ -26,36 +27,11 @@ module Dor
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def reset_to_apo_default()
|
29
|
-
|
30
|
-
rights_metadata_ds.content = admin_policy_object.rightsMetadata.ng_xml
|
30
|
+
self.rightsMetadata.content = admin_policy_object.rightsMetadata.ng_xml
|
31
31
|
end
|
32
32
|
|
33
|
-
# slight misnomer: also sets discover rights!
|
34
33
|
def set_read_rights(rights)
|
35
|
-
|
36
|
-
rights_xml = self.rightsMetadata.ng_xml
|
37
|
-
if (rights_xml.search('//rightsMetadata/access[@type=\'read\']').length==0)
|
38
|
-
raise('The rights metadata stream doesnt contain an entry for machine read permissions. Consider populating it from the APO before trying to change it.')
|
39
|
-
end
|
40
|
-
label = rights=='dark' ? 'none' : 'world'
|
41
|
-
rights_xml.search('//rightsMetadata/access[@type=\'discover\']/machine').each do |node|
|
42
|
-
node.children.remove
|
43
|
-
node.add_child Nokogiri::XML::Node.new(label,rights_xml)
|
44
|
-
end
|
45
|
-
rights_xml.search('//rightsMetadata/access[@type=\'read\']').each do |node|
|
46
|
-
node.children.remove
|
47
|
-
machine_node = Nokogiri::XML::Node.new('machine',rights_xml)
|
48
|
-
node.add_child(machine_node)
|
49
|
-
if rights == 'world'
|
50
|
-
machine_node.add_child Nokogiri::XML::Node.new(rights,rights_xml)
|
51
|
-
elsif rights == 'stanford'
|
52
|
-
group_node = Nokogiri::XML::Node.new('group',rights_xml)
|
53
|
-
group_node.content = "Stanford"
|
54
|
-
machine_node.add_child(group_node)
|
55
|
-
else # we know it is none or dark by the argument filter (first line)
|
56
|
-
machine_node.add_child Nokogiri::XML::Node.new('none',rights_xml)
|
57
|
-
end
|
58
|
-
end
|
34
|
+
self.rightsMetadata.set_read_rights(rights)
|
59
35
|
end
|
60
36
|
|
61
37
|
def add_collection(collection_or_druid)
|
@@ -87,6 +63,7 @@ module Dor
|
|
87
63
|
end
|
88
64
|
def rights
|
89
65
|
return nil unless self.respond_to? :rightsMetadata
|
66
|
+
return nil if self.rightsMetadata.nil?
|
90
67
|
xml = self.rightsMetadata.ng_xml
|
91
68
|
return nil if xml.search('//rightsMetadata').length != 1 # ORLY?
|
92
69
|
if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1
|
@@ -53,73 +53,31 @@ module Dor
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
## Module-level variables, shared between ALL mixin includers!
|
56
|
+
## Module-level variables, shared between ALL mixin includers (and ALL *their* includers/extenders)!
|
57
|
+
## used for caching found values
|
57
58
|
@@collection_hash={}
|
58
59
|
@@apo_hash={}
|
59
|
-
@@hydrus_apo_hash={}
|
60
|
-
@@hydrus_collection_hash={}
|
61
60
|
|
62
61
|
def to_solr(solr_doc=Hash.new, *args)
|
63
62
|
self.assert_content_model
|
64
63
|
super(solr_doc, *args)
|
64
|
+
|
65
65
|
solr_doc[Dor::INDEX_VERSION_FIELD] = Dor::VERSION
|
66
|
-
solr_doc['indexed_at_dtsi'
|
67
|
-
solr_doc['indexed_day_dtsi'] = Time.now.beginning_of_day.utc.xmlschema # technically unnecessary, but convenient
|
66
|
+
solr_doc['indexed_at_dtsi'] = Time.now.utc.xmlschema
|
68
67
|
datastreams.values.each do |ds|
|
69
|
-
add_solr_value(solr_doc,'ds_specs',ds.datastream_spec_string
|
68
|
+
add_solr_value(solr_doc, 'ds_specs', ds.datastream_spec_string, :string, [:symbol]) unless ds.new?
|
70
69
|
end
|
71
|
-
|
72
|
-
|
70
|
+
|
71
|
+
add_solr_value(solr_doc, 'title_sort', self.label, :string, [:stored_sortable])
|
72
|
+
|
73
73
|
rels_doc = Nokogiri::XML(self.datastreams['RELS-EXT'].content)
|
74
|
-
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#'
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# check cache first
|
80
|
-
if @@apo_hash.has_key?(druid) || @@hydrus_apo_hash.has_key?(druid)
|
81
|
-
add_solr_value(solr_doc, "hydrus_apo_title", @@hydrus_apo_hash[druid], :string, title_attrs) if @@hydrus_apo_hash.has_key? druid
|
82
|
-
add_solr_value(solr_doc, "apo_title", @@apo_hash[druid] , :string, title_attrs) if @@apo_hash.has_key? druid
|
83
|
-
else
|
84
|
-
begin
|
85
|
-
apo_object=Dor.find(druid)
|
86
|
-
if apo_object.tags.include? 'Project : Hydrus'
|
87
|
-
add_solr_value(solr_doc, "hydrus_apo_title", apo_object.label, :string, title_attrs)
|
88
|
-
@@hydrus_apo_hash[druid]=apo_object.label
|
89
|
-
else
|
90
|
-
add_solr_value(solr_doc, "apo_title", apo_object.label, :string, title_attrs)
|
91
|
-
@@apo_hash[druid]=apo_object.label
|
92
|
-
end
|
93
|
-
rescue
|
94
|
-
add_solr_value(solr_doc, "apo_title", druid, :string, title_attrs)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
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#' )
|
99
|
-
collections.each do |collection_node|
|
100
|
-
druid=collection_node['rdf:resource']
|
101
|
-
next unless druid ## TODO: warning here would also be useful
|
102
|
-
druid=druid.gsub('info:fedora/','')
|
103
|
-
if @@collection_hash.has_key?(druid) || @@hydrus_collection_hash.has_key?(druid)
|
104
|
-
add_solr_value(solr_doc, "hydrus_collection_title", @@hydrus_collection_hash[druid], :string, title_attrs) if @@hydrus_collection_hash.has_key? druid
|
105
|
-
add_solr_value(solr_doc, "collection_title", @@collection_hash[druid], :string, title_attrs) if @@collection_hash.has_key? druid
|
106
|
-
else
|
107
|
-
begin
|
108
|
-
collection_object=Dor.find(druid)
|
109
|
-
if collection_object.tags.include? 'Project : Hydrus'
|
110
|
-
add_solr_value(solr_doc, "hydrus_collection_title", collection_object.label, :string, title_attrs)
|
111
|
-
@@hydrus_collection_hash[druid]=collection_object.label
|
112
|
-
else
|
113
|
-
add_solr_value(solr_doc, "collection_title", collection_object.label, :string, title_attrs)
|
114
|
-
@@collection_hash[druid]=collection_object.label
|
115
|
-
end
|
116
|
-
rescue
|
117
|
-
add_solr_value(solr_doc, "collection_title", druid, :string, title_attrs)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
74
|
+
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#')
|
75
|
+
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#')
|
76
|
+
solrize_related_obj_titles(solr_doc, apos, @@apo_hash, "apo_title")
|
77
|
+
solrize_related_obj_titles(solr_doc, collections, @@collection_hash, "collection_title")
|
78
|
+
|
121
79
|
solr_doc["metadata_source_ssi"] = self.identity_metadata_source
|
122
|
-
solr_doc
|
80
|
+
return solr_doc
|
123
81
|
end
|
124
82
|
|
125
83
|
#@return [String] calculated value for Solr index
|
@@ -202,7 +160,7 @@ module Dor
|
|
202
160
|
|
203
161
|
#Ensure that an administrative tag meets the proper mininum format
|
204
162
|
#
|
205
|
-
#@
|
163
|
+
#@param tag_str [String] the tag
|
206
164
|
#
|
207
165
|
#@return [Array] the tag split into an array via ':'
|
208
166
|
def validate_tag_format(tag_str)
|
@@ -220,7 +178,7 @@ module Dor
|
|
220
178
|
|
221
179
|
#Add an administrative tag to an item, you will need to seperately save the item to write it to fedora
|
222
180
|
#
|
223
|
-
|
181
|
+
#@param tag [string] The tag you wish to add
|
224
182
|
def add_tag(tag)
|
225
183
|
identity_metadata_ds = self.identityMetadata
|
226
184
|
normalized_tag = validate_and_normalize_tag(tag, identity_metadata_ds.tags)
|
@@ -237,6 +195,18 @@ module Dor
|
|
237
195
|
end
|
238
196
|
return removed
|
239
197
|
end
|
198
|
+
|
199
|
+
#Removes all displayTypes from an item in preparation of adding a new display type
|
200
|
+
#
|
201
|
+
#@return Boolean True if displayTypes were removed, False if no displayTypes were removed
|
202
|
+
def remove_displayTypes
|
203
|
+
removed = false
|
204
|
+
self.identityMetadata.ng_xml.search('//displayType').each do |node|
|
205
|
+
node.remove
|
206
|
+
removed = true
|
207
|
+
end
|
208
|
+
return removed
|
209
|
+
end
|
240
210
|
|
241
211
|
def update_tag(old_tag, new_tag)
|
242
212
|
updated = false
|
@@ -248,5 +218,37 @@ module Dor
|
|
248
218
|
end
|
249
219
|
return updated
|
250
220
|
end
|
221
|
+
|
222
|
+
def get_related_obj_display_title(related_obj, default_title)
|
223
|
+
if related_obj
|
224
|
+
if related_obj.datastreams["DC"] && related_obj.datastreams["DC"].title
|
225
|
+
return related_obj.datastreams["DC"].title
|
226
|
+
else
|
227
|
+
return related_obj.label
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
return default_title
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
private
|
236
|
+
def solrize_related_obj_titles(solr_doc, relationships, title_hash, field_name)
|
237
|
+
title_type = :symbol # we'll get an _ssim because of the type
|
238
|
+
title_attrs = [:stored_searchable] # we'll also get a _tesim from this attr
|
239
|
+
relationships.each do |rel_node|
|
240
|
+
rel_druid = rel_node['rdf:resource']
|
241
|
+
next unless rel_druid # TODO: warning here would also be useful
|
242
|
+
rel_druid = rel_druid.gsub('info:fedora/', '')
|
243
|
+
if title_hash.has_key?(rel_druid)
|
244
|
+
add_solr_value(solr_doc, field_name, title_hash[rel_druid], title_type, title_attrs)
|
245
|
+
else
|
246
|
+
related_obj = Dor.find(rel_druid)
|
247
|
+
related_obj_title = get_related_obj_display_title(related_obj, rel_druid)
|
248
|
+
add_solr_value(solr_doc, field_name, related_obj_title, title_type, title_attrs)
|
249
|
+
title_hash[rel_druid] = related_obj_title
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
251
253
|
end
|
252
254
|
end
|
data/lib/dor/models/item.rb
CHANGED
@@ -1,23 +1,19 @@
|
|
1
1
|
module Dor
|
2
2
|
module BasicItem
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
include Identifiable
|
4
|
+
|
6
5
|
include Processable
|
7
|
-
include Governable
|
8
|
-
include Describable
|
9
|
-
include Publishable
|
10
6
|
include Shelvable
|
11
|
-
include Embargoable
|
7
|
+
include Embargoable # implies Publishable implies Identifiable, Describable, Governable, Rightsable ...
|
12
8
|
include Preservable
|
13
9
|
include Assembleable
|
14
10
|
include Versionable
|
15
11
|
include Contentable
|
16
12
|
include Geoable
|
17
|
-
include
|
18
|
-
|
13
|
+
include Releaseable
|
14
|
+
|
19
15
|
end
|
20
|
-
|
16
|
+
|
21
17
|
class Abstract < ::ActiveFedora::Base
|
22
18
|
include Identifiable
|
23
19
|
end
|