Changeset 44 for LATMOS-Accounts
- Timestamp:
- 04/25/09 09:23:55 (15 years ago)
- Location:
- LATMOS-Accounts/lib/LATMOS/Accounts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm
r43 r44 112 112 sub commit { 113 113 my ($self) = @_; 114 if ($ENV{LA_NO_COMMIT}) { return 1 } 114 115 $self->db->commit; 115 116 } … … 117 118 sub rollback { 118 119 my ($self) = @_; 120 if ($ENV{LA_NO_COMMIT}) { return 1 } 119 121 $self->db->rollback; 120 122 } -
LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
r41 r44 84 84 } 85 85 86 # sync obj $from to $to 87 # obj must be L::A::Base::Object based 88 89 sub _sync_object { 90 my ($self, $from, $to) = @_; 91 my @common_fields = $self->_common_fields($from, $to); 92 93 } 94 95 sub _common_fields { 96 my ($self, $from, $to, $otype) = @_; 97 my %fields = (); 98 foreach my $base ($from, $to) { 99 foreach ($base->list_canonicals_fields($otype)) { 100 $fields{$_} ||= 0; # avoid 101 $fields{$_}++; 102 } 103 } 104 # field having value are in both 105 grep { $fields{$_} == 2 } keys %fields; 106 } 107 86 108 sub process { 87 109 my ($self, %options) = @_; … … 108 130 warn "objects $otype => " . $destbase->type . "\n"; 109 131 my %exists = map { $_ => 1 } $destbase->list_objects($otype); 110 foreach (@lobjfrom) { 111 if (!$exists{$_}) { 112 warn " $otype $_: created\n"; 132 foreach my $uid (@lobjfrom) { 133 if (!$exists{$uid}) { 134 # TODO cache this: 135 my @common_fields = $self->_common_fields($self->from, $destbase, $otype); 136 137 my $sobj = $self->from->get_object($otype, $uid); 138 my %fields = map { $_ => $sobj->get_c_field($_) } @common_fields; 139 $destbase->create_c_object($otype, $uid, %fields); 140 warn " $otype $uid: created\n"; 113 141 } 114 142 }
Note: See TracChangeset
for help on using the changeset viewer.