Class: DigitalObjectComponent
- Inherits:
-
DigitalObject
show all
- Defined in:
- backend/app/model/digital_object_component.rb,
public/app/models/digital_object_component.rb
Constant Summary
Constants inherited
from Record
Record::ABSTRACT
Instance Attribute Summary
#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, #highlights, #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
#breadcrumb, #delete, #finding_aid, #initialize, instance_owners_root_records
Methods inherited from Record
#[], #apply_highlighting, #dig, #initialize, #note, #parse_full_title, #request_item
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
90
91
92
|
# File 'backend/app/model/digital_object_component.rb', line 87
def self.touch_records(obj)
[
{ type: DigitalObject, ids: [obj.root_record_id] },
{ type: Resource, ids: DigitalObject.instance_owners_root_records(obj.root_record_id) }
]
end
|
Instance Method Details
#parse_identifier ⇒ Object
8
9
10
|
# File 'public/app/models/digital_object_component.rb', line 8
def parse_identifier
json['component_id']
end
|
#root_node_uri ⇒ Object
4
5
6
|
# File 'public/app/models/digital_object_component.rb', line 4
def root_node_uri
json.fetch('digital_object').fetch('ref')
end
|
#validate ⇒ Object
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
|