Changeset 257


Ignore:
Timestamp:
06/25/09 07:58:07 (15 years ago)
Author:
nanardon
Message:
  • add attributes_summary: list current attributes values around all current objects
Location:
LATMOS-Accounts/lib/LATMOS/Accounts
Files:
2 edited

Legend:

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

    r233 r257  
    181181    my ($self, $otype, $id, %data) = @_; 
    182182    my $pclass = $self->_load_obj_class($otype); 
    183     $pclass->_create($self, $id, %data) or do { 
     183    if ($pclass->_create($self, $id, %data)) { 
     184        la_log(LA_INFO, 
     185            'Object %s (%s) created in base %s (%s)', 
     186            $id, $otype, $self->label, $self->type 
     187        ); 
     188    } else { 
    184189        la_log(LA_ERR, 
    185190            'Object creation %s (%s) in base %s (%s) failed', 
     
    368373    my $pclass = $self->_load_obj_class($otype) or return; 
    369374    $pclass->search($self, %filter); 
     375} 
     376 
     377sub attributes_summary { 
     378    my ($self, $otype, $attr) = @_; 
     379    my $pclass = $self->_load_obj_class($otype) or return; 
     380    $pclass->attributes_summary($self, $attr); 
    370381} 
    371382 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm

    r256 r257  
    300300} 
    301301 
     302 
     303sub attributes_summary { 
     304    my ($class, $base, $attribute) = @_; 
     305    my %values; 
     306    foreach my $id ($base->list_objects($class->type)) { 
     307        my $obj = $base->get_object($class->type, $id); 
     308        my $value = $obj->get_c_field($attribute); 
     309        if ($value) { 
     310            if (ref $value) { 
     311                foreach (@$value) { 
     312                    $values{$_} = 1; 
     313                } 
     314            } else { 
     315                $values{$value} = 1; 
     316            } 
     317        } 
     318    } 
     319    return sort(keys %values); 
     320} 
     321 
    302322sub find_next_numeric_id { 
    303323    my ($class, $base, $field, $min, $max) = @_; 
Note: See TracChangeset for help on using the changeset viewer.