From df3bba6e90be1e00f92ad7780a1b000651105233 Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Fri, 24 May 2019 09:21:46 -0400 Subject: [PATCH 1/6] Fixed a bug with accession json_fields method --- public/models/aeon_accession_mapper.rb | 3 +++ public/models/aeon_resource_mapper.rb | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/models/aeon_accession_mapper.rb b/public/models/aeon_accession_mapper.rb index c6d760f..a8995d4 100644 --- a/public/models/aeon_accession_mapper.rb +++ b/public/models/aeon_accession_mapper.rb @@ -9,6 +9,9 @@ def initialize(accession) def json_fields mappings = super + json = self.record.json + return mappings unless json + accession_identifier = [ json['id_0'], json['id_1'], json['id_2'], json['id_3'] ] mappings['accession_id'] = accession_identifier .reject {|id_comp| id_comp.blank?} diff --git a/public/models/aeon_resource_mapper.rb b/public/models/aeon_resource_mapper.rb index c72e05b..35e7a96 100644 --- a/public/models/aeon_resource_mapper.rb +++ b/public/models/aeon_resource_mapper.rb @@ -19,9 +19,7 @@ def json_fields mappings = super json = self.record.json - if !json - return mappings - end + return mappings unless json if json['repository_processing_note'] && json['repository_processing_note'].present? mappings['repository_processing_note'] = json['repository_processing_note'] From 4291134db54aae53bde0e86ba8fb66a2c91e68dd Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Wed, 29 May 2019 15:56:59 -0400 Subject: [PATCH 2/6] Added an alt to the font awesome icon --- public/locales/en.yml | 2 +- public/views/aeon/_aeon_request_action.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/locales/en.yml b/public/locales/en.yml index 9d1ccdf..e7fd2a3 100644 --- a/public/locales/en.yml +++ b/public/locales/en.yml @@ -1,6 +1,6 @@ en: plugins: aeon_fulfillment: - request_button_icon: fa fa-external-link fa-3x + request_button_icon: fa fa-external-link fa-external-link-alt fa-3x request_button_label: Aeon Request requesting_disabled: Requesting is not available for this record. diff --git a/public/views/aeon/_aeon_request_action.html.erb b/public/views/aeon/_aeon_request_action.html.erb index de9c9d3..65c3d7b 100644 --- a/public/views/aeon/_aeon_request_action.html.erb +++ b/public/views/aeon/_aeon_request_action.html.erb @@ -31,7 +31,7 @@ mapper = AeonRecordMapper.mapper_for(record)
From d1ee37b4ad3a1f45448ed73e4bfe6e9be18e0400 Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Wed, 29 May 2019 15:59:16 -0400 Subject: [PATCH 3/6] Adjusted note mappings and fixed whitespace errors --- public/models/aeon_accession_mapper.rb | 2 +- public/models/aeon_archival_object_mapper.rb | 2 +- public/models/aeon_record_mapper.rb | 41 +++++++++---------- public/models/aeon_resource_mapper.rb | 6 +-- .../views/aeon/_aeon_request_action.html.erb | 2 +- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/public/models/aeon_accession_mapper.rb b/public/models/aeon_accession_mapper.rb index a8995d4..1711f80 100644 --- a/public/models/aeon_accession_mapper.rb +++ b/public/models/aeon_accession_mapper.rb @@ -34,6 +34,6 @@ def record_fields mappings['language'] = self.record['language'] - return mappings + mappings end end diff --git a/public/models/aeon_archival_object_mapper.rb b/public/models/aeon_archival_object_mapper.rb index 5e622de..f7c68ee 100644 --- a/public/models/aeon_archival_object_mapper.rb +++ b/public/models/aeon_archival_object_mapper.rb @@ -12,7 +12,7 @@ def show_action? return self.requestable_based_on_archival_record_level? end - # Override for AeonRecordMapper json_fields method. + # Override for AeonRecordMapper json_fields method. def json_fields mappings = super diff --git a/public/models/aeon_record_mapper.rb b/public/models/aeon_record_mapper.rb index d95549b..238575b 100644 --- a/public/models/aeon_record_mapper.rb +++ b/public/models/aeon_record_mapper.rb @@ -221,7 +221,7 @@ def system_information mappings['Site'] = self.repo_settings[:aeon_site_code] if self.repo_settings.has_key?(:aeon_site_code) - return mappings + mappings end @@ -267,20 +267,7 @@ def record_fields .join("; ") end - if record.notes - accessrestrict = record.notes['accessrestrict'] - if accessrestrict - arSubnotes = accessrestrict['subnotes'] - if arSubnotes - mappings['accessrestrict'] = arSubnotes - .select { |arSubnote| arSubnote['content'].present? } - .map { |arSubnote| arSubnote['content'].strip } - .join("; ") - end - end - end - - return mappings + mappings end @@ -292,14 +279,26 @@ def json_fields json = self.record.json return mappings unless json + Rails.logger.debug("Aeon Fulfillment Plugin") { "json: #{json}" } + mappings['language'] = json['language'] - if json['notes'] - json['notes'].each do |note| - if note['type'] == 'physloc' and !note['content'].blank? - mappings['physical_location_note'] = note['content'].map { |cont| "#{cont}" }.join("; ") - end - end + notes = json['notes'] + if notes + mappings['physical_location_note'] = notes + .select { |note| note['type'] == 'physloc' and note['content'].present? } + .map { |note| note['content'] } + .flatten + .join("; ") + + mappings['accessrestrict'] = notes + .select { |note| note['type'] == 'accessrestrict' and note['subnotes'] } + .map { |note| note['subnotes'] } + .flatten + .select { |subnote| subnote['content'].present? } + .map { |subnote| subnote['content'] } + .flatten + .join("; ") end if json['dates'] diff --git a/public/models/aeon_resource_mapper.rb b/public/models/aeon_resource_mapper.rb index 35e7a96..a8bcecb 100644 --- a/public/models/aeon_resource_mapper.rb +++ b/public/models/aeon_resource_mapper.rb @@ -7,14 +7,14 @@ class AeonResourceMapper < AeonRecordMapper def initialize(resource) super(resource) end - + # Override of #show_action? from AeonRecordMapper def show_action? return false if !super return self.requestable_based_on_archival_record_level? end - # Override for AeonRecordMapper json_fields method. + # Override for AeonRecordMapper json_fields method. def json_fields mappings = super @@ -24,7 +24,7 @@ def json_fields if json['repository_processing_note'] && json['repository_processing_note'].present? mappings['repository_processing_note'] = json['repository_processing_note'] end - + resource_identifier = [ json['id_0'], json['id_1'], json['id_2'], json['id_3'] ] mappings['collection_id'] = resource_identifier .reject {|id_comp| id_comp.blank?} diff --git a/public/views/aeon/_aeon_request_action.html.erb b/public/views/aeon/_aeon_request_action.html.erb index 65c3d7b..8972af6 100644 --- a/public/views/aeon/_aeon_request_action.html.erb +++ b/public/views/aeon/_aeon_request_action.html.erb @@ -40,6 +40,6 @@ mapper = AeonRecordMapper.mapper_for(record) <% end %> -<% +<% Rails.logger.info("Aeon Fulfillment Plugin") { "Finished initializing plugin." } %> From b5aa5ddcb0f20357464b4739d5a0f31fbb2bcaa9 Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Wed, 29 May 2019 16:30:47 -0400 Subject: [PATCH 4/6] Adjusted logging, removed more "return"s --- public/models/aeon_archival_object_mapper.rb | 4 ++-- public/models/aeon_record_mapper.rb | 6 ++++-- public/models/aeon_resource_mapper.rb | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/public/models/aeon_archival_object_mapper.rb b/public/models/aeon_archival_object_mapper.rb index f7c68ee..19c74ad 100644 --- a/public/models/aeon_archival_object_mapper.rb +++ b/public/models/aeon_archival_object_mapper.rb @@ -25,7 +25,7 @@ def json_fields mappings['repository_processing_note'] = json['repository_processing_note'] end - return mappings + mappings end # Returns a hash that maps from Aeon OpenURL values to values in the provided record. @@ -34,6 +34,6 @@ def record_fields mappings['component_id'] = self.record['component_id'] - return mappings + mappings end end diff --git a/public/models/aeon_record_mapper.rb b/public/models/aeon_record_mapper.rb index 238575b..99ea8c4 100644 --- a/public/models/aeon_record_mapper.rb +++ b/public/models/aeon_record_mapper.rb @@ -186,7 +186,7 @@ def map .merge(self.record_fields) .merge(self.user_defined_fields) - return mappings + mappings end @@ -229,6 +229,8 @@ def system_information def record_fields mappings = {} + Rails.logger.debug("Aeon Fulfillment Plugin") { "Mapping Record: #{self.record}" } + mappings['identifier'] = self.record.identifier || self.record['identifier'] mappings['publish'] = self.record['publish'] mappings['level'] = self.record.level || self.record['level'] @@ -279,7 +281,7 @@ def json_fields json = self.record.json return mappings unless json - Rails.logger.debug("Aeon Fulfillment Plugin") { "json: #{json}" } + Rails.logger.debug("Aeon Fulfillment Plugin") { "Mapping Record JSON: #{json}" } mappings['language'] = json['language'] diff --git a/public/models/aeon_resource_mapper.rb b/public/models/aeon_resource_mapper.rb index a8bcecb..64038b1 100644 --- a/public/models/aeon_resource_mapper.rb +++ b/public/models/aeon_resource_mapper.rb @@ -11,7 +11,8 @@ def initialize(resource) # Override of #show_action? from AeonRecordMapper def show_action? return false if !super - return self.requestable_based_on_archival_record_level? + + self.requestable_based_on_archival_record_level? end # Override for AeonRecordMapper json_fields method. From d63b6caa97383a66c0124e217f5b816af88a9f9c Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Wed, 29 May 2019 16:31:06 -0400 Subject: [PATCH 5/6] README update to reflect the new version date --- Readme.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index be13743..e284eb8 100644 --- a/Readme.md +++ b/Readme.md @@ -1,8 +1,8 @@ # ArchivesSpace Request Fulfillment via Aeon -**Version:** 20190115 +**Version:** 20190529 -**Last Updated:** January 15, 2019 +**Last Updated:** May 29, 2019 ## Table of Contents @@ -141,7 +141,9 @@ ArchivesSpace may cause changes in the functionality of this plugin. - The plugin now removes all HTML tags from form values - **20190115** - Added the `:user_defined_fields` setting - +- **20190529** + - Bug fixes for compatibility with ArchivesSpace v2.6.0 RC1 + ## Configuring Plugin Settings In order to configure this plugin, you will need to modify the From 6394b1c00d7543aec0f200e651b9c295d7b48b19 Mon Sep 17 00:00:00 2001 From: Austin Schaffer Date: Wed, 29 May 2019 16:31:46 -0400 Subject: [PATCH 6/6] Removed more EOL whitespace --- public/models/aeon_record_mapper.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/public/models/aeon_record_mapper.rb b/public/models/aeon_record_mapper.rb index 99ea8c4..9c82f88 100644 --- a/public/models/aeon_record_mapper.rb +++ b/public/models/aeon_record_mapper.rb @@ -10,7 +10,7 @@ def initialize(record) @record = record @container_instances = find_container_instances(record['json'] || {}) end - + def archivesspace ArchivesSpaceClient.instance end @@ -41,7 +41,7 @@ def user_defined_fields if (udf_setting = self.repo_settings[:user_defined_fields]) if (user_defined_fields = (self.record['json'] || {})['user_defined']) - + # Determine if the list is a whitelist or a blacklist of fields. # If the setting is just an array, assume that the list is a # whitelist. @@ -193,7 +193,7 @@ def map # Pulls data from AppConfig and ASpace System def system_information mappings = {} - + mappings['SystemID'] = if (!self.repo_settings[:aeon_external_system_id].blank?) self.repo_settings[:aeon_external_system_id] @@ -251,7 +251,7 @@ def record_fields mappings['collection_id'] = collection_id_components .reject {|id_comp| id_comp.blank?} .join('-') - + mappings['collection_title'] = resource_obj[0]['title'] end end @@ -292,7 +292,7 @@ def json_fields .map { |note| note['content'] } .flatten .join("; ") - + mappings['accessrestrict'] = notes .select { |note| note['type'] == 'accessrestrict' and note['subnotes'] } .map { |note| note['subnotes'] } @@ -403,7 +403,7 @@ def json_fields def find_container_instances (record_json) current_uri = record_json['uri'] - + Rails.logger.info("Aeon Fulfillment Plugin") { "Checking \"#{current_uri}\" for Top Container instances..." } Rails.logger.debug("Aeon Fulfillment Plugin") { "#{record_json.to_json}" } @@ -424,14 +424,14 @@ def find_container_instances (record_json) parent_uri = record_json['resource']['ref'] parent_uri = record_json['resource'] unless parent_uri.present? end - + if parent_uri.present? Rails.logger.debug("Aeon Fulfillment Plugin") { "No Top Container instances found. Checking parent. (#{parent_uri})" } parent = archivesspace.get_record(parent_uri) parent_json = parent['json'] return find_container_instances(parent_json) end - + Rails.logger.debug("Aeon Fulfillment Plugin") { "No Top Container instances found." } []