File Coverage

blib/lib/ODO/RDFS/Properties/subPropertyOf.pm
Criterion Covered Total %
statement 25 62 40.3
branch 0 10 0.0
condition 0 3 0.0
subroutine 9 13 69.2
pod 2 4 50.0
total 36 92 39.1


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