hydra-pbcore 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +6 -0
  3. data/lib/hydra-pbcore.rb +60 -1
  4. data/lib/hydra-pbcore/behaviors.rb +4 -2
  5. data/lib/hydra-pbcore/conversions.rb +88 -0
  6. data/lib/hydra-pbcore/datastream/{digital_document.rb → deprecated/digital_document.rb} +3 -2
  7. data/lib/hydra-pbcore/datastream/deprecated/document.rb +310 -0
  8. data/lib/hydra-pbcore/datastream/deprecated/instantiation.rb +261 -0
  9. data/lib/hydra-pbcore/datastream/document.rb +37 -139
  10. data/lib/hydra-pbcore/datastream/instantiation.rb +184 -223
  11. data/lib/hydra-pbcore/methods.rb +23 -2
  12. data/lib/hydra-pbcore/templates.rb +116 -0
  13. data/lib/hydra-pbcore/version.rb +1 -1
  14. data/spec/{digital_document_spec.rb → deprecated/digital_document_spec.rb} +6 -26
  15. data/spec/deprecated/document_spec.rb +282 -0
  16. data/spec/deprecated/instantiation_spec.rb +214 -0
  17. data/spec/document_spec.rb +71 -194
  18. data/spec/fixtures/converted_digital_document_rrhof_1904.xml +53 -0
  19. data/spec/fixtures/converted_digital_document_rrhof_2405.xml +46 -0
  20. data/spec/fixtures/converted_document_rrhof_2439.xml +19 -0
  21. data/spec/fixtures/converted_document_rrhof_524.xml +45 -0
  22. data/spec/fixtures/converted_instantiation_rrhof_1184.xml +39 -0
  23. data/spec/fixtures/converted_rrhof_524.xml +45 -0
  24. data/spec/fixtures/converted_rrhof_524_instantiation.xml +18 -0
  25. data/spec/fixtures/{pbcore_digital_document_template.xml → deprecated/pbcore_digital_document_template.xml} +0 -0
  26. data/spec/fixtures/{pbcore_document_template.xml → deprecated/pbcore_document_template.xml} +0 -0
  27. data/spec/fixtures/{pbcore_instantiation_template.xml → deprecated/pbcore_instantiation_template.xml} +0 -0
  28. data/spec/fixtures/{pbcore_solr_digital_document_template.xml → deprecated/pbcore_solr_digital_document_template.xml} +0 -0
  29. data/spec/fixtures/{pbcore_solr_document_template.xml → deprecated/pbcore_solr_document_template.xml} +0 -0
  30. data/spec/fixtures/{pbcore_solr_instantiation_template.xml → deprecated/pbcore_solr_instantiation_template.xml} +0 -0
  31. data/spec/fixtures/digital_instantiation.xml +56 -0
  32. data/spec/fixtures/digital_instantiation_solr.xml +1913 -0
  33. data/spec/fixtures/digital_instantiation_template.xml +33 -0
  34. data/spec/fixtures/document.xml +72 -0
  35. data/spec/fixtures/document_solr.xml +582 -0
  36. data/spec/fixtures/document_template.xml +30 -0
  37. data/spec/fixtures/integration/digital_document_rrhof_1904.xml +63 -0
  38. data/spec/fixtures/integration/digital_document_rrhof_2405.xml +62 -0
  39. data/spec/fixtures/integration/document_rrhof_2439.xml +54 -0
  40. data/spec/fixtures/integration/document_rrhof_524.xml +80 -0
  41. data/spec/fixtures/integration/instantiation_rrhof_1184.xml +44 -0
  42. data/spec/fixtures/physical_instantiation.xml +20 -0
  43. data/spec/fixtures/physical_instantiation_solr.xml +441 -0
  44. data/spec/fixtures/physical_instantiation_template.xml +18 -0
  45. data/spec/instantiation_spec.rb +180 -132
  46. data/spec/integration/conversions_spec.rb +73 -0
  47. data/spec/spec_helper.rb +37 -9
  48. data/spec/templates_spec.rb +31 -0
  49. metadata +68 -17
@@ -6,254 +6,215 @@ class Instantiation < ActiveFedora::NokogiriDatastream
6
6
 
