ddr-models 3.0.0.beta.1 → 3.0.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a968b891893ea815c1d2cdfd34f7b30fd7b0037
4
- data.tar.gz: ab7b098e5f87fa7f31793e878206031bd010c98b
3
+ metadata.gz: 75efc0f919210a7a3c4f77818f3d48191485bd5c
4
+ data.tar.gz: a831671103f6e4d9e3b2c0d5ff60ecd217292836
5
5
  SHA512:
6
- metadata.gz: 76508b87a3e44c630e445d2ac5f89286ff08c59ffac61f07902e5e9e3ef59d54db78e2b1707d578f905c4c682008fc178ce770f8b61aa326a67490db2975a727
7
- data.tar.gz: 3b288f688a6513a82feada181e1fe8c60dde16fbb4bba03c809b5c0dcc21730008e551ab6c5575fa63f01bec9fd861f757431e5dcb09b664d7e091e37fcf11a7
6
+ metadata.gz: 311a0413074b9c8b82cad7f373d56f1a8dc12c0177183e587f4c571463b3f04abce3f142036fb99fcaf2a7b88977caa4a6df3d6d950426266e73e37cfa172c33
7
+ data.tar.gz: 85ee619d6263ebe046185b267d695804635e3defb72bf58749909317d0089f60344e9cc9fba0e044be4f71866eca03c32c1864ccc69d3f67a3e3f6e38a673ca7
@@ -20,7 +20,7 @@ module Ddr::Auth
20
20
  if role.is_a?(Role)
21
21
  role_set.include?(role)
22
22
  else
23
- !where(role).empty?
23
+ granted? Role.new(role)
24
24
  end
25
25
  end
26
26
 
@@ -40,6 +40,7 @@ module Ddr::Index
40
40
  DOI = Field.new :doi, :symbol
41
41
  EAD_ID = Field.new :ead_id, :stored_sortable
42
42
  EXTRACTED_TEXT = Field.new :extracted_text, :searchable, type: :text
43
+ FCREPO3_PID = Field.new :fcrepo3_pid, :stored_sortable
43
44
  HAS_MODEL = Field.new :has_model, :symbol
44
45
  IDENTIFIER_ALL = Field.new :identifier_all, :symbol
45
46
  IS_ATTACHED_TO = Field.new :is_attached_to, :symbol
@@ -119,50 +119,5 @@ module Ddr::Models
119
119
  self
120
120
  end
121
121
 
122
- # Moves the first (descriptive metadata) identifier into
123
- # (administrative metadata) local_id according to the following
124
- # rubric:
125
- #
126
- # No existing local_id:
127
- # - Set local_id to first identifier value
128
- # - Remove first identifier value
129
- #
130
- # Existing local_id:
131
- # Same as first identifier value
132
- # - Remove first identifier value
133
- # Not same as first identifier value
134
- # :replace option is true
135
- # - Set local_id to first identifier value
136
- # - Remove first identifier value
137
- # :replace option is false
138
- # - Do nothing
139
- #
140
- # Returns true or false depending on whether the object was
141
- # changed by this method
142
- def move_first_identifier_to_local_id(replace: true)
143
- moved = false
144
- identifiers = descMetadata.identifier.to_a
145
- first_id = identifiers.shift
146
- if first_id
147
- if local_id.blank?
148
- self.local_id = first_id
149
- self.descMetadata.identifier = identifiers
150
- moved = true
151
- else
152
- if local_id == first_id
153
- self.descMetadata.identifier = identifiers
154
- moved = true
155
- else
156
- if replace
157
- self.local_id = first_id
158
- self.descMetadata.identifier = identifiers
159
- moved = true
160
- end
161
- end
162
- end
163
- end
164
- moved
165
- end
166
-
167
122
  end
168
123
  end
@@ -29,6 +29,10 @@ module Ddr::Models
29
29
  predicate: Ddr::Vocab::Asset.eadId,
30
30
  multiple: false
31
31
 
32
+ property :fcrepo3_pid,
33
+ predicate: RDF::URI("info:fedora/fedora-system:def/model#PID"),
34
+ multiple: false
35
+
32
36
  property :license,
33
37
  predicate: RDF::DC.license,
34
38
  multiple: false
@@ -4,8 +4,12 @@ module Ddr
4
4
 
5
5
  def first_child
6
6
  child_class = self.class.reflect_on_association(:children).klass
7
- solr_field = child_class.reflect_on_association(:parent).solr_key
8
- child_class.where(solr_field => id).order("#{Ddr::Index::Fields::LOCAL_ID} ASC").first
7
+ if has_struct_metadata?
8
+ child_class.find(structure.default_struct_map_ids.first)
9
+ else
10
+ solr_field = child_class.reflect_on_association(:parent).solr_key
11
+ child_class.where(solr_field => id).order("#{Ddr::Index::Fields::LOCAL_ID} ASC").first
12
+ end
9
13
  end
10
14
 
11
15
  end
@@ -32,7 +32,7 @@ module Ddr
32
32
  private
33
33
 
34
34
  def find_children
