Skip to content

Commit

Permalink
Merge pull request #33 from AtlasSystems/bug/v2.6.0-compatibilitiy
Browse files Browse the repository at this point in the history
* Fixed a bug with accession json_fields method
* Added an alt to the font awesome icon
* Fixed mapping for accessrestrict notes
  • Loading branch information
Austin T Schaffer authored May 30, 2019
2 parents 1b62e13 + 6394b1c commit 558ec48
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 46 deletions.
8 changes: 5 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion public/locales/en.yml
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 4 additions & 1 deletion public/models/aeon_accession_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?}
Expand All @@ -31,6 +34,6 @@ def record_fields

mappings['language'] = self.record['language']

return mappings
mappings
end
end
6 changes: 3 additions & 3 deletions public/models/aeon_archival_object_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand All @@ -34,6 +34,6 @@ def record_fields

mappings['component_id'] = self.record['component_id']

return mappings
mappings
end
end
59 changes: 30 additions & 29 deletions public/models/aeon_record_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(record)
@record = record
@container_instances = find_container_instances(record['json'] || {})
end

def archivesspace
ArchivesSpaceClient.instance
end
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -186,14 +186,14 @@ def map
.merge(self.record_fields)
.merge(self.user_defined_fields)

return mappings
mappings
end


# 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]
Expand Down Expand Up @@ -221,14 +221,16 @@ def system_information

mappings['Site'] = self.repo_settings[:aeon_site_code] if self.repo_settings.has_key?(:aeon_site_code)

return mappings
mappings
end


# Pulls data from self.record
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']
Expand All @@ -249,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
Expand All @@ -267,20 +269,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


Expand All @@ -292,14 +281,26 @@ def json_fields
json = self.record.json
return mappings unless json

Rails.logger.debug("Aeon Fulfillment Plugin") { "Mapping Record 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']
Expand Down Expand Up @@ -402,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}" }

Expand All @@ -423,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." }

[]
Expand Down
13 changes: 6 additions & 7 deletions public/models/aeon_resource_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,25 @@ 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?

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

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']
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?}
Expand Down
4 changes: 2 additions & 2 deletions public/views/aeon/_aeon_request_action.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mapper = AeonRecordMapper.mapper_for(record)

<div id="disabled-button-wrapper" tabindex="0" rel="tooltip" data-placement="bottom" title="<%= t('plugins.aeon_fulfillment.requesting_disabled') %>">
<button id="disabled-aeon-fulfillment-request" class="btn btn-default page_action request" disabled="true" aria-disabled="true">
<i class="fa fa-external-link fa-3x"></i><br/><%= t('plugins.aeon_fulfillment.request_button_label') %>
<i class="<%= t('plugins.aeon_fulfillment.request_button_icon') %>"></i><br/><%= t('plugins.aeon_fulfillment.request_button_label') %>
<span class="visually-hidden"><%= t('plugins.aeon_fulfillment.requesting_disabled') %></span>
</button>
</div>
Expand All @@ -40,6 +40,6 @@ mapper = AeonRecordMapper.mapper_for(record)

<% end %>

<%
<%
Rails.logger.info("Aeon Fulfillment Plugin") { "Finished initializing plugin." }
%>

0 comments on commit 558ec48

Please sign in to comment.