7
7
  # Note: this is not a complete PBCore document, just an instantiation node
8
8
  set_terminology do |t|
9
- t.root(:path=>"pbcoreDescriptionDocument")
10
-
11
- t.pbcoreInstantiation do
9
+ t.root(:path=>"pbcoreInstantiation")
10
+
11
+ t.name(
12
+ :path => "instantiationIdentifier",
13
+ :attributes=>{
14
+ :annotation=>"Filename",
15
+ :source=>"Rock and Roll Hall of Fame and Museum"
16
+ },
17
+ :index_as => [:displayable]
18
+ )
19
+ t.barcode(
20
+ :path => "instantiationIdentifier",
21
+ :attributes=>{
22
+ :annotation=>"Barcode",
23
+ :source=>"Rock and Roll Hall of Fame and Museum"
24
+ },
25
+ :index_as => [:displayable]
26
+ )
27
+ t.instantiationDate(:attributes=>{ :dateType=>"created" },
28
+ :index_as => [:not_searchable, :converted_date, :displayable]
29
+ )
30
+ t.instantiationDigital(:attributes=>{ :source=>"EBU file formats" },
31
+ :index_as => [:searchable, :facetable]
32
+ )
33
+ t.instantiationPhysical(:attributes=>{ :source=>"PBCore instantiationPhysical" },
34
+ :index_as => [:searchable, :facetable]
35
+ )
36
+ t.instantiationStandard(:index_as => [:displayable])
37
+ t.instantiationLocation(:index_as => [:displayable])
38
+ t.instantiationGenerations(:attributes=>{ :source=>"PBCore instantiationGenerations" },
39
+ :index_as => [:displayable]
40
+ )
41
+ t.instantiationFileSize(:index_as => [:displayable]) do
42
+ t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
43
+ end
44
+ t.instantiationColors(:attributes=>{ :source=>"PBCore instantiationColors" },
45
+ :index_as => [:displayable]
46
+ )
47
+ t.instantiationMediaType(:attributes=>{ :source=>"PBCore instantiationMediaType" },
48
+ :index_as => [:facetable]
49
+ )
50
+ t.instantiationLanguage(
51
+ :attributes=>{
52
+ :source=>"ISO 639.2",
53
+ :ref=>"http://www.loc.gov/standards/iso639-2/php/code_list.php"
54
+ },
55
+ :index_as => [:searchable]
56
+ )
57
+ t.instantiationDuration(:index_as => [:displayable])
58
+
59
+ t.instantiationRights do
60
+ t.rightsSummary(:index_as => [:displayable])
61
+ end
12
62
 
