Module: RepresentativeFileVersion

Defined in:
backend/app/model/mixins/representative_file_version.rb

Overview

This module calculates and applies if possible a read-only #representative_file_version property to the following Record Types: DigitalObject, DigitalObjectComponent, Accession, Resource and ArchivalObject. It is intended to encapsulate all the logic for how representations are selected and displayed per the specification referenced here:

https://archivesspace.atlassian.net/browse/ANW-1209

The key fields for determining whether a file_version can appear as a representative_file_version of a parent DigitalObject or DigitalObjectComponent are: Boolean file_version.publish Boolean file_version.is_representative String file_version.use_statement

The other three record types determine their representative by looking for an Instance sub-record that a) links to a DigitalObject; and b) has is_representative set to true.

This implementation does not prevent a user from selecting a DigtalObject as an .is_representative Instance, even if the DigitalObject does not have any published FileVersion subrecords. Perhaps additional validation rules to prevent that scenario will be desired.

Finally, a DigitalObject can fall back to a descendent DigitalObjectComponent’s representative file version if necessary, and a Resource can fall back to a descendent ArchivalObject’s representative file version.

We assume the following constraints, which are implemented on DigitalObject and DigitalObjectComponent models:

1) digital_object(_component) cannot have more than one file_version where .is_representative is true” 2) file_version.is_representative cannot be true unless .publish is true

This could be optimized such that the json objects are only augmented with this field when the request is coming from the indexer.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



34
35
36
# File 'backend/app/model/mixins/representative_file_version.rb', line 34

def self.included(base)
  base.extend(ClassMethods)
end