[Bio] / Sprout / CustomAttributes.pm Repository:
ViewVC logotype

Diff of /Sprout/CustomAttributes.pm

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

revision 1.15, Tue Jan 9 01:49:08 2007 UTC revision 1.16, Wed Jan 24 09:50:29 2007 UTC
# Line 1406  Line 1406 
1406      } elsif (! defined($key)) {      } elsif (! defined($key)) {
1407          Confess("No attribute key specified for DeleteAttribute call.");          Confess("No attribute key specified for DeleteAttribute call.");
1408      } elsif (scalar(@values) == 0) {      } elsif (scalar(@values) == 0) {
1409          # Here we erase the entire key.          # Here we erase the entire key for this object.
1410          $self->EraseAttribute($key);          $self->DeleteRow('HasValueFor', $key, $objectID);
1411      } else {      } else {
1412          # Here we erase the matching values.          # Here we erase the matching values.
1413          my $valueString = join($self->{splitter}, @values);          my $valueString = join($self->{splitter}, @values);
# Line 1417  Line 1417 
1417      return 1;      return 1;
1418  }  }
1419    
1420    =head3 DeleteMatchingAttributes
1421    
1422    C<< my @deleted = $attrDB->DeleteMatchingAttributes($objectID, $key, @values); >>
1423    
1424    Delete all attributes that match the specified criteria. This is equivalent to
1425    calling L</GetAttributes> and then invoking L</DeleteAttribute> for each
1426    row found.
1427    
1428    =over 4
1429    
1430    =item objectID
1431    
1432    ID of object whose attributes are to be deleted. If the attributes for multiple
1433    objects are to be deleted, this parameter can be specified as a list reference. If
1434    attributes are to be deleted for all objects, specify C<undef> or an empty string.
1435    Finally, you can delete attributes for a range of object IDs by putting a percent
1436    sign (C<%>) at the end.
1437    
1438    =item key
1439    
1440    Attribute key name. A value of C<undef> or an empty string will match all
1441    attribute keys. If the values are to be deletedfor multiple keys, this parameter can be
1442    specified as a list reference. Finally, you can delete attributes for a range of
1443    keys by putting a percent sign (C<%>) at the end.
1444    
1445    =item values
1446    
1447    List of the desired attribute values, section by section. If C<undef>
1448    or an empty string is specified, all values in that section will match. A
1449    generic match can be requested by placing a percent sign (C<%>) at the end.
1450    In that case, all values that match up to and not including the percent sign
1451    will match. You may also specify a regular expression enclosed
1452    in slashes. All values that match the regular expression will be deleted. For
1453    performance reasons, only values have this extra capability.
1454    
1455    =item RETURN
1456    
1457    Returns a list of tuples for the attributes that were deleted, in the
1458    same form as L</GetAttributes>.
1459    
1460    =back
1461    
1462    =cut
1463    
1464    sub DeleteMatchingAttributes {
1465        # Get the parameters.
1466        my ($self, $objectID, $key, @values) = @_;
1467        # Get the matching attributes.
1468        my @retVal = $self->GetAttributes($objectID, $key, @values);
1469        # Loop through the attributes, deleting them.
1470        for my $tuple (@retVal) {
1471            $self->DeleteAttribute(@{$tuple});
1472        }
1473        # Return the deleted attributes.
1474        return @retVal;
1475    }
1476    
1477  =head3 ChangeAttribute  =head3 ChangeAttribute
1478    
1479  C<< $attrDB->ChangeAttribute($objectID, $key, \@oldValues, \@newValues); >>  C<< $attrDB->ChangeAttribute($objectID, $key, \@oldValues, \@newValues); >>
# Line 1489  Line 1546 
1546  sub EraseAttribute {  sub EraseAttribute {
1547      # Get the parameters.      # Get the parameters.
1548      my ($self, $key) = @_;      my ($self, $key) = @_;
1549      # Delete everything connected to the key. The "keepRoot" option keeps the key in the      # Delete everything connected to the key.
1550      # datanase while deleting everything attached to it.      $self->Disconnect('HasValueFor', 'AttributeKey', $key);
     $self->Delete('AttributeKey', $key, keepRoot => 1);  
1551      # Return a 1, for backward compatability.      # Return a 1, for backward compatability.
1552      return 1;      return 1;
1553  }  }

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3