Tech Blog

showPNX Revisited

Description

A more reliable and robust way to show PNX records(LOCAL and Primo Central).

Author: Mehmet Celik

Institution: KU Leuven

Year: 2013

License: BSD style

Short description: Use, modification and distribution of the code are permitted provided the copyright notice, list of conditions and disclaimer appear in all related material.

State

Stable

Programming language

Javascript, Java

Software Requirements

web browser

Screen Captures


showPNX Revisited from Mehmet Celik on Vimeo.

Author(s) homepage

http://www.libis.be

Working example

http://limo.libis.be

Go to the link above and run the bookmarklet(see installation instructions). The record numbers(1,2,3,…) appear and when you click a number a new window opens with your PNX record.

Using the following Ex Libris open interfaces

DeepSearch API

Installation instructions

Copy the next piece of code into a bookmark.

javascript:var e=$('td.EXLResultNumber:not(:has(a))');$.each(e, function(){var i=parseInt($(this).html());isNaN(i) ? alert('No record index found') : $(this).empty().append('<a target="_blank" href="/primo_library/libweb/showPNX.jsp?id=' + (i-1) +'">'+ i + '</a>');});e.show();void(0);

Create a file called showPNX.jsp (this is hardcoded in the bookmarklet so make sure the case is the same). Copy the code below into that file, make sure <?xml …. ?> is on the first line(if not your browser will complain.). Then copy that file to the FrontEnd server(s). It should be placed in the directory that the fe_web alias points to.

<?xml version="1.0" encoding="UTF-8"?>

<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page import="com.exlibris.primo.utils.SessionUtils" %>

<%@ page import="com.exlibris.jaguar.xsd.search.DOCDocument.DOC" %>

<%

String record = "<error>no record</error>";

int recordID = Integer.parseInt(request.getParameter("id"));

int recordIDOnPage = 0;

try {

        DOC[] docArray = SessionUtils.getSearchResult(request).getSEGMENTS().getJAGROOTArray(0).getRESULT().getDOCSET().getDOCArray();

       recordIDOnPage = recordID % docArray.length;

        record =docArray[recordIDOnPage].getPrimoNMBib().xmlText();

} catch (Exception e) {

   record = "<error>" + e.getMessage() + "</error>";

}

%>

<%=record%>

When you run the bookmarklet the record numbers(1,2,3,…) appear and clicking on a record number a new window opens with your PNX record.

Page attachments

View link here

Comments

May 31, 2013
Ulrich Leodolter

Hi,

We found that double click on the bookmark results in NaN links.

<td class="EXLResultNumber"><a href="/primo_library/libweb/showPNX.jsp?id=NaN" target="_blank">NaN</a></td>

I think the result of parseInt() should be checked for valid numbers, this works for us:

javascript:var e=$('td.EXLResultNumber');$.each(e, function(){var i=parseInt($(this).html());if(!isNaN(i)){$(this).empty().append('<a target="_blank" href="/primo_library/libweb/showPNX.jsp?id=' + (i-1) +'">'+ i +'</a>'););e.show();void(0);

Regards

Ulrich

May 31, 2013
Mehmet Celik

Thanks

June 13, 2013
Alexander Jerabek

Hi Mehmet,

This is very nicely done. I have managed to get it to work in our staging environment (v4.1.3) with the accesskey Alt+Shift+z (Firefox and Chrome), but cannot get it to work in our production environment (v3.1.3). Is the showPNX.jsp version specific?
Works nicely in staging v4.1.3: http://eudoxelien.uqam.ca/tout/brio
Does not work in production v3.1.3 http://virtuolien.uqam.ca/tout/brio

Any advice?

Thanks,
Sacha

June 13, 2013
Alexander Jerabek

Hi again,

Just for the record, the fact that it failed to work in v3.1.3 was entirely due to user error. It works fine in v3.1.3.

Thanks Mehmet!

Sacha

Jul 13, 2013
Dean Lingley

Hmm. i must be missing something… the #’s appear but the links don’t open to the PNX;

http://purdue-primo-prod.hosted.exlibrisgroup.com/primo_library/libweb/action/search.do?vid=PURDUE

Any ideas? We’re on 4.4/

Thanks!

Jul 18, 2013
Mehmet Celik

Hi Dean,

Did you copy the showPNX.jsp onto your frontend server(s)? Because if I query the file the browser says “404 not found”.

Mehmet

Jul 19, 2013
Dean Lingley

Doh.. It was a case issue. I had showPnx.jsp instead of showPNX.jsp

Thanks!

Aug 7, 2013
Alexander Jerabek

Hi Mehmet,

We’re getting a lot of good use out of this PNX button feature. Do you know if it is possible to easily adapt this so that we can also show the source data similar to the way the PNX viewer offers this option? This for local data from our Aleph catalogue, our librarians would find it useful to compare the PNX with the original exported MARC.

Thanks,

Sacha

Aug 12, 2013
Mehmet Celik

Yes you can but only for local records. I’ll contact you off list.

Oct 15, 2013
Philipp Zumstein

It is possible to use this file in the background to improve the zotero picker. We adapted the zotero translator Primo.js to use either this JSP-file or to add “&showPNX=true” to receive the PNX file from a record and save the citation. No special installation is needed.

Now, all primo instances with this JSP-file can easily save citations into zotero from local records as well as from PrimoCentral. Moreover, all other primo instances can still save citations from local records (as it was always).

Thank you very much for the JSP-file. Great work!

Oct 17, 2013
Mehmet Celik

Thanks Philipp

Leave a Reply