Availabiilty using DAIA (Document Availability Information API)

Extension Information
Extension File Name: 
daiaAvailability.js
Author: 
Owen Stephens
Extension Class Name: 
daiaAvailability
Function Parameters: 

* arg: ju - instance of juice
* arg: insert - JuiceInsert to use
* arg: targetDiv - id of element to place availability information in
* arg: availIDs - Juice Meta element containing array of IDs for DAIA requests
* arg: availServer - url of availability server
* arg: availType - set to 'online' to treat all availability as online, otherwise will treat DAIA response generically
* arg: format - format to return DAIA results [json only format currently supported]
* arg: noLines - number of availability lines to display unhidden.
      Remaining lines will be hidden and 'show' button added.
      Any 'open access' availability will be shown whatever this value
      Ignored when availType == 'online'
* arg: toggleExpand - URL of image to be used for the toggleAvailability 'expand' function where some results are hidden. Not used when availType == 'online'
* arg: toggleCollapse - URL of image to be used for the toggleAvailability 'collapse' function where some results are hidden. Not used when availType == 'online'

Dependencies: 

 Tested with Juice 0.6.4

Example Code: 

 
// ****************
 
// Get Print Availability
// Example assumes a page listing one or more items, each with a COinS (Context Object in Span - see http://ocoins.info/). For print availability the ISBN has been extracted from the COinS and added to an array of ISBNs as a metatag
// ****************

// Extension allows control over how many lines show in availabilty statements
// Define icons to be clicked for hiding/showing additional lines
var expandIcon = "http://example.ac.uk/expand.gif";
var collapseIcon = "http://example.ac.uk/collapse.gif"; 

var availServer = "http://daia.example.ac.uk"; // DAIA server for print availability
var availabilityDiv = '<div id="availability"></div>';
var insert_avail = new JuiceInsert(availabilityDiv,"span.Z3988","after");

// call daiaAvailability
/*
* Constructor arguments:
* arg: ju - instance of juice
* arg: insert - JuiceInsert to use
* arg: targetDiv - id of element to place image in
* arg: availIDs - Juice Meta element containing array of IDs for DAIA requests
* arg: availServer - url of availability server
* arg: availType - set to 'online' to treat all availability as online, otherwise will treat DAIA response generically
* arg: format - format to return DAIA results [jsonp only format currently supported]
* arg: noLines - number of availability lines to display unhidden. 
*                Remaining lines will be hidden and 'show' button added.
*                Any 'open access' availability will be shown whatever this value
*                Ignored when availType == 'online'
* arg: toggleExpand - URL of image to be used for the toggleAvailability 'expand' function where some results are hidden. Not used when availType == 'online'
* arg: toggleCollapse - URL of image to be used for the toggleAvailability 'collapse' function where some results are hidden. Not used when availType == 'online'
*/

new daiaAvailability(juice,insert_avail,"availability","isbns",availServer,"print","jsonp",1,expandIcon,collapseIcon);
}
// ****************
// Get Electronic Availability

// Example assumes a page listing one or more items, each with a COinS (Context Object in Span - see http://ocoins.info/). This has been used to create an array of COinS (one for each item) as a metatag

// ****************
 
// Create new Juice Meta that contains OpenURLs rather than just COINS 
// This is so we can use a proper http URI for DAIA request
 
var base_url = "http://openurl.ac.uk/?";
openurls = new(Array);
var coins = juice.getMetaValues("coins");
for (var i = 0; i < coins.length; i++){
openurls.push(base_url + coins[i]);
};
juice.setMeta("openurls",openurls);
 
var eavailServer = "http://daia.example.ac.uk"; // DAIA server for electronic availability
var eavailabilityDiv = '<div id="e-availability"></div>';
var insert_eavail = new JuiceInsert(eavailabilityDiv,"span.Z3988","after");

// call daiaAvailability
/*
* Constructor arguments:
* arg: ju - instance of juice
* arg: insert - JuiceInsert to use
* arg: targetDiv - id of element to place image in
* arg: availIDs - Juice Meta element containing array of IDs for DAIA requests
* arg: availServer - url of availability server
* arg: availType - set to 'online' to treat all availability as online, otherwise will treat DAIA response generically
* arg: format - format to return DAIA results [jsonp only format currently supported]
* arg: noLines - number of availability lines to display unhidden. 
*                Remaining lines will be hidden and 'show' button added.
*                Any 'open access' availability will be shown whatever this value
*                Ignored when availType == 'online'
* arg: toggleExpand - URL of image to be used for the toggleAvailability 'expand' function where some results are hidden. Not used when availType == 'online'
* arg: toggleCollapse - URL of image to be used for the toggleAvailability 'collapse' function where some results are hidden. Not used when availType == 'online'
*/

new daiaAvailability(juice,insert_eavail,"online-availability","openurls",eavailServer,"online","jsonp",0,expandIcon,collapseIcon);

This extension will pass an array of IDs (should be URIs, but the extension doesn't care) to any service that responds with DAIA compliant 'availability' statements. The extension then parses the results to display the 'availability' information.
Although there are a number of valid formats for DAIA responses, this extension only currently supports a JSONP response.
The extension supports request of 'print' availabilty or 'online' availability. This is for two reasons:

  • With DAIA it is not possible to discern the difference between availability of a physical item for loan and an online copy
  •  You may wish to display links to online availabiility in a different format to print availability

For print availability, the extension treats each DAIA 'department' as a separate location. Since in some circumstances this can result in many lines of 'availability' information, the extension allows you to limit the number of lines to display, with the option for the user to click an 'expand' option to see more (and subsequently hide the additional lines). In order to allow this, the extension needs to be passed the location of icons to represent the 'expand' and 'hide' functions when they are displayed to the user.
For more information on DAIA see http://purl.org/NET/DAIA and http://daia.sf.net.
Screen shots below show (respectively):

  • Display of online availability
  • Display of print availability expanded to show all availability
  • Display of print availability limited to one line

This extension was originally developed as part of the Sir Louie project at the University of Oxford, with funding from JISC. The original use case was to display availability information in a 'reading list' built with the Sakai Citation Helper. In this case the DAIA server functionality was built over Primo (print availability) and SFX (online availability). More information is available at http://blogs.oucs.ox.ac.uk/sirlouie/.
 

DAIAOnlineAvailability
DAIAPrintAvailabilityExpanded
DAIAPrintAvailabilityNotExpanded