package JCRGraphImpact; # -------------------------------------------------------------------- # 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 ISIBench; use JCRErrorList; use JCRUtil; use Log::Log4perl qw(get_logger); use base qq(JCRPage); use Data::Dumper; use JCR::Journal; use URL; sub build_page { ISIBench::start(); my $logger = get_logger("JCRGraphImpact"); my $self = shift; my $args = (ref $_[0] eq 'HASH') ? shift : { @_ }; my $session = $self->{session}; #Get input parameters my $request = $self->{request}; my($edition, $year, $journal, $journal_hash, $permissions, $jtitle); my $rqparam = $request->{'RQ'}; my $j20 = $request->{'journal'}; my $journal_rank = $request->{'rank'}; my $issn = $request->{'issn'}; my $poi = $request->{'PointOfEntry'}; my $return_link = $request->{'ReturnLink'}; my $img_logo = $request->{'ImgLogo'}; my $src_desc = $request->{'SrcDesc'}; $logger->debug("Args is : ", sub{Dumper($request)}); $edition = $session->get( 'value' => 'edition' ); $year = $session->get( 'value' => 'year' ); if ( $issn && !defined($j20) ) { $self->{from_links} = 1; $session->set( 'name' => 'source_app_URI', 'value' => $return_link, ); $session->set( 'name' => 'source_image_URI', 'value' => $img_logo, ); $session->set( 'name' => 'source_image_alttext', 'value' => $src_desc, ); # If linking in, we may need to determine the year and edition to use since it may be a new session # Note that we need to do this reguardless if an edition is already selected because # if the user has the science edition chosen, but links in from and app with an ISSN # for a social edition, we need to search both editions or it will fail when it does # not find the journal in the science edition. # FIXME: Make OO in 4.0 $permissions = $session->get_editions( 'year_min' => $CF::data_year_start, 'year_max' => $CF::data_year_end, ); foreach my $edition_name (keys %$permissions) { $year->{year} = $permissions->{$edition_name}->{end_year}; $edition->{edition} = $edition_name; $journal = JCR::Journal->new( 'db' => $self->{db}, 'edition' => $edition_name, 'year' => $year->{year}, ); if (defined($journal) && (ref($journal) =~ /journal/i)) { $journal_hash = $journal->get_journal_j20( 'issn' => $issn ); last if (defined($journal_hash) && (ref($journal_hash) =~ /hash/i)); } } unless (defined($journal_hash) && (ref($journal_hash) =~ /hash/i)) { ISIBench::stop(); return $journal_hash; } $j20 = $journal_hash->{journal}; $session->set( 'name' => 'year', 'value' => $year->{'year'}, ); $session->set( 'name' => 'edition', 'value' => $edition->{'edition'}, ); } # Build Journal Impact History # We may or may not have a journal object, so if not create one unless (defined($journal) && (ref($journal) =~ /journal/i)) { $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 $impact_history = $journal->get_journal_impact_history( 'j20' => $j20, 'issn' => $issn, 'year_min' => $CF::data_year_start, ); # get the journal title for displaying full title on the page. $jtitle = $journal->get_journal_title('j20' => $j20); unless (defined($jtitle) && (ref($jtitle) =~ /hash/i)) { $logger->error("Could not retrieve journal Title! (#$jtitle)"); ISIBench::stop(); return 0; } # Build the JCRImpact page template $logger->debug("Loading jcr_impact_factor.html template"); my $ret = $self->set_template( 'template' => "jcr_impact_factor.html" ); if ($ret) { ISIBench::stop(); return $ret; } # If an error is in the URI display it if (exists $request->{error}) { $logger->debug("Displaying error: #$request->{error}"); my $errorlist = JCRErrorList->new(); my $error = $errorlist->map( 'error' => $request->{error} ); $self->set( 'name' => 'error', 'value' => qq|***** $error->{error} *****|, ); } # Set the image width & height $self->set( 'name' => 'image_width', 'value' => $CF::ImpactFactorGraphWidth, ); $self->set( 'name' => 'image_height', 'value' => $CF::ImpactFactorGraphHeight, ); $j20 = URL::encode($j20); $self->set( 'name' => 'j20', 'value' => $j20, ); $self->set( 'name' => 'jtitle', 'value' => $jtitle->{title}, ); $self->set( 'name' => 'rank', 'value' => $journal_rank, ); $self->set( 'name' => 'impact_history', 'value' => $impact_history, ); # Set the page title $self->set_title( 'title' => 'Impact Trend Graph' ); # Add the toolbar my $toolbar = $self->build_toolbar( 'help' => '2.12' ); unless (defined($toolbar) && (ref($toolbar) =~ /toolbar/i)) { ISIBench::stop(); return $toolbar; } my $uri_return_string; if ( $self->{from_links} ) { $uri_return_string = qq|$CF::base_path/JCR?RQ=RECORD&rank=$journal_rank&journal=$j20|; } else { $uri_return_string = qq|$CF::base_path/JCR?RQ=RECORD&rank=$journal_rank&journal=$j20&req_from=TRENDS|; } #Add the return to summary button $toolbar->add( 'button' => 'TB_RET2JOURNAL', 'URI' => $uri_return_string, ); # Log the Impact Trend Page View event $session->log_event( 'event' => 'event_record_view', 'data' => { 'count' => 1, }, ); # error checking my $error_string = $session->getError(); if ( length($error_string) > 1 ) { $logger->error("WURS Event not logged: $error_string"); } ISIBench::stop(); return 0; } 1;