dor-services 4.22.3 → 4.22.4
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 +8 -8
- data/bin/dor-indexer +19 -20
- data/bin/dor-indexerd +2 -3
- data/config/certs/robots-dor-dev.crt +29 -0
- data/config/certs/robots-dor-dev.key +27 -0
- data/config/dev_console_env.rb +77 -0
- data/lib/dor-services.rb +3 -3
- data/lib/dor/config.rb +15 -15
- data/lib/dor/datastreams/administrative_metadata_ds.rb +5 -5
- data/lib/dor/datastreams/content_metadata_ds.rb +181 -225
- data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
- data/lib/dor/datastreams/default_object_rights_ds.rb +8 -10
- data/lib/dor/datastreams/desc_metadata_ds.rb +35 -34
- data/lib/dor/datastreams/embargo_metadata_ds.rb +7 -7
- data/lib/dor/datastreams/events_ds.rb +11 -11
- data/lib/dor/datastreams/geo_metadata_ds.rb +86 -86
- data/lib/dor/datastreams/identity_metadata_ds.rb +19 -19
- data/lib/dor/datastreams/role_metadata_ds.rb +3 -3
- data/lib/dor/datastreams/simple_dublin_core_ds.rb +13 -13
- data/lib/dor/datastreams/version_metadata_ds.rb +5 -5
- data/lib/dor/datastreams/workflow_definition_ds.rb +21 -21
- 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 +1 -1
- data/lib/dor/models/admin_policy_object.rb +1 -1
- data/lib/dor/models/assembleable.rb +5 -5
- data/lib/dor/models/contentable.rb +27 -27
- data/lib/dor/models/describable.rb +168 -179
- data/lib/dor/models/discoverable.rb +13 -13
- data/lib/dor/models/editable.rb +55 -55
- data/lib/dor/models/embargoable.rb +26 -26
- data/lib/dor/models/eventable.rb +3 -3
- data/lib/dor/models/geoable.rb +8 -8
- data/lib/dor/models/governable.rb +14 -14
- data/lib/dor/models/identifiable.rb +117 -143
- data/lib/dor/models/item.rb +2 -2
- data/lib/dor/models/itemizable.rb +9 -9
- data/lib/dor/models/presentable.rb +8 -8
- data/lib/dor/models/preservable.rb +4 -4
- data/lib/dor/models/processable.rb +22 -23
- data/lib/dor/models/releaseable.rb +26 -26
- data/lib/dor/models/shelvable.rb +14 -14
- data/lib/dor/models/upgradable.rb +13 -13
- data/lib/dor/models/versionable.rb +2 -2
- data/lib/dor/models/workflow_object.rb +4 -4
- data/lib/dor/services/cleanup_reset_service.rb +27 -27
- data/lib/dor/services/cleanup_service.rb +4 -7
- data/lib/dor/services/digital_stacks_service.rb +10 -10
- data/lib/dor/services/merge_service.rb +1 -1
- data/lib/dor/services/metadata_handlers/mdtoolkit_handler.rb +2 -2
- data/lib/dor/services/metadata_service.rb +20 -20
- data/lib/dor/services/registration_service.rb +27 -27
- data/lib/dor/services/reset_workspace_service.rb +15 -15
- data/lib/dor/services/sdr_ingest_service.rb +6 -6
- data/lib/dor/services/search_service.rb +2 -2
- data/lib/dor/services/suri_service.rb +5 -5
- data/lib/dor/services/technical_metadata_service.rb +2 -3
- data/lib/dor/utils/ng_tidy.rb +9 -9
- 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 +19 -19
- data/lib/dor/workflow/graph.rb +36 -36
- data/lib/dor/workflow/process.rb +12 -12
- data/lib/tasks/dor.rake +1 -1
- data/lib/tasks/rdoc.rake +3 -3
- metadata +6 -3
@@ -1,20 +1,18 @@
|
|
1
1
|
module Dor
|
2
|
-
class DefaultObjectRightsDS < ActiveFedora::OmDatastream
|
2
|
+
class DefaultObjectRightsDS < ActiveFedora::OmDatastream
|
3
3
|
|
4
4
|
set_terminology do |t|
|
5
5
|
t.root :path => 'rightsMetadata', :index_as => [:not_searchable]
|
6
6
|
t.copyright :path => 'copyright/human', :index_as => [:facetable]
|
7
7
|
t.use_statement :path => '/use/human[@type=\'useAndReproduction\']', :index_as => [:facetable]
|
8
|
-
|
8
|
+
|
9
9
|
t.use do
|
10
10
|
t.machine
|
11
11
|
t.human
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
t.creative_commons :path => '/use/machine', :type => 'creativeCommons'
|
15
15
|
t.creative_commons_human :path => '/use/human[@type=\'creativeCommons\']'
|
16
|
-
|
17
|
-
|
18
16
|
end
|
19
17
|
|
20
18
|
define_template :creative_commons do |xml|
|
@@ -23,6 +21,7 @@ module Dor
|
|
23
21
|
xml.machine(:type => "creativeCommons")
|
24
22
|
}
|
25
23
|
end
|
24
|
+
|
26
25
|
def self.xml_template
|
27
26
|
Nokogiri::XML::Builder.new do |xml|
|
28
27
|
xml.rightsMetadata{
|
@@ -30,7 +29,7 @@ module Dor
|
|
30
29
|
xml.machine{
|
31
30
|
xml.world
|
32
31
|
}
|
33
|
-
}
|
32
|
+
}
|
34
33
|
xml.access(:type => 'read'){
|
35
34
|
xml.machine{
|
36
35
|
xml.world
|
@@ -44,9 +43,8 @@ module Dor
|
|
44
43
|
xml.copyright{
|
45
44
|
xml.human
|
46
45
|
}
|
47
|
-
|
48
|
-
|
49
|
-
end
|
46
|
+
}
|
47
|
+
end.doc
|
48
|
+
end
|
50
49
|
end
|
51
50
|
end
|
52
|
-
end
|
@@ -1,39 +1,40 @@
|
|
1
1
|
module Dor
|
2
|
-
class DescMetadataDS < ActiveFedora::OmDatastream
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
class DescMetadataDS < ActiveFedora::OmDatastream
|
3
|
+
include SolrDocHelper
|
4
|
+
|
5
|
+
MODS_NS = 'http://www.loc.gov/mods/v3'
|
6
|
+
set_terminology do |t|
|
7
|
+
t.root :path => 'mods', :xmlns => MODS_NS, :index_as => [:not_searchable]
|
8
|
+
t.originInfo :index_as => [:not_searchable] do
|
9
|
+
t.publisher :index_as => [:searchable, :displayable]
|
10
|
+
t.place :index_as => [:not_searchable] do
|
11
|
+
t.placeTerm :attributes => {:type => 'text'}, :index_as => [:searchable, :displayable]
|
12
|
+
end
|
12
13
|
end
|
14
|
+
t.title_info(:path => 'titleInfo') {
|
15
|
+
t.main_title(:index_as => [:facetable], :path => 'title', :label => 'title') {
|
16
|
+
t.main_title_lang(:path => {:attribute => 'xml:lang'})
|
17
|
+
}
|
18
|
+
}
|
19
|
+
t.language {
|
20
|
+
t.languageTerm :attributes => {:type => 'code', :authority => 'iso639-2b'}, :index_as => [:not_searchable]
|
21
|
+
}
|
22
|
+
t.coordinates :index_as => [:searchable]
|
23
|
+
t.extent :index_as => [:searchable]
|
24
|
+
t.scale :index_as => [:searchable]
|
25
|
+
t.topic :index_as => [:searchable]
|
26
|
+
t.abstract :index_as => [:displayable]
|
13
27
|
end
|
14
|
-
t.title_info(:path=>"titleInfo") {
|
15
|
-
t.main_title(:index_as=>[:facetable],:path=>"title", :label=>"title") {
|
16
|
-
t.main_title_lang(:path=>{:attribute=> "xml:lang"})
|
17
|
-
}
|
18
|
-
}
|
19
|
-
t.coordinates :index_as => [:searchable]
|
20
|
-
t.extent :index_as => [:searchable]
|
21
|
-
t.scale :index_as => [:searchable]
|
22
|
-
t.topic :index_as => [:searchable]
|
23
|
-
t.abstract :index_as=>[:displayable]
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.xml_template
|
27
|
-
Nokogiri::XML::Builder.new do |xml|
|
28
|
-
xml.mods( 'xmlns' => 'http://www.loc.gov/mods/v3', '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'){
|
29
|
-
xml.titleInfo{
|
30
|
-
xml.title
|
31
|
-
}
|
32
|
-
}
|
33
|
-
end.doc
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
28
|
|
38
|
-
|
29
|
+
def self.xml_template
|
30
|
+
Nokogiri::XML::Builder.new do |xml|
|
31
|
+
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'){
|
32
|
+
xml.titleInfo{
|
33
|
+
xml.title
|
34
|
+
}
|
35
|
+
}
|
36
|
+
end.doc
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
39
40
|
end
|
@@ -24,13 +24,13 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
24
24
|
xml.twentyPctVisibilityReleaseDate
|
25
25
|
}
|
26
26
|
end
|
27
|
-
|
27
|
+
builder.doc
|
28
28
|
end
|
29
29
|
|
30
30
|
def to_solr solr_doc = {}, *args
|
31
31
|
super
|
32
|
-
add_solr_value(solr_doc, 'embargo_release_date',
|
33
|
-
add_solr_value(solr_doc, 'twenty_pct_visibility_release_date',
|
32
|
+
add_solr_value(solr_doc, 'embargo_release_date', release_date.utc.strftime('%FT%TZ') , :date, [:searchable]) rescue nil
|
33
|
+
add_solr_value(solr_doc, 'twenty_pct_visibility_release_date', twenty_pct_release_date.utc.strftime('%FT%TZ') , :date, [:searchable]) rescue nil
|
34
34
|
|
35
35
|
solr_doc
|
36
36
|
end
|
@@ -54,9 +54,9 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
54
54
|
|
55
55
|
# Sets the release date. Converts the date to beginning-of-day, UTC to help with Solr indexing
|
56
56
|
# @param [Time] rd A Time object represeting the release date. By default, it is set to now
|
57
|
-
def release_date=(rd=Time.now)
|
58
|
-
|
59
|
-
self.content=
|
57
|
+
def release_date=(rd = Time.now)
|
58
|
+
update_values([:release_date] => rd.beginning_of_day.utc.xmlschema)
|
59
|
+
self.content=ng_xml.to_s
|
60
60
|
end
|
61
61
|
|
62
62
|
# Current releaseDate value
|
@@ -76,7 +76,7 @@ class EmbargoMetadataDS < ActiveFedora::OmDatastream
|
|
76
76
|
|
77
77
|
# Sets the 20% visibility release date. Converts the date to beginning-of-day, UTC to help with Solr indexing
|
78
78
|
# @param [Time] rd A Time object represeting the release date. By default, it is set to now
|
79
|
-
def twenty_pct_release_date=(rd=Time.now)
|
79
|
+
def twenty_pct_release_date=(rd = Time.now)
|
80
80
|
update_values([:twenty_pct_release_date] => rd.beginning_of_day.utc.xmlschema)
|
81
81
|
content_will_change!
|
82
82
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Dor
|
2
2
|
class EventsDS < ActiveFedora::OmDatastream
|
3
3
|
before_create :ensure_non_versionable
|
4
|
-
|
4
|
+
|
5
5
|
set_terminology do |t|
|
6
6
|
t.root(:path => "events")
|
7
7
|
t.event do
|
@@ -11,30 +11,30 @@ class EventsDS < ActiveFedora::OmDatastream
|
|
11
11
|
t.message :path => "text()", :index_as => [:displayable, :not_searchable]
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
15
|
-
# Default EventsDS xml
|
14
|
+
|
15
|
+
# Default EventsDS xml
|
16
16
|
def self.xml_template
|
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
|
24
24
|
self.versionable = "false"
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# Adds an event to the datastream
|
28
28
|
# @param [String] type a tag used to group events together. Sets the type attribute for the event
|
29
29
|
# @param [String] who who is responsible for this event. Sets the who attribute for the event
|
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
|
-
ev = ng_xml.create_element "event", message,
|
32
|
+
ev = ng_xml.create_element "event", message,
|
33
33
|
:type => type, :who => who, :when => Time.now.xmlschema
|
34
34
|
ng_xml.root.add_child(ev)
|
35
35
|
content_will_change!
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# Finds events with the desired type attribute
|
39
39
|
# @param [String] tag events where type == tag will be returned
|
40
40
|
# @yield [who, timestamp, message] The values of the current event
|
@@ -46,7 +46,7 @@ class EventsDS < ActiveFedora::OmDatastream
|
|
46
46
|
block.call(node['who'], Time.parse(node['when']), node.content)
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
# Returns all the events in the datastream
|
51
51
|
# @yield [type, who, timestamp, message] The values of the current event
|
52
52
|
# @yieldparam [String] type tag for this particular event. Value of the 'type' attribute
|
@@ -58,6 +58,6 @@ class EventsDS < ActiveFedora::OmDatastream
|
|
58
58
|
block.call(node['type'], node['who'], Time.parse(node['when']), node.content)
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
|
+
end
|
62
63
|
end
|
63
|
-
end
|
@@ -9,11 +9,11 @@ module Dor
|
|
9
9
|
# The datastream is packaged using RDF to identify the optional ISO 19139 feature catalog
|
10
10
|
# @see http://www.isotc211.org
|
11
11
|
# @author Darren Hardy
|
12
|
-
class GeoMetadataDS < ActiveFedora::NokogiriDatastream
|
12
|
+
class GeoMetadataDS < ActiveFedora::NokogiriDatastream
|
13
13
|
include SolrDocHelper
|
14
|
-
|
14
|
+
|
15
15
|
attr_accessor :geometryType, :zipName, :purl
|
16
|
-
|
16
|
+
|
17
17
|
# namespaces
|
18
18
|
NS = {
|
19
19
|
:rdf => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
@@ -21,75 +21,74 @@ module Dor
|
|
21
21
|
:gmd => 'http://www.isotc211.org/2005/gmd',
|
22
22
|
:gfc => 'http://www.isotc211.org/2005/gfc'
|
23
23
|
}
|
24
|
-
|
24
|
+
|
25
25
|
# hash with all namespaces
|
26
26
|
XMLNS = Hash[NS.map {|k,v| ["xmlns:#{k}", v]}]
|
27
|
-
|
27
|
+
|
28
28
|
# schema locations
|
29
29
|
NS_XSD = NS.keys.collect {|k| "#{NS[k]} #{NS[k]}/#{k}.xsd"}
|
30
30
|
|
31
31
|
# [Nokogiri::XSLT::Stylesheet] for ISO 19139 to MODS
|
32
32
|
XSLT_GEOMODS = Nokogiri::XSLT(File.read(
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
File.join(
|
34
|
+
File.dirname(__FILE__), 'geo2mods.xsl')))
|
35
|
+
|
36
36
|
XSLT_DC = Nokogiri::XSLT(File.new(
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
File.expand_path(
|
38
|
+
File.dirname(__FILE__) + '/../models/mods2dc.xslt')))
|
39
|
+
|
40
40
|
# @see http://ruby-doc.org/gems/docs/o/om-1.8.0/OM/XML/Document/ClassMethods.html#method-i-set_terminology
|
41
41
|
set_terminology do |t|
|
42
|
-
t.root :path => '/rdf:RDF/rdf:Description/gmd:MD_Metadata',
|
43
|
-
'xmlns:gmd' => NS[:gmd],
|
44
|
-
'xmlns:gco' => NS[:gco],
|
42
|
+
t.root :path => '/rdf:RDF/rdf:Description/gmd:MD_Metadata',
|
43
|
+
'xmlns:gmd' => NS[:gmd],
|
44
|
+
'xmlns:gco' => NS[:gco],
|
45
45
|
'xmlns:rdf' => NS[:rdf]
|
46
46
|
|
47
47
|
t.id_ :path => '/rdf:RDF/rdf:Description[1]/@rdf:about'
|
48
48
|
|
49
49
|
p = './'
|
50
|
-
t.dataset_id
|
51
|
-
t.file_id
|
52
|
-
t.metadata_dt
|
50
|
+
t.dataset_id :path => p + 'gmd:dataSetURI/gco:CharacterString'
|
51
|
+
t.file_id :path => p + 'gmd:fileIdentifier/gco:CharacterString'
|
52
|
+
t.metadata_dt :path => p + 'gmd:dateStamp/gco:Date/text()' # XXX: Allow DateTime
|
53
53
|
t.metadata_language :path => p + 'gmd:MD_Metadata/gmd:language/gmd:LanguageCode[@codeSpace="ISO639-2"]/@codeListValue'
|
54
54
|
|
55
55
|
p = 'gmd:identificationInfo/gmd:MD_DataIdentification/'
|
56
|
-
t.abstract
|
57
|
-
t.purpose
|
56
|
+
t.abstract :path => p + 'gmd:abstract/gco:CharacterString/text()'
|
57
|
+
t.purpose :path => p + 'gmd:purpose/gco:CharacterString/text()'
|
58
58
|
t.publisher :path => p + 'gmd:pointOfContact/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode/@codeListValue="pointOfContact"]/gmd:organisationName/gco:CharacterString/text()'
|
59
59
|
|
60
60
|
p = 'gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/'
|
61
|
-
t.title
|
61
|
+
t.title :path => p + 'gmd:title/gco:CharacterString/text()'
|
62
62
|
t.publish_dt :path => p + 'gmd:date/gmd:CI_Date/gmd:date/gco:Date/text()'
|
63
63
|
t.originator :path => p + 'gmd:citedResponsibleParty/gmd:CI_ResponsibleParty[gmd:role/gmd:CI_RoleCode/@codeListValue="originator"]/gmd:organisationName/gco:CharacterString/text()'
|
64
64
|
|
65
65
|
p = 'gmd:distributionInfo/gmd:MD_Distribution/gmd:distributionFormat/gmd:MD_Format/'
|
66
66
|
t.format :path => p + 'gmd:name/gco:CharacterString/text()'#, :index_as => [:facetable]
|
67
|
-
|
67
|
+
|
68
68
|
p = 'gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/'
|
69
69
|
t.layername :path => p + 'gmd:name/gco:CharacterString/text()'
|
70
|
-
|
70
|
+
|
71
71
|
# XXX should define projection as codeSpace + ':' + code in terminology
|
72
72
|
p = 'gmd:referenceSystemInfo/gmd:MD_ReferenceSystem/gmd:referenceSystemIdentifier/gmd:RS_Identifier/'
|
73
|
-
t.projection
|
73
|
+
t.projection :path => p + 'gmd:code/gco:CharacterString/text()'
|
74
74
|
t.projection_code_space :path => p + 'gmd:codeSpace/gco:CharacterString/text()'
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# @return [Nokogiri::XML::Document] with gmd:MD_Metadata as root node
|
78
78
|
# @raise [Dor::ParameterError] if MD_Metadata is missing
|
79
79
|
def metadata
|
80
80
|
root = ng_xml.xpath('/rdf:RDF/rdf:Description/gmd:MD_Metadata', XMLNS)
|
81
|
-
if root.nil?
|
82
|
-
raise Dor::ParameterError, "Invalid geoMetadata -- missing MD_Metadata: #{root}"
|
81
|
+
if root.nil? || root.empty?
|
82
|
+
raise Dor::ParameterError, "Invalid geoMetadata -- missing MD_Metadata: #{root}"
|
83
83
|
else
|
84
84
|
Nokogiri::XML(root.first.to_xml)
|
85
85
|
end
|
86
86
|
end
|
87
|
-
|
88
|
-
# @return [Nokogiri::XML::Document] with gfc:FC_FeatureCatalogue as root node
|
89
|
-
# or nil if not provided
|
87
|
+
|
88
|
+
# @return [Nokogiri::XML::Document] with gfc:FC_FeatureCatalogue as root node or nil if not provided
|
90
89
|
def feature_catalogue
|
91
90
|
root = ng_xml.xpath('/rdf:RDF/rdf:Description/gfc:FC_FeatureCatalogue', XMLNS)
|
92
|
-
if root.nil?
|
91
|
+
if root.nil? || root.empty?
|
93
92
|
nil # Feature catalog is optional
|
94
93
|
else
|
95
94
|
Nokogiri::XML(root.first.to_xml)
|
@@ -101,7 +100,7 @@ module Dor
|
|
101
100
|
# Includes all possible xmlns for gmd and gfc
|
102
101
|
def self.xml_template
|
103
102
|
Nokogiri::XML::Builder.new do |xml|
|
104
|
-
xml['rdf'].RDF XMLNS,
|
103
|
+
xml['rdf'].RDF XMLNS,
|
105
104
|
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
106
105
|
"xsi:schemaLocation" => NS_XSD.join(' ') do
|
107
106
|
xml['rdf'].Description 'rdf:about' => nil do
|
@@ -122,21 +121,21 @@ module Dor
|
|
122
121
|
# Uses GML SimpleFeatures for the geometry type (e.g., Polygon, LineString, etc.)
|
123
122
|
# @see http://portal.opengeospatial.org/files/?artifact_id=25355
|
124
123
|
#
|
125
|
-
def to_mods(params = {})
|
126
|
-
params = params.merge({
|
124
|
+
def to_mods(params = {})
|
125
|
+
params = params.merge({
|
127
126
|
'geometryType' => "'#{@geometryType.nil?? 'Polygon' : @geometryType}'",
|
128
127
|
'zipName' => "'#{@zipName.nil?? 'data.zip' : @zipName}'",
|
129
128
|
'purl' => "'#{@purl}'"
|
130
129
|
})
|
131
130
|
doc = XSLT_GEOMODS.transform(metadata.document, params.to_a.flatten)
|
132
|
-
unless doc.root
|
131
|
+
unless doc.root && doc.root.children.size > 0
|
133
132
|
raise CrosswalkError, 'to_mods produced incorrect xml'
|
134
133
|
end
|
135
134
|
# ap doc
|
136
|
-
doc.xpath('/mods:mods' +
|
137
|
-
'/mods:subject' +
|
138
|
-
'/mods:cartographics' +
|
139
|
-
'/mods:projection',
|
135
|
+
doc.xpath('/mods:mods' +
|
136
|
+
'/mods:subject' +
|
137
|
+
'/mods:cartographics' +
|
138
|
+
'/mods:projection',
|
140
139
|
'xmlns:mods' => Dor::DescMetadataDS::MODS_NS).each do |e|
|
141
140
|
# Retrieve this mapping from config file
|
142
141
|
case e.content.downcase
|
@@ -149,62 +148,63 @@ module Dor
|
|
149
148
|
doc.xpath('/mods:mods' +
|
150
149
|
'/mods:subject' +
|
151
150
|
'/mods:cartographics' +
|
152
|
-
'/mods:coordinates',
|
151
|
+
'/mods:coordinates',
|
153
152
|
'xmlns:mods' => Dor::DescMetadataDS::MODS_NS).each do |e|
|
154
153
|
e.content = '(' + self.class.to_coordinates_ddmmss(e.content.to_s) + ')'
|
155
154
|
end
|
156
155
|
doc
|
157
156
|
end
|
158
|
-
|
157
|
+
|
159
158
|
def to_dublin_core
|
160
159
|
XSLT_DC.transform(to_mods)
|
161
160
|
end
|
162
|
-
|
161
|
+
|
163
162
|
# @deprecated stub for GeoBlacklight (not Argo -- use to_solr as usual)
|
164
|
-
def to_solr_spatial(solr_doc=
|
163
|
+
def to_solr_spatial(solr_doc = {}, *args)
|
165
164
|
# There are a whole bunch of namespace-related things that can go
|
166
165
|
# wrong with this terminology. Until it's fixed in OM, ignore them all.
|
167
166
|
begin
|
168
|
-
doc = solr_doc#super solr_doc, *args
|
167
|
+
doc = solr_doc # super solr_doc, *args
|
169
168
|
bb = to_bbox
|
170
169
|
ap({:doc => doc, :bb => bb, :self => self}) if $DEBUG
|
170
|
+
# self is required once below, because format is a keyword
|
171
171
|
{
|
172
|
-
:id =>
|
173
|
-
:druid => URI(
|
174
|
-
:file_id_s =>
|
172
|
+
:id => id.first,
|
173
|
+
:druid => URI(id.first).path.gsub(%r{^/}, ''),
|
174
|
+
:file_id_s => file_id.first,
|
175
175
|
:geo_bbox => to_solr_bbox,
|
176
176
|
:geo_data_type_s => 'vector',
|
177
|
-
:geo_format_s => self.format.first,
|
177
|
+
:geo_format_s => self.format.first, # rubocop:disable Style/RedundantSelf
|
178
178
|
:geo_geometry_type_s => 'Polygon',
|
179
|
-
:geo_layername_s => File.basename(
|
179
|
+
:geo_layername_s => File.basename(layername.first, '.shp'),
|
180
180
|
:geo_ne_pt => Dor::GeoMetadataDS.to_wkt([bb.e, bb.n]),
|
181
181
|
:geo_pt => to_solr_centroid,
|
182
182
|
:geo_sw_pt => Dor::GeoMetadataDS.to_wkt([bb.w, bb.s]),
|
183
|
-
:geo_proj =>
|
183
|
+
:geo_proj => projection.first,
|
184
184
|
:dc_coverage_t => to_dc_coverage,
|
185
|
-
:dc_creator_t =>
|
186
|
-
:dc_date_i =>
|
187
|
-
:dc_description_t => [
|
185
|
+
:dc_creator_t => originator.first,
|
186
|
+
:dc_date_i => publish_dt.map {|i| i.to_s[0..3]},
|
187
|
+
:dc_description_t => [abstract.first, purpose.first].join(";\n"),
|
188
188
|
:dc_format_s => 'application/x-esri-shapefile',
|
189
|
-
:dc_language_s =>
|
190
|
-
:dc_title_t =>
|
191
|
-
:text => [
|
189
|
+
:dc_language_s => metadata_language.first,
|
190
|
+
:dc_title_t => title.first,
|
191
|
+
:text => [title.first, abstract.first, purpose.first].join(";\n")
|
192
192
|
}.each do |id, v|
|
193
193
|
::Solrizer::Extractor.insert_solr_field_value(doc, id.to_s, v)
|
194
194
|
end
|
195
195
|
|
196
196
|
return doc
|
197
|
-
rescue
|
197
|
+
rescue
|
198
198
|
solr_doc
|
199
199
|
end
|
200
200
|
end
|
201
|
-
|
202
|
-
# @return [Struct] in minX minY maxX maxY order
|
201
|
+
|
202
|
+
# @return [Struct] in minX minY maxX maxY order
|
203
203
|
# with .w, .e, .n., .s for west, east, north, south as floats
|
204
204
|
def to_bbox
|
205
205
|
params = { 'xmlns:gmd' => NS[:gmd], 'xmlns:gco' => NS[:gco] }
|
206
206
|
bb = metadata.xpath(
|
207
|
-
'//gmd:EX_Extent/gmd:geographicElement' +
|
207
|
+
'//gmd:EX_Extent/gmd:geographicElement' +
|
208
208
|
'/gmd:EX_GeographicBoundingBox', params).first
|
209
209
|
Struct.new(:w, :e, :n, :s).new(
|
210
210
|
bb.xpath('gmd:westBoundLongitude/gco:Decimal', params).text.to_f,
|
@@ -213,17 +213,17 @@ module Dor
|
|
213
213
|
bb.xpath('gmd:southBoundLatitude/gco:Decimal', params).text.to_f
|
214
214
|
)
|
215
215
|
end
|
216
|
-
|
216
|
+
|
217
217
|
# @return [Array<Numeric>] (x y) coordinates of center point - assumes #to_bbox
|
218
218
|
# @see http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
219
219
|
def to_centroid
|
220
220
|
bb = to_bbox
|
221
221
|
[ (bb.w + bb.e)/2, (bb.n + bb.s)/2 ]
|
222
222
|
end
|
223
|
-
|
223
|
+
|
224
224
|
# A lat-lon rectangle can be indexed with 4 numbers in minX minY maxX maxY order:
|
225
|
-
#
|
226
|
-
# <field name="geo">-74.093 41.042 -69.347 44.558</field>
|
225
|
+
#
|
226
|
+
# <field name="geo">-74.093 41.042 -69.347 44.558</field>
|
227
227
|
# <field name="geo">POLYGON((...))</field>
|
228
228
|
#
|
229
229
|
# @param [Symbol] either :solr3 or :solr4
|
@@ -231,7 +231,7 @@ module Dor
|
|
231
231
|
# @see http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
232
232
|
def to_solr_bbox format = :solr4
|
233
233
|
bb = to_bbox
|
234
|
-
|
234
|
+
|
235
235
|
case format
|
236
236
|
when :solr3
|
237
237
|
[bb.w, bb.s, bb.e, bb.n].join(' ')
|
@@ -241,39 +241,39 @@ module Dor
|
|
241
241
|
raise ArgumentError, "Unsupported format #{format}"
|
242
242
|
end
|
243
243
|
end
|
244
|
-
|
244
|
+
|
245
245
|
# @return [String] in Dublin Core Coverage format
|
246
246
|
def to_dc_coverage
|
247
247
|
bb = to_bbox
|
248
248
|
"x.min=#{bb.w} x.max=#{bb.e} y.min=#{bb.s} y.max=#{bb.n}"
|
249
249
|
end
|
250
|
-
|
250
|
+
|
251
251
|
# A lat-lon point for the centroid of the bounding box:
|
252
|
-
#
|
253
|
-
# <field name="geo">69.4325,-78.085007</field>
|
252
|
+
#
|
253
|
+
# <field name="geo">69.4325,-78.085007</field>
|
254
254
|
# <field name="geo">POINT(-78.085007 69.4325)</field>
|
255
255
|
#
|
256
256
|
# @param [Symbol] either :solr3 or :solr4
|
257
257
|
# @return [String] minX minY maxX maxY for :solr3 or POLYGON((...)) for :solr4
|
258
258
|
# @see http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
259
|
-
|
259
|
+
|
260
260
|
# @return [String] (y,x) coordinates of center point matching the LatLonType Solr type
|
261
261
|
# @see http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
|
262
262
|
def to_solr_centroid format = :solr4
|
263
263
|
x, y = to_centroid
|
264
|
-
|
264
|
+
|
265
265
|
case format
|
266
266
|
when :solr3
|
267
|
-
[y,x].join(',') # for solr.LatLonType
|
267
|
+
[y, x].join(',') # for solr.LatLonType
|
268
268
|
when :solr4
|
269
269
|
Dor::GeoMetadataDS.to_wkt [x, y]
|
270
270
|
else
|
271
271
|
raise ArgumentError, "Unsupported format #{format}"
|
272
272
|
end
|
273
273
|
end
|
274
|
-
|
275
|
-
|
276
|
-
|
274
|
+
|
275
|
+
# Class Methods
|
276
|
+
|
277
277
|
# @param [Array<Numeric>] (x,y) coordinates for point or bounding box
|
278
278
|
# @return [String] WKT for point or rectangle
|
279
279
|
def self.to_wkt xy, xy2 = nil
|
@@ -287,23 +287,23 @@ module Dor
|
|
287
287
|
"POINT(#{xy[0]} #{xy[1]})"
|
288
288
|
end
|
289
289
|
end
|
290
|
-
|
290
|
+
|
291
291
|
# Convert to MARC 255 DD into DDMMSS
|
292
292
|
# westernmost longitude, easternmost longitude, northernmost latitude, and southernmost latitude
|
293
293
|
# e.g., -109.758319 -- -88.990844/48.999336 -- 29.423028
|
294
294
|
def self.to_coordinates_ddmmss s
|
295
295
|
w, e, n, s = s.scanf('%f -- %f/%f -- %f')
|
296
|
-
raise ArgumentError, "Out of bounds latitude: #{n} #{s}"
|
297
|
-
raise ArgumentError, "Out of bounds longitude: #{w} #{e}" unless w >= -180
|
296
|
+
raise ArgumentError, "Out of bounds latitude: #{n} #{s}" unless n >= -90 && n <= 90 && s >= -90 && s <= 90
|
297
|
+
raise ArgumentError, "Out of bounds longitude: #{w} #{e}" unless w >= -180 && w <= 180 && e >= -180 && e <= 180
|
298
298
|
w = "#{w < 0 ? 'W' : 'E'} #{Dor::GeoMetadataDS::dd2ddmmss_abs w}"
|
299
299
|
e = "#{e < 0 ? 'W' : 'E'} #{Dor::GeoMetadataDS::dd2ddmmss_abs e}"
|
300
300
|
n = "#{n < 0 ? 'S' : 'N'} #{Dor::GeoMetadataDS::dd2ddmmss_abs n}"
|
301
301
|
s = "#{s < 0 ? 'S' : 'N'} #{Dor::GeoMetadataDS::dd2ddmmss_abs s}"
|
302
302
|
"#{w}--#{e}/#{n}--#{s}"
|
303
303
|
end
|
304
|
-
|
304
|
+
|
305
305
|
# Convert DD.DD to DD MM SS.SS
|
306
|
-
# e.g.,
|
306
|
+
# e.g.,
|
307
307
|
# * -109.758319 => 109°45ʹ29.9484ʺ
|
308
308
|
# * 48.999336 => 48°59ʹ57.609ʺ
|
309
309
|
E = 1
|
@@ -312,13 +312,13 @@ module Dor
|
|
312
312
|
QDEG = "\u00B0"
|
313
313
|
def self.dd2ddmmss_abs f
|
314
314
|
dd = f.to_f.abs
|
315
|
-
d
|
316
|
-
mm = (
|
317
|
-
m
|
318
|
-
s
|
319
|
-
m, s = m+1, 0 if s >= 60
|
320
|
-
d, m = d+1, 0 if m >= 60
|
321
|
-
"#{d}#{QDEG}" + (m>0 ? "#{m}#{QMIN}" : '') + (s>0 ? "#{s}#{QSEC}" : '')
|
315
|
+
d = dd.floor
|
316
|
+
mm = (dd - d) * 60
|
317
|
+
m = mm.floor
|
318
|
+
s = ((mm - mm.floor) * 60).round
|
319
|
+
m, s = m + 1, 0 if s >= 60
|
320
|
+
d, m = d + 1, 0 if m >= 60
|
321
|
+
"#{d}#{QDEG}" + (m > 0 ? "#{m}#{QMIN}" : '') + (s > 0 ? "#{s}#{QSEC}" : '')
|
322
322
|
end
|
323
323
|
end
|
324
324
|
end
|