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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/cul/hydra/controller.rb +22 -0
  3. data/app/controllers/concerns/cul/hydra/resolver.rb +69 -0
  4. data/app/controllers/concerns/cul/hydra/thumbnails.rb +62 -0
  5. data/app/controllers/concerns/cul/scv/hydra/controller.rb +3 -19
  6. data/app/controllers/concerns/cul/scv/hydra/resolver.rb +2 -65
  7. data/app/controllers/concerns/cul/scv/hydra/thumbnails.rb +3 -59
  8. data/app/models/concept.rb +1 -1
  9. data/app/models/concerns/cul/hydra/models.rb +24 -0
  10. data/app/models/concerns/cul/hydra/models/aggregator.rb +121 -0
  11. data/app/models/concerns/cul/hydra/models/common.rb +220 -0
  12. data/app/models/concerns/cul/hydra/models/image_resource.rb +78 -0
  13. data/app/models/concerns/cul/hydra/models/linkable_resources.rb +108 -0
  14. data/app/models/concerns/cul/hydra/models/resource.rb +87 -0
  15. data/app/models/concerns/cul/scv/hydra/models.rb +1 -13
  16. data/app/models/concerns/cul/scv/hydra/models/aggregator.rb +1 -116
  17. data/app/models/concerns/cul/scv/hydra/models/common.rb +1 -213
  18. data/app/models/concerns/cul/scv/hydra/models/image_resource.rb +3 -75
  19. data/app/models/concerns/cul/scv/hydra/models/linkable_resources.rb +3 -105
  20. data/app/models/concerns/cul/scv/hydra/models/resource.rb +2 -83
  21. data/app/models/cul/hydra/datastreams/dc_metadata.rb +107 -0
  22. data/app/models/cul/hydra/datastreams/mods_document.rb +195 -0
  23. data/app/models/cul/hydra/datastreams/struct_metadata.rb +176 -0
  24. data/app/models/cul/scv/hydra/datastreams/dc_metadata.rb +5 -104
  25. data/app/models/cul/scv/hydra/datastreams/mods_document.rb +5 -178
  26. data/app/models/cul/scv/hydra/datastreams/struct_metadata.rb +5 -174
  27. data/app/models/dc_document.rb +1 -1
  28. data/app/models/generic_aggregator.rb +5 -5
  29. data/app/models/generic_object.rb +2 -2
  30. data/app/models/generic_resource.rb +4 -4
  31. data/app/models/mets_structured_aggregator.rb +2 -2
  32. data/app/models/resource.rb +3 -3
  33. data/app/models/resource_aggregator.rb +3 -3
  34. data/fixtures/spec/CUL_MODS/mods-subjects.xml +24 -0
  35. data/lib/cul_hydra.rb +18 -0
  36. data/lib/cul_hydra/access_controls_enforcement.rb +53 -0
  37. data/lib/cul_hydra/controllers.rb +13 -0
  38. data/lib/cul_hydra/controllers/aggregates.rb +93 -0
  39. data/lib/cul_hydra/controllers/aggregator_controller_helper.rb +27 -0
  40. data/lib/cul_hydra/controllers/catalog.rb +12 -0
  41. data/lib/cul_hydra/controllers/content_aggregators.rb +81 -0
  42. data/lib/cul_hydra/controllers/datastreams.rb +145 -0
  43. data/lib/cul_hydra/controllers/helpers.rb +10 -0
  44. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/active_fedora_helper_behavior.rb +1 -1
  45. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/application_helper_behavior.rb +1 -1
  46. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/dc_metadata_helper_behavior.rb +1 -1
  47. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_assets_helper_behavior.rb +1 -1
  48. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_autocomplete_helper_behavior.rb +1 -1
  49. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/hydra_uploader_helper_behavior.rb +1 -1
  50. data/lib/{cul_scv_hydra → cul_hydra}/controllers/helpers/resources_helper_behavior.rb +1 -1
  51. data/lib/cul_hydra/controllers/resources.rb +161 -0
  52. data/lib/cul_hydra/controllers/static_image_aggregators.rb +105 -0
  53. data/lib/cul_hydra/controllers/suggestions.rb +126 -0
  54. data/lib/cul_hydra/controllers/terms.rb +205 -0
  55. data/lib/cul_hydra/engine.rb +31 -0
  56. data/lib/cul_hydra/fedora.rb +41 -0
  57. data/lib/cul_hydra/fedora/dummy_object.rb +37 -0
  58. data/lib/cul_hydra/fedora/rubydora_patch.rb +16 -0
  59. data/lib/cul_hydra/fedora/url_helper_behavior.rb +32 -0
  60. data/lib/cul_hydra/indexer.rb +84 -0
  61. data/lib/cul_hydra/om.rb +7 -0
  62. data/lib/cul_hydra/om/standard_mods.rb +115 -0
  63. data/lib/cul_hydra/risearch_members.rb +92 -0
  64. data/lib/cul_hydra/solrizer.rb +10 -0
  65. data/lib/cul_hydra/solrizer/extractor.rb +27 -0
  66. data/lib/cul_hydra/solrizer/mods_fieldable.rb +435 -0
  67. data/lib/cul_hydra/solrizer/terminology_based_solrizer.rb +35 -0
  68. data/lib/cul_hydra/solrizer/value_mapper.rb +46 -0
  69. data/lib/{cul_scv_hydra/solrizer/field_mapper.rb → cul_hydra/solrizer_patch.rb} +0 -0
  70. data/lib/cul_hydra/version.rb +8 -0
  71. data/lib/cul_hydra/version.rb~ +8 -0
  72. data/lib/cul_scv_fedora/dummy_object.rb +1 -30
  73. data/lib/cul_scv_fedora/rubydora_patch.rb +3 -7
  74. data/lib/cul_scv_fedora/url_helper_behavior.rb +3 -23
  75. data/lib/cul_scv_hydra.rb +5 -32
  76. data/lib/cul_scv_hydra/access_controls_enforcement.rb +3 -50
  77. data/lib/cul_scv_hydra/controllers.rb +10 -10
  78. data/lib/cul_scv_hydra/controllers/aggregates.rb +1 -86
  79. data/lib/cul_scv_hydra/controllers/aggregator_controller_helper.rb +4 -23
  80. data/lib/cul_scv_hydra/controllers/catalog.rb +5 -9
  81. data/lib/cul_scv_hydra/controllers/content_aggregators.rb +4 -77
  82. data/lib/cul_scv_hydra/controllers/datastreams.rb +3 -140
  83. data/lib/cul_scv_hydra/controllers/helpers.rb +44 -8
  84. data/lib/cul_scv_hydra/controllers/resources.rb +4 -157
  85. data/lib/cul_scv_hydra/controllers/static_image_aggregators.rb +4 -100
  86. data/lib/cul_scv_hydra/controllers/suggestions.rb +4 -122
  87. data/lib/cul_scv_hydra/controllers/terms.rb +4 -201
  88. data/lib/cul_scv_hydra/engine.rb +1 -1
  89. data/lib/cul_scv_hydra/indexer.rb +3 -82
  90. data/lib/cul_scv_hydra/om.rb +2 -2
  91. data/lib/cul_scv_hydra/om/standard_mods.rb +1 -108
  92. data/lib/cul_scv_hydra/risearch_members.rb +4 -89
  93. data/lib/cul_scv_hydra/solrizer.rb +5 -6
  94. data/lib/cul_scv_hydra/solrizer/extractor.rb +1 -25
  95. data/lib/cul_scv_hydra/solrizer/scv_mods_fieldable.rb +4 -429
  96. data/lib/cul_scv_hydra/solrizer/terminology_based_solrizer.rb +4 -32
  97. data/lib/cul_scv_hydra/solrizer/value_mapper.rb +1 -44
  98. data/lib/cul_scv_hydra/version.rb +5 -5
  99. data/lib/tasks/index.rake +2 -2
  100. data/lib/tasks/transform.rake +23 -0
  101. metadata +55 -12
