DLESE Tools
v1.2

org.dlese.dpc.index.writer
Class ADNFileIndexingWriter

java.lang.Object
  extended byorg.dlese.dpc.index.writer.FileIndexingServiceWriter
      extended byorg.dlese.dpc.index.writer.XMLFileIndexingWriter
          extended byorg.dlese.dpc.index.writer.ItemFileIndexingWriter
              extended byorg.dlese.dpc.index.writer.ADNFileIndexingWriter
All Implemented Interfaces:
DocWriter

public class ADNFileIndexingWriter
extends ItemFileIndexingWriter

Creates a Lucene Document from an ADN-item metadata source file.

The Lucene Document fields that are created by this class are (in addition the the ones listed for FileIndexingServiceWriter):

doctype - Set to 'adn'. Stored. Note: the actual indexing of this field happens in the superclass FileIndexingServiceWriter.
additional fields - A number of additional fields are defined. See the Java code for method addFrameworkFields(Document, Document) for details.

Author:
John Weatherley, Ryan Deardorff

Field Summary
 
Fields inherited from class org.dlese.dpc.index.writer.XMLFileIndexingWriter
recordDataService, vocab
 
Constructor Summary
ADNFileIndexingWriter(String collection, RecordDataService recordDataService)
          Create a ADNFileIndexingWriter that indexes the given collection in field collection.
ADNFileIndexingWriter(String collection, RecordDataService recordDataService, boolean singleRecord)
          Constructor for the ADNFileIndexingWriter object
 
Method Summary
protected  void addFrameworkFields(Document newDoc, Document existingDoc)
          Adds custom fields to the index that are unique to this framework.
protected  void destroy()
          Release map resources for GC after processing.
protected  String getAccessionStatus()
          Returns the accession status of this record, for example 'accessioned'.
 String getCollection()
          Returns unique collection keys for the item being indexed, separated by spaces.
protected  String[] getContentStandards()
          Gets the contentStandards attribute of the ADNFileIndexingWriter object
protected  String getCreator()
          Returns the items creator's full name.
protected  String getCreatorLastName()
          Returns the items creator's last name.
protected  String getDescription()
          Gets the description attribute of the ADNFileIndexingWriter object
 String getDocType()
          Gets the docType attribute of the ADNFileIndexingWriter, which is 'adn.'
protected  String[] getGradeRange()
          Gets the gradeRange attribute of the ADNFileIndexingWriter object
protected  String getId()
          Gets the id(s) for this item, separated by spaces.
protected  String getKeywords()
          Returns the items keywords.
 String getReaderClass()
          Gets the name of the concrete DocReader class that is used to read this type of Document, which is "ItemDocReader".
protected  String[] getResourceTypes()
          Gets the resourceTypes attribute of the ADNFileIndexingWriter object
protected  String[] getSubjects()
          Gets the subjects attribute of the ADNFileIndexingWriter object
protected  String getTermStringFromStringArray(String[] vals)
          Gets the appropriate terms from a string array of metadata fields.
protected  String getTitle()
          Gets the title attribute of the ADNFileIndexingWriter object
protected  String getUrl()
          Gets the url attribute of the ADNFileIndexingWriter object
protected  String getValidationReport()
          Gets a report detailing any errors found in the validation of the data, or null if no error was found.
 void init(File source, Document existingDoc)
          Initialize the XML map prior to processing
 
Methods inherited from class org.dlese.dpc.index.writer.ItemFileIndexingWriter
addFields, getDeletedDoc
 
Methods inherited from class org.dlese.dpc.index.writer.XMLFileIndexingWriter
addCustomFields, getFieldContent, getFieldContent, getFieldName, getOaiModtime
 
Methods inherited from class org.dlese.dpc.index.writer.FileIndexingServiceWriter
abortIndexing, addToAdminDefaultField, addToDefaultField, create, getExistingDoc, getFileIndexingService, getSourceDir, getSourceFile, isValidationEnabled, prtln, prtlnErr, setDebug, setDefaultFieldName, setFileIndexingService, setValidationEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ADNFileIndexingWriter

public ADNFileIndexingWriter(String collection,
                             RecordDataService recordDataService)
Create a ADNFileIndexingWriter that indexes the given collection in field collection. The RecordDataService is used to get indexible data such as recordStatus, annotations, vocab ID mappings and associated IDs.

Parameters:
collection - A name for the collection
recordDataService - The recordData service used with writer.

ADNFileIndexingWriter

public ADNFileIndexingWriter(String collection,
                             RecordDataService recordDataService,
                             boolean singleRecord)
Constructor for the ADNFileIndexingWriter object

Parameters:
collection - DESCRIPTION
recordDataService - DESCRIPTION
singleRecord - DESCRIPTION
Method Detail

getCollection

public String getCollection()
Returns unique collection keys for the item being indexed, separated by spaces. For example 'dcc,' 'comet' or 'dwel'.

Specified by:
getCollection in class XMLFileIndexingWriter
Returns:
The collection keys

getAccessionStatus

protected String getAccessionStatus()
                             throws Exception
