Hyrax v3.0 ( branch: )

Add or Update schema metadata definitions

In ActiveFedora defined works, metadata was defined in property statements in the Work class. Valkyrie resources use attributes statements in a similar way. You could manually create attribute statements in your work, but there is a much better way to define metadata in Hyrax 3.0

In Hyrax Valkyrie Resources, the main way to define metadata is in a schema for each resource class. Schemas are defined in /config/metadata/_WORK_RESOURCE_CLASSNAME_.yaml. The structure of this file includes attributes as the first level key.

The second level keys define each attribute’s name. Under each attribute, define its characteristics including the following…

  • type - data type. See Hyrax Schema Loader, Valkyrie Supported Data Types, and Valkyrie::Types module. Conversion tip: I made the arbitrary decision to set all ours to String, except a few that were clearly dates.
  • multiple - single vs. multiple value. Conversion tip: Set this to the same value as multiple in the ActiveFedora property definition, which defaults to multiple=true if not specified.
  • index_keys - names of the fields in the solr document. Conversion tip: These equate to the index.as settings in ActiveFedora property definitions.
    • append ‘_tesim’ to metadata attribute name for :stored_searchable (e.g. “authors_tesim”)
    • append ‘_sim’ to metadata attribute name for :facetable (e.g. “authors_sim”)
    • see more extension examples at Appendix - Solrizer Reference.
  • forms - controls how fields will show up on the new/edit form
requiredtrue | false Is the user required to enter a value before saving the form?
Conversion tip: Set this to true if the attribute was set in self.required_fields defined in existing Hyrax::_WORK_NAME_Form class; otherwise, false.
primarytrue | false Should the field appear above the fold?
Conversion tip: Set this to true if you want it to appear above the fold (i.e. when form is loaded and user has not yet pressed more button). In our case, if field is required, I set primary to true; otherwise, false.
multipletrue | false Can the user enter multiple values through the form?
Conversion tip: This is generally the same as the main level value of multiple. So this was again set to the value of multiple in the ActiveFedora property definition.
  • Any attributes defined with the generator will have a basic entry generated in the metadata schema file.

Edit config/metadata/_WORK_RESOURCE_CLASSNAME_.yaml to define the work resource metadata.

For every property statement in Hyrax < 3.0 version of the model (app/model/_ACTIVE_FEDORA_WORK_MODEL_.rb), define an entry in the schema following the pattern…

   _metadata_attribute_name_:
    type: string
    multiple: true
    index_keys:
      - "authors_tesim"
      - "authors_sim"
    form:
      required: false
      primary: false
      multiple: true
    # predicate: ::RDF::Vocab::MARCRelators.aut

See basic_metadata.yaml for a complete example

  • Predicate - NOT SUPPORTED - I included the predicate to avoid losing this information. At this time, it is not used by Hyrax-Wings, but hoping that there will be some type of implementation for predicates in the future. To avoid YML.safe_load errors, the predicate is commented out.

Write tests for Work Resource Metadata

  • Any attributes defined with the generator will have the basic respond_to test generated in the model spec.

Edit spec/models/publication_resource_spec.rb and add tests for attributes.

For every property statement in 2.7 Publication model (app/model/publication.rb), define a respond_to test…

it { is_expected.to respond_to(:authors) }