Class: Accession

Constant Summary

Constants included from Identifiers

Identifiers::MAX_LENGTH

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

Instance Method Summary collapse

Methods included from RepresentativeFileVersion

included

Methods included from Assessments::LinkedRecord

#delete, included

Methods included from ReindexTopContainers

#accession_instance_root_record_update, #ao_instance_root_record_update, #delete, #reindex_top_containers, #reindex_top_containers_by_any_means_necessary, #resource_instance_update, #set_parent_and_position, #set_root, #update_from_json

Methods included from Publishable

db_value_for, included

Methods included from Events

included

Methods included from Transferable

#transfer_to_repository

Methods included from AutoGenerator

included, #update_from_json

Methods included from Classifications

included

Methods included from UserDefineds

included

Methods included from Instances

#eagerly_load!, included

Methods included from MetadataRights

included

Methods included from CollectionManagements

included

Methods included from ExternalIDs

included

Methods included from DirectionalRelationships

included, #update_from_json

Methods included from Agents

included

Methods included from Deaccessions

included

Methods included from RightsStatements

included

Methods included from ExternalDocuments

included

Methods included from Dates

included

Methods included from Subjects

included

Methods included from LangMaterials

included

Methods included from Extents

included

Methods included from Identifiers

#after_initialize, #before_validation, format, #format_multipart_identifier, #id_0=, #id_1=, #id_2=, #id_3=, included, parse, #validate

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) ⇒ Accession

Returns a new instance of Accession.



7
8
9
10
11
12
13
14
# File 'public/app/models/accession.rb', line 7

def initialize(*args)
  super

  @related_resources = parse_related_resources
  @related_accessions = parse_related_accessions
  @use_restrictions_note = json['use_restrictions_note']
  @access_restrictions_note = json['access_restrictions_note']
end

Instance Attribute Details

#access_restrictions_noteObject (readonly)

Returns the value of attribute access_restrictions_note



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

def access_restrictions_note
  @access_restrictions_note
end

#languageObject (readonly)

Returns the value of attribute language



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

def language
  @language
end

#provenanceObject (readonly)

Returns the value of attribute provenance



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

def provenance
  @provenance
end

Returns the value of attribute related_accessions



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

def related_accessions
  @related_accessions
end

Returns the value of attribute related_resources



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

def related_resources
  @related_resources
end

Returns the value of attribute resource_link



2
3
4
# File 'frontend/app/models/accession.rb', line 2

def resource_link
  @resource_link
end

#scriptObject (readonly)

Returns the value of attribute script



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

def script
  @script
end

#use_restrictions_noteObject (readonly)

Returns the value of attribute use_restrictions_note



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

def use_restrictions_note
  @use_restrictions_note
end

Instance Method Details

#access_restrictions_apply?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'public/app/models/accession.rb', line 63

def access_restrictions_apply?
  json['access_restrictions']
end

#acquisition_typeObject



16
17
18
19
20
# File 'public/app/models/accession.rb', line 16

def acquisition_type
  if json['acquisition_type']
    I18n.t("enumerations.accession_acquisition_type.#{json['acquisition_type']}", :default => json['acquisition_type'])
  end
end

#content_descriptionObject



27
28
29
# File 'public/app/models/accession.rb', line 27

def content_description
  json['content_description']
end

#deaccessionsObject



22
23
24
25
# File 'public/app/models/accession.rb', line 22

def deaccessions
  return '' unless AppConfig[:pui_display_deaccessions]
  ASUtils.wrap(json['deaccessions'])
end

#inventoryObject



31
32
33
# File 'public/app/models/accession.rb', line 31

def inventory
  json['inventory']
end

#populate_from_accession(accession) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'frontend/app/models/accession.rb', line 24

def populate_from_accession(accession)
  values = accession.to_hash(:raw)

  # Recursively remove bits that don't make sense to copy (like "lock_version" properties)
  values = JSONSchemaUtils.map_hash_with_schema(values, JSONModel(:accession).schema,
                                                [proc { |hash, schema|
                                                   hash = hash.clone
                                                   hash.delete_if {|k, v| k.to_s =~ /^(id_[0-9]|lock_version)$/}
                                                   hash
                                                 }])

  prepare_for_clone(values)

  self.update(values)
end

#ref_idObject



11
12
13
14
15
16
17
18
19
20
21
# File 'frontend/app/models/accession.rb', line 11

def ref_id
  ref_id = ""

  (0..3).each do |i|
    next if self.send("id_#{i.to_s}").blank?
    ref_id << " - " unless i === 0
    ref_id << self.send("id_#{i.to_s}")
  end

  ref_id
end

#restrictions_apply?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'public/app/models/accession.rb', line 51

def restrictions_apply?
  json['restrictions_apply']
end

#use_restrictions_apply?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'public/app/models/accession.rb', line 67

def use_restrictions_apply?
  json['use_restrictions']
end