line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::RDB2RDF; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
150506
|
use 5.010; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
297
|
|
4
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
116
|
|
5
|
4
|
|
|
4
|
|
20958
|
use utf8; |
|
4
|
|
|
|
|
51
|
|
|
4
|
|
|
|
|
21
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
3418
|
use RDF::RDB2RDF::Simple; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use RDF::RDB2RDF::R2RML; |
9
|
|
|
|
|
|
|
use RDF::RDB2RDF::DirectMapping; |
10
|
|
|
|
|
|
|
use RDF::RDB2RDF::DirectMapping::Store; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
13
|
|
|
|
|
|
|
our $VERSION = '0.008'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new |
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
my ($class, $type, @args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $map = { |
20
|
|
|
|
|
|
|
simple => 'Simple', |
21
|
|
|
|
|
|
|
r2rml => 'R2RML', |
22
|
|
|
|
|
|
|
direct => 'DirectMapping', |
23
|
|
|
|
|
|
|
directmapping => 'DirectMapping', |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$type =~ s/[^A-Za-z0-9]//g; |
27
|
|
|
|
|
|
|
$type = $map->{lc $type} if exists $map->{lc $type}; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$class .= '::'.$type; |
30
|
|
|
|
|
|
|
$class->new(@args); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub process |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
die "Not implemented.\n"; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub process_turtle |
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
my ($self, $dbh, %options) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $model = $self->process($dbh); |
43
|
|
|
|
|
|
|
return RDF::Trine::Serializer |
44
|
|
|
|
|
|
|
->new('Turtle', %options) |
45
|
|
|
|
|
|
|
->serialize_model_to_string($model); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
{ |
49
|
|
|
|
|
|
|
package RDF::TrineX::Store::DirectMapping; |
50
|
|
|
|
|
|
|
our @ISA = 'RDF::RDB2RDF::DirectMapping::Store'; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
__END__ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding utf8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
RDF::RDB2RDF - map relational database to RDF declaratively |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
print RDF::RDB2RDF->new(R2RML => $r2rml)->process_turtle($dbh); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
It's quite common to want to map legacy relational (SQL) data to RDF. This is |
69
|
|
|
|
|
|
|
usually quite simple to do by looping through database tables and spitting out |
70
|
|
|
|
|
|
|
triples. Nothing wrong with that; I've done that in the past, and that's what |
71
|
|
|
|
|
|
|
RDF::RDB2RDF does under the hood. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
But it's nice to be able to write your mapping declaratively. This distribution |
74
|
|
|
|
|
|
|
provides three modules to enable that: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * L<RDF::RDB2RDF::Simple> - map relational database to RDF easily |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * L<RDF::RDB2RDF::R2RML> - map relational database to RDF using R2RML |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * L<RDF::RDB2RDF::DirectMapping> - map relational database to RDF directly |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=back |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
C<RDF::RDB2RDF> itself provides a wrapper for constructing mapper objects, |
87
|
|
|
|
|
|
|
and acts as a base class for the three implementations. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
There is also a module L<RDF::RDB2RDF::DirectMapping::Store> which uses |
90
|
|
|
|
|
|
|
the same mapping as L<RDF::RDB2RDF::DirectMapping> but provides the same |
91
|
|
|
|
|
|
|
interface as L<RDF::Trine::Store>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 BUGS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Please report any bugs to |
96
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=RDF-RDB2RDF>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SEE ALSO |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L<RDF::Trine>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<RDF::RDB2RDF::Simple>, |
103
|
|
|
|
|
|
|
L<RDF::RDB2RDF::R2RML>, |
104
|
|
|
|
|
|
|
L<RDF::RDB2RDF::DirectMapping>. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<RDF::RDB2RDF::DirectMapping::Store>. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<http://www.perlrdf.org/>. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Copyright 2011-2013 Toby Inkster |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it |
119
|
|
|
|
|
|
|
under the same terms as Perl itself. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
124
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
125
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
126
|
|
|
|
|
|
|
|