Class: Accession

Inherits:
Record show all
Defined in:
backend/app/model/accession.rb,
frontend/app/models/accession.rb,
public/app/models/accession.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

Instance Method Summary collapse

Methods inherited from Record

#[], #apply_highlighting, #dig, #note, #parse_full_title, #request_item

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