Changeset 2624
- Timestamp:
- 05/15/24 10:55:57 (2 weeks ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
r2621 r2624 1100 1100 } 1101 1101 1102 my $KeyAttribute = $self->config( 'keyAttribute.' . $srcobj->base->label . '.' . $srcobj->type ); 1103 1104 my $destid = $KeyAttribute 1105 ? $srcobj->get_attibutes( $KeyAttribute ) 1106 : $srcobj->id; 1107 1108 if (my $dstobj = $self->get_object($srcobj->type, $destid)) { 1102 if (my $dstobj = $self->get_object($srcobj->type, $srcobj->id )) { 1109 1103 keys %data or return 'SYNCED'; 1110 1104 foreach (keys %data) { … … 1125 1119 return; 1126 1120 } 1127 if (my $res = $self->_create_c_object($srcobj->type, $ destid, %data)) {1121 if (my $res = $self->_create_c_object($srcobj->type, $srcobj->id, %data)) { 1128 1122 return 'CREATED' 1129 1123 } else { -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r2611 r2624 36 36 my $sth = $base->db->prepare_cached( 37 37 sprintf( 38 q{select %s as k from %s where internobject = false %s %s order by %s},38 q{select %s as k from %s where %s IS NOT NULL internobject = false %s %s order by %s}, 39 39 $base->db->quote_identifier($class->_key_field), 40 40 $base->db->quote_identifier($class->_object_table), 41 $base->db->quote_identifier($class->_key_field), 41 42 ($base->{wexported} ? '' : 'and exported = true'), 42 43 ($Real ? 'and oalias IS NULL' : ''), … … 52 53 } 53 54 54 # $keyAttribute must be a internal attribute55 56 55 sub list_from_rev { 57 my ($class, $base, $rev, $keyAttribute) = @_; 58 defined( $rev ) or die '$rev must be defined when calling list_from_rev()'; 59 $keyAttribute ||= $base->db->quote_identifier($class->_key_field); 56 my ($class, $base, $rev) = @_; 60 57 my $sth = $base->db->prepare_cached( 61 58 sprintf( 62 q{select %s as k from %s where rev > ? AND internobject = false 63 AND oalias IS NULL AND %s IS NOT NULL %s order by %s}, 64 $keyAttribute, 59 q{select %s as k from %s where %s IS NOT NULL AND 60 rev > ? and internobject = false 61 and oalias IS NULL %s order by %s}, 62 $base->db->quote_identifier($class->_key_field), 65 63 $base->db->quote_identifier($class->_object_table), 66 $ keyAttribute,64 $base->db->quote_identifier($class->_key_field), 67 65 ($base->{wexported} ? '' : 'and exported = true'), 68 66 $base->db->quote_identifier($class->_key_field), -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm
r2623 r2624 283 283 $destbase->is_supported_object($otype) or next; 284 284 285 my $SyncKeyAttribute;286 if ( my $attr = $destbase->config( 'keyAttribute.' . $self->from->label . '.' . $otype ) ) {287 $SyncKeyAttribute = $attr;288 }289 290 285 my %existings; 291 286 my %filtering; 292 287 293 288 $existings{$otype} = { map { $_ => 1 } 294 $self->from->list _objects_from_rev( $otype, 0, $SyncKeyAttribute) };289 $self->from->listRealObjects($otype) }; 295 290 296 291 # Is there a filter to apply: … … 298 293 if (my $filter = $self->{options}->{$filtername}) { 299 294 la_log(LA_DEBUG, "Found %s param, using it: %s", $filtername, $filter); 300 foreach ( my $id = $self->from->search_objects($otype, $filter, 'oalias=NULL') ) { 301 my $obj = $self->from->get_object( $otype, $id ); 302 my $id = $obj->get_attributes( $SyncKeyAttribute ); 303 $filtering{$otype}{ $id } = 1; 304 } 295 $filtering{$otype} = { map { $_ => 1 } 296 $self->from->search_objects($otype, $filter, 'oalias=NULL') }; 305 297 } else { 306 298 $filtering{$otype} = $existings{$otype}; … … 366 358 $otype, 367 359 $self->val($self->from->label, $destbase->label, 0), 368 $SyncKeyAttribute,369 360 )); 370 361 … … 394 385 } 395 386 396 my $res = $destbase->sync_object_from( 397 $self->from, $otype, $_, 398 %options, firstpass => $pass ); 387 my $res = $destbase->sync_object_from($self->from, $otype, $_, 388 %options, firstpass => $pass); 399 389 if (defined $res) { 400 390 if ($res) {
Note: See TracChangeset
for help on using the changeset viewer.