Class: Classification

Inherits:
Record
  • Object
show all
Includes:
ASModel, AutoGenerator, ClassificationIndexing, Publishable, Trees
Defined in:
backend/app/model/classification.rb,
public/app/models/classification.rb

Direct Known Subclasses

ClassificationTerm

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 Publishable

db_value_for, included

Methods included from ClassificationIndexing

#reindex_children

Methods included from Trees

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

Methods included from AutoGenerator

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 Record

#[], #dig, #note, #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) ⇒ Classification

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

#creatorObject (readonly)

Returns the value of attribute creator



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

def creator
  @creator
end

#linked_recordsObject (readonly)

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



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

Returns:

  • (Boolean)


34
35
36
# File 'public/app/models/classification.rb', line 34

def classification_terms?
  raw['has_classification_terms'] == true
end

#descriptionObject



12
13
14
# File 'public/app/models/classification.rb', line 12

def description
  json['description'] || ''
end

#display_string_for_breadcrumbObject



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_uriObject



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