Skip to content

Commit

Permalink
MODS Export: export authority_id in 'valueURI' param in name tag for
Browse files Browse the repository at this point in the history
agents if provided
  • Loading branch information
avatar382 committed Apr 10, 2018
1 parent 0b04400 commit 0646e6d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions backend/app/exporters/models/mods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def handle_agents(linked_agents)
'type' => name_type,
'role' => role,
'source' => name['source'],
'authority_id' => name['authority_id'],
'parts' => name_parts(name, agent['jsonmodel_type']),
'displayForm' => name['sort_name']
}
Expand Down
1 change: 1 addition & 0 deletions backend/app/exporters/serializers/mods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def serialize_mods_inner(mods, xml)
def serialize_name(name, xml)
atts = {:type => name['type']}
atts[:authority] = name['source'] if name['source']
atts["valueURI"] = name['authority_id'] if name['authority_id']
xml.name(atts) {
name['parts'].each do |part|
if part['type']
Expand Down
22 changes: 16 additions & 6 deletions backend/spec/export_mods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
@agent_person = create(:json_agent_person,
:names => names)

@agent_corporation = create(:json_agent_corporate_entity,
:names => [build(:json_name_corporate_entity,
:authority_id => rand(1000000).to_s
)]
)

@subject_person = create(:json_agent_person)

@subjects = (0..5).map { create(:json_subject) }
Expand All @@ -35,6 +41,10 @@
:role => 'creator',
:ref => @agent_person.uri
},
{
:role => 'creator',
:ref => @agent_corporation.uri
},
{
:role => 'subject',
:ref => @subject_person.uri
Expand Down Expand Up @@ -116,6 +126,12 @@
it "creates a role for each name" do
@mods.should have_tag "mods/name[@type='personal']/role/roleTerm[@type='text'][@authority='marcrelator']" => "creator"
end

it "should put authority_id and source in the name tag for corporate agents" do
authority_id = @agent_corporation['names'][0]['authority_id']
source = @agent_corporation['names'][0]['source']
@mods.should have_tag "name[@type='corporate'][@valueURI='#{authority_id}'][@authority='#{source}']"
end
end


Expand Down Expand Up @@ -300,12 +316,6 @@
@mods = get_mods(@digital_object_unpub)
end

after(:all) do
@digital_object_unpub.flatten.each do |rec|
rec.delete
end
end

it "should not export extent notes if unpublished" do
@mods.should_not have_tag "physicalDescription/note[@type='dimensions'][@displayLabel='Dimensions']" => note_content(@dimension_note[0])
end
Expand Down

0 comments on commit 0646e6d

Please sign in to comment.