@@ -5,7 +5,7 @@ class DcDocument < ActiveFedora::Base
5
5
  include ::ActiveFedora::FinderMethods::RepositoryMethods
6
6
  include ::ActiveFedora::DatastreamCollections
7
7
  include Hydra::ModelMethods
8
- include Cul::Scv::Hydra::Models::Common
8
+ include Cul::Hydra::Models::Common
9
9
  #alias :file_objects :resources
10
10
 
11
11
  has_and_belongs_to_many :parts, :property => :cul_member_of, :class_name=>'ActiveFedora::Base'
@@ -4,8 +4,8 @@ class GenericAggregator < ::ActiveFedora::Base
4
4
  include ::ActiveFedora::FinderMethods::RepositoryMethods
5
5
  include ::ActiveFedora::DatastreamCollections
6
6
  include ::Hydra::ModelMethods
7
- include Cul::Scv::Hydra::Models::Common
8
- include Cul::Scv::Hydra::Models::Aggregator
7
+ include Cul::Hydra::Models::Common
8
+ include Cul::Hydra::Models::Aggregator
9
9
 
10
10
  has_many :parts, :property => :cul_member_of, :class_name=>'ActiveFedora::Base'
11
11
 
@@ -14,9 +14,9 @@ class GenericAggregator < ::ActiveFedora::Base
14
14
  end
