line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2005-2006 IBM Corporation. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# All rights reserved. This program and the accompanying materials |
5
|
|
|
|
|
|
|
# are made available under the terms of the Eclipse Public License v1.0 |
6
|
|
|
|
|
|
|
# which accompanies this distribution, and is available at |
7
|
|
|
|
|
|
|
# http://www.eclipse.org/legal/epl-v10.html |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# File: $Source: /var/lib/cvs/ODO/lib/ODO/Ontology/RDFS/BaseClass.pm,v $ |
10
|
|
|
|
|
|
|
# Created by: Stephen Evanchik( evanchik@us.ibm.com ) |
11
|
|
|
|
|
|
|
# Created on: 02/22/2005 |
12
|
|
|
|
|
|
|
# Revision: $Id: BaseClass.pm,v 1.4 2009-11-25 17:58:25 ubuntu Exp $ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Contributors: |
15
|
|
|
|
|
|
|
# IBM Corporation - initial API and implementation |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
package ODO::Ontology::RDFS::BaseClass; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
100
|
|
20
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
70
|
|
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
14
|
use ODO::Exception; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
250
|
|
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
16
|
use ODO::Node; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
106
|
|
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
3
|
|
16
|
use ODO::Query::Simple; |
|
3
|
|
|
|
|
18
|
|
|
3
|
|
|
|
|
80
|
|
27
|
3
|
|
|
3
|
|
1766
|
use ODO::Query::RDQL::Parser; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
172
|
|
28
|
3
|
|
|
3
|
|
2576
|
use ODO::Ontology::RDFS::Vocabulary; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
255
|
|
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
3
|
|
19
|
use base qw/ODO/; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
271
|
|
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
3
|
|
31
|
use vars qw /$VERSION/; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
3308
|
|
33
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /: (\d+)\.(\d+)/; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our @METHODS = qw/graph subject propertyContainerName properties propertyURIMap/; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(@METHODS); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
ODO::Ontology::RDFS::BaseClass |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 DESCRIPTION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 METHODS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=over |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item value( ) |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub value { |
58
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return undef |
61
|
0
|
0
|
|
|
|
0
|
unless(UNIVERSAL::isa($self->subject(), 'ODO::Node')); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
return $self->subject()->value(); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item query( ) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub query { |
72
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
0
|
my $rdf_map = "rdf for <${ODO::Ontology::RDFS::Vocabulary::RDF}>"; |
75
|
0
|
|
|
|
|
0
|
my $rdfs_map = "rdfs for <${ODO::Ontology::RDFS::Vocabulary::RDFS}>"; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
my $qs_rdql = 'SELECT ?stmt WHERE ' . $self->queryString() . " USING $rdf_map, $rdfs_map"; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
my $results = $self->issue_query( $qs_rdql ); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
my $objects = []; |
82
|
0
|
|
|
|
|
0
|
while(@{ $results }) { |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
my $r = shift @{ $results }; |
|
0
|
|
|
|
|
0
|
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
my $object = ref $self; |
87
|
0
|
|
|
|
|
0
|
push @{ $objects }, $object->new($r->subject(), $self->graph()); |
|
0
|
|
|
|
|
0
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
0
|
|
|
|
0
|
return (wantarray) ? @{ $objects } : $objects; |
|
0
|
|
|
|
|
0
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item get_property_values( $property_perl_package_name ) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub get_property_values { |
99
|
128
|
|
|
128
|
1
|
195
|
my ($self, $property_perl_package_name) = @_; |
100
|
128
|
|
|
|
|
7751
|
eval "require $property_perl_package_name"; |
101
|
|
|
|
|
|
|
# Only Resources can have properties |
102
|
128
|
50
|
|
|
|
17252
|
throw ODO::Exception::Runtime(error=> 'Subject is not a ODO::Node::Resource') |
103
|
|
|
|
|
|
|
unless(UNIVERSAL::isa($self->subject(), 'ODO::Node::Resource')); |
104
|
|
|
|
|
|
|
|
105
|
128
|
50
|
|
|
|
1138
|
throw ODO::Exception::Runtime(error=> 'Missing graph') |
106
|
|
|
|
|
|
|
unless($self->graph()); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Create a triple match that can get all of _THIS_ object's |
109
|
|
|
|
|
|
|
# instances of the specific property. |
110
|
128
|
|
|
|
|
865
|
my $property_query = ODO::Query::Simple->new($self->subject(), ODO::Node::Resource->new($property_perl_package_name->objectURI()), $ODO::Node::ANY); |
111
|
|
|
|
|
|
|
|
112
|
128
|
|
|
|
|
1125
|
my $results = $self->graph()->query($property_query)->results(); |
113
|
|
|
|
|
|
|
|
114
|
128
|
|
|
|
|
1329
|
my $objects = []; |
115
|
|
|
|
|
|
|
|
116
|
128
|
|
|
|
|
181
|
while(@{ $results }) { |
|
157
|
|
|
|
|
394
|
|
117
|
29
|
|
|
|
|
32
|
my $r = shift @{ $results }; |
|
29
|
|
|
|
|
48
|
|
118
|
29
|
|
|
|
|
34
|
push @{ $objects }, $property_perl_package_name->new($r->object(), $self->graph()); |
|
29
|
|
|
|
|
96
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
128
|
50
|
|
|
|
853
|
return (wantarray) ? @{ $objects } : $objects; |
|
0
|
|
|
|
|
0
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item issue_query( $query ) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub issue_query { |
130
|
0
|
|
|
0
|
1
|
0
|
my ($self, $query) = @_; |
131
|
0
|
|
|
|
|
0
|
my $result_set = $self->graph()->query($query); |
132
|
0
|
|
|
|
|
0
|
my $results = $result_set->results(); |
133
|
0
|
0
|
|
|
|
0
|
return (wantarray) ? @{ $results } : $results; |
|
0
|
|
|
|
|
0
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub new { |
137
|
40
|
|
|
40
|
1
|
68
|
my ($self, $resource, $graph) = @_; |
138
|
40
|
|
|
|
|
163
|
return $self->Class::Base::new(subject=> $resource, graph=> $graph); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub init { |
142
|
40
|
|
|
40
|
1
|
945
|
my ($self, $config) = @_; |
143
|
40
|
|
|
|
|
167
|
$self->params($config, qw/subject graph/); |
144
|
40
|
|
|
|
|
1460
|
$self->propertyURIMap( {} ); |
145
|
40
|
|
|
|
|
304
|
return $self; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Copyright (c) 2004-2006 IBM Corporation. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
All rights reserved. This program and the accompanying materials |
156
|
|
|
|
|
|
|
are made available under the terms of the Eclipse Public License v1.0 |
157
|
|
|
|
|
|
|
which accompanies this distribution, and is available at |
158
|
|
|
|
|
|
|
http://www.eclipse.org/legal/epl-v10.html |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__END__ |