13
- t.instantiationIdentifier(
14
- :attributes=>{
15
- :annotation=>"Filename",
16
- :source=>"Rock and Roll Hall of Fame and Museum"
17
- },
63
+ t.instantiationEssenceTrack do
64
+ t.essenceTrackStandard(:index_as => [:displayable])
65
+ t.essenceTrackEncoding( :attributes=>{ :source=>"PBCore essenceTrackEncoding" },
18
66
  :index_as => [:displayable]
19
67
  )
20
- t.instantiationDate(:attributes=>{ :dateType=>"created" },
21
- :index_as => [:not_searchable, :converted_date, :displayable]
22
- )
23
- t.instantiationDigital(:attributes=>{ :source=>"EBU file formats" },
24
- :index_as => [:searchable, :facetable]
25
- )
26
- t.instantiationStandard(:index_as => [:displayable])
27
- t.instantiationLocation(:index_as => [:displayable])
28
- t.instantiationGenerations(:attributes=>{ :source=>"PBCore instantiationGenerations" },
29
- :index_as => [:displayable]
30
- )
31
- t.instantiationFileSize(:index_as => [:displayable]) do
68
+ t.essenceTrackDataRate(:index_as => [:displayable]) do
32
69
  t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
33
70
  end
34
- t.instantiationColors(:attributes=>{ :source=>"PBCore instantiationColors" },
71
+ t.essenceTrackFrameRate(:attributes=>{ :unitsOfMeasure=>"fps" }, :index_as => [:displayable])
72
+ t.essenceTrackFrameSize(:attributes=>{ :source=>"PBCore essenceTrackFrameSize" }, :index_as => [:displayable])
73
+ t.essenceTrackBitDepth(:index_as => [:displayable])
74
+ t.essenceTrackAspectRatio(:attributes=>{ :source=>"PBCore essenceTrackAspectRatio" },
35
75
  :index_as => [:displayable]
36
76
  )
37
- t.instantiationMediaType(:attributes=>{ :source=>"PBCore instantiationMediaType" },
38
- :index_as => [:facetable]
39
- )
40
- t.instantiationLanguage(
41
- :attributes=>{
42
- :source=>"ISO 639.2",
43
- :ref=>"http://www.loc.gov/standards/iso639-2/php/code_list.php"
44
- },
45
- :index_as => [:searchable]
46
- )
47
- t.instantiationDuration(:index_as => [:displayable])
48
-
49
- t.instantiationRights do
50
- t.rightsSummary(:index_as => [:displayable])
51
- end
52
-
53
- t.instantiationEssenceTrack do
54
- t.essenceTrackStandard(:index_as => [:displayable])
55
- t.essenceTrackEncoding( :attributes=>{ :source=>"PBCore essenceTrackEncoding" },
56
- :index_as => [:displayable]
57
- )
58
- t.essenceTrackDataRate(:index_as => [:displayable]) do
59
- t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
60
- end
61
- t.essenceTrackFrameRate(:attributes=>{ :unitsOfMeasure=>"fps" }, :index_as => [:displayable])
62
- t.essenceTrackFrameSize(:attributes=>{ :source=>"PBCore essenceTrackFrameSize" }, :index_as => [:displayable])
63
- t.essenceTrackBitDepth(:index_as => [:displayable])
64
- t.essenceTrackAspectRatio(:attributes=>{ :source=>"PBCore essenceTrackAspectRatio" },
65
- :index_as => [:displayable]
66
- )
67
- t.essenceTrackSamplingRate(:index_as => [:displayable]) do
68
- t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
69
- end
70
- t.essenceTrackAnnotation( :attributes=>{ :annotationType=>"Number of Audio Channels" },
71
- :index_as => [:displayable]
72
- )
73
- end
74
- t.video_essence(:ref => [:pbcoreInstantiation, :instantiationEssenceTrack],
75
- :path=>'instantiationEssenceTrack[essenceTrackType="Video"]'
76
- )
77
- t.audio_essence(:ref => [:pbcoreInstantiation, :instantiationEssenceTrack],
78
- :path=>'instantiationEssenceTrack[essenceTrackType="Audio"]'
79
- )
80
-
81
- t.instantiationRelation do
82
- t.instantiationRelationIdentifier(:attributes=>{ :source=>"Rock and Roll Hall of Fame and Museum" })
77
+ t.essenceTrackSamplingRate(:index_as => [:displayable]) do
78
+ t.units(:path=>{:attribute=>"unitsOfMeasure"}, :index_as => [:displayable])
83
79
  end
84
- # The file we're describing at the root of this document preceeds the file marked "next"
85
- t.next_inst(:ref => [:pbcoreInstantiation, :instantiationRelation],
86
- :path=>'instantiationRelation[instantiationRelationType="Precedes in Sequence"]'
87
- )
88
- # The file we're describing at the root of this document comes after the file marked "previous"
89
- t.previous_inst(:ref => [:pbcoreInstantiation, :instantiationRelation],
90
- :path=>'instantiationRelation[instantiationRelationType="Follows in Sequence"]'
91
- )
92
-
93
- # Instantitation annotiations
94
- t.inst_chksum_type(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Checksum Type" },
95
- :index_as => [:displayable]
96
- )
97
- t.inst_chksum_value(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Checksum Value" },
98
- :index_as => [:displayable]
99
- )
100
- t.inst_device(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Playback Device" },
101
- :index_as => [:displayable]
102
- )
103
- t.inst_capture_soft(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Capture Software" },
104
- :index_as => [:displayable]
105
- )
106
- t.inst_trans_soft(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Transcoding Software" },
107
- :index_as => [:displayable]
108
- )
109
- t.inst_operator(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Operator" },
110
- :index_as => [:displayable]
111
- )
112
- t.inst_trans_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Transfer Notes" },
113
- :index_as => [:displayable]
114
- )
115
- t.inst_vendor(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Vendor Name" },
116
- :index_as => [:displayable]
117
- )
118
- t.inst_cond_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Condition Notes" },
119
- :index_as => [:displayable]
120
- )
121
- t.inst_clean_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Cleaning Notes" },
122
- :index_as => [:displayable]
123
- )
124
- t.inst_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Notes" },
125
- :index_as => [:displayable]
126
- )
127
- t.inst_color_space(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Color Space" },
128
- :index_as => [:displayable]
129
- )
130
- t.inst_chroma(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Chroma" },
80
+ t.essenceTrackAnnotation( :attributes=>{ :annotationType=>"Number of Audio Channels" },
131
81
  :index_as => [:displayable]
132
82
  )
133
-
134
83
  end
84
+ t.video_essence(:ref => [:pbcoreInstantiation, :instantiationEssenceTrack],
85
+ :path=>'instantiationEssenceTrack[essenceTrackType="Video"]'
86
+ )
87
+ t.audio_essence(:ref => [:pbcoreInstantiation, :instantiationEssenceTrack],
88
+ :path=>'instantiationEssenceTrack[essenceTrackType="Audio"]'
89
+ )
90
+
91
+ t.instantiationRelation do
92
+ t.instantiationRelationIdentifier(:attributes=>{ :source=>"Rock and Roll Hall of Fame and Museum" })
93
+ end
94
+ # The file we're describing at the root of this document preceeds the file marked "next"
95
+ t.next_inst(:ref => [:pbcoreInstantiation, :instantiationRelation],
96
+ :path=>'instantiationRelation[instantiationRelationType="Precedes in Sequence"]'
97
+ )
98
+ # The file we're describing at the root of this document comes after the file marked "previous"
99
+ t.previous_inst(:ref => [:pbcoreInstantiation, :instantiationRelation],
100
+ :path=>'instantiationRelation[instantiationRelationType="Follows in Sequence"]'
101
+ )
102
+
103
+ # Instantitation annotiations
104
+ t.inst_chksum_type(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Checksum Type" },
105
+ :index_as => [:displayable]
106
+ )
107
+ t.inst_chksum_value(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Checksum Value" },
108
+ :index_as => [:displayable]
109
+ )
110
+ t.inst_device(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Playback Device" },
111
+ :index_as => [:displayable]
112
+ )
113
+ t.inst_capture_soft(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Capture Software" },
114
+ :index_as => [:displayable]
115
+ )
116
+ t.inst_trans_soft(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Transcoding Software" },
117
+ :index_as => [:displayable]
118
+ )
119
+ t.inst_operator(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Operator" },
120
+ :index_as => [:displayable]
121
+ )
122
+ t.inst_trans_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Transfer Notes" },
123
+ :index_as => [:displayable]
124
+ )
125
+ t.inst_vendor(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Vendor Name" },
126
+ :index_as => [:displayable]
127
+ )
128
+ t.inst_cond_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Condition Notes" },
129
+ :index_as => [:displayable]
130
+ )
131
+ t.inst_clean_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Cleaning Notes" },
132
+ :index_as => [:displayable]
133
+ )
134
+ t.inst_note(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Notes" },
135
+ :index_as => [:displayable]
136
+ )
137
+ t.inst_color_space(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Color Space" },
138
+ :index_as => [:displayable]
139
+ )
140
+ t.inst_chroma(:path=>"instantiationAnnotation", :attributes=>{ :annotationType=>"Chroma" },
141
+ :index_as => [:displayable]
142
+ )
143
+
144
+ t.condition_note(:path=>"instantiationAnnotation",
145
+ :attributes=>{ :annotationType=>"Condition Notes"},
146
+ :index_as => [:searchable, :displayable]
147
+ )
148
+ t.cleaning_note(:path=>"instantiationAnnotation",
149
+ :attributes=>{ :annotationType=>"Cleaning Notes" },
150
+ :index_as => [:searchable, :displayable]
151
+ )
135
152
 
136
153
  #
137
- # Here are the actual references to the fields
154
+ # Proxied terms
138
155
  #
139
- t.name(:proxy=>[:pbcoreInstantiation, :instantiationIdentifier])
140
- t.location(:proxy=>[:pbcoreInstantiation, :instantiationLocation])
141
- t.date(:proxy=>[:pbcoreInstantiation, :instantiationDate])
142
- t.generation(:proxy=>[:pbcoreInstantiation, :instantiationGenerations])
143
- t.media_type(:proxy=>[:pbcoreInstantiation, :instantiationMediaType])
144
- t.file_format(:proxy=>[:pbcoreInstantiation, :instantiationDigital])
145
- t.size(:proxy=>[:pbcoreInstantiation, :instantiationFileSize])
146
- t.size_units(:proxy=>[:pbcoreInstantiation, :instantiationFileSize, :units])
147
- t.colors(:proxy=>[:pbcoreInstantiation, :instantiationColors])
148
- t.duration(:proxy=>[:pbcoreInstantiation, :instantiationDuration])
149
- t.rights_summary(:proxy=>[:pbcoreInstantiation, :instantiationRights, :rightsSummary])
156
+ t.location(:proxy=>[:instantiationLocation])
157
+ t.date(:proxy=>[:instantiationDate])
158
+ t.generation(:proxy=>[:instantiationGenerations])
159
+ t.media_type(:proxy=>[:instantiationMediaType])
160
+ t.file_format(:proxy=>[:instantiationDigital])
161
+ t.format(:proxy=>[:instantiationPhysical])
162
+ t.size(:proxy=>[:instantiationFileSize])
163
+ t.size_units(:proxy=>[:instantiationFileSize, :units])
164
+ t.colors(:proxy=>[:instantiationColors])
165
+ t.duration(:proxy=>[:instantiationDuration])
166
+ t.rights_summary(:proxy=>[:instantiationRights, :rightsSummary])
150
167
 