15
15
 
16
16
  def index_type_label
17
- riquery = Cul::Scv::Hydra::Models::MEMBER_ITQL.gsub(/%PID%/, self.pid)
17
+ riquery = Cul::Hydra::Models::MEMBER_ITQL.gsub(/%PID%/, self.pid)
18
18
  begin
19
- docs = Cul::Scv::Fedora.repository.find_by_itql riquery, limit: 2, format: 'count/json'
19
+ docs = Cul::Fedora.repository.find_by_itql riquery, limit: 2, format: 'count/json'
20
20
  docs = JSON.parse(docs)['results']
21
21
  size = docs.first && docs.first['count'] && docs.first['count'].to_i
22
22
  rescue Exception=>e
@@ -39,7 +39,7 @@ class GenericAggregator < ::ActiveFedora::Base
39
39
  # set the index type label and any RI-based fields
40
40
  # overridde
41
41
  def set_size_labels(solr_doc={})
42
- count = Cul::Scv::Hydra::RisearchMembers.get_direct_member_count(pid)
42
+ count = Cul::Hydra::RisearchMembers.get_direct_member_count(pid)
43
43
  solr_doc["index_type_label_ssi"] = [type_label_for(count)]
44
44
  solr_doc["cul_number_of_members_isi"] = count
45
45
  end
@@ -5,8 +5,8 @@ class GenericObject < ::ActiveFedora::Base
5
5
  include ::ActiveFedora::FinderMethods::RepositoryMethods
6
6
  include ::ActiveFedora::DatastreamCollections
7
7
  include ::Hydra::ModelMethods
8
- include Cul::Scv::Hydra::Models::Common
9
- include Cul::Scv::Hydra::Models::Aggregator
8
+ include Cul::Hydra::Models::Common
9
+ include Cul::Hydra::Models::Aggregator
10
10
 
11
11
  has_many :parts, :property => :cul_member_of, :class_name=>'ActiveFedora::Base'
12
12
 
@@ -9,9 +9,9 @@ class GenericResource < ::ActiveFedora::Base
9
9
  include ::ActiveFedora::FinderMethods::RepositoryMethods
10
10
  include ::ActiveFedora::DatastreamCollections
11
11
  include ::Hydra::ModelMethods
12
- include Cul::Scv::Hydra::Models::Common
13
- include Cul::Scv::Hydra::Models::ImageResource
14
- include Cul::Scv::Fedora::UrlHelperBehavior
12
+ include Cul::Hydra::Models::Common
13
+ include Cul::Hydra::Models::ImageResource
14
+ include Cul::Hydra::Fedora::UrlHelperBehavior
15
15
  include ::ActiveFedora::RelsInt
16
16
 
17
17
  has_and_belongs_to_many :containers, :property=>:cul_member_of, :class_name=>'ActiveFedora::Base'
@@ -72,8 +72,8 @@ class GenericResource < ::ActiveFedora::Base
72
72
 
73
73
  solr_doc["fulltext_tesim"] = []
74
74
  unless self.datastreams["fulltext"].nil?
75
+ solr_doc["fulltext_tesim"].concat(solr_doc["title_display_ssm"]) unless solr_doc["title_display_ssm"].nil? or solr_doc["title_display_ssm"].length == 0
75
76
  solr_doc["fulltext_tesim"] << self.datastreams["fulltext"].content
76
- solr_doc["fulltext_tesim"] << solr_doc["title_display_ssm"].first unless solr_doc["title_display_ssm"].nil? or solr_doc["title_display_ssm"].length == 0
77
77
  end
78
78
  relationships(:original_name).each do |original_name|
79
79
  solr_doc["original_name_tesim"] ||= []
@@ -5,8 +5,8 @@ class METSStructuredAggregator < ::ActiveFedora::Base
5
5
  include ::ActiveFedora::FinderMethods::RepositoryMethods
6
6
  include ::ActiveFedora::DatastreamCollections
7
7
  include ::Hydra::ModelMethods
8
- include Cul::Scv::Hydra::Models::Common
9
- include Cul::Scv::Hydra::Models::Aggregator
8
+ include Cul::Hydra::Models::Common
9
+ include Cul::Hydra::Models::Aggregator
10
10
 
