odrl-ruby 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +16 -16
- data/CHANGELOG.md +5 -5
- data/Gemfile +12 -12
- data/Gemfile.lock +249 -249
- data/LICENSE.txt +21 -21
- data/README.md +128 -127
- data/Rakefile +8 -8
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/examples/biohackathon-output.ttl +63 -63
- data/examples/build_profile.rb +48 -47
- data/examples/create-biohackathon-offer.rb +44 -44
- data/examples/create-nagoya-es-offer.rb +54 -54
- data/examples/nagoya-output.ttl +66 -66
- data/launch.json +10 -10
- data/lib/odrl/action.rb +106 -106
- data/lib/odrl/asset.rb +77 -77
- data/lib/odrl/base.rb +230 -230
- data/lib/odrl/constraint.rb +110 -110
- data/lib/odrl/odrl/version.rb +7 -7
- data/lib/odrl/party.rb +97 -97
- data/lib/odrl/policy.rb +97 -97
- data/lib/odrl/profile/builder.rb +348 -186
- data/lib/odrl/ruby.rb +26 -26
- data/lib/odrl/rule.rb +116 -116
- metadata +8 -6
data/lib/odrl/profile/builder.rb
CHANGED
@@ -1,186 +1,348 @@
|
|
1
|
-
require "linkeddata"
|
2
|
-
|
3
|
-
RDFS = RDF::Vocabulary.new("http://www.w3.org/2000/01/rdf-schema#")
|
4
|
-
DCAT = RDF::Vocabulary.new("http://www.w3.org/ns/dcat#")
|
5
|
-
DC = RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/")
|
6
|
-
DCT = RDF::Vocabulary.new("http://purl.org/dc/terms/")
|
7
|
-
FUND = RDF::Vocabulary.new("http://vocab.ox.ac.uk/projectfunding#")
|
8
|
-
SKOS = RDF::Vocabulary.new("http://www.w3.org/2004/02/skos/core#")
|
9
|
-
ODRLV = RDF::Vocabulary.new("http://www.w3.org/ns/odrl/2/")
|
10
|
-
OBO = RDF::Vocabulary.new("http://purl.obolibrary.org/obo/")
|
11
|
-
XSD = RDF::Vocabulary.new("http://www.w3.org/2001/XMLSchema#")
|
12
|
-
SCHEMA = RDF::Vocabulary.new("https://schema.org/")
|
13
|
-
OWL = RDF::Vocabulary.new("http://www.w3.org/2002/07/owl#")
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
attr_accessor :
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
@
|
25
|
-
@title = title
|
26
|
-
@description = description
|
27
|
-
@
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
class
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
1
|
+
require "linkeddata"
|
2
|
+
|
3
|
+
RDFS = RDF::Vocabulary.new("http://www.w3.org/2000/01/rdf-schema#")
|
4
|
+
DCAT = RDF::Vocabulary.new("http://www.w3.org/ns/dcat#")
|
5
|
+
DC = RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/")
|
6
|
+
DCT = RDF::Vocabulary.new("http://purl.org/dc/terms/")
|
7
|
+
FUND = RDF::Vocabulary.new("http://vocab.ox.ac.uk/projectfunding#")
|
8
|
+
SKOS = RDF::Vocabulary.new("http://www.w3.org/2004/02/skos/core#")
|
9
|
+
ODRLV = RDF::Vocabulary.new("http://www.w3.org/ns/odrl/2/")
|
10
|
+
OBO = RDF::Vocabulary.new("http://purl.obolibrary.org/obo/")
|
11
|
+
XSD = RDF::Vocabulary.new("http://www.w3.org/2001/XMLSchema#")
|
12
|
+
SCHEMA = RDF::Vocabulary.new("https://schema.org/")
|
13
|
+
OWL = RDF::Vocabulary.new("http://www.w3.org/2002/07/owl#")
|
14
|
+
PROFILE = RDF::Vocabulary.new("http://www.w3.org/ns/dx/prof/")
|
15
|
+
|
16
|
+
module ODRL
|
17
|
+
module Profile
|
18
|
+
class Builder
|
19
|
+
attr_accessor :uri, :repository, :title, :description, :authors, :version, :license, :prefix, :separator, :fullURI
|
20
|
+
attr_accessor :prefixes, :policies, :permissions, :prohibitions, :duties, :asset_relations, :party_functional_roles, :actions, :leftOperands, :rightOperands, :operators, :skosMembers
|
21
|
+
|
22
|
+
# attr_accessor :logicalConstraints, :conflict_strategies, :rules
|
23
|
+
def initialize(uri:, title:, description:, authors:, version:, license:, prefix: "ex", separator: "#")
|
24
|
+
@uri = uri
|
25
|
+
@title = title
|
26
|
+
@description = description
|
27
|
+
@authors = authors
|
28
|
+
@version = version
|
29
|
+
@license = license
|
30
|
+
@prefix = prefix
|
31
|
+
@separator = separator
|
32
|
+
@repository = RDF::Repository.new
|
33
|
+
@prefixes = {}
|
34
|
+
@policies = []
|
35
|
+
@permissions = []
|
36
|
+
@prohibitions = []
|
37
|
+
@duties = []
|
38
|
+
@asset_relations = []
|
39
|
+
@party_functional_roles = []
|
40
|
+
@actions = []
|
41
|
+
@leftOperands = []
|
42
|
+
@rightOperands = []
|
43
|
+
@operators = []
|
44
|
+
@skosMembers = []
|
45
|
+
|
46
|
+
@fullURI = @uri + @separator
|
47
|
+
|
48
|
+
@prefixes.store(@prefix, @fullURI)
|
49
|
+
|
50
|
+
ODRL::Profile::Builder.triplify(@uri, RDF.type, OWL.Ontology, @repository)
|
51
|
+
ODRL::Profile::Builder.triplify(@uri, RDF.type, PROFILE.Profile, @repository)
|
52
|
+
ODRL::Profile::Builder.triplify(@uri, RDFS.label, @title, @repository)
|
53
|
+
ODRL::Profile::Builder.triplify(@uri, OWL.versionInfo, @version, @repository, skip_type_or_language: true)
|
54
|
+
ODRL::Profile::Builder.triplify(@uri, DCT.title, @title, @repository)
|
55
|
+
ODRL::Profile::Builder.triplify(@uri, DCT.description, @description, @repository)
|
56
|
+
ODRL::Profile::Builder.triplify(@uri, DCT.license, @license, @repository)
|
57
|
+
|
58
|
+
@authors.each do |author|
|
59
|
+
ODRL::Profile::Builder.triplify(@uri, DCT.creator, author, @repository, skip_type_or_language: true)
|
60
|
+
end
|
61
|
+
|
62
|
+
# SKOS
|
63
|
+
ODRL::Profile::Builder.triplify(@fullURI, RDF.type, SKOS.Collection, @repository)
|
64
|
+
ODRL::Profile::Builder.triplify(@fullURI, SKOS.prefLabel, "Profile Vocabulary", @repository)
|
65
|
+
end
|
66
|
+
|
67
|
+
def build
|
68
|
+
repo = repository # just shorter :-)
|
69
|
+
|
70
|
+
[policies, permissions, prohibitions, duties, asset_relations, party_functional_roles, actions, leftOperands, rightOperands, operators].flatten.each do |elem|
|
71
|
+
ODRL::Profile::Builder.triplify(elem.uri, RDFS.isDefinedBy, @fullURI, repo)
|
72
|
+
elem.parent_property and ODRL::Profile::Builder.triplify(elem.uri, RDFS.subPropertyOf, elem.parent_property, repo)
|
73
|
+
elem.parent_class and ODRL::Profile::Builder.triplify(elem.uri, RDFS.subClassOf, elem.parent_class, repo)
|
74
|
+
|
75
|
+
elem.build(repo: repo)
|
76
|
+
|
77
|
+
@skosMembers << elem.uri
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def build_skos(uri, members, label, repo)
|
82
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Collection, repo)
|
83
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.prefLabel, label, repo)
|
84
|
+
|
85
|
+
members.each do |member|
|
86
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.member, member.uri, repo)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def serialize(format: :turtle)
|
91
|
+
format = format.to_sym
|
92
|
+
|
93
|
+
## All profile SKOS members
|
94
|
+
@skosMembers.each do |member|
|
95
|
+
ODRL::Profile::Builder.triplify(@fullURI, SKOS.member, member, @repository)
|
96
|
+
end
|
97
|
+
|
98
|
+
## Specific profile SKOS members
|
99
|
+
@policies.length > 0 and build_skos(@fullURI + "policies", @policies, "Policies", @repository)
|
100
|
+
@permissions.length > 0 and build_skos(@fullURI + "permissions", @permissions, "Permissions", @repository)
|
101
|
+
@prohibitions.length > 0 and build_skos(@fullURI + "prohibitions", @prohibitions, "Prohibitions", @repository)
|
102
|
+
@duties.length > 0 and build_skos(@fullURI + "duties", @duties, "Duties", @repository)
|
103
|
+
@actions.length > 0 and build_skos(@fullURI + "actions", @actions, "Actions for Rules", @repository)
|
104
|
+
@asset_relations.length > 0 and build_skos(@fullURI + "asset_relations", @asset_relations, "Asset Relations", @repository)
|
105
|
+
@party_functional_roles.length > 0 and build_skos(@fullURI + "partyFunctions", @party_functional_roles, "Party Functions", @repository)
|
106
|
+
@leftOperands.length > 0 and build_skos(@fullURI + "constraintLeftOperand", @leftOperands, "Left Operands", @repository)
|
107
|
+
@rightOperands.length > 0 and build_skos(@fullURI + "constraintRightOperand", @rightOperands, "Right Operands", @repository)
|
108
|
+
@operators.length > 0 and build_skos(@fullURI + "operators", @operators, "Operators", @repository)
|
109
|
+
|
110
|
+
w = get_writer(type: format)
|
111
|
+
w.dump(repository, nil, prefixes: @prefixes)
|
112
|
+
end
|
113
|
+
|
114
|
+
def get_writer(type: :turtle)
|
115
|
+
RDF::Writer.for(type)
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.triplify(s, p, o, repo, skip_type_or_language: false)
|
119
|
+
s = s.strip if s.instance_of?(String)
|
120
|
+
p = p.strip if p.instance_of?(String)
|
121
|
+
o = o.strip if o.instance_of?(String)
|
122
|
+
|
123
|
+
unless s.respond_to?("uri")
|
124
|
+
|
125
|
+
raise "Subject #{s} must be a URI-compatible thingy #{s}, #{p}, #{o}" unless s.to_s =~ %r{^\w+:/?/?[^\s]+}
|
126
|
+
|
127
|
+
s = RDF::URI.new(s.to_s)
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
unless p.respond_to?("uri")
|
132
|
+
|
133
|
+
raise "Predicate #{p} must be a URI-compatible thingy #{s}, #{p}, #{o}" unless p.to_s =~ %r{^\w+:/?/?[^\s]+}
|
134
|
+
|
135
|
+
p = RDF::URI.new(p.to_s)
|
136
|
+
|
137
|
+
end
|
138
|
+
unless o.respond_to?("uri")
|
139
|
+
o = if o.to_s =~ %r{^\w+:/?/?[^\s]+}
|
140
|
+
RDF::URI.new(o.to_s)
|
141
|
+
elsif o.to_s =~ /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d/
|
142
|
+
RDF::Literal.new(o.to_s, datatype: (RDF::XSD.date if skip_type_or_language == false))
|
143
|
+
elsif o.to_s =~ /^\d\.\d/
|
144
|
+
RDF::Literal.new(o.to_s, datatype: (RDF::XSD.float if skip_type_or_language == false))
|
145
|
+
elsif o.to_s =~ /^[0-9]+$/
|
146
|
+
RDF::Literal.new(o.to_s, datatype: (RDF::XSD.int if skip_type_or_language == false))
|
147
|
+
else
|
148
|
+
RDF::Literal.new(o.to_s, language: (:en if skip_type_or_language == false))
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
triple = RDF::Statement(s, p, o)
|
153
|
+
repo.insert(triple)
|
154
|
+
|
155
|
+
true
|
156
|
+
end
|
157
|
+
end # end of Class Builder
|
158
|
+
|
159
|
+
class ProfileElement
|
160
|
+
attr_accessor :uri, :label, :definition, :parent_class, :parent_property
|
161
|
+
|
162
|
+
# parent_class => subClassOf
|
163
|
+
# parent_property => subPropertyOf
|
164
|
+
def initialize(uri:, label:, definition:, parent_class: nil, parent_property: nil, **_args)
|
165
|
+
@uri = uri
|
166
|
+
@label = label
|
167
|
+
@definition = definition
|
168
|
+
@parent_class = parent_class
|
169
|
+
@parent_property = parent_property
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
class Policy < ProfileElement
|
174
|
+
attr_accessor :disjoints
|
175
|
+
|
176
|
+
def initialize(disjoints: [], **args)
|
177
|
+
# Additional disjoints can added for custom policies
|
178
|
+
@disjoints = [
|
179
|
+
ODRLV.Agreement,
|
180
|
+
ODRLV.Offer,
|
181
|
+
ODRLV.Privacy,
|
182
|
+
ODRLV.Request,
|
183
|
+
ODRLV.Ticket,
|
184
|
+
ODRLV.Assertion
|
185
|
+
].concat(disjoints)
|
186
|
+
|
187
|
+
super(**args)
|
188
|
+
end
|
189
|
+
|
190
|
+
# ex:myPolicy a odrl:Policy .
|
191
|
+
def build(repo:)
|
192
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, RDFS.Class, repo)
|
193
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, OWL.Class, repo)
|
194
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Concept, repo)
|
195
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
196
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
197
|
+
|
198
|
+
# Required declarations of disjointedness
|
199
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.subClassOf, ODRLV.Policy, repo)
|
200
|
+
|
201
|
+
@disjoints.each do |disjoint|
|
202
|
+
ODRL::Profile::Builder.triplify(uri, OWL.disjointWith, disjoint, repo)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
# This class MUST NOT be used to add custom ODRL Rules. Instead, sublcasses of this class offered by the builder must be used.
|
208
|
+
# This class is used to define the common properties of ODRL rules.
|
209
|
+
# E.g: In a Policy, the newly CustomPermission has been created and can be used as follows:
|
210
|
+
# ex:myPolicy odrl:permission ex:myPermission .
|
211
|
+
# ex:myPermission a ex-profile:CustomPermission ; odrl:target <https://example.com/asset_01> ...
|
212
|
+
class Rule < ProfileElement
|
213
|
+
attr_accessor :disjoints
|
214
|
+
|
215
|
+
def initialize(disjoints: [], **args)
|
216
|
+
@disjoints = disjoints
|
217
|
+
|
218
|
+
super(**args)
|
219
|
+
end
|
220
|
+
|
221
|
+
def build(repo:)
|
222
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, RDFS.Class, repo)
|
223
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, OWL.Class, repo)
|
224
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Concept, repo)
|
225
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
226
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
227
|
+
|
228
|
+
@disjoints.each do |disjoint|
|
229
|
+
ODRL::Profile::Builder.triplify(uri, OWL.disjointWith, disjoint, repo)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
class Permission < Rule
|
235
|
+
def initialize(disjoints: [], **args)
|
236
|
+
super(disjoints: [ODRLV.Prohibition, ODRLV.Duty].concat(disjoints), **args)
|
237
|
+
end
|
238
|
+
|
239
|
+
def build(repo:)
|
240
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.subClassOf, ODRLV.Permission, repo)
|
241
|
+
|
242
|
+
super(repo: repo)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
class Prohibition < Rule
|
247
|
+
def initialize(disjoints: [], **args)
|
248
|
+
super(disjoints: [ODRLV.Permission, ODRLV.Duty].concat(disjoints), **args)
|
249
|
+
end
|
250
|
+
|
251
|
+
def build(repo:)
|
252
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.subClassOf, ODRLV.Prohibition, repo)
|
253
|
+
|
254
|
+
super(repo: repo)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
class Duty < Rule
|
259
|
+
def initialize(disjoints: [], **args)
|
260
|
+
super(disjoints: [ODRLV.Permission, ODRLV.Prohibition].concat(disjoints), **args)
|
261
|
+
end
|
262
|
+
|
263
|
+
def build(repo:)
|
264
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.subClassOf, ODRLV.Duty, repo)
|
265
|
+
|
266
|
+
super(repo: repo)
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
class AssetRelation < ProfileElement
|
271
|
+
# ex:myRelation rdfs:subPropertyOf odrl:relation .
|
272
|
+
def build(repo:)
|
273
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, RDF.Property, repo)
|
274
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, OWL.ObjectProperty, repo)
|
275
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Concept, repo)
|
276
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.subPropertyOf, ODRLV.relation, repo)
|
277
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
278
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
279
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.domain, ODRLV.Rule, repo)
|
280
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.range, ODRLV.Asset, repo)
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
class PartyFunction < ProfileElement
|
285
|
+
# ex:myFunctionRole rdfs:subPropertyOf odrl:function
|
286
|
+
def build(repo:)
|
287
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, RDF.Property, repo)
|
288
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, OWL.ObjectProperty, repo)
|
289
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Concept, repo)
|
290
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.subPropertyOf, ODRLV.function, repo)
|
291
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
292
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
class Action < ProfileElement
|
297
|
+
# ex:myAction a odrl:Action .
|
298
|
+
# ex:myAction odrl:includedIn odrl:use .
|
299
|
+
# ex:myAction odrl:implies odrl:distribute .
|
300
|
+
attr_accessor :implies, :included_in
|
301
|
+
|
302
|
+
def initialize(implies: nil, included_in: ODRLV.use, **args)
|
303
|
+
@implies = implies
|
304
|
+
@included_in = included_in
|
305
|
+
super(**args)
|
306
|
+
end
|
307
|
+
|
308
|
+
def build(repo:)
|
309
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.Action, repo)
|
310
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Concept, repo)
|
311
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
312
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
313
|
+
ODRL::Profile::Builder.triplify(uri, ODRLV.includedIn, included_in, repo)
|
314
|
+
return unless implies
|
315
|
+
ODRL::Profile::Builder.triplify(uri, ODRLV.implies, implies, repo)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
class LeftOperand < ProfileElement
|
320
|
+
# ex:myLeftOperand a odrl:LeftOperand .
|
321
|
+
def build(repo:)
|
322
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.LeftOperand, repo)
|
323
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, OWL.NamedIndividual, repo)
|
324
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, SKOS.Concept, repo)
|
325
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
326
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
class RightOperand < ProfileElement
|
331
|
+
# ex:myRightOperand a odrl:RightOperand .
|
332
|
+
def build(repo:)
|
333
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.RightOperand, repo)
|
334
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
335
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
class Operator < ProfileElement
|
340
|
+
# ex:myOperator a odrl:Operator .
|
341
|
+
def build(repo:)
|
342
|
+
ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.Operator, repo)
|
343
|
+
ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
|
344
|
+
ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
data/lib/odrl/ruby.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
require "linkeddata"
|
2
|
-
require "rdf/raptor"
|
3
|
-
|
4
|
-
# RDF = RDF::Vocabulary.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
|
5
|
-
|
6
|
-
RDFS = RDF::Vocabulary.new("http://www.w3.org/2000/01/rdf-schema#")
|
7
|
-
DCAT = RDF::Vocabulary.new("http://www.w3.org/ns/dcat#")
|
8
|
-
DC = RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/")
|
9
|
-
DCT = RDF::Vocabulary.new("http://purl.org/dc/terms/")
|
10
|
-
FUND = RDF::Vocabulary.new("http://vocab.ox.ac.uk/projectfunding#")
|
11
|
-
SKOS = RDF::Vocabulary.new("http://www.w3.org/2004/02/skos/core#")
|
12
|
-
ODRLV = RDF::Vocabulary.new("http://www.w3.org/ns/odrl/2/")
|
13
|
-
OBO = RDF::Vocabulary.new("http://purl.obolibrary.org/obo/")
|
14
|
-
XSD = RDF::Vocabulary.new("http://www.w3.org/2001/XMLSchema#")
|
15
|
-
SCHEMA = RDF::Vocabulary.new("https://schema.org/")
|
16
|
-
|
17
|
-
require_relative "base"
|
18
|
-
require_relative "action"
|
19
|
-
require_relative "asset"
|
20
|
-
require_relative "constraint"
|
21
|
-
require_relative "party"
|
22
|
-
require_relative "policy"
|
23
|
-
require_relative "rule"
|
24
|
-
|
25
|
-
module ODRL
|
26
|
-
end
|
1
|
+
require "linkeddata"
|
2
|
+
require "rdf/raptor"
|
3
|
+
|
4
|
+
# RDF = RDF::Vocabulary.new("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
|
5
|
+
|
6
|
+
RDFS = RDF::Vocabulary.new("http://www.w3.org/2000/01/rdf-schema#")
|
7
|
+
DCAT = RDF::Vocabulary.new("http://www.w3.org/ns/dcat#")
|
8
|
+
DC = RDF::Vocabulary.new("http://purl.org/dc/elements/1.1/")
|
9
|
+
DCT = RDF::Vocabulary.new("http://purl.org/dc/terms/")
|
10
|
+
FUND = RDF::Vocabulary.new("http://vocab.ox.ac.uk/projectfunding#")
|
11
|
+
SKOS = RDF::Vocabulary.new("http://www.w3.org/2004/02/skos/core#")
|
12
|
+
ODRLV = RDF::Vocabulary.new("http://www.w3.org/ns/odrl/2/")
|
13
|
+
OBO = RDF::Vocabulary.new("http://purl.obolibrary.org/obo/")
|
14
|
+
XSD = RDF::Vocabulary.new("http://www.w3.org/2001/XMLSchema#")
|
15
|
+
SCHEMA = RDF::Vocabulary.new("https://schema.org/")
|
16
|
+
|
17
|
+
require_relative "base"
|
18
|
+
require_relative "action"
|
19
|
+
require_relative "asset"
|
20
|
+
require_relative "constraint"
|
21
|
+
require_relative "party"
|
22
|
+
require_relative "policy"
|
23
|
+
require_relative "rule"
|
24
|
+
|
25
|
+
module ODRL
|
26
|
+
end
|