BioPerl-DB
view release on metacpan or search on metacpan
lib/Bio/DB/BioSQL/CommentAdaptor.pm view on Meta::CPAN
A Bio::Annotation::Comment will reference a bioentry.
Example :
Returns : an array of Bio::DB::PersistentObjectI implementing objects
Args : The object about to be inserted or updated, or undef if the call
is for a SELECT query. In the latter case return class or interface
names that are mapped to the foreign key tables.
Optionally, additional named parameters. A common parameter will
be -fkobjs, with a reference to an array of foreign key objects
that are not retrievable from the persistent object itself.
=cut
sub get_foreign_key_objects{
my ($self,$obj,@args) = @_;
my $bioentry;
# Bio::Annotation::Comment doesn't have a pointer to the bioentry. Hence,
# we need to get this from the arguments.
my ($fkobjs) = $self->_rearrange([qw(FKOBJS)], @args);
if($fkobjs && @$fkobjs) {
($bioentry) = grep { $_->isa("Bio::PrimarySeqI"); } @$fkobjs;
} else {
$bioentry = "Bio::SeqI";
}
return ($bioentry);
}
=head2 attach_foreign_key_objects
Title : attach_foreign_key_objects
Usage :
Function: Attaches foreign key objects to the given object as far as
necessary.
This method is called after find_by_XXX() queries, not for
INSERTs or UPDATEs.
Bio::Annotation::Comment objects have a Bio::SeqI as
foreign key, but it is not referenced by the object. So we
do nothing here.
Example :
Returns : TRUE on success, and FALSE otherwise.
Args : The object to which to attach foreign key objects.
A reference to an array of foreign key values, in the order of
foreign keys returned by get_foreign_key_objects().
=cut
sub attach_foreign_key_objects{
return 1;
}
=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 calls 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::Annotation::Comment->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.
Usually a derived class will instantiate the proper class and pass
it on to populate_from_row().
( run in 0.796 second using v1.01-cache-2.11-cpan-39bf76dae61 )