151
168
  # Proxies to annotation fields and other fields that are not in the template
152
- t.note(:proxy=>[:pbcoreInstantiation, :inst_note])
153
- t.checksum_type(:proxy=>[:pbcoreInstantiation, :inst_chksum_type])
154
- t.checksum_value(:proxy=>[:pbcoreInstantiation, :inst_chksum_value])
155
- t.device(:proxy=>[:pbcoreInstantiation, :inst_device])
156
- t.capture_soft(:proxy=>[:pbcoreInstantiation, :inst_capture_soft])
157
- t.trans_soft(:proxy=>[:pbcoreInstantiation, :inst_trans_soft])
158
- t.operator(:proxy=>[:pbcoreInstantiation, :inst_operator])
159
- t.trans_note(:proxy=>[:pbcoreInstantiation, :inst_trans_note])
160
- t.vendor(:proxy=>[:pbcoreInstantiation, :inst_vendor])
161
- t.condition(:proxy=>[:pbcoreInstantiation, :inst_cond_note])
162
- t.cleaning(:proxy=>[:pbcoreInstantiation, :inst_clean_note])
163
- t.color_space(:proxy=>[:pbcoreInstantiation, :inst_color_space])
164
- t.chroma(:proxy=>[:pbcoreInstantiation, :inst_chroma])
165
- t.standard(:proxy=>[:pbcoreInstantiation, :instantiationStandard])
166
- t.language(:proxy=>[:pbcoreInstantiation, :instantiationLanguage])
169
+ t.note(:proxy=>[:inst_note])
170
+ t.checksum_type(:proxy=>[:inst_chksum_type])
171
+ t.checksum_value(:proxy=>[:inst_chksum_value])
172
+ t.device(:proxy=>[:inst_device])
173
+ t.capture_soft(:proxy=>[:inst_capture_soft])
174
+ t.trans_soft(:proxy=>[:inst_trans_soft])
175
+ t.operator(:proxy=>[:inst_operator])
176
+ t.trans_note(:proxy=>[:inst_trans_note])
177
+ t.vendor(:proxy=>[:inst_vendor])
178
+ t.condition(:proxy=>[:inst_cond_note])
179
+ t.cleaning(:proxy=>[:inst_clean_note])
180
+ t.color_space(:proxy=>[:inst_color_space])
181
+ t.chroma(:proxy=>[:inst_chroma])
182
+ t.standard(:proxy=>[:instantiationStandard])
183
+ t.language(:proxy=>[:instantiationLanguage])
167
184
 
