CSV lookup Enrichment Plug-in
Tags: enrichment, publishing, pipes, plug-in, primo
Last Updated: Oct 30, 2009 01:17
- Description
A pipe enrichment plug-in to look up the record's id in a CSV file and insert data found into the PNX record. Also useful as a base to build other plug-ins.
In this code, records identified in the CSV are part of the 'Discover' service. If a record is found in the CSV it should be added to the 'Discover' search scope, the label for the category topic should be added to the PNX fields search/addtitle and facets/collection, and all its ancestor categories should also be included in those fields.
It could do with some tidyup, but I thought it was better to put it up in a raw state than never get around to putting it up at all! 
- Author: Douglas Campbell
- Institution: National Library of New Zealand
- Year: 2009
- 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.
- Link to terms: [Detailed license terms]
- Skill required for using this code:
Choose one of the following: advanced. Please also add your choice as a tag at the bottom of the page.
State
Stable (for us)
Programming language
Java
Software requirements
Java
Download
DiscoverCategory.java
CommandlineTest.java
Working example
http://find.natlib.govt.nz/
Using the following Ex Libris open interfaces
http://www.exlibrisgroup.org/display/Primo/Enrichment+Plug-in
Installation instructions
(The file location shown are for our installation, eg. 'p2_1' may differ.)
Overview
Can only specify one enrichment set per pipe, but you can define multiple classes to be called in succession. The classes become available in the Back Office by defining them in the custom_enrich_tasks_list.xml config file.
There is one user-controlled config file passed to all user-defined plugins, but a parameter passed in from there could be a filename for the class to load in additional parameters.
Your class will implement the com.exlibris.primo.api.enrichment.plugin.EnrichmentPlugIn.enrich() interface which is in /exlibris/primo/p2_1/ng/primo/home/system/thirdparty/openserver/server/publish/deploy/primo_publishing-app.ear/lib/primo_publishing-api.jar.
The enrich() class is passed the PNX record and a parameters Map. The parameters Map initially just contains the filename for the overall config file, but you can also store your own parameters in it to pass to subsequently called classes (in theory - haven't tested this).
Process
1. Create your class then compile and place jar on server, also place data files on server:
/exlibris/primo/p2_1/ng/primo/home/profile/publish/publish/production/conf/enrichPlugin/lib/DiscoverEnrichment.jar
/exlibris/primo/p2_1/ng/primo/home/profile/publish/publish/production/conf/enrichPlugin/data/DiscoverIds.csv
IRN,REFNO,NDHAID,CATEGORY1,CATEGORY2,CATEGORY3
1440,C-025-009,IE141651,A-VA-05-22,,
4125,C-025-021,IE46599,A-VA-05-22,,
...
/exlibris/primo/p2_1/ng/primo/home/profile/publish/publish/production/conf/enrichPlugin/data/DiscoverCategories.csv
code,label
A-M,"Music"
A-M-01,"New Zealand Composers and Collaboration"
A-M-01-02,"Buchanan, Dorothy Quita 1945-"
...
2. Add local parms to parms file:
/exlibris/primo/p2_1/ng/primo/home/profile/publish/publish/production/conf/enrichPlugin/plugin_parameters.txt
discover_lookup_filename=/exlibris/primo/p2_1/ng/primo/home/profile/publish/publish/production/conf/enrichPlugin/data/DiscoverIds.csv
discover_categories_filename=/exlibris/primo/p2_1/ng/primo/home/profile/publish/publish/production/conf/enrichPlugin/data/DiscoverCategories.csv
3. Add class to config:
/exlibris/primo/p2_1/ng/primo/home/profile/publish/publish/production/conf/enrichPlugin/custom_enrich_tasks_list.xml
<?xml version = "1.0" encoding = "UTF-8"?>
<tasksConfiguration>
<tasksPackage>nz.govt.natlib.find.discover.enrichment</tasksPackage>
<tasksList>
<taskName>DiscoverCategory</taskName>
</tasksList>
</tasksConfiguration>
4. Define your enrichment in Back Office - copy an existing enrichment, edit it and change to "User Plugin Enrichment" (parameter box seems to be unused): Primo Home > Ongoing Configuration Wizards > Pipe Configuration Wizard > Enrichment Sets Configuration
5. Restart back office
6. Make/edit pipe and add DiscoverCategory enrichment
DiscoverCategory.java