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.
@@ -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
- module ODRL
16
- module Profile
17
- class Builder
18
- attr_accessor :uri, :profile_class, :repository, :title, :description, :author
19
- attr_accessor :asset_relations, :party_functional_roles, :actions, :leftOperands, :rightOperands, :operators
20
-
21
- # attr_accessor :logicalConstraints, :conflict_strategies, :rules
22
- def initialize(uri:, profile_class:, title:, description:, author:)
23
- @uri = uri
24
- @profile_class = profile_class
25
- @title = title
26
- @description = description
27
- @author = author
28
- @repository = RDF::Repository.new
29
- @asset_relations = []
30
- @party_functional_roles = []
31
- @actions = []
32
- @leftOperands = []
33
- @rightOperands = []
34
- @operators = []
35
- @asset_relations = []
36
-
37
- # Required declarations of disjointedness
38
- ODRL::Profile::Builder.triplify(@profile_class, RDFS.subClassOf, ODRLV.Policy, @repository)
39
- ODRL::Profile::Builder.triplify(@profile_class, OWL.disjointWith, ODRLV.Agreement, @repository)
40
- ODRL::Profile::Builder.triplify(@profile_class, OWL.disjointWith, ODRLV.Offer, @repository)
41
- ODRL::Profile::Builder.triplify(@profile_class, OWL.disjointWith, ODRLV.Privacy, @repository)
42
- ODRL::Profile::Builder.triplify(@profile_class, OWL.disjointWith, ODRLV.Request, @repository)
43
- ODRL::Profile::Builder.triplify(@profile_class, OWL.disjointWith, ODRLV.Ticket, @repository)
44
- ODRL::Profile::Builder.triplify(@profile_class, OWL.disjointWith, ODRLV.Assertion, @repository)
45
- end
46
-
47
- def build
48
- repo = repository # just shorter :-)
49
- title and ODRL::Profile::Builder.triplify(uri, DCT.title, title, repo)
50
- description and ODRL::Profile::Builder.triplify(uri, DCT.title, description, repo)
51
- author and ODRL::Profile::Builder.triplify(uri, DC.creator, author, repo)
52
-
53
- [asset_relations, party_functional_roles, actions, leftOperands, rightOperands, operators].flatten.each do |elem|
54
- elem.build(repo: repo)
55
- end
56
- end
57
-
58
- def serialize(format: :turtle)
59
- format = format.to_sym
60
- w = get_writer(type: format)
61
- w.dump(repository)
62
- end
63
-
64
- def get_writer(type: :turtle)
65
- RDF::Writer.for(type)
66
- end
67
-
68
- def self.triplify(s, p, o, repo)
69
- s = s.strip if s.instance_of?(String)
70
- p = p.strip if p.instance_of?(String)
71
- o = o.strip if o.instance_of?(String)
72
-
73
- unless s.respond_to?("uri")
74
-
75
- raise "Subject #{s} must be a URI-compatible thingy #{s}, #{p}, #{o}" unless s.to_s =~ %r{^\w+:/?/?[^\s]+}
76
-
77
- s = RDF::URI.new(s.to_s)
78
-
79
- end
80
-
81
- unless p.respond_to?("uri")
82
-
83
- raise "Predicate #{p} must be a URI-compatible thingy #{s}, #{p}, #{o}" unless p.to_s =~ %r{^\w+:/?/?[^\s]+}
84
-
85
- p = RDF::URI.new(p.to_s)
86
-
87
- end
88
- unless o.respond_to?("uri")
89
- o = if o.to_s =~ %r{^\w+:/?/?[^\s]+}
90
- RDF::URI.new(o.to_s)
91
- elsif o.to_s =~ /^\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d/
92
- RDF::Literal.new(o.to_s, datatype: RDF::XSD.date)
93
- elsif o.to_s =~ /^\d\.\d/
94
- RDF::Literal.new(o.to_s, datatype: RDF::XSD.float)
95
- elsif o.to_s =~ /^[0-9]+$/
96
- RDF::Literal.new(o.to_s, datatype: RDF::XSD.int)
97
- else
98
- RDF::Literal.new(o.to_s, language: :en)
99
- end
100
- end
101
-
102
- triple = RDF::Statement(s, p, o)
103
- repo.insert(triple)
104
-
105
- true
106
- end
107
- end # end of Class Builder
108
-
109
- class ProfileElement
110
- attr_accessor :uri, :label, :definition
111
-
112
- def initialize(uri:, label:, definition:, **_args)
113
- @uri = uri
114
- @label = label
115
- @definition = definition
116
- end
117
- end
118
-
119
- class AssetRelation < ProfileElement
120
- # ex:myRelation rdfs:subPropertyOf odrl:relation .
121
- def build(repo:)
122
- ODRL::Profile::Builder.triplify(uri, RDFS.subPropertyOf, ODRLV.relation, repo)
123
- ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
124
- ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
125
- end
126
- end
127
-
128
- class PartyFunction < ProfileElement
129
- # ex:myFunctionRole rdfs:subPropertyOf odrl:function
130
- def build(repo:)
131
- ODRL::Profile::Builder.triplify(uri, RDFS.subPropertyOf, ODRLV.function, repo)
132
- ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
133
- ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
134
- end
135
- end
136
-
137
- class Action < ProfileElement
138
- # ex:myAction a odrl:Action .
139
- # ex:myAction odrl:includedIn odrl:use .
140
- # ex:myAction odrl:implies odrl:distribute .
141
- attr_accessor :implies, :included_in
142
-
143
- def initialize(implies: nil, included_in: ODRLV.use, **args)
144
- @implies = implies
145
- @included_in = included_in
146
- super(**args)
147
- end
148
-
149
- def build(repo:)
150
- ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.Action, repo)
151
- ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
152
- ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
153
- ODRL::Profile::Builder.triplify(uri, ODRLV.includedIn, included_in, repo)
154
- return unless implies
155
- ODRL::Profile::Builder.triplify(uri, ODRLV.implies, implies, repo)
156
- end
157
- end
158
-
159
- class LeftOperand < ProfileElement
160
- # ex:myLeftOperand a odrl:LeftOperand .
161
- def build(repo:)
162
- ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.LeftOperand, repo)
163
- ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
164
- ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
165
- end
166
- end
167
-
168
- class RightOperand < ProfileElement
169
- # ex:myRightOperand a odrl:RightOperand .
170
- def build(repo:)
171
- ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.RightOperand, repo)
172
- ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
173
- ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
174
- end
175
- end
176
-
177
- class Operator < ProfileElement
178
- # ex:myOperator a odrl:Operator .
179
- def build(repo:)
180
- ODRL::Profile::Builder.triplify(uri, RDF.type, ODRLV.Operator, repo)
181
- ODRL::Profile::Builder.triplify(uri, RDFS.label, label, repo)
182
- ODRL::Profile::Builder.triplify(uri, SKOS.defintion, definition, repo)
183
- end
184
- end
185
- end
186
- end
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