h1. Defining a custom Hydra Model h2. General Introduction/Tutorial The "HOW_TO_GET_STARTED":http://hudson.projecthydra.org/job/hydra-head-rails3-plugin/Documentation/file.HOW_TO_GET_STARTED.html tutorial includes a detailed section on defining a JournalArticle model. Read that to get a sense of how to create a working Hydra Model. h2. Steps to Defining Your Model # Pick xml schema(s) # Create "fixture" XML # Define or reuse OM Terminologies & Datastream Classes for your XML # Write rspec tests for your Datastream classes # Define the Model # Write rspec tests for your Model # Decide what relationships your Model will have & which predicates to use # Add relationship methods to your Model Set up rightsMetadata and Depositor/Owner Permissions # make sure objects have a rightsMetadata datastream # include Hydra::ModelMethods in your model OM Topics: * namespaces * Indexing ** index_as ** suppressing fields ** advanced indexing with custom solr schemas (:displayable and :searchable) * retrieving Terms & Values h2. rightsMetadata and Depositor/Owner Permissions Two steps are necessary in order to ensure that your controllers will be able to set the permissions on your Assets. If you don't follow these steps, users will be able to create objects but won't be able to edit them. Before reading this, make sure to read the page on "Hydra Access Controls":http://hudson.projecthydra.org/job/hydra-head-rails3-plugin/Documentation/file.HYDRA_ACCESS_CONTROLS.html h3. (1) make sure objects have a rightsMetadata datastream If you are adhering to the formal Hydra commonMetadata cModel, which says that you must have a descMetadata datastream and a rightsMetadata datastream, you can put this line in your model:
# This model adheres to the formal Hydra commonMetadata cModel, meaning that it has a descMetadata datastream and a rightsMetadata datastream include Hydra::ModelMixins::CommonMetadataIf you are not adhering to the formal Hydra commonMetadata cModel and simply want to have a rightsMetadata datastream, declare the datastream directly in your Model
# Explicitly declaring rightsMetadata datastream has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadatah3. (2) include Hydra::ModelMethods in your model or define custom apply_depositor_metadata method on yoru Model {Hydra::ModelMethods} will provide {Hydra::ModelMethods#apply_depositor_metadata} method within your Controllers. You might want to override that method with model-specific behavior. The most important behavior to retain is adding +depositor_id+ to the asset's individual edit permissions if the asset has a rightsMetadata datastream.
# in your model include Hydra::ModelMethods