Module: ASpaceExport::ArchivalObjectDescriptionHelpers

Included in:
EADModel
Defined in:
backend/app/exporters/lib/export_helpers.rb

Overview

Convenience methods that will work for resource or archival_object models during serialization

Instance Method Summary (collapse)

Instance Method Details

- (Object) archdesc_dates

[View source]

115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'backend/app/exporters/lib/export_helpers.rb', line 115

def archdesc_dates
  unless @archdesc_dates
    results = []
    dates = self.dates || []
    dates.each do |date|
      normal = ""
      unless date['begin'].nil?
        normal = "#{date['begin']}/"
        normal_suffix = (date['date_type'] == 'single' || date['end'].nil? || date['end'] == date['begin']) ? date['begin'] : date['end']
        normal += normal_suffix ? normal_suffix : ""
      end
      type = %w(single inclusive).include?(date['date_type']) ? 'inclusive' : 'bulk' 
      content = if date['expression']
                date['expression']
              elsif date['date_type'] == 'bulk'
                'bulk'
              elsif date['end'].nil? || date['end'] == date['begin']
                date['begin']
              else
                "#{date['begin']}-#{date['end']}"
              end

      atts = {:type => type}
      atts[:normal] = normal unless normal.empty?

      results << {:content => content, :atts => atts}
    end

    @archdesc_dates = results
  end

  @archdesc_dates
end

- (Object) archdesc_note_types

[View source]

6
7
8
# File 'backend/app/exporters/lib/export_helpers.rb', line 6

def archdesc_note_types
  %w(accruals appraisal arrangement bioghist accessrestrict legalstatus userestrict custodhist altformavail originalsloc fileplan odd acqinfo otherfindaid phystech prefercite processinfo relatedmaterial scopecontent separatedmaterial)
end

- (Object) bibliographies

[View source]

16
17
18
# File 'backend/app/exporters/lib/export_helpers.rb', line 16

def bibliographies
  self.notes.select{|n| n['jsonmodel_type'] == 'note_bibliography'}
end

- (Object) controlaccess_linked_agents

[View source]

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'backend/app/exporters/lib/export_helpers.rb', line 41

def controlaccess_linked_agents
  unless @controlaccess_linked_agents
    results = []
    linked = self.linked_agents || []
    linked.each_with_index do |link, i|

      role = link['relator'] ? link['relator'] : (link['role'] == 'source' ? 'fmo' : nil)

      agent = link['_resolved'].dup
      sort_name = agent['display_name']['sort_name']
      rules = agent['display_name']['rules']
      source = agent['display_name']['source']
      content = sort_name.dup

      if link['terms'].length > 0
        content << " -- "
        content << link['terms'].map{|t| t['term']}.join(' -- ')
      end

      node_name = case agent['agent_type']
                  when 'agent_person'; 'persname'
                  when 'agent_family'; 'famname'
                  when 'agent_corporate_entity'; 'corpname'
                  end

      atts = {}
      atts[:role] = role if role
      atts[:source] = source if source
      atts[:rules] = rules if rules

      results << {:node_name => node_name, :atts => atts, :content => content}
    end

    @controlaccess_linked_agents = results
  end

  @controlaccess_linked_agents
end

- (Object) controlaccess_subjects

[View source]

81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'backend/app/exporters/lib/export_helpers.rb', line 81

def controlaccess_subjects
  unless @controlaccess_subjects
    results = []
    linked = self.subjects || []
    linked.each do |link|
      subject = link['_resolved']

      node_name = case subject['terms'][0]['term_type']
                  when 'function'; 'function'
                  when 'genre_form', 'style_period';  'genreform'
                  when 'geographic', 'cultural_context'; 'geogname'
                  when 'occupation';  'occupation'
                  when 'topical'; 'subject'
                  when 'uniform_title'; 'title'
                  else; nil
                  end

      next unless node_name

      content = subject['terms'].map{|t| t['term']}.join(' -- ')

      atts = {}
      atts['source'] = subject['source'] if subject['source']

      results << {:node_name => node_name, :atts => atts, :content => content}
    end

    @controlaccess_subjects = results
  end

  @controlaccess_subjects
end

- (Object) did_note_types

[View source]

11
12
13
# File 'backend/app/exporters/lib/export_helpers.rb', line 11

def did_note_types
  %w(abstract dimensions physdesc langmaterial physloc materialspec physfacet)
end

- (Object) index_item_type_map

[View source]

26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'backend/app/exporters/lib/export_helpers.rb', line 26

def index_item_type_map
  {
    'corporate_entity'=> 'corpname',
    'genre_form'=> 'genreform',
    'name'=> 'name',
    'occupation'=> 'occupation',
    'person'=> 'persname',
    'subject'=> 'subject',
    'family'=> 'famname',
    'function'=> 'function',
    'geographic_name'=> 'geogname',
    'title'=> 'title'
  }
end

- (Object) indexes

[View source]

21
22
23
# File 'backend/app/exporters/lib/export_helpers.rb', line 21

def indexes
  self.notes.select{|n| n['jsonmodel_type'] == 'note_index'}
end