| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Oryx::Schema; |
|
2
|
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
2479
|
use base qw(Class::Data::Inheritable); |
|
|
18
|
|
|
|
|
36
|
|
|
|
18
|
|
|
|
|
9691
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Oryx::Schema - Schema class for Oryx |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package CMS::Schema; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# enable auto deploy for all classes |
|
14
|
|
|
|
|
|
|
use Oryx::Class(auto_deploy => 1); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# useful if you want to say $storage->deploySchema('CMS::Schema'); |
|
17
|
|
|
|
|
|
|
use CMS::Page; |
|
18
|
|
|
|
|
|
|
use CMS::Paragraph; |
|
19
|
|
|
|
|
|
|
use CMS::Image; |
|
20
|
|
|
|
|
|
|
use CMS::Author; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub prefix { 'cms' } |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
1; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#================================================================== |
|
27
|
|
|
|
|
|
|
# ALTERNATIVE - With XML::DOM::Lite installed |
|
28
|
|
|
|
|
|
|
#================================================================== |
|
29
|
|
|
|
|
|
|
package CMS::Schema; |
|
30
|
|
|
|
|
|
|
use base qw(Oryx::Schema); |
|
31
|
|
|
|
|
|
|
1; |
|
32
|
|
|
|
|
|
|
__DATA__ |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use CMS::Schema; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $cms_storage = Oryx->connect(\@conn, 'CMS::Schema'); |
|
47
|
|
|
|
|
|
|
CMS::Schema->addClass('CMS::Revision'); |
|
48
|
|
|
|
|
|
|
my @cms_classes = CMS::Schema->classes; |
|
49
|
|
|
|
|
|
|
$cms_storage->deploySchema(); # deploys only classes seen by CMS::Schema |
|
50
|
|
|
|
|
|
|
$cms_storage->deploySchema('CMS::Schema') # same thing, but `use's CMS::Schema first |
|
51
|
|
|
|
|
|
|
my $name = CMS::Schema->name; # returns CMS_Schema |
|
52
|
|
|
|
|
|
|
CMS::Schema->hasClass($classname); # true if seen $classname |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Schema class for Oryx. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The use of this class is optional. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The intention is to allow arbitrary grouping of classes |
|
62
|
|
|
|
|
|
|
into different namespaces to support simultaneous use of |
|
63
|
|
|
|
|
|
|
different storage backends, or for having logically separate |
|
64
|
|
|
|
|
|
|
groups of classes in the same database, but having table |
|
65
|
|
|
|
|
|
|
names prefixed to provide namespace separation. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_classes'); |
|
70
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_name'); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub new { |
|
73
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
74
|
0
|
0
|
|
|
|
|
$class->_classes({ }) unless defined $class->_classes; |
|
75
|
0
|
|
|
|
|
|
return bless { }, $class; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub name { |
|
79
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
80
|
0
|
0
|
|
|
|
|
if (@_) { |
|
81
|
0
|
|
|
|
|
|
$_[0] =~ s/::/_/g; |
|
82
|
0
|
|
|
|
|
|
$self->_name($_[0]); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
0
|
0
|
|
|
|
|
unless ($self->_name) { |
|
85
|
0
|
|
0
|
|
|
|
my $name = ref($self) || $self; |
|
86
|
0
|
|
|
|
|
|
$name =~ s/::/_/g; |
|
87
|
0
|
|
|
|
|
|
$self->_name($name); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
0
|
|
|
|
|
|
return $self->_name; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub prefix { |
|
93
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
94
|
0
|
0
|
|
|
|
|
if (@_) { |
|
95
|
0
|
|
|
|
|
|
$self->{prefix} = shift; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
0
|
0
|
|
|
|
|
unless (defined $self->{prefix}) { |
|
98
|
0
|
|
|
|
|
|
$self->{prefix} = ''; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
0
|
|
|
|
|
|
return $self->{prefix}; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub classes { |
|
104
|
0
|
|
|
0
|
|
|
my @gens = grep { UNIVERSAL::isa($_, 'Oryx::Schema::Generator') } @INC; |
|
|
0
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
foreach my $gen (@gens) { $gen->requireAll() } |
|
|
0
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
keys %{$_[0]->_classes}; |
|
|
0
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub addClass { |
|
110
|
0
|
|
|
0
|
|
|
my ($self, $class) = @_; |
|
111
|
0
|
|
|
|
|
|
$self->_classes->{$class}++; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub hasClass { |
|
115
|
0
|
|
|
0
|
|
|
return shift->class(@_); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub class { |
|
119
|
0
|
|
|
0
|
|
|
my $class = $_[0]->_classes->{$_[1]}; |
|
120
|
0
|
|
|
|
|
|
return $class; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub loadXML { |
|
124
|
|
|
|
|
|
|
my $self = shift; |
|
125
|
|
|
|
|
|
|
my $xstr = shift; |
|
126
|
18
|
|
|
18
|
|
11914
|
use XML::DOM::Lite::Parser; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
use Oryx::Schema::Generator; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $parser = XML::DOM::Lite::Parser->new( whitespace => 'strip' ); |
|
130
|
|
|
|
|
|
|
my $doc = $parser->parse( $xstr ); |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
push @INC, Oryx::Schema::Generator->new( $doc ); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub import { |
|
136
|
|
|
|
|
|
|
my $class = shift; |
|
137
|
|
|
|
|
|
|
my $fh = *{"$class\::DATA"}{IO}; |
|
138
|
|
|
|
|
|
|
return undef unless $fh; |
|
139
|
|
|
|
|
|
|
local $/ = undef; |
|
140
|
|
|
|
|
|
|
my $data = <$fh>; |
|
141
|
|
|
|
|
|
|
if ($data) { |
|
142
|
|
|
|
|
|
|
$class->loadXML($data); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L, L |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 AUTHOR |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Copyright (C) 2005 Richard Hundt |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 LICENSE |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This library is free software and may be used under the same terms as Perl itself. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |