cul_scv_hydra 0.22.6 → 0.22.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
- data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
- data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
- data/app/controllers/concerns/cul/scv/hydra/controller.rb +3 -19
- data/app/controllers/concerns/cul/scv/hydra/resolver.rb +2 -65
- data/app/controllers/concerns/cul/scv/hydra/thumbnails.rb +3 -59
- data/app/models/concept.rb +1 -1
- data/app/models/concerns/cul/hydra/models.rb +24 -0
- data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
- data/app/models/concerns/cul/hydra/models/common.rb +220 -0
- data/app/models/concerns/cul/hydra/models/image_resource.rb +78 -0
- data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
- data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
- data/app/models/concerns/cul/scv/hydra/models.rb +1 -13
- data/app/models/concerns/cul/scv/hydra/models/aggregator.rb +1 -116
- data/app/models/concerns/cul/scv/hydra/models/common.rb +1 -213
- data/app/models/concerns/cul/scv/hydra/models/image_resource.rb +3 -75
- data/app/models/concerns/cul/scv/hydra/models/linkable_resources.rb +3 -105
- data/app/models/concerns/cul/scv/hydra/models/resource.rb +2 -83
- data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
- data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
- data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
- data/app/models/cul/scv/hydra/datastreams/dc_metadata.rb +5 -104
- data/app/models/cul/scv/hydra/datastreams/mods_document.rb +5 -178
- data/app/models/cul/scv/hydra/datastreams/struct_metadata.rb +5 -174
- data/app/models/dc_document.rb +1 -1
- data/app/models/generic_aggregator.rb +5 -5
- data/app/models/generic_object.rb +2 -2
- data/app/models/generic_resource.rb +4 -4
- data/app/models/mets_structured_aggregator.rb +2 -2
- data/app/models/resource.rb +3 -3
- data/app/models/resource_aggregator.rb +3 -3
- data/fixtures/spec/CUL_MODS/mods-subjects.xml +24 -0
- data/lib/cul_hydra.rb +18 -0
- data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
- data/lib/cul_hydra/controllers.rb +13 -0
- data/lib/cul_hydra/controllers/aggregates.rb +93 -0
- data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
- data/lib/cul_hydra/controllers/catalog.rb +12 -0
- data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
- data/lib/cul_hydra/controllers/datastreams.rb +145 -0
- data/lib/cul_hydra/controllers/helpers.rb +10 -0
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/active_fedora_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/application_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/dc_metadata_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_assets_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_autocomplete_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_uploader_helper_behavior.rb +1 -1
- data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/resources_helper_behavior.rb +1 -1
- data/lib/cul_hydra/controllers/resources.rb +161 -0
- data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
- data/lib/cul_hydra/controllers/suggestions.rb +126 -0
- data/lib/cul_hydra/controllers/terms.rb +205 -0
- data/lib/cul_hydra/engine.rb +31 -0
- data/lib/cul_hydra/fedora.rb +41 -0
- data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
- data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
- data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
- data/lib/cul_hydra/indexer.rb +84 -0
- data/lib/cul_hydra/om.rb +7 -0
- data/lib/cul_hydra/om/standard_mods.rb +115 -0
- data/lib/cul_hydra/risearch_members.rb +92 -0
- data/lib/cul_hydra/solrizer.rb +10 -0
- data/lib/cul_hydra/solrizer/extractor.rb +27 -0
- data/lib/cul_hydra/solrizer/mods_fieldable.rb +435 -0
- data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
- data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
- data/lib/{cul_scv_hydra/solrizer/field_mapper.rb → cul_hydra/solrizer_patch.rb} +0 -0
- data/lib/cul_hydra/version.rb +8 -0
- data/lib/cul_hydra/version.rb~ +8 -0
- data/lib/cul_scv_fedora/dummy_object.rb +1 -30
- data/lib/cul_scv_fedora/rubydora_patch.rb +3 -7
- data/lib/cul_scv_fedora/url_helper_behavior.rb +3 -23
- data/lib/cul_scv_hydra.rb +5 -32
- data/lib/cul_scv_hydra/access_controls_enforcement.rb +3 -50
- data/lib/cul_scv_hydra/controllers.rb +10 -10
- data/lib/cul_scv_hydra/controllers/aggregates.rb +1 -86
- data/lib/cul_scv_hydra/controllers/aggregator_controller_helper.rb +4 -23
- data/lib/cul_scv_hydra/controllers/catalog.rb +5 -9
- data/lib/cul_scv_hydra/controllers/content_aggregators.rb +4 -77
- data/lib/cul_scv_hydra/controllers/datastreams.rb +3 -140
- data/lib/cul_scv_hydra/controllers/helpers.rb +44 -8
- data/lib/cul_scv_hydra/controllers/resources.rb +4 -157
- data/lib/cul_scv_hydra/controllers/static_image_aggregators.rb +4 -100
- data/lib/cul_scv_hydra/controllers/suggestions.rb +4 -122
- data/lib/cul_scv_hydra/controllers/terms.rb +4 -201
- data/lib/cul_scv_hydra/engine.rb +1 -1
- data/lib/cul_scv_hydra/indexer.rb +3 -82
- data/lib/cul_scv_hydra/om.rb +2 -2
- data/lib/cul_scv_hydra/om/standard_mods.rb +1 -108
- data/lib/cul_scv_hydra/risearch_members.rb +4 -89
- data/lib/cul_scv_hydra/solrizer.rb +5 -6
- data/lib/cul_scv_hydra/solrizer/extractor.rb +1 -25
- data/lib/cul_scv_hydra/solrizer/scv_mods_fieldable.rb +4 -429
- data/lib/cul_scv_hydra/solrizer/terminology_based_solrizer.rb +4 -32
- data/lib/cul_scv_hydra/solrizer/value_mapper.rb +1 -44
- data/lib/cul_scv_hydra/version.rb +5 -5
- data/lib/tasks/index.rake +2 -2
- data/lib/tasks/transform.rake +23 -0
- metadata +55 -12
@@ -1,109 +1,10 @@
|
|
1
1
|
require 'active-fedora'
|
2
2
|
module Cul
|
3
|
-
module Scv
|
4
|
-
module Hydra
|
5
|
-
module Datastreams
|
6
|
-
class DCMetadata < ::
|
7
|
-
|
8
|
-
after_save :action_after_save
|
9
|
-
set_terminology do |t|
|
10
|
-
t.root(:path=>"dc", :namespace_prefix=>"oai_dc",
|
11
|
-
"xmlns:oai_dc"=>"http://www.openarchives.org/OAI/2.0/oai_dc/",
|
12
|
-
"xmlns:dc"=>"http://purl.org/dc/elements/1.1/",
|
13
|
-
:schema=>"http://www.openarchives.org/OAI/2.0/oai_dc.xsd")
|
14
|
-
t.dc_contributor(:path=>"contributor",
|
15
|
-
:namespace_prefix=>"dc",
|
16
|
-
:index_as=>[:displayable, :searchable])
|
17
|
-
t.dc_coverage(:path=>"coverage",
|
18
|
-
:namespace_prefix=>"dc",
|
19
|
-
:index_as=>[:displayable, :searchable])
|
20
|
-
t.dc_creator(:path=>"creator",
|
21
|
-
:namespace_prefix=>"dc",
|
22
|
-
:index_as=>[:displayable, :searchable])
|
23
|
-
t.dc_date(:path=>"date",
|
24
|
-
:namespace_prefix=>"dc",
|
25
|
-
:index_as=>[:displayable, :searchable])
|
26
|
-
t.dc_description(:path=>"description",
|
27
|
-
:namespace_prefix=>"dc",
|
28
|
-
:index_as=>[:displayable, :searchable])
|
29
|
-
t.dc_format(:path=>"format",
|
30
|
-
:namespace_prefix=>"dc",
|
31
|
-
:index_as=>[:displayable, :facetable])
|
32
|
-
t.dc_identifier(:path=>"identifier",
|
33
|
-
:namespace_prefix=>"dc",
|
34
|
-
:type=>:string,
|
35
|
-
:index_as=>[:symbol])
|
36
|
-
t.dc_language(:path=>"language",
|
37
|
-
:namespace_prefix=>"dc",
|
38
|
-
:index_as=>[:displayable, :searchable])
|
39
|
-
t.dc_publisher(:path=>"publisher",
|
40
|
-
:namespace_prefix=>"dc",
|
41
|
-
:index_as=>[:displayable, :searchable])
|
42
|
-
t.dc_relation(:path=>"relation",
|
43
|
-
:namespace_prefix=>"dc",
|
44
|
-
:index_as=>[:displayable, :searchable])
|
45
|
-
t.dc_rights(:path=>"rights",
|
46
|
-
:namespace_prefix=>"dc",
|
47
|
-
:index_as=>[:displayable, :searchable])
|
48
|
-
t.dc_source(:path=>"source",
|
49
|
-
:namespace_prefix=>"dc",
|
50
|
-
:index_as=>[:displayable, :searchable])
|
51
|
-
t.dc_subject(:path=>"subject",
|
52
|
-
:namespace_prefix=>"dc",
|
53
|
-
:index_as=>[:displayable, :searchable])
|
54
|
-
t.dc_title(:path=>"title",
|
55
|
-
:namespace_prefix=>"dc",
|
56
|
-
:index_as=>[:displayable, :searchable])
|
57
|
-
t.dc_type(:path=>"type",
|
58
|
-
:namespace_prefix=>"dc",
|
59
|
-
:index_as=>[:displayable, :facetable])
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.xml_template
|
63
|
-
|
64
|
-
Nokogiri::XML::Document.parse(<<-src
|
65
|
-
<oai_dc:dc
|
66
|
-
xmlns:oai_dc='http://www.openarchives.org/OAI/2.0/oai_dc/'
|
67
|
-
xmlns:dc='http://purl.org/dc/elements/1.1/'
|
68
|
-
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
|
69
|
-
xsi:schemaLocation='http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd'></oai_dc:dc>
|
70
|
-
src
|
71
|
-
)
|
72
|
-
end
|
73
|
-
# Because FCRepo 3.5+ modifies DC on saves (to ensure that PID is a dc:identifier value),
|
74
|
-
# this datastream's content must be reloaded after saves
|
75
|
-
def action_after_save
|
76
|
-
@content = nil
|
77
|
-
@ng_xml = nil
|
78
|
-
remove_instance_variable(:@ng_xml)
|
79
|
-
end
|
80
|
-
|
81
|
-
def prefix
|
82
|
-
#if ::ActiveFedora::VERSION >= '8'
|
83
|
-
# Rails.logger.warn("the prefix method of #{self.class.name} was overriden to maintain backwards compatibility")
|
84
|
-
#end
|
85
|
-
''
|
86
|
-
end
|
87
|
-
|
88
|
-
def method_missing method, *args
|
89
|
-
query = false
|
90
|
-
_mname = method.id2name
|
91
|
-
if _mname[-1,1] == '?'
|
92
|
-
query = true
|
93
|
-
_mname = _mname[0,_mname.length-1]
|
94
|
-
end
|
95
|
-
_msym = _mname.to_sym
|
96
|
-
has_term = self.class.terminology.has_term?(_msym)
|
97
|
-
return false if query and not has_term
|
98
|
-
_r = super(_mname.to_sym, *args)
|
99
|
-
if query
|
100
|
-
_r.length > 0
|
101
|
-
else
|
102
|
-
_r
|
3
|
+
module Scv
|
4
|
+
module Hydra
|
5
|
+
module Datastreams
|
6
|
+
class DCMetadata < Cul::Hydra::Datastreams::DCMetadata; end
|
7
|
+
end
|
103
8
|
end
|
104
9
|
end
|
105
10
|
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
@@ -2,184 +2,11 @@ require 'active-fedora'
|
|
2
2
|
require 'solrizer'
|
3
3
|
require 'cul_scv_hydra/solrizer'
|
4
4
|
module Cul
|
5
|
-
module Scv
|
6
|
-
module Hydra
|
7
|
-
module Datastreams
|
8
|
-
class ModsDocument < ::
|
9
|
-
|
10
|
-
include Cul::Scv::Hydra::Solrizer::TerminologyBasedSolrizer
|
11
|
-
include Cul::Scv::Hydra::Solrizer::ScvModsFieldable
|
12
|
-
|
13
|
-
#map_field("lib_repo_sim", :marc_to_facet)
|
14
|
-
#map_field("lib_repo_long_ssim", :marc_to_display)
|
15
|
-
#map_field("lib_project_sim", :project_to_facet)
|
16
|
-
|
17
|
-
set_terminology do |t|
|
18
|
-
t.root(:path=>"mods",
|
19
|
-
:xmlns=>"http://www.loc.gov/mods/v3",
|
20
|
-
:schema=>"http://www.loc.gov/standards/mods/v3/mods-3-4.xsd") {
|
21
|
-
}
|
22
|
-
|
23
|
-
t.main_title_info(:path=>'titleInfo', :index_as=>[], :attributes=>{:type=>:none}){
|
24
|
-
t.non_sort(:path=>"nonSort", :index_as=>[])
|
25
|
-
t.main_title(:path=>"title", :index_as=>[])
|
26
|
-
}
|
27
|
-
|
28
|
-
t.title(:proxy=>[:mods, :main_title_info, :main_title], :type=>:string,
|
29
|
-
:index_as=>[:searchable, :sortable])
|
30
|
-
t.title_display(:proxy=>[:mods, :main_title_info], :type=>:string,
|
31
|
-
:index_as=>[:displayable])
|
32
|
-
|
33
|
-
t.search_title_info(:path=>'titleInfo', :index_as=>[]){
|
34
|
-
t.search_title(:path=>'title', :index_as=>[:textable])
|
35
|
-
}
|
36
|
-
t.part(:path=>"relatedItem", :attributes=>{:type=>"constituent"}, :index_as=>[]){
|
37
|
-
t.part_title_info(:path=>'titleInfo', :index_as=>[]){
|
38
|
-
t.lib_part(:path=>'title',:index_as=>[])
|
39
|
-
}
|
40
|
-
}
|
41
|
-
t.project(:path=>"relatedItem", :attributes=>{:type=>"host", :displayLabel=>"Project"}, :index_as=>[]){
|
42
|
-
t.project_title_info(:path=>'titleInfo', :index_as=>[]){
|
43
|
-
t.lib_project(:path=>'title',:index_as=>[])
|
44
|
-
}
|
45
|
-
}
|
46
|
-
t.collection(:path=>"relatedItem", :attributes=>{:type=>"host", :displayLabel=>"Collection"}, :index_as=>[]){
|
47
|
-
t.collection_title_info(:path=>'titleInfo', :index_as=>[]){
|
48
|
-
t.lib_collection(:path=>'title', :index_as=>[])
|
49
|
-
}
|
50
|
-
}
|
51
|
-
t.lib_project(:proxy=>[:project,:project_title_info], :index_as=>[:project_textable])
|
52
|
-
t.lib_collection(:proxy=>[:collection,:collection_title_info], :index_as=>[:displayable])
|
53
|
-
t.lib_part(:proxy=>[:part,:part_title_info], :index_as=>[:displayable, :textable])
|
54
|
-
# pattern matches
|
55
|
-
t.identifier(:path=>"identifier", :attributes=>{:type=>"local"}, :type=>:string, :index_as=>[:symbol, :textable])
|
56
|
-
t.clio(:path=>"identifier", :attributes=>{:type=>"CLIO"}, :data_type=>:symbol, :index_as=>[:symbol, :textable])
|
57
|
-
t.abstract(:index_as=>[:displayable, :textable])
|
58
|
-
t.table_of_contents(:path=>"tableOfContents", :index_as=>[:displayable, :textable])
|
59
|
-
t.subject(:index_as=>[:textable]){
|
60
|
-
t.topic(:index_as=>[:facetable, :displayable])
|
61
|
-
t.geographic(:index_as=>[:facetable])
|
62
|
-
}
|
63
|
-
t.type_of_resource(:path=>"typeOfResource", :index_as=>[:displayable])
|
64
|
-
t.physical_description(:path=>"physicalDescription", :index_as=>[]){
|
65
|
-
t.form_marc(:path=>"form", :attributes=>{:authority=>"marcform"}, :index_as=>[:displayable])
|
66
|
-
t.form_aat(:path=>"form", :attributes=>{:authority=>"aat"}, :index_as=>[:displayable, :facetable])
|
67
|
-
t.form_local(:path=>"form", :attributes=>{:authority=>"local"}, :index_as=>[:displayable, :facetable])
|
68
|
-
t.form(:attributes=>{:authority=>:none}, :index_as=>[:displayable])
|
69
|
-
t.form_nomarc(:path=>"form[@authority !='marcform']", :index_as=>[])
|
70
|
-
t.extent(:path=>"extent", :index_as=>[:searchable, :displayable])
|
71
|
-
t.reformatting_quality(:path=>"reformattingQuality", :index_as=>[:displayable])
|
72
|
-
t.internet_media_type(:path=>"internetMediaType", :index_as=>[:displayable])
|
73
|
-
t.digital_origin(:path=>"digitalOrigin", :index_as=>[:displayable])
|
74
|
-
}
|
75
|
-
t.lib_format(:proxy=>[:physical_description, :form_nomarc], :index_as=>[:displayable, :facetable, :textable])
|
76
|
-
t.location(:path=>"location", :index_as=>[]){
|
77
|
-
t.repo_text(:path=>"physicalLocation",:attributes=>{:authority=>:none}, :index_as=>[])
|
78
|
-
t.lib_repo(:path=>"physicalLocation",
|
79
|
-
:attributes=>{:authority=>"marcorg"},
|
80
|
-
:index_as=>[:textable])
|
81
|
-
t.shelf_locator(:path=>"shelfLocator", :index_as=>[:textable, :displayable])
|
82
|
-
t.sublocation(:path=>"sublocation", :index_as=>[:textable, :displayable])
|
83
|
-
t.url
|
84
|
-
}
|
85
|
-
t.top_level_location_url(:proxy=>[:mods, :location, :url])
|
86
|
-
t.lib_repo(:proxy=>[:location, :lib_repo], :type=>:text,
|
87
|
-
:index_as=>[:marc_code_textable])
|
88
|
-
t.name_usage_primary(
|
89
|
-
:path=>'name',:attributes=>{:usage=>'primary'},
|
90
|
-
:index_as=>[]){
|
91
|
-
t.name_part(:path=>'namePart', :index_as=>[])
|
92
|
-
}
|
93
|
-
t.primary_name(proxy: [:name_usage_primary,:name_part], index_as: :facetable)
|
94
|
-
#t.name_corporate(
|
95
|
-
# :path=>'name',:attributes=>{:type=>'corporate'},
|
96
|
-
# :index_as=>[:facetable, :displayable],
|
97
|
-
# :variant_of=>{:field_base=>:lib_name}){
|
98
|
-
# t.name_part(
|
99
|
-
# :path=>'namePart',
|
100
|
-
# :index_as=>[])
|
101
|
-
#}
|
102
|
-
t.note(:path=>"note", :index_as=>[:textable])
|
103
|
-
t.access_condition(:path=>"accessCondition", :attributes=>{:type=>"useAndReproduction"}, :index_as => [:searchable, :symbol])
|
104
|
-
t.record_info(:path=>"recordInfo", :index_as=>[]) {
|
105
|
-
t.record_creation_date(:path=>"recordCreationDate",:attributes=>{:encoding=>"w3cdtf"}, :index_as=>[])
|
106
|
-
t.record_content_source(:path=>"recordContentSource",:attributes=>{:authority=>"marcorg"}, :index_as=>[])
|
107
|
-
t.language_of_cataloging(:path=>"languageOfCataloging", :index_as=>[]){
|
108
|
-
t.language_term(:path=>"languageTerm", :index_as=>[], :attributes=>{:type=>:none})
|
109
|
-
t.language_code(:path=>"languageTerm",:attributes=>{:type=>'code',:authority=>"iso639-2b"}, :index_as=>[])
|
110
|
-
}
|
111
|
-
t.record_origin(:path=>"recordOrigin", :index_as=>[])
|
112
|
-
}
|
113
|
-
t.language_term(:proxy=>[:record_info, :language_of_cataloging, :language_term])
|
114
|
-
t.language_code(:proxy=>[:record_info, :language_of_cataloging, :language_code])
|
115
|
-
|
116
|
-
t.language(:index_as=>[]){
|
117
|
-
t.language_term_text(:path=>"languageTerm", :attributes=>{:authority=>'iso639-2b',:type=>'text'}, :index_as=>[:symbol, :textable])
|
118
|
-
t.language_term_code(:path=>"languageTerm", :attributes=>{:authority=>'iso639-2b',:type=>'code'}, :index_as=>[:symbol, :textable])
|
119
|
-
}
|
120
|
-
|
121
|
-
t.origin_info(:path=>"originInfo", :index_as=>[]){
|
122
|
-
t.date_issued(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes'}, :index_as=>[:displayable, :textable])
|
123
|
-
t.date_issued_start(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes',:point=>'start'}, :index_as=>[:displayable, :textable])
|
124
|
-
t.date_issued_end(:path=>"dateIssued", :attributes=>{:encoding=>'w3cdtf',:point=>'end'}, :index_as=>[:displayable, :textable])
|
125
|
-
t.date_issued_textual(:path=>"dateIssued", :attributes=>{:encoding=>:none, :keyDate=>:none}, :index_as=>[:textable])
|
126
|
-
|
127
|
-
t.date_created(:path=>"dateCreated", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes'}, :index_as=>[:displayable, :textable])
|
128
|
-
t.date_created_start(:path=>"dateCreated", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes',:point=>'start'}, :index_as=>[:displayable, :textable])
|
129
|
-
t.date_created_end(:path=>"dateCreated", :attributes=>{:encoding=>'w3cdtf',:point=>'end'}, :index_as=>[:displayable, :textable])
|
130
|
-
t.date_created_textual(:path=>"dateCreated", :attributes=>{:encoding=>:none, :keyDate=>:none}, :index_as=>[:textable])
|
131
|
-
|
132
|
-
t.date_other(:path=>"dateOther", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes'}, :index_as=>[:displayable, :textable])
|
133
|
-
t.date_other_start(:path=>"dateOther", :attributes=>{:encoding=>'w3cdtf',:keyDate=>'yes',:point=>'start'}, :index_as=>[:displayable, :textable])
|
134
|
-
t.date_other_end(:path=>"dateOther", :attributes=>{:encoding=>'w3cdtf',:point=>'end'}, :index_as=>[:displayable, :textable])
|
135
|
-
t.date_other_textual(:path=>"dateOther", :attributes=>{:encoding=>:none, :keyDate=>:none}, :index_as=>[:textable])
|
136
|
-
|
137
|
-
t.publisher(:index_as=>[:displayable])
|
138
|
-
t.edition(:index_as=>[:displayable])
|
139
|
-
}
|
140
|
-
t.lib_publisher(:proxy=>[:mods, :origin_info, :publisher], :index_as=>[:displayable])
|
141
|
-
end
|
142
|
-
|
143
|
-
def self.xml_template
|
144
|
-
builder = Nokogiri::XML::Builder.new do |xml|
|
145
|
-
xml.mods(:version=>"3.4",
|
146
|
-
"xmlns"=>"http://www.loc.gov/mods/v3",
|
147
|
-
"xmlns:xlink"=>"http://www.w3.org/1999/xlink",
|
148
|
-
"xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance"){
|
149
|
-
}
|
150
|
-
end
|
151
|
-
builder.doc.encoding = 'UTF-8'
|
152
|
-
# for some reason, this is the only way to get an equivalent nokogiri root node; the attribute can't be in the original builder call
|
153
|
-
builder.doc.root["xsi:schemaLocation"] = 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'
|
154
|
-
return builder.doc
|
155
|
-
end
|
156
|
-
|
157
|
-
def prefix
|
158
|
-
#if ::ActiveFedora::VERSION >= '8'
|
159
|
-
# Rails.logger.warn("the prefix method of #{self.class.name} was overriden to maintain backwards compatibility")
|
160
|
-
#end
|
161
|
-
''
|
162
|
-
end
|
163
|
-
|
164
|
-
def method_missing method, *args
|
165
|
-
query = false
|
166
|
-
_mname = method.id2name
|
167
|
-
if _mname[-1,1] == '?'
|
168
|
-
query = true
|
169
|
-
_mname = _mname[0,_mname.length-1]
|
170
|
-
end
|
171
|
-
_msym = _mname.to_sym
|
172
|
-
has_term = self.class.terminology.has_term?(_msym)
|
173
|
-
return false if query and not has_term
|
174
|
-
_r = super(_mname.to_sym, *args)
|
175
|
-
if query
|
176
|
-
_r.length > 0
|
177
|
-
else
|
178
|
-
_r
|
5
|
+
module Scv
|
6
|
+
module Hydra
|
7
|
+
module Datastreams
|
8
|
+
class ModsDocument < Cul::Hydra::Datastreams::ModsDocument; end
|
9
|
+
end
|
179
10
|
end
|
180
11
|
end
|
181
12
|
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
@@ -1,178 +1,9 @@
|
|
1
1
|
module Cul
|
2
|
-
module Scv
|
3
|
-
module Hydra
|
4
|
-
module Datastreams
|
5
|
-
class StructMetadata < ::
|
6
|
-
include ::ActiveFedora::Datastreams::NokogiriDatastreams
|
7
|
-
|
8
|
-
def self.default_attributes
|
9
|
-
super.merge(:controlGroup => 'M', :mimeType => 'text/xml')
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.xml_template
|
13
|
-
Nokogiri::XML::Document.parse("<mets:structMap xmlns:mets=\"http://www.loc.gov/METS/\">")
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.div_template(prefix="mets")
|
17
|
-
prefix.nil? ? '<div/>' : "<#{prefix}:div/>"
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(digital_object=nil, dsid=nil, options={})
|
21
|
-
super
|
22
|
-
end
|
23
|
-
|
24
|
-
# Indicates that this datastream has metadata content.
|
25
|
-
# @return true
|
26
|
-
def metadata?
|
27
|
-
true
|
28
|
-
end
|
29
|
-
|
30
|
-
def autocreate?
|
31
|
-
changed_attributes.has_key? :profile
|
32
|
-
end
|
33
|
-
|
34
|
-
def label=(value)
|
35
|
-
struct_map["LABEL"] = value
|
36
|
-
ng_xml_will_change!
|
37
|
-
end
|
38
|
-
|
39
|
-
def label
|
40
|
-
struct_map["LABEL"]
|
41
|
-
end
|
42
|
-
|
43
|
-
def type=(value)
|
44
|
-
struct_map["TYPE"] = value
|
45
|
-
ng_xml_will_change!
|
46
|
-
end
|
47
|
-
|
48
|
-
def type
|
49
|
-
struct_map["TYPE"]
|
50
|
-
end
|
51
|
-
|
52
|
-
def prefix
|
53
|
-
prefix = nil
|
54
|
-
ng_xml.namespaces.each do |p, href|
|
55
|
-
prefix = p.sub(/xmlns:/,'') if href == "http://www.loc.gov/METS/"
|
56
|
-
end
|
57
|
-
prefix
|
58
|
-
end
|
59
|
-
|
60
|
-
def struct_map
|
61
|
-
prefix = self.prefix
|
62
|
-
path = prefix.nil? ? 'xmlns:structMap' : "#{prefix}:structMap"
|
63
|
-
ng_xml.xpath(path, ng_xml.namespaces).first
|
64
|
-
end
|
65
|
-
|
66
|
-
def create_div_node(parent=nil, atts={})
|
67
|
-
if parent.nil?
|
68
|
-
parent = struct_map
|
69
|
-
end
|
70
|
-
divNode = parent.add_child(StructMetadata.div_template(parent.namespace.prefix)).first
|
71
|
-
[:label, :order, :contentids]. each do |key|
|
72
|
-
divNode[key.to_s.upcase] = atts[key].to_s if atts.has_key? key
|
73
|
-
end
|
74
|
-
ng_xml_will_change! if (divNode.document == ng_xml.document)
|
75
|
-
divNode
|
76
|
-
end
|
77
|
-
|
78
|
-
def divs_with_attribute(descend=true, name=nil, value=nil)
|
79
|
-
prefix = self.prefix || 'xmlns'
|
80
|
-
xpath = descend ? "//#{prefix}:div" : "/#{prefix}:structMap/#{prefix}:div"
|
81
|
-
if !name.nil?
|
82
|
-
xpath << "[@#{name}"
|
83
|
-
if !value.nil?
|
84
|
-
xpath << "='#{value}'"
|
2
|
+
module Scv
|
3
|
+
module Hydra
|
4
|
+
module Datastreams
|
5
|
+
class StructMetadata < Cul::Hydra::Datastreams::StructMetadata; end
|
85
6
|
end
|
86
|
-
xpath << ']'
|
87
7
|
end
|
88
|
-
ng_xml.xpath(xpath, ng_xml.namespaces)
|
89
|
-
end
|
90
|
-
|
91
|
-
def first_ordered_content_div
|
92
|
-
divs_with_contentids_attr = self.divs_with_attribute(true, 'CONTENTIDS')
|
93
|
-
sorted_divs_with_contentids_attr = divs_with_contentids_attr.sort_by{ |node|
|
94
|
-
node.attr("ORDER").to_i
|
95
|
-
}
|
96
|
-
return sorted_divs_with_contentids_attr.first
|
97
|
-
end
|
98
|
-
|
99
|
-
# a convenience method for setting attributes and creating divs (if necessary) for R/V structure
|
100
|
-
# returns the mets:structMap node
|
101
|
-
def recto_verso!
|
102
|
-
self.type= 'physical' unless self.type == 'physical'
|
103
|
-
self.label= 'Sides' unless self.label == 'Sides'
|
104
|
-
create_div_node struct_map, {:order=>'1'} unless divs_with_attribute(false,'ORDER','1').first
|
105
|
-
create_div_node struct_map, {:order=>'2'} unless divs_with_attribute(false,'ORDER','2').first
|
106
|
-
if (div = divs_with_attribute(false,'ORDER','1').first)
|
107
|
-
div['LABEL'] = 'Recto' unless div['LABEL'] == 'Recto'
|
108
|
-
end
|
109
|
-
if (div = divs_with_attribute(false,'ORDER','2').first)
|
110
|
-
div['LABEL'] = 'Verso' unless div['LABEL'] == 'Verso'
|
111
|
-
end
|
112
|
-
struct_map
|
113
|
-
end
|
114
|
-
|
115
|
-
def recto
|
116
|
-
divs_with_attribute(false, 'LABEL', 'Recto').first
|
117
|
-
end
|
118
|
-
|
119
|
-
def verso
|
120
|
-
divs_with_attribute(false, 'LABEL', 'Verso').first
|
121
|
-
end
|
122
|
-
|
123
|
-
def to_solr(doc={})
|
124
|
-
doc[:structured_bsi] = (has_content? ? 'true' : 'false')
|
125
|
-
doc
|
126
|
-
end
|
127
|
-
|
128
|
-
def proxies
|
129
|
-
divs = divs_with_attribute(true)
|
130
|
-
graph_context_uri = RDF::URI("info:fedora/#{self.pid}")
|
131
|
-
file_system = self.type.eql?(RDF::NFO[:"#Filesystem"].to_s)
|
132
|
-
divs.collect do |div|
|
133
|
-
proxy_uri_chain = proxy_uri_chain_for(div)
|
134
|
-
proxy_resource_uri = proxy_uri_chain.pop
|
135
|
-
if div['CONTENTIDS']
|
136
|
-
subclass = file_system ?
|
137
|
-
NFO::FileDataObject : SC::Canvas
|
138
|
-
proxy = subclass.new(proxy_resource_uri, graph_context_uri)
|
139
|
-
proxy.proxyFor = RDF::URI(div['CONTENTIDS'])
|
140
|
-
else
|
141
|
-
subclass = file_system ?
|
142
|
-
NFO::Folder : SC::Sequence
|
143
|
-
proxy = subclass.new(proxy_resource_uri, graph_context_uri)
|
144
|
-
end
|
145
|
-
if div.parent and div.parent.name == 'div'
|
146
|
-
proxy.belongsToContainer = proxy_uri_for(div.parent)
|
147
|
-
end
|
148
|
-
proxy.isPartOf = proxy_uri_chain unless proxy_uri_chain.empty?
|
149
|
-
proxy.index = div['ORDER']
|
150
|
-
proxy.label = div['LABEL']
|
151
|
-
proxy
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
private
|
156
|
-
def ancestors(node)
|
157
|
-
current = node
|
158
|
-
labels = []
|
159
|
-
while (current.name == 'div')
|
160
|
-
labels.unshift URI.escape(current['LABEL'])
|
161
|
-
current = current.parent
|
162
|
-
end
|
163
|
-
labels
|
164
|
-
end
|
165
|
-
def proxy_uri_chain_for(node)
|
166
|
-
uris = []
|
167
|
-
ancestors(node).inject(RDF::URI("info:fedora/#{self.pid}/#{self.dsid}")) {|m,a| (uris << m/a).last}
|
168
|
-
uris
|
169
|
-
end
|
170
|
-
def proxy_uri_for(node)
|
171
|
-
# uri = segments.inject(base_uri) {|m,a| m/a}
|
172
|
-
ancestors(node).inject(RDF::URI("info:fedora/#{self.pid}/#{self.dsid}")) {|m,a| m/a}
|
173
8
|
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
9
|
+
end
|