3 use CXGN
::Insitu
::Experiment
;
6 package CXGN
::Insitu
::Organism
;
8 use base qw
/ CXGN::Insitu::DB /;
25 my $self = $class -> SUPER
::new
($dbh);
28 $self->set_organism_id($id);
29 $self->fetch_organism();
36 my $query = "SELECT is_organism_id,
41 FROM insitu.is_organism
42 WHERE is_organism_id=?";
43 my $sth = $self->get_dbh()->prepare($query);
44 $sth->execute($self->get_organism_id());
45 my ($organism_id, $name, $common_name, $description, $user_id) =
46 $sth->fetchrow_array();
47 $self->set_organism_id($organism_id);
48 $self->set_name($name);
49 $self->set_common_name($common_name);
50 $self->set_description($description);
51 $self->set_user_id($user_id);
67 if ($self->get_organism_id()) {
68 my $query = "UPDATE insitu.is_organism SET
73 WHERE is_organism_id=?";
74 my $sth = $self->get_dbh()->prepare($query);
77 $self->get_common_name(),
78 $self->get_description(),
79 $self->get_organism_id(),
85 my $query = "INSERT INTO insitu.is_organism
86 (name, common_name, description, user_id)
88 my $sth = $self->get_dbh()->prepare($query);
91 $self->get_common_name(),
92 $self->get_description(),
95 return $self->get_dbh()->last_insert_id("is_organism");
99 =head2 get_all_organisms
101 Usage: my ($names_ref, $ids_ref) = CXGN::Insitu::Organism::get_all_organisms($dbh);
102 Desc: This is a static function.
103 Ret: Returns to arrayrefs. One array contains all the
104 organism names, and the other all the organism ids
105 with corresponding array indices.
106 Args: a database handle
112 sub get_all_organisms
{
114 my $query = "SELECT name, is_organism_id
115 FROM insitu.is_organism";
116 my $sth = $dbh->prepare($query);
120 while (my($name, $organism_id) = $sth->fetchrow_array()) {
122 push @ids, $organism_id;
124 return (\
@names, \
@ids);
129 =head2 get_organism_id
140 sub get_organism_id
{
142 return $self->{organism_id
};
146 =head2 set_organism_id
157 sub set_organism_id
{
159 $self->{organism_id
}=shift;
175 return $self->{name
};
195 =head2 get_common_name
206 sub get_common_name
{
208 return $self->{common_name
};
212 =head2 set_common_name
223 sub set_common_name
{
225 $self->{common_name
}=shift;
228 =head2 get_description
239 sub get_description
{
241 return $self->{description
};
245 =head2 set_description
256 sub set_description
{
258 $self->{description
}=shift;
274 return $self->{user_id
};
291 $self->{user_id
}=shift;
297 =head2 get_associated_experiments
308 sub get_associated_experiments
{
310 my $query = "SELECT experiment.experiment_id FROM insitu.experiment
311 WHERE is_organism_id=?";
312 my $sth = $self->get_dbh()->prepare($query);
313 $sth->execute($self->get_organism_id());
314 my @experiments = ();
315 while (my ($experiment_id) = $sth->fetchrow_array()) {
316 push @experiments, CXGN
::Insitu
::Experiment
->new($self->get_dbh(), $experiment_id);