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
-
#archdesc_dates ⇒ Object
-
#archdesc_note_types ⇒ Object
-
#bibliographies ⇒ Object
-
#controlaccess_linked_agents(include_unpublished = false) ⇒ Object
-
#controlaccess_subjects ⇒ Object
-
#did_note_types ⇒ Object
-
#index_item_type_map ⇒ Object
-
#indexes ⇒ Object
Instance Method Details
#archdesc_dates ⇒ Object
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 148 149 150 151 152 153 154 155 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 120 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 = ( date['date_type'] == 'inclusive' ) ? 'inclusive' : ( ( date['date_type'] == 'single') ? nil : 'bulk') content = if date['expression'] date['expression'] elsif date['end'].nil? || date['end'] == date['begin'] date['begin'] else "#{date['begin']}-#{date['end']}" end atts = {} atts[:type] = type if type atts[:certainty] = date['certainty'] if date['certainty'] atts[:normal] = normal unless normal.empty? atts[:era] = date['era'] if date['era'] atts[:calendar] = date['calendar'] if date['calendar'] atts[:datechar] = date['label'] if date['label'] results << {:content => content, :atts => atts} end @archdesc_dates = results end @archdesc_dates end |
#archdesc_note_types ⇒ Object
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 |
#bibliographies ⇒ Object
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 |
#controlaccess_linked_agents(include_unpublished = false) ⇒ Object
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 79 80 81 82 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 41 def controlaccess_linked_agents(include_unpublished = false) unless @controlaccess_linked_agents results = [] linked = self.linked_agents || [] linked.each_with_index do |link, i| next if link['role'] == 'creator' || (link['_resolved']['publish'] == false && !include_unpublished) 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'] authfilenumber = agent['display_name']['authority_id'] 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' when 'agent_software'; 'name' end atts = {} atts[:role] = role if role atts[:source] = source if source atts[:rules] = rules if rules atts[:authfilenumber] = authfilenumber if authfilenumber atts[:audience] = 'internal' if link['_resolved']['publish'] == false results << {:node_name => node_name, :atts => atts, :content => content} end @controlaccess_linked_agents = results end @controlaccess_linked_agents end |
#controlaccess_subjects ⇒ Object
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 113 114 115 116 117 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 85 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'] atts['authfilenumber'] = subject['authority_id'] if subject['authority_id'] results << {:node_name => node_name, :atts => atts, :content => content} end @controlaccess_subjects = results end @controlaccess_subjects end |
#did_note_types ⇒ Object
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 |
#index_item_type_map ⇒ Object
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 |
#indexes ⇒ Object
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 |