File Coverage

blib/lib/ODO/RDFS/Class.pm
Criterion Covered Total %
statement 48 70 68.5
branch 5 18 27.7
condition 3 6 50.0
subroutine 10 13 76.9
pod 2 4 50.0
total 68 111 61.2


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