168
185
  # Proxies to video essence fields
169
- t.video_standard(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackStandard])
170
- t.video_encoding(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackEncoding])
171
- t.video_bit_rate(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackDataRate])
172
- t.video_bit_rate_units(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackDataRate, :units])
173
- t.frame_rate(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackFrameRate])
174
- t.frame_size(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackFrameSize])
175
- t.video_bit_depth(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackBitDepth])
176
- t.aspect_ratio(:proxy=>[:pbcoreInstantiation, :video_essence, :essenceTrackAspectRatio])
186
+ t.video_standard(:proxy=>[:video_essence, :essenceTrackStandard])
187
+ t.video_encoding(:proxy=>[:video_essence, :essenceTrackEncoding])
188
+ t.video_bit_rate(:proxy=>[:video_essence, :essenceTrackDataRate])
189
+ t.video_bit_rate_units(:proxy=>[:video_essence, :essenceTrackDataRate, :units])
190
+ t.frame_rate(:proxy=>[:video_essence, :essenceTrackFrameRate])
191
+ t.frame_size(:proxy=>[:video_essence, :essenceTrackFrameSize])
192
+ t.video_bit_depth(:proxy=>[:video_essence, :essenceTrackBitDepth])
193
+ t.aspect_ratio(:proxy=>[:video_essence, :essenceTrackAspectRatio])
177
194
 
178
195
  # Proxies to audio essence fields
179
- t.audio_standard(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackStandard])
180
- t.audio_encoding(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackEncoding])
181
- t.audio_bit_rate(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackDataRate])
182
- t.audio_bit_rate_units(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackDataRate, :units])
183
- t.audio_sample_rate(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackSamplingRate])
184
- t.audio_sample_rate_units(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackSamplingRate, :units])
185
- t.audio_bit_depth(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackBitDepth])
186
- t.audio_channels(:proxy=>[:pbcoreInstantiation, :audio_essence, :essenceTrackAnnotation])
196
+ t.audio_standard(:proxy=>[:audio_essence, :essenceTrackStandard])
197
+ t.audio_encoding(:proxy=>[:audio_essence, :essenceTrackEncoding])
198
+ t.audio_bit_rate(:proxy=>[:audio_essence, :essenceTrackDataRate])
199
+ t.audio_bit_rate_units(:proxy=>[:audio_essence, :essenceTrackDataRate, :units])
200
+ t.audio_sample_rate(:proxy=>[:audio_essence, :essenceTrackSamplingRate])
201
+ t.audio_sample_rate_units(:proxy=>[:audio_essence, :essenceTrackSamplingRate, :units])
202
+ t.audio_bit_depth(:proxy=>[:audio_essence, :essenceTrackBitDepth])
203
+ t.audio_channels(:proxy=>[:audio_essence, :essenceTrackAnnotation])
187
204
 
188
205
  # Proxies to the relation fields
189
- t.next_(:proxy=>[:pbcoreInstantiation, :next_inst, :instantiationRelationIdentifier])
190
- t.previous_(:proxy=>[:pbcoreInstantiation, :previous_inst, :instantiationRelationIdentifier])
191
-
206
+ t.next_(:proxy=>[:next_inst, :instantiationRelationIdentifier])
207
+ t.previous_(:proxy=>[:previous_inst, :instantiationRelationIdentifier])
192
208
  end
193
209
 
