| 1 | package FAIR::Accessor::Container; | ||
| 2 | $FAIR::Accessor::Container::VERSION = '1.0'; | ||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 | use strict; | ||
| 8 | use Moose; | ||
| 9 | use UUID::Generator::PurePerl; | ||
| 10 | use RDF::Trine::Store::Memory; | ||
| 11 | use RDF::Trine::Model; | ||
| 12 | |||
| 13 | with 'FAIR::CoreFunctions'; | ||
| 14 | |||
| 15 | has 'model' => ( | ||
| 16 | isa => "RDF::Trine::Model", | ||
| 17 | is => "rw", | ||
| 18 | default => sub {my $store = RDF::Trine::Store::Memory->new(); return RDF::Trine::Model->new($store)} | ||
| 19 | ); | ||
| 20 | |||
| 21 | has 'MetaData' => ( | ||
| 22 | isa => "HashRef", | ||
| 23 | is => "rw", | ||
| 24 | default => sub {my $h = {}; return $h} | ||
| 25 | ); | ||
| 26 | |||
| 27 | has 'NS' => ( | ||
| 28 | is => 'rw', | ||
| 29 | ); | ||
| 30 | |||
| 31 | has 'FreeFormRDF' => ( | ||
| 32 | is => 'rw', | ||
| 33 | isa => "RDF::Trine::Model" | ||
| 34 | ); | ||
| 35 | |||
| 36 | has Records => ( | ||
| 37 | isa => "ArrayRef", | ||
| 38 | is => "rw" | ||
| 39 | ); | ||
| 40 | |||
| 41 | |||
| 42 | sub addRecords { | ||
| 43 | my ($self, $records) = @_; | ||
| 44 | |||
| 45 | $self->addMetadata({'void:entities' => scalar(@$records)});; # THE TOTAL *NUMBER* OF RECORDS THAT CAN BE SERVED | ||
| 46 | $self->Records($records); | ||
| 47 | |||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | sub addMetadata { | ||
| 52 | my ($self, $metadata) = @_; | ||
| 53 | my %datahash = %$metadata; | ||
| 54 | my %existing = %{$self->MetaData}; | ||
| 55 | foreach my $key(keys %datahash){ | ||
| 56 | $existing{$key} = $datahash{$key}; | ||
| 57 | } | ||
| 58 | $self->MetaData(\%existing); | ||
| 59 | |||
| 60 | } | ||
| 61 | |||
| 62 | |||
| 63 | 1; | ||
| 64 | |||
| 65 | __END__ | ||
| 66 | |||
| 67 | =pod | ||
| 68 | |||
| 69 | =encoding UTF-8 | ||
| 70 | |||
| 71 | =head1 NAME | ||
| 72 | |||
| 73 | FAIR::Accessor::Container | ||
| 74 | |||
| 75 | =head1 VERSION | ||
| 76 | |||
| 77 | version 1.0 | ||
| 78 | |||
| 79 | =head1 Name FAIR::Accessor::Container | ||
| 80 | |||
| 81 | =head1 Description | ||
| 82 | |||
| 83 | This generates the behaviors for the LDP Container-like functions of the FAIR Accessor | ||
| 84 | |||
| 85 | =head1 AUTHOR | ||
| 86 | |||
| 87 | Mark Denis Wilkinson (markw [at] illuminae [dot] com) | ||
| 88 | |||
| 89 | =head1 COPYRIGHT AND LICENSE | ||
| 90 | |||
| 91 | This software is Copyright (c) 2016 by Mark Denis Wilkinson. | ||
| 92 | |||
| 93 | This is free software, licensed under: | ||
| 94 | |||
| 95 | The Apache License, Version 2.0, January 2004 | ||
| 96 | |||
| 97 | =cut |