Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 336 lines (232 sloc) 8.728 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
# $Id$
#
# BioPerl module for Bio::DB::PersistentObjectI
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Hilmar Lapp <hlapp at gmx.net>
#
# Copyright Hilmar Lapp
#
# You may distribute this module under the same terms as perl itself

#
# (c) Hilmar Lapp, hlapp at gmx.net, 2002.
# (c) GNF, Genomics Institute of the Novartis Research Foundation, 2002.
#
# You may distribute this module under the same terms as perl itself.
# Refer to the Perl Artistic License (see the license accompanying this
# software package, or see http://www.perl.com/language/misc/Artistic.html)
# for the terms under which you may use, modify, and redistribute this module.
#
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#

# POD documentation - main docs before the code

=head1 NAME

Bio::DB::PersistentObjectI - DESCRIPTION of Interface

=head1 SYNOPSIS

Give standard usage here

=head1 DESCRIPTION

Describe the interface here

=head1 FEEDBACK

=head2 Mailing Lists

User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.

bioperl-l@bioperl.org - General discussion
http://bioperl.org/wiki/Mailing_lists - About the mailing lists

=head2 Support
Please direct usage questions or support issues to the mailing list:
L<bioperl-l@bioperl.org>
rather than to the module maintainer directly. Many experienced and
reponsive experts will be able look at the problem and quickly
address it. Please include a thorough description of the problem
with code and data examples if at all possible.

=head2 Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:

http://bugzilla.open-bio.org/

=head1 AUTHOR - Hilmar Lapp

Email hlapp at gmx.net

Describe contact details here

=head1 CONTRIBUTORS

Additional contributors names and emails here

=head1 APPENDIX

The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _

=cut


# Let the code begin...


package Bio::DB::PersistentObjectI;
use vars qw(@ISA);
use strict;
use Carp;
use Bio::Root::RootI;

@ISA = qw( Bio::Root::RootI );

=head1 Methods for managing persistence of this object

Create (insert), store (update), remove (delete), and the primary
key

=cut

=head2 create

Title : create
Usage : $obj->create()
Function: Creates the object as a persistent object in the datastore. This
is equivalent to an insert.

Note that you will be able to retrieve the primary key at any time
by calling primary_key() on the object.
Example :
Returns : The newly assigned primary key.
Args : 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 create{
    my ($self,@args) = @_;
   
    $self->throw_not_implemented();
}

=head2 store

Title : store
Usage : $obj->store()
Function: Updates the persistent object in the datastore to reflect its
attribute values.
Example :
Returns : TRUE on success and FALSE otherwise
Args : 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 store{
    my ($self,@args) = @_;

    $self->throw_not_implemented();
}

=head2 remove

Title : remove
Usage : $obj->remove()
Function: Removes the persistent object from the datastore.
Example :
Returns : TRUE on success and FALSE otherwise
Args : none


=cut

sub remove{
    my ($self,@args) = @_;

    $self->throw_not_implemented();
}

=head2 primary_key

Title : primary_key
Usage : $obj->primary_key($newval)
Function: Get the primary key of the persistent object in the datastore.

Note that an implementation may not permit changing the
primary key once it has been set. For most applications,
changing an existing primary key value to another one is a
potentially very hazardous operation and will hence be
prohibited.

Example :
Returns : value of primary_key (a scalar)
Args : new value (a scalar, optional)


=cut

sub primary_key{
    my ($self,$value) = @_;
    $self->throw_not_implemented();
}

=head2 obj

Title : obj
Usage : $obj->obj()
Function: Get/set the object that is made persistent through this adaptor.

Note that an implementation is not required to allow
setting a value. In fact, an implementation is encouraged
to disallow changing the value once it has been set.

Implementations based on inheriting from the class to be
made persistent will just return $self here.

Example :
Returns : The object made persistent through this adaptor
Args : On set, the new value. Read above for caveat.


=cut

sub obj{
    my ($self,$value) = @_;
    $self->throw_not_implemented();
}

=head1 Methods for transactional control

Rollback and commit

=cut

=head2 commit

Title : commit
Usage :
Function: Commits the current transaction, if the underlying driver
supports transactions.
Example :
Returns : TRUE
Args : none


=cut

sub commit{
    shift->throw_not_implemented();
}

=head2 rollback

Title : rollback
Usage :
Function: Triggers a rollback of the current transaction, if the
underlying driver supports transactions.
Example :
Returns : TRUE
Args : none


=cut

sub rollback{
    shift->throw_not_implemented();
}

=head1 Decorating methods

These methods aren't intrinsically necessary on this interface, but
rather ease recurrent tasks when serializing objects and translate
from object model to relational model.

=cut

=head2 rank

Title : rank
Usage : $obj->rank($newval)
Function: Get/set the rank of this persistent object in a 1:n or n:n
relationship.

This method is here in order to ease maintaining the order
of objects in an array property or cardinality-n
association. Unless the schema mandates the corresponding
attribute as NOT NULL, derived classes may override the
implementation given here with an empty one.

In practice it may only pertain to few objects and hence
could be just as well stuck onto those classes instead of
also on the interface. This design decision is up for debate -
if people don''t like it, it can be changed without too
much effort.

Example :
Returns : value of rank (a scalar)
Args : new value (a scalar or undef, optional)


=cut

sub rank{
    shift->throw_not_implemented();
}

=head2 foreign_key_slot

Title : foreign_key_slot
Usage : $obj->foreign_key_slot($newval)
Function: Get/set of the slot name that is referring to this persistent
object as a foreign key.

This should come in a fully-qualified form. The fully qualified
form is the class name (or adaptor name for the class) that defines
the slot, followed by a double-colon and the name of the slot
(method) itself. I.e., it is the name of the method as class
method.

Without this method, the name of the foreign key may be determined
automatically based on naming convention, or based on a full
mapping table. Neither is always possible because the situation can
be ambiguous, e.g., if an entity references another instance of
itself as foreign key, or if an entity references the same other
entity via multiple foreign keys (e.g. entity associated to itself).

This method is here only to aid ferrying this value from adaptors
to schema drivers and mappers who need to actually figure the
name of the foreign key column in the physical schema. An adaptor
is not required to use it, and everyone else other than the intended
sender and recipient should know what he/she is doing before
tampering with it.

Example :
Returns : value of foreign_key_slot (a scalar)
Args : new value (a scalar or undef, optional)


=cut

sub foreign_key_slot{
    shift->throw_not_implemented();
}

1;
Something went wrong with that request. Please try again.