Class: DigitalObjectComponent

Inherits:
DigitalObject show all
Includes:
ASModel, Agents, AutoGenerator, ComponentsAddChildren, Dates, Events, Extents, ExternalDocuments, ExternalIDs, FileVersions, LangMaterials, Notes, Publishable, RepresentativeFileVersion, RightsStatements, Subjects, TouchRecords, TreeNodes
Defined in:
backend/app/model/digital_object_component.rb,
public/app/models/digital_object_component.rb

Constant Summary

Constants included from TreeNodes

TreeNodes::DB_RETRIES, TreeNodes::POSITION_STEP

Constants included from JSONModel

JSONModel::REFERENCE_KEY_REGEX

Constants included from Trees

Trees::NODE_PAGE_SIZE

Constants inherited from Record

Record::ABSTRACT

Instance Attribute Summary

Attributes inherited from DigitalObject

#cite, #cite_item, #cite_item_description, #linked_instances

Attributes inherited from Record

#agents, #classifications, #container_display, #container_summary_for_badge, #container_titles_and_uris, #criteria, #dates, #display_string, #extents, #external_documents, #full, #identifier, #json, #lang_materials, #level, #linked_digital_objects, #notes, #other_level, #primary_type, #raw, #repository_information, #resolved_repository, #resolved_resource, #resolved_top_container, #subjects, #uri

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RepresentativeFileVersion

included

Methods included from TouchRecords

#delete, included, #set_parent_and_position, #set_root, #update_from_json

Methods included from Publishable

db_value_for, included

Methods included from Events

included

Methods included from ComponentsAddChildren

#add_children, included

Methods included from FileVersions

included

Methods included from ExternalIDs

included

Methods included from RightsStatements

included

Methods included from Notes

included, #persistent_id_context, #update_from_json

Methods included from AutoGenerator

included, #update_from_json

Methods included from TreeNodes

#ancestors, #attempt_set_parent_and_position, #attempt_set_position_in_list, #breadcrumb, #breadcrumb_identifier, #breadcrumb_title_for_node, #breadcrumb_uri_for_node, #children, #ensure_gap, #has_children?, included, #logical_position, #previous_node, #set_parent_and_position, #set_position_in_list, #set_root, #transfer_to_repository, #trigger_index_of_child_nodes, #update_from_json

Methods included from Agents

included

Methods included from ExternalDocuments

included

Methods included from Dates

included

Methods included from LangMaterials

included

Methods included from Extents

included

Methods included from Subjects

included

Methods included from ASModel

all_models, included, update_publish_flag, update_suppressed_flag

Methods included from JSONModel

JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, check_valid_refs, client_mode?, custom_validations, destroy_model, enum_default_value, enum_values, handle_error, init, load_schema, #models, models, parse_jsonmodel_ref, parse_reference, repository, repository_for, schema_src, set_publish_flags!, set_repository, strict_mode, strict_mode?, validate_schema, with_repository

Methods inherited from DigitalObject

#breadcrumb, #delete, #finding_aid, #initialize

Methods included from Assessments::LinkedRecord

#delete, included

Methods included from UserDefineds

included

Methods included from MetadataRights

included

Methods included from CollectionManagements

included

Methods included from DigitalObjectTrees

#build_node_query, #load_node_properties, #load_root_properties, #set_file_version

Methods included from Trees

#adopt_children, #apply_exclusions_to_descendants, #assimilate, #build_node_query, #children, #children?, included, #load_node_properties, #load_root_properties, #ordered_records, #partial_tree, #transfer_to_repository, #tree, #trigger_index_of_entire_tree, #update_from_json

Methods included from Classifications

included

Methods inherited from Record

#[], #dig, #initialize, #note, #parse_full_title, #request_item

Methods included from PrefixHelper

app_prefix, #app_prefix, app_prefix_js, #app_prefix_js

Methods included from RecordHelper

#badge_for_type, #icon_for_type, #record_class_for_type, #record_for_type, #record_from_resolved_json

Methods included from JsonHelper

#merge_notes, #process_json_notes

Methods included from ManipulateNode

#inheritance, #process_mixed_content, #strip_mixed_content

Constructor Details

This class inherits a constructor from DigitalObject

Class Method Details

.produce_display_string(json) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'backend/app/model/digital_object_component.rb', line 54

def self.produce_display_string(json)
  display_string = json['title'] || json['label'] || ""

  date_label = json.has_key?('dates') && json['dates'].length > 0 ?
                json['dates'].map do |date|
                  if date['expression']
                    date['date_type'] == 'bulk' ? "#{I18n.t("date_type_bulk.bulk")}: #{date['expression']}" : date['expression']
                  elsif date['begin'] and date['end']
                    date['date_type'] == 'bulk' ? "#{I18n.t("date_type_bulk.bulk")}: #{date['begin']} - #{date['end']}" : "#{date['begin']} - #{date['end']}"
                  else
                    date['date_type'] == 'bulk' ? "#{I18n.t("date_type_bulk.bulk")}: #{date['begin']}" : date['begin']
                  end
                end.join(', ') : false

  display_string += ", " if json['title'] && date_label
  display_string += date_label if date_label

  display_string
end

.sequel_to_jsonmodel(objs, opts = {}) ⇒ Object



74
75
76
77
78
# File 'backend/app/model/digital_object_component.rb', line 74

def self.sequel_to_jsonmodel(objs, opts = {})
  jsons = super
  AncestorListing.add_ancestors(objs, jsons)
  jsons
end

.touch_records(obj) ⇒ Object



87
88
89
# File 'backend/app/model/digital_object_component.rb', line 87

def self.touch_records(obj)
  [{ type: DigitalObject, ids: [obj.root_record_id] }]
end

Instance Method Details

#parse_identifierObject



8
9
10
# File 'public/app/models/digital_object_component.rb', line 8

def parse_identifier
  json['component_id']
end

#root_node_uriObject



4
5
6
# File 'public/app/models/digital_object_component.rb', line 4

def root_node_uri
  json.fetch('digital_object').fetch('ref')
end

#validateObject



80
81
82
83
84
85
# File 'backend/app/model/digital_object_component.rb', line 80

def validate
  validates_unique([:root_record_id, :component_id],
                   :message => "A Digital Object Component ID must be unique to its Digital Object")
  map_validation_to_json_property([:root_record_id, :component_id], :component_id)
  super
end