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/PerlEntity.pm,v $ |
10
|
|
|
|
|
|
|
# Created by: Stephen Evanchik( evanchik@us.ibm.com ) |
11
|
|
|
|
|
|
|
# Created on: 04/01/2005 |
12
|
|
|
|
|
|
|
# Revision: $Id: PerlEntity.pm,v 1.13 2009-11-25 17:58:25 ubuntu Exp $ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Contributors: |
15
|
|
|
|
|
|
|
# IBM Corporation - initial API and implementation |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
package ODO::Ontology::RDFS::PerlEntity; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
74
|
|
20
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
12
|
use ODO::Exception; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
23
|
2
|
|
|
2
|
|
12
|
use ODO::Ontology::RDFS::Vocabulary; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
86
|
|
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
2
|
|
12
|
use vars qw /$VERSION/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
197
|
|
26
|
|
|
|
|
|
|
$VERSION = sprintf "%d.%02d", q$Revision: 1.13 $ =~ /: (\d+)\.(\d+)/; |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
|
12
|
use base qw/ODO::Ontology::PerlEntity/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1262
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $CLASS_SYMTAB_URI = 'http://ibm-slrp.sourceforge.net/uris/odo/2007/01/rdfs/classes/'; |
31
|
|
|
|
|
|
|
our $PROPERTY_SYMTAB_URI = 'http://ibm-slrp.sourceforge.net/uris/odo/2007/01/rdfs/properties/'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $CLASS_IMPL_SYMTAB_URI = 'http://ibm-slrp.sourceforge.net/uris/odo/2007/01/rdfs/classes/impls'; |
34
|
|
|
|
|
|
|
our $PROPERTY_IMPL_SYMTAB_URI = 'http://ibm-slrp.sourceforge.net/uris/odo/2007/01/rdfs/properties/impls'; |
35
|
|
|
|
|
|
|
our $PROPERTY_ACC_IMPL_SYMTAB_URI = 'http://ibm-slrp.sourceforge.net/uris/odo/2007/01/rdfs/properties/accessors/impls'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new_instance { |
38
|
0
|
|
|
0
|
0
|
|
my ($self, $object_name, $resource) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $uri = $object_name; |
41
|
|
|
|
|
|
|
# At this point, the passed in is a URI or an ODO::Node::Resource object |
42
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Parameter::Invalid(error=> 'Resource parameter must be an ODO::Node::Resource or ODO::Node::Blank') |
43
|
|
|
|
|
|
|
unless(UNIVERSAL::isa($resource, 'ODO::Node::Resource')); |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
$object_name = $object_name->uri() |
46
|
|
|
|
|
|
|
if(UNIVERSAL::isa($object_name, 'ODO::Node::Resource')); |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
unless($self->__is_perl_package($object_name)) { |
49
|
0
|
|
0
|
|
|
|
$object_name = ( $self->ontology()->get_symtab_entry($CLASS_SYMTAB_URI, $object_name) |
50
|
|
|
|
|
|
|
|| $self->ontology()->get_symtab_entry($PROPERTY_SYMTAB_URI, $object_name) ); |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Runtime(error=> "Object: $uri does not have method 'new'") |
53
|
|
|
|
|
|
|
unless($object_name); |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $object_name->new($resource, $self->ontology()->graph(), @_); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub find_instances { |
60
|
0
|
|
|
0
|
0
|
|
my ($self, $object_name) = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $uri = $object_name; |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
unless($self->__is_perl_package($object_name)) { |
65
|
0
|
|
0
|
|
|
|
$object_name = ( $self->ontology()->get_symtab_entry($CLASS_SYMTAB_URI, $object_name) |
66
|
|
|
|
|
|
|
|| $self->ontology()->get_symtab_entry($PROPERTY_SYMTAB_URI, $object_name) ); |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Runtime(error=> "Object: $uri does not have method 'new'") |
69
|
|
|
|
|
|
|
unless($object_name); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Runtime(error=> "$object_name does not have a query string") |
73
|
|
|
|
|
|
|
unless($object_name->queryString()); |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $rdf_map = "rdf for <${ODO::Ontology::RDFS::Vocabulary::RDF}>"; |
76
|
0
|
|
|
|
|
|
my $rdfs_map = "rdfs for <${ODO::Ontology::RDFS::Vocabulary::RDFS}>"; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $qs_rdql = 'SELECT ?stmt WHERE ' . $object_name->queryString() . " USING $rdf_map, $rdfs_map"; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $results = $self->ontology()->graph()->query( $qs_rdql )->results(); |
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
|
|
|
|
throw ODO::Exception::Runtime(error=> "Error querying for the object: $object_name") |
83
|
|
|
|
|
|
|
unless($results); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $objects = []; |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
while(@{ $results }) { |
|
0
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $r = shift @{ $results }; |
|
0
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
push @{ $objects }, $object_name->new($r->subject(), $self->ontology()->graph()); |
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
return (wantarray) ? @{ $objects } : $objects; |
|
0
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub __find_class_instances { |
97
|
0
|
|
|
0
|
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
return $self->__find_instances(@_); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub __find_property_instances { |
103
|
0
|
|
|
0
|
|
|
my $self = shift; |
104
|
0
|
|
|
|
|
|
return $self->__find_instances(@_); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub __can_as { |
109
|
0
|
|
|
0
|
|
|
my ($self, $uri, $package) = @_; |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
return undef |
112
|
0
|
0
|
|
|
|
|
unless($self->($package)); |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
return 1; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub init { |
119
|
0
|
|
|
0
|
1
|
|
my ($self, $config) = @_; |
120
|
0
|
|
|
|
|
|
return $self->SUPER::init($config); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |