File Coverage

blib/lib/ODO/RDFS/Property/PropertiesContainer.pm
Criterion Covered Total %
statement 30 60 50.0
branch 6 18 33.3
condition 3 9 33.3
subroutine 8 8 100.0
pod 0 3 0.0
total 47 98 47.9


line stmt bran cond sub pod time code
1             package ODO::RDFS::Property::PropertiesContainer;
2              
3 1     1   7 use strict;
  1         3  
  1         35  
4 1     1   5 use warnings;
  1         3  
  1         27  
5              
6 1     1   6 use vars qw( $AUTOLOAD @ISA );
  1         2  
  1         64  
7 1     1   9 use vars qw /$VERSION/;
  1         1  
  1         82  
8             $VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/;
9 1     1   6 use ODO::RDFS::Resource::PropertiesContainer;
  1         7  
  1         636  
10              
11             @ISA = ( 'ODO::RDFS::Resource::PropertiesContainer', );
12              
13             # Methods
14              
15              
16             sub subPropertyOf {
17 5     5 0 63 my $self = shift;
18              
19 5         14 my $parent = $self->{'parent'};
20 5 50       15 unless($parent) {
21 0         0 die('Fatal error in property container: parent object is not defined!');
22             }
23              
24 5 50 33     20 if( scalar(@_) > 0
25             && UNIVERSAL::isa($_[0], 'ODO::RDFS::Properties::subPropertyOf')) {
26              
27 0         0 my $value = $_[0]->value();
28            
29 0         0 my $property = ODO::Node::Resource->new( ODO::RDFS::Properties::subPropertyOf->objectURI() );
30 0 0       0 if(UNIVERSAL::isa($value, 'ODO::Node::Literal')) {
31 0         0 my $stmt = ODO::Statement->new($parent->subject(), $property, $value);
32 0         0 $parent->graph()->add($stmt);
33             }
34             else {
35             # The property's value is a URI with other attached URIs so add them
36             # all to the graph
37 0         0 my $stmt = ODO::Statement->new($parent->subject(), $property, $_[0]->subject());
38 0         0 $parent->graph()->add($stmt);
39 0         0 $parent->graph()->add( @{ $value } );
  0         0  
40             }
41             }
42            
43 5         18 return $parent->get_property_values( 'ODO::RDFS::Properties::subPropertyOf' );
44             }
45              
46              
47              
48              
49             sub range {
50 5     5 0 64 my $self = shift;
51              
52 5         13 my $parent = $self->{'parent'};
53 5 50       16 unless($parent) {
54 0         0 die('Fatal error in property container: parent object is not defined!');
55             }
56              
57 5 50 33     20 if( scalar(@_) > 0
58             && UNIVERSAL::isa($_[0], 'ODO::RDFS::Properties::range')) {
59              
60 0         0 my $value = $_[0]->value();
61            
62 0         0 my $property = ODO::Node::Resource->new( ODO::RDFS::Properties::range->objectURI() );
63 0 0       0 if(UNIVERSAL::isa($value, 'ODO::Node::Literal')) {
64 0         0 my $stmt = ODO::Statement->new($parent->subject(), $property, $value);
65 0         0 $parent->graph()->add($stmt);
66             }
67             else {
68             # The property's value is a URI with other attached URIs so add them
69             # all to the graph
70 0         0 my $stmt = ODO::Statement->new($parent->subject(), $property, $_[0]->subject());
71 0         0 $parent->graph()->add($stmt);
72 0         0 $parent->graph()->add( @{ $value } );
  0         0  
73             }
74             }
75            
76 5         20 return $parent->get_property_values( 'ODO::RDFS::Properties::range' );
77             }
78              
79              
80              
81              
82             sub domain {
83 5     5 0 59 my $self = shift;
84              
85 5         14 my $parent = $self->{'parent'};
86 5 50       17 unless($parent) {
87 0         0 die('Fatal error in property container: parent object is not defined!');
88             }
89              
90 5 50 33     20 if( scalar(@_) > 0
91             && UNIVERSAL::isa($_[0], 'ODO::RDFS::Properties::domain')) {
92              
93 0         0 my $value = $_[0]->value();
94            
95 0         0 my $property = ODO::Node::Resource->new( ODO::RDFS::Properties::domain->objectURI() );
96 0 0       0 if(UNIVERSAL::isa($value, 'ODO::Node::Literal')) {
97 0         0 my $stmt = ODO::Statement->new($parent->subject(), $property, $value);
98 0         0 $parent->graph()->add($stmt);
99             }
100             else {
101             # The property's value is a URI with other attached URIs so add them
102             # all to the graph
103 0         0 my $stmt = ODO::Statement->new($parent->subject(), $property, $_[0]->subject());
104 0         0 $parent->graph()->add($stmt);
105 0         0 $parent->graph()->add( @{ $value } );
  0         0  
106             }
107             }
108            
109 5         19 return $parent->get_property_values( 'ODO::RDFS::Properties::domain' );
110             }
111              
112              
113              
114              
115              
116              
117             1;