Changeset 76
- Timestamp:
- 05/09/09 19:45:21 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
r74 r76 101 101 102 102 sub _traverse { 103 my ($self, $ attr_cb, %options) = @_;103 my ($self, $callback) = @_; 104 104 105 105 # listing existing obj one time: … … 116 116 warn "Sync objects $otype\n"; 117 117 foreach my $destbase (@obj_dest_base) { 118 $callback->($otype, $destbase); 119 } 120 } 121 } 122 123 sub _traverse_update { 124 my ($self, %options) = @_; 125 $self->_traverse( 126 sub { 127 my ($otype, $destbase) = @_; 118 128 my @lobjfrom = $self->from->list_objects_from_rev( 119 129 $otype, … … 121 131 ); 122 132 warn "objects $otype " . $self->from->label . " => " . $destbase->label . "\n"; 123 my @common_fields = $ attr_cb->($self->from, $destbase, $otype) or next;133 my @common_fields = $options{attr_cb}->($self->from, $destbase, $otype) or return; 124 134 warn "Synching fields: " . join(', ', sort @common_fields) . "\n"; 125 135 my %exists = map { $_ => 1 } $destbase->list_objects($otype); … … 137 147 } 138 148 } 149 } 150 ); 151 } 152 153 sub _traverse_delete { 154 my ($self, %options) = @_; 155 $self->_traverse( 156 sub { 157 my ($otype, $destbase) = @_; 158 my %exists = map { $_ => 1 } $destbase->list_objects($otype); 139 159 my %srcexists = map { $_ => 1 } $self->from->list_objects($otype); 140 160 foreach (keys %exists) { … … 145 165 } 146 166 } 147 }167 ); 148 168 } 149 169 … … 160 180 161 181 my %delayed; 162 $self->_traverse( 163 sub { 182 $self->_traverse_delete; 183 $self->_traverse_update( 184 attr_cb => sub { 164 185 my ($from, $to, $otype) = @_; 165 186 my %fields = (); … … 179 200 }, 180 201 ); 181 $self->_traverse (182 sub {202 $self->_traverse_update( 203 attr_cb => sub { 183 204 my ($from, $to, $otype) = @_; 184 205 my %fields = ();
Note: See TracChangeset
for help on using the changeset viewer.