35
- query = association_query(:children)
35
+ query = ActiveFedora::SolrService.construct_query_for_rel([[ self.class.reflect_on_association(:children), self.id ]])
36
36
  sort = "#{Ddr::Index::Fields::LOCAL_ID} ASC, #{Ddr::Index::Fields::OBJECT_CREATE_DATE} ASC"
37
37
  ActiveFedora::SolrService.query(query, sort: sort, rows: 999999)
38
38
  end
@@ -50,9 +50,9 @@ module Ddr
50
50
  div
51
51
  end
52
52
 
53
- def create_fptr(stru, div, pid)
53
+ def create_fptr(stru, div, id)
54
54
  fptr = Nokogiri::XML::Node.new('fptr', stru.as_xml_document)
55
- fptr['CONTENTIDS'] = "info:fedora/#{pid}"
55
+ fptr['CONTENTIDS'] = id
56
56
  div.add_child(fptr)
57
57
  end
58
58
 
@@ -22,6 +22,7 @@ module Ddr
22
22
  DISPLAY_FORMAT => display_format,
23
23
  DOI => doi,
24
24
  EAD_ID => ead_id,
25
+ FCREPO3_PID => fcrepo3_pid,
25
26
  IDENTIFIER_ALL => all_identifiers,
26
27
  LICENSE => license,
27
28
  LOCAL_ID => local_id,
@@ -43,7 +43,7 @@ module Ddr
43
43
  private
44
44
 
45
45
  def fptr_pids(div_node)
46
- div_node.xpath('xmlns:fptr').map { |fptr_node| fptr_node["CONTENTIDS"].gsub('info:fedora/', '') }
46
+ div_node.xpath('xmlns:fptr').map { |fptr_node| fptr_node["CONTENTIDS"] }
47
47
  end
48
48
 
49
49
  def subdivs(structmap_or_div_node)
@@ -13,6 +13,14 @@ module Ddr
13
13
  @struct_maps ||= build_struct_maps(structMap_nodes)
14
14
  end
15
15
 
16
+ def default_struct_map
17
+ struct_maps['default'] || struct_maps[struct_maps.keys.first]
18
+ end
19
+
20
+ def default_struct_map_ids
21
+ default_struct_map.pids
22
+ end
23
+
16
24
  def structMap_node(type='default')
17
25
  xpath("//xmlns:structMap[@TYPE='#{type}']").first
18
26
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "3.0.0.beta.1"
3
+ VERSION = "3.0.0.beta.2"
4
4
  end
5
5
  end
@@ -79,6 +79,10 @@ module Ddr::Auth
79
79
  expect(subject.granted?(role1.to_h)).to be true
80
80
  expect(subject.granted?(role2.to_h)).to be false
81
81
  end
82
+ it "coerces argument to Role" do
83
+ expect(subject.granted?(role_type: Roles::EDITOR, agent: role1.agent, scope: "resource"))
84
+ .to be true
85
+ end
82
86
  end
83
87
 
84
88
  end
@@ -1,7 +1,7 @@
1
1
  module Ddr::Models
2
2
  RSpec.describe HasChildren do
3
3
 
4
- subject { FactoryGirl.create(:collection) }
4
+ subject { FactoryGirl.create(:item) }
5
5
 
6
6
  describe "#first_child" do
7
7
  describe "when the object has no children" do
@@ -10,19 +10,50 @@ module Ddr::Models
10
10
  end
11
11
  end
12
12
  describe "when the object has children" do
13
- let(:child1) { FactoryGirl.create(:item) }
14
- let(:child2) { FactoryGirl.create(:item) }
13
+ let(:child1) { FactoryGirl.create(:component) }
14
+ let(:child2) { FactoryGirl.create(:component) }
15
+ let(:child3) { FactoryGirl.create(:component) }
15
16
  before do
16
17
  child1.local_id = "test002"
17
- child1.save
18
+ child1.save!
18
19
  child2.local_id = "test001"
19
- child2.save
20
+ child2.save!
21
+ child3.local_id = "test003"
22
+ child3.save!
20
23
  subject.children << child1
21
24
  subject.children << child2
22
- subject.save
25
+ subject.children << child3
26
+ subject.save!
23
27
  end
24
- it "should return the first child as sorted by local ID" do
25
- expect(subject.first_child).to eq(child2)
28
+ describe "when the object has structural metadata" do
29
+ before do
30
+ struct_map = <<-EOS
31
+ <mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
32
+ <structMap TYPE="default">
33
+ <div ORDER="1">
34
+ <fptr CONTENTIDS="#{child3.id}" />
35
+ </div>
36
+ <div ORDER="2">
37
+ <fptr CONTENTIDS="#{child2.id}" />
38
+ </div>
39
+ <div ORDER="3">
40
+ <fptr CONTENTIDS="#{child1.id}" />
41
+ </div>
42
+ </structMap>
43
+ </mets>
44
+ EOS
45
+ subject.structMetadata.content = struct_map
46
+ subject.save!
47
+ end
48
+ it "should return the first child based on structural metadata order" do
49
+ expect(subject.first_child).to eq(child3)
50
+ end
51
+ end
52
+ describe "when the object does not have structural metadata" do
53
+
54
+ it "should return the first child as sorted by local ID" do
55
+ expect(subject.first_child).to eq(child2)
56
+ end
26
57
  end
