ddr-core 1.11.0 → 1.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +2 -3
- data/lib/ddr/core.rb +0 -5
- data/lib/ddr/index/query_result.rb +4 -2
- data/lib/ddr/structure.rb +12 -106
- data/lib/ddr/structures/div.rb +0 -5
- data/lib/ddr/structures/mptr.rb +9 -1
- metadata +3 -8
- data/lib/ddr/structures/f_locat.rb +0 -54
- data/lib/ddr/structures/file.rb +0 -52
- data/lib/ddr/structures/file_grp.rb +0 -35
- data/lib/ddr/structures/file_sec.rb +0 -22
- data/lib/ddr/structures/fptr.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1747ec2e17d7996e200306167e43b58e2dc131e90dc53e60cea8e743330d427e
|
4
|
+
data.tar.gz: 198b5d9ec8d996df0d90244e28b2256494f7dacd97e3f912f7f9aa35a0b43dd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66cb2bce2d80a04dcad5fa2fc4903ea3f2a73a98acb419ee108acaf8410864444f7e149f35fe841e672b070f06531fa5f750a053e73d1f13a1ef0bf4c9c96bc7
|
7
|
+
data.tar.gz: 1e13d74efb54b66264639ccefeecf9b9b0a07496d76bff8d93e7207562637bac6cd22e0376f0cfb2a6a61a5d9a09a82ee9a1eb1a6a8393dfa9301655adb4f4db
|
@@ -4,8 +4,7 @@ module Ddr
|
|
4
4
|
|
5
5
|
# An object can't be published if it's already published or not publishable
|
6
6
|
# It can't be unpublished if it's already unpublished
|
7
|
-
# It can't be made nonpublishable if it's already
|
8
|
-
# first) or already nonpublishable
|
7
|
+
# It can't be made nonpublishable if it's already nonpublishable
|
9
8
|
def call
|
10
9
|
cannot :publish, Ddr::Resource do |obj|
|
11
10
|
obj.published? || !obj.publishable?
|
@@ -14,7 +13,7 @@ module Ddr
|
|
14
13
|
!obj.published? && !obj.nonpublishable?
|
15
14
|
end
|
16
15
|
cannot :make_nonpublishable, Ddr::Resource do |obj|
|
17
|
-
obj.
|
16
|
+
obj.nonpublishable?
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
data/lib/ddr/core.rb
CHANGED
@@ -59,9 +59,11 @@ module Ddr::Index
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def objects
|
62
|
+
resource_factory = Valkyrie::MetadataAdapter.find(:index_solr).resource_factory
|
63
|
+
|
62
64
|
Enumerator.new do |e|
|
63
|
-
|
64
|
-
e <<
|
65
|
+
each do |obj|
|
66
|
+
e << resource_factory.to_resource(object: obj)
|
65
67
|
end
|
66
68
|
end
|
67
69
|
end
|
data/lib/ddr/structure.rb
CHANGED
@@ -11,43 +11,16 @@ module Ddr
|
|
11
11
|
|
12
12
|
TYPE_DEFAULT = 'default'.freeze
|
13
13
|
|
14
|
-
# Based on the PCDM Extension 'Use' ontology -- https://github.com/duraspace/pcdm/blob/master/pcdm-ext/use.rdf
|
15
|
-
USE_EXTRACTED_TEXT = 'ExtractedText'.freeze
|
16
|
-
USE_INTERMEDIATE_FILE = 'IntermediateFile'.freeze
|
17
|
-
USE_ORIGINAL_FILE = 'OriginalFile'.freeze
|
18
|
-
USE_PRESERVATION_MASTER_FILE = 'PreservationMasterFile'.freeze
|
19
|
-
USE_SERVICE_FILE = 'ServiceFile'.freeze
|
20
|
-
USE_THUMBNAIL_IMAGE = 'ThumbnailImage'.freeze
|
21
|
-
USE_TRANSCRIPT = 'Transcript'.freeze
|
22
|
-
|
23
|
-
def filesec
|
24
|
-
@filesec ||= Ddr::Structures::FileSec.new(fileSec_node)
|
25
|
-
end
|
26
|
-
|
27
|
-
def files
|
28
|
-
@files ||= collect_files
|
29
|
-
end
|
30
|
-
|
31
|
-
def uses
|
32
|
-
@uses ||= collect_uses
|
33
|
-
end
|
34
|
-
|
35
|
-
def structmap(type=nil)
|
36
|
-
sm = type ? structMap_node(type) : structMap_nodes.first
|
37
|
-
@structmap ||= Ddr::Structures::StructMap.new(sm)
|
38
|
-
end
|
39
|
-
|
40
14
|
def structmaps
|
41
15
|
@structmaps ||= structMap_nodes.map { |sm| Ddr::Structures::StructMap.new(sm) }
|
42
16
|
end
|
43
17
|
|
44
18
|
def metshdr
|
45
|
-
@metshdr ||=
|
19
|
+
@metshdr ||= Ddr::Structures::MetsHdr.new(metsHdr_node)
|
46
20
|
end
|
47
21
|
|
48
22
|
def creator
|
49
|
-
|
50
|
-
: Ddr::Structures::MetsHdr.new(metsHdr_node).agents.first.name
|
23
|
+
metshdr.agents.first&.name
|
51
24
|
end
|
52
25
|
|
53
26
|
def repository_maintained?
|
@@ -55,89 +28,49 @@ module Ddr
|
|
55
28
|
end
|
56
29
|
|
57
30
|
def dereferenced_structure
|
58
|
-
|
59
|
-
structmaps.each do |sm|
|
60
|
-
deref_struct[sm.type] = sm.dereferenced_hash
|
61
|
-
end
|
62
|
-
deref_struct
|
31
|
+
Hash[structmaps.map { |sm| [sm.type, sm.dereferenced_hash] }]
|
63
32
|
end
|
64
33
|
|
65
34
|
def as_xml_document
|
66
35
|
__getobj__
|
67
36
|
end
|
68
37
|
|
69
|
-
def add_metshdr(id:nil, createdate:nil, lastmoddate:nil, recordstatus:nil)
|
38
|
+
def add_metshdr(id: nil, createdate: nil, lastmoddate: nil, recordstatus: nil)
|
70
39
|
metshdr = Ddr::Structures::MetsHdr.build(id: id, createdate: createdate, lastmoddate: lastmoddate,
|
71
|
-
|
40
|
+
recordstatus: recordstatus, document: as_xml_document)
|
72
41
|
root.add_child(metshdr)
|
73
42
|
metshdr
|
74
43
|
end
|
75
44
|
|
76
|
-
def add_agent(parent:, id:nil, role:, otherrole:nil, type:nil, othertype:nil, name:nil)
|
45
|
+
def add_agent(parent:, id: nil, role:, otherrole: nil, type: nil, othertype: nil, name: nil)
|
77
46
|
agent = Ddr::Structures::Agent.build(id: id, role: role, otherrole: otherrole, type: type,
|
78
|
-
|
47
|
+
othertype: othertype, name: name, document: as_xml_document)
|
79
48
|
parent.add_child(agent)
|
80
49
|
agent
|
81
50
|
end
|
82
51
|
|
83
|
-
def
|
84
|
-
filesec = Ddr::Structures::FileSec.build(id: id, document: as_xml_document)
|
85
|
-
|
86
|
-
root.add_child(filesec)
|
87
|
-
filesec
|
88
|
-
end
|
89
|
-
|
90
|
-
def add_filegrp(parent:, id:nil, use:nil)
|
91
|
-
filegrp = Ddr::Structures::FileGrp.build(id: id, use: use, document: as_xml_document)
|
92
|
-
parent.add_child(filegrp)
|
93
|
-
filegrp
|
94
|
-
end
|
95
|
-
|
96
|
-
def add_file(parent:, id: "id_" + SecureRandom.uuid, use:nil)
|
97
|
-
file = Ddr::Structures::File.build(id: id, use: use, document: as_xml_document)
|
98
|
-
parent.add_child(file)
|
99
|
-
file
|
100
|
-
end
|
101
|
-
|
102
|
-
def add_flocat(parent:, id:nil, loctype:'ARK', otherloctype: nil, use:nil, href:)
|
103
|
-
flocat = Ddr::Structures::FLocat.build(id: id, loctype: loctype, otherloctype: otherloctype, use: use,
|
104
|
-
href: href, document: as_xml_document)
|
105
|
-
parent.add_child(flocat)
|
106
|
-
flocat
|
107
|
-
end
|
108
|
-
|
109
|
-
def add_structmap(id:nil, label:nil, type:)
|
52
|
+
def add_structmap(id: nil, label: nil, type:)
|
110
53
|
structmap = Ddr::Structures::StructMap.build(id: id, label: label, type: type, document: as_xml_document)
|
111
54
|
root.add_child(structmap)
|
112
55
|
structmap
|
113
56
|
end
|
114
57
|
|
115
|
-
def add_div(parent:, id:nil, label:nil, order:nil, orderlabel: nil, type:nil)
|
58
|
+
def add_div(parent:, id: nil, label: nil, order: nil, orderlabel: nil, type: nil)
|
116
59
|
div = Ddr::Structures::Div.build(id: id, label: label, order:order, orderlabel: orderlabel, type: type,
|
117
|
-
|
60
|
+
document: as_xml_document)
|
118
61
|
parent.add_child(div)
|
119
62
|
div
|
120
63
|
end
|
121
64
|
|
122
|
-
def
|
123
|
-
fptr = Ddr::Structures::Fptr.build(id: id, fileid: fileid, document: as_xml_document)
|
124
|
-
parent.add_child(fptr)
|
125
|
-
fptr
|
126
|
-
end
|
127
|
-
|
128
|
-
def add_mptr(parent:, id: nil, loctype:'ARK', otherloctype: nil, href:)
|
65
|
+
def add_mptr(parent:, id: nil, loctype: 'ARK', otherloctype: nil, href:)
|
129
66
|
mptr = Ddr::Structures::Mptr.build(id: id, loctype: loctype, otherloctype: otherloctype, href: href,
|
130
|
-
|
67
|
+
document: as_xml_document)
|
131
68
|
parent.add_child(mptr)
|
132
69
|
mptr
|
133
70
|
end
|
134
71
|
|
135
72
|
private
|
136
73
|
|
137
|
-
def fileSec_node
|
138
|
-
xpath("//xmlns:fileSec").first
|
139
|
-
end
|
140
|
-
|
141
74
|
def structMap_nodes
|
142
75
|
xpath("//xmlns:structMap")
|
143
76
|
end
|
@@ -150,33 +83,6 @@ module Ddr
|
|
150
83
|
xpath("//xmlns:metsHdr")
|
151
84
|
end
|
152
85
|
|
153
|
-
def file_nodes
|
154
|
-
xpath("//xmlns:file")
|
155
|
-
end
|
156
|
-
|
157
|
-
def flocat_nodes
|
158
|
-
xpath("//xmlns:FLocat")
|
159
|
-
end
|
160
|
-
|
161
|
-
def collect_files
|
162
|
-
files = {}
|
163
|
-
file_nodes.each do |file_node|
|
164
|
-
file = Ddr::Structures::File.new(file_node)
|
165
|
-
files[file.id] = file
|
166
|
-
end
|
167
|
-
files
|
168
|
-
end
|
169
|
-
|
170
|
-
def collect_uses
|
171
|
-
uses = {}
|
172
|
-
flocat_nodes.each do |flocat_node|
|
173
|
-
flocat = Ddr::Structures::FLocat.new(flocat_node)
|
174
|
-
uses[flocat.effective_use] ||= []
|
175
|
-
uses[flocat.effective_use] << flocat
|
176
|
-
end
|
177
|
-
uses
|
178
|
-
end
|
179
|
-
|
180
86
|
def self.xml_template
|
181
87
|
Nokogiri::XML(
|
182
88
|
'<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink" />'
|
data/lib/ddr/structures/div.rb
CHANGED
@@ -28,10 +28,6 @@ module Ddr::Structures
|
|
28
28
|
xpath('xmlns:div').map { |node| Div.new(node) }
|
29
29
|
end
|
30
30
|
|
31
|
-
def fptrs
|
32
|
-
xpath('xmlns:fptr').map { |node| Fptr.new(node) }
|
33
|
-
end
|
34
|
-
|
35
31
|
def mptrs
|
36
32
|
xpath('xmlns:mptr').map { |node| Mptr.new(node) }
|
37
33
|
end
|
@@ -43,7 +39,6 @@ module Ddr::Structures
|
|
43
39
|
def dereferenced_hash
|
44
40
|
contents = []
|
45
41
|
contents.concat(divs.map { |div| div.dereferenced_hash }) unless divs.empty?
|
46
|
-
contents.concat(fptrs.map { |fptr| fptr.dereferenced_hash }) unless fptrs.empty?
|
47
42
|
contents.concat(mptrs.map { |mptr| mptr.dereferenced_hash }) unless mptrs.empty?
|
48
43
|
dh = { id: id, label: label, order: order, orderlabel: orderlabel, type: type }.compact
|
49
44
|
dh[:contents] = contents unless contents.empty?
|
data/lib/ddr/structures/mptr.rb
CHANGED
@@ -24,12 +24,20 @@ module Ddr::Structures
|
|
24
24
|
loctype == 'ARK'
|
25
25
|
end
|
26
26
|
|
27
|
+
def urn?
|
28
|
+
loctype == 'URN'
|
29
|
+
end
|
30
|
+
|
27
31
|
def ark
|
28
32
|
href if ark?
|
29
33
|
end
|
30
34
|
|
31
35
|
def repo_id
|
32
|
-
|
36
|
+
if ark?
|
37
|
+
SolrDocument.find_by_permanent_id(ark).id
|
38
|
+
elsif urn?
|
39
|
+
href.sub(/^urn:uuid:/, '')
|
40
|
+
end
|
33
41
|
end
|
34
42
|
|
35
43
|
def dereferenced_hash
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddr-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Coble
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2022-
|
14
|
+
date: 2022-04-13 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activeresource
|
@@ -416,11 +416,6 @@ files:
|
|
416
416
|
- lib/ddr/structures/agent.rb
|
417
417
|
- lib/ddr/structures/component_type_term.rb
|
418
418
|
- lib/ddr/structures/div.rb
|
419
|
-
- lib/ddr/structures/f_locat.rb
|
420
|
-
- lib/ddr/structures/file.rb
|
421
|
-
- lib/ddr/structures/file_grp.rb
|
422
|
-
- lib/ddr/structures/file_sec.rb
|
423
|
-
- lib/ddr/structures/fptr.rb
|
424
419
|
- lib/ddr/structures/mets_hdr.rb
|
425
420
|
- lib/ddr/structures/mptr.rb
|
426
421
|
- lib/ddr/structures/struct_map.rb
|
@@ -452,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
452
447
|
- !ruby/object:Gem::Version
|
453
448
|
version: '0'
|
454
449
|
requirements: []
|
455
|
-
rubygems_version: 3.3.
|
450
|
+
rubygems_version: 3.3.11
|
456
451
|
signing_key:
|
457
452
|
specification_version: 4
|
458
453
|
summary: Models used in the Duke Digital Repository
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Ddr::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'FLocat' node
|
4
|
-
#
|
5
|
-
class FLocat < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def loctype
|
12
|
-
self['LOCTYPE']
|
13
|
-
end
|
14
|
-
|
15
|
-
def otherloctype
|
16
|
-
self['OTHERLOCTYPE']
|
17
|
-
end
|
18
|
-
|
19
|
-
def use
|
20
|
-
self['USE']
|
21
|
-
end
|
22
|
-
|
23
|
-
def href
|
24
|
-
self['xlink:href']
|
25
|
-
end
|
26
|
-
|
27
|
-
def ark?
|
28
|
-
loctype == 'ARK'
|
29
|
-
end
|
30
|
-
|
31
|
-
def ark
|
32
|
-
href if ark?
|
33
|
-
end
|
34
|
-
|
35
|
-
def effective_use
|
36
|
-
use ? use : File.new(parent).effective_use
|
37
|
-
end
|
38
|
-
|
39
|
-
def repo_id
|
40
|
-
SolrDocument.find_by_permanent_id(ark).id if ark?
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.build(args)
|
44
|
-
node = Nokogiri::XML::Node.new('FLocat', args[:document])
|
45
|
-
node['ID'] = args[:id] if args[:id]
|
46
|
-
node['LOCTYPE'] = args[:loctype] if args[:loctype]
|
47
|
-
node['OTHERLOCTYPE'] = args[:otherloctype] if args[:otherloctype]
|
48
|
-
node['USE'] = args[:use] if args[:use]
|
49
|
-
node['xlink:href'] = args[:href] if args[:href]
|
50
|
-
node
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
data/lib/ddr/structures/file.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
module Ddr::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'file' node
|
4
|
-
#
|
5
|
-
class File < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def use
|
12
|
-
self['USE']
|
13
|
-
end
|
14
|
-
|
15
|
-
def files
|
16
|
-
xpath('xmlns:file').map { |node| File.new(node) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def flocats
|
20
|
-
xpath('xmlns:FLocat').map { |node| FLocat.new(node) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def effective_use
|
24
|
-
if use
|
25
|
-
use
|
26
|
-
else
|
27
|
-
case parent.name
|
28
|
-
when "file"
|
29
|
-
File.new(parent).effective_use
|
30
|
-
when "fileGrp"
|
31
|
-
FileGrp.new(parent).effective_use
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def repo_ids
|
37
|
-
flocats.map(&:repo_id)
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.build(args)
|
41
|
-
node = Nokogiri::XML::Node.new('file', args[:document])
|
42
|
-
node['ID'] = args[:id] if args[:id]
|
43
|
-
node['USE'] = args[:use] if args[:use]
|
44
|
-
node
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.find(structure, fileid)
|
48
|
-
structure.files[fileid]
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Ddr::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'fileGrp' node
|
4
|
-
#
|
5
|
-
class FileGrp < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def use
|
12
|
-
self['USE']
|
13
|
-
end
|
14
|
-
|
15
|
-
def filegrps
|
16
|
-
xpath('xmlns:filegrp').map { |node| FileGrp.new(node) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def files
|
20
|
-
xpath('xmlns:file').map { |node| File.new(node) }
|
21
|
-
end
|
22
|
-
|
23
|
-
def effective_use
|
24
|
-
use
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.build(args)
|
28
|
-
node = Nokogiri::XML::Node.new('fileGrp', args[:document])
|
29
|
-
node['ID'] = args[:id] if args[:id]
|
30
|
-
node['USE'] = args[:use] if args[:use]
|
31
|
-
node
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Ddr::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'fileSec' node
|
4
|
-
#
|
5
|
-
class FileSec < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def filegrps
|
12
|
-
xpath('xmlns:fileGrp').map { |node| FileGrp.new(node) }
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.build(args)
|
16
|
-
node = Nokogiri::XML::Node.new('fileSec', args[:document])
|
17
|
-
node['ID'] = args[:id] if args[:id]
|
18
|
-
node
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
data/lib/ddr/structures/fptr.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Ddr::Structures
|
2
|
-
#
|
3
|
-
# Wraps a Nokogiri (XML) 'fptr' node
|
4
|
-
#
|
5
|
-
class Fptr < SimpleDelegator
|
6
|
-
|
7
|
-
def id
|
8
|
-
self['ID']
|
9
|
-
end
|
10
|
-
|
11
|
-
def fileid
|
12
|
-
self['FILEID']
|
13
|
-
end
|
14
|
-
|
15
|
-
def dereferenced_hash
|
16
|
-
structure = Ddr::Structure.new(document)
|
17
|
-
file = File.find(structure, fileid)
|
18
|
-
repo_id = file.repo_ids.first
|
19
|
-
use = file.flocats.first.effective_use
|
20
|
-
{ id: id, repo_id: repo_id, use: use }.compact
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.build(args)
|
24
|
-
node = Nokogiri::XML::Node.new('fptr', args[:document])
|
25
|
-
node['ID'] = args[:id] if args[:id]
|
26
|
-
node['FILEID'] = args[:fileid] if args[:fileid]
|
27
|
-
node
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|