Class: Ld4lVirtualCollection::ItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ld4l_virtual_collection/items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /collections/1/items



30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 30

def create
  # puts("*** Entering CTRL: create item")
  @item = Item.new(@collection, item_params)

  # TODO How to save only affected items & collection instead of all items & collection???
  if LD4L::OreRDF::PersistAggregation.call(@collection) == true
    redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Item was successfully created.'
  else
    # TODO How to add error message about what failed to persist???
    render :new
  end
end

#destroyObject

DELETE /collections/1/items/1



62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 62

def destroy
  # puts("*** Entering CTRL: destroy item")
  # TODO -- need to implement destroy in ORE Gem -- Destroying just the item leaves the aggregates triples
  @item.destroy   ## TODO REMOVE THIS LINE WHEN DestroyProxy IS IMPLEMENTED
  # if LD4L::OreRDF::DestroyProxy.call(@collection,@item.rdf_subject) == true
  redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Item was successfully removed.'
  # else
  #   # TODO Should it redirect to edit???  OR list???  OR  where???
  #   # TODO How to add error message about what failed to be destroyed???
  #  render :edit
  # end
end

#editObject

GET /items/1/edit



25
26
27
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 25

def edit
  # puts("*** Entering CTRL: edit item")
end

#indexObject

GET /collections/1/items



9
10
11
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 9

def index
  @items = Item.all(@collection)
end

#metadata_from_uriObject

GET /collections/1/items/1



56
57
58
59
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 56

def 
  # puts("*** Entering CTRL: create_from_uri (item)")
  LD4L::WorksRDF::GetMetadataFromURI(@proxy_for)
end

#newObject

GET /collections/1/items/new



18
19
20
21
22
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 18

def new
  # puts("*** Entering CTRL: new item")
  @item = Item.new(@collection)
  @proxy_for = ""
end

#showObject

GET /collections/1/items/1



14
15
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 14

def show
end

#updateObject

PATCH/PUT /collections/1/items/1



44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/ld4l_virtual_collection/items_controller.rb', line 44

def update
  # puts("*** Entering CTRL: update item")
  @item = Item.update(@collection, @item, item_params)
  # TODO How to save only affected items & collection instead of all items & collection???
  if LD4L::OreRDF::PersistAggregation.call(@collection) == true
    redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Item was successfully updated.'
  else
    render :edit
  end
end