spec/support/structural_metadata_helper.rb in ddr-models-2.11.0 vs spec/support/structural_metadata_helper.rb in ddr-models-3.0.0.alpha.1
- old
+ new
@@ -1,306 +1,135 @@
require 'spec_helper'
def simple_structure_document
- Nokogiri::XML(simple_structure_xml) do |config|
+ Nokogiri::XML(simple_structure) do |config|
config.noblanks
end
end
def nested_structure_document
- Nokogiri::XML(nested_structure_xml) do |config|
+ Nokogiri::XML(nested_structure) do |config|
config.noblanks
end
end
-def nested_structure_mptr_document
- Nokogiri::XML(nested_structure_mptr_xml) do |config|
- config.noblanks
- end
-end
-
def multiple_struct_maps_structure_document
Nokogiri::XML(multiple_struct_maps_structure) do |config|
config.noblanks
end
end
-def simple_structure_xml
+def simple_structure
<<-eos
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
- <metsHdr>
- <agent ROLE="CREATOR">
- <name>#{Ddr::Models::Structures::Agent::NAME_REPOSITORY_DEFAULT}</name>
- </agent>
- </metsHdr>
- <fileSec>
- <fileGrp>
- <file ID="abc" USE="foo">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4ab3" />
- </file>
- <file ID="def" USE="bar">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4cd9" />
- </file>
- <file ID="ghi" USE="baz">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4ef1" />
- </file>
- </fileGrp>
- </fileSec>
<structMap TYPE="default">
<div ORDER="1">
- <fptr FILEID="abc" />
+ <fptr CONTENTIDS="info:fedora/test:6" />
</div>
<div ORDER="2">
- <fptr FILEID="def" />
+ <fptr CONTENTIDS="info:fedora/test:5" />
</div>
<div ORDER="3">
- <fptr FILEID="ghi" />
+ <fptr CONTENTIDS="info:fedora/test:7" />
</div>
</structMap>
</mets>
eos
end
-def nested_structure_xml
+def nested_structure
<<-eos
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
- <metsHdr>
- <agent ROLE="CREATOR">
- <name>Sam Spade</name>
- </agent>
- </metsHdr>
- <fileSec>
- <fileGrp>
- <file ID="abc" USE="foo">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4ab3" />
- </file>
- <file ID="def" USE="bar">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4cd9" />
- </file>
- <file ID="ghi" USE="baz">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4ef1" />
- </file>
- </fileGrp>
- </fileSec>
<structMap TYPE="default">
<div ORDER="1" LABEL="Front">
- <fptr FILEID="abc" />
+ <fptr CONTENTIDS="info:fedora/test:5" />
</div>
<div ORDER="2" LABEL="Back">
<div ORDER="1" LABEL="Top">
- <fptr FILEID="def" />
- </div>
+ <fptr CONTENTIDS="info:fedora/test:7" />
+ </div>
<div ORDER="2" LABEL="Bottom">
- <fptr FILEID="ghi" />
- </div>
+ <fptr CONTENTIDS="info:fedora/test:6" />
+ </div>
</div>
</structMap>
</mets>
eos
end
-def nested_structure_mptr_xml
- <<-eos
- <mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
- <metsHdr>
- <agent ROLE="CREATOR">
- <name>Sam Spade</name>
- </agent>
- </metsHdr>
- <structMap TYPE="default">
- <div ORDER="1" LABEL="Front">
- <mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4ab3" />
- </div>
- <div ORDER="2" LABEL="Back">
- <div ORDER="1" LABEL="Top">
- <mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4cd9" />
- </div>
- <div ORDER="2" LABEL="Bottom">
- <mptr LOCTYPE="ARK" xlink:href="ark:/99999/fk4ef1" />
- </div>
- </div>
- </structMap>
- </mets>
- eos
-end
-
def multiple_struct_maps_structure
<<-eos
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink">
- <fileSec>
- <fileGrp>
- <file ID="abc" USE="foo">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4ab3" />
- </file>
- <file ID="def" USE="bar">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4cd9" />
- </file>
- <file ID="ghi" USE="baz">
- <FLocat LOCTYPE="ARK" xlink:href="ark:/99999/fk4ef1" />
- </file>
- </fileGrp>
- </fileSec>
<structMap TYPE="default">
<div ORDER="1" LABEL="Front">
- <fptr FILEID="abc" />
+ <fptr CONTENTIDS="info:fedora/test:5" />
</div>
<div ORDER="2" LABEL="Back">
<div ORDER="1" LABEL="Top">
- <fptr FILEID="def" />
- </div>
+ <fptr CONTENTIDS="info:fedora/test:7" />
+ </div>
<div ORDER="2" LABEL="Bottom">
- <fptr FILEID="ghi" />
- </div>
+ <fptr CONTENTIDS="info:fedora/test:6" />
+ </div>
</div>
</structMap>
<structMap TYPE="reverse">
<div ORDER="1" LABEL="Back">
<div ORDER="1" LABEL="Bottom">
- <fptr FILEID="ghi" />
+ <fptr CONTENTIDS="info:fedora/test:6" />
</div>
<div ORDER="2" LABEL="Top">
- <fptr FILEID="def" />
- </div>
+ <fptr CONTENTIDS="info:fedora/test:7" />
+ </div>
</div>
<div ORDER="2" LABEL="Front">
- <fptr FILEID="abc" />
+ <fptr CONTENTIDS="info:fedora/test:5" />
</div>
</structMap>
</mets>
eos
end
-def simple_structure_dereferenced_hash
- yaml = <<-eos
- default:
- :type: 'default'
- :contents:
- - :order: '1'
- :contents:
- - :repo_id: 'test:7'
- :use: 'foo'
- - :order: '2'
- :contents:
- - :repo_id: 'test:8'
- :use: 'bar'
- - :order: '3'
- :contents:
- - :repo_id: 'test:9'
- :use: 'baz'
- eos
- YAML.load(yaml)
+def simple_structure_query_response
+ [{"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"}]
end
-def nested_structure_dereferenced_hash
- yaml = <<-eos
- default:
- :type: 'default'
- :contents:
- - :label: 'Front'
- :order: '1'
- :contents:
- - :repo_id: 'test:7'
- :use: 'foo'
- - :label: 'Back'
- :order: '2'
- :contents:
- - :label: 'Top'
- :order: '1'
- :contents:
- - :repo_id: 'test:8'
- :use: 'bar'
- - :label: 'Bottom'
- :order: '2'
- :contents:
- - :repo_id: 'test:9'
- :use: 'baz'
+def simple_structure_to_json
+ j = <<-eos
+ {\"default\":
+ {\"type\":\"default\",
+ \"divs\":[{\"order\":\"1\",\"fptrs\":[\"test:6\"],\"divs\":[]},
+ {\"order\":\"2\",\"fptrs\":[\"test:5\"],\"divs\":[]},
+ {\"order\":\"3\",\"fptrs\":[\"test:7\"],\"divs\":[]}
+ ]
+ }
+ }
eos
- YAML.load(yaml)
+ j.gsub(/\s+/, "")
end
-def nested_structure_mptr_dereferenced_hash
- yaml = <<-eos
- default:
- :type: 'default'
- :contents:
- - :label: 'Front'
- :order: '1'
- :contents:
- - :repo_id: 'test:7'
- - :label: 'Back'
- :order: '2'
- :contents:
- - :label: 'Top'
- :order: '1'
- :contents:
- - :repo_id: 'test:8'
- - :label: 'Bottom'
- :order: '2'
- :contents:
- - :repo_id: 'test:9'
- eos
- YAML.load(yaml)
-end
-
-def multiple_struct_maps_structure_dereferenced_hash
- yaml = <<-eos
- default:
- :type: 'default'
- :contents:
- - :label: 'Front'
- :order: '1'
- :contents:
- - :repo_id: 'test:7'
- :use: 'foo'
- - :label: 'Back'
- :order: '2'
- :contents:
- - :label: 'Top'
- :order: '1'
- :contents:
- - :repo_id: 'test:8'
- :use: 'bar'
- - :label: 'Bottom'
- :order: '2'
- :contents:
- - :repo_id: 'test:9'
- :use: 'baz'
- reverse:
- :type: 'reverse'
- :contents:
- - :label: 'Back'
- :order: '1'
- :contents:
- - :label: 'Bottom'
- :order: '1'
- :contents:
- - :repo_id: 'test:9'
- :use: 'baz'
- - :label: 'Top'
- :order: '2'
- :contents:
- - :repo_id: 'test:8'
- :use: 'bar'
- - :label: 'Front'
- :order: '2'
- :contents:
- - :repo_id: 'test:7'
- :use: 'foo'
- eos
- YAML.load(yaml)
-end
-
-def simple_structure_to_json
- simple_structure_dereferenced_hash.to_json
-end
-
-def nested_structure_to_json
- nested_structure_dereferenced_hash.to_json
-end
-
-def nested_structure_mptr_to_json
- nested_structure_mptr_dereferenced_hash.to_json
-end
-
def multiple_struct_maps_structure_to_json
- multiple_struct_maps_structure_dereferenced_hash.to_json
-end
+ j = <<-eos
+ {\"default\":
+ {\"type\":\"default\",
+ \"divs\":[{\"label\":\"Front\",\"order\":\"1\",\"fptrs\":[\"test:5\"],\"divs\":[]},
+ {\"label\":\"Back\",\"order\":\"2\",\"fptrs\":[],
+ \"divs\":[{\"label\":\"Top\",\"order\":\"1\",\"fptrs\":[\"test:7\"],\"divs\":[]},
+ {\"label\":\"Bottom\",\"order\":\"2\",\"fptrs\":[\"test:6\"],\"divs\":[]}
+ ]
+ }
+ ]
+ },
+ \"reverse\":
+ {\"type\":\"reverse\",
+ \"divs\":[{\"label\":\"Back\",\"order\":\"1\",\"fptrs\":[],
+ \"divs\":[{\"label\":\"Bottom\",\"order\":\"1\",\"fptrs\":[\"test:6\"],\"divs\":[]},
+ {\"label\":\"Top\",\"order\":\"2\",\"fptrs\":[\"test:7\"],\"divs\":[]}
+ ]
+ },
+ {\"label\":\"Front\",\"order\":\"2\",\"fptrs\":[\"test:5\"],\"divs\":[]}
+ ]
+ }
+ }
+ eos
+ j.gsub(/\s+/, "")
+end
\ No newline at end of file