line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alzabo::Runtime::RowState::Potential; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
67
|
use strict; |
|
11
|
|
|
|
|
23
|
|
|
11
|
|
|
|
|
421
|
|
4
|
|
|
|
|
|
|
|
5
|
11
|
|
|
11
|
|
62
|
use Alzabo::Runtime; |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
278
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
60
|
use base qw(Alzabo::Runtime::RowState::Live); |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
7853
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _init |
10
|
|
|
|
|
|
|
{ |
11
|
0
|
|
|
0
|
|
|
my $class = shift; |
12
|
0
|
|
|
|
|
|
my $row = shift; |
13
|
0
|
|
|
|
|
|
my %p = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Can't just call ->update here cause with MethodMaker there may |
16
|
|
|
|
|
|
|
# be update hooks that probably shouldn't be invoked here. |
17
|
0
|
|
|
|
|
|
foreach ( keys %{ $p{values} } ) |
|
0
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
# This will throw an exception if the column doesn't exist. |
20
|
0
|
|
|
|
|
|
my $c = $row->table->column($_); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
0
|
|
|
|
Alzabo::Exception::Params->throw( error => "Column " . $c->name . " cannot be null." ) |
|
|
|
0
|
|
|
|
|
23
|
|
|
|
|
|
|
unless defined $p{values}->{$_} || $c->nullable || defined $c->default; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$row->{data}{$_} = $p{values}->{$_}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
foreach my $c ( $row->table->columns ) |
29
|
|
|
|
|
|
|
{ |
30
|
0
|
0
|
|
|
|
|
if ( defined $c->default ) |
31
|
|
|
|
|
|
|
{ |
32
|
0
|
|
|
|
|
|
my $name = $c->name; |
33
|
0
|
0
|
|
|
|
|
$row->{data}{$name} = $c->default unless defined $row->{data}{$name}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _get_data |
41
|
|
|
|
|
|
|
{ |
42
|
0
|
|
|
0
|
|
|
my $class = shift; |
43
|
0
|
|
|
|
|
|
my $row = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my %data; |
46
|
0
|
|
|
|
|
|
@data{@_} = @{ $row->{data} }{@_}; |
|
0
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return %data; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub update |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
54
|
0
|
|
|
|
|
|
my $row = shift; |
55
|
0
|
|
|
|
|
|
my %data = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
foreach my $k (keys %data) |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
# This will throw an exception if the column doesn't exist. |
60
|
0
|
|
|
|
|
|
my $c = $row->table->column($k); |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
0
|
|
|
|
Alzabo::Exception::NotNullable->throw |
|
|
|
0
|
|
|
|
|
63
|
|
|
|
|
|
|
( error => $c->name . " column in " . $row->table->name . " table cannot be null.", |
64
|
|
|
|
|
|
|
column_name => $c->name, |
65
|
|
|
|
|
|
|
) |
66
|
|
|
|
|
|
|
unless defined $data{$k} || $c->nullable || defined $c->default; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my $changed = 0; |
70
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each %data ) |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
0
|
|
|
|
|
next if $row->_cached_data_is_same( $k, $data{$k} ); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$row->{data}{$k} = $v; |
75
|
0
|
|
|
|
|
|
$changed = 1; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $changed; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# doesn't need to do anything |
82
|
0
|
|
|
0
|
0
|
|
sub refresh { } |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub delete |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
0
|
0
|
|
$_[1]->set_state( 'Alzabo::Runtime::RowState::Deleted' ); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
0
|
0
|
|
sub id_as_string { '' } |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
0
|
|
sub is_potential { 1 } |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
0
|
|
sub is_live { 0 } |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
0
|
0
|
|
sub is_deleted { 0 } |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |