Class: Record

Inherits:
Object
  • Object
show all
Defined in:
public/app/models/record.rb

Constant Summary collapse

ABSTRACT =
%w(abstract scopecontent)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solr_result, full = false) ⇒ Record

Returns a new instance of Record.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'public/app/models/record.rb', line 19

def initialize(solr_result, full = false)
  @raw = solr_result
  if solr_result['json'].is_a? Hash
    @json = solr_result['json']
  else
    @json = ASUtils.json_parse(solr_result['json']) || {}
  end

  @full = full

  @primary_type = raw['primary_type']
  @uri = raw['uri']
  @identifier = parse_identifier

  @resolved_resource = parse_resource

  @level = raw['level']
  @other_level = json['other_level']
  @display_string = parse_full_title
  @container_display = parse_container_display
  @container_summary_for_badge = parse_container_summary_for_badge
  @container_titles_and_uris = parse_container_display(:include_uri => true)
  @linked_digital_objects = parse_digital_object_instances
  @notes = parse_notes
  @dates = parse_dates
  @lang_materials = parse_lang_materials
  @external_documents = parse_external_documents
  @resolved_repository = parse_repository
  @resolved_top_container = parse_top_container
  @repository_information = parse_repository_info
  @subjects = parse_subjects
  @classifications = parse_classifications
  @agents = parse_agents(subjects)
  @extents = parse_extents
end

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents



8
9
10
# File 'public/app/models/record.rb', line 8

def agents
  @agents
end

#classificationsObject (readonly)

Returns the value of attribute classifications



8
9
10
# File 'public/app/models/record.rb', line 8

def classifications
  @classifications
end

#container_displayObject (readonly)

Returns the value of attribute container_display



8
9
10
# File 'public/app/models/record.rb', line 8

def container_display
  @container_display
end

#container_summary_for_badgeObject (readonly)

Returns the value of attribute container_summary_for_badge



8
9
10
# File 'public/app/models/record.rb', line 8

def container_summary_for_badge
  @container_summary_for_badge
end

#container_titles_and_urisObject (readonly)

Returns the value of attribute container_titles_and_uris



8
9
10
# File 'public/app/models/record.rb', line 8

def container_titles_and_uris
  @container_titles_and_uris
end

#criteriaObject

Returns the value of attribute criteria



15
16
17
# File 'public/app/models/record.rb', line 15

def criteria
  @criteria
end

#datesObject (readonly)

Returns the value of attribute dates



8
9
10
# File 'public/app/models/record.rb', line 8

def dates
  @dates
end

#display_stringObject (readonly)

Returns the value of attribute display_string



8
9
10
# File 'public/app/models/record.rb', line 8

def display_string
  @display_string
end

#extentsObject (readonly)

Returns the value of attribute extents



8
9
10
# File 'public/app/models/record.rb', line 8

def extents
  @extents
end

#external_documentsObject (readonly)

Returns the value of attribute external_documents



8
9
10
# File 'public/app/models/record.rb', line 8

def external_documents
  @external_documents
end

#fullObject (readonly)

Returns the value of attribute full



8
9
10
# File 'public/app/models/record.rb', line 8

def full
  @full
end

#highlightsObject

Returns the value of attribute highlights



15
16
17
# File 'public/app/models/record.rb', line 15

def highlights
  @highlights
end

#identifierObject (readonly)

Returns the value of attribute identifier



8
9
10
# File 'public/app/models/record.rb', line 8

def identifier
  @identifier
end

#jsonObject (readonly)

Returns the value of attribute json



8
9
10
# File 'public/app/models/record.rb', line 8

def json
  @json
end

#lang_materialsObject (readonly)

Returns the value of attribute lang_materials



8
9
10
# File 'public/app/models/record.rb', line 8

def lang_materials
  @lang_materials
end

#levelObject (readonly)

Returns the value of attribute level



8
9
10
# File 'public/app/models/record.rb', line 8

def level
  @level
end

#linked_digital_objectsObject (readonly)

Returns the value of attribute linked_digital_objects



8
9
10
# File 'public/app/models/record.rb', line 8

def linked_digital_objects
  @linked_digital_objects
end

#notesObject (readonly)

Returns the value of attribute notes



8
9
10
# File 'public/app/models/record.rb', line 8

def notes
  @notes
end

#other_levelObject (readonly)

Returns the value of attribute other_level



8
9
10
# File 'public/app/models/record.rb', line 8

def other_level
  @other_level
end

#primary_typeObject (readonly)

Returns the value of attribute primary_type



8
9
10
# File 'public/app/models/record.rb', line 8

def primary_type
  @primary_type
end

#rawObject (readonly)

Returns the value of attribute raw



8
9
10
# File 'public/app/models/record.rb', line 8

def raw
  @raw
end

#repository_informationObject (readonly)

Returns the value of attribute repository_information



8
9
10
# File 'public/app/models/record.rb', line 8

def repository_information
  @repository_information
end

#resolved_repositoryObject (readonly)

Returns the value of attribute resolved_repository



8
9
10
# File 'public/app/models/record.rb', line 8

def resolved_repository
  @resolved_repository
end

#resolved_resourceObject (readonly)

Returns the value of attribute resolved_resource



8
9
10
# File 'public/app/models/record.rb', line 8

def resolved_resource
  @resolved_resource
end

#resolved_top_containerObject (readonly)

Returns the value of attribute resolved_top_container



8
9
10
# File 'public/app/models/record.rb', line 8

def resolved_top_container
  @resolved_top_container
end

#subjectsObject (readonly)

Returns the value of attribute subjects



8
9
10
# File 'public/app/models/record.rb', line 8

def subjects
  @subjects
end

#uriObject (readonly)

Returns the value of attribute uri



8
9
10
# File 'public/app/models/record.rb', line 8

def uri
  @uri
end

Instance Method Details

#[](k) ⇒ Object



63
64
65
66
67
68
69
# File 'public/app/models/record.rb', line 63

def [](k)
  if k == 'json'
    json
  else
    raw[k]
  end
end

#apply_highlighting(highlights) ⇒ Object



55
56
57
58
59
60
61
# File 'public/app/models/record.rb', line 55

def apply_highlighting(highlights)
  if highlights.key?('title') && highlights['title'].length == 1
    @display_string = highlights['title'][0]
  end

  @highlights = highlights
end

#dig(*args) ⇒ Object



71
72
73
# File 'public/app/models/record.rb', line 71

def dig(*args)
  json.dig(args)
end

#note(type) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'public/app/models/record.rb', line 75

def note(type)
  if notes && notes[type]
    note = notes[type][0].clone
    for i in 1...notes[type].length
      note = merge_notes(note, notes[type][i])
    end
    note
  else
    {}
  end
end

#parse_full_title(infinite_item = false) ⇒ Object



93
94
95
96
97
98
# File 'public/app/models/record.rb', line 93

def parse_full_title(infinite_item = false)
  unless infinite_item || json['title_inherited'].blank? || (json['display_string'] || '') == json['title']
    return "#{json['title']}, #{json['display_string']}"
  end
  return process_mixed_content_title(json['display_string'] || json['title'])
end

#request_itemObject



87
88
89
90
91
# File 'public/app/models/record.rb', line 87

def request_item
  return unless RequestItem.allow_for_type(resolved_repository.dig('repo_code'), primary_type.intern)

  build_request_item
end