variablerecordsets
Class AuthorDetailsRecordsetHandler

java.lang.Object
  extended by com.wrq.vhi.script.api.RecordSetEventHandler
      extended by variablerecordsets.AuthorDetailsRecordsetHandler
All Implemented Interfaces:
com.wrq.vhi.script.api.EventHandler

public class AuthorDetailsRecordsetHandler
extends com.wrq.vhi.script.api.RecordSetEventHandler

Parse author search results for the Yale Orbis Library catalog.

Each library record contains an author name, followed by one or more titles of works by that author. A publication date may be present, using the syntax "<1989>": that is a four-digit year surrounded by angle brackets.

Some author records (denoted by an "*" as the first title character) simply redirect a search for an author's works to a different name.

The work of parsing is divided between several events:

  1. The parseScreen(com.wrq.vhi.script.api.ParseScreenEvent) event handles dividing each screen into a set of records, one record per title.
  2. The parseRecord(com.wrq.vhi.script.api.ParseRecordEvent) event handles binding each title and date to the author name.
  3. The getRecordType(com.wrq.vhi.script.api.GetRecordTypeEvent) event removes records that do not contain titles (that is, the redirect records).
  4. The applyFilter(com.wrq.vhi.script.api.ApplyFilterEvent) event does any post-fetch filtering required based upon the publication date.

The readField event handler is used to remove extra blanks included in multi-line titles.


Field Summary
static int applyFilterTimeout
          Timeout in seconds for the applyFilter() event.
static java.lang.String description
           
static int getCurrentHostRecordTimeout
          Timeout in seconds for the getCurrentHostRecord() event.
static int getRecordTypeTimeout
          Timeout in seconds for the getRecordType() event.
static int insertRecordTimeout
          Timeout in seconds for the insertRecord() event.
static int isTerminatedTimeout
          Timeout in seconds for the isTerminated() event.
static int parseRecordTimeout
          Timeout in seconds for the parseRecord() event.
static int parseScreenTimeout
          Timeout in seconds for the parseScreen() event.
static int updateRecordTimeout
          Timeout in seconds for the updateRecord() event.
 
Fields inherited from interface com.wrq.vhi.script.api.EventHandler
DEFAULT_TIMEOUT
 
Constructor Summary
AuthorDetailsRecordsetHandler()
           
 
Method Summary
 boolean applyFilter(com.wrq.vhi.script.api.ApplyFilterEvent event)
          Called to apply a filter to a record.
 int getRecordType(com.wrq.vhi.script.api.GetRecordTypeEvent event)
          Called to identify the type of record.
 java.util.Map parseRecord(com.wrq.vhi.script.api.ParseRecordEvent event)
          Called to parse a record into a set of fields.
 java.util.List parseScreen(com.wrq.vhi.script.api.ParseScreenEvent event)
          Called to parse the current host screen into a set of records.
 
Methods inherited from class com.wrq.vhi.script.api.RecordSetEventHandler
getCurrentHostRecord, insertRecord, isTerminated, updateRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

public static final java.lang.String description
See Also:
Constant Field Values

parseScreenTimeout

public static final int parseScreenTimeout
Timeout in seconds for the parseScreen() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

parseRecordTimeout

public static final int parseRecordTimeout
Timeout in seconds for the parseRecord() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

isTerminatedTimeout

public static final int isTerminatedTimeout
Timeout in seconds for the isTerminated() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

getRecordTypeTimeout

public static final int getRecordTypeTimeout
Timeout in seconds for the getRecordType() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

applyFilterTimeout

public static final int applyFilterTimeout
Timeout in seconds for the applyFilter() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

getCurrentHostRecordTimeout

public static final int getCurrentHostRecordTimeout
Timeout in seconds for the getCurrentHostRecord() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

updateRecordTimeout

public static final int updateRecordTimeout
Timeout in seconds for the updateRecord() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values

insertRecordTimeout

public static final int insertRecordTimeout
Timeout in seconds for the insertRecord() event. A value of DEFAULT_TIMEOUT means the event will use the model defined default event timeout.

See Also:
Constant Field Values
Constructor Detail

AuthorDetailsRecordsetHandler

public AuthorDetailsRecordsetHandler()
Method Detail

parseScreen

public java.util.List parseScreen(com.wrq.vhi.script.api.ParseScreenEvent event)
                           throws com.wrq.apptrieve.agent.ApptrieveException
Called to parse the current host screen into a set of records.

The strategy here is to define each record as starting with the author and ending with the latest book. This means for authors with multiple books, we just define the prior books as part of this record and then ignore the extra data later when parsing the fields within each record (parseRecord(com.wrq.vhi.script.api.ParseRecordEvent)).

Overrides:
parseScreen in class com.wrq.vhi.script.api.RecordSetEventHandler
Parameters:
event - the event instance
Returns:
A list of RecordLocation objects
Throws:
com.wrq.apptrieve.agent.ApptrieveException

parseRecord

public java.util.Map parseRecord(com.wrq.vhi.script.api.ParseRecordEvent event)
                          throws com.wrq.apptrieve.agent.ApptrieveException
Called to parse a record into a set of fields.

Each record passed to this method begins with an author name on the first line. Following that is a set of zero or more book titles. Following each book title is a publication date with the form "<2004>".

This event handler builds a single record by locating the author's first and last names, the last book title in the record, and the publication date (if any) for the last title.

Overrides:
parseRecord in class com.wrq.vhi.script.api.RecordSetEventHandler
Parameters:
event - the event instance
Returns:
A map of field names to FieldLocation objects
Throws:
com.wrq.apptrieve.agent.ApptrieveException

getRecordType

public int getRecordType(com.wrq.vhi.script.api.GetRecordTypeEvent event)
                  throws com.wrq.apptrieve.agent.ApptrieveException
Called to identify the type of record.

Records in which the title starts with an asterisk ("*") or for which the title is zero-length are excluded from the result recordset. A record containing an asterisk does not contain a book, but simply redirects searches for that author to another author record.

Overrides:
getRecordType in class com.wrq.vhi.script.api.RecordSetEventHandler
Parameters:
event - the event instance
Returns:
one of the following constants:
  • GetRecordTypeEvent.NORMAL_RECORD
  • GetRecordTypeEvent.BLANK_RECORD
  • GetRecordTypeEvent.EXCLUDED_RECORD
  • GetRecordTypeEvent.EXCLUDED_BLANK_RECORD
Throws:
com.wrq.apptrieve.agent.ApptrieveException

applyFilter

public boolean applyFilter(com.wrq.vhi.script.api.ApplyFilterEvent event)
                    throws com.wrq.apptrieve.agent.ApptrieveException
Called to apply a filter to a record.

The filtering provided allows selecting records based upon comparing the publication date with a numeric literal using an "=", "<", or ">" comparison. And the field name (BookDate) must appear first. Records which satisfy the condition are included in the fetch results. Other books are not.

Notice that applying a filter requires first parsing the filter expression, and then performing the comparison on a single record. Each event handler defines its own filter syntax.

Overrides:
applyFilter in class com.wrq.vhi.script.api.RecordSetEventHandler
Parameters:
event - the event instance
Returns:
true if the record matches the filter, otherwise false
Throws:
com.wrq.apptrieve.agent.ApptrieveException