| 1 | package LIMS::Controller; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '1.6'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | { package lims_controller; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use LIMS::Database::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use LIMS::Web::Interface; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # web methods come first in the inheritance tree | ||||||||||||||||||||||||||||
| 13 | 1 | our @ISA = qw( lims_interface lims_database ); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 16 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 17 | 0 | $self->close_log; | |||||||||||||||||||||||||||
| 18 | 0 | $self->disconnect_dbh; | |||||||||||||||||||||||||||
| 19 | 0 | $self->SUPER::DESTROY; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub finish { | ||||||||||||||||||||||||||
|
Subroutine
finish: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 23 | 0 | $self->param_forward; | |||||||||||||||||||||||||||
| 24 | 0 | $self->print_footer; | |||||||||||||||||||||||||||
| 25 | 0 | $self->disconnect_dbh; | |||||||||||||||||||||||||||
| 26 | 0 | $self->close_log; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | ### login/session methods ### | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub check_login { | ||||||||||||||||||||||||||
|
Subroutine
check_login: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 31 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 32 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 33 | 0 | ▶ | if (my $db_user_name = $q->param('user_name')){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (my $db_user_pass = $q->param('password')){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 35 | 0 | $self->check_user_pass; | |||||||||||||||||||||||||||
| 36 | } elsif (my $personnel_id = $q->param('personnel_id')){ | ||||||||||||||||||||||||||||
| 37 | 0 | $self->check_session; | |||||||||||||||||||||||||||
| 38 | } else { | ||||||||||||||||||||||||||||
| 39 | 0 | $self->db_error('No password was entered'); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||
| 42 | 0 | $self->db_error('No user name was entered'); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($self->db_error){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | $self->print_errors; | |||||||||||||||||||||||||||
| 46 | 0 | $self->print_footer; | |||||||||||||||||||||||||||
| 47 | 0 | return undef; # bad login | |||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||
| 49 | 0 | return 1; # login OK | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub check_session { | ||||||||||||||||||||||||||
|
Subroutine
check_session: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 53 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 54 | 0 | my $epoch_time = Date::EzDate->new()->{'epoch second'}; | |||||||||||||||||||||||||||
| 55 | 0 | my $sess_start_secs; | |||||||||||||||||||||||||||
| 56 | 0 | my $session_length = $self->session_length; | |||||||||||||||||||||||||||
| 57 | # get session information from db | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (my $user_session = $self->get_user_session) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | # check time since last session activity | ||||||||||||||||||||||||||||
| 60 | 0 | $sess_start_secs = Date::EzDate->new( $self->session_time )->{'epoch second'}; | |||||||||||||||||||||||||||
| 61 | 0 | my $session_duration = $epoch_time - $sess_start_secs; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( $session_duration > $session_length ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | $self->db_error('session timed out'); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | #Êcheck the user's ip address matches that in the db | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( $self->session_ip ne $self->current_ip ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | $self->db_error('ip error'); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } else { | ||||||||||||||||||||||||||||
| 70 | 0 | $self->db_error('session closed'); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | # so long as there aren't any errors, update the session to NOW() | ||||||||||||||||||||||||||||
| 73 | 0 | ▶ | unless( $self->db_error ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | # compare session time in db with that from cgi | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if (( $sess_start_secs > Date::EzDate->new( $self->current_sess_time )->{'epoch second'}) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sess_start_secs > "Date::EzDate"->new($self->current_sess_time)->{"epoch second"} and $self->back_sensitive
MC/DC0%0/2
$sess_start_secs > "Date::EzDate"->new($self->current_sess_time)->{"epoch second"} and $self->back_sensitive
$sess_start_secs > "Date::EzDate"->new($self->current_sess_time)->{"epoch second"}
$self->back_sensitive
Truth table0%0/3
A and B
A= $sess_start_secs > "Date::EzDate"->new($self->current_sess_time)->{"epoch second"}B= $self->back_sensitive
| |||||||||||||||||||||||||||||
| 76 | ( $self->back_sensitive)) { # is an 'old' session | ||||||||||||||||||||||||||||
| 77 | 0 | $self->standard_error("Data from this page has already been entered into the database.","Please don't use the browser's 'back' button after submitting a form"); | |||||||||||||||||||||||||||
| 78 | 0 | $self->kill_pipeline; | |||||||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||||||||
| 80 | 0 | $self->update_session; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub update_session { | ||||||||||||||||||||||||||
|
Subroutine
update_session: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 86 | 0 | $self->alter_session_id(1); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub close_session { | ||||||||||||||||||||||||||
|
Subroutine
close_session: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 90 | 0 | $self->alter_session_id(0); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub log_out { | ||||||||||||||||||||||||||
|
Subroutine
log_out: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 94 | 0 | $self->close_session; | |||||||||||||||||||||||||||
| 95 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 96 | 0 | $q->delete_all(); | |||||||||||||||||||||||||||
| 97 | 0 | $q->param(-name=>'logout',-value=>1); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub alter_session_id { | ||||||||||||||||||||||||||
|
Subroutine
alter_session_id: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 101 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 0 | my $state = shift; | |||||||||||||||||||||||||||
| 103 | 0 | my $date = Date::EzDate->new(); | |||||||||||||||||||||||||||
| 104 | 0 | my $mysql_time = $date->{'{year}/{%m}/{%d} %T'}; # unix style %Y actually returns 2-digit year | |||||||||||||||||||||||||||
| 105 | 0 | my $ip_address = $self->current_ip; | |||||||||||||||||||||||||||
| 106 | 0 | my $usr_info_obj = $self->get_user_info; | |||||||||||||||||||||||||||
| 107 | 0 | ▶ | my $session_id = ($state) ? $ip_address.",".$mysql_time : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | 0 | $usr_info_obj->session_id($session_id); | |||||||||||||||||||||||||||
| 109 | 0 | $usr_info_obj->update(); | |||||||||||||||||||||||||||
| 110 | 0 | $usr_info_obj->dbi_commit; | |||||||||||||||||||||||||||
| 111 | 0 | $self->session_id($usr_info_obj->session_id); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub current_ip { | ||||||||||||||||||||||||||
|
Subroutine
current_ip: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | if(defined $ENV{'HTTP_PC_REMOTE_ADDR'}){ # is mac os x server | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 0 | return $ENV{'HTTP_PC_REMOTE_ADDR'}; | |||||||||||||||||||||||||||
| 118 | } else { # use standard cgi remote host call | ||||||||||||||||||||||||||||
| 119 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 120 | 0 | return $q->remote_host(); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub system_ip { | ||||||||||||||||||||||||||
|
Subroutine
system_ip: not called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||
| 124 | 1 | ▶ | use Net::Address::IPv4::Local; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 125 | 0 | my $ip = Net::Address::IPv4::Local->public; | |||||||||||||||||||||||||||
| 126 | 0 | return $ip; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | 0 | ▶ | sub current_sess_time { # from cgi | ||||||||||||||||||||||||||
|
Subroutine
current_sess_time: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 129 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 130 | 0 | $self->session_arry($self->session_id,1); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub session_ip { # from db | ||||||||||||||||||||||||||
|
Subroutine
session_ip: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 133 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 134 | 0 | $self->session_arry($self->get_user_session,0); | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub session_id { | ||||||||||||||||||||||||||
|
Subroutine
session_id: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 137 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 138 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 0 | $q->param('session_id',shift); | |||||||||||||||||||||||||||
| 141 | } else { | ||||||||||||||||||||||||||||
| 142 | 0 | $q->param('session_id'); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub session_time { # from db | ||||||||||||||||||||||||||
|
Subroutine
session_time: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 146 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 147 | 0 | $self->session_arry($self->get_user_session,1); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub session_arry { | ||||||||||||||||||||||||||
|
Subroutine
session_arry: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 150 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 151 | 0 | my $session = shift; # e.g. 127.0.0.1,2007/10/22 12:2:14 | |||||||||||||||||||||||||||
| 152 | 0 | my @session = split (/,/, $session); | |||||||||||||||||||||||||||
| 153 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 0 | my $element = shift; | |||||||||||||||||||||||||||
| 155 | 0 | return($session[$element]); | |||||||||||||||||||||||||||
| 156 | } else { | ||||||||||||||||||||||||||||
| 157 | 0 | return(@session); | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub get_user_session { | ||||||||||||||||||||||||||
|
Subroutine
get_user_session: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 161 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 162 | 0 | my $user_obj = $self->get_user_info; | |||||||||||||||||||||||||||
| 163 | 0 | return $user_obj->session_id; # e.g. 127.0.0.1,2007/10/22 12:2:14 | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub get_user_info { | ||||||||||||||||||||||||||
|
Subroutine
get_user_info: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 167 | 0 | ▶ | unless ($self->{ _user_info }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 0 | $self->{ _user_info } = DBLoader::UserInformation->retrieve($self->personnel_id); | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | 0 | return $self->{ _user_info }; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub check_user_pass { | ||||||||||||||||||||||||||
|
Subroutine
check_user_pass: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 173 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 174 | 0 | my $user_name = $self->db_user_name; | |||||||||||||||||||||||||||
| 175 | 0 | my $user_pass = $self->db_user_pass; | |||||||||||||||||||||||||||
| 176 | 0 | my $statement = " | |||||||||||||||||||||||||||
| 177 | SELECT personnel_id | ||||||||||||||||||||||||||||
| 178 | FROM user_information | ||||||||||||||||||||||||||||
| 179 | WHERE full_name = '$user_name' | ||||||||||||||||||||||||||||
| 180 | AND password = OLD_PASSWORD(?) | ||||||||||||||||||||||||||||
| 181 | "; | ||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if (my $personnel_id = $self->sql_fetch_bindparam($statement,$user_pass)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 184 | 0 | $q->delete('password','Login'); | |||||||||||||||||||||||||||
| 185 | 0 | $self->personnel_id($personnel_id); | |||||||||||||||||||||||||||
| 186 | 0 | $self->update_session; | |||||||||||||||||||||||||||
| 187 | } else { | ||||||||||||||||||||||||||||
| 188 | 0 | $self->db_error('login failed'); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | # user_name and user_pass are only set at login | ||||||||||||||||||||||||||||
| 192 | 0 | ▶ | sub db_user_name { | ||||||||||||||||||||||||||
|
Subroutine
db_user_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 193 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 194 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 195 | 0 | $q->param('user_name'); | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub db_user_pass { | ||||||||||||||||||||||||||
|
Subroutine
db_user_pass: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 198 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 200 | 0 | $q->param('password'); | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | # personnel_id set by check_login() | ||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub personnel_id { | ||||||||||||||||||||||||||
|
Subroutine
personnel_id: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 204 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 205 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 206 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 0 | $q->param('personnel_id',shift); | |||||||||||||||||||||||||||
| 208 | } else { | ||||||||||||||||||||||||||||
| 209 | 0 | $q->param('personnel_id'); | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | 0 | ▶ | sub text_errors { | ||||||||||||||||||||||||||
|
Subroutine
text_errors: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 213 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 214 | 0 | return $self->get_error_string($self->db_error,$self->standard_error); | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub print_db_errors { | ||||||||||||||||||||||||||
|
Subroutine
print_db_errors: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 217 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 218 | 0 | ▶ | return unless (my $aErrors = $self->db_error); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ($self->has_cgi){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 0 | my $q = $self->get_cgi; | |||||||||||||||||||||||||||
| 221 | 0 | ▶ | $self->print_header unless ($self->title_printed); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 0 | print $q->h2("The following errors were reported:"), | |||||||||||||||||||||||||||
| 223 | $q->start_p({-class=>'lims_error'}); | ||||||||||||||||||||||||||||
| 224 | 0 | for my $error (@$aErrors){ | |||||||||||||||||||||||||||
| 225 | 0 | print $q->em($error), | |||||||||||||||||||||||||||
| 226 | $q->br; | ||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 0 | print $q->end_p; | |||||||||||||||||||||||||||
| 229 | } else { | ||||||||||||||||||||||||||||
| 230 | 0 | print $self->get_error_string($aErrors); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub any_error { | ||||||||||||||||||||||||||
|
Subroutine
any_error: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 234 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 235 | 0 | ▶ | if (($self->standard_error) || ($self->db_error)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->standard_error or $self->db_error
MC/DC0%0/2
$self->standard_error or $self->db_error
$self->standard_error
$self->db_error
Truth table0%0/3
A or B
A= $self->standard_errorB= $self->db_error
| |||||||||||||||||||||||||||||
| 236 | 0 | return 1; | |||||||||||||||||||||||||||
| 237 | } else { | ||||||||||||||||||||||||||||
| 238 | 0 | return; | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub print_errors { | ||||||||||||||||||||||||||
|
Subroutine
print_errors: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 242 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 243 | 0 | $self->print_db_errors; | |||||||||||||||||||||||||||
| 244 | 0 | $self->print_standard_errors; | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | 0 | ▶ | sub clear_all_errors { | ||||||||||||||||||||||||||
|
Subroutine
clear_all_errors: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 247 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 248 | 0 | $self->clear_db_errors; | |||||||||||||||||||||||||||
| 249 | 0 | $self->clear_standard_errors; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub write_log { | ||||||||||||||||||||||||||
|
Subroutine
write_log: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 252 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 253 | 0 | my $oLog_File = $self->get_log_file; | |||||||||||||||||||||||||||
| 254 | 0 | $oLog_File->add_text(@_); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 0 | ▶ | sub close_log { | ||||||||||||||||||||||||||
|
Subroutine
close_log: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 257 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 258 | 0 | ▶ | if ($self->is_log_open){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | my $oLog_File = $self->get_log_file; | |||||||||||||||||||||||||||
| 260 | 0 | $oLog_File->close_filehandle; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub log_open { | ||||||||||||||||||||||||||
|
Subroutine
log_open: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 264 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 265 | 0 | $self->{ _log_open }++; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub is_log_open { | ||||||||||||||||||||||||||
|
Subroutine
is_log_open: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 268 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 269 | 0 | $self->{ _log_open }; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub get_log_file { | ||||||||||||||||||||||||||
|
Subroutine
get_log_file: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 272 | 0 | require Microarray::File; | |||||||||||||||||||||||||||
| 273 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 274 | 0 | ▶ | unless (defined $self->{ _log_file }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 0 | $self->{ _log_file } = log_file->new($self->create_storage_path('log_file')); | |||||||||||||||||||||||||||
| 276 | 0 | $self->log_open; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | 0 | $self->{ _log_file }; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub save_file { | ||||||||||||||||||||||||||
|
Subroutine
save_file: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 281 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 282 | 0 | my $var = shift; | |||||||||||||||||||||||||||
| 283 | 0 | my ($filehandle,$file_name); | |||||||||||||||||||||||||||
| 284 | 0 | ▶ | if (ref $var){ # isa filehandle | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 0 | $file_name = shift; | |||||||||||||||||||||||||||
| 286 | 0 | $filehandle = $var; | |||||||||||||||||||||||||||
| 287 | } else { # var isa file param name | ||||||||||||||||||||||||||||
| 288 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 0 | ($filehandle,$file_name) = $self->upload_file($var,shift); | |||||||||||||||||||||||||||
| 290 | } else { | ||||||||||||||||||||||||||||
| 291 | 0 | ($filehandle,$file_name) = $self->upload_file($var); | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | 0 | my $file_id = $self->filehandle_to_blob($filehandle,$file_name); | |||||||||||||||||||||||||||
| 295 | 0 | return ($file_id, $file_name); | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 1 | 1; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | __END__ | ||||||||||||||||||||||||||||