Returns the accession status of this record, for example 'accessioned'. The String is tokenized, stored and indexed under the field key 'accessionstatus'.

Specified by:
getAccessionStatus in class ItemFileIndexingWriter
Returns:
The accession status.
Throws:
Exception - This method should throw and Exception with appropriate error message if an error occurs.

init

public void init(File source,
                 Document existingDoc)
          throws Exception
Initialize the XML map prior to processing

Specified by:
init in class ItemFileIndexingWriter
Parameters:
source - The source file being indexed.
existingDoc - A Document that previously existed in the index for this item, if present
Throws:
Exception - Thrown if error reading the XML map

destroy

protected void destroy()
Release map resources for GC after processing.

Specified by:
destroy in class ItemFileIndexingWriter

getReaderClass

public String getReaderClass()
Gets the name of the concrete DocReader class that is used to read this type of Document, which is "ItemDocReader".

Specified by:
getReaderClass in interface DocWriter
Specified by:
getReaderClass in class ItemFileIndexingWriter
Returns:
The String "ItemDocReader".

getValidationReport

protected String getValidationReport()
                              throws Exception
Gets a report detailing any errors found in the validation of the data, or null if no error was found.

Specified by:
getValidationReport in class ItemFileIndexingWriter
Returns:
Null if no data validation errors were found, otherwise a String that details the nature of the error.
Throws:
Exception - If error in performing the validation.

getDocType

public final String getDocType()
Gets the docType attribute of the ADNFileIndexingWriter, which is 'adn.'

Specified by:
getDocType in interface DocWriter
Specified by:
getDocType in class ItemFileIndexingWriter
Returns:
The docType, which is 'adn.'

getId

protected final String getId()
                      throws Exception
Gets the id(s) for this item, separated by spaces. If multiple IDs exists, the first one is the primary.

Specified by:
getId in class XMLFileIndexingWriter
Returns:
The id value
Throws:
Exception - If an error occurs

getTitle

protected final String getTitle()
                         throws Exception
Gets the title attribute of the ADNFileIndexingWriter object

Specified by:
getTitle in class ItemFileIndexingWriter
Returns:
The title value
Throws:
Exception - If an error occurs

getDescription

protected final String getDescription()
                               throws Exception
Gets the description attribute of the ADNFileIndexingWriter object

Specified by:
getDescription in class ItemFileIndexingWriter
Returns:
The description value
Throws:
Exception - If an error occurs

getUrl

protected final String getUrl()
                       throws Exception
Gets the url attribute of the ADNFileIndexingWriter object

Specified by:
getUrl in class ItemFileIndexingWriter
Returns:
The url value
Throws:
Exception - If an error occurs

getKeywords

protected String getKeywords()
                      throws Exception
Returns the items keywords. An empty String or null is acceptable. The String is tokenized, stored and indexed under the field key 'keywords' and is also indexed in the 'default' field.

Specified by:
getKeywords in class ItemFileIndexingWriter
Returns:
The keywords String
Throws:
Exception - This method should throw and Exception with appropriate error message if an error occurs.

getCreatorLastName

protected String getCreatorLastName()
                             throws Exception
Returns the items creator's last name. An empty String or null is acceptable. The String is tokenized, stored and indexed under the field the 'default' field only.

Specified by:
getCreatorLastName in class ItemFileIndexingWriter
Returns:
The creator's last name String
Throws:
Exception - This method should throw and Exception with appropriate error message if an error occurs.

getCreator

protected String getCreator()
                     throws Exception
Returns the items creator's full name. An empty String or null is acceptable. The String is tokenized, stored and indexed under the field key 'creator'.

Specified by:
getCreator in class ItemFileIndexingWriter
Returns:
Creator's full name
Throws:
Exception - This method should throw and Exception with appropriate error message if an error occurs.

addFrameworkFields

protected final void addFrameworkFields(Document newDoc,
                                        Document existingDoc)
                                 throws Exception
Adds custom fields to the index that are unique to this framework.

Specified by:
addFrameworkFields in class ItemFileIndexingWriter
Parameters:
newDoc - The feature to be added to the FrameworkFields attribute
existingDoc - The feature to be added to the FrameworkFields attribute
Throws:
Exception - If an error occurs

getGradeRange

protected String[] getGradeRange()
Gets the gradeRange attribute of the ADNFileIndexingWriter object

Returns:
The gradeRange value

getResourceTypes

protected String[] getResourceTypes()
Gets the resourceTypes attribute of the ADNFileIndexingWriter object

Returns:
The resourceTypes value

getContentStandards

protected String[] getContentStandards()
Gets the contentStandards attribute of the ADNFileIndexingWriter object

Returns:
The contentStandards value

getSubjects

protected String[] getSubjects()
Gets the subjects attribute of the ADNFileIndexingWriter object

Returns:
The subjects value

getTermStringFromStringArray

protected String getTermStringFromStringArray(String[] vals)
Gets the appropriate terms from a string array of metadata fields. Uses all terms found after the last colon ":" found in the string.

Parameters:
vals - Metadata fields that must be delemited by colons.
Returns:
The individual terms used for indexing.

DLESE Tools
v1.2