Class: Classification
- Inherits:
-
Record
show all
- Defined in:
- backend/app/model/classification.rb,
public/app/models/classification.rb
Constant Summary
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, #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
Methods inherited from Record
#[], #apply_highlighting, #dig, #note, #request_item
Constructor Details
Returns a new instance of Classification.
5
6
7
8
9
10
|
# File 'public/app/models/classification.rb', line 5
def initialize(*args)
super
@linked_records = parse_linked_records
@creator = parse_creator
end
|
Instance Attribute Details
#creator ⇒ Object
Returns the value of attribute creator
3
4
5
|
# File 'public/app/models/classification.rb', line 3
def creator
@creator
end
|
#linked_records ⇒ Object
Returns the value of attribute linked_records
3
4
5
|
# File 'public/app/models/classification.rb', line 3
def linked_records
@linked_records
end
|
Class Method Details
.create_from_json(json, opts = {}) ⇒ Object
46
47
48
49
50
51
|
# File 'backend/app/model/classification.rb', line 46
def self.create_from_json(json, opts = {})
self.set_path_from_root(json)
obj = super
obj.reindex_children
obj
end
|
.sequel_to_jsonmodel(objs, opts = {}) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'backend/app/model/classification.rb', line 62
def self.sequel_to_jsonmodel(objs, opts = {})
jsons = super
jsons.zip(objs).each do |json, obj|
self.set_path_from_root(json)
json['has_classification_terms'] = obj.children?
end
jsons
end
|
.set_path_from_root(json) ⇒ Object
41
42
43
|
# File 'backend/app/model/classification.rb', line 41
def self.set_path_from_root(json)
json['path_from_root'] = [{'title' => json.title, 'identifier' => json.identifier}]
end
|
Instance Method Details
#breadcrumb ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'public/app/models/classification.rb', line 24
def breadcrumb
[
{
:uri => '',
:crumb => display_string,
:type => 'classification'
}
]
end
|
#classification_terms? ⇒ Boolean
34
35
36
|
# File 'public/app/models/classification.rb', line 34
def classification_terms?
raw['has_classification_terms'] == true
end
|
#description ⇒ Object
12
13
14
|
# File 'public/app/models/classification.rb', line 12
def description
json['description'] || ''
end
|
#display_string_for_breadcrumb ⇒ Object
16
17
18
|
# File 'public/app/models/classification.rb', line 16
def display_string_for_breadcrumb
"#{json['identifier']}#{I18n.t('classification.identifier_separator')} #{json['title']}"
end
|
#load_node_properties(node, properties, ids_of_interest = :all) ⇒ Object
74
75
76
77
|
# File 'backend/app/model/classification.rb', line 74
def load_node_properties(node, properties, ids_of_interest = :all)
super
properties[node.id][:identifier] = node.identifier
end
|
#load_root_properties(properties, ids_of_interest = :all) ⇒ Object
80
81
82
83
|
# File 'backend/app/model/classification.rb', line 80
def load_root_properties(properties, ids_of_interest = :all)
super
properties[:identifier] = self.identifier
end
|
#root_node_uri ⇒ Object
20
21
22
|
# File 'public/app/models/classification.rb', line 20
def root_node_uri
uri
end
|
#update_from_json(json, opts = {}, apply_nested_records = true) ⇒ Object
54
55
56
57
58
59
|
# File 'backend/app/model/classification.rb', line 54
def update_from_json(json, opts = {}, apply_nested_records = true)
self.class.set_path_from_root(json)
obj = super
obj.reindex_children
obj
end
|