11
11
  has_many :parts, :property => :cul_member_of, :class_name=>'ActiveFedora::Base'
12
12
 
@@ -7,9 +7,9 @@ class Resource < ActiveFedora::Base
7
7
  include ::ActiveFedora::FinderMethods::RepositoryMethods
8
8
  include ::ActiveFedora::DatastreamCollections
9
9
  # include ::Hydra::ModelMethods
10
- include Cul::Scv::Hydra::Models::Common
11
- include Cul::Scv::Hydra::Models::Resource
12
- include Cul::Scv::Hydra::Models::ImageResource
10
+ include Cul::Hydra::Models::Common
11
+ include Cul::Hydra::Models::Resource
12
+ include Cul::Hydra::Models::ImageResource
13
13
 
14
14
  belongs_to :container, :property=>:cul_member_of, :class_name=>'ActiveFedora::Base'
15
15
 
@@ -2,9 +2,9 @@ class ResourceAggregator < ::ActiveFedora::Base
2
2
  include ::ActiveFedora::FinderMethods::RepositoryMethods
3
3
  include ::ActiveFedora::DatastreamCollections
4
4
  include ::Hydra::ModelMethods
5
- include Cul::Scv::Hydra::Models::Common
6
- include Cul::Scv::Hydra::Models::Aggregator
7
- include Cul::Scv::Hydra::Models::LinkableResources
5
+ include Cul::Hydra::Models::Common
6
+ include Cul::Hydra::Models::Aggregator
7
+ include Cul::Hydra::Models::LinkableResources
8
8
 
9
9
  has_many :parts, :property => :cul_member_of, :class_name=>'Resource'
10
10
 
@@ -41,4 +41,28 @@
41
41
  We Are Currently Ignoring Subject Occupation
42
42
  </occupation>
43
43
  </subject>
44
+ <subject>
45
+ <cartographics>
46
+ <coordinates>40.8075, -73.9619</coordinates>
47
+ </cartographics>
48
+ </subject>
49
+ <subject>
50
+ <cartographics>
51
+ <coordinates>40.6892, -74.0444</coordinates>
52
+ </cartographics>
53
+ </subject>
54
+ <subject>
55
+ <hierarchicalGeographic>
56
+ <country>United States</country>
57
+ <province>Nova Scotia</province>
58
+ <region>Northeast</region>
59
+ <state>New York</state>
60
+ <county>Westchester</county>
61
+ <citySection citySectionType="borough">Brooklyn</citySection>
62
+ <city>White Plains</city>
63
+ <citySection citySectionType="neighborhood">The Backpacking District</citySection>
64
+ <citySection citySectionType="zip code">10027</citySection>
65
+ <citySection citySectionType="street">123 Broadway</citySection>
66
+ </hierarchicalGeographic>
67
+ </subject>
44
68
  </mods>
data/lib/cul_hydra.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'cul_hydra/solrizer_patch'
2
+ module Cul
3
+ module Hydra
4
+ autoload :Controllers, 'cul_hydra/controllers'
5
+ autoload :Fedora, 'cul_hydra/fedora'
6
+ autoload :Om, 'cul_hydra/om'
7
+ autoload :Solrizer, 'cul_hydra/solrizer'
8
+ end
9
+ end
10
+
11
+ require "cul_hydra/access_controls_enforcement"
12
+ require "cul_hydra/controllers"
13
+ require "cul_hydra/om"
14
+ require "cul_hydra/indexer"
15
+ require "cul_hydra/risearch_members"
16
+ require "cul_hydra/solrizer"
17
+ require "cul_hydra/version"
18
+ require "cul_hydra/engine" if defined? Rails
@@ -0,0 +1,53 @@
1
+ module Cul::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
@@ -0,0 +1,13 @@
1
+ module Cul::Hydra
2
+ module Controllers
3
+ autoload :Aggregates, 'cul_hydra/controllers/aggregates'
4
+ autoload :Catalog, 'cul_hydra/controllers/catalog'
5
+ autoload :ContentAggregators, 'cul_hydra/controllers/content_aggregators'
6
+ autoload :Datastreams, 'cul_hydra/controllers/datastreams'
7
+ autoload :Helpers, 'cul_hydra/controllers/helpers'
8
+ autoload :Resources, 'cul_hydra/controllers/resources'
9
+ autoload :StaticImageAggregators, 'cul_hydra/controllers/static_image_aggregators'
10
+ autoload :Suggestions, 'cul_hydra/controllers/suggestions'
11
+ autoload :Terms, 'cul_hydra/controllers/terms'
12
+ end
13
+ end
@@ -0,0 +1,93 @@
1
+ require 'cul_hydra/controllers/aggregator_controller_helper'
2
+ require 'cul_hydra/controllers/helpers/resources_helper_behavior'
3
+ module Cul::Hydra::Controllers
4
+ module Aggregates
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ include Hydra::AssetsControllerHelper
8
+ include Cul::Hydra::Controllers::AggregatorControllerHelper
9
+ include Cul::Hydra::Controllers::Helpers::ResourcesHelperBehavior
10
+ include Hydra::RepositoryController
11
+ include MediaShelf::ActiveFedoraHelper
12
+ include Blacklight::SolrHelper
13
+ before_filter :load_resources, :only=>[:index]
14
+ prepend_before_filter :sanitize_update_params
15
+ end
16
+
17
+ def index
18
+
19
+ if params[:layout] == "false"
20
+ layout = false
21
+ end
22
+ container_uri = "info:fedora/#{params[:asset_id]}"
23
+ escaped_uri = container_uri.gsub(/(:)/, '\\:')
24
+ extra_controller_params = {:q=>"cul_member_of_s:#{escaped_uri}"}
25
+ @response, @document_list = get_search_results( extra_controller_params )
26
+
27
+ # Including this line so permissions tests can be run against the container
28
+ @container_response, @document = get_solr_response_for_doc_id(params[:asset_id])
29
+
30
+ render :action=>params[:action], :layout=>layout
31
+ end
32
+
33
+ def load_aggregate
34
+ if params.has_key? :aggregate_id
35
+ af_base = ActiveFedora::Base.load_instance(params[:aggregate_id])
36
+ else
37
+ af_base = ActiveFedora::Base.load_instance(params[:id])
38
+ end
39
+ the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first
40
+ if the_model.nil? or the_model == ActiveFedora::Base
41
+ the_model = DcDocument
42
+ end
43
+
44
+ @resource = the_model.load_instance(af_base.pid)
45
+ end
46
+
47
+ # Creates and Saves a Parent - Child relationship in the Child's RELS-EXT
48
+ # If container_id is provided:
49
+ # * the File Asset will use RELS-EXT to assert that it's a part of the specified container
50
+ # * the method will redirect to the container object's edit view after saving
51
+ def create
52
+ if params.has_key?(:aggregate_id)
53
+ @resource = load_aggregate
54
+ logger.debug @resource.class
55
+ logger.debug @resource.datastreams["RELS-EXT"].content
56
+ logger.debug @resource.to_rels_ext(@resource.pid)
57
+ if !params[:asset_id].nil?
58
+ associate_resource_with_container(@resource, params[:asset_id])
59
+ @resource.save
60
+ flash[:notice] = "Aggregated #{@resource.pid} under #{params[:asset_id]}."
61
+ else
62
+ flash[:notice] = "You must specify a container for the aggregate."
63
+ end
64
+ else
65
+ flash[:notice] = "You must specify a resource to aggregate."
66
+ end
67
+
68
+ if !params[:asset_id].nil?
69
+ redirect_params = {:controller=>"aggregates", :id=>params[:asset_id], :action=>:index}
70
+ end
71
+
72
+ redirect_params ||= {:action=>:index}
73
+
74
+ redirect_to redirect_params
75
+ end
76
+
77
+ # Common destroy method for all AssetsControllers
78
+ def destroy
79
+ @resource = load_aggregate
80
+ remove_resource_from_container(@resource, params[:asset_id])
81
+ @resource.save
82
+
83
+ flash[:notice] = "Deleted #{params[:id]} from #{params[:asset_id]}."
84
+ if !params[:asset_id].nil?
85
+ redirect_params = {:controller=>"aggregates", :id=>params[:asset_id], :action=>:index}
86
+ end
87
+
88
+ redirect_params ||= {:action=>:index}
89
+
90
+ redirect_to redirect_params
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,27 @@
1
+ require 'active-fedora'
2
+ module Cul::Hydra::Controllers
3
+ module AggregatorControllerHelper
4
+ def load_fedora_document
5
+ if params.has_key? :asset_id
6
+ af_base = ActiveFedora::Base.load_instance(params[:asset_id])
7
+ else
8
+ af_base = ActiveFedora::Base.load_instance(params[:id])
9
+ end
10
+ the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first
11
+ if the_model.nil? or the_model == ActiveFedora::Base
12
+ the_model = DcDocument
13
+ end
14
+
15
+ @document_fedora = af_base.adapt_to the_model
16
+ end
17
+ def load_resources
18
+ @document_fedora ||= load_fedora_document
19
+ if @document_fedora.is_a? Cul::Hydra::ActiveFedora::Model::Aggregator
20
+ @resources = @document_fedora.resources
21
+ else
22
+ logger.debug "Only aggregators have parts!"
23
+ end
24
+ @resources
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ require 'cul_hydra/controllers/aggregator_controller_helper'
2
+ require 'cul_hydra/controllers/helpers/active_fedora_helper_behavior'
3
+ module Cul::Hydra::Controllers
4
+ module Catalog
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ include Cul::Hydra::Controllers::AggregatorControllerHelper
8
+ include Cul::Hydra::Controllers::Helpers::ActiveFedoraHelperBehavior
9
+ before_filter :load_resources, :only=>[:show, :edit]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,81 @@
1
+ require 'cul_hydra/controllers/helpers/resources_helper_behavior'
2
+ module Cul::Hydra::Controllers
3
+ module ContentAggregators
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ include Hydra::AssetsControllerHelper
7
+ include Cul::Hydra::Controllers::Helpers::ResourcesHelperBehavior
8
+ include Hydra::RepositoryController
9
+ include MediaShelf::ActiveFedoraHelper
10
+ include Blacklight::SolrHelper
11
+ prepend_before_filter :sanitize_update_params
12
+ end
13
+
14
+ def index
15
+ if params[:layout] == "false"
16
+ # action = "index_embedded"
17
+ layout = false
18
+ end
19
+ if !params[:container_id].nil?
20
+ container_uri = "info:fedora/#{params[:container_id]}"
21
+ escaped_uri = container_uri.gsub(/(:)/, '\\:')
22
+ extra_controller_params = {:q=>"cul_member_of_s:#{escaped_uri}"}
23
+ @response, @document_list = get_search_results( extra_controller_params )
24
+
25
+ # Including this line so permissions tests can be run against the container
26
+ @container_response, @document = get_solr_response_for_doc_id(params[:container_id])
27
+
28
+ # Including these lines for backwards compatibility (until we can use Rails3 callbacks)
29
+ @container = ActiveFedora::Base.load_instance(params[:container_id])
30
+ @solr_result = @container.file_objects(:response_format=>:solr)
31
+ else
32
+ # @solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_field:info\:fedora/ldpd\:Resource', @search_params)
33
+ @solr_result = Resource.find_by_solr(:all)
34
+ end
35
+ render :action=>params[:action], :layout=>layout
36
+ end
37
+
38
+ def new
39
+ @asset = ContentAggregator.new
40
+ apply_depositor_metadata(@asset)
41
+ set_collection_type(@asset, params[:content_type])
42
+ if !params[:container_id].nil?
43
+ associate_resource_with_container(@asset, params[:container_id])
44
+ end
45
+ @asset.save
46
+ msg = "Created a Content Aggregator with pid #{@asset.pid}. Now it's ready to be edited."
47
+ flash[:notice]= msg
48
+
49
+ session[:scripts] = params[:combined] == "true"
50
+ redirect_to url_for(:action=>"edit", :id=>@asset.pid, :new_asset=>true, :controller=>'catalog')
51
+
52
+ end
53
+
54
+ # Common destroy method for all AssetsControllers
55
+ def destroy
56
+ # The correct implementation, with garbage collection:
57
+ # if params.has_key?(:container_id)
58
+ # container = ActiveFedora::Base.load_instance(params[:container_id])
59
+ # container.file_objects_remove(params[:id])
60
+ # FileAsset.garbage_collect(params[:id])
61
+ # else
62
+
63
+ # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers)
64
+ ActiveFedora::Base.load_instance(params[:id]).delete
65
+ render :text => "Deleted #{params[:id]} from #{params[:container_id]}."
66
+ end
67
+
68
+
69
+ def show
70
+ @image_agg = ContentAggregator.find(params[:id])
71
+ if (@image_agg.nil?)
72
+ logger.warn("No such object: " + params[:id])
73
+ flash[:notice]= "No such object."
74
+ redirect_to(:action => 'index', :q => nil , :f => nil)
75
+ else
76
+ @id_array = @image_agg.containers(:response_format => :id_array)
77
+ end
78
+ render :action=>params[:action], :layout=>(params[:layout]=="false")
79
+ end
80
+ end
81
+ end