[Bio] / FigKernelPackages / FIG.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/FIG.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.537, Wed Nov 8 23:12:49 2006 UTC revision 1.538, Thu Nov 9 21:14:29 2006 UTC
# Line 54  Line 54 
54  use FIGRules;  use FIGRules;
55  use Tracer;  use Tracer;
56  use GenomeIDMap;  use GenomeIDMap;
57    use CustomAttributes;
58    
59  our $haveDateParse;  our $haveDateParse;
60  eval {  eval {
# Line 206  Line 207 
207      my $self = {      my $self = {
208          _dbf  => $rdbH,          _dbf  => $rdbH,
209      };      };
210        if ($FIG_Config::attrDbName) {
211            $self->{_ca} = CustomAttributes->new();
212        }
213    
214      #      #
215      # If we have a readonly-database defined in the config,      # If we have a readonly-database defined in the config,
# Line 9821  Line 9825 
9825    
9826  sub get_attributes {  sub get_attributes {
9827      my($self,@request) = @_;      my($self,@request) = @_;
9828        if (exists $self->{_ca}) {
9829            # Here we can use the new system.
9830            return $self->{_ca}->GetAttributes(@request);
9831        } else {
9832      my($rdbH,$relational_db_response);      my($rdbH,$relational_db_response);
9833    
9834      # clean the keys if there is one      # clean the keys if there is one
# Line 9863  Line 9871 
9871      map {unshift @$_, $self->join_attribute_oid(splice(@$_, 0, 3))} @$res;      map {unshift @$_, $self->join_attribute_oid(splice(@$_, 0, 3))} @$res;
9872      return @{$res};      return @{$res};
9873  }  }
9874    }
9875    
9876    
9877  =head3 get_cv_attributes  =head3 get_cv_attributes
# Line 9870  Line 9879 
9879  A simple wrapper around get_attriubtes to return only those attributes  A simple wrapper around get_attriubtes to return only those attributes
9880  that have meta_data indicating that the key is a controlled vocabulary.  that have meta_data indicating that the key is a controlled vocabulary.
9881    
9882  See get_attributes for description of arguments and return types.  ### DEPRECATED ### The controlled vocabulary feature was never used.
9883    
9884  =cut  =cut
9885    
9886  sub get_cv_attributes {  sub get_cv_attributes {
9887      my($self,@request) = @_;      return ();
     my @res;  
     foreach my $attribute ( $self->get_attributes( @request ) ) {  
         my $data=$self->key_info($attribute->[1]);  
         if ( !$data->{"is_cv"} == 1) {next}  
         push @res, $attribute;  
     }  
   
     return @res;  
9888  }  }
9889    
9890    
# Line 9902  Line 9903 
9903  =cut  =cut
9904    
9905  sub add_attribute {  sub add_attribute {
9906      my($self,$peg,$k,$v, $url, $notl) = @_;      my ($self, @request) = @_;
9907        if (exists $self->{_ca}) {
9908            # Here we can use the new system.
9909            return $self->{_ca}->AddAttribute(@request);
9910        } else {
9911            my($peg,$k,$v, $url, $notl) = @request;
9912      return unless ($peg && $k); # we must have at least a peg and a tag to add (though other things can be undef)      return unless ($peg && $k); # we must have at least a peg and a tag to add (though other things can be undef)
9913      $k =  $self->clean_attribute_key($k);      $k =  $self->clean_attribute_key($k);
9914      my $rdbH = $self->db_handle;      my $rdbH = $self->db_handle;
# Line 9924  Line 9930 
9930      }      }
9931      return 1;      return 1;
9932  }  }
9933    }
9934    
9935  =head3 delete_attribute  =head3 delete_attribute
9936    
# Line 9942  Line 9949 
9949  =cut  =cut
9950    
9951  sub delete_attribute {  sub delete_attribute {
9952      my($self,$peg,$k, $oldval, $oldurl, $notl) = @_;      my ($self, @request) = @_;
9953        if (exists $self->{_ca}) {
9954            # Here we can use the new system.
9955            return $self->{_ca}->DeleteAttribute(@request);
9956        } else {
9957            my($peg,$k, $oldval, $oldurl, $notl) = @request;
9958    
9959      # we need a feature and a key to delete      # we need a feature and a key to delete
9960      return unless ($peg && $k);      return unless ($peg && $k);
# Line 9959  Line 9971 
9971      }      }
9972      return $self->change_attribute($peg, $k, $oldval, $oldurl, undef, undef);      return $self->change_attribute($peg, $k, $oldval, $oldurl, undef, undef);
9973  }  }
9974    }
9975    
9976  =head3 change_attribute  =head3 change_attribute
9977    
# Line 9978  Line 9991 
9991  =cut  =cut
9992    
9993  sub change_attribute {  sub change_attribute {
9994      my($self,$peg,$k,$oldval, $oldurl, $newval, $newurl, $notl) = @_;      my ($self, @request) = @_;
9995        if (exists $self->{_ca}) {
9996            # Here we can use the new system.
9997            return $self->{_ca}->ChangeAttribute(@request);
9998        } else {
9999            my($peg,$k,$oldval, $oldurl, $newval, $newurl, $notl) = @request;
10000      return (0) unless ($peg && $k); # we must have at least a peg and a key.      return (0) unless ($peg && $k); # we must have at least a peg and a key.
10001      $k =  $self->clean_attribute_key($k);      $k =  $self->clean_attribute_key($k);
10002      my $rdbH = $self->db_handle;      my $rdbH = $self->db_handle;
# Line 10023  Line 10041 
10041      }      }
10042      return 1;      return 1;
10043  }  }
10044    }
10045    
10046    
10047    

Legend:
Removed from v.1.537  
changed lines
  Added in v.1.538

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3