-
Notifications
You must be signed in to change notification settings - Fork 4
Add a Model
- create a template for the model
- write tests
-
create the model
- add new properties (and tests)
- create the metadata concerns
- create the indexer
- Autoload any new models / concerns in dog_biscuits.rb
- pass tests
Before writing any code, it's sensible to establish the requirements for the new model.
I've created some templates in Google Docs to help with this:
- Common Data Model - draft specification for the common metadata available to all works
- Journal Article - draft specification for Journal Articles
- Thesis/Dissertation - draft specification for Theses
These templates attend to address these questions:
- What objects are being described?
- What properties are needed?
- What predicates represent these properties?
- Is the property multi-valued or single?
- How will it be indexed in solr?
- Is it required?
- What is the object of the property? (free-text, a value from a controlled list, another object in the repository)
- Write tests
- Create a mock object in /spec/factories/works.rb
- Test properties in 'support' - follow the same pattern used for other properties
- Add a spec test in /spec/lib/models/works/MODEL_spec.rb
Create a model.rb where model is the name of the model (eg. thesis.rb)
- for a work, add it to the lib/dog_biscuits/models/works folder
- for an authority, add it to the lib/dog_biscuits/models/authorities folder
- for an agent, add it to the lib/dog_biscuits/models/authorities/agents folder
The work model should contain:
- includes statement for
::Hydra::Works::WorkBehavior
- an rdf type value
- a method that returns true for the name of the model
In addition, the model may contain
-
extra methods and callbacks
-
create a concern to list all of the the metadata, eg.
- lib/dog_biscuits/models/concerns/model_property_sets/MODEL_metadata.rb
-
If the properties are already defined, include them in this file, otherwise
- add any new properties, observing the conventions
- add as individual concerns mixins
- OR, add to the model itself if they are super-specific to the current model (or, if there are a lot of super-specific properties create lib/dog_biscuits/models/concerns/property_sets/MODEL_metadata.rb)
- name has_and_belongs_to_many relations as PROPERTY_resource
- add new properties to models/concerns/extended_solr_document.rb
- add new properties to property_mappings/property_mappings.rb
- add any new properties, observing the conventions
-
Add an indexer class called MODEL_indexer in indexers and specify any indexing rules
-
Add to the available models list in lib/dog_biscuits/configuration.rb and add MODEL_properties and MODEL_properties_required; also to the configuration_spec
-
Finally, autoload all new code in the correct place in lib/dog_biscuits.rb - if you don't do this, everything is broken
- Make sure tests pass!