blib/lib/FAIR/Accessor/MetaRecord.pm untested

filter: Statementstmt 0.0% 0 / 53 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 67 CC 3 SCAR 16.1
CC
3
Cov
0%
addDistribution
12.0
addMetadata
2.0
BEGIN
2.0
CRAP 5.0
1 package FAIR::Accessor::MetaRecord;
2 $FAIR::Accessor::MetaRecord::VERSION = '1.0';
3  
4  
5  
6 use strict;
7 use Moose;
8 use UUID::Generator::PurePerl;
9 use RDF::Trine::Store::Memory;
10 use RDF::Trine::Model;
11 use FAIR::Accessor::Distribution;
12  
13 with 'FAIR::CoreFunctions';
14  
15  
16 has 'MetaData' => (
17 isa => "HashRef",
18 is => "rw",
19 default => sub {my $h = {}; return $h}
20 );
21  
22  
23 has 'FreeFormRDF' => (
24 is => 'rw',
25 isa => "RDF::Trine::Model"
26 );
27  
28 has 'NS' => (
29 is => 'rw',
30 required => 'true',
31 );
32  
33 has 'ID' => (
34 is => 'rw',
35 isa => 'Str',
36 required => 'true',
37 );
38  
39 has 'Distributions' => (
40 is => 'rw',
41 isa => 'ArrayRef[FAIR::Accessor::Distribution]',
42 );
43  
44  
45  
46 sub addMetadata {
47 my ($self, $metadata) = @_;
48 my %datahash = %$metadata;
49 my %existing = %{$self->MetaData};
50 foreach my $key(keys %datahash){
51 $existing{$key} = $datahash{$key};
52 }
53 $self->MetaData(\%existing);
54
55 }
56  
57 sub addDistribution {
58 my ($self, %ARGS) = @_; #
59 my $currentDistributions = $self->Distributions;
60 my @currentDistributions;
61 if ($currentDistributions) {
62 @currentDistributions = @$currentDistributions;
63 }
64
65 my $Distribution = FAIR::Accessor::Distribution->new();
66 $Distribution->NS($self->NS);
67 $Distribution->downloadURL($ARGS{downloadURL});
68 $Distribution->availableformats($ARGS{availableformats});
69  
70 if ($ARGS{source}) { # this is very dangerous... we assume that the user sends all parameters... if not, we don't check and Moose constraints will be violated
71 # these are only for TPF
72 $Distribution->source($ARGS{source});
73 $Distribution->subjecttemplate($ARGS{subjecttemplate});
74 $Distribution->subjecttype($ARGS{subjecttype});
75 $Distribution->predicate($ARGS{predicate});
76 $Distribution->objecttemplate($ARGS{objecttemplate});
77 $Distribution->objecttype($ARGS{objecttype});
78 }
79
80 push @currentDistributions, $Distribution;
81 $self->Distributions(\@currentDistributions);
82 }
83  
84  
85 1;
86  
87 __END__
88  
89 =pod
90  
91 =encoding UTF-8
92  
93 =head1 NAME
94  
95 FAIR::Accessor::MetaRecord
96  
97 =head1 VERSION
98  
99 version 1.0
100  
101 =head1 Name FAIR::Accessor::MetaRecord
102  
103 =head1 Description
104  
105 This generates the behaviors for the LDP MetaRecord functions of the FAIR Accessor
106  
107 =head1 AUTHOR
108  
109 Mark Denis Wilkinson (markw [at] illuminae [dot] com)
110  
111 =head1 COPYRIGHT AND LICENSE
112  
113 This software is Copyright (c) 2016 by Mark Denis Wilkinson.
114  
115 This is free software, licensed under:
116  
117 The Apache License, Version 2.0, January 2004
118  
119 =cut