27
58
  end
28
59
  end
@@ -4,7 +4,7 @@ module Ddr
4
4
  module Models
5
5
  RSpec.describe HasStructMetadata, type: :model, structural_metadata: true do
6
6
 
7
- let(:item) { Item.new(pid: 'test:2') }
7
+ let(:item) { Item.new(id: 'test_2') }
8
8
 
9
9
  describe "#structure" do
10
10
  context "no existing structural metadata" do
@@ -21,9 +21,9 @@ module Ddr
21
21
  end
22
22
 
23
23
  describe "#build_default_structure" do
24
- let(:components) { [ Component.new(pid: 'test:5', identifier: [ 'abc002' ]),
25
- Component.new(pid: 'test:6', identifier: [ 'abc001' ]),
26
- Component.new(pid: 'test:7', identifier: [ 'abc003' ])
24
+ let(:components) { [ Component.new(id: 'test_5', identifier: [ 'abc002' ]),
25
+ Component.new(id: 'test_6', identifier: [ 'abc001' ]),
26
+ Component.new(id: 'test_7', identifier: [ 'abc003' ])
27
27
  ] }
28
28
  let(:expected) { FactoryGirl.build(:simple_structure) }
29
29
  before { allow(item).to receive(:find_children) { simple_structure_query_response } }
@@ -18,6 +18,7 @@ module Ddr::Models
18
18
  obj.permanent_url = "http://id.library.duke.edu/ark:/99999/fk4zzz"
19
19
  obj.display_format = "Image"
20
20
  obj.roles.grant role1, role2, role3, role4
21
+ obj.fcrepo3_pid = "duke:1"
21
22
  end
22
23
 
23
24
  its([Indexing::LICENSE]) { is_expected.to eq("cc-by-nc-nd-40") }
@@ -29,6 +30,6 @@ module Ddr::Models
29
30
  its([Indexing::ACCESS_ROLE]) { is_expected.to eq(obj.roles.to_json) }
30
31
  its([Indexing::POLICY_ROLE]) { is_expected.to contain_exactly(role2.agent, role3.agent, role4.agent) }
31
32
  its([Indexing::RESOURCE_ROLE]) { is_expected.to contain_exactly(role1.agent) }
32
-
33
+ its([Indexing::FCREPO3_PID]) { is_expected.to eq("duke:1") }
33
34
  end
34
35
  end
@@ -13,35 +13,35 @@ module Ddr
13
13
  expect(struct_div.divs.size).to eq(2)
14
14
  expect(struct_div.divs.first.label).to eq("Front")
15
15
  expect(struct_div.divs.first.divs).to be_empty
16
- expect(struct_div.divs.first.fptrs).to eq([ "test:5" ])
16
+ expect(struct_div.divs.first.fptrs).to eq([ "test_5" ])
17
17
  expect(struct_div.divs.last.label).to eq("Back")
18
18
  expect(struct_div.divs.last.divs.size).to eq(2)
19
19
  expect(struct_div.divs.last.fptrs).to be_empty
20
20
  expect(struct_div.divs.last.divs.first.label).to eq("Top")
21
21
  expect(struct_div.divs.last.divs.first.divs).to be_empty
22
- expect(struct_div.divs.last.divs.first.fptrs).to eq([ "test:7" ])
22
+ expect(struct_div.divs.last.divs.first.fptrs).to eq([ "test_7" ])
23
23
  expect(struct_div.divs.last.divs.last.label).to eq("Bottom")
24
24
  expect(struct_div.divs.last.divs.last.divs).to be_empty
25
- expect(struct_div.divs.last.divs.last.fptrs).to eq([ "test:6" ])
25
+ expect(struct_div.divs.last.divs.last.fptrs).to eq([ "test_6" ])
26
26
  end
27
27
  end
28
28
 
29
29
  describe "#pids" do
30
30
  context "top level" do
31
31
  it "should return all pids in the structMap" do
32
- expect(struct_div.pids).to match_array([ 'test:5', 'test:6', 'test:7' ])
32
+ expect(struct_div.pids).to match_array([ 'test_5', 'test_6', 'test_7' ])
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
37
  describe "#docs" do
38
- let(:solr_response) { [ { 'id'=>'test:5' }, { 'id'=>'test:6' }, { 'id'=>'test:7'} ] }
38
+ let(:solr_response) { [ { 'id'=>'test_5' }, { 'id'=>'test_6' }, { 'id'=>'test_7'} ] }
39
39
  before do
40
40
  allow(ActiveFedora::SolrService).to receive(:query) { solr_response }
41
41
  end
42
42
  it "should return a hash of Solr documents" do
43
43
  results = struct_div.docs
44
- expect(results.keys).to match_array([ 'test:5', 'test:6', 'test:7' ])
44
+ expect(results.keys).to match_array([ 'test_5', 'test_6', 'test_7' ])
45
45
  results.keys.each do |key|
46
46
  expect(results[key]).to be_a(SolrDocument)
47
47
  expect(results[key].id).to eq(key)
@@ -50,18 +50,18 @@ module Ddr
50
50
  end
51
51
 
52
52
  describe "#objects" do
53
- let(:repo_objects) { [ Component.new(pid: 'test:5'), Component.new(pid: 'test:6'), Component.new(pid: 'test:7') ] }
53
+ let(:repo_objects) { [ Component.new(id: 'test_5'), Component.new(id: 'test_6'), Component.new(id: 'test_7') ] }
54
54
  before do
55
- allow(ActiveFedora::Base).to receive(:find).with('test:5') { repo_objects[0] }
56
- allow(ActiveFedora::Base).to receive(:find).with('test:6') { repo_objects[1] }
57
- allow(ActiveFedora::Base).to receive(:find).with('test:7') { repo_objects[2] }
55
+ allow(ActiveFedora::Base).to receive(:find).with('test_5') { repo_objects[0] }
56
+ allow(ActiveFedora::Base).to receive(:find).with('test_6') { repo_objects[1] }
57
+ allow(ActiveFedora::Base).to receive(:find).with('test_7') { repo_objects[2] }
58
58
  end
59
59
  it "should return a hash of Active Fedora objects" do
60
60
  results = struct_div.objects
61
- expect(results.keys).to match_array([ 'test:5', 'test:6', 'test:7' ])
62
- expect(results['test:5']).to eq(repo_objects[0])
63
- expect(results['test:6']).to eq(repo_objects[1])
64
- expect(results['test:7']).to eq(repo_objects[2])
61
+ expect(results.keys).to match_array([ 'test_5', 'test_6', 'test_7' ])
62
+ expect(results['test_5']).to eq(repo_objects[0])
63
+ expect(results['test_6']).to eq(repo_objects[1])
64
+ expect(results['test_7']).to eq(repo_objects[2])
65
65
  end
66
66
  end
67
67
 
@@ -5,9 +5,8 @@ module Ddr
5
5
  module Models
6
6
  RSpec.describe Structure, type: :model, structural_metadata: true do
7
7
 
8
- let(:structure) { FactoryGirl.build(:multiple_struct_maps_structure) }
9
-
10
8
  describe "#struct_maps" do
9
+ let(:structure) { FactoryGirl.build(:multiple_struct_maps_structure) }
11
10
  let(:struct_maps) { structure.struct_maps }
12
11
  it "should include struct divs for each struct map" do
13
12
  expect(struct_maps.keys).to match_array([ 'default', 'reverse' ])
@@ -16,6 +15,102 @@ module Ddr
16
15
  end
17
16
  end
18
17
 
18
+ describe "#default_struct_map" do
19
+ context "struct map with type 'default'" do
20
+ let(:struct_map_xml) do
21
+ <<-eos
22
+ <mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
23
+ <structMap TYPE="reverse">
24
+ <div ORDER="1" LABEL="Back">
25
+ <div ORDER="1" LABEL="Bottom">
26
+ <fptr CONTENTIDS="test_6" />
27
+ </div>
28
+ <div ORDER="2" LABEL="Top">
29
+ <fptr CONTENTIDS="test_7" />
30
+ </div>
31
+ </div>
32
+ <div ORDER="2" LABEL="Front">
33
+ <fptr CONTENTIDS="test_5" />
34
+ </div>
35
+ </structMap>
36
+ <structMap TYPE="default">
37
+ <div ORDER="1" LABEL="Front">
38
+ <fptr CONTENTIDS="test_5" />
39
+ </div>
40
+ <div ORDER="2" LABEL="Back">
41
+ <div ORDER="1" LABEL="Top">
42
+ <fptr CONTENTIDS="test_7" />
43
+ </div>
44
+ <div ORDER="2" LABEL="Bottom">
45
+ <fptr CONTENTIDS="test_6" />
46
+ </div>
47
+ </div>
48
+ </structMap>
49
+ </mets>
50
+ eos
51
+ end
52
+ let(:struct_map_doc) do
53
+ Nokogiri::XML(struct_map_xml) do |config|
54
+ config.noblanks
55
+ end
56
+ end
57
+ let(:structure) { Structure.new(struct_map_doc) }
58
+ it "should return the struct map with type :default" do
59
+ expect(structure.default_struct_map).to eq(structure.struct_maps['default'])
60
+ end
61
+ end
62
+ context "no struct map with type 'default'" do
63
+ let(:struct_map_xml) do
64
+ <<-eos
65
+ <mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
66
+ <structMap TYPE="reverse">
67
+ <div ORDER="1" LABEL="Back">
68
+ <div ORDER="1" LABEL="Bottom">
69
+ <fptr CONTENTIDS="test_6" />
70
+ </div>
71
+ <div ORDER="2" LABEL="Top">
72
+ <fptr CONTENTIDS="test_7" />
73
+ </div>
74
+ </div>
75
+ <div ORDER="2" LABEL="Front">
76
+ <fptr CONTENTIDS="test_5" />
77
+ </div>
78
+ </structMap>
79
+ <structMap TYPE="other">
80
+ <div ORDER="1" LABEL="Front">
81
+ <fptr CONTENTIDS="test_5" />
82
+ </div>
83
+ <div ORDER="2" LABEL="Back">
84
+ <div ORDER="1" LABEL="Top">
85
+ <fptr CONTENTIDS="test_7" />
86
+ </div>
87
+ <div ORDER="2" LABEL="Bottom">
88
+ <fptr CONTENTIDS="test_6" />
89
+ </div>
90
+ </div>
91
+ </structMap>
92
+ </mets>
93
+ eos
94
+ end
95
+ let(:struct_map_doc) do
96
+ Nokogiri::XML(struct_map_xml) do |config|
97
+ config.noblanks
98
+ end
99
+ end
100
+ let(:structure) { Structure.new(struct_map_doc) }
101
+ it "should return the first struct map" do
102
+ expect(structure.default_struct_map).to eq(structure.struct_maps['reverse'])
103
+ end
104
+ end
105
+ end
106
+
107
+ describe "#default_struct_map_ids" do
108
+ let(:structure) { FactoryGirl.build(:simple_structure) }
109
+ it "should return the ids in order" do
110
+ expect(structure.default_struct_map_ids).to match_array([ 'test_6', 'test_5', 'test_7' ])
111
+ end
112
+ end
113
+
19
114
  end
20
115
  end
21
- end
116
+ end
@@ -22,101 +22,4 @@ RSpec.shared_examples "a DDR model" do
22
22
  end
23
23
  end
24
24
 
25
- describe "move first desc metadata identifier to local id" do
26
- let(:local_id) { 'locl001' }
27
- let(:identifiers) { [ 'id001', 'id002' ] }
28
- context "no desc metadata identifiers" do
29
- context "local id present" do
30
- before { subject.local_id = local_id }
31
- it "should not change the local id" do
32
- result = subject.move_first_identifier_to_local_id
33
- expect(result).to be false
34
- expect(subject.local_id).to eq(local_id)
35
- end
36
- end
37
- end
38
- context "one desc metadata identifier" do
39
- before { subject.descMetadata.identifier = Array(identifiers.first) }
40
- context "local id not present" do
41
- it "should set the local id and remove the identifier" do
42
- result = subject.move_first_identifier_to_local_id
43
- expect(result).to be true
44
- expect(subject.local_id).to eq(identifiers.first)
45
- expect(subject.descMetadata.identifier).to be_empty
46
- end
47
- end
48
- context "local id present" do
49
- before { subject.local_id = local_id }
50
- context "replace option is true" do
51
- it "should set the local id and remove the identifier" do
52
- result = subject.move_first_identifier_to_local_id
53
- expect(result).to be true
54
- expect(subject.local_id).to eq(identifiers.first)
55
- expect(subject.descMetadata.identifier).to be_empty
56
- end
57
- end
58
- context "replace option is false" do
59
- context "local id matches first identifier" do
60
- before { subject.descMetadata.identifier = Array(local_id) }
61
- it "should remove the identifier" do
62
- result = subject.move_first_identifier_to_local_id(replace: false)
63
- expect(result).to be true
64
- expect(subject.local_id).to eq(local_id)
65
- expect(subject.descMetadata.identifier).to be_empty
66
- end
67
- end
68
- context "local id does not match first identifier" do
69
- it "should not change the local id and not remove the identifier" do
70
- result = subject.move_first_identifier_to_local_id(replace: false)
71
- expect(result).to be false
72
- expect(subject.local_id).to eq(local_id)
73
- expect(subject.descMetadata.identifier).to eq(Array(identifiers.first))
74
- end
75
- end
76
- end
77
- end
78
- end
79
- context "more than one desc metadata identifer" do
80
- before { subject.descMetadata.identifier = identifiers }
81
- context "local id not present" do
82
- it "should set the local id and remove the identifier" do
83
- result = subject.move_first_identifier_to_local_id
84
- expect(result).to be true
85
- expect(subject.local_id).to eq(identifiers.first)
86
- expect(subject.descMetadata.identifier).to eq(Array(identifiers.last))
87
- end
88
- end
89
- context "local id present" do
90
- before { subject.local_id = local_id }
91
- context "replace option is true" do
92
- it "should set the local id and remove the identifier" do
93
- result = subject.move_first_identifier_to_local_id
94
- expect(result).to be true
95
- expect(subject.local_id).to eq(identifiers.first)
96
- expect(subject.descMetadata.identifier).to eq(Array(identifiers.last))
97
- end
98
- end
99
- context "replace option is false" do
100
- context "local id matches first identifier" do
101
- before { subject.descMetadata.identifier = [ local_id, identifiers.last ] }
102
- it "should remove the identifier" do
103
- result = subject.move_first_identifier_to_local_id(replace: false)
104
- expect(result).to be true
105
- expect(subject.local_id).to eq(local_id)
106
- expect(subject.descMetadata.identifier).to eq(Array(identifiers.last))
107
- end
108
- end
109
- context "local id does not match first identifier" do
110
- it "should not change the local id and not remove the identifier" do
111
- result = subject.move_first_identifier_to_local_id(replace: false)
112
- expect(result).to be false
113
- expect(subject.local_id).to eq(local_id)
114
- expect(subject.descMetadata.identifier).to eq(identifiers)
115
- end
116
- end
117
- end
118
- end
119
- end
120
- end
121
-
122
25
  end
@@ -23,13 +23,13 @@ def simple_structure
23
23
  <mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
24
24
  <structMap TYPE="default">
25
25
  <div ORDER="1">
26
- <fptr CONTENTIDS="info:fedora/test:6" />
26
+ <fptr CONTENTIDS="test_6" />
27
27
  </div>
28
28
  <div ORDER="2">
29
- <fptr CONTENTIDS="info:fedora/test:5" />
29
+ <fptr CONTENTIDS="test_5" />
30
30
  </div>
31
31
  <div ORDER="3">
32
- <fptr CONTENTIDS="info:fedora/test:7" />
32
+ <fptr CONTENTIDS="test_7" />
33
33
  </div>
34
34
  </structMap>
35
35
  </mets>
@@ -41,14 +41,14 @@ def nested_structure
41
41
  <mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
42
42
  <structMap TYPE="default">
43
43
  <div ORDER="1" LABEL="Front">
44
- <fptr CONTENTIDS="info:fedora/test:5" />
44
+ <fptr CONTENTIDS="test_5" />
45
45
  </div>
46
46
  <div ORDER="2" LABEL="Back">
47
47
  <div ORDER="1" LABEL="Top">
48
- <fptr CONTENTIDS="info:fedora/test:7" />
48
+ <fptr CONTENTIDS="test_7" />
49
49
  </div>
50
50
  <div ORDER="2" LABEL="Bottom">
51
- <fptr CONTENTIDS="info:fedora/test:6" />
51
+ <fptr CONTENTIDS="test_6" />
52
52
  </div>
53
53
  </div>
54
54
  </structMap>
@@ -61,28 +61,28 @@ def multiple_struct_maps_structure
61
61
  <mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
62
62
  <structMap TYPE="default">
63
63
  <div ORDER="1" LABEL="Front">
64
- <fptr CONTENTIDS="info:fedora/test:5" />
64
+ <fptr CONTENTIDS="test_5" />
65
65
  </div>
66
66
  <div ORDER="2" LABEL="Back">
67
67
  <div ORDER="1" LABEL="Top">
68
- <fptr CONTENTIDS="info:fedora/test:7" />
68
+ <fptr CONTENTIDS="test_7" />
69
69
  </div>
70
70
  <div ORDER="2" LABEL="Bottom">
71
- <fptr CONTENTIDS="info:fedora/test:6" />
71
+ <fptr CONTENTIDS="test_6" />
72
72
  </div>
73
73
  </div>
74
74
  </structMap>
75
75
  <structMap TYPE="reverse">
76
76
  <div ORDER="1" LABEL="Back">
77
77
  <div ORDER="1" LABEL="Bottom">
78
- <fptr CONTENTIDS="info:fedora/test:6" />
78
+ <fptr CONTENTIDS="test_6" />
79
79
  </div>
80
80
  <div ORDER="2" LABEL="Top">
81
- <fptr CONTENTIDS="info:fedora/test:7" />
81
+ <fptr CONTENTIDS="test_7" />
82
82
  </div>
83
83
  </div>
84
84
  <div ORDER="2" LABEL="Front">
85
- <fptr CONTENTIDS="info:fedora/test:5" />
85
+ <fptr CONTENTIDS="test_5" />
86
86
  </div>
87
87
  </structMap>
88
88
  </mets>
@@ -90,16 +90,16 @@ def multiple_struct_maps_structure
90
90
  end
91
91
 
92
92
  def simple_structure_query_response
93
- [{"system_create_dtsi"=>"2015-06-17T21:04:24Z", "system_modified_dtsi"=>"2015-06-17T21:04:56Z", "object_state_ssi"=>"A", "active_fedora_model_ssi"=>"Component", "id"=>"test:6", "object_profile_ssm"=>["{\"datastreams\":{\"RELS-EXT\":{\"dsLabel\":\"Fedora Object-to-Object Relationship Metadata\",\"dsVersionID\":\"RELS-EXT.1\",\"dsCreateDate\":\"2015-06-17T21:04:56Z\",\"dsState\":\"A\",\"dsMIME\":\"application/rdf+xml\",\"dsFormatURI\":null,\"dsControlGroup\":\"X\",\"dsSize\":408,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:6+RELS-EXT+RELS-EXT.1\",\"dsLocationType\":null,\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"bf84faa89d6b25924bc06357f7c33347a602e2ec8df9c1020ec98015fe571760\"},\"descMetadata\":{\"dsLabel\":\"Descriptive Metadata for this object\",\"dsVersionID\":\"descMetadata.1\",\"dsCreateDate\":\"2015-06-17T21:04:56Z\",\"dsState\":\"A\",\"dsMIME\":\"application/n-triples\",\"dsFormatURI\":null,\"dsControlGroup\":\"M\",\"dsSize\":70,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:6+descMetadata+descMetadata.1\",\"dsLocationType\":\"INTERNAL_ID\",\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"4d227bc972634ba2126eefff207fb3b35f6ff802a210ad7945d2ec60360076dd\"},\"rightsMetadata\":{},\"properties\":{},\"thumbnail\":{},\"adminMetadata\":{},\"content\":{},\"extractedText\":{},\"multiresImage\":{},\"structMetadata\":{}},\"objLabel\":null,\"objOwnerId\":\"fedoraAdmin\",\"objModels\":[\"info:fedora/fedora-system:FedoraObject-3.0\"],\"objCreateDate\":\"2015-06-17T21:04:24Z\",\"objLastModDate\":\"2015-06-17T21:04:24Z\",\"objDissIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A6/methods/fedora-system%3A3/viewMethodIndex\",\"objItemIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A6/methods/fedora-system%3A3/viewItemIndex\",\"objState\":\"A\"}"], "identifier_tesim"=>["abc001"], "is_part_of_ssim"=>["info:fedora/test:2"], "has_model_ssim"=>["info:fedora/afmodel:Component"], "title_ssi"=>"abc001", "internal_uri_ssi"=>"info:fedora/test:6", "identifier_ssi"=>"abc001", "access_role_ssi"=>"[]", "_version_"=>1504261016868880384, "timestamp"=>"2015-06-17T21:04:56.958Z"}, {"system_create_dtsi"=>"2015-06-17T21:03:58Z", "system_modified_dtsi"=>"2015-06-17T21:04:54Z", "object_state_ssi"=>"A", "active_fedora_model_ssi"=>"Component", "id"=>"test:5", "object_profile_ssm"=>["{\"datastreams\":{\"RELS-EXT\":{\"dsLabel\":\"Fedora Object-to-Object Relationship Metadata\",\"dsVersionID\":\"RELS-EXT.1\",\"dsCreateDate\":\"2015-06-17T21:04:54Z\",\"dsState\":\"A\",\"dsMIME\":\"application/rdf+xml\",\"dsFormatURI\":null,\"dsControlGroup\":\"X\",\"dsSize\":408,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:5+RELS-EXT+RELS-EXT.1\",\"dsLocationType\":null,\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"6a7f1cbe6e435991ae3bba134e52e7a275af8a232b209ac725fa54fdd81bb973\"},\"descMetadata\":{\"dsLabel\":\"Descriptive Metadata for this object\",\"dsVersionID\":\"descMetadata.1\",\"dsCreateDate\":\"2015-06-17T21:04:54Z\",\"dsState\":\"A\",\"dsMIME\":\"application/n-triples\",\"dsFormatURI\":null,\"dsControlGroup\":\"M\",\"dsSize\":70,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:5+descMetadata+descMetadata.1\",\"dsLocationType\":\"INTERNAL_ID\",\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"8b106726ca2d39d9a2e187fc9da2e58b25bd3553031012515ae31cf4fbe520e9\"},\"rightsMetadata\":{},\"properties\":{},\"thumbnail\":{},\"adminMetadata\":{},\"content\":{},\"extractedText\":{},\"multiresImage\":{},\"structMetadata\":{}},\"objLabel\":null,\"objOwnerId\":\"fedoraAdmin\",\"objModels\":[\"info:fedora/fedora-system:FedoraObject-3.0\"],\"objCreateDate\":\"2015-06-17T21:03:58Z\",\"objLastModDate\":\"2015-06-17T21:03:58Z\",\"objDissIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A5/methods/fedora-system%3A3/viewMethodIndex\",\"objItemIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A5/methods/fedora-system%3A3/viewItemIndex\",\"objState\":\"A\"}"], "identifier_tesim"=>["abc002"], "is_part_of_ssim"=>["info:fedora/test:2"], "has_model_ssim"=>["info:fedora/afmodel:Component"], "title_ssi"=>"abc002", "internal_uri_ssi"=>"info:fedora/test:5", "identifier_ssi"=>"abc002", "access_role_ssi"=>"[]", "_version_"=>1504261014501195776, "timestamp"=>"2015-06-17T21:04:54.701Z"}, {"system_create_dtsi"=>"2015-06-17T21:04:46Z", "system_modified_dtsi"=>"2015-06-17T21:04:59Z", "object_state_ssi"=>"A", "active_fedora_model_ssi"=>"Component", "id"=>"test:7", "object_profile_ssm"=>["{\"datastreams\":{\"RELS-EXT\":{\"dsLabel\":\"Fedora Object-to-Object Relationship Metadata\",\"dsVersionID\":\"RELS-EXT.1\",\"dsCreateDate\":\"2015-06-17T21:04:59Z\",\"dsState\":\"A\",\"dsMIME\":\"application/rdf+xml\",\"dsFormatURI\":null,\"dsControlGroup\":\"X\",\"dsSize\":408,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:7+RELS-EXT+RELS-EXT.1\",\"dsLocationType\":null,\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"cb385ff9a55b5fe24e8c2a8159fc928e3ee582ef312955132d34282676102a6a\"},\"descMetadata\":{\"dsLabel\":\"Descriptive Metadata for this object\",\"dsVersionID\":\"descMetadata.1\",\"dsCreateDate\":\"2015-06-17T21:04:59Z\",\"dsState\":\"A\",\"dsMIME\":\"application/n-triples\",\"dsFormatURI\":null,\"dsControlGroup\":\"M\",\"dsSize\":70,\"dsVersionable\":true,\"dsInfoType\":null,\"dsLocation\":\"test:7+descMetadata+descMetadata.1\",\"dsLocationType\":\"INTERNAL_ID\",\"dsChecksumType\":\"SHA-256\",\"dsChecksum\":\"523ee1e5d55d188bd17b2789e4c9109c8f9d0170b63af1219de8a74d4f32966a\"},\"rightsMetadata\":{},\"properties\":{},\"thumbnail\":{},\"adminMetadata\":{},\"content\":{},\"extractedText\":{},\"multiresImage\":{},\"structMetadata\":{}},\"objLabel\":null,\"objOwnerId\":\"fedoraAdmin\",\"objModels\":[\"info:fedora/fedora-system:FedoraObject-3.0\"],\"objCreateDate\":\"2015-06-17T21:04:46Z\",\"objLastModDate\":\"2015-06-17T21:04:46Z\",\"objDissIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A7/methods/fedora-system%3A3/viewMethodIndex\",\"objItemIndexViewURL\":\"http://localhost:8983/fedora/objects/test%3A7/methods/fedora-system%3A3/viewItemIndex\",\"objState\":\"A\"}"], "identifier_tesim"=>["abc003"], "is_part_of_ssim"=>["info:fedora/test:2"], "has_model_ssim"=>["info:fedora/afmodel:Component"], "title_ssi"=>"abc003", "internal_uri_ssi"=>"info:fedora/test:7", "identifier_ssi"=>"abc003", "access_role_ssi"=>"[]", "_version_"=>1504261019487174656, "timestamp"=>"2015-06-17T21:04:59.455Z"}]
93
+ [ { "id"=>"test_6", "local_id_ssi"=>"abc001" }, { "id"=>"test_5", "local_id_ssi"=>"abc002" }, { "id"=>"test_7", "local_id_ssi"=>"abc003" } ]
94
94
  end
95
95
 
96
96
  def simple_structure_to_json
97
97
  j = <<-eos
98
98
  {\"default\":
99
99
  {\"type\":\"default\",
100
- \"divs\":[{\"order\":\"1\",\"fptrs\":[\"test:6\"],\"divs\":[]},
101
- {\"order\":\"2\",\"fptrs\":[\"test:5\"],\"divs\":[]},
102
- {\"order\":\"3\",\"fptrs\":[\"test:7\"],\"divs\":[]}
100
+ \"divs\":[{\"order\":\"1\",\"fptrs\":[\"test_6\"],\"divs\":[]},
101
+ {\"order\":\"2\",\"fptrs\":[\"test_5\"],\"divs\":[]},
102
+ {\"order\":\"3\",\"fptrs\":[\"test_7\"],\"divs\":[]}
103
103
  ]
104
104
  }
105
105
  }
@@ -111,10 +111,10 @@ def multiple_struct_maps_structure_to_json
111
111
  j = <<-eos
112
112
  {\"default\":
113
113
  {\"type\":\"default\",
114
- \"divs\":[{\"label\":\"Front\",\"order\":\"1\",\"fptrs\":[\"test:5\"],\"divs\":[]},
114
+ \"divs\":[{\"label\":\"Front\",\"order\":\"1\",\"fptrs\":[\"test_5\"],\"divs\":[]},
115
115
  {\"label\":\"Back\",\"order\":\"2\",\"fptrs\":[],
116
- \"divs\":[{\"label\":\"Top\",\"order\":\"1\",\"fptrs\":[\"test:7\"],\"divs\":[]},
117
- {\"label\":\"Bottom\",\"order\":\"2\",\"fptrs\":[\"test:6\"],\"divs\":[]}
116
+ \"divs\":[{\"label\":\"Top\",\"order\":\"1\",\"fptrs\":[\"test_7\"],\"divs\":[]},
117
+ {\"label\":\"Bottom\",\"order\":\"2\",\"fptrs\":[\"test_6\"],\"divs\":[]}
118
118
  ]
119
119
  }
120
120
  ]
@@ -122,11 +122,11 @@ def multiple_struct_maps_structure_to_json
122
122
  \"reverse\":
123
123
  {\"type\":\"reverse\",
124
124
  \"divs\":[{\"label\":\"Back\",\"order\":\"1\",\"fptrs\":[],
125
- \"divs\":[{\"label\":\"Bottom\",\"order\":\"1\",\"fptrs\":[\"test:6\"],\"divs\":[]},
126
- {\"label\":\"Top\",\"order\":\"2\",\"fptrs\":[\"test:7\"],\"divs\":[]}
125
+ \"divs\":[{\"label\":\"Bottom\",\"order\":\"1\",\"fptrs\":[\"test_6\"],\"divs\":[]},
126
+ {\"label\":\"Top\",\"order\":\"2\",\"fptrs\":[\"test_7\"],\"divs\":[]}
127
127
  ]
128
128
  },
129
- {\"label\":\"Front\",\"order\":\"2\",\"fptrs\":[\"test:5\"],\"divs\":[]}
129
+ {\"label\":\"Front\",\"order\":\"2\",\"fptrs\":[\"test_5\"],\"divs\":[]}
130
130
  ]
131
131
  }
132
132
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.1
4
+ version: 3.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-11-13 00:00:00.000000000 Z
12
+ date: 2015-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails