package PaintGraphPubFreq; # -------------------------------------------------------------------- # 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::GraphPubFreq; use ISIBench; use JCR::Journal; use JCR::Category; use Log::Log4perl qw(get_logger); use base qq(JCRPage); sub build_page { ISIBench::start(); my $logger = get_logger("PaintGraphImpact"); my $self = shift; my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; #Get input parameters my $request = $self->{request}; my $cat_name = $request->{'category'}; $logger->debug("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::GraphPubFreq->new( 'year' => $year->{year} ); # Build cache directory path my $path = $CF::cache_directory . qq{/journals/$year->{year}/$edition->{edition}/$cat_name/Graphs}; $path =~ tr/ /_/; # Are we cached? my $results; $results = $graph->load( 'path' => $path, 'filename' => $CF::JFCacheFilename, ) if ($CF::cache_pubfreq_graph); unless (defined($results)) { # Not cached, so build the graph $logger->debug("Journal Publication Frequency 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; } #Create a category object my $cat = JCR::Category->new( 'db' => $self->{db}, 'edition' => $edition->{edition}, 'year' => $year->{year}, ); unless (defined($cat) && (ref($cat) =~ /category/i)) { $logger->error("Could not create category object (#$cat)!"); ISIBench::stop(); return $cat; } # Get category subject by name my $cathash = $cat->get_category_by_name( 'name' => $cat_name, 'order_by' => 'name', ); $logger->debug("Cat Hash : ", sub{Dumper($cathash)}); my $pubfreq = $cat->get_category_pubfreq('subject' => $cathash); $results = $graph->build( 'title' => $CF::JFGraphTitle, 'pub_frequency' => $pubfreq, ); # save Journal Publication Frequency graph in cache if ($CF::cache_pubfreq_graph) { $graph->save( 'path' => $path, 'filename' => $CF::JFCacheFilename, ); $logger->debug("Saving Impact Graph into: $path/$CF::JFCacheFilename"); } } else { $logger->debug("Journal Publication Frequency Graph Loaded from: $path"); $logger->debug("Journal Publication Frequency 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/jpeg', ); $self->{CONTENT} = $results->{'data'}; 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;