line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FAIR::Profile; |
2
|
|
|
|
|
|
|
$FAIR::Profile::VERSION = '0.230'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: the base class representing a FAIR Profile. Everything else is attached to this |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
9602535
|
use Moose; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
64
|
|
7
|
6
|
|
|
6
|
|
38324
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
163
|
|
8
|
6
|
|
|
6
|
|
28
|
use Carp; |
|
6
|
|
|
|
|
29
|
|
|
6
|
|
|
|
|
516
|
|
9
|
6
|
|
|
6
|
|
37
|
use base 'FAIR::Base'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
3030
|
|
10
|
6
|
|
|
6
|
|
55
|
use FAIR::NAMESPACES; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
518
|
|
11
|
6
|
|
|
6
|
|
2643
|
use FAIR::Profile::Class; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
430
|
|
12
|
6
|
|
|
6
|
|
2947
|
use FAIR::Profile::Property; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
419
|
|
13
|
6
|
|
|
6
|
|
54
|
use RDF::Trine::Store::Memory; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
3169
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has URI => ( |
41
|
|
|
|
|
|
|
is => 'rw', |
42
|
|
|
|
|
|
|
isa => "Str", |
43
|
|
|
|
|
|
|
builder => '_generate_URI', |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has type => ( |
47
|
|
|
|
|
|
|
is => 'rw', |
48
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
49
|
|
|
|
|
|
|
traits => [qw/Serializable/], # it is, but it is handled differently than most serializable traits |
50
|
|
|
|
|
|
|
default => sub {[FAIR.'FAIRProfile', DC.'ProvenanceStatement']}, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has hasClass => ( |
54
|
|
|
|
|
|
|
is => 'rw', |
55
|
|
|
|
|
|
|
isa => 'FAIR::Profile::Class', |
56
|
|
|
|
|
|
|
traits => [qw/Serializable/], # THIS attribute is mirror-image, so if you try to serialize it you get an infinite loop |
57
|
|
|
|
|
|
|
writer => '_add_Class', |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has label => ( |
61
|
|
|
|
|
|
|
is => 'rw', |
62
|
|
|
|
|
|
|
isa => "Str", |
63
|
|
|
|
|
|
|
default => 'FAIR Profile Descriptor', |
64
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has title => ( |
68
|
|
|
|
|
|
|
is => 'rw', |
69
|
|
|
|
|
|
|
isa => "Str", |
70
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has description => ( |
74
|
|
|
|
|
|
|
is => 'rw', |
75
|
|
|
|
|
|
|
isa => "Str", |
76
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has license => ( |
80
|
|
|
|
|
|
|
is => 'rw', |
81
|
|
|
|
|
|
|
isa => "Str", |
82
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has issued => ( |
86
|
|
|
|
|
|
|
is => 'rw', |
87
|
|
|
|
|
|
|
isa => "Str", |
88
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has modified => ( |
92
|
|
|
|
|
|
|
is => 'rw', |
93
|
|
|
|
|
|
|
isa => "Str", |
94
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has organization => ( |
98
|
|
|
|
|
|
|
is => 'rw', |
99
|
|
|
|
|
|
|
isa => "Str", |
100
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
has identifier => ( |
104
|
|
|
|
|
|
|
is => 'rw', |
105
|
|
|
|
|
|
|
isa => "Str", |
106
|
|
|
|
|
|
|
traits => [qw/Serializable/], |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
#has schemardfs_URL => ( |
110
|
|
|
|
|
|
|
# is => 'rw', |
111
|
|
|
|
|
|
|
# isa => "Str", |
112
|
|
|
|
|
|
|
# traits => [qw/Serializable/], |
113
|
|
|
|
|
|
|
# default => FAIR, |
114
|
|
|
|
|
|
|
# ); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _generate_URI { |
117
|
1
|
|
|
1
|
|
1314
|
my ($self, $newval) = @_; |
118
|
1
|
50
|
|
|
|
4
|
return $newval if $newval; |
119
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
13
|
my $ug = UUID::Generator::PurePerl->new(); |
121
|
1
|
|
|
|
|
14
|
my $ug1 = $ug->generate_v4()->as_string; |
122
|
1
|
|
|
|
|
3881
|
return "http://datafairport.org/sampledata/profileschemaprofile/$ug1"; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub add_Class { |
127
|
3
|
|
|
3
|
1
|
401
|
my ($self, $class) = @_; |
128
|
3
|
50
|
|
|
|
10
|
die "not a FAIR Profile Schema Class *$class->type*" unless (FAIR.'FAIRClass' ~~ $class->type); |
129
|
3
|
|
|
|
|
63
|
$class->provenance($self); |
130
|
|
|
|
|
|
|
#my $classes = $self->hasClass; |
131
|
|
|
|
|
|
|
#push @$classes, $class; |
132
|
3
|
|
|
|
|
66
|
$self->_add_Class($class); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub serialize { |
138
|
|
|
|
|
|
|
#ntriples |
139
|
|
|
|
|
|
|
#nquads |
140
|
|
|
|
|
|
|
#rdfxml |
141
|
|
|
|
|
|
|
#rdfjson |
142
|
|
|
|
|
|
|
#ntriples-canonical |
143
|
|
|
|
|
|
|
#turtle |
144
|
5
|
|
|
5
|
0
|
109020
|
my ($self, $format) = @_; |
145
|
5
|
|
100
|
|
|
27
|
$format ||='rdfxml'; |
146
|
5
|
|
|
|
|
111
|
my $store = RDF::Trine::Store::Memory->new(); |
147
|
5
|
|
|
|
|
202
|
my $model = RDF::Trine::Model->new($store); |
148
|
5
|
|
|
|
|
108
|
my @triples = $self->toTriples; |
149
|
5
|
|
|
|
|
4815
|
foreach my $statement(@triples){ |
150
|
130
|
|
|
|
|
43185
|
$model->add_statement($statement); |
151
|
|
|
|
|
|
|
} |
152
|
5
|
|
|
|
|
1984
|
my $serializer = RDF::Trine::Serializer->new($format); |
153
|
5
|
|
|
|
|
211
|
return $serializer->serialize_model_to_string($model); |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
__END__ |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=pod |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=encoding UTF-8 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 NAME |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
FAIR::Profile - the base class representing a FAIR Profile. Everything else is attached to this |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 VERSION |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
version 0.230 |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 SYNOPSIS |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
use FAIR; |
176
|
|
|
|
|
|
|
use FAIR::Profile::Parser; |
177
|
|
|
|
|
|
|
use FAIR::Profile; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $parser = FAIR::Profile::Parser->new(filename => "./ProfileSchema.rdf"); |
180
|
|
|
|
|
|
|
my $Profile = $parser->parse; # A DCAT::Profile from a file |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
my $Profile2 = FAIR::Profile->new( |
183
|
|
|
|
|
|
|
label => 'UBC Thesis Submission Profile', |
184
|
|
|
|
|
|
|
title => 'UBC Thesis Submission Profile' |
185
|
|
|
|
|
|
|
description => 'the metadata that must be associated with thesis deposition', |
186
|
|
|
|
|
|
|
modified => 'May 21, 2014', |
187
|
|
|
|
|
|
|
license => 'CC', |
188
|
|
|
|
|
|
|
issued => 'May 21, 2014, |
189
|
|
|
|
|
|
|
organization => 'University of British Columbia', |
190
|
|
|
|
|
|
|
identifier => 'doi:123.123.123', |
191
|
|
|
|
|
|
|
URI => 'http://ubc.ca/library/thesis/metadataprofile.rdf' |
192
|
|
|
|
|
|
|
) |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
my $ProfileClass = FAIR::Profile::Class->new( |
195
|
|
|
|
|
|
|
class_type => FAIR."dataset", # DCAT is an exported constant |
196
|
|
|
|
|
|
|
URI => "http://datafairport.org/examples/ProfileSchemas/DCATDatasetExample.rdf", |
197
|
|
|
|
|
|
|
); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my $TitleProperty = FAIR::Profile::Property->new( |
200
|
|
|
|
|
|
|
property_type => DCT.'title', # DCT is an exported constant |
201
|
|
|
|
|
|
|
allow_multiple => "false", |
202
|
|
|
|
|
|
|
); |
203
|
|
|
|
|
|
|
$TitleProperty->set_RequirementStatus('required'); |
204
|
|
|
|
|
|
|
$TitleProperty->add_ValueRange(XSD."string"); |
205
|
|
|
|
|
|
|
$ProfileClass->add_Property($TitleProperty); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
my $DescrProperty = FAIR::Profile::Property->new( |
209
|
|
|
|
|
|
|
property_type => DCT.'description', |
210
|
|
|
|
|
|
|
allow_multiple => "false", |
211
|
|
|
|
|
|
|
); |
212
|
|
|
|
|
|
|
$DescrProperty->set_RequirementStatus('required'); |
213
|
|
|
|
|
|
|
$DescrProperty->add_ValueRange(XSD."string"); # XSD is an exported constant |
214
|
|
|
|
|
|
|
$ProfileClass->add_Property($DescrProperty); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
$Profile2->add_Class($DCATDatasetClass); |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
my $profileRDF = $Profile2->serialize; |
219
|
|
|
|
|
|
|
open(OUT, ">ProfileSchema.rdf") or die "$!\n"; |
220
|
|
|
|
|
|
|
print OUT $schema; |
221
|
|
|
|
|
|
|
close OUT; |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 DESCRIPTION |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
DCAT Profiles describe the metadata elements, and constrained values, that should be |
226
|
|
|
|
|
|
|
associated with a given information entity. They ARE NOT containers for this metadata, |
227
|
|
|
|
|
|
|
they only describe what that metadata should look like (meta-meta-data :-) ) |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
This module represents a DCAT Profile, and can be serialized into RDF. |
230
|
|
|
|
|
|
|
The objects it contains (classes and properties) will tell you what metadata fields |
231
|
|
|
|
|
|
|
are required/optional, and what possible values they are allowed to contain. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
DCAT Profiles are not part of the official DCAT specification, but the idea was raised |
234
|
|
|
|
|
|
|
by the DCAT working group as something that might be useful... it |
235
|
|
|
|
|
|
|
certainly is! |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 NAME |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
FAIR::Profile - a module representing a FAIR Profile. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHORS |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Mark Wilkinson (markw at illuminae dot com) |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 METHODS |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 new |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Title : new |
250
|
|
|
|
|
|
|
Usage : my $ProfileParser = DCAT::Profile->new(); |
251
|
|
|
|
|
|
|
Function: Builds a new DCAT::Profile |
252
|
|
|
|
|
|
|
Returns : DCAT::Profile |
253
|
|
|
|
|
|
|
Args : label => $string |
254
|
|
|
|
|
|
|
title => $string |
255
|
|
|
|
|
|
|
description => $string |
256
|
|
|
|
|
|
|
modified => $date |
257
|
|
|
|
|
|
|
license => $string |
258
|
|
|
|
|
|
|
issued => $date |
259
|
|
|
|
|
|
|
organization => $string |
260
|
|
|
|
|
|
|
identifier => $string |
261
|
|
|
|
|
|
|
URI => $URI (optional - a unique URI will be auto-generated) |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head2 label |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Title : label |
266
|
|
|
|
|
|
|
Usage : $label = $Profile->label($label); |
267
|
|
|
|
|
|
|
Function: get/set the RDF label for this object when serialized |
268
|
|
|
|
|
|
|
Returns : string |
269
|
|
|
|
|
|
|
Args : string |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head2 title |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Title : title |
274
|
|
|
|
|
|
|
Usage : $title = $Profile->title($title); |
275
|
|
|
|
|
|
|
Function: get/set the title of this Profile |
276
|
|
|
|
|
|
|
Returns : string |
277
|
|
|
|
|
|
|
Args : string |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head2 description |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Title : description |
282
|
|
|
|
|
|
|
Usage : $desc = $Profile->description($desc); |
283
|
|
|
|
|
|
|
Function: get/set the description of this Profile |
284
|
|
|
|
|
|
|
Returns : string |
285
|
|
|
|
|
|
|
Args : string |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=head2 modified |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
Title : modified |
290
|
|
|
|
|
|
|
Usage : $date = $Profile->modified($date); |
291
|
|
|
|
|
|
|
Function: get/set the modified date of this Profile |
292
|
|
|
|
|
|
|
Returns : string (one day this will be more rigorous!) |
293
|
|
|
|
|
|
|
Args : string (one day this will be more rigorous!) |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head2 issued |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Title : issued |
298
|
|
|
|
|
|
|
Usage : $date = $Profile->issued($date); |
299
|
|
|
|
|
|
|
Function: get/set the created/issued date of this Profile |
300
|
|
|
|
|
|
|
Returns : string (one day this will be more rigorous!) |
301
|
|
|
|
|
|
|
Args : string (one day this will be more rigorous!) |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head2 organization |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
Title : organization |
306
|
|
|
|
|
|
|
Usage : $name = $Profile->organization($name); |
307
|
|
|
|
|
|
|
Function: get/set the organization who created this Profile |
308
|
|
|
|
|
|
|
Returns : string (should probably be a URI... one day) |
309
|
|
|
|
|
|
|
Args : string (should probably be a URI... one day) |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=head2 identifier |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
Title : identifier |
314
|
|
|
|
|
|
|
Usage : $id = $Profile->identifier($id); |
315
|
|
|
|
|
|
|
Function: get/set the unique identifier for this Profile |
316
|
|
|
|
|
|
|
Returns : string (should be a URI or a DOI if available) |
317
|
|
|
|
|
|
|
Args : string (should be a URI or a DOI if available) |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head2 URI |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Title : URI |
322
|
|
|
|
|
|
|
Usage : $uri = $Profile->URI($uri); |
323
|
|
|
|
|
|
|
Function: get/set the URI for this Profile - the root URI in the RDF |
324
|
|
|
|
|
|
|
Returns : string (should be a URI) |
325
|
|
|
|
|
|
|
Args : string (should be a URI) |
326
|
|
|
|
|
|
|
notes: if this is not supplied, a unique URI will be automatically generated |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=head2 add_Class |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
Title : add_Class |
331
|
|
|
|
|
|
|
Usage : $Profile->add_Class($Class); |
332
|
|
|
|
|
|
|
Function: add a new DCAT::Profile::Class to the Profile |
333
|
|
|
|
|
|
|
Returns : boolean (1 for success) |
334
|
|
|
|
|
|
|
Args : DCAT::Profile::Class |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
=head2 has_class |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
Title : has_class |
339
|
|
|
|
|
|
|
Usage : $Profile->has_class(); |
340
|
|
|
|
|
|
|
Function: retrieve all Classes for the profile |
341
|
|
|
|
|
|
|
Returns : listref of DCAT::Profile::Class objects |
342
|
|
|
|
|
|
|
Args : none |
343
|
|
|
|
|
|
|
Note: the capitalization of the method name |
344
|
|
|
|
|
|
|
matches the capitalization of the RDF predicate... |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=head1 AUTHOR |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
Mark Denis Wilkinson (markw [at] illuminae [dot] com) |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Mark Denis Wilkinson. |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
This is free software, licensed under: |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
The Apache License, Version 2.0, January 2004 |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=cut |