Module: Cul::Hydra::Controllers::ContentAggregators

Extended by:
ActiveSupport::Concern
Defined in:
lib/cul_hydra/controllers/content_aggregators.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

Common destroy method for all AssetsControllers



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cul_hydra/controllers/content_aggregators.rb', line 55

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

#indexObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cul_hydra/controllers/content_aggregators.rb', line 14

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

#newObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cul_hydra/controllers/content_aggregators.rb', line 38

def new
  @asset = ContentAggregator.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
  msg = "Created a Content Aggregator with pid #{@asset.pid}. Now it's ready to be edited."
  flash[:notice]= msg

  session[:scripts] = params[:combined] == "true"
  redirect_to url_for(:action=>"edit", :id=>@asset.pid, :new_asset=>true, :controller=>'catalog')

end

#showObject



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cul_hydra/controllers/content_aggregators.rb', line 69

def show
  @image_agg = ContentAggregator.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