cul_scv_hydra 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
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,18 @@
1
+ require "active-fedora"
2
+ require "cul_scv_hydra/om"
3
+ require 'uri'
4
+ require 'rdf'
5
+ module Cul
6
+ module Scv
7
+ module Hydra
8
+ module ActiveFedora
9
+ AGGREGATOR_TYPE = (URI.parse("http://purl.oclc.org/NET/CUL/Aggregator"))
10
+ RESOURCE_TYPE = (URI.parse("http://purl.oclc.org/NET/CUL/Resource"))
11
+ MEMBER_QUERY = <<-SPARQL
12
+ SELECT ?pid WHERE { ?pid <http://purl.oclc.org/NET/CUL/memberOf> <info:fedora/%PID%> }
13
+ SPARQL
14
+ end
15
+ end
16
+ end
17
+ end
18
+ require 'cul_scv_hydra/active_fedora/model.rb'
@@ -0,0 +1,8 @@
1
+ module Cul::Scv::Hydra::ActiveFedora
2
+ module Model
3
+ end
4
+ end
5
+ require 'cul_scv_hydra/active_fedora/model/aggregator'
6
+ require 'cul_scv_hydra/active_fedora/model/common'
7
+ require 'cul_scv_hydra/active_fedora/model/dcdocument'
8
+ require 'cul_scv_hydra/active_fedora/model/resource'
@@ -0,0 +1,45 @@
1
+ module Cul::Scv::Hydra::ActiveFedora::Model
2
+ module Aggregator
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_relationship "parts", :cul_member_of, :inbound => true
7
+ after_create :aggregator!
8
+ end
9
+ module InstanceMethods
10
+ def aggregator!
11
+ add_relationship(:rdf_type, Cul::Scv::Hydra::ActiveFedora::AGGREGATOR_TYPE.to_s)
12
+ @metadata_is_dirty = true
13
+ update
14
+ end
15
+
16
+ def add_member(member, container=self)
17
+ if container.respond_to?:internal_uri
18
+ container = container.internal_uri
19
+ end
20
+ if container =~ /\A[\w\-]+:[\w\-]+\Z/
21
+ container = "info:fedora/#{container}"
22
+ end
23
+ member.add_relationship(:cul_member_of, container)
24
+ member.datastreams["RELS-EXT"].dirty = true
25
+ member.save
26
+ end
27
+
28
+ def remove_member(member, container=self)
29
+ if container.respond_to?:internal_uri
30
+ container = container.internal_uri
31
+ end
32
+ if container =~ /\A[\w\-]+:[\w\-]+\Z/
33
+ container = "info:fedora/#{container}"
34
+ end
35
+ rel = ActiveFedora::Relationship.new()
36
+ rel.subject_pid= :self
37
+ rel.object = container
38
+ rel.predicate = :cul_member_of
39
+ member.remove_relationship(rel)
40
+ member.datastreams["RELS-EXT"].dirty = true
41
+ member.save
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,221 @@
1
+ require "active-fedora"
2
+ require 'uri'
3
+ module Cul::Scv::Hydra::ActiveFedora::Model
4
+ module Common
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ define_model_callbacks :create
9
+
10
+ has_relationship "containers", :cul_member_of
11
+ has_relationship "rdf_type", :rdf_type
12
+ has_metadata :name => "DC", :type=>Cul::Scv::Hydra::Om::DCMetadata, :versionable => true
13
+ has_metadata :name => "descMetadata", :type=>Cul::Scv::Hydra::Om::ModsDocument, :versionable => true
14
+ has_metadata :name => "rightsMetadata", :type=>::Hydra::RightsMetadata, :versionable => true
15
+ end
16
+
17
+ module ClassMethods
18
+ def pid_namespace
19
+ "ldpd"
20
+ end
21
+ end
22
+
23
+ module InstanceMethods
24
+ def initialize(attrs = nil)
25
+ attrs = {} if attrs.nil?
26
+ attrs[:namespace] = self.class.pid_namespace unless attrs[:namespace]
27
+ super
28
+ end
29
+
30
+ def create
31
+ run_callbacks :create do
32
+ super
33
+ end
34
+ end
35
+
36
+ def resources(opts={})
37
+ if self.respond_to? :parts # aggregator
38
+ opts = {:rows=>25,:response_format=>:solr}.merge(opts)
39
+ self.parts(opts)
40
+ #opts = {:rows=>25,:response_format=>:solr}.merge(opts)
41
+ #query = self.class.inbound_relationship_query(self.pid, "parts")
42
+ #solr_result = ::ActiveFedora::SolrService.instance.conn.query(query, :rows=>opts[:rows])
43
+ #if opts[:response_format] == :solr
44
+ # return solr_result
45
+ #else
46
+ # if opts[:response_format] == :id_array
47
+ # id_array = []
48
+ # solr_result.hits.each do |hit|
49
+ # id_array << hit[SOLR_DOCUMENT_ID]
50
+ # end
51
+ # return id_array
52
+ # elsif opts[:response_format] == :load_from_solr || self.load_from_solr
53
+ # return ::ActiveFedora::SolrService.reify_solr_results(solr_result,{:load_from_solr=>true})
54
+ # else
55
+ # return ::ActiveFedora::SolrService.reify_solr_results(solr_result)
56
+ # end
57
+ #end
58
+ else
59
+ logger.warn "parts not defined; was this an Aggregator?"
60
+ []
61
+ end
62
+ end
63
+
64
+ def members(opts={})
65
+ resources(opts)
66
+ end
67
+
68
+ def members_ids(opts={})
69
+ opts = opts.merge({:response_format=>:id_array})
70
+ resources(opts)
71
+ end
72
+
73
+
74
+ def cmodel_pid(klass)
75
+ klass.pid_namespace + ":" + klass.name.split("::")[-1]
76
+ end
77
+
78
+ def datastreams_in_fedora
79
+ mds = {}
80
+ self.datastreams_xml['datastream'].each do |ds|
81
+ dsid = ds["dsid"]
82
+ ds.merge!({:pid => self.pid, :dsID => dsid, :dsLabel => ds["label"]})
83
+ if dsid == "RELS-EXT"
84
+ mds.merge!({dsid => ActiveFedora::RelsExtDatastream.new(ds)})
85
+ else
86
+ if self.class.ds_specs.has_key? dsid
87
+ mds.merge!({dsid => self.class.ds_specs[dsid][0].new(ds)})
88
+ else
89
+ mds.merge!({dsid => ActiveFedora::Datastream.new(ds)})
90
+ end
91
+ end
92
+ mds[dsid].new_object = false
93
+ end
94
+ mds
95
+ end
96
+ end
97
+
98
+ def route_as
99
+ "default"
100
+ end
101
+
102
+ def index_type_label
103
+ riquery = Cul::Scv::Hydra::ActiveFedora::MEMBER_QUERY.gsub(/%PID%/, self.pid)
104
+ begin
105
+ docs = ::ActiveFedora::RubydoraConnection.instance.connection.find_by_sparql riquery
106
+ rescue
107
+ docs = self.parts
108
+ end
109
+ if docs.length == 0
110
+ label = "EMPTY"
111
+ elsif docs.length == 1
112
+ label = "SINGLE PART"
113
+ else
114
+ label = "MULTIPART"
115
+ end
116
+ label
117
+ end
118
+
119
+ def has_desc?
120
+ has_desc = false
121
+ begin
122
+ has_desc = self.datastreams.include? "descMetadata"
123
+ has_desc = has_desc and self.inner_object.datastreams["descMetadata"].content.length > 0
124
+ has_desc = self.datastreams["descMetadata"].term_values(:identifier).length > 0
125
+ rescue
126
+ has_desc = false
127
+ end
128
+ has_desc
129
+ end
130
+
131
+ def to_solr(solr_doc = Hash.new, opts={})
132
+ super
133
+ if has_desc?
134
+ solr_doc["descriptor_s"] = ["mods"]
135
+ else
136
+ solr_doc["descriptor_s"] = ["dublin core"]
137
+ end
138
+ # if no mods, pull some values from DC
139
+ if not (solr_doc["title_display"] and solr_doc["title_display"].length > 0)
140
+ if self.dc.term_values(:title).first
141
+ solr_doc["title_display"] = [self.dc.term_values(:title).first]
142
+ else
143
+ solr_doc["title_display"] = [self.dc.term_values(:identifier).first]
144
+ end
145
+ if self.dc.term_values(:relation).first
146
+ self.dc.term_values(:relation).each {|val|
147
+ if val =~ /clio:/
148
+ solr_doc["clio_s"] ||= []
149
+ solr_doc["clio_s"] << val.split(':')[-1]
150
+ end
151
+ }
152
+ end
153
+ end
154
+ solr_doc["format"] = [self.route_as]
155
+ solr_doc["index_type_label_s"] = [self.index_type_label]
156
+ solr_doc
157
+ end
158
+
159
+ def update_datastream_attributes(params={}, opts={})
160
+ logger.debug "Common.update_datastream_attributes"
161
+ result = params.dup
162
+ params.each_pair do |dsid, ds_params|
163
+ if datastreams.include?(dsid)
164
+ verify_params = ds_params.dup
165
+ current_indexed_attributes = {}
166
+ changed = false
167
+ verify_params.each { |pointer, values|
168
+ changed ||= value_changed?(datastreams[dsid],pointer,values)
169
+ }
170
+ if changed
171
+ logger.debug "Common.update_datastream_attributes calling update_indexed_attributes"
172
+ result[dsid] = datastreams[dsid].update_indexed_attributes(ds_params)
173
+ else
174
+ result[dsid] = no_update(ds_params)
175
+ end
176
+ logger.debug "change detected? #{changed} digital_object? #{datastreams[dsid].changed?}"
177
+ else
178
+ result.delete(dsid)
179
+ end
180
+ end
181
+ return result
182
+ end
183
+
184
+ private
185
+ def value_changed?(ds,pointer,values)
186
+ if values.is_a? Hash
187
+ values = values.dup
188
+ else
189
+ values = {"0"=>values}
190
+ end
191
+ logger.debug "submitted values for #{pointer.inspect} : #{values.inspect}"
192
+ return true if values["-1"]
193
+ changed = false
194
+ old_values = ds.get_values(pointer)
195
+ indexed_values = {}
196
+ old_values.each_index {|ix| indexed_values[ix.to_s] = old_values[ix] }
197
+ indexed_values.each {|k,v|
198
+ new_val = values.delete(k)
199
+ puts "old: #{v} new: #{new_val} changed? #{!(v.eql? new_val)}"
200
+ logger.debug "old: #{v} new: #{new_val} changed? #{!(v.eql? new_val)}"
201
+ changed ||= !(v.eql? new_val)
202
+ }
203
+ puts "remaining values! #{values.inspect}" if values.length > 0
204
+ changed || (values.length > 0)
205
+ end
206
+
207
+ def no_update(ds_params)
208
+ response = {}
209
+ ds_params.each{|pointer, values|
210
+ returned = []
211
+ if values.is_a? Hash
212
+ keys = values.keys.sort {|x,y| x.to_i <=> y.to_i}
213
+ keys.each {|key| returned << values[key]}
214
+ else
215
+ returned << values
216
+ end
217
+ response[OM::XML::Terminology.term_hierarchical_name(pointer)] = returned
218
+ }
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,43 @@
1
+ require "active-fedora"
2
+ require "cul_scv_hydra/active_fedora"
3
+ require "hydra"
4
+ module Cul::Scv::Hydra::ActiveFedora::Model
5
+ class DcDocument < ::ActiveFedora::Base
6
+ include ::ActiveFedora::Relationships
7
+ include ::Hydra::ModelMethods
8
+ include Cul::Scv::Hydra::ActiveFedora::Model::Common
9
+ alias :file_objects :resources
10
+
11
+ # relationships #
12
+ has_relationship "containers", :cul_member_of
13
+ has_relationship "parts", :cul_member_of, :inbound => true
14
+
15
+ def self.load_instance_from_solr(pid,solr_doc=nil)
16
+ if solr_doc.nil?
17
+ result = find_by_solr(pid)
18
+ raise "Object #{pid} not found in solr" if result.nil?
19
+ solr_doc = result.hits.first
20
+ #double check pid and id in record match
21
+ raise "Object #{pid} not found in Solr" unless !result.nil? && !solr_doc.nil? && pid == solr_doc[SOLR_DOCUMENT_ID]
22
+ else
23
+ raise "Solr document record id and pid do not match" unless pid == solr_doc[SOLR_DOCUMENT_ID]
24
+ end
25
+
26
+ create_date = solr_doc[::ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[::ActiveFedora::SolrService.solr_name(:system_create, :date).to_s] : solr_doc[::ActiveFedora::SolrService.solr_name(:system_create, :date)]
27
+ modified_date = solr_doc[::ActiveFedora::SolrService.solr_name(:system_create, :date)].nil? ? solr_doc[::ActiveFedora::SolrService.solr_name(:system_modified, :date).to_s] : solr_doc[::ActiveFedora::SolrService.solr_name(:system_modified, :date)]
28
+ obj = DcDocument.new({:pid=>solr_doc[SOLR_DOCUMENT_ID],:create_date=>create_date,:modified_date=>modified_date})
29
+ obj.new_object = false
30
+ #set by default to load any dependent relationship objects from solr as well
31
+ obj.load_from_solr = true
32
+ #need to call rels_ext once so it exists when iterating over datastreams
33
+ obj.rels_ext
34
+ obj.datastreams.each_value do |ds|
35
+ if ds.respond_to?(:from_solr)
36
+ ds.from_solr(solr_doc) if ds.kind_of?(::ActiveFedora::MetadataDatastream) || ds.kind_of?(::ActiveFedora::NokogiriDatastream) || ( ds.kind_of?(::ActiveFedora::RelsExtDatastream))
37
+ end
38
+ end
39
+ obj
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,79 @@
1
+ module Cul::Scv::Hydra::ActiveFedora::Model
2
+ module Resource
3
+ extend ActiveSupport::Concern
4
+ # constants #
5
+ IMAGE_MIME_TYPES = [
6
+ 'image/bmp',
7
+ 'image/gif',
8
+ 'image/jpeg',
9
+ 'image/png',
10
+ 'image/tiff'
11
+ ]
12
+
13
+ included do
14
+ if self.respond_to? :has_relationship
15
+ has_relationship "image_width", :image_width
16
+ has_relationship "image_length", :image_length
17
+ has_relationship "x_sampling", :x_sampling
18
+ has_relationship "y_sampling", :y_sampling
19
+ has_relationship "sampling_unit", :sampling_unit
20
+ has_relationship "extent", :extent
21
+
22
+ after_create :resource!
23
+ end
24
+ if self.respond_to? :has_datastream
25
+ has_datastream :name => "CONTENT", :type=>::ActiveFedora::Datastream, :versionable => true
26
+ end
27
+ end
28
+ module InstanceMethods
29
+ def resource!
30
+ add_relationship(:rdf_type, Cul::Scv::Hydra::ActiveFedora::RESOURCE_TYPE.to_s)
31
+ @metadata_is_dirty = true
32
+ update
33
+ end
34
+
35
+ def add_content_blob(blob, opts)
36
+ file_name = opts[:file_name]
37
+ mime = opts[:mime_type].nil? ? mime_type(file_name) : opts[:mime_type]
38
+ add_file_datastream(blob, :label=>file_name, :mimeType=>mime, :dsid => 'CONTENT')
39
+ set_title_and_label( file_name, :only_if_blank=>true )
40
+ if IMAGE_MIME_TYPES.include? mime
41
+ blob.rewind
42
+ # retrieve Nokogiri of image property RDF
43
+ image_prop_nodes = Cul::Image::Properties.identify(blob).nodeset
44
+ relsext = datastreams['RELS-EXT']
45
+ image_prop_nodes.each { |node|
46
+ if node["resource"]
47
+ is_literal = false
48
+ object = RDF::URI.new(node["resource"])
49
+ else
50
+ is_literal = true
51
+ object = RDF::Literal(node.text)
52
+ end
53
+ subject = RDF::URI(internal_uri)
54
+ predicate = RDF::URI("#{node.namespace.href}#{node.name}")
55
+ query = RDF::Query.new({ :subject => {predicate => :object}})
56
+ relationships(predicate).dup.each { |stmt|
57
+ relationships.delete(stmt)
58
+ }
59
+ add_relationship(predicate,object, is_literal)
60
+ relationships_are_dirty=true
61
+ }
62
+ # add mimetype to DC:format values
63
+ self.datastreams['DC'].update_values({[:format] => mime})
64
+ end
65
+ blob.rewind
66
+ end
67
+
68
+ private
69
+
70
+ # Return the mimeType for a given file name
71
+ # @param [String] file_name The filename to use to get the mimeType
72
+ # @return [String] mimeType for filename passed in. Default: application/octet-stream if mimeType cannot be determined
73
+ def mime_type file_name
74
+ mime_types = MIME::Types.of(file_name)
75
+ mime_type = mime_types.empty? ? "application/octet-stream" : mime_types.first.content_type
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,13 @@
1
+ module Cul::Scv::Hydra
2
+ module Controllers
3
+ end
4
+ end
5
+ require 'cul_scv_hydra/controllers/aggregates'
6
+ require 'cul_scv_hydra/controllers/catalog'
7
+ require 'cul_scv_hydra/controllers/content_aggregators'
8
+ require 'cul_scv_hydra/controllers/datastreams'
9
+ require 'cul_scv_hydra/controllers/helpers'
10
+ require 'cul_scv_hydra/controllers/resources'
11
+ require 'cul_scv_hydra/controllers/static_image_aggregators'
12
+ require 'cul_scv_hydra/controllers/suggestions'
13
+ require 'cul_scv_hydra/controllers/terms'
@@ -0,0 +1,95 @@
1
+ require 'cul_scv_hydra/controllers/aggregator_controller_helper'
2
+ require 'cul_scv_hydra/controllers/helpers/resources_helper_behavior'
3
+ module Cul::Scv::Hydra::Controllers
4
+ module Aggregates
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ include Hydra::AssetsControllerHelper
8
+ include Cul::Scv::Hydra::Controllers::AggregatorControllerHelper
9
+ include Cul::Scv::Hydra::Controllers::Helpers::ResourcesHelperBehavior
10
+ include Hydra::RepositoryController
11
+ include MediaShelf::ActiveFedoraHelper
12
+ include Blacklight::SolrHelper
13
+ before_filter :require_solr, :only=>[:index, :create, :show, :destroy]
14
+ before_filter :load_resources, :only=>[:index]
15
+ prepend_before_filter :sanitize_update_params
16
+ end
17
+ module InstanceMethods
18
+ def index
19
+
20
+ if params[:layout] == "false"
21
+ layout = false
22
+ end
23
+ container_uri = "info:fedora/#{params[:asset_id]}"
24
+ escaped_uri = container_uri.gsub(/(:)/, '\\:')
25
+ extra_controller_params = {:q=>"cul_member_of_s:#{escaped_uri}"}
26
+ @response, @document_list = get_search_results( extra_controller_params )
27
+
28
+ # Including this line so permissions tests can be run against the container
29
+ @container_response, @document = get_solr_response_for_doc_id(params[:asset_id])
30
+
31
+ render :action=>params[:action], :layout=>layout
32
+ end
33
+
34
+ def load_aggregate
35
+ if params.has_key? :aggregate_id
36
+ af_base = ActiveFedora::Base.load_instance(params[:aggregate_id])
37
+ else
38
+ af_base = ActiveFedora::Base.load_instance(params[:id])
39
+ end
40
+ the_model = ActiveFedora::ContentModel.known_models_for( af_base ).first
41
+ if the_model.nil? or the_model == ActiveFedora::Base
42
+ the_model = DcDocument
43
+ end
44
+
45
+ @resource = the_model.load_instance(af_base.pid)
46
+ end
47
+
48
+ # Creates and Saves a Parent - Child relationship in the Child's RELS-EXT
49
+ # If container_id is provided:
50
+ # * the File Asset will use RELS-EXT to assert that it's a part of the specified container
51
+ # * the method will redirect to the container object's edit view after saving
52
+ def create
53
+ if params.has_key?(:aggregate_id)
54
+ @resource = load_aggregate
55
+ logger.debug @resource.class
56
+ logger.debug @resource.datastreams["RELS-EXT"].content
57
+ logger.debug @resource.to_rels_ext(@resource.pid)
58
+ if !params[:asset_id].nil?
59
+ associate_resource_with_container(@resource, params[:asset_id])
60
+ @resource.save
61
+ flash[:notice] = "Aggregated #{@resource.pid} under #{params[:asset_id]}."
62
+ else
63
+ flash[:notice] = "You must specify a container for the aggregate."
64
+ end
65
+ else
66
+ flash[:notice] = "You must specify a resource to aggregate."
67
+ end
68
+
69
+ if !params[:asset_id].nil?
70
+ redirect_params = {:controller=>"aggregates", :id=>params[:asset_id], :action=>:index}
71
+ end
72
+
73
+ redirect_params ||= {:action=>:index}
74
+
75
+ redirect_to redirect_params
76
+ end
77
+
78
+ # Common destroy method for all AssetsControllers
79
+ def destroy
80
+ @resource = load_aggregate
81
+ remove_resource_from_container(@resource, params[:asset_id])
82
+ @resource.save
83
+
84
+ flash[:notice] = "Deleted #{params[:id]} from #{params[:asset_id]}."
85
+ if !params[:asset_id].nil?
86
+ redirect_params = {:controller=>"aggregates", :id=>params[:asset_id], :action=>:index}
87
+ end
88
+
89
+ redirect_params ||= {:action=>:index}
90
+
91
+ redirect_to redirect_params
92
+ end
93
+ end
94
+ end
95
+ end