libis-tools 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/lib/libis/tools/command.rb +1 -1
- data/lib/libis/tools/metadata/dublin_core_record.rb +2 -2
- data/lib/libis/tools/mets_file.rb +446 -30
- data/lib/libis/tools/version.rb +1 -1
- data/lib/libis/tools/xml_document.rb +1 -1
- data/spec/metadata/dublin_core_spec.rb +2 -2
- data/spec/metadata/marc21_spec.rb +2 -2
- data/spec/mets_file_spec.rb +218 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ad80b0200a021e9181c164d32163ef90c03ec40
|
4
|
+
data.tar.gz: ff6cba705fa063e1a98c83f80c79e20516da2eaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b09c20e3962dc4b8aeb1555212a51992a5102a07f3b6b27b65af97075bd06de12fcf8fea24a6d762aa8d34554a0ab43cfe13110e4072dcbfb99c0dbd4af58e82
|
7
|
+
data.tar.gz: 597b7334148abc3ba78f675b8914cbaf05647a7b57a5d9d66e61717c1cb083588d0e8d7a69a6d949320528b52f4c7dec9b3bcaf8036663551f4a4fbca98bed96
|
data/.travis.yml
CHANGED
data/lib/libis/tools/command.rb
CHANGED
@@ -32,10 +32,10 @@ module Libis
|
|
32
32
|
Libis::Tools::XmlDocument.from_hash(doc)
|
33
33
|
when NilClass
|
34
34
|
Libis::Tools::XmlDocument.new.build do |xml|
|
35
|
-
xml.record('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
35
|
+
xml[:dc].record('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
|
36
36
|
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
|
37
37
|
'xmlns:dcterms' => 'http://purl.org/dc/terms/') {
|
38
|
-
yield xml
|
38
|
+
yield xml if block_given?
|
39
39
|
}
|
40
40
|
end
|
41
41
|
else
|
@@ -41,7 +41,12 @@ module Libis
|
|
41
41
|
class Representation
|
42
42
|
include IdContainer
|
43
43
|
|
44
|
-
attr_accessor :label, :preservation_type, :usage_type, :
|
44
|
+
attr_accessor :label, :preservation_type, :usage_type, :representation_code, :entity_type, :priority, :order,
|
45
|
+
:digital_original, :content, :context, :hardware, :carrier, :original_name,
|
46
|
+
:user_a, :user_b, :user_c, :group_id,
|
47
|
+
:preservation_levels, :env_dependencies, :hardware_ids, :software_ids,
|
48
|
+
:hardware_infos, :software_infos, :relationship_infos, :environments,
|
49
|
+
:dc_record, :source_metadata
|
45
50
|
|
46
51
|
def xml_id
|
47
52
|
"rep#{id}"
|
@@ -50,14 +55,161 @@ module Libis
|
|
50
55
|
def amd
|
51
56
|
dnx = {}
|
52
57
|
tech_data = []
|
58
|
+
# General characteristics
|
53
59
|
data = {
|
54
60
|
preservationType: preservation_type,
|
55
61
|
usageType: usage_type,
|
56
|
-
|
57
|
-
|
62
|
+
DigitalOriginal: digital_original,
|
63
|
+
label: label,
|
64
|
+
representationEntityType: entity_type,
|
65
|
+
contentType: content,
|
66
|
+
contextType: context,
|
67
|
+
hardwareUsed: hardware,
|
68
|
+
physicalCarrierMedia: carrier,
|
69
|
+
deliveryPriority: priority,
|
70
|
+
orderingSequence: order,
|
71
|
+
RepresentationCode: representation_code,
|
72
|
+
RepresentationOriginalName: original_name,
|
73
|
+
UserDefinedA: user_a,
|
74
|
+
UserDefinedB: user_b,
|
75
|
+
UserDefinedC: user_c,
|
58
76
|
}.cleanup
|
59
77
|
tech_data << TechGeneralRep.new(data) unless data.empty?
|
78
|
+
# Object characteristics
|
79
|
+
data = {
|
80
|
+
groupID: group_id
|
81
|
+
}.cleanup
|
82
|
+
tech_data << TechObjectChars.new(data) unless data.empty?
|
83
|
+
# Preservation level
|
84
|
+
if preservation_levels
|
85
|
+
data_list = []
|
86
|
+
preservation_levels.each do |preservation_level|
|
87
|
+
data = {
|
88
|
+
preservationLevelValue: preservation_level[:value],
|
89
|
+
preservationLevelRole: preservation_level[:role],
|
90
|
+
preservationLevelRationale: preservation_level[:rationale],
|
91
|
+
preservationLevelDateAssigned: preservation_level[:date],
|
92
|
+
}.cleanup
|
93
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
94
|
+
end
|
95
|
+
tech_data << PreservationLevel.new(array: data_list) unless data_list.empty?
|
96
|
+
end
|
97
|
+
# Dependencies
|
98
|
+
if env_dependencies
|
99
|
+
data_list = []
|
100
|
+
env_dependencies.each do |dependency|
|
101
|
+
data = {
|
102
|
+
dependencyName: dependency[:name],
|
103
|
+
dependencyIdentifierType1: dependency[:type1],
|
104
|
+
dependencyIdentifierValue1: dependency[:value1],
|
105
|
+
dependencyIdentifierType2: dependency[:type2],
|
106
|
+
dependencyIdentifierValue2: dependency[:value2],
|
107
|
+
dependencyIdentifierType3: dependency[:type3],
|
108
|
+
dependencyIdentifierValue3: dependency[:value3],
|
109
|
+
}.cleanup
|
110
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
111
|
+
end
|
112
|
+
tech_data << EnvDeps.new(array: data_list) unless data_list.empty?
|
113
|
+
end
|
114
|
+
# Hardware registry id
|
115
|
+
if hardware_ids
|
116
|
+
data_list = []
|
117
|
+
hardware_ids.each do |id|
|
118
|
+
data = {
|
119
|
+
registryId: id
|
120
|
+
}.cleanup
|
121
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
122
|
+
end
|
123
|
+
tech_data << HardwareId.new(array: data_list) unless data_list.empty?
|
124
|
+
end
|
125
|
+
# Software registry id
|
126
|
+
if software_ids
|
127
|
+
data_list = []
|
128
|
+
software_ids.each do |id|
|
129
|
+
data = {
|
130
|
+
registryId: id
|
131
|
+
}.cleanup
|
132
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
133
|
+
end
|
134
|
+
tech_data << SoftwareId.new(array: data_list) unless data_list.empty?
|
135
|
+
end
|
136
|
+
# Hardware
|
137
|
+
if hardware_infos
|
138
|
+
data_list = []
|
139
|
+
hardware_infos.each do |hardware|
|
140
|
+
data = {
|
141
|
+
hardwareName: hardware[:name],
|
142
|
+
hardwareType: hardware[:type],
|
143
|
+
hardwareOtherInformation: hardware[:info],
|
144
|
+
}.cleanup
|
145
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
146
|
+
end
|
147
|
+
tech_data << HardwareInfo.new(array: data_list) unless data_list.empty?
|
148
|
+
end
|
149
|
+
# Software
|
150
|
+
if software_infos
|
151
|
+
data_list = []
|
152
|
+
software_infos.each do |software|
|
153
|
+
data = {
|
154
|
+
softwareName: software[:name],
|
155
|
+
softwareVersion: software[:version],
|
156
|
+
softwareType: software[:type],
|
157
|
+
softwareOtherInformation: software[:info],
|
158
|
+
softwareDependancy: software[:dependency],
|
159
|
+
}.cleanup
|
160
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
161
|
+
end
|
162
|
+
tech_data << SoftwareInfo.new(array: data_list) unless data_list.empty?
|
163
|
+
end
|
164
|
+
# Relationship
|
165
|
+
if relationship_infos
|
166
|
+
data_list = []
|
167
|
+
relationship_infos.each do |relationship|
|
168
|
+
data = {
|
169
|
+
relationshipType: relationship[:type],
|
170
|
+
relationshipSubType: relationship[:subtype],
|
171
|
+
relatedObjectIdentifierType1: relationship[:type1],
|
172
|
+
relatedObjectIdentifierValue1: relationship[:id1],
|
173
|
+
relatedObjectSequence1: relationship[:seq1],
|
174
|
+
relatedObjectIdentifierType2: relationship[:type2],
|
175
|
+
relatedObjectIdentifierValue2: relationship[:id2],
|
176
|
+
relatedObjectSequence2: relationship[:seq2],
|
177
|
+
relatedObjectIdentifierType3: relationship[:type3],
|
178
|
+
relatedObjectIdentifierValue3: relationship[:id3],
|
179
|
+
relatedObjectSequence3: relationship[:seq3],
|
180
|
+
}.cleanup
|
181
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
182
|
+
end
|
183
|
+
tech_data << RelationShip.new(array: data_list) unless data_list.empty?
|
184
|
+
end
|
185
|
+
# Environment
|
186
|
+
if environments
|
187
|
+
data_list = []
|
188
|
+
environments.each do |environment|
|
189
|
+
data = {
|
190
|
+
environmentCharacteristic: environment[:characteristic],
|
191
|
+
environmentPurpose: environment[:purpose],
|
192
|
+
environmentNote: environment[:note],
|
193
|
+
}.cleanup
|
194
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
195
|
+
end
|
196
|
+
tech_data << Environment.new(array: data_list) unless data_list.empty?
|
197
|
+
end
|
198
|
+
# Finally assemble technical section
|
60
199
|
dnx[:tech] = tech_data unless tech_data.empty?
|
200
|
+
# Rights section
|
201
|
+
rights_data = []
|
202
|
+
data = {
|
203
|
+
policyId: hash[:access_right]
|
204
|
+
}.cleanup
|
205
|
+
rights_data << Rights.new(data) unless data.empty?
|
206
|
+
dnx[:rights] = rights_data unless rights_data.empty?
|
207
|
+
# Source metadata
|
208
|
+
if source_metadata
|
209
|
+
source_metadata.each_with_index do |metadata, i|
|
210
|
+
dnx["source-#{metadata[:type].to_s.upcase}-#{i}"] = metadata[:data]
|
211
|
+
end
|
212
|
+
end
|
61
213
|
dnx
|
62
214
|
end
|
63
215
|
|
@@ -66,7 +218,13 @@ module Libis
|
|
66
218
|
class File
|
67
219
|
include IdContainer
|
68
220
|
|
69
|
-
attr_accessor :label, :location, :target_location, :mimetype, :entity_type,
|
221
|
+
attr_accessor :label, :note, :location, :target_location, :mimetype, :entity_type,
|
222
|
+
:creation_date, :modification_date, :composition_level, :group_id,
|
223
|
+
:fixity_type, :fixity_value,
|
224
|
+
:preservation_levels, :inhibitors, :env_dependencies, :hardware_ids, :software_ids,
|
225
|
+
:signatures, :hardware_infos, :software_infos, :relationship_infos, :environments, :applications,
|
226
|
+
:dc_record, :source_metadata
|
227
|
+
:representation
|
70
228
|
|
71
229
|
def xml_id
|
72
230
|
"fid#{id}"
|
@@ -111,20 +269,194 @@ module Libis
|
|
111
269
|
def amd
|
112
270
|
dnx = {}
|
113
271
|
tech_data = []
|
272
|
+
# General File charateristics
|
114
273
|
data = {
|
115
274
|
label: label,
|
116
|
-
|
275
|
+
note: note,
|
276
|
+
fileCreationDate: creation_date,
|
277
|
+
fileModificationDate: modification_date,
|
278
|
+
FileEntityType: entity_type,
|
279
|
+
compositionLevel: composition_level,
|
280
|
+
# fileLocationType: 'FILE',
|
281
|
+
# fileLocation: '',
|
117
282
|
fileOriginalName: orig_name,
|
118
283
|
fileOriginalPath: orig_path,
|
119
|
-
|
120
|
-
|
284
|
+
fileOriginalID: location,
|
285
|
+
fileExtension: ::File.extname(orig_name),
|
286
|
+
fileMIMEType: mimetype,
|
287
|
+
fileSizeBytes: size,
|
288
|
+
|
121
289
|
}.cleanup
|
122
290
|
tech_data << TechGeneralFile.new(data) unless data.empty?
|
123
|
-
#
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
291
|
+
# Fixity
|
292
|
+
data = {
|
293
|
+
fixityType: fixity_type,
|
294
|
+
fixityValue: fixity_value,
|
295
|
+
}.cleanup
|
296
|
+
tech_data << TechFixity.new(data) unless data.empty?
|
297
|
+
# Object characteristics
|
298
|
+
data = {
|
299
|
+
groupID: group_id
|
300
|
+
}.cleanup
|
301
|
+
tech_data << TechObjectChars.new(data) unless data.empty?
|
302
|
+
# Preservation level
|
303
|
+
if preservation_levels
|
304
|
+
data_list = []
|
305
|
+
preservation_levels.each do |preservation_level|
|
306
|
+
data = {
|
307
|
+
preservationLevelValue: preservation_level[:value],
|
308
|
+
preservationLevelRole: preservation_level[:role],
|
309
|
+
preservationLevelRationale: preservation_level[:rationale],
|
310
|
+
preservationLevelDateAssigned: preservation_level[:date],
|
311
|
+
}.cleanup
|
312
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
313
|
+
end
|
314
|
+
tech_data << PreservationLevel.new(array: data_list) unless data_list.empty?
|
315
|
+
end
|
316
|
+
# Inhibitor
|
317
|
+
if inhibitors
|
318
|
+
data_list = []
|
319
|
+
inhibitors.each do |inhibitor|
|
320
|
+
data = {
|
321
|
+
inhibitorType: inhibitor[:type],
|
322
|
+
inhibitorTarget: inhibitor[:target],
|
323
|
+
inhibitorKey: inhibitor[:key],
|
324
|
+
}.cleanup
|
325
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
326
|
+
end
|
327
|
+
tech_data << Inhibitor.new(array: data_list) unless data_list.empty?
|
328
|
+
end
|
329
|
+
# Dependencies
|
330
|
+
if env_dependencies
|
331
|
+
data_list = []
|
332
|
+
env_dependencies.each do |dependency|
|
333
|
+
data = {
|
334
|
+
dependencyName: dependency[:name],
|
335
|
+
dependencyIdentifierType1: dependency[:type1],
|
336
|
+
dependencyIdentifierValue1: dependency[:value1],
|
337
|
+
dependencyIdentifierType2: dependency[:type2],
|
338
|
+
dependencyIdentifierValue2: dependency[:value2],
|
339
|
+
dependencyIdentifierType3: dependency[:type3],
|
340
|
+
dependencyIdentifierValue3: dependency[:value3],
|
341
|
+
}.cleanup
|
342
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
343
|
+
end
|
344
|
+
tech_data << EnvDeps.new(array: data_list) unless data_list.empty?
|
345
|
+
end
|
346
|
+
# Hardware registry id
|
347
|
+
if hardware_ids
|
348
|
+
data_list = []
|
349
|
+
hardware_ids.each do |id|
|
350
|
+
data = {
|
351
|
+
registryId: id
|
352
|
+
}.cleanup
|
353
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
354
|
+
end
|
355
|
+
tech_data << HardwareId.new(array: data_list) unless data_list.empty?
|
356
|
+
end
|
357
|
+
# Software registry id
|
358
|
+
if software_ids
|
359
|
+
data_list = []
|
360
|
+
software_ids.each do |id|
|
361
|
+
data = {
|
362
|
+
registryId: id
|
363
|
+
}.cleanup
|
364
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
365
|
+
end
|
366
|
+
tech_data << SoftwareId.new(array: data_list) unless data_list.empty?
|
367
|
+
end
|
368
|
+
# Singatures
|
369
|
+
if signatures
|
370
|
+
data_list = []
|
371
|
+
signatures.each do |signature|
|
372
|
+
data = {
|
373
|
+
signatureInformationEncoding: signature[:encoding],
|
374
|
+
signer: signature[:signer],
|
375
|
+
signatureMethod: signature[:method],
|
376
|
+
signatureValue: signature[:value],
|
377
|
+
signatureValidationRules: signature[:rules],
|
378
|
+
signatureProperties: signature[:properties],
|
379
|
+
}.cleanup
|
380
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
381
|
+
end
|
382
|
+
tech_data << Signature.new(array: data_list) unless data_list.empty?
|
383
|
+
end
|
384
|
+
# Hardware
|
385
|
+
if hardware_infos
|
386
|
+
data_list = []
|
387
|
+
hardware_infos.each do |hardware|
|
388
|
+
data = {
|
389
|
+
hardwareName: hardware[:name],
|
390
|
+
hardwareType: hardware[:type],
|
391
|
+
hardwareOtherInformation: hardware[:info],
|
392
|
+
}.cleanup
|
393
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
394
|
+
end
|
395
|
+
tech_data << HardwareInfo.new(array: data_list) unless data_list.empty?
|
396
|
+
end
|
397
|
+
# Software
|
398
|
+
if software_infos
|
399
|
+
data_list = []
|
400
|
+
software_infos.each do |software|
|
401
|
+
data = {
|
402
|
+
softwareName: software[:name],
|
403
|
+
softwareVersion: software[:version],
|
404
|
+
softwareType: software[:type],
|
405
|
+
softwareOtherInformation: software[:info],
|
406
|
+
softwareDependancy: software[:dependency],
|
407
|
+
}.cleanup
|
408
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
409
|
+
end
|
410
|
+
tech_data << SoftwareInfo.new(array: data_list) unless data_list.empty?
|
411
|
+
end
|
412
|
+
# Relationship
|
413
|
+
if relationship_infos
|
414
|
+
data_list = []
|
415
|
+
relationship_infos.each do |relationship|
|
416
|
+
data = {
|
417
|
+
relationshipType: relationship[:type],
|
418
|
+
relationshipSubType: relationship[:subtype],
|
419
|
+
relatedObjectIdentifierType1: relationship[:type1],
|
420
|
+
relatedObjectIdentifierValue1: relationship[:id1],
|
421
|
+
relatedObjectSequence1: relationship[:seq1],
|
422
|
+
relatedObjectIdentifierType2: relationship[:type2],
|
423
|
+
relatedObjectIdentifierValue2: relationship[:id2],
|
424
|
+
relatedObjectSequence2: relationship[:seq2],
|
425
|
+
relatedObjectIdentifierType3: relationship[:type3],
|
426
|
+
relatedObjectIdentifierValue3: relationship[:id3],
|
427
|
+
relatedObjectSequence3: relationship[:seq3],
|
428
|
+
}.cleanup
|
429
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
430
|
+
end
|
431
|
+
tech_data << RelationShip.new(array: data_list) unless data_list.empty?
|
432
|
+
end
|
433
|
+
# Environment
|
434
|
+
if environments
|
435
|
+
data_list = []
|
436
|
+
environments.each do |environment|
|
437
|
+
data = {
|
438
|
+
environmentCharacteristic: environment[:characteristic],
|
439
|
+
environmentPurpose: environment[:purpose],
|
440
|
+
environmentNote: environment[:note],
|
441
|
+
}.cleanup
|
442
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
443
|
+
end
|
444
|
+
tech_data << Environment.new(array: data_list) unless data_list.empty?
|
445
|
+
end
|
446
|
+
# Application
|
447
|
+
if applications
|
448
|
+
data_list = []
|
449
|
+
applications.each do |application|
|
450
|
+
data = {
|
451
|
+
creatingApplicationName: application[:name],
|
452
|
+
creatingApplicationVersion: application[:version],
|
453
|
+
dateCreatedByApplication: application[:date],
|
454
|
+
}.cleanup
|
455
|
+
data_list << OpenStruct.new(data) unless data.empty?
|
456
|
+
end
|
457
|
+
tech_data << Application.new(array: data_list) unless data_list.empty?
|
458
|
+
end
|
459
|
+
# Finally assemble technical section
|
128
460
|
dnx[:tech] = tech_data unless tech_data.empty?
|
129
461
|
dnx
|
130
462
|
end
|
@@ -190,6 +522,10 @@ module Libis
|
|
190
522
|
end
|
191
523
|
end
|
192
524
|
|
525
|
+
class TechObjectChars < DnxSection
|
526
|
+
tag 'objectCharacteristics'
|
527
|
+
end
|
528
|
+
|
193
529
|
class TechGeneralIE < DnxSection
|
194
530
|
tag 'generalIECharacteristics'
|
195
531
|
end
|
@@ -214,6 +550,54 @@ module Libis
|
|
214
550
|
tag 'accessRightsPolicy'
|
215
551
|
end
|
216
552
|
|
553
|
+
class WebHarvesting < DnxSection
|
554
|
+
tag 'webHarvesting'
|
555
|
+
end
|
556
|
+
|
557
|
+
class PreservationLevel < DnxSection
|
558
|
+
tag 'preservationLevel'
|
559
|
+
end
|
560
|
+
|
561
|
+
class EnvDeps < DnxSection
|
562
|
+
tag 'environmentDependencies'
|
563
|
+
end
|
564
|
+
|
565
|
+
class HardwareId < DnxSection
|
566
|
+
tag 'envHardwareRegistry'
|
567
|
+
end
|
568
|
+
|
569
|
+
class SoftwareId < DnxSection
|
570
|
+
tag 'envSoftwareRegistry'
|
571
|
+
end
|
572
|
+
|
573
|
+
class HardwareInfo < DnxSection
|
574
|
+
tag 'environmentHardware'
|
575
|
+
end
|
576
|
+
|
577
|
+
class SoftwareInfo < DnxSection
|
578
|
+
tag 'environmentSoftware'
|
579
|
+
end
|
580
|
+
|
581
|
+
class Relationship < DnxSection
|
582
|
+
tag 'relationship'
|
583
|
+
end
|
584
|
+
|
585
|
+
class Environment < DnxSection
|
586
|
+
tag 'environment'
|
587
|
+
end
|
588
|
+
|
589
|
+
class Inhibitor < DnxSection
|
590
|
+
tag 'inhibitors'
|
591
|
+
end
|
592
|
+
|
593
|
+
class Signature < DnxSection
|
594
|
+
tag 'signatureInformation'
|
595
|
+
end
|
596
|
+
|
597
|
+
class Application < DnxSection
|
598
|
+
tag 'creatingApplication'
|
599
|
+
end
|
600
|
+
|
217
601
|
attr_reader :representations, :files, :divs, :maps
|
218
602
|
|
219
603
|
# noinspection RubyConstantNamingConvention
|
@@ -229,6 +613,8 @@ module Libis
|
|
229
613
|
@files = {}
|
230
614
|
@divs = {}
|
231
615
|
@maps = {}
|
616
|
+
@dnx = {}
|
617
|
+
@dc_record = nil
|
232
618
|
end
|
233
619
|
|
234
620
|
def self.parse(xml)
|
@@ -287,8 +673,8 @@ module Libis
|
|
287
673
|
)
|
288
674
|
hash_rep
|
289
675
|
end
|
290
|
-
{
|
291
|
-
|
676
|
+
{amd: amd_sec['ie-amd'],
|
677
|
+
dmd: dmd_sec['ie-dmd'],
|
292
678
|
}.cleanup.merge(
|
293
679
|
xml_doc.root.xpath('.//mets:structMap[@TYPE="PHYSICAL"]', NS).inject({}) do |hash_map, map|
|
294
680
|
rep_id = map[:ID].gsub(/-\d+$/, '')
|
@@ -329,17 +715,31 @@ module Libis
|
|
329
715
|
@dnx = {}
|
330
716
|
tech_data = []
|
331
717
|
data = {
|
718
|
+
groupID: hash[:group_id]
|
719
|
+
}.cleanup
|
720
|
+
tech_data << TechObjectChars.new(data) unless data.empty?
|
721
|
+
data = {
|
722
|
+
status: hash[:status],
|
332
723
|
IEEntityType: hash[:entity_type],
|
333
724
|
UserDefinedA: hash[:user_a],
|
334
725
|
UserDefinedB: hash[:user_b],
|
335
726
|
UserDefinedC: hash[:user_c],
|
336
|
-
|
727
|
+
submissionReason: hash[:submission_reason],
|
337
728
|
}.cleanup
|
338
729
|
tech_data << TechGeneralIE.new(data) unless data.empty?
|
339
730
|
data = {
|
340
731
|
policyId: hash[:retention_id],
|
341
732
|
}.cleanup
|
342
733
|
tech_data << RetentionPeriod.new(data) unless data.empty?
|
734
|
+
data = {
|
735
|
+
primarySeedURL: hash[:harvest_url],
|
736
|
+
WCTIdentifier: hash[:harvest_id],
|
737
|
+
targetName: hash[:harvest_target],
|
738
|
+
group: hash[:harvest_group],
|
739
|
+
harvestDate: hash[:harvest_date],
|
740
|
+
harvestTime: hash[:harvest_time],
|
741
|
+
}.cleanup
|
742
|
+
tech_data << WebHarvesting.new(data) unless data.empty?
|
343
743
|
@dnx[:tech] = tech_data unless tech_data.empty?
|
344
744
|
data = {
|
345
745
|
policyId: hash[:access_right]
|
@@ -347,6 +747,9 @@ module Libis
|
|
347
747
|
rights_data = []
|
348
748
|
rights_data << Rights.new(data) unless data.empty?
|
349
749
|
@dnx[:rights] = rights_data unless rights_data.empty?
|
750
|
+
(hash[:source_metadata] || []).each_with_index do |metadata, i|
|
751
|
+
@dnx["source-#{metadata[:type].to_s.upcase}-#{i+1}"] = metadata[:data]
|
752
|
+
end
|
350
753
|
end
|
351
754
|
|
352
755
|
# @param [Hash] hash
|
@@ -488,7 +891,7 @@ module Libis
|
|
488
891
|
TYPE: 'PHYSICAL',
|
489
892
|
) {
|
490
893
|
xml[:mets].div(LABEL: map.representation.label) {
|
491
|
-
add_struct_map(xml, map.
|
894
|
+
add_struct_map(xml, map.diqv) if map.div
|
492
895
|
}
|
493
896
|
}
|
494
897
|
end
|
@@ -519,7 +922,7 @@ module Libis
|
|
519
922
|
xml[:mets].dmdSec(ID: dmd_id(id)) {
|
520
923
|
xml[:mets].mdWrap(MDTYPE: 'DC') {
|
521
924
|
xml[:mets].xmlData {
|
522
|
-
xml << dc_record
|
925
|
+
xml[:dc] << dc_record
|
523
926
|
}
|
524
927
|
}
|
525
928
|
}
|
@@ -527,29 +930,42 @@ module Libis
|
|
527
930
|
|
528
931
|
def add_amd_section(xml, id, dnx_sections = {})
|
529
932
|
xml[:mets].amdSec(ID: amd_id(id)) {
|
530
|
-
|
531
|
-
|
532
|
-
xml[:mets].
|
533
|
-
xml[:mets].
|
534
|
-
|
933
|
+
dnx_sections.each do |section_type, data|
|
934
|
+
if section_type.to_s =~ /^source-(.*)-\d+$/
|
935
|
+
xml[:mets].send('sourceMD', ID: "#{amd_id(id)}-#{section_type.to_s}") {
|
936
|
+
xml[:mets].mdWrap(MDTYPE: $1) {
|
937
|
+
xml[:mets].xmlData {
|
938
|
+
xml << data
|
939
|
+
}
|
535
940
|
}
|
536
941
|
}
|
537
|
-
|
942
|
+
else
|
943
|
+
xml[:mets].send("#{section_type}MD", ID: "#{amd_id(id)}-#{section_type.to_s}") {
|
944
|
+
xml[:mets].mdWrap(MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx') {
|
945
|
+
xml[:mets].xmlData {
|
946
|
+
add_dnx_sections(xml, data)
|
947
|
+
}
|
948
|
+
}
|
949
|
+
}
|
950
|
+
end
|
538
951
|
end
|
539
952
|
}
|
540
953
|
end
|
541
954
|
|
542
955
|
def add_dnx_sections(xml, section_data)
|
543
956
|
section_data ||= []
|
544
|
-
xml
|
957
|
+
xml.dnx(xmlns: NS[:dnx]) {
|
545
958
|
(section_data).each do |section|
|
546
959
|
xml.section(id: section.tag) {
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
960
|
+
records = section[:array] || [section]
|
961
|
+
records.each do |data|
|
962
|
+
xml.record {
|
963
|
+
data.each_pair do |key, value|
|
964
|
+
next if value.nil?
|
965
|
+
xml.key(value, id: key)
|
966
|
+
end
|
967
|
+
}
|
968
|
+
end
|
553
969
|
}
|
554
970
|
end
|
555
971
|
}
|
data/lib/libis/tools/version.rb
CHANGED
@@ -215,7 +215,7 @@ module Libis
|
|
215
215
|
def build(at_node = nil, options = {}, &block)
|
216
216
|
options = {encoding: 'utf-8' }.merge options
|
217
217
|
if at_node
|
218
|
-
|
218
|
+
Nokogiri::XML::Builder.new(options,at_node, &block)
|
219
219
|
else
|
220
220
|
xml = Nokogiri::XML::Builder.new(options, &block)
|
221
221
|
@document = xml.doc
|
@@ -29,13 +29,13 @@ describe 'DublinCoreRecord' do
|
|
29
29
|
context 'Empty record' do
|
30
30
|
let(:data) { nil }
|
31
31
|
let(:root) { <<STR.chomp
|
32
|
-
<record \
|
32
|
+
<dc:record \
|
33
33
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
|
34
34
|
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/"
|
35
35
|
STR
|
36
36
|
}
|
37
37
|
let(:record_start) { root + '>' }
|
38
|
-
let(:record_end) { '</record>' }
|
38
|
+
let(:record_end) { '</dc:record>' }
|
39
39
|
let(:empty_record) { header + root + '/>' }
|
40
40
|
|
41
41
|
|
@@ -93,7 +93,7 @@ describe 'Marc21Record' do
|
|
93
93
|
record.extend Libis::Tools::Metadata::Mappers::Kuleuven
|
94
94
|
xml_doc = Libis::Tools::XmlDocument.parse <<STR
|
95
95
|
<?xml version="1.0" encoding="utf-8"?>
|
96
|
-
<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/">
|
96
|
+
<dc:record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/">
|
97
97
|
<dc:identifier>urn:ControlNumber:9921543960101471</dc:identifier>
|
98
98
|
<dc:identifier>(BeLVLBS)002154396LBS01-Aleph</dc:identifier>
|
99
99
|
<dc:identifier>8389207</dc:identifier>
|
@@ -103,7 +103,7 @@ describe 'Marc21Record' do
|
|
103
103
|
<dc:date>1722 - 1724</dc:date>
|
104
104
|
<dcterms:extent>8o: 4 v.; [22], 298, [8]; [16], 354, [1]; [16], 299, [7]; [16], 271, [5] p.</dcterms:extent>
|
105
105
|
<dc:language/>
|
106
|
-
</record>
|
106
|
+
</dc:record>
|
107
107
|
STR
|
108
108
|
expect(record.to_dc.root).to be_equivalent_to(xml_doc.root).respecting_element_order
|
109
109
|
record.to_dc.elements.each_with_index do |element, i|
|
@@ -0,0 +1,218 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative 'spec_helper'
|
3
|
+
require 'rspec/matchers'
|
4
|
+
require 'equivalent-xml'
|
5
|
+
require 'libis/tools/mets_file'
|
6
|
+
require 'libis/tools/xml_document'
|
7
|
+
|
8
|
+
describe 'METS File' do
|
9
|
+
|
10
|
+
before(:all) do
|
11
|
+
::Libis::Tools::Config << {appname: 'LIBIS Default'}
|
12
|
+
end
|
13
|
+
|
14
|
+
subject(:mets_file) { ::Libis::Tools::MetsFile.new }
|
15
|
+
|
16
|
+
context 'without data' do
|
17
|
+
|
18
|
+
let(:skeleton) {
|
19
|
+
::Libis::Tools::XmlDocument.build do |xml|
|
20
|
+
# noinspection RubyResolve
|
21
|
+
xml[:mets].mets 'xmlns:mets' => 'http://www.loc.gov/METS/' do
|
22
|
+
xml[:mets].amdSec 'ID' => 'ie-amd'
|
23
|
+
xml[:mets].fileSec
|
24
|
+
end
|
25
|
+
end.document
|
26
|
+
}
|
27
|
+
|
28
|
+
it 'generates skeleton XML' do
|
29
|
+
expect(mets_file.xml_doc.root).to be_equivalent_to skeleton.root
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with IE AMD' do
|
35
|
+
|
36
|
+
let(:dc_record) {
|
37
|
+
record = Libis::Tools::Metadata::DublinCoreRecord.new
|
38
|
+
record.title = 'Title'
|
39
|
+
record.author = 'Author'
|
40
|
+
record.subject = 'Subject'
|
41
|
+
record
|
42
|
+
}
|
43
|
+
|
44
|
+
let(:marc_record) {
|
45
|
+
Libis::Tools::XmlDocument.parse <<-STR
|
46
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
47
|
+
<record xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
|
48
|
+
xmlns="http://www.loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
49
|
+
<leader>abcdefghiljklmnopqrstuvwxyz</leader>
|
50
|
+
<controlfield tag="001">1234567890</controlfield>
|
51
|
+
<datafield tag="010" ind1="a" ind2="b">
|
52
|
+
<subfield code="a">abc</subfield>
|
53
|
+
<subfield code="b">xyz</subfield>
|
54
|
+
</datafield>
|
55
|
+
</record>
|
56
|
+
STR
|
57
|
+
}
|
58
|
+
|
59
|
+
let(:src_record) {
|
60
|
+
Libis::Tools::XmlDocument.parse <<-STR
|
61
|
+
<my_description xmlns="http://www.libis.be/description/">
|
62
|
+
<title>Title</title>
|
63
|
+
<importance>high</importance>
|
64
|
+
<location>here</location>
|
65
|
+
</my_description>
|
66
|
+
STR
|
67
|
+
}
|
68
|
+
|
69
|
+
let(:target) {
|
70
|
+
# noinspection RubyResolve
|
71
|
+
::Libis::Tools::XmlDocument.build do |xml|
|
72
|
+
# noinspection RubyResolve
|
73
|
+
xml[:mets].mets 'xmlns:mets' => 'http://www.loc.gov/METS/' do
|
74
|
+
# noinspection RubyResolve
|
75
|
+
xml[:mets].amdSec ID: 'ie-amd' do
|
76
|
+
# noinspection RubyResolve
|
77
|
+
xml[:mets].techMD ID: 'ie-amd-tech' do
|
78
|
+
# noinspection RubyResolve
|
79
|
+
xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
|
80
|
+
# noinspection RubyResolve
|
81
|
+
xml[:mets].xmlData do
|
82
|
+
xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
|
83
|
+
# noinspection RubyResolve
|
84
|
+
xml.section.objectCharacteristics! do
|
85
|
+
xml.record do
|
86
|
+
# noinspection RubyResolve
|
87
|
+
xml.key.groupID! 'group_id'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
# noinspection RubyResolve
|
91
|
+
xml.section.generalIECharacteristics! do
|
92
|
+
# noinspection RubyResolve
|
93
|
+
xml.record do
|
94
|
+
xml.key.status! 'status'
|
95
|
+
xml.key.IEEntityType! 'entity_type'
|
96
|
+
xml.key.UserDefinedA! 'user_a'
|
97
|
+
xml.key.UserDefinedB! 'user_b'
|
98
|
+
xml.key.UserDefinedC! 'user_c'
|
99
|
+
xml.key.submissionReason! 'submission_reason'
|
100
|
+
end
|
101
|
+
end
|
102
|
+
# noinspection RubyResolve
|
103
|
+
xml.section.retentionPolicy! do
|
104
|
+
# noinspection RubyResolve
|
105
|
+
xml.record do
|
106
|
+
xml.key.policyId! 'retention_id'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
# noinspection RubyResolve
|
110
|
+
xml.section.webHarvesting! do
|
111
|
+
# noinspection RubyResolve
|
112
|
+
xml.record do
|
113
|
+
xml.key.primarySeedURL! 'harvest_url'
|
114
|
+
xml.key.WCTIdentifier! 'harvest_id'
|
115
|
+
xml.key.targetName! 'harvest_target'
|
116
|
+
xml.key.group! 'harvest_group'
|
117
|
+
xml.key.harvestDate! 'harvest_date'
|
118
|
+
xml.key.harvestTime! 'harvest_time'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
# noinspection RubyResolve
|
126
|
+
xml[:mets].rightsMD ID: 'ie-amd-rights' do
|
127
|
+
# noinspection RubyResolve
|
128
|
+
xml[:mets].mdWrap MDTYPE: 'OTHER', OTHERMDTYPE: 'dnx' do
|
129
|
+
# noinspection RubyResolve
|
130
|
+
xml[:mets].xmlData do
|
131
|
+
xml.dnx xmlns: 'http://www.exlibrisgroup.com/dps/dnx' do
|
132
|
+
# noinspection RubyResolve
|
133
|
+
xml.section.accessRightsPolicy! do
|
134
|
+
# noinspection RubyResolve
|
135
|
+
xml.record do
|
136
|
+
xml.key.policyId! 'access_right'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
# noinspection RubyResolve
|
144
|
+
xml[:mets].sourceMD ID: 'ie-amd-source-DC-1' do
|
145
|
+
# noinspection RubyResolve
|
146
|
+
xml[:mets].mdWrap MDTYPE: 'DC' do
|
147
|
+
# noinspection RubyResolve
|
148
|
+
xml[:mets].xmlData do
|
149
|
+
# xml.parent.namespace = xml.parent.namespace_definitions.first
|
150
|
+
xml.parent << dc_record.root.to_xml
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
# noinspection RubyResolve
|
155
|
+
xml[:mets].sourceMD ID: 'ie-amd-source-MARC-2' do
|
156
|
+
# noinspection RubyResolve
|
157
|
+
xml[:mets].mdWrap MDTYPE: 'MARC' do
|
158
|
+
# noinspection RubyResolve
|
159
|
+
xml[:mets].xmlData do
|
160
|
+
# xml.parent.namespace = xml.parent.namespace_definitions.first
|
161
|
+
xml.parent << marc_record.root.to_xml
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
# noinspection RubyResolve
|
166
|
+
xml[:mets].sourceMD ID: 'ie-amd-source-OTHER-3' do
|
167
|
+
# noinspection RubyResolve
|
168
|
+
xml[:mets].mdWrap MDTYPE: 'OTHER' do
|
169
|
+
# noinspection RubyResolve
|
170
|
+
xml[:mets].xmlData do
|
171
|
+
# xml.namespace = xml.parent.namespace_definitions.first
|
172
|
+
xml.parent << src_record.root.to_xml
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
xml[:mets].fileSec
|
178
|
+
end
|
179
|
+
end.document
|
180
|
+
}
|
181
|
+
|
182
|
+
it 'fills in IE-AMD section' do
|
183
|
+
mets_file.amd_info = {
|
184
|
+
group_id: 'group_id',
|
185
|
+
status: 'status',
|
186
|
+
entity_type: 'entity_type',
|
187
|
+
user_a: 'user_a',
|
188
|
+
user_b: 'user_b',
|
189
|
+
user_c: 'user_c',
|
190
|
+
submission_reason: 'submission_reason',
|
191
|
+
retention_id: 'retention_id',
|
192
|
+
harvest_url: 'harvest_url',
|
193
|
+
harvest_id: 'harvest_id',
|
194
|
+
harvest_target: 'harvest_target',
|
195
|
+
harvest_group: 'harvest_group',
|
196
|
+
harvest_date: 'harvest_date',
|
197
|
+
harvest_time: 'harvest_time',
|
198
|
+
access_right: 'access_right',
|
199
|
+
source_metadata: [
|
200
|
+
{
|
201
|
+
type: 'DC',
|
202
|
+
data: dc_record.root.to_xml
|
203
|
+
}, {
|
204
|
+
type: 'Marc',
|
205
|
+
data: marc_record.root.to_xml
|
206
|
+
}, {
|
207
|
+
type: 'other',
|
208
|
+
data: src_record.root.to_xml
|
209
|
+
}
|
210
|
+
]
|
211
|
+
}
|
212
|
+
|
213
|
+
expect(mets_file.xml_doc.root).to be_equivalent_to target.root
|
214
|
+
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libis-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kris Dekeyser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -267,6 +267,7 @@ files:
|
|
267
267
|
- spec/metadata/marc21_parser_spec.rb
|
268
268
|
- spec/metadata/marc21_spec.rb
|
269
269
|
- spec/metadata/metadata_mapper_spec.rb
|
270
|
+
- spec/mets_file_spec.rb
|
270
271
|
- spec/parameter_container_spec.rb
|
271
272
|
- spec/parameter_spec.rb
|
272
273
|
- spec/spec_helper.rb
|
@@ -320,6 +321,7 @@ test_files:
|
|
320
321
|
- spec/metadata/marc21_parser_spec.rb
|
321
322
|
- spec/metadata/marc21_spec.rb
|
322
323
|
- spec/metadata/metadata_mapper_spec.rb
|
324
|
+
- spec/mets_file_spec.rb
|
323
325
|
- spec/parameter_container_spec.rb
|
324
326
|
- spec/parameter_spec.rb
|
325
327
|
- spec/spec_helper.rb
|