| 1 | package LIMS::Base; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '1.3'; | |||||||||
| 6 | |||||||||||
| 7 | { package lims; | ||||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||
| 10 | 0 | my $class = shift; | |||||||||
| 11 | 0 | my $self = { _page_title => shift }; | |||||||||
| 12 | 0 | bless $self, $class; | |||||||||
| 13 | 0 | $self->start_cgi; | |||||||||
| 14 | 0 | $self->load_dbi; | |||||||||
| 15 | 0 | ▶ | if ($self->check_login){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | return $self; | |||||||||
| 17 | } else { | ||||||||||
| 18 | 0 | return undef; | |||||||||
| 19 | } | ||||||||||
| 20 | } | ||||||||||
| 21 | 0 | ▶ | sub new_guest { | ||||||||
|
Subroutine
new_guest: not called CC=1 SCAR=6.9
| |||||||||||
| 22 | 0 | my $class = shift; | |||||||||
| 23 | 0 | my $self = { _page_title => shift }; | |||||||||
| 24 | 0 | bless $self, $class; | |||||||||
| 25 | 0 | $self->load_dbi; | |||||||||
| 26 | 0 | return $self; | |||||||||
| 27 | } | ||||||||||
| 28 | 0 | ▶ | sub new_script { | ||||||||
|
Subroutine
new_script: not called CC=1 SCAR=6.9
| |||||||||||
| 29 | 0 | my $class = shift; | |||||||||
| 30 | 0 | my $self = { _name => 'script' }; | |||||||||
| 31 | 0 | bless $self, $class; | |||||||||
| 32 | 0 | return $self; | |||||||||
| 33 | } | ||||||||||
| 34 | # special constructor for test scripts | ||||||||||
| 35 | # finds LIMS_Test.pm from test script and loads the test config file | ||||||||||
| 36 | 0 | ▶ | sub new_test { | ||||||||
|
Subroutine
new_test: not called CC=1 SCAR=6.9
| |||||||||||
| 37 | 0 | my $class = shift; | |||||||||
| 38 | 0 | my $config = shift; | |||||||||
| 39 | 0 | my $self = { _page_title => 'trl_test', | |||||||||
| 40 | _config_file_path => $config }; | ||||||||||
| 41 | 0 | bless $self, 'trl_test'; | |||||||||
| 42 | 0 | $self->set_isa($class); | |||||||||
| 43 | 0 | $self->load_dbi; | |||||||||
| 44 | 0 | return $self; | |||||||||
| 45 | } | ||||||||||
| 46 | 0 | ▶ | sub DESTROY { | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||
| 47 | 0 | my $self = shift; | |||||||||
| 48 | } | ||||||||||
| 49 | 0 | ▶ | sub get_error_string { | ||||||||
|
Subroutine
get_error_string: not called CC=4 SCAR=30.0
| |||||||||||
| 50 | 0 | my $self = shift; | |||||||||
| 51 | 0 | my $errors = ""; | |||||||||
| 52 | 0 | ▶ | ERROR:while (my $aErrors = shift){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 53 | 0 | ▶ | next ERROR unless (@$aErrors); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | 0 | for my $error (@$aErrors){ | |||||||||
| 55 | 0 | $errors .= $error."\n"; | |||||||||
| 56 | } | ||||||||||
| 57 | } | ||||||||||
| 58 | 0 | return $errors; | |||||||||
| 59 | } | ||||||||||
| 60 | 0 | ▶ | sub standard_error { | ||||||||
|
Subroutine
standard_error: not called CC=3 SCAR=24.8
| |||||||||||
| 61 | 0 | my $self = shift; | |||||||||
| 62 | 0 | ▶ | if (@_){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | my @aErrors = @_; | |||||||||
| 64 | 0 | ▶ | if (defined $self->{ _standard_error }){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | my $aErrors = $self->{ _standard_error }; | |||||||||
| 66 | 0 | push (@$aErrors, @aErrors); | |||||||||
| 67 | } else { | ||||||||||
| 68 | 0 | $self->{ _standard_error } = \@aErrors; | |||||||||
| 69 | } | ||||||||||
| 70 | } else { | ||||||||||
| 71 | 0 | $self->{ _standard_error }; | |||||||||
| 72 | } | ||||||||||
| 73 | } | ||||||||||
| 74 | 0 | ▶ | sub text_errors { | ||||||||
|
Subroutine
text_errors: not called CC=1 SCAR=6.9
| |||||||||||
| 75 | 0 | my $self = shift; | |||||||||
| 76 | 0 | return $self->get_error_string($self->standard_error); | |||||||||
| 77 | } | ||||||||||
| 78 | 0 | ▶ | sub any_error { | ||||||||
|
Subroutine
any_error: not called CC=2 SCAR=17.9
| |||||||||||
| 79 | 0 | my $self = shift; | |||||||||
| 80 | 0 | ▶ | if ($self->standard_error){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | return 1; | |||||||||
| 82 | } else { | ||||||||||
| 83 | 0 | return; | |||||||||
| 84 | } | ||||||||||
| 85 | } | ||||||||||
| 86 | 0 | ▶ | sub print_standard_errors { | ||||||||
|
Subroutine
print_standard_errors: not called CC=2 SCAR=17.9
| |||||||||||
| 87 | 0 | my $self = shift; | |||||||||
| 88 | 0 | ▶ | return unless (my $aErrors = $self->standard_error); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | 0 | print $self->get_error_string($aErrors); | |||||||||
| 90 | } | ||||||||||
| 91 | 0 | ▶ | sub print_errors { | ||||||||
|
Subroutine
print_errors: not called CC=1 SCAR=6.9
| |||||||||||
| 92 | 0 | my $self = shift; | |||||||||
| 93 | 0 | $self->print_standard_errors; | |||||||||
| 94 | } | ||||||||||
| 95 | 0 | ▶ | sub clear_standard_errors { | ||||||||
|
Subroutine
clear_standard_errors: not called CC=1 SCAR=6.9
| |||||||||||
| 96 | 0 | my $self = shift; | |||||||||
| 97 | 0 | $self->{ _standard_error } = []; | |||||||||
| 98 | } | ||||||||||
| 99 | 0 | ▶ | sub clear_all_errors { | ||||||||
|
Subroutine
clear_all_errors: not called CC=1 SCAR=6.9
| |||||||||||
| 100 | 0 | my $self = shift; | |||||||||
| 101 | 0 | $self->clear_standard_errors; | |||||||||
| 102 | } | ||||||||||
| 103 | 0 | ▶ | sub kill_pipeline { | ||||||||
|
Subroutine
kill_pipeline: not called CC=2 SCAR=17.9
| |||||||||||
| 104 | 0 | my $self = shift; | |||||||||
| 105 | 0 | ▶ | if (@_){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 0 | $self->standard_error(@_); | |||||||||
| 107 | } | ||||||||||
| 108 | 0 | $self->print_errors; | |||||||||
| 109 | 0 | $self->DESTROY; | |||||||||
| 110 | 0 | exit; | |||||||||
| 111 | } | ||||||||||
| 112 | 0 | ▶ | sub load_config { | ||||||||
|
Subroutine
load_config: not called CC=2 SCAR=10.9
| |||||||||||
| 113 | 1 | ▶ | use Config::IniFiles; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 114 | 0 | my $self = shift; | |||||||||
| 115 | 0 | ▶ | my $config_obj = new Config::IniFiles( -file => $self->config_file_path ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 116 | or die "LIMS::Base ERROR: Could not import the config file;\n".$self->config_file_path."\n"; | ||||||||||
| 117 | 0 | $self->{ _config_obj } = $config_obj; | |||||||||
| 118 | } | ||||||||||
| 119 | 0 | ▶ | sub config_obj { | ||||||||
|
Subroutine
config_obj: not called CC=2 SCAR=17.9
| |||||||||||
| 120 | 0 | my $self = shift; | |||||||||
| 121 | 0 | ▶ | unless (defined $self->{ _config_obj }){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 122 | 0 | $self->load_config; | |||||||||
| 123 | } | ||||||||||
| 124 | 0 | $self->{ _config_obj }; | |||||||||
| 125 | } | ||||||||||
| 126 | 0 | ▶ | sub config_param { | ||||||||
|
Subroutine
config_param: not called CC=1 SCAR=6.9
| |||||||||||
| 127 | 0 | my $self = shift; | |||||||||
| 128 | 0 | my $config_obj = $self->config_obj; | |||||||||
| 129 | 0 | return $config_obj->val(shift,shift); | |||||||||
| 130 | } | ||||||||||
| 131 | 0 | ▶ | sub config_all_params { | ||||||||
|
Subroutine
config_all_params: not called CC=1 SCAR=6.9
| |||||||||||
| 132 | 0 | my $self = shift; | |||||||||
| 133 | 0 | my $config_obj = $self->config_obj; | |||||||||
| 134 | 0 | return $config_obj->Parameters(shift); | |||||||||
| 135 | } | ||||||||||
| 136 | 0 | ▶ | sub config_all_sections { | ||||||||
|
Subroutine
config_all_sections: not called CC=1 SCAR=6.9
| |||||||||||
| 137 | 0 | my $self = shift; | |||||||||
| 138 | 0 | my $config_obj = $self->config_obj; | |||||||||
| 139 | 0 | return $config_obj->Sections; | |||||||||
| 140 | } | ||||||||||
| 141 | |||||||||||
| 142 | |||||||||||
| 143 | |||||||||||
| 144 | } | ||||||||||
| 145 | |||||||||||
| 146 | 1 | 1; | |||||||||
| 147 | |||||||||||
| 148 | __END__ | ||||||||||