Module: ASpaceExport::ArchivalObjectDescriptionHelpers
- 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
-
#digital_objects ⇒ Object
-
#index_item_type_map ⇒ Object
-
#indexes ⇒ Object
-
#instances_with_digital_objects ⇒ Object
-
#instances_with_sub_containers ⇒ Object
Instance Method Details
#archdesc_dates ⇒ Object
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 156 157 158 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 123 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 83 84 85 |
# 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| if link['role'] == 'creator' || (link['_resolved']['publish'] == false && !include_unpublished) results << {} next end 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
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 118 119 120 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 88 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 |
#digital_objects ⇒ Object
167 168 169 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 167 def digital_objects self.instances_with_digital_objects.map { |instance| instance['digital_object']['_resolved'] } 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 |
#instances_with_digital_objects ⇒ Object
160 161 162 163 164 165 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 160 def instances_with_digital_objects instances = self.instances.select { |inst| inst['digital_object']}.compact instances.each do |inst| inst['digital_object']['_resolved']['_is_in_representative_instance'] = inst['is_representative'] end end |
#instances_with_sub_containers ⇒ Object
171 172 173 |
# File 'backend/app/exporters/lib/export_helpers.rb', line 171 def instances_with_sub_containers self.instances.select {|inst| inst['sub_container']}.compact end |