fix bp selenium test and brapi add program
[sgn.git] / cgi-bin / sequencing / itag / status.pl
blob3c534af008364b39c516094d8ec63a601dab555d
1 use CatalystX::GlobalContext qw( $c );
2 use strict;
3 use warnings;
4 use English;
6 use XML::Generator;
8 use CXGN::Scrap::AjaxPage;
10 use CXGN::Tools::List qw/str_in/;
12 use CXGN::ITAG::Pipeline;
14 our $itag_feature = $c->enabled_feature('itag')
15 or do { print "\n\nITAG feature not enabled.\n"; exit };
17 eval {
18 $ENV{CXGNITAGPIPELINEANALYSISTESTING} = 1 unless $c->get_conf('production_server');
20 my $page = CXGN::Scrap::AjaxPage->new("text/plain");
21 $page->send_http_header;
23 my ( $op ) = $page->get_encoded_arguments('op');
24 $op or die "must specify an operation when calling status web service\n";
26 #hash of operations
27 my %ops = ( astat => sub { analysis_status($page) },
28 lbs => sub { my ($p,$b) = get_pipe_and_batch($page); $b->seqlist},
29 lb => sub { get_pipe($page)->list_batches },
30 la => sub { get_pipe($page)->list_analyses },
31 lp => sub { map {sprintf("%03d",$_)} $itag_feature->list_pipelines },
34 $ops{$op} or die "unknown operation. valid operations are: ".join(',',sort keys %ops)."\n";
36 print map "$_\n",$ops{$op}->(); #call the operation and print its results
38 if($EVAL_ERROR) {
39 print "\n\nERROR: $EVAL_ERROR\nWeb service documentation can be found at: http://www.ab.wur.nl/TomatoWiki/PipelineStatusWebService\n";
42 exit;
45 ############ OPERATION SUBS ##############################
47 sub analysis_status {
48 my $page = shift;
49 my ($pipe,$batch) = get_pipe_and_batch($page);
50 my ($atag) = $page->get_encoded_arguments('atag');
51 my $a = $pipe->analysis($atag)
52 or die "no analysis found with that tag name\n";
53 return $a->status($batch);
56 ######### UTIL SUBS ######################################
58 sub get_pipe_and_batch {
59 my ( $page ) = @_;
60 my $pipe = get_pipe($page);
61 my ($bnum) = $page->get_encoded_arguments('batch');
62 $bnum += 0;
63 my $batch = $pipe->batch($bnum)
64 or die "batch number $bnum does not exist";
65 return ($pipe,$batch);
68 sub get_pipe {
69 my ( $page ) = @_;
70 my ( $ver ) = $page->get_encoded_arguments('pipe');
71 my @args = defined $ver ? (version => $ver+0) : ();
72 my $pipe = $itag_feature->pipeline( @args )
73 or die 'pipeline version $ver not found';
74 return $pipe;