org.vivoweb.harvester.fetch
Class NIHFetch

java.lang.Object
  extended by org.vivoweb.harvester.fetch.NIHFetch
Direct Known Subclasses:
NLMJournalFetch, PubmedFetch, PubmedHTTPFetch

public abstract class NIHFetch
extends java.lang.Object

Shared code for modules for fetching NIH data using the SOAP or HTML Interface Based on the example code available at the NIH Website.

Author:
Stephen V. Williams (swilliams@ctrip.ufl.edu), Dale R. Scheppler (dscheppler@ctrip.ufl.edu), Christopher Haines (hainesc@ctrip.ufl.edu)

Constructor Summary
protected NIHFetch(ArgList argList, java.lang.String database, java.lang.String outputFile)
          Constructor
protected NIHFetch(ArgList argList, java.lang.String database, XMLRecordOutputStream os)
          Constructor
protected NIHFetch(java.lang.String emailAddress, java.io.OutputStream outStream, java.lang.String database)
          Constructor: Primary method for running an NIH Fetch.
protected NIHFetch(java.lang.String emailAddress, java.lang.String searchTerm, java.lang.String maxRecords, java.lang.String batchSize, java.io.OutputStream outStream, java.lang.String database)
          Constructor: Primary method for running an NIH Fetch.
 
Method Summary
 void execute()
          Executes the task
 void fetchRecords(java.lang.String[] env)
          Performs an NIH Fetch using a previously defined esearch environment and querykey
 void fetchRecords(java.lang.String[] env, java.lang.String retStart, java.lang.String numRecords)
          Performs an NIH Fetch using a previously defined esearch environment and querykey
protected abstract  void fetchRecords(java.lang.String WebEnv, java.lang.String QueryKey, java.lang.String retStart, java.lang.String numRecords)
          Performs an NIH Fetch using a previously defined esearch environment and querykey
protected  java.lang.String getBatchSize()
           
protected  java.lang.String getEmailAddress()
           
protected abstract  int getLatestRecord()
          Get latest NIH result
protected  java.lang.String getMaxRecords()
           
protected  java.io.OutputStreamWriter getOsWriter()
           
protected static ArgParser getParser(java.lang.String appName, java.lang.String database)
          Get the ArgParser for this task
protected  java.lang.String getSearchTerm()
           
protected  java.lang.String getToolName()
           
 java.lang.String[] runESearch(java.lang.String term)
          Performs an ESearch against NIH database and returns the query web environment/query key data
 java.lang.String[] runESearch(java.lang.String term, boolean logMessage)
          Performs an ESearch against NIH database and returns the query web environment/query key data
protected  void setBatchSize(java.lang.String batchSize)
           
protected  void setEmailAddress(java.lang.String emailAddress)
           
protected  void setMaxRecords(java.lang.String maxRecords)
           
protected  void setOsWriter(java.io.OutputStream os)
          Setter for xmlwriter
protected  void setSearchTerm(java.lang.String searchTerm)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NIHFetch

protected NIHFetch(java.lang.String emailAddress,
                   java.io.OutputStream outStream,
                   java.lang.String database)
Constructor: Primary method for running an NIH Fetch. The email address of the person responsible for this install of the program is required by NIH guidelines so the person can be contacted if there is a problem, such as sending too many queries too quickly.

Parameters:
emailAddress - contact email address of the person responsible for this install of the VIVO Harvester
outStream - output stream to write to
database - database name

NIHFetch

protected NIHFetch(java.lang.String emailAddress,
                   java.lang.String searchTerm,
                   java.lang.String maxRecords,
                   java.lang.String batchSize,
                   java.io.OutputStream outStream,
                   java.lang.String database)
Constructor: Primary method for running an NIH Fetch. The email address of the person responsible for this install of the program is required by NIH guidelines so the person can be contacted if there is a problem, such as sending too many queries too quickly.

Parameters:
emailAddress - contact email address of the person responsible for this install of the VIVO Harvester
searchTerm - query to run on data
maxRecords - maximum number of records to fetch
batchSize - number of records to fetch per batch
outStream - output stream to write to
database - database name

NIHFetch

protected NIHFetch(ArgList argList,
                   java.lang.String database,
                   XMLRecordOutputStream os)
            throws java.io.IOException
