9 $object_adaptor = $dba->get_SpecificObjectAdaptor;
10 $object_adaptor = $specific_object->adaptor;
14 This module defines a parent
class for all specific object adaptors.
15 It is not supposed to be instantiated directly.
19 See the NOTICE file distributed with
this work
for additional information
20 regarding copyright ownership.
22 Licensed under the Apache License, Version 2.0 (the
"License"); you may not use
this file except in compliance with the License.
23 You may obtain a copy of the License at
27 Unless required by applicable law or agreed to in writing, software distributed under the License
28 is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 See the License
for the specific language governing permissions and limitations under the License.
33 Please subscribe to the Hive mailing list: http:
38 package Bio::EnsEMBL::Hive::DBSQL::ObjectAdaptor;
43 use base (
'Bio::EnsEMBL::Hive::DBSQL::BaseAdaptor');
47 die
"Please define object_class() in your specific adaptor class to return the class name of your intended object";
51 sub slicer { # take a slice of the object (
if only we could
inline in Perl!)
52 my ($self, $object, $fields) = @_;
54 my $autoinc_id = $self->autoinc_id();
55 my $overflow_limit = $self->overflow_limit();
57 return [
map { ($_ eq $autoinc_id)
59 : eval { my $value = $object->$_();
60 my $ol = $overflow_limit->{$_};
61 (defined($ol) and length($value)>$ol)
62 ? $self->db->get_AnalysisDataAdaptor()->store_if_needed( $value )
69 sub objectify { # turn the hashref into an object (
if only we could
inline in Perl!)
70 my ($self, $hashref) = @_;
72 my $autoinc_id = $self->autoinc_id();
74 my $object = $self->object_class()->new( 'adaptor' => $self,
map { ( ($_ eq $autoinc_id) ?
'dbID' : $_ ) => $hashref->{$_} } keys %$hashref );
75 $object->hive_pipeline($self->db->hive_pipeline)
if $self->db->hive_pipeline and $object->can(
'hive_pipeline');
81 my ($self, $object, $dbID) = @_;
83 if($self->autoinc_id()) {
86 $object->adaptor($self);
91 my ($self, $object) = @_;
93 my $autoinc_id = $self->autoinc_id();
94 my $sorted_keys = [ sort grep { ($_ ne $autoinc_id) and defined($object->$_()) } keys %{ $self->column_set() } ];
96 return ( $sorted_keys, join(
', ', @$sorted_keys) );
103 Description: reload the
object from the database
104 Returntype : The
object with the same reference but with reloaded data.
109 my ($self, $object) = @_;
111 my $new_object = $self->fetch_by_dbID( $object->dbID ); # fetch into a separate
object
113 my $orig_hive_pipeline = exists $object->{
'_hive_pipeline'} && $object->
hive_pipeline;
114 %$object = %$new_object; # copy the data over
115 $object->hive_pipeline($orig_hive_pipeline)
if $orig_hive_pipeline;