Class: DigitalObject

Direct Known Subclasses

DigitalObjectComponent

Constant Summary

Constants included from Trees

Trees::NODE_PAGE_SIZE

Constants included from JSONModel

JSONModel::REFERENCE_KEY_REGEX

Constants inherited from Record

Record::ABSTRACT

Instance Attribute Summary collapse

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 Assessments::LinkedRecord

included

Methods included from Publishable

db_value_for, included

Methods included from Events

included

Methods included from ComponentsAddChildren

#add_children, included

Methods included from UserDefineds

included

Methods included from MetadataRights

included

Methods included from CollectionManagements

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 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 Agents

included

Methods included from ExternalDocuments

included

Methods included from Classifications

included

Methods included from Dates

included

Methods included from LangMaterials

included

Methods included from Extents

included

Methods included from Subjects

included

Methods included from AutoGenerator

included, #update_from_json

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 Record

#[], #dig, #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

#initialize(*args) ⇒ DigitalObject

Returns a new instance of DigitalObject.



5
6
7
8
9
10
11
12
13
# File 'public/app/models/digital_object.rb', line 5

def initialize(*args)
  super

  @linked_instances = parse_linked_instances
  # ANW-921: Refactored citation modal, keep cite in case used by others
  @cite = parse_cite_string("")
  @cite_item = parse_cite_string("item")
  @cite_item_description = parse_cite_string("description")
end

Instance Attribute Details

#citeObject (readonly)

Returns the value of attribute cite



3
4
5
# File 'public/app/models/digital_object.rb', line 3

def cite
  @cite
end

#cite_itemObject (readonly)

Returns the value of attribute cite_item



3
4
5
# File 'public/app/models/digital_object.rb', line 3

def cite_item
  @cite_item
end

#cite_item_descriptionObject (readonly)

Returns the value of attribute cite_item_description



3
4
5
# File 'public/app/models/digital_object.rb', line 3

def cite_item_description
  @cite_item_description
end

#linked_instancesObject (readonly)

Returns the value of attribute linked_instances



3
4
5
# File 'public/app/models/digital_object.rb', line 3

def linked_instances
  @linked_instances
end

Class Method Details

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



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'backend/app/model/digital_object.rb', line 56

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

  relationships = find_relationship(:instance_do_link).find_by_participant_ids(self, objs.map(&:id))
  instances = Instance.filter(:id => relationships.map {|relationship| relationship[:instance_id]}).all

  relationship_to_instance = Hash[relationships.map {|relationship|
                                    [relationship, instances.select {|instance| relationship[:instance_id] == instance.id}]
                                  }]

  jsons.zip(objs).each do |json, obj|
    json["linked_instances"] = []

    relationships.each do |relationship|
      next unless relationship.relates_to?(obj)

      instances = relationship_to_instance[relationship]

      instances.each do |link|
        uri = self.uri_for(:resource, link[:resource_id]) if link[:resource_id]
        uri = self.uri_for(:archival_object, link[:archival_object_id]) if link[:archival_object_id]
        uri = self.uri_for(:accession, link[:accession_id]) if link[:accession_id]

        if uri.nil?
          raise "Digital Object Instance not linked to either a resource, archival object or accession"
        end

        json["linked_instances"].push({"ref" => uri})
      end
    end
  end

  jsons
end

Instance Method Details



25
26
27
28
29
30
31
32
33
# File 'public/app/models/digital_object.rb', line 25

def breadcrumb
  [
    {
      :uri => '',
      :type => 'digital_object',
      :crumb => display_string
    }
  ]
end

#deleteObject



91
92
93
94
# File 'backend/app/model/digital_object.rb', line 91

def delete
  related_records(:instance_do_link).map {|sub| sub.delete }
  super
end

#finding_aidObject



15
16
17
18
19
# File 'public/app/models/digital_object.rb', line 15

def finding_aid
  # as this shares the same template as resources,
  # be clear that this object doesn't have a finding aid
  nil
end

#root_node_uriObject



21
22
23
# File 'public/app/models/digital_object.rb', line 21

def root_node_uri
  uri
end