add subject names and categories

This commit is contained in:
John Bintz 2011-03-22 16:22:36 -04:00
parent fb81d7c349
commit 20391fc842
6 changed files with 65 additions and 2 deletions

View File

@ -59,6 +59,7 @@ module AVM
'RelatedResources',
'MetadataDate',
'MetadataVersion',
'Subject.Category',
]
AVM_SINGLE_METHODS = [
@ -88,6 +89,7 @@ module AVM
:related_resources,
:metadata_date,
:metadata_version,
:categories
]
AVM_SINGLE_MESSAGES = [
@ -117,6 +119,7 @@ module AVM
:related_resources,
:string_metadata_date,
:metadata_version,
:categories
]
AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS)
@ -138,7 +141,7 @@ module AVM
:spatial_scale, :spatial_rotation, :coordinate_system_projection, :spatial_quality,
:spatial_notes, :fits_header, :spatial_cd_matrix, :distance,
:publisher, :publisher_id, :resource_id, :resource_url,
:related_resources, :metadata_date, :metadata_version
:related_resources, :metadata_date, :metadata_version, :subject_names, :categories
]
attr_reader :creator, :observations
@ -271,6 +274,10 @@ module AVM
end
end
if node = refs[:dublin_core].at_xpath(".//dc:subject/rdf:Bag")
options[:subject_names] = node.search('./rdf:li').collect(&:text)
end
AVM_SINGLES.each do |tag, field|
if node = refs[:avm].at_xpath("./avm:#{tag}")
if !(list_items = node.search('.//rdf:li')).empty?

View File

@ -22,6 +22,7 @@ describe AVM::Image do
let(:light_years) { 'Light years' }
let(:subject_names) { [ 'Name one', 'Name two' ] }
let(:categories) { [ 'Category one', 'Category two' ] }
let(:coordinate_frame) { 'ICRS' }
let(:equinox) { '100' }
@ -78,6 +79,8 @@ describe AVM::Image do
:related_resources => related_resources,
:metadata_date => metadata_date,
:metadata_version => metadata_version,
:subject_names => subject_names,
:categories => categories
} }
end
@ -122,6 +125,9 @@ describe AVM::Image do
its(:metadata_date) { should == Time.parse(metadata_date) }
its(:metadata_version) { should == metadata_version }
its(:subject_names) { should == subject_names }
its(:categories) { should == categories }
it { should be_valid }
end
@ -165,6 +171,8 @@ describe AVM::Image do
:related_resources => related_resources,
:metadata_date => Time.parse(metadata_date),
:metadata_version => metadata_version,
:subject_names => subject_names,
:categories => categories
} }
its(:distance) { should == [ light_years, redshift ] }
@ -190,7 +198,7 @@ describe AVM::Image do
:light_years, :coordinate_frame, :equinox, :reference_value,
:reference_dimension, :reference_pixel, :spatial_scale,
:spatial_rotation, :coordinate_system_projection, :spatial_quality, :spatial_notes,
:fits_header, :spatial_cd_matrix
:fits_header, :spatial_cd_matrix, :subject_names, :categories
].each do |field|
its(field) { should be_nil }
end

View File

@ -12,6 +12,12 @@
<rdf:li xml:lang="x-default">Description</rdf:li>
</rdf:Alt>
</dc:description>
<dc:subject>
<rdf:Bag>
<rdf:li>Name one</rdf:li>
<rdf:li>Name two</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/">
@ -32,6 +38,12 @@
<avm:ID>ID</avm:ID>
<avm:Type>Observation</avm:Type>
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
<avm:Subject.Category>
<rdf:Bag>
<rdf:li>Category one</rdf:li>
<rdf:li>Category two</rdf:li>
</rdf:Bag>
</avm:Subject.Category>
<avm:Distance>
<rdf:Seq>
<rdf:li>Light years</rdf:li>

View File

@ -12,6 +12,12 @@
<rdf:li xml:lang="x-default">Description</rdf:li>
</rdf:Alt>
</dc:description>
<dc:subject>
<rdf:Bag>
<rdf:li>Name one</rdf:li>
<rdf:li>Name two</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/">
@ -32,6 +38,12 @@
<avm:ID>ID</avm:ID>
<avm:Type>Observation</avm:Type>
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
<avm:Subject.Category>
<rdf:Bag>
<rdf:li>Category one</rdf:li>
<rdf:li>Category two</rdf:li>
</rdf:Bag>
</avm:Subject.Category>
<avm:Distance><rdf:Seq><rdf:li>Light years</rdf:li></rdf:Seq></avm:Distance>
<avm:Spatial.CoordinateFrame>ICRS</avm:Spatial.CoordinateFrame>
<avm:Spatial.Equinox>100</avm:Spatial.Equinox>

View File

@ -12,6 +12,12 @@
<rdf:li xml:lang="x-default">Description</rdf:li>
</rdf:Alt>
</dc:description>
<dc:subject>
<rdf:Bag>
<rdf:li>Name one</rdf:li>
<rdf:li>Name two</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>
<rdf:Description rdf:about=""
@ -39,6 +45,12 @@
<rdf:li>Redshift</rdf:li>
</rdf:Seq>
</avm:Distance>
<avm:Subject.Category>
<rdf:Bag>
<rdf:li>Category one</rdf:li>
<rdf:li>Category two</rdf:li>
</rdf:Bag>
</avm:Subject.Category>
<avm:Spatial.CoordinateFrame>ICRS</avm:Spatial.CoordinateFrame>
<avm:Spatial.Equinox>100</avm:Spatial.Equinox>
<avm:Spatial.ReferenceValue>

View File

@ -12,6 +12,12 @@
<rdf:li xml:lang="x-default">Description</rdf:li>
</rdf:Alt>
</dc:description>
<dc:subject>
<rdf:Bag>
<rdf:li>Name one</rdf:li>
<rdf:li>Name two</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/">
@ -33,6 +39,12 @@
<avm:Type>Observation</avm:Type>
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
<avm:Distance>Light years</avm:Distance>
<avm:Subject.Category>
<rdf:Bag>
<rdf:li>Category one</rdf:li>
<rdf:li>Category two</rdf:li>
</rdf:Bag>
</avm:Subject.Category>
<avm:Spatial.CoordinateFrame>ICRS</avm:Spatial.CoordinateFrame>
<avm:Spatial.Equinox>100</avm:Spatial.Equinox>
<avm:Spatial.ReferenceValue>