Core/Model.pm

filter: Statementstmt 20.0% 12 / 60 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 39 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 21.4% 3 / 14 Podpod 100% 10 / 10 totaltotal 14.8% 25 / 168 CC 26 SCAR 29.5
CC
26
Cov
10%
getObjects
42.0
addStmt
20.0
removeStmt
20.0
CRAP 19.1
« Core/Statement.pm ↑ Summary Core/Schema.pm »
1 #
2 # The contents of this file are subject to the Mozilla Public
3 # License Version 1.1 (the "License"); you may not use this file
4 # except in compliance with the License. You may obtain a copy of
5 # the License at http://www.mozilla.org/MPL/
6 #
7 # Software distributed under the License is distributed on an "AS
8 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 # implied. See the License for the specific language governing
10 # rights and limitations under the License.
11 #
12 # The Original Code is the RDF::Core module
13 #
14 # The Initial Developer of the Original Code is Ginger Alliance Ltd.
15 # Portions created by Ginger Alliance are
16 # Copyright (C) 2001 Ginger Alliance Ltd.
17 # All Rights Reserved.
18 #
19 # Contributor(s):
20 #
21 # Alternatively, the contents of this file may be used under the
22 # terms of the GNU General Public License Version 2 or later (the
23 # "GPL"), in which case the provisions of the GPL are applicable
24 # instead of those above. If you wish to allow use of your
25 # version of this file only under the terms of the GPL and not to
26 # allow others to use your version of this file under the MPL,
27 # indicate your decision by deleting the provisions above and
28 # replace them with the notice and other provisions required by
29 # the GPL. If you do not delete the provisions above, a recipient
30 # may use your version of this file under either the MPL or the
31 # GPL.
32 #
33  
34 package RDF::Core::Model;
35  
36 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 require Exporter;
38  
39 2 require RDF::Core::Resource;
40 2 ▶use RDF::Core::Constants qw(:rdf);
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
45 0 my ($pkg,%options) = @_;
46 0 ▶ $pkg = ref $pkg || $pkg;
Condition0%0/3
ref $pkg || $pkg
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $pkg || $pkg
ref $pkg $pkg
Truth table0%0/3
A || B
A= ref $pkgB= $pkg
ABresult
1X1
011
000
47 0 my $self = {};
48 0 $self->{_options} = \%options;
49 0 bless $self, $pkg;
50 }
51 0 ▶sub setOptions {
Subroutine setOptions: not called CC=1 SCAR=6.9
Pod documented
52 0 my ($self,$options) = @_;
53 0 $self->{_options} = $options;
54 }
55 0 ▶sub getOptions {
Subroutine getOptions: not called CC=1 SCAR=6.9
Pod documented
56 0 my $self = shift;
57 0 return $self->{_options};
58 }
59 0 ▶sub addStmt {
Subroutine addStmt: not called CC=4 SCAR=30.0
Pod documented
60 0 my $self = shift;
61 carp "No storage defined"
62 unless exists $self->{_options}->{Storage} &&
63 defined $self->{_options}->{Storage} &&
64 0 ▶ ref $self->{_options}->{Storage};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"} 0 0 0
Condition0%0/6
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
exists $self->{"_options"}{"Storage"} defined $self->{"_options"}{"Storage"} ref $self->{"_options"}{"Storage"}
Truth table0%0/4
A and B and C
A= exists $self->{"_options"}{"Storage"}B= defined $self->{"_options"}{"Storage"}C= ref $self->{"_options"}{"Storage"}
ABCresult
0XX0
10X0
1100
1111
65 0 $self->{_options}->{Storage}->addStmt(@_);
66 }
67 0 ▶sub removeStmt {
Subroutine removeStmt: not called CC=4 SCAR=30.0
Pod documented
68 0 my $self = shift;
69 carp "No storage defined"
70 unless exists $self->{_options}->{Storage} &&
71 defined $self->{_options}->{Storage} &&
72 0 ▶ ref $self->{_options}->{Storage};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"} 0 0 0
Condition0%0/6
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
exists $self->{"_options"}{"Storage"} defined $self->{"_options"}{"Storage"} ref $self->{"_options"}{"Storage"}
Truth table0%0/4
A and B and C
A= exists $self->{"_options"}{"Storage"}B= defined $self->{"_options"}{"Storage"}C= ref $self->{"_options"}{"Storage"}
ABCresult
0XX0
10X0
1100
1111
73 0 $self->{_options}->{Storage}->removeStmt(@_);
74 }
75 0 ▶sub existsStmt {
Subroutine existsStmt: not called CC=4 SCAR=30.0
Pod documented
76 0 my $self = shift;
77 carp "No storage defined"
78 unless exists $self->{_options}->{Storage} &&
79 defined $self->{_options}->{Storage} &&
80 0 ▶ ref $self->{_options}->{Storage};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"} 0 0 0
Condition0%0/6
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
exists $self->{"_options"}{"Storage"} defined $self->{"_options"}{"Storage"} ref $self->{"_options"}{"Storage"}
Truth table0%0/4
A and B and C
A= exists $self->{"_options"}{"Storage"}B= defined $self->{"_options"}{"Storage"}C= ref $self->{"_options"}{"Storage"}
ABCresult
0XX0
10X0
1100
1111
81 0 $self->{_options}->{Storage}->existsStmt(@_);
82 }
83 0 ▶sub getStmts {
Subroutine getStmts: not called CC=4 SCAR=30.0
Pod documented
84 0 my $self = shift;
85 carp "No storage defined"
86 unless exists $self->{_options}->{Storage} &&
87 defined $self->{_options}->{Storage} &&
88 0 ▶ ref $self->{_options}->{Storage};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"} 0 0 0
Condition0%0/6
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
exists $self->{"_options"}{"Storage"} defined $self->{"_options"}{"Storage"} ref $self->{"_options"}{"Storage"}
Truth table0%0/4
A and B and C
A= exists $self->{"_options"}{"Storage"}B= defined $self->{"_options"}{"Storage"}C= ref $self->{"_options"}{"Storage"}
ABCresult
0XX0
10X0
1100
1111
89 0 $self->{_options}->{Storage}->getStmts(@_);
90 }
91 0 ▶sub countStmts {
Subroutine countStmts: not called CC=4 SCAR=30.0
Pod documented
92 0 my $self = shift;
93 carp "No storage defined"
94 unless exists $self->{_options}->{Storage} &&
95 defined $self->{_options}->{Storage} &&
96 0 ▶ ref $self->{_options}->{Storage};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"} 0 0 0
Condition0%0/6
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $self->{"_options"}{"Storage"} and defined $self->{"_options"}{"Storage"} and ref $self->{"_options"}{"Storage"}
exists $self->{"_options"}{"Storage"} defined $self->{"_options"}{"Storage"} ref $self->{"_options"}{"Storage"}
Truth table0%0/4
A and B and C
A= exists $self->{"_options"}{"Storage"}B= defined $self->{"_options"}{"Storage"}C= ref $self->{"_options"}{"Storage"}
ABCresult
0XX0
10X0
1100
1111
97 0 $self->{_options}->{Storage}->countStmts(@_);
98 }
99  
100 0 ▶sub getObjects {
Subroutine getObjects: not called CC=6 SCAR=37.4
Pod documented
101 0 my ($self, $subj, $pred) = @_;
102 0 ▶ $subj = new RDF::Core::Resource($subj)
Branch: 1 branch
BranchTrueFalseTotal
unless ref $subj and $subj->isa("RDF::Core::Resource") 0 0 0
Condition0%0/3
ref $subj and $subj->isa("RDF::Core::Resource")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $subj and $subj->isa("RDF::Core::Resource")
ref $subj $subj->isa("RDF::Core::Resource")
Truth table0%0/3
A and B
A= ref $subjB= $subj->isa("RDF::Core::Resource")
ABresult
0X0
100
111
103 unless (ref $subj && $subj->isa("RDF::Core::Resource"));
104 0 ▶ $pred = new RDF::Core::Resource($pred)
Branch: 1 branch
BranchTrueFalseTotal
unless ref $pred and $pred->isa("RDF::Core::Resource") 0 0 0
Condition0%0/3
ref $pred and $pred->isa("RDF::Core::Resource")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $pred and $pred->isa("RDF::Core::Resource")
ref $pred $pred->isa("RDF::Core::Resource")
Truth table0%0/3
A and B
A= ref $predB= $pred->isa("RDF::Core::Resource")
ABresult
0X0
100
111
105 unless (ref $pred && $pred->isa("RDF::Core::Resource"));
106 0 my $enum = $self->getStmts($subj, $pred, undef);
107 0 my $stmt = $enum->getFirst;
108 0 my $ret = [];
109 0 ▶ while ($stmt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt) 0 0 0
110 0 push @$ret, $stmt->getObject;
111 0 $stmt = $enum->getNext;
112 }
113 0 return $ret;
114 }
115  
116 0 ▶sub _rdf_container_sort {
Subroutine _rdf_container_sort: not called CC=3 SCAR=24.8
117 0 my ($a, $b) = @_;
118 0 ▶ my $aa = $1 if $a->getPredicate->getURI =~ /.*#_(\d+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $a->getPredicate->getURI =~ /.*#_(\d+)/ 0 0 0
119 0 ▶ my $bb = $1 if $b->getPredicate->getURI =~ /.*#_(\d+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $b->getPredicate->getURI =~ /.*#_(\d+)/ 0 0 0
120 0 return $aa <=> $bb;
121 }
122  
123 0 ▶sub getContainerObjects {
Subroutine getContainerObjects: not called CC=3 SCAR=24.8
Pod documented
124 0 my ($self, $cont) = @_;
125 0 my $members = $self->getStmts($cont, undef, undef);
126 0 my $member = $members->getFirst;
127 0 my @arr;
128 0 ▶ while ($member) {
Branch: 1 branch
BranchTrueFalseTotal
if ($member) 0 0 0
129 0 ▶ push @arr, $member unless $member->getPredicate->equals(RDF_TYPE);
Branch: 1 branch
BranchTrueFalseTotal
unless $member->getPredicate->equals("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") 0 0 0
130 0 $member = $members->getNext;
131 }
132
133 0 return [map {$_->getObject} sort {_rdf_container_sort($a, $b)} @arr];
134 }
135  
136 2 1;
137 __END__
« Core/Statement.pm ↑ Summary Core/Schema.pm »