cul_scv_hydra 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. data/app/models/bag_aggregator.rb +16 -0
  2. data/app/models/content_aggregator.rb +16 -0
  3. data/app/models/dcdocument.rb +9 -0
  4. data/app/models/generic_aggregator.rb +16 -0
  5. data/app/models/generic_object.rb +16 -0
  6. data/app/models/jp2_image_aggregator.rb +38 -0
  7. data/app/models/mets_structured_aggregator.rb +16 -0
  8. data/app/models/resource.rb +59 -0
  9. data/app/models/static_audio_aggregator.rb +21 -0
  10. data/app/models/static_image_aggregator.rb +21 -0
  11. data/config/fedora.yml +6 -0
  12. data/config/predicate_mappings.yml +56 -0
  13. data/config/solr.yml +15 -0
  14. data/config/solr_mappings.yml +26 -0
  15. data/config/solr_value_maps.yml +29 -0
  16. data/lib/cul_scv_hydra.rb +14 -0
  17. data/lib/cul_scv_hydra/access_controls_enforcement.rb +53 -0
  18. data/lib/cul_scv_hydra/active_fedora.rb +18 -0
  19. data/lib/cul_scv_hydra/active_fedora/model.rb +8 -0
  20. data/lib/cul_scv_hydra/active_fedora/model/aggregator.rb +45 -0
  21. data/lib/cul_scv_hydra/active_fedora/model/common.rb +221 -0
  22. data/lib/cul_scv_hydra/active_fedora/model/dcdocument.rb +43 -0
  23. data/lib/cul_scv_hydra/active_fedora/model/resource.rb +79 -0
  24. data/lib/cul_scv_hydra/controllers.rb +13 -0
  25. data/lib/cul_scv_hydra/controllers/aggregates.rb +95 -0
  26. data/lib/cul_scv_hydra/controllers/aggregator_controller_helper.rb +27 -0
  27. data/lib/cul_scv_hydra/controllers/catalog.rb +13 -0
  28. data/lib/cul_scv_hydra/controllers/content_aggregators.rb +83 -0
  29. data/lib/cul_scv_hydra/controllers/datastreams.rb +146 -0
  30. data/lib/cul_scv_hydra/controllers/helpers.rb +11 -0
  31. data/lib/cul_scv_hydra/controllers/helpers/active_fedora_helper_behavior.rb +9 -0
  32. data/lib/cul_scv_hydra/controllers/helpers/application_helper_behavior.rb +17 -0
  33. data/lib/cul_scv_hydra/controllers/helpers/dc_metadata_helper_behavior.rb +9 -0
  34. data/lib/cul_scv_hydra/controllers/helpers/hydra_assets_helper_behavior.rb +46 -0
  35. data/lib/cul_scv_hydra/controllers/helpers/hydra_autocomplete_helper_behavior.rb +35 -0
  36. data/lib/cul_scv_hydra/controllers/helpers/hydra_uploader_helper_behavior.rb +34 -0
  37. data/lib/cul_scv_hydra/controllers/helpers/resources_helper_behavior.rb +160 -0
  38. data/lib/cul_scv_hydra/controllers/resources.rb +162 -0
  39. data/lib/cul_scv_hydra/controllers/static_image_aggregators.rb +106 -0
  40. data/lib/cul_scv_hydra/controllers/suggestions.rb +127 -0
  41. data/lib/cul_scv_hydra/controllers/terms.rb +152 -0
  42. data/lib/cul_scv_hydra/engine.rb +9 -0
  43. data/lib/cul_scv_hydra/om.rb +11 -0
  44. data/lib/cul_scv_hydra/om/dc_metadata.rb +70 -0
  45. data/lib/cul_scv_hydra/om/scv_mods_document.rb +132 -0
  46. data/lib/cul_scv_hydra/om/standard_mods.rb +111 -0
  47. data/lib/cul_scv_hydra/solrizer.rb +12 -0
  48. data/lib/cul_scv_hydra/solrizer/extractor.rb +27 -0
  49. data/lib/cul_scv_hydra/solrizer/field_mapper.rb +30 -0
  50. data/lib/cul_scv_hydra/solrizer/terminology_based_solrizer.rb +112 -0
  51. data/lib/cul_scv_hydra/solrizer/value_mapper.rb +35 -0
  52. data/lib/cul_scv_hydra/version.rb +10 -0
  53. metadata +333 -0