Constructor

Parameters:
argList - parsed argument list
database - database name
os - xml record output stream
Throws:
java.io.IOException - error creating task

NIHFetch

protected NIHFetch(ArgList argList,
                   java.lang.String database,
                   java.lang.String outputFile)
            throws java.io.IOException
Constructor

Parameters:
argList - parsed argument list
database - database name
outputFile - output file path
Throws:
java.io.IOException - error creating task
Method Detail

runESearch

public java.lang.String[] runESearch(java.lang.String term)
                              throws java.io.IOException
Performs an ESearch against NIH database and returns the query web environment/query key data

Parameters:
term - search term to run against database
Returns:
String[] = {WebEnv, QueryKey, number of records found, first record ID} from the search
Throws:
java.io.IOException - error processing search

runESearch

public java.lang.String[] runESearch(java.lang.String term,
                                     boolean logMessage)
                              throws java.io.IOException
Performs an ESearch against NIH database and returns the query web environment/query key data

Parameters:
term - search term to run against database
logMessage - do we write log messages
Returns:
String[] = {WebEnv, QueryKey, number of records found, first record ID} from the search
Throws:
java.io.IOException - error processing search

execute

public void execute()
             throws java.io.IOException
Executes the task

Throws:
java.io.IOException - error processing search

getLatestRecord

protected abstract int getLatestRecord()
                                throws java.io.IOException
Get latest NIH result

Returns:
latest record
Throws:
java.io.IOException - error processing search

fetchRecords

protected abstract void fetchRecords(java.lang.String WebEnv,
                                     java.lang.String QueryKey,
                                     java.lang.String retStart,
                                     java.lang.String numRecords)
                              throws java.io.IOException
Performs an NIH Fetch using a previously defined esearch environment and querykey

Parameters:
WebEnv - web environment from an ESearch
QueryKey - query key from an ESearch
retStart - record number (out of the total - eg: '1200' out of 15000 records), not the record ID
numRecords - The number of records to fetch
Throws:
java.io.IOException - error fetching records

fetchRecords

public void fetchRecords(java.lang.String[] env)
                  throws java.io.IOException
Performs an NIH Fetch using a previously defined esearch environment and querykey

Parameters:
env - {WebEnv, QueryKey, number of records found} - from ESearch
Throws:
java.io.IOException - error fetching records

fetchRecords

public void fetchRecords(java.lang.String[] env,
                         java.lang.String retStart,
                         java.lang.String numRecords)
                  throws java.io.IOException
Performs an NIH Fetch using a previously defined esearch environment and querykey

Parameters:
env - {WebEnv, QueryKey, number of records found} - from ESearch
retStart - record number (out of the total - eg: '1200' out of 15000 records), not the record ID
numRecords - The number of records to fetch
Throws:
java.io.IOException - error fetching records

setOsWriter

protected void setOsWriter(java.io.OutputStream os)
Setter for xmlwriter

Parameters:
os - outputstream to write to

getParser

protected static ArgParser getParser(java.lang.String appName,
                                     java.lang.String database)
Get the ArgParser for this task

Parameters:
appName - the application name
database - the database name
Returns:
the ArgParser

getEmailAddress

protected java.lang.String getEmailAddress()
Returns:
the emailAddress

setEmailAddress

protected void setEmailAddress(java.lang.String emailAddress)
Parameters:
emailAddress - the emailAddress to set

getOsWriter

protected java.io.OutputStreamWriter getOsWriter()
Returns:
the osWriter

getSearchTerm

protected java.lang.String getSearchTerm()
Returns:
the searchTerm

setSearchTerm

protected void setSearchTerm(java.lang.String searchTerm)
Parameters:
searchTerm - the searchTerm to set

getMaxRecords

protected java.lang.String getMaxRecords()
Returns:
the maxRecords

setMaxRecords

protected void setMaxRecords(java.lang.String maxRecords)
Parameters:
maxRecords - the maxRecords to set

getBatchSize

protected java.lang.String getBatchSize()
Returns:
the batchSize

setBatchSize

protected void setBatchSize(java.lang.String batchSize)
Parameters:
batchSize - the batchSize to set

getToolName

protected java.lang.String getToolName()
Returns:
the toolName