-
Notifications
You must be signed in to change notification settings - Fork 20
Dive Into Curation Concerns
Esmé Cowles edited this page Apr 29, 2016
·
13 revisions
- AF: provides ActiveRecord-style modeling for Fedora
- Hydra::PCDM: provides the basic PCDM classes and relationships
- Hydra::Works: adds Works and FileSets, plus a Swiss Army Knife of repository functionality
- CurationConcerns: adds a Rails engine, views, controllers, etc.
- Sufia 7: rebuilding Sufia on top of CurationConcerns, adds dashboards, reporting, and other IR functionality
- standard hydra test/development infrastructure
- download solr and fcrepo and quickly spin up with minimal config
- do not use in production: they delete data
- fedora
- separate machine with tomcat or jetty
- files on network storage
- relational database for metadata
- event-based workflow
- solr
- solr 5+ standalone app
- might be shared with other applications
- fast disk and/or enough memory to keep index in memory
-
install dependencies and download the curation-concerns-vagrant environment
https://github.com/escowles/curation-concerns-vagrant/archive/dc-fug-2016-04-28.zip
-
start the vagrant environment
$ unzip curation-concerns-vagrant-dc-fug-2016-04-28.zip $ cd curation-concerns-vagrant-dc-fug-2016-04-28 $ vagrant up
-
start the curation-concerns-demo application
$ vagrant ssh $ cd curation-concerns-demo $ rails s -b 0.0.0.0
- demo of unmodified curation concerns
- add an object, upload a file
- search, facet, view, download
- behind the scenes
- fedora view of an object: http://localhost:8984/rest/
- solr view of an object: http://localhost:8983/solr/hydra-development/select
- basic customization
- adding a property to a model
- adding to edit and show forms
- how the framework is organized
- models, views, controllers
- forms, indexers, presenters
- model defines the property
- form wraps the model
- view provides HTML UI
class Book < ActiveFedora::Base
include ::CurationConcerns::WorkBehavior
include ::CurationConcerns::BasicMetadata
validates :title, presence: { message: 'Your work must have a title.' }
+ property :copyright, predicate: ::RDF::URI('http://www.loc.gov/premis/rdf/v1#hasCopyrightStatus')
end
module CurationConcerns
class BookForm < CurationConcerns::Forms::WorkForm
self.model_class = ::Book
+ delegate :copyright, to: :model
+ self.terms += [:copyright]
end
end
+ <fieldset class="optional prompt">
+ <legend>Additional Information</legend>
+ <%= f.input :subject, as: :multi_value, input_html: { class: 'form-control' } %>
+ <%= f.input :publisher, as: :multi_value, input_html: { class: 'form-control' } %>
+ <%= f.input :source, as: :multi_value, input_html: { class: 'form-control' } %>
+ <%= f.input :language, as: :multi_value, input_html: { class: 'form-control' } %>
+ <%= f.input :copyright, as: :multi_value, input_html: { class: 'form-control' } %>
+ </fieldset>
- create or edit a record
- add a copyright value
- view the copyright value in fedora
- but it doesn't show up in solr
- indexer maps from the model to Solr
- model defines which indexer to use
$ mkdir app/indexers
+ class BookIndexer < CurationConcerns::WorkIndexer
+ def generate_solr_document
+ super.tap do |solr_doc|
+ Solrizer.set_field(solr_doc, 'copyright', object.copyright, :displayable)
+ end
+ end
+ end
class Book < ActiveFedora::Base
include ::CurationConcerns::WorkBehavior
include ::CurationConcerns::BasicMetadata
validates :title, presence: { message: 'Your work must have a title.' }
property :copyright, predicate: ::RDF::URI('http://www.loc.gov/premis/rdf/v1#hasCopyrightStatus')
+ def self.indexer
+ ::BookIndexer
+ end
end
- update the object to trigger reindexing
- view the copyright field in solr
- still not showing up on the show page
- presenter maps from Solr to the form
- controller defines which presenter to use
- view provides HTML UI
$ mkdir app/presenters
+ class BookPresenter < CurationConcerns::WorkShowPresenter
+ delegate :copyright, to: :solr_document
+ end
...
+ def copyright
+ fetch('copyright_ssm', [])
+ end
end
class CurationConcerns::BooksController < ApplicationController
include CurationConcerns::CurationConcernController
self.curation_concern_type = Book
+ def show_presenter
+ ::BookPresenter
+ end
end
+ <%= presenter.attribute_to_html(:description) %>
+ <%= presenter.attribute_to_html(:creator, catalog_search_link: true ) %>
+ <%= presenter.attribute_to_html(:contributor, label: 'Contributors', catalog_search_link: true) %>
+ <%= presenter.attribute_to_html(:subject, catalog_search_link: true) %>
+ <%= presenter.attribute_to_html(:publisher) %>
+ <%= presenter.attribute_to_html(:language) %>
+ <%= presenter.attribute_to_html(:copyright) %>
- reload the show page
- see the copyright value displayed to end users
- update the indexer to index as facetable
- update the search controller to display the facet
class BookIndexer < CurationConcerns::WorkIndexer
def generate_solr_document
super.tap do |solr_doc|
- Solrizer.set_field(solr_doc, 'copyright', object.copyright, :displayable)
+ Solrizer.set_field(solr_doc, 'copyright', object.copyright, :displayable, :facetable)
end
end
end
class CatalogController < ApplicationController
include CurationConcerns::CatalogController
configure_blacklight do |config|
...
config.add_facet_field solr_name('based_near', :facetable), limit: 5
config.add_facet_field solr_name('publisher', :facetable), limit: 5
config.add_facet_field solr_name('file_format', :facetable), limit: 5
config.add_facet_field 'generic_type_sim', show: false, single: true
+ config.add_facet_field solr_name('copyright', :facetable), limit: 5, label: 'Copyright'
...
end
- update a record with copyright
- perform a search
- see copyright facet in the sidebar
thanks to justin coyne for great tutorials: