Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANW-1843: add toggle to exclude <unitid> containing ASpace URI from EAD #3188

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions backend/app/controllers/exports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class ArchivesSpaceService < Sinatra::Base
curl -s -F password="admin" "http://localhost:8089/users/admin/login"
set SESSION="session_id"
curl -H "X-ArchivesSpace-Session: $SESSION" \\
"http://localhost:8089/repositories/2/resource_descriptions/577.xml?include_unpublished=false&include_daos=true&numbered_cs=true&print_pdf=false&ead3=false" //
"http://localhost:8089/repositories/2/resource_descriptions/577.xml?include_unpublished=false&include_daos=true&include_uri_unitids=true&numbered_cs=true&print_pdf=false&ead3=false" //
--output ead.xml
SHELL
end
Expand Down Expand Up @@ -351,6 +351,8 @@ class ArchivesSpaceService < Sinatra::Base
"Include unpublished records", :optional => true],
["include_daos", BooleanParam,
"Include digital objects in dao tags", :optional => true],
["include_uri_unitids", BooleanParam,
"Include unitid tags containing ArchivesSpace URIs", :optional => true],
["numbered_cs", BooleanParam,
"Use numbered <c> tags in ead", :optional => true],
["print_pdf", BooleanParam,
Expand All @@ -367,6 +369,7 @@ class ArchivesSpaceService < Sinatra::Base
ead_stream = generate_ead(params[:id],
(params[:include_unpublished] || false),
(params[:include_daos] || false),
(params[:include_uri_unitids] || false),
(params[:numbered_cs] || false),
(params[:ead3] || false))
stream_response(ead_stream)
Expand All @@ -379,7 +382,7 @@ class ArchivesSpaceService < Sinatra::Base
curl -s -F password="admin" "http://localhost:8089/users/admin/login"
set SESSION="session_id"
curl -H "X-ArchivesSpace-Session: $SESSION" \\
"http://localhost:8089/repositories/2/resource_descriptions/577.pdf?include_unpublished=false&include_daos=true&numbered_cs=true&print_pdf=false&ead3=false" //
"http://localhost:8089/repositories/2/resource_descriptions/577.pdf?include_unpublished=false&include_daos=true&include_uri_unitids=true&numbered_cs=true&print_pdf=false&ead3=false" //
--output ead.pdf
SHELL
end
Expand Down Expand Up @@ -413,6 +416,8 @@ class ArchivesSpaceService < Sinatra::Base
"Include unpublished records", :optional => true],
["include_daos", BooleanParam,
"Include digital objects in dao tags", :optional => true],
["include_uri_unitids", BooleanParam,
"Include unitid tags containing ArchivesSpace URIs", :optional => true],
["numbered_cs", BooleanParam,
"Use numbered <c> tags in ead", :optional => true],
["print_pdf", BooleanParam,
Expand All @@ -426,6 +431,7 @@ class ArchivesSpaceService < Sinatra::Base
ead_stream = generate_ead(params[:id],
(params[:include_unpublished] || false),
(params[:include_daos] || false),
(params[:include_uri_unitids] || false),
(params[:numbered_cs] || false),
(params[:ead3] || false))

Expand Down
4 changes: 4 additions & 0 deletions backend/app/exporters/models/ead.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ def include_daos?
@include_daos
end

def include_uri_unitids?
@include_uri_unitids
end


def use_numbered_c_tags?
@use_numbered_c_tags
Expand Down
9 changes: 7 additions & 2 deletions backend/app/exporters/serializers/ead.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def stream(data)
@fragments = ASpaceExport::RawXMLHandler.new
@include_unpublished = data.include_unpublished?
@include_daos = data.include_daos?
@include_uri_unitids = data.include_uri_unitids?
@use_numbered_c_tags = data.use_numbered_c_tags?
@id_prefix = I18n.t('archival_object.ref_id_export_prefix', :default => 'aspace_')

Expand Down Expand Up @@ -193,7 +194,9 @@ def stream(data)

handle_arks(data, xml)

serialize_aspace_uri(data, xml)
if @include_uri_unitids
serialize_aspace_uri(data, xml)
end

serialize_extents(data, xml, @fragments)

Expand Down Expand Up @@ -321,7 +324,9 @@ def serialize_child(data, xml, fragments, c_depth = 1)

handle_arks(data, xml)

serialize_aspace_uri(data, xml)
if @include_uri_unitids
serialize_aspace_uri(data, xml)
end

if @include_unpublished
data.external_ids.each do |exid|
Expand Down
10 changes: 8 additions & 2 deletions backend/app/exporters/serializers/ead3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def stream(data)
@fragments = ASpaceExport::RawXMLHandler.new
@include_unpublished = data.include_unpublished?
@include_daos = data.include_daos?
@include_uri_unitids = data.include_uri_unitids?
@use_numbered_c_tags = data.use_numbered_c_tags?
@id_prefix = I18n.t('archival_object.ref_id_export_prefix', :default => 'aspace_')

Expand Down Expand Up @@ -486,7 +487,10 @@ def stream(data)

handle_arks(data, xml)

serialize_aspace_uri(data, xml)

if @include_uri_unitids
serialize_aspace_uri(data, xml)
end

unless data.repo.nil? || data.repo.name.nil?
xml.repository {
Expand Down Expand Up @@ -1173,7 +1177,9 @@ def serialize_child(data, xml, fragments, c_depth = 1)

handle_arks(data, xml)

serialize_aspace_uri(data, xml)
if @include_uri_unitids
serialize_aspace_uri(data, xml)
end

if !data.component_id.nil? && !data.component_id.empty?
xml.unitid data.component_id
Expand Down
3 changes: 2 additions & 1 deletion backend/app/lib/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def generate_marc(id, include_unpublished = false)
end


def generate_ead(id, include_unpublished, include_daos, use_numbered_c_tags, ead3)
def generate_ead(id, include_unpublished, include_daos, include_uri_unitids, use_numbered_c_tags, ead3)
resolve = ['repository', 'linked_agents', 'subjects', 'digital_object', 'top_container', 'top_container::container_profile']

resource = Resource.get_or_die(id)
Expand All @@ -94,6 +94,7 @@ def generate_ead(id, include_unpublished, include_daos, use_numbered_c_tags, ead
opts = {
:include_unpublished => include_unpublished,
:include_daos => include_daos,
:include_uri_unitids => include_uri_unitids,
:use_numbered_c_tags => use_numbered_c_tags,
:ead3 => ead3
}
Expand Down
19 changes: 15 additions & 4 deletions backend/spec/export_ead3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,12 @@ def archival_object(index)

as_test_user("admin", true) do
load_export_fixtures
@doc = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true&ead3=true")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep a test that checks that the default behavior (the one that is currently happening on master) also continues to happen on these changes if no include_uri_unitids parameter is present in the request.

@doc = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true&include_uri_unitids=true&ead3=true")
@doc_nsless = Nokogiri::XML::Document.parse(@doc.to_xml)
@doc_nsless.remove_namespaces!
@doc_uri_disabled = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_daos=true&include_uri_unitids=false")
@doc_no_uri_param_present = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_daos=true")

raise Sequel::Rollback
end
end
Expand Down Expand Up @@ -419,6 +422,14 @@ def archival_object(index)
mt(object.uri, "#{desc_path}/did/unitid[@localtype='aspace_uri']")
end

it "does not map {archival_object}.uri to {desc_path}/did/unitid[@type='aspace_uri'] if flag disabled" do
expect(@doc_uri_disabled).not_to have_node(desc_path + "/did/unitid[@type='aspace_uri']")
end

it "does maps {archival_object}.uri to {desc_path}/did/unitid[@type='aspace_uri'] if flag not present" do
expect(@doc_no_uri_param_present).to have_node(desc_path + "/did/unitid[@type='aspace_uri']")
end

it "maps {archival_object}.(id_[0-3]|component_id) to {desc_path}/did/unitid" do
if !unitid_src.nil? && !unitid_src.empty?
mt(unitid_src, "#{desc_path}/did/unitid")
Expand Down Expand Up @@ -1377,7 +1388,7 @@ def description_content(obj)
describe "Test unpublished record EAD exports" do

def get_xml_doc(include_unpublished = false)
doc_for_unpublished_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@unpublished_resource_jsonmodel.id}.xml?include_unpublished=#{include_unpublished}&include_daos=true&ead3=true", true)
doc_for_unpublished_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@unpublished_resource_jsonmodel.id}.xml?include_unpublished=#{include_unpublished}&include_daos=true&include_uri_unitids=true&ead3=true", true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, we should ensure that the default behavior happens if no include_uri_unitids param is given.


doc_nsless_for_unpublished_resource = Nokogiri::XML::Document.parse(doc_for_unpublished_resource)
doc_nsless_for_unpublished_resource.remove_namespaces!
Expand Down Expand Up @@ -1483,7 +1494,7 @@ def get_xml_doc(include_unpublished = false)
def get_xml_doc
as_test_user("admin") do
DB.open(true) do
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource_jsonmodel.id}.xml?include_unpublished=true&include_daos=true", true)
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource_jsonmodel.id}.xml?include_unpublished=true&include_daos=true&include_uri_unitids=true", true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. We should check that the default behavior is happening both

  • if include_uri_uinitids=true is present
  • and if no include_uri_unitids param is present


doc_nsless_for_resource = Nokogiri::XML::Document.parse(doc_for_resource)
doc_nsless_for_resource.remove_namespaces!
Expand Down Expand Up @@ -1579,7 +1590,7 @@ def get_xml_doc
def get_xml_doc
as_test_user("admin") do
DB.open(true) do
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true&ead3=true", true)
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true&include_uri_unitids=true&ead3=true", true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. We should check that the default behavior is happening both

  • if include_uri_uinitids=true is present
  • and if no include_uri_unitids param is present


doc_nsless_for_resource = Nokogiri::XML::Document.parse(doc_for_resource)
doc_nsless_for_resource.remove_namespaces!
Expand Down
15 changes: 10 additions & 5 deletions backend/spec/export_ead_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ def archival_object(index)

as_test_user("admin", true) do
load_export_fixtures
@doc = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true")
@doc_unpub = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_daos=true")
@doc = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true&include_uri_unitids=true")
@doc_unpub = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_daos=true&include_uri_unitids=true")
@doc_no_uri = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_daos=true&include_uri_unitids=false")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment. We should also add the case when no include_uri_unitids param is present

@doc_nsless = Nokogiri::XML::Document.parse(@doc.to_xml)
@doc_nsless.remove_namespaces!
Expand Down Expand Up @@ -301,6 +302,10 @@ def archival_object(index)
mt(object.uri, "#{desc_path}/did/unitid[@type='aspace_uri']")
end

it "does not map {archival_object}.uri to {desc_path}/did/unitid[@type='aspace_uri'] if flag disabled" do
expect(@doc_no_uri).not_to have_node(desc_path + "/did/unitid[@type='aspace_uri']")
end

it "maps {archival_object}.lang_materials['language_and_script'] to {desc_path}/did/langmaterial/language" do

language = object.lang_materials[0]['language_and_script']['language']
Expand Down Expand Up @@ -1319,7 +1324,7 @@ def description_content(obj)
def get_xml_doc(include_unpublished = false)
as_test_user("admin") do
DB.open(true) do
doc_for_unpublished_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@unpublished_resource_jsonmodel.id}.xml?include_unpublished=#{include_unpublished}&include_daos=true", true)
doc_for_unpublished_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@unpublished_resource_jsonmodel.id}.xml?include_unpublished=#{include_unpublished}&include_daos=true&include_uri_unitids=true", true)

doc_nsless_for_unpublished_resource = Nokogiri::XML::Document.parse(doc_for_unpublished_resource)
doc_nsless_for_unpublished_resource.remove_namespaces!
Expand Down Expand Up @@ -1454,7 +1459,7 @@ def get_xml_doc(include_unpublished = false)
def get_xml_doc
as_test_user("admin") do
DB.open(true) do
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource_jsonmodel.id}.xml?include_unpublished=true&include_daos=true", true)
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource_jsonmodel.id}.xml?include_unpublished=true&include_daos=true&include_uri_unitids=true", true)

doc_nsless_for_resource = Nokogiri::XML::Document.parse(doc_for_resource)
doc_nsless_for_resource.remove_namespaces!
Expand Down Expand Up @@ -1533,7 +1538,7 @@ def get_xml_doc
def get_xml_doc
as_test_user("admin") do
DB.open(true) do
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true", true)
doc_for_resource = get_xml("/repositories/#{$repo_id}/resource_descriptions/#{@resource.id}.xml?include_unpublished=true&include_daos=true&include_uri_unitids=true", true)

doc_nsless_for_resource = Nokogiri::XML::Document.parse(doc_for_resource)
doc_nsless_for_resource.remove_namespaces!
Expand Down
2 changes: 1 addition & 1 deletion common/config/config-defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

AppConfig[:oai_proxy_url] = 'http://your-public-oai-url.example.com'

AppConfig[:oai_ead_options] = {}
AppConfig[:oai_ead_options] = { :include_uri_unitids => true }
# alternate example: AppConfig[:oai_ead_options] = { :include_daos => true, :use_numbered_c_tags => true }

##
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/assets/javascripts/export_dropdown.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(function () {
e.stopPropagation();
});
$('.record-toolbar').on('click', 'a.download-ead-action', function(e) {
var url = AS.quickTemplate(decodeURIComponent($("#download-ead-dropdown").data("download-ead-url")), { testme: true, include_unpublished: $("input#include-unpublished").is(':checked'), include_daos: $("input#include-daos").is(':checked'), numbered_cs: $("input#numbered-cs").is(':checked'), print_pdf: $("input#print-pdf").is(':checked'), ead3: $("input#ead3").is(':checked')});
var url = AS.quickTemplate(decodeURIComponent($("#download-ead-dropdown").data("download-ead-url")), { testme: true, include_unpublished: $("input#include-unpublished").is(':checked'), include_daos: $("input#include-daos").is(':checked'), include_uri_unitids: $("input#include-uri-unitids").is(':checked'), numbered_cs: $("input#numbered-cs").is(':checked'), print_pdf: $("input#print-pdf").is(':checked'), ead3: $("input#ead3").is(':checked')});
location.href = url;
});
$('.record-toolbar').on('click', 'a.download-marc-action', function(e) {
Expand Down
1 change: 1 addition & 0 deletions frontend/app/controllers/exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def download_ead
:include_unpublished => (params[:include_unpublished] ? params[:include_unpublished] : false),
:print_pdf => (params[:print_pdf] ? params[:print_pdf] : false),
:include_daos => (params[:include_daos] ? params[:include_daos] : false),
:include_uri_unitids => (params[:include_uri_unitids] ? params[:include_uri_unitids] : false),
:numbered_cs => (params[:numbered_cs] ? params[:numbered_cs] : false),
:ead3 => (params[:ead3] ? params[:ead3] : false))
end
Expand Down
6 changes: 5 additions & 1 deletion frontend/app/views/resources/_toolbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<% content_for :exports do %>
<li class="dropdown-submenu" id="download-ead-dropdown" data-download-ead-url="<%= url_for(:controller => :exports,
:action => :download_ead, :id => @resource.id, :include_unpublished => "${include_unpublished}",
:include_daos => "${include_daos}", :numbered_cs => "${numbered_cs}", :print_pdf => "${print_pdf}",
:include_daos => "${include_daos}", :include_uri_unitids => "${include_uri_unitids}", :numbered_cs => "${numbered_cs}", :print_pdf => "${print_pdf}",
:ead3 => "${ead3}" )%>">
<a href="#" data-toggle="dropdown" class="menu-with-options download-ead-action" title="<%= I18n.t("actions.export_ead") %>"><%= I18n.t("actions.export_ead") %></a>
<div class="dropdown-menu" id="form_download_ead">
Expand All @@ -20,6 +20,10 @@
<input type="checkbox" id="include-daos" name="include_daos" checked="checked"/>
<%= I18n.t("export_options.include_daos") %>&#160;
</label>
<label class="checkbox" for="include-uri-unitids">
<input type="checkbox" id="include-uri-unitids" name="include_uri_unitids" checked="checked"/>
<%= I18n.t("export_options.include_uri_unitids") %>&#160;
</label>
<label class="checkbox" for="numbered-cs">
<input type="checkbox" id="numbered-cs" name="numbered_cs" />
<%= I18n.t("export_options.numbered_cs") %>&#160;
Expand Down
1 change: 1 addition & 0 deletions frontend/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ en:
export_options:
include_unpublished: Include unpublished
include_daos: Include &lt;dao&gt; tags
include_uri_unitids: Include &lt;unitid&gt; tags containing URIs
numbered_cs: Use numbered &lt;c&gt; tags
print_pdf: Print to PDF
ead3: EAD3 schema
Expand Down