BioPerl-DB
view release on metacpan or search on metacpan
lib/Bio/DB/BioSQL/OntologyAdaptor.pm view on Meta::CPAN
# we want to enable object caching
push(@args, "-cache_objects", 1) unless grep { /cache_objects/i; } @args;
my $self = $class->SUPER::new(@args);
return $self;
}
=head2 get_persistent_slots
Title : get_persistent_slots
Usage :
Function: Get the slots of the object that map to attributes in its respective
entity in the datastore.
Slots should be methods callable without an argument.
Example :
Returns : an array of method names constituting the serializable slots
Args : the object about to be inserted or updated
=cut
sub get_persistent_slots{
my ($self,@args) = @_;
return ("name", "definition");
}
=head2 get_persistent_slot_values
Title : get_persistent_slot_values
Usage :
Function: Obtain the values for the slots returned by get_persistent_slots(),
in exactly that order.
Example :
Returns : A reference to an array of values for the persistent slots of this
object. Individual values may be undef.
Args : The object about to be serialized.
A reference to an array of foreign key objects if not retrievable
from the object itself.
=cut
sub get_persistent_slot_values {
my ($self,$obj,$fkobjs) = @_;
my @vals = ($obj->name(),
$obj->definition()
);
return \@vals;
}
=head2 remove_children
Title : remove_children
Usage :
Function: This method is to cascade deletes in maintained objects.
We just return TRUE here.
Example :
Returns : TRUE on success and FALSE otherwise
Args : The persistent object that was just removed from the database.
Additional (named) parameter, as passed to remove().
=cut
sub remove_children{
return 1;
}
=head2 instantiate_from_row
Title : instantiate_from_row
Usage :
Function: Instantiates the class this object is an adaptor for, and populates
it with values from columns of the row.
This implementation call populate_from_row() to do the real job.
Example :
Returns : An object, or undef, if the row contains no values
Args : A reference to an array of column values. The first column is the
primary key, the other columns are expected to be in the order
returned by get_persistent_slots().
Optionally, the object factory to be used for instantiating the
proper class. The adaptor must be able to instantiate a default
class if this value is undef.
=cut
sub instantiate_from_row{
my ($self,$row,$fact) = @_;
my $obj;
if($row && @$row) {
if($fact) {
$obj = $fact->create_object();
} else {
$obj = Bio::Ontology::Ontology->new();
}
$self->populate_from_row($obj, $row);
}
return $obj;
}
=head2 populate_from_row
Title : populate_from_row
Usage :
Function: Instantiates the class this object is an adaptor for, and populates
it with values from columns of the row.
Example :
Returns : An object, or undef, if the row contains no values
Args : The object to be populated.
( run in 0.732 second using v1.01-cache-2.11-cpan-39bf76dae61 )