File Coverage

blib/lib/ODO/RDFS/Properties/value.pm
Criterion Covered Total %
statement 28 65 43.0
branch 0 10 0.0
condition 0 3 0.0
subroutine 10 14 71.4
pod 2 4 50.0
total 40 96 41.6


line stmt bran cond sub pod time code
1             package ODO::RDFS::Properties::value;
2              
3 1     1   4 use strict;
  1         2  
  1         25  
4 1     1   4 use warnings;
  1         1  
  1         28  
5              
6 1     1   4 use vars qw( @ISA );
  1         2  
  1         34  
7 1     1   4 use vars qw /$VERSION/;
  1         1  
  1         56  
8             $VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/;
9 1     1   4 use ODO;
  1         2  
  1         25  
10 1     1   4 use ODO::Query::Simple;
  1         6  
  1         24  
11 1     1   5 use ODO::Statement::Group;
  1         2  
  1         29  
12 1     1   4 use ODO::RDFS::Resource;
  1         2  
  1         22  
13 1     1   4 use ODO::RDFS::Property;
  1         2  
  1         437  
14              
15             @ISA = ( 'ODO::RDFS::Resource', 'ODO::RDFS::Property', );
16              
17             #
18             # Description: Idiomatic property used for structured values.
19             #
20             # Schema URI: http://www.w3.org/1999/02/22-rdf-syntax-ns#
21             #
22             sub new {
23 0     0 1 0 my $self = shift;
24 0         0 my ($resource, $graph, %properties) = @_;
25            
26 0         0 $self = $self->SUPER::new(@_);
27            
28             return undef
29 0 0       0 unless(ref $self);
30            
31 0         0 $self->propertyContainerName( 'ODO::RDFS::Properties::value::PropertiesContainer' );
32 0         0 $self->properties(bless {}, 'ODO::RDFS::Properties::value::PropertiesContainer');
33              
34 0         0 $self->properties()->{'parent'} = $self;
35              
36              
37 0         0 return $self;
38             }
39              
40             sub queryString {
41 0     0 0 0 return '(?subj, rdf:type, )';
42             }
43              
44             sub objectURI {
45 11     11 0 140 return 'http://www.w3.org/1999/02/22-rdf-syntax-ns#value';
46             }
47              
48             sub value {
49 0     0 1   my $self = shift;
50            
51 0 0         return $self->subject()
52             if(UNIVERSAL::isa($self->subject(), 'ODO::Node::Literal'));
53            
54 0           return $self->__to_statement_array();
55             }
56              
57             sub __to_statement_array {
58 0     0     my $self = shift;
59            
60 0           my $statements = [];
61            
62 0           foreach my $my_super (@ISA) {
63            
64             next
65 0 0         unless(UNIVERSAL::can($my_super, '__to_statement_array'));
66            
67 0           my $super_func = "${my_super}::__to_statement_array";
68 0           push @{ $statements }, @{ $self->$super_func() };
  0            
  0            
69             }
70            
71 0           my %properties = (''=> '',);
72            
73 0           foreach my $propertyName (keys(%properties)) {
74              
75             next
76 0 0 0       unless($propertyName && $propertyName ne '');
77            
78 0           my $property = $self->properties()->$propertyName();
79            
80 0           foreach my $p (@{ $property }) {
  0            
81 0           my $p_value = $p->value();
82            
83 0           my $property_uri = ODO::Node::Resource->new($properties{$propertyName}->objectURI() );
84 0 0         if(UNIVERSAL::isa($p_value, 'ODO::Node::Literal')) {
85 0           push @{ $statements }, ODO::Statement->new($self->subject(), $property_uri, $p_value);
  0            
86             }
87             else {
88 0           push @{ $statements }, ODO::Statement->new($self->subject(), $property_uri, $p->subject());
  0            
89 0           push @{ $statements }, @{ $p_value };
  0            
  0            
90             }
91             }
92             }
93            
94 0           return $statements;
95             }
96              
97             1;