194
- def self.xml_template
195
- builder = Nokogiri::XML::Builder.new do |xml|
196
-
197
- xml.pbcoreDescriptionDocument("xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance",
198
- "xsi:schemaLocation"=>"http://www.pbcore.org/PBCore/PBCoreNamespace.html") {
199
-
200
- # These fields are only added so that this document will be validated. However, they
201
- # shouldn't be used for anything else here because they're in the parent Fedora object
202
- xml.pbcoreIdentifier(:annotation=>"PID", :source=>"Rock and Roll Hall of Fame and Museum")
203
- xml.pbcoreTitle
204
- xml.pbcoreDescription
205
-
206
- xml.pbcoreInstantiation {
207
-
208
- xml.instantiationIdentifier(:annotation=>"Filename", :source=>"Rock and Roll Hall of Fame and Museum")
209
- xml.instantiationDate(:dateType=>"created")
210
- xml.instantiationDigital(:source=>"EBU file formats")
211
- xml.instantiationLocation
212
- xml.instantiationMediaType(:source=>"PBCore instantiationMediaType") {
213
- xml.text "Moving image"
214
- }
215
- xml.instantiationGenerations(:source=>"PBCore instantiationGenerations")
216
- xml.instantiationFileSize(:unitsOfMeasure=>"")
217
- xml.instantiationDuration
218
- xml.instantiationColors(:source=>"PBCore instantiationColors") {
219
- xml.text "Color"
220
- }
221
-
222
- xml.instantiationEssenceTrack {
223
- xml.essenceTrackType {
224
- xml.text "Video"
225
- }
226
- xml.essenceTrackStandard
227
- xml.essenceTrackEncoding(:source=>"PBCore essenceTrackEncoding")
228
- xml.essenceTrackDataRate(:unitsOfMeasure=>"")
229
- xml.essenceTrackFrameRate(:unitsOfMeasure=>"fps")
230
- xml.essenceTrackBitDepth
231
- xml.essenceTrackFrameSize(:source=>"PBCore essenceTrackFrameSize")
232
- xml.essenceTrackAspectRatio(:source=>"PBCore essenceTrackAspectRatio")
233
- }
234
-
235
- xml.instantiationEssenceTrack {
236
- xml.essenceTrackType {
237
- xml.text "Audio"
238
- }
239
- xml.essenceTrackStandard
240
- xml.essenceTrackEncoding(:source=>"PBCore essenceTrackEncoding")
241
- xml.essenceTrackDataRate(:unitsOfMeasure=>"")
242
- xml.essenceTrackSamplingRate(:unitsOfMeasure=>"")
243
- xml.essenceTrackBitDepth
244
- xml.essenceTrackAnnotation(:annotationType=>"Number of Audio Channels")
245
- }
246
-
247
- xml.instantiationRights {
248
- xml.rightsSummary
249
- }
250
-
251
- }
252
-
253
- }
254
-
210
+ def define opts
211
+ if opts == :physical
212
+ self.ng_xml = physical_instantiation
213
+ elsif opts == :digital
214
+ self.ng_xml = digital_instantiation
215
+ else
216
+ return self.ng_xml
255
217
  end
256
- return builder.doc
257
218
  end
258
219
 
259
220
  end
@@ -1,10 +1,31 @@
1
1
  module HydraPbcore::Methods
2
2
 
3
-
4
- def remove_node(type, index)
3
+ def remove_node(type, index = 0)
5
4
  self.find_by_terms(type.to_sym).slice(index.to_i).remove
6
5
  self.dirty = true
7
6
  end
8
7
 
8
+ # Returns a new Nokogiri::XML object with the contents of self reordered and repackaged as a
9
+ # valid pbcore xml document.
10
+ #
11
+ # The original xml from the datastream is copied to a new Nokogiri object, then each node
12
+ # is added--in correct order--to a new blank, valid pbcore xml document.
13
+ def to_pbcore_xml
14
+ original = Nokogiri::XML(self.to_xml)
15
+ new_doc = HydraPbcore.blank
16
+ HydraPbcore::DocumentNodes.each do |node|
17
+ original.search(node).each do |n|
18
+ new_doc.root.add_child(n)
19
+ end
20
+ end
21
+ return new_doc
22
+ end
23
+
24
+ # Validates a PBCore document against an xsd
25
+ # Returns an array of errors -- an empty array means it's valid
26
+ def valid?
27
+ xsd = Nokogiri::XML::Schema(open("http://pbcore.org/xsd/pbcore-2.0.xsd"))
28
+ xsd.validate(self.to_pbcore_xml)
29
+ end
9
30
 
10
31
  end