cul_hydra 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/assets/images/cul_hydra/crystal/binary.png +0 -0
- data/app/assets/images/cul_hydra/crystal/document.png +0 -0
- data/app/assets/images/cul_hydra/crystal/file.png +0 -0
- data/app/assets/images/cul_hydra/crystal/file_broken.png +0 -0
- data/app/assets/images/cul_hydra/crystal/folder_documents.png +0 -0
- data/app/assets/images/cul_hydra/crystal/folder_images.png +0 -0
- data/app/assets/images/cul_hydra/crystal/folder_music.png +0 -0
- data/app/assets/images/cul_hydra/crystal/folder_sound.png +0 -0
- data/app/assets/images/cul_hydra/crystal/folder_video.png +0 -0
- data/app/assets/images/cul_hydra/crystal/kmultiple.png +0 -0
- data/app/assets/images/cul_hydra/crystal/knotify.png +0 -0
- data/app/assets/images/cul_hydra/crystal/mp3.png +0 -0
- data/app/assets/images/cul_hydra/crystal/multimedia2.png +0 -0
- data/app/assets/images/cul_hydra/crystal/video.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/application.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/code.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/css.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/db.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/directory.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/doc.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/file.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/film.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/flash.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/folder_open.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/html.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/java.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/linux.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/music.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/pdf.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/php.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/picture.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/ppt.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/psd.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/ruby.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/script.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/spinner.gif +0 -0
- data/app/assets/images/cul_hydra/filesystem/txt.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/xls.png +0 -0
- data/app/assets/images/cul_hydra/filesystem/zip.png +0 -0
- data/app/controllers/concerns/cul/hydra/application_id_behavior.rb +43 -0
- 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/helpers/cul/hydra/ore_proxies_helper_behavior.rb +119 -0
- data/app/helpers/cul/hydra/struct_metadata_helper_behavior.rb +89 -0
- data/app/models/bag_aggregator.rb +7 -0
- data/app/models/concept.rb +23 -0
- 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 +106 -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/nfo/common.rb +17 -0
- data/app/models/concerns/nfo/file_data_object.rb +10 -0
- data/app/models/concerns/nfo/folder.rb +10 -0
- data/app/models/concerns/nie/information_element.rb +10 -0
- data/app/models/concerns/ore/proxy.rb +124 -0
- data/app/models/concerns/rdf/cul.rb +77 -0
- data/app/models/concerns/rdf/fcrepo3.rb +360 -0
- data/app/models/concerns/rdf/nfo.rb +807 -0
- data/app/models/concerns/rdf/nie.rb +338 -0
- data/app/models/concerns/rdf/olo.rb +100 -0
- data/app/models/concerns/rdf/ore.rb +101 -0
- data/app/models/concerns/rdf/pimo.rb +605 -0
- data/app/models/concerns/rdf/sc.rb +47 -0
- data/app/models/concerns/sc/canvas.rb +12 -0
- data/app/models/concerns/sc/sequence.rb +21 -0
- data/app/models/content_aggregator.rb +3 -0
- 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/dc_document.rb +39 -0
- data/app/models/generic_aggregator.rb +68 -0
- data/app/models/generic_object.rb +18 -0
- data/app/models/generic_resource.rb +210 -0
- data/app/models/jp2_image_aggregator.rb +34 -0
- data/app/models/mets_structured_aggregator.rb +18 -0
- data/app/models/resource.rb +78 -0
- data/app/models/resource_aggregator.rb +22 -0
- data/app/models/static_audio_aggregator.rb +12 -0
- data/app/models/static_image_aggregator.rb +32 -0
- data/bin/rails +12 -0
- data/config/fedora.yml +17 -0
- data/config/jetty.yml +6 -0
- data/config/locales/ldpd_hydra.en.yml +125 -0
- data/config/predicate_mappings.yml +79 -0
- data/config/solr.yml +8 -0
- data/config/solr_mappings.yml +26 -0
- data/config/solr_value_maps.yml +41 -0
- data/config/subs.yml +17 -0
- data/fixtures/cmodels/ldpd_ADLMetadata.xml +56 -0
- data/fixtures/cmodels/ldpd_AESMetadata.xml +56 -0
- data/fixtures/cmodels/ldpd_BagAggregator.xml +70 -0
- data/fixtures/cmodels/ldpd_Concept.xml +69 -0
- data/fixtures/cmodels/ldpd_ContentAggregator.xml +70 -0
- data/fixtures/cmodels/ldpd_DynamicAggregator.xml +56 -0
- data/fixtures/cmodels/ldpd_JP2ImageAggregator.xml +60 -0
- data/fixtures/cmodels/ldpd_METSMetadata.xml +56 -0
- data/fixtures/cmodels/ldpd_METSStructuredAggregator.xml +53 -0
- data/fixtures/cmodels/ldpd_MODSMetadata.xml +73 -0
- data/fixtures/cmodels/ldpd_MostRecent.xml +46 -0
- data/fixtures/cmodels/ldpd_PTIFImageAggregator.xml +63 -0
- data/fixtures/cmodels/ldpd_Resource.xml +72 -0
- data/fixtures/cmodels/ldpd_RestrictedResource.xml +54 -0
- data/fixtures/cmodels/ldpd_Since.xml +62 -0
- data/fixtures/cmodels/ldpd_StaticAudioAggregator.xml +54 -0
- data/fixtures/cmodels/ldpd_StaticImageAggregator.xml +71 -0
- data/fixtures/cmodels/ldpd_htest.xml +54 -0
- data/fixtures/cmodels/ldpd_nullbind.xml +63 -0
- data/fixtures/cmodels/ldpd_sdef.Aggregator.xml +71 -0
- data/fixtures/cmodels/ldpd_sdef.Core.xml +48 -0
- data/fixtures/cmodels/ldpd_sdef.Image.xml +47 -0
- data/fixtures/cmodels/ldpd_sdef.Metadata.xml +62 -0
- data/fixtures/cmodels/ldpd_sdef.Resource.xml +76 -0
- data/fixtures/cmodels/ldpd_sdef.ZoomingImage.xml +46 -0
- data/fixtures/cmodels/ldpd_sdep.BagAggregator.xml +160 -0
- data/fixtures/cmodels/ldpd_sdep.BagAggregatorCore.xml +221 -0
- data/fixtures/cmodels/ldpd_sdep.ContentAggregatorCore.xml +221 -0
- data/fixtures/cmodels/ldpd_sdep.DynamicAggregator.xml +171 -0
- data/fixtures/cmodels/ldpd_sdep.DynamicAggregatorCore.xml +215 -0
- data/fixtures/cmodels/ldpd_sdep.JP2Image.xml +220 -0
- data/fixtures/cmodels/ldpd_sdep.JP2ImageAggregator.xml +167 -0
- data/fixtures/cmodels/ldpd_sdep.JP2ImageCore.xml +229 -0
- data/fixtures/cmodels/ldpd_sdep.MODSMetadata.xml +158 -0
- data/fixtures/cmodels/ldpd_sdep.MODSMetadataCore.xml +227 -0
- data/fixtures/cmodels/ldpd_sdep.PTIFImage.xml +222 -0
- data/fixtures/cmodels/ldpd_sdep.PTIFImageAggregator.xml +167 -0
- data/fixtures/cmodels/ldpd_sdep.PTIFImageCore.xml +215 -0
- data/fixtures/cmodels/ldpd_sdep.StaticImage.xml +210 -0
- data/fixtures/cmodels/ldpd_sdep.StaticImageAggregator.xml +186 -0
- data/fixtures/cmodels/ldpd_sdep.StaticImageCore.xml +220 -0
- data/fixtures/cmodels/ore_Proxy.xml +50 -0
- data/fixtures/spec/BLOB/test001.jpg +0 -0
- data/fixtures/spec/CUL_DC/dc.xml +5 -0
- data/fixtures/spec/CUL_MODS/mods-001.xml +25 -0
- data/fixtures/spec/CUL_MODS/mods-all.xml +65 -0
- data/fixtures/spec/CUL_MODS/mods-bad-repo.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-date-created-range.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-date-created-single.xml +6 -0
- data/fixtures/spec/CUL_MODS/mods-date-end-with-all-u-characters.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-date-issued-range.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-date-issued-single.xml +6 -0
- data/fixtures/spec/CUL_MODS/mods-date-other-range.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-date-other-single.xml +6 -0
- data/fixtures/spec/CUL_MODS/mods-date-range-short-years.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-date-start-with-all-u-characters.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-dates-with-all-u-characters.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-dates-with-some-u-characters.xml +7 -0
- data/fixtures/spec/CUL_MODS/mods-item.xml +31 -0
- data/fixtures/spec/CUL_MODS/mods-names.xml +35 -0
- data/fixtures/spec/CUL_MODS/mods-notes.xml +8 -0
- data/fixtures/spec/CUL_MODS/mods-ns.xml +2 -0
- data/fixtures/spec/CUL_MODS/mods-origin-info.xml +9 -0
- data/fixtures/spec/CUL_MODS/mods-part.xml +22 -0
- data/fixtures/spec/CUL_MODS/mods-physical-description.xml +12 -0
- data/fixtures/spec/CUL_MODS/mods-physical-location.xml +9 -0
- data/fixtures/spec/CUL_MODS/mods-record-info.xml +4 -0
- data/fixtures/spec/CUL_MODS/mods-relateditem-project.xml +8 -0
- data/fixtures/spec/CUL_MODS/mods-subjects.xml +73 -0
- data/fixtures/spec/CUL_MODS/mods-textual-date.xml +8 -0
- data/fixtures/spec/CUL_MODS/mods-titles.xml +33 -0
- data/fixtures/spec/CUL_MODS/mods-top-level-location-vs-relateditem-location.xml +21 -0
- data/fixtures/spec/CUL_MODS/mods-unmapped-project.xml +7 -0
- data/fixtures/spec/CUL_SOLR/mods-001.xml +1 -0
- data/fixtures/spec/CUL_SOLR/mods-001.yml +30 -0
- data/fixtures/spec/FOXML/content-aggregator.xml +64 -0
- data/fixtures/spec/FOXML/content-cmodel.xml +48 -0
- data/fixtures/spec/FOXML/image-cmodel.xml +48 -0
- data/fixtures/spec/FOXML/resource-max.xml +83 -0
- data/fixtures/spec/FOXML/resource-screen.xml +273 -0
- data/fixtures/spec/FOXML/resource-thumb.xml +86 -0
- data/fixtures/spec/FOXML/static-image-aggregator.xml +31 -0
- data/fixtures/spec/STRUCTMAP/structmap-examples.xml +21 -0
- data/fixtures/spec/STRUCTMAP/structmap-nested.xml +10 -0
- data/fixtures/spec/STRUCTMAP/structmap-recto.xml +4 -0
- data/fixtures/spec/STRUCTMAP/structmap-seq.xml +5 -0
- data/fixtures/spec/STRUCTMAP/structmap-unordered-seq.xml +5 -0
- data/lib/cul_hydra.rb +20 -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_hydra/controllers/helpers/active_fedora_helper_behavior.rb +9 -0
- data/lib/cul_hydra/controllers/helpers/application_helper_behavior.rb +16 -0
- data/lib/cul_hydra/controllers/helpers/dc_metadata_helper_behavior.rb +9 -0
- data/lib/cul_hydra/controllers/helpers/hydra_assets_helper_behavior.rb +46 -0
- data/lib/cul_hydra/controllers/helpers/hydra_autocomplete_helper_behavior.rb +35 -0
- data/lib/cul_hydra/controllers/helpers/hydra_uploader_helper_behavior.rb +34 -0
- data/lib/cul_hydra/controllers/helpers/resources_helper_behavior.rb +159 -0
- 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 +102 -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 +473 -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_hydra/solrizer_patch.rb +172 -0
- data/lib/cul_hydra/version.rb +8 -0
- data/lib/cul_hydra/version.rb~ +8 -0
- data/lib/tasks/cmodel.rake +122 -0
- data/lib/tasks/cul_hydra_dev.rake +54 -0
- data/lib/tasks/index.rake +73 -0
- data/lib/tasks/transform.rake +23 -0
- metadata +503 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
module Cul::Hydra::Models::LinkableResources
|
2
|
+
include Cul::Hydra::Fedora::UrlHelperBehavior
|
3
|
+
# so as to avoid including all the url hepers via:
|
4
|
+
## include Rails.application.routes.url_helpers
|
5
|
+
# we are just going to delegate
|
6
|
+
delegate :fedora_content_path, :to => 'Rails.application.routes.url_helpers'
|
7
|
+
delegate :cache_path, :to => 'Rails.application.routes.url_helpers'
|
8
|
+
|
9
|
+
def http_client
|
10
|
+
unless @http_client
|
11
|
+
@http_client ||= HTTPClient.new
|
12
|
+
@http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
13
|
+
uname = Cul::Hydra::Fedora.repository.config[:user]
|
14
|
+
pwd = Cul::Hydra::Fedora.repository.config[:password]
|
15
|
+
@http_client.set_auth(nil, uname, pwd)
|
16
|
+
end
|
17
|
+
@http_client
|
18
|
+
end
|
19
|
+
|
20
|
+
def linkable_resources
|
21
|
+
r = self.parts(:response_format => :solr)
|
22
|
+
return [] if r.blank?
|
23
|
+
members = r.collect {|hit|
|
24
|
+
SolrDocument.new(hit)
|
25
|
+
}
|
26
|
+
members.delete_if { |sd| (sd[:has_model_ssim] & ["info:fedora/ldpd:Resource"]).blank? }
|
27
|
+
case self.route_as
|
28
|
+
when "zoomingimage"
|
29
|
+
results = members.collect {|doc| image_resource(doc)}
|
30
|
+
base_id = self.pid
|
31
|
+
url = fedora_ds_url(base_id, 'SOURCE') + '/content'
|
32
|
+
head_req = http_client().head(url)
|
33
|
+
file_size = head_req.header["Content-Length"].first.to_i
|
34
|
+
results << {
|
35
|
+
:dimensions => "Original",
|
36
|
+
:mime_type => "image/jp2",
|
37
|
+
:uri=>base_id, :block=>"SOURCE", :filename=>base_id + "_source.jp2",
|
38
|
+
:content_models=>[]}
|
39
|
+
when "audio"
|
40
|
+
results = members.collect {|doc| audio_resource(doc)}
|
41
|
+
when "image"
|
42
|
+
results = members.collect {|doc| image_resource(doc)}
|
43
|
+
else
|
44
|
+
raise "Unknown format #{self.route_as}"
|
45
|
+
end
|
46
|
+
return results
|
47
|
+
end
|
48
|
+
|
49
|
+
def basic_resource(document)
|
50
|
+
res = {}
|
51
|
+
res[:pid] = document["id"]
|
52
|
+
res[:dsid] = "CONTENT"
|
53
|
+
res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
|
54
|
+
res[:content_models] = document["has_model_ssim"]
|
55
|
+
res[:file_size] = document["extent_ssim"].first.to_i
|
56
|
+
res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
|
57
|
+
res
|
58
|
+
end
|
59
|
+
|
60
|
+
def image_resource(document)
|
61
|
+
res = basic_resource(document)
|
62
|
+
if document["image_width_ssim"]
|
63
|
+
res[:dimensions] = document["image_width_ssim"].first + " x " + document["image_length_ssim"].first
|
64
|
+
res[:width] = document["image_width_ssim"].first
|
65
|
+
res[:height] = document["image_length_ssim"].first
|
66
|
+
else
|
67
|
+
res[:dimensions] = "? x ?"
|
68
|
+
res[:width] = "0"
|
69
|
+
res[:height] = "0"
|
70
|
+
end
|
71
|
+
base_id = document["id"]
|
72
|
+
base_filename = base_id.gsub(/\:/,"")
|
73
|
+
img_filename = base_filename + "." + document["dc_format_ssm"].first.gsub(/^[^\/]+\//,"")
|
74
|
+
res[:filename] = img_filename
|
75
|
+
res[:block] = "CONTENT"
|
76
|
+
res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
|
77
|
+
res[:content_models] = document["has_model_ssim"]
|
78
|
+
res[:file_size] = document["extent_ssim"].first.to_i
|
79
|
+
res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
|
80
|
+
res[:uri] = base_id
|
81
|
+
res
|
82
|
+
end
|
83
|
+
|
84
|
+
def audio_resource(document)
|
85
|
+
res = basic_resource(document)
|
86
|
+
base_id = document["id"]
|
87
|
+
base_filename = base_id.gsub(/\:/,"")
|
88
|
+
if res[:mime_type] =~ /wav/
|
89
|
+
ext = 'wav'
|
90
|
+
elsif res[:mime_type] =~ /mpeg/
|
91
|
+
ext = 'mp3'
|
92
|
+
else
|
93
|
+
ext = 'bin'
|
94
|
+
end
|
95
|
+
filename = base_filename + "." + ext
|
96
|
+
dc_filename = base_filename + "_dc.xml"
|
97
|
+
res[:uri] = base_id
|
98
|
+
res[:block] = "CONTENT"
|
99
|
+
res[:filename] = filename
|
100
|
+
res[:dc_path] = fedora_content_path(:download_method=>"show_pretty", :uri=>base_id, :block=>"DC", :filename=>dc_filename)
|
101
|
+
res[:mime_type] = document["dc_format_ssm"] ? document["dc_format_ssm"].first : "application/octect-stream"
|
102
|
+
res[:content_models] = document["has_model_ssim"]
|
103
|
+
res[:file_size] = document["extent_ssim"].first.to_i
|
104
|
+
res[:size] = (document["extent_ssim"].first.to_i / 1024).to_s + " Kb"
|
105
|
+
res
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Cul::Hydra::Models::Resource
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
# constants #
|
4
|
+
IMAGE_MIME_TYPES = [
|
5
|
+
'image/bmp',
|
6
|
+
'image/gif',
|
7
|
+
'image/jpeg',
|
8
|
+
'image/png',
|
9
|
+
'image/tiff'
|
10
|
+
]
|
11
|
+
|
12
|
+
included do
|
13
|
+
if self.is_a? ::ActiveFedora::SemanticNode
|
14
|
+
props = {
|
15
|
+
"image_width" => :image_width,
|
16
|
+
"image_length" => :image_length,
|
17
|
+
"x_sampling" => :x_sampling,
|
18
|
+
"y_sampling" => :y_sampling,
|
19
|
+
"sampling_unit" => :sampling_unit,
|
20
|
+
"extent" => :extent,
|
21
|
+
}
|
22
|
+
props.each { |x, y|
|
23
|
+
class_eval %Q{
|
24
|
+
def #{x}
|
25
|
+
return relationships[:#{y.to_s}]
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
after_create :resource!
|
30
|
+
end
|
31
|
+
if self.respond_to? :has_datastream
|
32
|
+
has_datastream :name => "CONTENT", :type=>::ActiveFedora::Datastream, :versionable => true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def resource!
|
37
|
+
add_relationship(:rdf_type, Cul::Hydra::Models::RESOURCE_TYPE.to_s)
|
38
|
+
@metadata_is_dirty = true
|
39
|
+
update
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_content_blob(blob, opts)
|
43
|
+
file_name = opts[:file_name]
|
44
|
+
mime = opts[:mime_type].nil? ? mime_type(file_name) : opts[:mime_type]
|
45
|
+
add_file_datastream(blob, :label=>file_name, :mimeType=>mime, :dsid => 'CONTENT')
|
46
|
+
set_title_and_label( file_name, :only_if_blank=>true )
|
47
|
+
if IMAGE_MIME_TYPES.include? mime
|
48
|
+
blob.rewind
|
49
|
+
# retrieve Nokogiri of image property RDF
|
50
|
+
image_properties = Cul::Image::Properties.identify(blob)
|
51
|
+
if image_properties
|
52
|
+
image_prop_nodes = image_properties.nodeset
|
53
|
+
relsext = datastreams['RELS-EXT']
|
54
|
+
image_prop_nodes.each { |node|
|
55
|
+
if node["resource"]
|
56
|
+
is_literal = false
|
57
|
+
object = RDF::URI.new(node["resource"])
|
58
|
+
else
|
59
|
+
is_literal = true
|
60
|
+
object = RDF::Literal(node.text)
|
61
|
+
end
|
62
|
+
subject = RDF::URI(internal_uri)
|
63
|
+
predicate = RDF::URI("#{node.namespace.href}#{node.name}")
|
64
|
+
query = RDF::Query.new({ :subject => {predicate => :object}})
|
65
|
+
relationships(predicate).dup.each { |stmt|
|
66
|
+
relationships.delete(stmt)
|
67
|
+
}
|
68
|
+
add_relationship(predicate,object, is_literal)
|
69
|
+
relationships_are_dirty=true
|
70
|
+
}
|
71
|
+
# add mimetype to DC:format values
|
72
|
+
self.datastreams['DC'].update_values({[:format] => mime})
|
73
|
+
end
|
74
|
+
end
|
75
|
+
blob.rewind
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
# Return the mimeType for a given file name
|
81
|
+
# @param [String] file_name The filename to use to get the mimeType
|
82
|
+
# @return [String] mimeType for filename passed in. Default: application/octet-stream if mimeType cannot be determined
|
83
|
+
def mime_type file_name
|
84
|
+
mime_types = MIME::Types.of(file_name)
|
85
|
+
mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module NFO
|
2
|
+
module Common
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
included do
|
5
|
+
property :belongsToContainer, predicate: RDF::NFO[:"#belongsToContainer"], multivalue: false do |ix|
|
6
|
+
ix.as :stored_sortable
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_solr(solr_doc={})
|
11
|
+
solr_doc = super(solr_doc)
|
12
|
+
if solr_doc['']
|
13
|
+
end
|
14
|
+
solr_doc
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module NFO
|
2
|
+
class FileDataObject < ORE::Proxy
|
3
|
+
include NIE::InformationElement
|
4
|
+
include NFO::Common
|
5
|
+
def initialize(proxy_for_uri, context_uri, *args)
|
6
|
+
super(proxy_for_uri, context_uri, *args)
|
7
|
+
self.get_values(:type) << RDF::NFO[:"#FileDataObject"]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
# A named graph describing the location of a Resource in a virtual nested structure
|
2
|
+
require 'digest'
|
3
|
+
require 'active_triples'
|
4
|
+
module ORE
|
5
|
+
class Proxy < ActiveTriples::Resource
|
6
|
+
include Digest
|
7
|
+
include Solrizer::Common
|
8
|
+
include ActiveFedora::Rdf::Indexing
|
9
|
+
|
10
|
+
module Id
|
11
|
+
class Descriptor < Solrizer::Descriptor
|
12
|
+
def name_and_converter(field_name, field_type)
|
13
|
+
['id']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
def self.id_for2(proxy_in, proxy_for)
|
17
|
+
path = proxy_for.to_s
|
18
|
+
path = path.sub(/^info.fedora\/[^\/]+\/structMetadata\//,'')
|
19
|
+
"urn:proxy:#{proxy_in ? Digest::MD5.hexdigest(proxy_in.to_s) : '' }:#{path}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def self.type
|
23
|
+
RDF::ORE.Proxy
|
24
|
+
end
|
25
|
+
property :id, predicate: RDF.nodeID, multivalue: false do |ix|
|
26
|
+
ix.as Id::Descriptor.new
|
27
|
+
end
|
28
|
+
property :isAggregatedBy, predicate: RDF::ORE.isAggregatedBy, multivalue: false do |ix|
|
29
|
+
ix.as :stored_sortable
|
30
|
+
end
|
31
|
+
property :lineage, predicate: RDF::ORE.lineage, multivalue: false do |ix|
|
32
|
+
ix.as :stored_sortable
|
33
|
+
end
|
34
|
+
property :proxyFor, predicate: RDF::ORE.proxyFor, multivalue: false do |ix|
|
35
|
+
ix.as :stored_sortable
|
36
|
+
end
|
37
|
+
property :proxyIn, predicate: RDF::ORE.proxyIn, multivalue: false do |ix|
|
38
|
+
ix.as :stored_sortable
|
39
|
+
end
|
40
|
+
property :index, predicate: RDF::OLO.index, multivalue: false do |ix|
|
41
|
+
ix.as :stored_sortable
|
42
|
+
ix.type :integer
|
43
|
+
end
|
44
|
+
property :format, predicate: RDF::DC.format, multivalue: false do |ix|
|
45
|
+
ix.as :stored_sortable
|
46
|
+
end
|
47
|
+
property :extent, predicate: RDF::DC.extent, multivalue: false do |ix|
|
48
|
+
ix.as :displayable
|
49
|
+
end
|
50
|
+
property :label, predicate: RDF::RDFS.label, multivalue: false do |ix|
|
51
|
+
ix.as :stored_sortable
|
52
|
+
end
|
53
|
+
property :hasModel, predicate: RDF::FCREPO3::MODEL.hasModel, multivalue: false do |ix|
|
54
|
+
ix.as :stored_sortable
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(proxy_resource_uri, graph_context_uri, *args)
|
58
|
+
proxy_resource_uri = RDF::URI(proxy_resource_uri)
|
59
|
+
super(proxy_resource_uri,*args)
|
60
|
+
update(RDF::Statement(rdf_subject,RDF.nodeID,proxy_resource_uri))
|
61
|
+
self.proxyIn = graph_context_uri
|
62
|
+
self.proxyFor = proxy_resource_uri
|
63
|
+
end
|
64
|
+
|
65
|
+
# override to obscure attempts to identify a containing Datastream
|
66
|
+
def apply_prefix(name)
|
67
|
+
name
|
68
|
+
end
|
69
|
+
|
70
|
+
def resource
|
71
|
+
self
|
72
|
+
end
|
73
|
+
|
74
|
+
def to_json
|
75
|
+
to_solr.with_indifferent_access
|
76
|
+
end
|
77
|
+
|
78
|
+
def to_solr(solr_doc = {}) # :nodoc:
|
79
|
+
fields.each do |field_key, field_info|
|
80
|
+
values = resource.get_values(field_key.to_sym).result || []
|
81
|
+
values = [values] unless values.is_a? Array
|
82
|
+
values.each do |val|
|
83
|
+
if val.kind_of? RDF::URI
|
84
|
+
val = val.to_s
|
85
|
+
elsif val.kind_of? ActiveTriples::Resource
|
86
|
+
val = val.solrize
|
87
|
+
end
|
88
|
+
self.class.create_and_insert_terms(apply_prefix(field_key), val, field_info[:behaviors], solr_doc)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
solr_doc
|
92
|
+
end
|
93
|
+
# returns a Hash, e.g.: {field => {:values => [], :type => :something, :behaviors => []}, ...}
|
94
|
+
def fields
|
95
|
+
field_map = {}.with_indifferent_access
|
96
|
+
insert_field_map(:type, type_config(),field_map)
|
97
|
+
self.class.properties.each do |name, config|
|
98
|
+
insert_field_map(name, config, field_map)
|
99
|
+
end
|
100
|
+
field_map
|
101
|
+
end
|
102
|
+
|
103
|
+
def insert_field_map(name, config, field_map={})
|
104
|
+
type = config[:type]
|
105
|
+
behaviors = config[:behaviors]
|
106
|
+
return field_map unless type and behaviors
|
107
|
+
return field_map if config[:class_name] && config[:class_name] < ActiveFedora::Base
|
108
|
+
resource.query(:subject => rdf_subject, :predicate => config[:predicate]).each_statement do |statement|
|
109
|
+
field_map[name] ||= {:values => [], :type => type, :behaviors => behaviors, term: config[:term]}
|
110
|
+
field_map[name][:values] << statement.object.to_s
|
111
|
+
end
|
112
|
+
field_map
|
113
|
+
end
|
114
|
+
|
115
|
+
def type_config
|
116
|
+
@type_node_config ||= begin
|
117
|
+
config = ActiveTriples::NodeConfig.new(:type, RDF.type)
|
118
|
+
config.with_index {|ix| ix.as :symbol }
|
119
|
+
config
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# This file generated automatically using vocab-fetch from http://www.semanticdesktop.org/ontologies/2007/03/22/nfo
|
3
|
+
require 'rdf'
|
4
|
+
module RDF
|
5
|
+
class CUL < RDF::StrictVocabulary("http://purl.oclc.org/NET/CUL/")
|
6
|
+
term :Aggregator,
|
7
|
+
comment: %(An collection of Aggregators or Resources).freeze,
|
8
|
+
label: "Aggregator".freeze,
|
9
|
+
type: "rdfs:Class".freeze
|
10
|
+
term :Resource,
|
11
|
+
comment: %(A file-like Resource).freeze,
|
12
|
+
label: "Resource".freeze,
|
13
|
+
type: "rdfs:Class".freeze
|
14
|
+
property :hasMember,
|
15
|
+
comment: %(The object is a member of the subject Aggregator.).freeze,
|
16
|
+
domain: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
|
17
|
+
label: "hasMember".freeze,
|
18
|
+
range: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
|
19
|
+
subPropertyOf: "info:fedora/fedora-system:def/relations-external#hasMember".freeze,
|
20
|
+
type: "rdf:Property".freeze
|
21
|
+
property :memberOf,
|
22
|
+
comment: %(The subject is a member of the object Aggregator.).freeze,
|
23
|
+
domain: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
|
24
|
+
label: "memberOf".freeze,
|
25
|
+
range: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
|
26
|
+
subPropertyOf: "info:fedora/fedora-system:def/relations-external#isMemberOf".freeze,
|
27
|
+
type: "rdf:Property".freeze
|
28
|
+
property :obsoleteFrom,
|
29
|
+
comment: %(The subject is an obsolete member of the object Aggregator.).freeze,
|
30
|
+
domain: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
|
31
|
+
label: "obsoleteFrom".freeze,
|
32
|
+
range: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
|
33
|
+
subPropertyOf: "info:fedora/fedora-system:def/relations-external#isMemberOf".freeze,
|
34
|
+
type: "rdf:Property".freeze
|
35
|
+
property :metadataFor,
|
36
|
+
comment: %(The subject is an obsolete description of the object.).freeze,
|
37
|
+
domain: ["http://purl.oclc.org/NET/CUL/Aggregator".freeze,"http://purl.oclc.org/NET/CUL/Resource".freeze],
|
38
|
+
label: "metadataFor".freeze,
|
39
|
+
range: "http://purl.oclc.org/NET/CUL/Aggregator".freeze,
|
40
|
+
subPropertyOf: "info:fedora/fedora-system:def/relations-external#isMetadataFor".freeze,
|
41
|
+
type: "rdf:Property".freeze
|
42
|
+
module RESOURCE
|
43
|
+
module STILLIMAGE
|
44
|
+
class BASIC < RDF::StrictVocabulary("http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/")
|
45
|
+
property :imageWidth,
|
46
|
+
label: "imageWidth",
|
47
|
+
type: "rdf:Property".freeze
|
48
|
+
property :imageLength,
|
49
|
+
label: "imageLength",
|
50
|
+
type: "rdf:Property".freeze
|
51
|
+
end
|
52
|
+
class ASSESSMENT < RDF::StrictVocabulary("http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/ASSESSMENT/")
|
53
|
+
property :xSamplingFrequency,
|
54
|
+
label: "xSamplingFrequency",
|
55
|
+
type: "rdf:Property".freeze
|
56
|
+
property :ySamplingFrequency,
|
57
|
+
label: "ySamplingFrequency",
|
58
|
+
type: "rdf:Property".freeze
|
59
|
+
property :samplingFrequencyUnit,
|
60
|
+
label: "samplingFrequencyUnit",
|
61
|
+
type: "rdf:Property".freeze
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
# An addition to FOAF used locally at CUL
|
66
|
+
class FOAF < RDF::StrictVocabulary("http://xmlns.com/foaf/0.1/")
|
67
|
+
property :zoomingImage,
|
68
|
+
comment: %(A derived zoomable image.).freeze,
|
69
|
+
domain: "foaf:Image".freeze,
|
70
|
+
label: "zoomingImage".freeze,
|
71
|
+
range: "foaf:Image".freeze,
|
72
|
+
"rdfs:isDefinedBy" => %(foaf:).freeze,
|
73
|
+
type: ["rdf:Property".freeze, "owl:ObjectProperty".freeze],
|
74
|
+
"vs:term_status" => %(testing).freeze
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|