Class: DigitalObject
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- DigitalObject
- Includes:
- ASModel, Agents, CollectionManagements, ComponentsAddChildren, Dates, DigitalObjectTrees, Events, Extents, ExternalDocuments, ExternalIDs, FileVersions, Notes, Publishable, RightsStatements, Subjects, Trees, UserDefineds
- Defined in:
- backend/app/model/digital_object.rb
Constant Summary
Constant Summary
Constants included from Trees
Class Method Summary (collapse)
Methods included from Publishable
Methods included from Events
Methods included from ComponentsAddChildren
Methods included from UserDefineds
Methods included from CollectionManagements
Methods included from FileVersions
Methods included from ExternalIDs
Methods included from RightsStatements
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, #assimilate, #build_node_query, #children, included, #load_node_properties, #load_root_properties, #partial_tree, #transfer_to_repository, #tree, #trigger_index_of_entire_tree, #update_from_json
Methods included from Agents
Methods included from ExternalDocuments
Methods included from Dates
Methods included from Extents
Methods included from Subjects
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, 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_repository, strict_mode, strict_mode?, with_repository
Class Method Details
+ (Object) sequel_to_jsonmodel(objs, opts = {})
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'backend/app/model/digital_object.rb', line 36 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 |