package PaintGraphBoxplot; # -------------------------------------------------------------------- # The copyright and all other proprietary rights in this Database # (including software - SEE LICENSING AGREEMENT) are the sole and # exclusive property of the Institute for Scientific Information # (ISI). This Database and source code, or any derivative works # thereof, are confidential and proprietary to ISI . Therefore, # duplication, reuse, redistribution, reverse assembling, reverse # compiling, or translation of the Database, source code, or any # portion thereof IS NOT PERMITTED. Consult Licensing Agreement. # -------------------------------------------------------------------- use strict; use Data::Dumper; use JCR::GraphBoxplot; use ISIBench; use JCR::Journal; use Log::Log4perl qw(get_logger); use base qq(JCRPage); sub build_page { ISIBench::start(); my $logger = get_logger("PaintGraphBoxplot"); my $self = shift; my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; my ($edition, $year, $results,$path,$category); #Get input parameters my $request = $self->{request}; my $j20 = $request->{'journal'}; my $cat = $request->{'category'}; my $issn = $request->{'issn'}; my $source = $request->{'source'}; $logger->debug(" PaintBoxplot Args are : ", sub{Dumper($request)}); # Get session object my $session = $self->{session}; # Get year & edition my $edition = $session->get( 'value' => 'edition' ); my $year = $session->get( 'value' => 'year' ); # Get Graph Object my $graph = JCR::GraphBoxplot->new( 'year' => $year->{year} ); # Check for Cache before hitting the database if ( $j20 ) { $path = $CF::cache_directory . qq{/journals/$year->{year}/$edition->{edition}/$j20/Boxplots}; $path =~ tr/ /_/; $logger->debug("Boxplots Dir Path : $path "); } elsif ( $cat ) { $path = qq{$CF::cache_directory/journals/$year->{year}/$edition->{edition}/$cat/Boxplots}; $path =~ tr/ /_/; } # Are we cached? $results = $graph->load( 'path' => $path, 'filename' => $CF::IFBoxplotCacheFilename, ) if ($CF::cache_impact_boxplot); unless (defined($results)) { if ( $j20 ) { # Not cached, so build the graph $logger->debug("BOXPLOT Graph Built, not found in $path"); my $journal = JCR::Journal->new( 'db' => $self->{db}, 'edition' => $edition->{edition}, 'year' => $year->{year}, ); unless (defined($journal) && (ref($journal) =~ /journal/i)) { $logger->error("Could not create journal object (#$journal)!"); ISIBench::stop(); return $journal; } my $title = $journal->get_journal_title('j20' => $j20); if (defined($title) && (ref($title) =~ /hash/i)) { unless (length($title->{'title'})) { $logger->error("Could not retrieve title for : $j20!"); ISIBench::stop(); return $title; } } my $jimpact = $journal->get_journal_impact('j20' => $j20); my $current_impact_factor = $$jimpact{'impact_current'}; $logger->debug("JImpact : $current_impact_factor", sub {Dumper($jimpact)}); #Returns a Hash with Key -> Cat_Name ; Value-> @ Impact Factors my $jcat_impact_factors= $journal->get_category_impactfactors('j20' => $j20); unless (defined($jcat_impact_factors) && (ref($jcat_impact_factors) =~ /hash/i)) { $logger->debug(" Could not retrieve Categories and IF In JCR PaintGraphBoxplot : $jcat_impact_factors"); ISIBench::stop(); return 0; } #$logger->debug("In Paint graph jcat_impact_factors Values: ", sub{Dumper($jcat_impact_factors)}); $results = $graph->build( 'title' => $j20, 'jimpact' => $current_impact_factor, 'graph_type' => 'journal', 'jcat_impact_factors' => $jcat_impact_factors, ); $logger->debug("IFBoxplot Graph Data 1 : ", sub{Dumper($results)}); }elsif ( $cat ){ # No cache, so build the graph $logger->debug(" Category Boxplot Build, not found in $path"); # Get the category object $category = JCR::Category->new( 'db' => $self->{db}, 'edition' => $edition->{edition}, 'year' => $year->{year}, ); unless (defined($category) && (ref($category) =~ /category/i)) { $logger->error("Could not create category object (#$category)!"); ISIBench::stop(); return $cat; } #Returns a Hash with Key -> Cat_Name ; Value-> @ Impact Factors my $cat_impact_factors= $category->get_category_impactfactors( 'category' => $cat ); unless (defined($cat_impact_factors) && (ref($cat_impact_factors) =~ /hash/i)) { $logger->debug(" Could not retrieve Categories and IF In JCR PaintGraphBoxplot : $cat_impact_factors"); ISIBench::stop(); return 0; } $results = $graph->build( 'title' => $cat, 'graph_type' => 'category', 'jcat_impact_factors' => $cat_impact_factors, ); $logger->debug("IFBoxplot Category Data : ", sub{Dumper($results)}); } # save Impact Factor BOXPLOT graph in cache if ($CF::cache_impact_boxplot) { $graph->save( 'path' => $path, 'filename' => $CF::IFBoxplotCacheFilename, ); $logger->debug("Saving Impact Graph into: $path/$CF::IFBoxplotCacheFilename"); } }else { $logger->debug("IFBoxplot Graph Loaded from: $path"); $logger->debug("IFBoxplot Graph Data: ", sub{Dumper($results)}); } $self->set_header( 'name' => 'Expires', 'value' => 'Thu, 01 Jan 1970 00:00:01 GMT', ); $self->set_header( 'name' => 'Cache-Control', 'value' => 'no-cache', ); $self->set_header( 'name' => 'Pragma', 'value' => 'no-cache', ); $self->set_header( 'name' => 'Content-type', 'value' => 'image/png', ); $self->{CONTENT} = $results->{'data'} if (defined($results) && (ref($results) =~ /hash/i)); ISIBench::stop(); return 0; } # Overriding Page.pm's get_content method since we don't use a template for this output sub get_content { my $self = shift; return $self->{CONTENT}; } 1; =back =head1 AUTHOR Snehal Sidanale.