Changeset 2624


Ignore:
Timestamp:
05/15/24 10:55:57 (2 weeks ago)
Author:
nanardon
Message:

Revert alternative id attribute for synchro

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm

    r2621 r2624  
    11001100    } 
    11011101 
    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 )) { 
    11091103        keys %data or return 'SYNCED'; 
    11101104        foreach (keys %data) { 
     
    11251119            return; 
    11261120        } 
    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)) { 
    11281122            return 'CREATED' 
    11291123        } else { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r2611 r2624  
    3636    my $sth = $base->db->prepare_cached( 
    3737        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}, 
    3939            $base->db->quote_identifier($class->_key_field), 
    4040            $base->db->quote_identifier($class->_object_table), 
     41            $base->db->quote_identifier($class->_key_field), 
    4142            ($base->{wexported} ? '' : 'and exported = true'), 
    4243            ($Real ? 'and oalias IS NULL' : ''), 
     
    5253} 
    5354 
    54 # $keyAttribute must be a internal attribute 
    55  
    5655sub 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) = @_; 
    6057    my $sth = $base->db->prepare_cached( 
    6158        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), 
    6563            $base->db->quote_identifier($class->_object_table), 
    66             $keyAttribute, 
     64            $base->db->quote_identifier($class->_key_field), 
    6765            ($base->{wexported} ? '' : 'and exported = true'), 
    6866            $base->db->quote_identifier($class->_key_field), 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Synchro.pm

    r2623 r2624  
    283283            $destbase->is_supported_object($otype) or next; 
    284284 
    285             my $SyncKeyAttribute; 
    286             if ( my $attr = $destbase->config( 'keyAttribute.' . $self->from->label . '.' . $otype ) ) { 
    287                 $SyncKeyAttribute = $attr; 
    288             } 
    289  
    290285            my %existings; 
    291286            my %filtering; 
    292287 
    293288            $existings{$otype} = { map { $_ => 1 } 
    294                 $self->from->list_objects_from_rev( $otype, 0, $SyncKeyAttribute ) }; 
     289                $self->from->listRealObjects($otype) }; 
    295290 
    296291            # Is there a filter to apply: 
     
    298293            if (my $filter = $self->{options}->{$filtername}) { 
    299294                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') }; 
    305297            } else { 
    306298                $filtering{$otype} = $existings{$otype}; 
     
    366358                    $otype, 
    367359                    $self->val($self->from->label, $destbase->label, 0), 
    368                     $SyncKeyAttribute, 
    369360                )); 
    370361 
     
    394385                    } 
    395386 
    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); 
    399389                    if (defined $res) { 
    400390                        if ($res) { 
Note: See TracChangeset for help on using the changeset viewer.