Changeset 45 for LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
- Timestamp:
- 04/25/09 10:29:23 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
r44 r45 46 46 # allow ref and array ref of, eg 47 47 # to = $foo and $to = [ $foo, $bar ] 48 foreach (ref $to? @{ $to || []} : ($to)) {48 foreach (ref($to) eq 'ARRAY' ? @{ $to || []} : ($to)) { 49 49 push(@{$self->{to}}, $_); 50 50 } … … 82 82 $self->{to} = \@loaded; 83 83 return $unloaded; 84 }85 86 # sync obj $from to $to87 # obj must be L::A::Base::Object based88 89 sub _sync_object {90 my ($self, $from, $to) = @_;91 my @common_fields = $self->_common_fields($from, $to);92 93 84 } 94 85 … … 129 120 foreach my $destbase (@obj_dest_base) { 130 121 warn "objects $otype => " . $destbase->type . "\n"; 122 my @common_fields = $self->_common_fields($self->from, $destbase, $otype); 131 123 my %exists = map { $_ => 1 } $destbase->list_objects($otype); 132 124 foreach my $uid (@lobjfrom) { 133 125 if (!$exists{$uid}) { 134 # TODO cache this:135 my @common_fields = $self->_common_fields($self->from, $destbase, $otype);136 137 126 my $sobj = $self->from->get_object($otype, $uid); 138 127 my %fields = map { $_ => $sobj->get_c_field($_) } @common_fields; 139 128 $destbase->create_c_object($otype, $uid, %fields); 140 129 warn " $otype $uid: created\n"; 130 } else { 131 my $sobj = $self->from->get_object($otype, $uid); 132 my %fields = map { $_ => $sobj->get_c_field($_) } @common_fields; 133 my $dobj = $destbase->get_object($otype, $uid); 134 $dobj->set_c_fields(%fields); 135 136 warn " $otype $uid: synched\n"; 141 137 } 142 138 } 143 139 } 140 } 141 142 foreach ($self->to) { 143 $_->commit; 144 144 } 145 145
Note: See TracChangeset
for help on using the changeset viewer.