[Bio] / WebApplication / DataHandler / Babel.pm Repository:
ViewVC logotype

Annotation of /WebApplication/DataHandler/Babel.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (view) (download) (as text)

1 : wilke 1.1 package DataHandler::Babel;
2 :    
3 :     # DataHandler::Babel - data handler to the Babel database
4 :    
5 :    
6 :    
7 :     use strict;
8 :     #use warnings;
9 :    
10 :     use base qw( DataHandler );
11 :    
12 :     use DBMaster;
13 :     use DBI;
14 :     use FIG_Config;
15 :    
16 :    
17 :     =pod
18 :    
19 :     =head1 NAME
20 :    
21 :     DataHandler::ACH - data handler to the Babel database
22 :    
23 :     =head1 DESCRIPTION
24 :    
25 :     This module returns the DBMaster object to the Babel database stored in the root
26 :     job directory of a ACH server. It requires the FIG_Config.pm to specify the
27 :     $rast_jobs directory.
28 :    
29 :     Refer to WebApplication/DataHandler.pm for the full documentation.
30 :    
31 :     =head1 METHODS
32 :    
33 :     =over 4
34 :    
35 :     =item * B<handle> ()
36 :    
37 :     Returns the enclosed data handle. Returns undef if it fails to open the Jobs database
38 :    
39 :     =cut
40 :    
41 :     sub handle {
42 :    
43 :     unless (exists $_[0]->{_handle}) {
44 :    
45 :     my $user = "";
46 : tharriso 1.2 my $dbpass = "";
47 : wilke 1.1 my $db = "";
48 :     my $dbhost = "";
49 :     my $backend = "";
50 : tharriso 1.2 my $type = "SQL"; # default is not PPO
51 :     my $dbsock = $FIG_Config::dbsock || "";
52 :     my $dbport = $FIG_Config::dbsock || "";
53 : wilke 1.1
54 : tharriso 1.2 if ($WebConfig::BABELDB) {
55 :     $user = $WebConfig::BABELUSER || "ach";
56 :     $dbpass = $WebConfig::BABELDBPASS || "";
57 : wilke 1.1 $db = $WebConfig::BABELDB;
58 :     $dbhost = $WebConfig::BABELDBHOST;
59 : tharriso 1.2 $backend = $WebConfig::BABELDBBACKEND || "MySQL"; # for PPO only
60 :     $type = $WebConfig::BABELDBPTYPE if ($WebConfig::BABELDBTYPE);
61 : wilke 1.1 $dbsock = $WebConfig::BABELDBSOCK if ($WebConfig::BABELDBSOCK);
62 :     $dbport = $WebConfig::BABELDBPORT if ($WebConfig::BABELDBPORT);
63 :     }
64 :     elsif ($FIG_Config::babel_db) {
65 : tharriso 1.2 $user = $FIG_Config::babel_dbuser || "ach";
66 :     $dbpass = $FIG_Config::babel_dbpass || "";
67 : wilke 1.1 $db = $FIG_Config::babel_db;
68 :     $dbhost = $FIG_Config::babel_dbhost;
69 : tharriso 1.2 $backend = $FIG_Config::babel_dbbackend || "MySQL"; # for PPO only
70 :     $type = $FIG_Config::babel_dbtype if ($FIG_Config::babel_dbtype);
71 :     $dbsock = $FIG_Config::babel_dbsock if ($FIG_Config::babel_dbsock);
72 :     $dbport = $FIG_Config::babel_dbport if ($FIG_Config::babel_dbport);
73 : wilke 1.1
74 :     }
75 : tharriso 1.2 else {
76 : wilke 1.1 warn "Unable to read DataHandler::Babel database: can't find FIG_Config.pm or Babel.pm\n";
77 :     return undef;
78 :     }
79 :    
80 : tharriso 1.2 if ($type eq "PPO") {
81 : wilke 1.1 eval {
82 :     $_[0]->{_handle} = DBMaster->new( -database => $db,
83 :     -host => $dbhost,
84 :     -user => $user,
85 :     -backend => $backend,
86 :     );
87 :     };
88 :     }
89 : tharriso 1.2 else {
90 :     if ($dbhost) {
91 :     $_[0]->{_handle} = DBI->connect("DBI:$type:dbname=$db;host=$dbhost", $user, $dbpass);
92 :     }
93 :     print STDERR $_[0]->{_handle} . "\n";
94 : wilke 1.1 unless ( $_[0]->{_handle} ) {
95 :     print STDERR "Error , " , DBI->error , "\n";
96 :     }
97 :     }
98 :    
99 :     if ($@) {
100 :     warn "Unable to read DataHandler::Babel : $@\n";
101 :     $_[0]->{_handle} = undef;
102 :     }
103 :     }
104 :     return $_[0]->{_handle};
105 :     }
106 :    
107 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3