@@ -0,0 +1,16 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class BagAggregator < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+ include ::ActiveFedora::DatastreamCollections
6
+ include ::ActiveFedora::Relationships
7
+ include ::Hydra::ModelMethods
8
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
10
+
11
+ alias :file_objects :resources
12
+
13
+ def route_as
14
+ "collection"
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class ContentAggregator < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+ include ::ActiveFedora::DatastreamCollections
6
+ include ::ActiveFedora::Relationships
7
+ include ::Hydra::ModelMethods
8
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
10
+
11
+ alias :file_objects :resources
12
+
13
+ def route_as
14
+ "multipartitem"
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class DcDocument < ActiveFedora::Base
4
+ include ::ActiveFedora::DatastreamCollections
5
+ include ::ActiveFedora::Relationships
6
+ include Hydra::ModelMethods
7
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
8
+ alias :file_objects :resources
9
+ end
@@ -0,0 +1,16 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class GenericAggregator < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+ include ::ActiveFedora::DatastreamCollections
6
+ include ::ActiveFedora::Relationships
7
+ include ::Hydra::ModelMethods
8
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
10
+
11
+ alias :file_objects :resources
12
+
13
+ def route_as
14
+ "multipartitem"
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class GenericObject < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+ include ::ActiveFedora::DatastreamCollections
6
+ include ::ActiveFedora::Relationships
7
+ include ::Hydra::ModelMethods
8
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
10
+
11
+ alias :file_objects :resources
12
+
13
+ def route_as
14
+ "multipartitem"
15
+ end
16
+ end
@@ -0,0 +1,38 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class JP2ImageAggregator < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+ include ::ActiveFedora::DatastreamCollections
6
+ include ::ActiveFedora::Relationships
7
+ include ::Hydra::ModelMethods
8
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
10
+
11
+ has_datastream :name => "SOURCE", :type=>::ActiveFedora::Datastream, :mimeType=>"image/jp2", :controlGroup=>'E'
12
+
13
+ alias :file_objects :resources
14
+
15
+ def route_as
16
+ "zoomingimage"
17
+ end
18
+
19
+ def index_type_label
20
+ "PART"
21
+ end
22
+
23
+ def to_solr(solr_doc = Hash.new, opts={})
24
+ solr_doc = super
25
+ source = self.datastreams["SOURCE"]
26
+ source.profile
27
+ if source.controlGroup == 'E'
28
+ solr_doc["rft_id"] = source.dsLocation
29
+ else
30
+ rc = ActiveFedora::RubydoraConnection.instance.connection
31
+ url = rc.config["url"]
32
+ uri = URI::parse(url)
33
+ url = "#{uri.scheme}://#{uri.host}:#{uri.port}/fedora/objects/#{pid}/datastreams/SOURCE/content"
34
+ solr_doc["rft_id"] = url
35
+ end
36
+ solr_doc
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class METSStructuredAggregator < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+ include ::ActiveFedora::DatastreamCollections
6
+ include ::ActiveFedora::Relationships
7
+ include ::Hydra::ModelMethods
8
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
10
+
11
+ alias :file_objects :resources
12
+
13
+ def route_as
14
+ "multipartitem"
15
+ end
16
+ end
@@ -0,0 +1,59 @@
1
+ require "active-fedora"
2
+ require "cul_image_props"
3
+ require "hydra"
4
+ require "mime/types"
5
+ require "uri"
6
+ class Resource < ::ActiveFedora::Base
7
+ extend ActiveModel::Callbacks
8
+
9
+ include ::ActiveFedora::DatastreamCollections
10
+ include ::ActiveFedora::Relationships
11
+ include ::Hydra::ModelMethods
12
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
13
+ include Cul::Scv::Hydra::ActiveFedora::Model::Resource
14
+
15
+ alias :file_objects :resources
16
+
17
+ def route_as
18
+ "resource"
19
+ end
20
+
21
+ def index_type_label
22
+ "FILE RESOURCE"
23
+ end
24
+
25
+ def to_solr(solr_doc = Hash.new, opts={})
26
+ super
27
+ unless solr_doc["extent_s"] || self.datastreams["CONTENT"].nil?
28
+ solr_doc["extent_s"] = [self.datastreams["CONTENT"].size]
29
+ end
30
+ solr_doc
31
+ end
32
+
33
+ def set_title_and_label(new_title, opts={})
34
+ if opts[:only_if_blank]
35
+ if self.label.nil? || self.label.empty?
36
+ self.label = new_title
37
+ self.set_title( new_title )
38
+ end
39
+ else
40
+ self.label = new_title
41
+ set_title( new_title )
42
+ end
43
+ end
44
+
45
+ # Set the title and label on the current object
46
+ #
47
+ # @param [String] new_title
48
+ # @param [Hash] opts (optional) hash of configuration options
49
+ def set_title(new_title, opts={})
50
+ if has_desc?
51
+ desc_metadata_ds = self.datastreams["descMetadata"]
52
+ if desc_metadata_ds.respond_to?(:title_values)
53
+ desc_metadata_ds.title_values = new_title
54
+ else
55
+ desc_metadata_ds.title = new_title
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,21 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class StaticAudioAggregator < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+
6
+ include ::ActiveFedora::DatastreamCollections
7
+ include ::ActiveFedora::Relationships
8
+ include ::Hydra::ModelMethods
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
10
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
11
+
12
+ alias :file_objects :resources
13
+
14
+ def route_as
15
+ "audio"
16
+ end
17
+
18
+ def index_type_label
19
+ "PART"
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ require "active-fedora"
2
+ require "hydra"
3
+ class StaticImageAggregator < ::ActiveFedora::Base
4
+ extend ActiveModel::Callbacks
5
+
6
+ include ::ActiveFedora::DatastreamCollections
7
+ include ::ActiveFedora::Relationships
8
+ include ::Hydra::ModelMethods
9
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
10
+ include Cul::Scv::Hydra::ActiveFedora::Model::Aggregator
11
+
12
+ alias :file_objects :resources
13
+
14
+ def route_as
15
+ "image"
16
+ end
17
+
18
+ def index_type_label
19
+ "PART"
20
+ end
21
+ end
data/config/fedora.yml ADDED
@@ -0,0 +1,6 @@
1
+ development:
2
+ url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora
3
+ test:
4
+ url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora
5
+ default:
6
+ url: http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora
@@ -0,0 +1,56 @@
1
+ # The default namespace maps to the default namespace for generating rels_ext from solr
2
+ :default_namespace: info:fedora/fedora-system:def/relations-external#
3
+
4
+ # namespace mappings---
5
+ # you can add specific mappings for your institution by providing the following:
6
+ # namespace_uri:
7
+ # :relationship_symbol: relationship_identifier
8
+ #
9
+ # For example, if you have the following element in your rels_ext:
10
+ #
11
+ # <oai:itemID>oai:example.edu:changeme:500</oai:itemID>
12
+ #
13
+ # With the last two lines of this file uncommented, the relationships hash of your object will include:
14
+ # :oai_item_id => ["info:fedora/oai:example.edu:changeme:500"]
15
+ #
16
+ :predicate_mapping:
17
+ http://purl.oclc.org/NET/CUL/:
18
+ :cul_member_of: memberOf
19
+ :cul_metadata_for: metadataFor
20
+ info:fedora/fedora-system:def/relations-external#:
21
+ :conforms_to: conformsTo
22
+ :has_annotation: hasAnnotation
23
+ :has_collection_member: hasCollectionMember
24
+ :has_constituent: hasConstituent
25
+ :has_dependent: hasDependent
26
+ :has_derivation: hasDerivation
27
+ :has_description: hasDescription
28
+ :has_equivalent: hasEquivalent
29
+ :has_metadata: hasMetadata
30
+ :has_member: hasMember
31
+ :has_model: hasModel
32
+ :has_part: hasPart
33
+ :has_subset: hasSubset
34
+ :is_annotation_of: isAnnotationOf
35
+ :is_constituent_of: isConstituentOf
36
+ :is_dependent_of: isDependentOf
37
+ :is_derivation_of: isDerivationOf
38
+ :is_description_of: isDescriptionOf
39
+ :is_member_of: isMemberOf
40
+ :is_member_of_collection: isMemberOfCollection
41
+ :is_metadata_for: isMetadataFor
42
+ :is_part_of: isPartOf
43
+ :is_subset_of: isSubsetOf
44
+ info:fedora/fedora-system:def/model#:
45
+ :has_model: hasModel
46
+ http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/BASIC/:
47
+ :image_width: imageWidth
48
+ :image_length: imageLength
49
+ http://purl.oclc.org/NET/CUL/RESOURCE/STILLIMAGE/ASSESSMENT/:
50
+ :x_sampling: xSamplingFrequency
51
+ :y_sampling: ySamplingFrequency
52
+ :sampling_unit: samplingFrequencyUnit
53
+ http://purl.org/dc/terms/:
54
+ :extent: extent
55
+ http://www.w3.org/1999/02/22-rdf-syntax-ns#:
56
+ :rdf_type: type
data/config/solr.yml ADDED
@@ -0,0 +1,15 @@
1
+ development:
2
+ default:
3
+ url: http://127.0.0.1:8983/solr/development
4
+ full_text:
5
+ url: http://127.0.0.1:8983/solr/development
6
+ test:
7
+ default:
8
+ url: http://127.0.0.1:8983/solr/test
9
+ full_text:
10
+ url: http://127.0.0.1:8983/solr/test
11
+ default:
12
+ default:
13
+ url: http://127.0.0.1:8983/solr/test
14
+ full_text:
15
+ url: http://127.0.0.1:8983/solr/test
@@ -0,0 +1,26 @@
1
+ # Define additional properties for OM terms to communicate with Solrizer
2
+ # (Solrizer's use of dynamic fields to turn OM terms into Solr fields)
3
+ # example: t.my_term(:index_as=>[:searchable, :displayable])
4
+ # implies that the Solr document will have fields my_term_t and my_term_display
5
+ # if there is a value for the OM term :my_term in an object.
6
+ # :textable is a dummy; the field named returned will be 'text'
7
+ id: id
8
+ default: searchable
9
+ searchable:
10
+ default: _t
11
+ date: _dt
12
+ string: _t
13
+ text: _t
14
+ symbol: _s
15
+ integer: _i
16
+ long: _l
17
+ boolean: _b
18
+ float: _f
19
+ double: _d
20
+ displayable: _display
21
+ facetable: _facet
22
+ sortable: _sort
23
+ textable:
24
+ # this is a dummy value, all values will be mapped to a field called 'text'
25
+ default: _t
26
+ unstemmed_searchable: _unstem_search
@@ -0,0 +1,29 @@
1
+ :marc_to_facet :
2
+ 'NNC-A' : 'Avery'
3
+ 'NNC-ART' : 'Office of Art Properties'
4
+ 'NNBa' : 'Barnard College Library'
5
+ 'NNC-EA' : 'East Asian'
6
+ 'NNC-L' : 'Law Library'
7
+ 'NNC-M' : 'Health Sciences Library'
8
+ 'NNC-MUS' : 'Music Library'
9
+ 'NNC-RB' : 'RBML'
10
+ 'NyNyCBL' : 'Burke Library'
11
+ 'NyNyCOH' : 'CCOH'
12
+ :marc_to_display :
13
+ 'NNC-A' : 'Avery Architectural & Fine Arts Library'
14
+ 'NNC-ART' : 'Office of Art Properties'
15
+ 'NNBa' : 'Barnard College Library'
16
+ 'NNC-EA' : 'Starr East Asian'
17
+ 'NNC-L' : 'Law Library'
18
+ 'NNC-M' : 'Health Sciences Library'
19
+ 'NNC-MUS' : 'Music Library'
20
+ 'NNC-RB' : 'Rare Book and Manuscript Library'
21
+ 'NyNyCBL' : 'Burke Library at Union Theological Seminary'
22
+ 'NyNyCOH' : 'Columbia Center for Oral History Collections'
23
+ :project_facet :
24
+ 'Customer Order Collection' : 'Pres Orders'
25
+ "Children's Drawings of the Spanish Civil War (online exhibition)" : 'Spanish Civil War'
26
+ "Jewels in her crown: treasures of Columbia University Libraries special collections" : 'Jewels in her Crown'
27
+ "Russian Imperial Corps of Pages" : 'Russian Corps of Pages'
28
+ "Osama bin Laden posters" : 'Osama bin Laden posters'
29
+ "Chinese paper gods" : 'Chinese paper gods'
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+ module Cul
3
+ module Scv
4
+ module Hydra
5
+ end
6
+ end
7
+ end
8
+ require "cul_scv_hydra/access_controls_enforcement"
9
+ require "cul_scv_hydra/active_fedora"
10
+ require "cul_scv_hydra/controllers"
11
+ require "cul_scv_hydra/om"
12
+ require "cul_scv_hydra/solrizer"
13
+ require "cul_scv_hydra/version"
14
+ require "cul_scv_hydra/engine" if defined? Rails
@@ -0,0 +1,53 @@
1
+ module Cul::Scv::Hydra::AccessControlsEnforcement
2
+
3
+ private
4
+
5
+ def build_lucene_query(user_query)
6
+ q = ""
7
+ # start query of with user supplied query term
8
+ q << "_query_:\"{!dismax qf=$qf_dismax pf=$pf_dismax}#{user_query}\""
9
+
10
+ # Append the exclusion of Resources
11
+ q << " AND NOT _query_:\"info\\\\:fedora/ldpd\\\\:Resource\""
12
+
13
+ # Append the query responsible for adding the users discovery level
14
+ permission_types = ["edit","discover","read"]
15
+ field_queries = []
16
+ embargo_query = ""
17
+ permission_types.each do |type|
18
+ field_queries << "_query_:\"#{type}_access_group_t:public\""
19
+ end
20
+
21
+ unless current_user.nil?
22
+ # for roles
23
+ RoleMapper.roles(current_user.login).each do |role|
24
+ permission_types.each do |type|
25
+ field_queries << "_query_:\"#{type}_access_group_t:#{role}\""
26
+ end
27
+ end
28
+ # for individual person access
29
+ permission_types.each do |type|
30
+ field_queries << "_query_:\"#{type}_access_person_t:#{current_user.login}\""
31
+ end
32
+ if current_user.is_being_superuser?(session)
33
+ permission_types.each do |type|
34
+ field_queries << "_query_:\"#{type}_access_person_t:[* TO *]\""
35
+ end
36
+ end
37
+
38
+ # if it is the depositor and it is under embargo, that is ok
39
+ # otherwise if it not the depositor and it is under embargo, don't show it
40
+ embargo_query = " OR ((_query_:\"embargo_release_date_dt:[NOW TO *]\" AND _query_:\"depositor_t:#{current_user.login}\") AND NOT (NOT _query_:\"depositor_t:#{current_user.login}\" AND _query_:\"embargo_release_date_dt:[NOW TO *]\"))"
41
+ end
42
+
43
+ # remove anything with an embargo release date in the future
44
+ #embargo_query = " AND NOT _query_:\"embargo_release_date_dt:[NOW TO *]\"" if embargo_query.blank?
45
+ field_queries << " NOT _query_:\"embargo_release_date_dt:[NOW TO *]\"" if embargo_query.blank?
46
+
47
+ q << " AND (#{field_queries.join(" OR ")})"
48
+ q << embargo_query
49
+ return q
50
+ end
51
+
52
+
53
+ end