Module: Cul::Hydra::Controllers::StaticImageAggregators
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cul_hydra/controllers/static_image_aggregators.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
Common destroy method for all AssetsControllers.
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
Instance Method Details
#destroy ⇒ Object
Common destroy method for all AssetsControllers
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cul_hydra/controllers/static_image_aggregators.rb', line 79 def destroy # The correct implementation, with garbage collection: # if params.has_key?(:container_id) # container = ActiveFedora::Base.load_instance(params[:container_id]) # container.file_objects_remove(params[:id]) # FileAsset.garbage_collect(params[:id]) # else # The dirty implementation (leaves relationship in container object, deletes regardless of whether the file object has other containers) ActiveFedora::Base.load_instance(params[:id]).delete render :text => "Deleted #{params[:id]} from #{params[:container_id]}." end |
#index ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/cul_hydra/controllers/static_image_aggregators.rb', line 16 def index if params[:layout] == "false" # action = "index_embedded" layout = false end if !params[:container_id].nil? container_uri = "info:fedora/#{params[:container_id]}" escaped_uri = container_uri.gsub(/(:)/, '\\:') extra_controller_params = {:q=>"cul_member_of_s:#{escaped_uri}"} @response, @document_list = get_search_results( extra_controller_params ) # Including this line so permissions tests can be run against the container @container_response, @document = get_solr_response_for_doc_id(params[:container_id]) # Including these lines for backwards compatibility (until we can use Rails3 callbacks) @container = ActiveFedora::Base.load_instance(params[:container_id]) @solr_result = @container.file_objects(:response_format=>:solr) else # @solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_field:info\:fedora/ldpd\:Resource', @search_params) @solr_result = Resource.find_by_solr(:all) end render :action=>params[:action], :layout=>layout end |
#new ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cul_hydra/controllers/static_image_aggregators.rb', line 40 def new @asset = StaticImageAggregator.new (@asset) set_collection_type(@asset, params[:content_type]) if !params[:container_id].nil? associate_resource_with_container(@asset, params[:container_id]) end @asset.save @asset.refresh msg = "Created a Static Image Aggregator with pid #{@asset.pid}. Now it's ready to be edited." flash[:notice]= msg if params.has_key?(:Filedata) @file_asset = create_and_save_resource_from_params (@file_asset) flash[:notice] += " The file #{params[:Filename]} has been saved in <a href=\"#{asset_url(@file_asset.pid)}\">#{@file_asset.pid}</a>." if !params[:container_id].nil? associate_resource_with_container(@file_asset, @asset.pid) end ## Apply any posted file metadata unless params[:asset].nil? logger.debug("applying submitted file metadata: #{@sanitized_params.inspect}") @metadata_update_response = update_document(@file_asset, @sanitized_params) end @file_asset.save # If redirect_params has not been set, use {:action=>:index} logger.debug "Created #{@file_asset.pid}." end @asset.save session[:scripts] = params[:combined] == "true" redirect_to url_for(:action=>"edit", :id=>@asset.pid, :new_asset=>true, :controller=>'catalog') end |
#show ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cul_hydra/controllers/static_image_aggregators.rb', line 93 def show @image_agg = StaticImageAggregator.find(params[:id]) if (@image_agg.nil?) logger.warn("No such object: " + params[:id]) flash[:notice]= "No such object." redirect_to(:action => 'index', :q => nil , :f => nil) else @id_array = @image_agg.containers(:response_format => :id_array) end render :action=>params[:action], :layout=>(params[:layout]=="false") end |