| 1 | # | ||||||||||||||||||||||||||||||||
| 2 | # DESCRIPTION | ||||||||||||||||||||||||||||||||
| 3 | # PerlORM - Object relational mapper (ORM) for Perl. PerlORM is Perl | ||||||||||||||||||||||||||||||||
| 4 | # library that implements object-relational mapping. Its features are | ||||||||||||||||||||||||||||||||
| 5 | # much similar to those of Java's Hibernate library, but interface is | ||||||||||||||||||||||||||||||||
| 6 | # much different and easier to use. | ||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||
| 8 | # AUTHOR | ||||||||||||||||||||||||||||||||
| 9 | # Alexey V. Akimov <akimov_alexey@sourceforge.net> | ||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||
| 11 | # COPYRIGHT | ||||||||||||||||||||||||||||||||
| 12 | # Copyright (C) 2005-2006 Alexey V. Akimov | ||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||
| 14 | # This library is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||||||
| 15 | # modify it under the terms of the GNU Lesser General Public | ||||||||||||||||||||||||||||||||
| 16 | # License as published by the Free Software Foundation; either | ||||||||||||||||||||||||||||||||
| 17 | # version 2.1 of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||
| 19 | # This library is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||
| 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||
| 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||||||
| 22 | # Lesser General Public License for more details. | ||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||
| 24 | # You should have received a copy of the GNU Lesser General Public | ||||||||||||||||||||||||||||||||
| 25 | # License along with this library; if not, write to the Free Software | ||||||||||||||||||||||||||||||||
| 26 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use English; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use Cwd 'abs_path'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use ORM::Meta::ORM::History; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | ## | ||||||||||||||||||||||||||||||||
| 34 | ## CONSTRUCTORS | ||||||||||||||||||||||||||||||||
| 35 | ## | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | ## use: $hist = $history_class->new | ||||||||||||||||||||||||||||||||
| 38 | ## ( | ||||||||||||||||||||||||||||||||
| 39 | ## obj => ORM, | ||||||||||||||||||||||||||||||||
| 40 | ## changed => { $prop1_name => [ $old_value, $new_value ], ... }, | ||||||||||||||||||||||||||||||||
| 41 | ## error => ORM::Error, | ||||||||||||||||||||||||||||||||
| 42 | ## ); | ||||||||||||||||||||||||||||||||
| 43 | ## | ||||||||||||||||||||||||||||||||
| 44 | ## use: $hist = $history_class->new | ||||||||||||||||||||||||||||||||
| 45 | ## ( | ||||||||||||||||||||||||||||||||
| 46 | ## obj => ORM, | ||||||||||||||||||||||||||||||||
| 47 | ## created => 1, | ||||||||||||||||||||||||||||||||
| 48 | ## error => ORM::Error, | ||||||||||||||||||||||||||||||||
| 49 | ## ); | ||||||||||||||||||||||||||||||||
| 50 | ## | ||||||||||||||||||||||||||||||||
| 51 | ## use: $hist = $history_class->new | ||||||||||||||||||||||||||||||||
| 52 | ## ( | ||||||||||||||||||||||||||||||||
| 53 | ## obj => ORM, | ||||||||||||||||||||||||||||||||
| 54 | ## deleted => 1, | ||||||||||||||||||||||||||||||||
| 55 | ## error => ORM::Error, | ||||||||||||||||||||||||||||||||
| 56 | ## ); | ||||||||||||||||||||||||||||||||
| 57 | ## | ||||||||||||||||||||||||||||||||
| 58 | sub new | ||||||||||||||||||||||||||||||||
| 59 | 9 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=14 SCAR=27.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 60 | 9 | my $class = shift; | |||||||||||||||||||||||||||||||
| 61 | 9 | my %arg = @_; | |||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my %prop = defined $arg{prop} ? %{$arg{prop}} : (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 63 | 9 | my $error = ORM::Error->new; | |||||||||||||||||||||||||||||||
| 64 | 9 | my @record; | |||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | # Define common properties | ||||||||||||||||||||||||||||||||
| 67 | 9 | delete $arg{prop}; | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 9 | $prop{obj_class} = ref $arg{obj}; | |||||||||||||||||||||||||||||||
| 70 | 9 | $prop{obj_id} = $arg{obj}->id; | |||||||||||||||||||||||||||||||
| 71 | 9 | $prop{date} = time; | |||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | 9 | ▶ | if( $::ENV{REQUEST_URI} ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||
| 75 | $prop{editor} = | ||||||||||||||||||||||||||||||||
| 76 | "WWW: " . | ||||||||||||||||||||||||||||||||
| 77 | $::ENV{REMOTE_USER} . '@' . $::ENV{SERVER_NAME} . ':' . | ||||||||||||||||||||||||||||||||
| 78 | $::ENV{SERVER_PORT} . $::ENV{REQUEST_URI} . | ||||||||||||||||||||||||||||||||
| 79 | 0 | ", RemoteIP: " . $::ENV{REMOTE_ADDR}; | |||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | else | ||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||
| 83 | 9 | my $exec; | |||||||||||||||||||||||||||||||
| 84 | 9 | ▶ | $exec = abs_path( $0 ) unless( $OSNAME eq 'MSWin32' ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 85 | 9 | $prop{editor} = "Exec[$PID]: $exec, UID: ${UID}:".(int $GID).", EUID: ${EUID}:".(int $EGID); | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | # Define operation related properties and create objects | ||||||||||||||||||||||||||||||||
| 89 | 9 | ▶ | if( $arg{created} ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 90 | { | ||||||||||||||||||||||||||||||||
| 91 | 2 | $prop{slaved_by} = undef; | |||||||||||||||||||||||||||||||
| 92 | 2 | $prop{prop_name} = 'id'; | |||||||||||||||||||||||||||||||
| 93 | 2 | $prop{old_value} = undef; | |||||||||||||||||||||||||||||||
| 94 | 2 | $prop{new_value} = $arg{obj}->id; | |||||||||||||||||||||||||||||||
| 95 | 2 | push @record, $class->SUPER::new( prop=>\%prop, error=>$error ); | |||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | elsif( $arg{deleted} ) | ||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||
| 99 | 2 | $prop{slaved_by} = undef; | |||||||||||||||||||||||||||||||
| 100 | 2 | $prop{prop_name} = 'id'; | |||||||||||||||||||||||||||||||
| 101 | 2 | $prop{old_value} = $arg{obj}->id; | |||||||||||||||||||||||||||||||
| 102 | 2 | $prop{new_value} = undef; | |||||||||||||||||||||||||||||||
| 103 | 2 | $prop{slaved_by} = $class->SUPER::new( prop=>\%prop, error=>$error ); | |||||||||||||||||||||||||||||||
| 104 | 2 | push @record, $prop{slaved_by}; | |||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 2 | for my $prop ( (ref $arg{obj})->_not_mandatory_props ) | |||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||
| 108 | 8 | ▶ | if( $error->fatal ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||
| 110 | 0 | last; | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | else | ||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||
| 114 | 8 | $prop{prop_name} = $prop; | |||||||||||||||||||||||||||||||
| 115 | 8 | $prop{old_value} = $arg{obj}{_ORM_data}{$prop}; | |||||||||||||||||||||||||||||||
| 116 | 8 | $prop{new_value} = undef; | |||||||||||||||||||||||||||||||
| 117 | 8 | push @record, $class->SUPER::new( prop=>\%prop, error=>$error ); | |||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||
| 121 | else | ||||||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||||||
| 123 | 5 | $prop{slaved_by} = undef; | |||||||||||||||||||||||||||||||
| 124 | 5 | for my $prop ( keys %{$arg{changed}} ) | |||||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||||||
| 126 | 7 | my $record; | |||||||||||||||||||||||||||||||
| 127 | 7 | ▶ | if( $error->fatal ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | { | ||||||||||||||||||||||||||||||||
| 129 | 0 | last; | |||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||
| 131 | else | ||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||
| 133 | 7 | $prop{prop_name} = $prop; | |||||||||||||||||||||||||||||||
| 134 | 7 | $prop{old_value} = $arg{changed}{$prop}[0]; | |||||||||||||||||||||||||||||||
| 135 | 7 | $prop{new_value} = $arg{changed}{$prop}[1]; | |||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 7 | $record = $class->SUPER::new( prop=>\%prop, %arg ); | |||||||||||||||||||||||||||||||
| 138 | 7 | ▶ | $prop{slaved_by} = $record unless( $prop{slaved_by} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 139 | 7 | push @record, $record; | |||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | # Rollback creation of history object if error occured | ||||||||||||||||||||||||||||||||
| 145 | 9 | ▶ | if( $error->fatal ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | while( my $record = pop @record ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 148 | { | ||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $record->SUPER::delete( error=>$error ) if( defined $record ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 9 | $error->upto( $arg{error} ); | |||||||||||||||||||||||||||||||
| 154 | 9 | return $record[0]; | |||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | ## | ||||||||||||||||||||||||||||||||
| 158 | ## PROPERTIES | ||||||||||||||||||||||||||||||||
| 159 | ## | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | sub obj | ||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
obj: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 163 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | unless( $self->{obj} ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||
| 167 | 0 | $self->_load_ORM_class( $self->obj_class ); | |||||||||||||||||||||||||||||||
| 168 | 0 | $self->{obj} = $self->obj_class->find_id( id=>$self->obj_id ); | |||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | 0 | return $self->{obj}; | |||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub master { ! $_[0]->slaved_by; } | ||||||||||||||||||||||||||||||
|
Subroutine
master: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | ## | ||||||||||||||||||||||||||||||||
| 177 | ## METHODS | ||||||||||||||||||||||||||||||||
| 178 | ## | ||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | sub update | ||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 182 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 183 | 0 | my %arg = @_; | |||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | $arg{error} && $arg{error}->add_fatal( "Updates of history have no sense" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | sub delete | ||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 190 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 191 | 0 | my $class = ref $self; | |||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if( $self->slaved_by ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 194 | { | ||||||||||||||||||||||||||||||||
| 195 | 0 | $arg{error}->add_fatal( "You should not delete slaved objects, delete master instead" ); | |||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | else | ||||||||||||||||||||||||||||||||
| 198 | { | ||||||||||||||||||||||||||||||||
| 199 | 0 | my @slave = $class->find | |||||||||||||||||||||||||||||||
| 200 | ( | ||||||||||||||||||||||||||||||||
| 201 | filter => ( $class->M->slaved_by == $self ), | ||||||||||||||||||||||||||||||||
| 202 | error => $error, | ||||||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||||||
| 204 | 0 | for my $slave ( @slave ) | |||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||
| 206 | 0 | $slave->delete( @_ ); | |||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | 0 | $self->SUPER::delete( @_ ); | |||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||
| 212 | sub rollback | ||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
rollback: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 214 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 215 | 0 | my $class = ref $self; | |||||||||||||||||||||||||||||||
| 216 | 0 | my %arg = @_; | |||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if( $self->slaved_by ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||
| 220 | $arg{error}->add_fatal | ||||||||||||||||||||||||||||||||
| 221 | ( | ||||||||||||||||||||||||||||||||
| 222 | 0 | "You should not rollback slaved object, rollback its master instead" | |||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | else | ||||||||||||||||||||||||||||||||
| 226 | { | ||||||||||||||||||||||||||||||||
| 227 | 0 | my $error = ORM::Error->new; | |||||||||||||||||||||||||||||||
| 228 | 0 | my $obj; | |||||||||||||||||||||||||||||||
| 229 | my @slave; | ||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||
| 231 | # Case of created object | ||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if( $self->prop_name eq 'id' && $self->old_value == undef ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$self->prop_name eq "id" and $self->old_value == undef
MC/DC0%0/2
$self->prop_name eq "id" and $self->old_value == undef
$self->prop_name eq "id"
$self->old_value == undef
Truth table0%0/3
A and B
A= $self->prop_name eq "id"B= $self->old_value == undef
| |||||||||||||||||||||||||||||||||
| 233 | { | ||||||||||||||||||||||||||||||||
| 234 | 0 | $obj = $self->obj_class->find_id( id=>$self->obj_id, error=>$error ); | |||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if( $obj ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||||||
| 237 | 0 | $obj->delete( error=>$error, history=>0 ); | |||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||
| 239 | else | ||||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||
| 241 | 0 | $error->add_fatal | |||||||||||||||||||||||||||||||
| 242 | ( | ||||||||||||||||||||||||||||||||
| 243 | "Can't rollback creation of object #" . $self->obj_id | ||||||||||||||||||||||||||||||||
| 244 | . " of class '".$self->obj_class."' because it doesn't exist" | ||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||
| 248 | # Case of deleted object | ||||||||||||||||||||||||||||||||
| 249 | ▶ | elsif( $self->prop_name eq 'id' && $self->new_value == undef ) | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->prop_name eq "id" and $self->new_value == undef
MC/DC0%0/2
$self->prop_name eq "id" and $self->new_value == undef
$self->prop_name eq "id"
$self->new_value == undef
Truth table0%0/3
A and B
A= $self->prop_name eq "id"B= $self->new_value == undef
| |||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||
| 251 | 0 | @slave = $class->find | |||||||||||||||||||||||||||||||
| 252 | ( | ||||||||||||||||||||||||||||||||
| 253 | filter => ( $class->M->slaved_by == $self ), | ||||||||||||||||||||||||||||||||
| 254 | error => $error, | ||||||||||||||||||||||||||||||||
| 255 | ); | ||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | unless( $error->fatal ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 257 | { | ||||||||||||||||||||||||||||||||
| 258 | 0 | my %prop; | |||||||||||||||||||||||||||||||
| 259 | 0 | for my $slave ( @slave ) | |||||||||||||||||||||||||||||||
| 260 | { | ||||||||||||||||||||||||||||||||
| 261 | 0 | $prop{$slave->prop_name} = $slave->old_value; | |||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||
| 263 | 0 | $obj = $self->obj_class->new | |||||||||||||||||||||||||||||||
| 264 | ( | ||||||||||||||||||||||||||||||||
| 265 | prop => \%prop, | ||||||||||||||||||||||||||||||||
| 266 | repair_id => $self->old_value, | ||||||||||||||||||||||||||||||||
| 267 | error => $error, | ||||||||||||||||||||||||||||||||
| 268 | history => 0, | ||||||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||
| 272 | # Case of changed object | ||||||||||||||||||||||||||||||||
| 273 | else | ||||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||||
| 275 | 0 | $obj = $self->obj_class->find_id( id=>$self->obj_id, error=>$error ); | |||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if( $obj ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||
| 278 | 0 | @slave = $class->find | |||||||||||||||||||||||||||||||
| 279 | ( | ||||||||||||||||||||||||||||||||
| 280 | filter => ( $class->M->slaved_by == $self ), | ||||||||||||||||||||||||||||||||
| 281 | error => $error, | ||||||||||||||||||||||||||||||||
| 282 | ); | ||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | unless( $error->fatal ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 284 | { | ||||||||||||||||||||||||||||||||
| 285 | 0 | my %prop; | |||||||||||||||||||||||||||||||
| 286 | my %old_prop; | ||||||||||||||||||||||||||||||||
| 287 | 0 | for my $slave ( $self, @slave ) | |||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||||
| 289 | 0 | $prop{$slave->prop_name} = $slave->old_value; | |||||||||||||||||||||||||||||||
| 290 | 0 | $old_prop{$slave->prop_name} = $slave->new_value; | |||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||
| 292 | $obj->update | ||||||||||||||||||||||||||||||||
| 293 | ( | ||||||||||||||||||||||||||||||||
| 294 | 0 | prop => \%prop, | |||||||||||||||||||||||||||||||
| 295 | old_prop => \%old_prop, | ||||||||||||||||||||||||||||||||
| 296 | error => $error, | ||||||||||||||||||||||||||||||||
| 297 | history => 0, | ||||||||||||||||||||||||||||||||
| 298 | ); | ||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||
| 301 | else | ||||||||||||||||||||||||||||||||
| 302 | { | ||||||||||||||||||||||||||||||||
| 303 | 0 | $error->add_fatal | |||||||||||||||||||||||||||||||
| 304 | ( | ||||||||||||||||||||||||||||||||
| 305 | "Can't rollback update of object #" . $self->obj_id | ||||||||||||||||||||||||||||||||
| 306 | . " of class '".$self->obj_class."' because it doesn't exist" | ||||||||||||||||||||||||||||||||
| 307 | ); | ||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | unless( $error->fatal ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||
| 313 | 0 | $self->delete( error=>$error ); | |||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | 0 | $error->upto( $arg{error} ); | |||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub metaprop_class { 'ORM::Meta::ORM::History'; } | ||||||||||||||||||||||||||||||
|
Subroutine
metaprop_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||