| 1 | package FAIR::Profile::Property; | ||||||||||
| 2 | 6 | $FAIR::Profile::Property::VERSION = '0.41'; | |||||||||
| 3 | |||||||||||
| 4 | |||||||||||
| 5 | # ABSTRACT: to represent a Property in a FAIR Profile | ||||||||||
| 6 | |||||||||||
| 7 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 6 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 6 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | #use FAIR::Base; | ||||||||||
| 11 | 6 | ▶ | use FAIR::NAMESPACES; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 6 | ▶ | use UUID::Generator::PurePerl; # slower, but it will work on all setups! | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 6 | ▶ | use base 'FAIR::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 6 | ▶ | use FAIR::Profile::SerializableProperty; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | |||||||||||
| 32 | 6 | has label => ( | |||||||||
| 33 | is => 'rw', | ||||||||||
| 34 | isa => "Str", # this should be forced to be a URI | ||||||||||
| 35 | traits => ['Serializable'], | ||||||||||
| 36 | required => 1, | ||||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | 6 | has onPropertyType => ( | |||||||||
| 40 | is => 'rw', | ||||||||||
| 41 | isa => "Str", # this should be forced to be a URI | ||||||||||
| 42 | traits => ['Serializable'], | ||||||||||
| 43 | required => 1, | ||||||||||
| 44 | ); | ||||||||||
| 45 | |||||||||||
| 46 | 6 | has allowedValues => ( | |||||||||
| 47 | is => 'rw', | ||||||||||
| 48 | isa => 'ArrayRef', # one day make this a forced URI! | ||||||||||
| 49 | traits => ['Serializable'], | ||||||||||
| 50 | writer => '_add_AllowedValue', | ||||||||||
| 51 | ); | ||||||||||
| 52 | |||||||||||
| 53 | 6 | has minCount => ( | |||||||||
| 54 | is => 'rw', | ||||||||||
| 55 | isa => "Int", | ||||||||||
| 56 | traits => ['Serializable'], | ||||||||||
| 57 | ); | ||||||||||
| 58 | |||||||||||
| 59 | 6 | has maxCount => ( | |||||||||
| 60 | is => 'rw', | ||||||||||
| 61 | isa => "Int", | ||||||||||
| 62 | traits => ['Serializable'], | ||||||||||
| 63 | ); | ||||||||||
| 64 | |||||||||||
| 65 | has type => ( | ||||||||||
| 66 | is => 'rw', | ||||||||||
| 67 | isa => 'ArrayRef[Str]', | ||||||||||
| 68 | traits => ['Serializable'], | ||||||||||
| 69 | required => 1, | ||||||||||
| 70 | 7 | ▶ | default => sub {[FAIR.'FAIRProperty']}, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 71 | 6 | ); | |||||||||
| 72 | |||||||||||
| 73 | 6 | has URI => ( | |||||||||
| 74 | is => 'rw', | ||||||||||
| 75 | isa => "Str", | ||||||||||
| 76 | traits => ['Serializable'], | ||||||||||
| 77 | builder => '_generate_URI', | ||||||||||
| 78 | required => 1, | ||||||||||
| 79 | |||||||||||
| 80 | ); | ||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | sub _generate_URI { | ||||||||||
| 84 | 1 | ▶ | my ($self, $newval) = @_; | ||||||||
|
Subroutine
_generate_URI: called CC=2 SCAR=7.0
| |||||||||||
| 85 | 1 | ▶ | return $newval if $newval; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 86 | |||||||||||
| 87 | 1 | my $ug = UUID::Generator::PurePerl->new(); | |||||||||
| 88 | 1 | my $ug1 = $ug->generate_v4()->as_string; | |||||||||
| 89 | 1 | return "http://datafairport.org/sampledata/profileschemaproperty/$ug1"; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | |||||||||||
| 93 | sub add_AllowedValue { | ||||||||||
| 94 | 1 | ▶ | my ($self, $p) = @_; | ||||||||
|
Subroutine
add_AllowedValue: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 95 | 1 | ▶ | die "not a valid profile property-value range $p" unless ($p =~ /^https?:/); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | 1 | my $ps = $self->allowedValues; | |||||||||
| 97 | 1 | push @$ps, $p; | |||||||||
| 98 | 1 | $self->_add_AllowedValue($ps); | |||||||||
| 99 | 1 | return 1; | |||||||||
| 100 | } | ||||||||||
| 101 | |||||||||||
| 102 | |||||||||||
| 103 | |||||||||||
| 104 | 6 | 1; | |||||||||
| 105 | |||||||||||
| 106 | __END__ | ||||||||||
| 107 | |||||||||||
| 108 | =pod | ||||||||||
| 109 | |||||||||||
| 110 | =encoding UTF-8 | ||||||||||
| 111 | |||||||||||
| 112 | =head1 NAME | ||||||||||
| 113 | |||||||||||
| 114 | FAIR::Profile::Property - to represent a Property in a FAIR Profile | ||||||||||
| 115 | |||||||||||
| 116 | =head1 VERSION | ||||||||||
| 117 | |||||||||||
| 118 | version 0.41 | ||||||||||
| 119 | |||||||||||
| 120 | =head1 SYNOPSIS | ||||||||||
| 121 | |||||||||||
| 122 | use FAIR::Profile::Class; | ||||||||||
| 123 | use FAIR::Profile::Property; | ||||||||||
| 124 | |||||||||||
| 125 | my $ProfileClass = FAIR::Profile::Class->new( | ||||||||||
| 126 | class_type => FAIR."dataset", # DCAT is an exported constant | ||||||||||
| 127 | URI => "http://example.org//ProfileClasses/ThisClass.rdf", | ||||||||||
| 128 | label => "core metadata for the thesis submission" | ||||||||||
| 129 | ); | ||||||||||
| 130 | |||||||||||
| 131 | my $TitleProperty = FAIR::Profile::Property->new( | ||||||||||
| 132 | property_type => DCT.'title', # DCT is an exported constant | ||||||||||
| 133 | allow_multiple => "false", | ||||||||||
| 134 | ); | ||||||||||
| 135 | $TitleProperty->set_RequirementStatus('required'); | ||||||||||
| 136 | $TitleProperty->add_ValueRange(XSD."string"); | ||||||||||
| 137 | $ProfileClass->add_Property($TitleProperty); | ||||||||||
| 138 | |||||||||||
| 139 | =head1 DESCRIPTION | ||||||||||
| 140 | |||||||||||
| 141 | FAIR Property describes a single metadata element, and its possible values. | ||||||||||
| 142 | It IS NOT a containers for this metadata, | ||||||||||
| 143 | it only describes what that metadata should look like (meta-meta-data :-) ) | ||||||||||
| 144 | |||||||||||
| 145 | Effectively, in RDF terms, this is the predicate associated with the metadata, and it's ranges | ||||||||||
| 146 | |||||||||||
| 147 | =head1 NAME | ||||||||||
| 148 | |||||||||||
| 149 | FAIR::Profile::Property - a module representing a DCAT Profile Property | ||||||||||
| 150 | |||||||||||
| 151 | =head1 AUTHORS | ||||||||||
| 152 | |||||||||||
| 153 | Mark Wilkinson (markw at illuminae dot com) | ||||||||||
| 154 | |||||||||||
| 155 | =head1 METHODS | ||||||||||
| 156 | |||||||||||
| 157 | =head2 new | ||||||||||
| 158 | |||||||||||
| 159 | Title : new | ||||||||||
| 160 | Usage : my $Property = FAIR::Profile::Property->new(); | ||||||||||
| 161 | Function: Builds a new FAIR::Profile::Property | ||||||||||
| 162 | Returns : FAIR::Profile::Property | ||||||||||
| 163 | Args : label => $string | ||||||||||
| 164 | property_type => $URI (possibly an OWL predicate URI) | ||||||||||
| 165 | allow_multiple => $boolean ('true'/'false') | ||||||||||
| 166 | URI => $URI (optional - a unique URI will be auto-generated) | ||||||||||
| 167 | |||||||||||
| 168 | =head2 label | ||||||||||
| 169 | |||||||||||
| 170 | Title : label | ||||||||||
| 171 | Usage : $label = $Property->label($label); | ||||||||||
| 172 | Function: get/set the RDF label for this object when serialized | ||||||||||
| 173 | Returns : string | ||||||||||
| 174 | Args : string | ||||||||||
| 175 | |||||||||||
| 176 | =head2 property_type | ||||||||||
| 177 | |||||||||||
| 178 | Title : property_type | ||||||||||
| 179 | Usage : $property_type = $Property->property_type($property_type); | ||||||||||
| 180 | Function: get/set the property type (should be a URI, e.g. of an ontology predicate) | ||||||||||
| 181 | Returns : string (URI) | ||||||||||
| 182 | Args : string (URI) | ||||||||||
| 183 | |||||||||||
| 184 | =head2 URI | ||||||||||
| 185 | |||||||||||
| 186 | Title : URI | ||||||||||
| 187 | Usage : $uri = $Property->URI($uri); | ||||||||||
| 188 | Function: get/set the URI for this Property - the URI in the RDF | ||||||||||
| 189 | Returns : string (should be a URI) | ||||||||||
| 190 | Args : string (should be a URI) | ||||||||||
| 191 | notes: if this is not supplied, a unique URI will be automatically generated | ||||||||||
| 192 | |||||||||||
| 193 | =head2 set_MinCount | ||||||||||
| 194 | |||||||||||
| 195 | Title : set_MinCount | ||||||||||
| 196 | Usage : $req = $Property->set_MinCount($int); | ||||||||||
| 197 | Function: minimum number of occurrences of this property | ||||||||||
| 198 | Returns : int | ||||||||||
| 199 | Args : int | ||||||||||
| 200 | |||||||||||
| 201 | =head2 set_MinCount | ||||||||||
| 202 | |||||||||||
| 203 | Title : set_MaxCount | ||||||||||
| 204 | Usage : $req = $Property->set_MaxCount($int); | ||||||||||
| 205 | Function: maximum number of occurrences of this property | ||||||||||
| 206 | Returns : int | ||||||||||
| 207 | Args : int | ||||||||||
| 208 | |||||||||||
| 209 | =head2 add_ValueRange | ||||||||||
| 210 | |||||||||||
| 211 | Title : add_ValueRange | ||||||||||
| 212 | Usage : $Property->add_ValueRange($URI); | ||||||||||
| 213 | Function: add a range restriction for this predicate | ||||||||||
| 214 | Returns : none | ||||||||||
| 215 | Args : string - the string should be a URI... | ||||||||||
| 216 | Notes: This is the "critical bit" of the FAIR Profile. The ranges | ||||||||||
| 217 | can be defined by one of: the URI of an XSD datatype, the URI | ||||||||||
| 218 | to a SKOS view of a set of ontology terms (according to Jupp et al, 2013) | ||||||||||
| 219 | or the URI to another FAIR::Profile (in this way, profiles can be hierarchical) | ||||||||||
| 220 | |||||||||||
| 221 | =head2 allowedValues | ||||||||||
| 222 | |||||||||||
| 223 | Title : allowedValues | ||||||||||
| 224 | Usage : $req = $Property->allowedValues(); | ||||||||||
| 225 | Function: retrieve the value ranges for the property | ||||||||||
| 226 | Returns : listref of URIs (see add_ValueRange for details) | ||||||||||
| 227 | Args : none | ||||||||||
| 228 | |||||||||||
| 229 | =head1 AUTHOR | ||||||||||
| 230 | |||||||||||
| 231 | Mark Denis Wilkinson (markw [at] illuminae [dot] com) | ||||||||||
| 232 | |||||||||||
| 233 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 234 | |||||||||||
| 235 | This software is Copyright (c) 2016 by Mark Denis Wilkinson. | ||||||||||
| 236 | |||||||||||
| 237 | This is free software, licensed under: | ||||||||||
| 238 | |||||||||||
| 239 | The Apache License, Version 2.0, January 2004 | ||||||||||
| 240 | |||||||||||
| 241 | =cut | ||||||||||