DLESE Tools
v1.6.0

org.dlese.dpc.index.writer
Class NewsOppsFileIndexingWriter

java.lang.Object
  extended by org.dlese.dpc.index.writer.FileIndexingServiceWriter
      extended by org.dlese.dpc.index.writer.XMLFileIndexingWriter
          extended by org.dlese.dpc.index.writer.NewsOppsFileIndexingWriter
All Implemented Interfaces:
DocWriter

public class NewsOppsFileIndexingWriter
extends XMLFileIndexingWriter

Used to write a Lucene Document for a DLESE news-opps XML record. The reader for this type of Document is NewsOppsDocReader.

Author:
John Weatherley
See Also:
XMLDocReader, RecordDataService, FileIndexingServiceWriter

Field Summary
static String FIELD_NS
          The News Opps NS
 
Constructor Summary
NewsOppsFileIndexingWriter()
          Create a NewsOppsFileIndexingWriter.
 
Method Summary
protected  String[] _getIds()
          Gets the ID of this collection record.
protected  void addFields(org.apache.lucene.document.Document newDoc, org.apache.lucene.document.Document existingDoc, File sourceFile)
          Adds fields to the index that are part of the news-opps Document.
protected  void destroy()
          This method is called at the conclusion of processing and may be used for tear-down.
 String getDescription()
          Return a description for the document being indexed, or null if none applies.
 String getDocType()
          Gets the docType attribute of the NewsOppsFileIndexingWriter, which is 'news_opps.'
 String getReaderClass()
          Gets the name of the concrete DocReader class that is used to read this type of Document, which is "NewsOppsDocReader".
 String getTitle()
          Return a title for the document being indexed, or null if none applies.
 String[] getUrls()
          Return the URL(s) to the resource being indexed, or null if none apply.
protected  String getValidationReport()
          Gets a report detailing any errors found in the XML validation of the news-opps record, or null if no error was found.
protected  Date getWhatsNewDate()
          Returns the date used to determine "What's new" in the library, which is the post date.
protected  String getWhatsNewType()
          Returns 'newsopps'.
 boolean indexFullContentInDefaultAndStems()
          Default and stems fields handled here, so do not index full content.
 void init(File source, org.apache.lucene.document.Document existingDoc)
          Nothing needed.
 
Methods inherited from class org.dlese.dpc.index.writer.XMLFileIndexingWriter
addCustomFields, getBoundingBox, getCollections, getDeletedDoc, getDocGroup, getDom4jDoc, getFieldContent, getFieldContent, getFieldName, getIds, getIndex, getMyAnnoResultDocs, getMyCollectionDoc, getOaiModtime, getPrimaryId, getRecordDataService, getRelatedIds, getRelatedIdsMap, getRelatedUrls, getRelatedUrlsMap, getTermStringFromStringArray, getXmlIndexer, getXmlIndexerFieldsConfig
 
Methods inherited from class org.dlese.dpc.index.writer.FileIndexingServiceWriter
abortIndexing, addDocToRemove, addToAdminDefaultField, addToDefaultField, create, getConfigAttributes, getDocsource, getFileContent, getFileIndexingPlugin, getFileIndexingService, getLuceneDoc, getPreviousRecordDoc, getSessionAttributes, getSourceDir, getSourceFile, isMakingDeletedDoc, isValidationEnabled, prtln, prtlnErr, setConfigAttributes, setDebug, setFileIndexingPlugin, setFileIndexingService, setIsMakingDeletedDoc, setValidationEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIELD_NS

public static final String FIELD_NS
The News Opps NS

See Also:
Constant Field Values
Constructor Detail

NewsOppsFileIndexingWriter

public NewsOppsFileIndexingWriter()
Create a NewsOppsFileIndexingWriter.

Method Detail

_getIds

protected String[] _getIds()
                    throws Exception
Gets the ID of this collection record.

Specified by:
_getIds in class XMLFileIndexingWriter
Returns:
The ID
Throws:
Exception - If error

getUrls

public String[] getUrls()
                 throws Exception
Description copied from class: XMLFileIndexingWriter
Return the URL(s) to the resource being indexed, or null if none apply. If more than one URL references the resource, the first one is the primary. The URL Strings are tokenized and indexed under the field key 'uri' and is also indexed in the 'default' field. It is also stored in the index untokenized under the field key 'url.'

Specified by:
getUrls in class XMLFileIndexingWriter
Returns:
The url String(s)
Throws:
Exception - This method should throw and Exception with appropriate error message if an error occurs.

getDescription

public String getDescription()
                      throws Exception
Description copied from class: XMLFileIndexingWriter
Return a description for the document being indexed, or null if none applies. The String is tokenized, stored and indexed under the field key 'description' and is also indexed in the 'default' field.

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

getTitle

public String getTitle()
                throws Exception
Description copied from class: XMLFileIndexingWriter
Return a title for the document being indexed, or null if none applies. The String is tokenized, stored and indexed under the field key 'title' and is also indexed in the 'default' field.

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

getDocType

public String getDocType()
Gets the docType attribute of the NewsOppsFileIndexingWriter, which is 'news_opps.'

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

getReaderClass

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

Specified by:
getReaderClass in interface DocWriter
Specified by:
getReaderClass in class FileIndexingServiceWriter
Returns:
The String "org.dlese.dpc.index.reader.NewsOppsDocReader".

getWhatsNewDate

protected Date getWhatsNewDate()
                        throws Exception
Returns the date used to determine "What's new" in the library, which is the post date.

Specified by:
getWhatsNewDate in class XMLFileIndexingWriter
Returns:
The what's new date for the item
Throws:
Exception - This method should throw and Exception with appropriate error message if an error occurs.

getWhatsNewType

protected String getWhatsNewType()
Returns 'newsopps'.

Specified by:
getWhatsNewType in class XMLFileIndexingWriter
Returns:
The string 'newsopps'.

init

public void init(File source,
                 org.apache.lucene.document.Document existingDoc)
          throws Exception
Nothing needed.

Specified by:
init in class XMLFileIndexingWriter
Parameters:
source - The source file being indexed
existingDoc - An existing Document that currently resides in the index for the given resource, or null if none was previously present
Throws:
Exception - If an error occured during set-up.

destroy

protected void destroy()
This method is called at the conclusion of processing and may be used for tear-down.

Specified by:
destroy in class FileIndexingServiceWriter

getValidationReport

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

Overrides:
getValidationReport in class FileIndexingServiceWriter
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.

indexFullContentInDefaultAndStems

public boolean indexFullContentInDefaultAndStems()
Default and stems fields handled here, so do not index full content.

Specified by:
indexFullContentInDefaultAndStems in class XMLFileIndexingWriter
Returns:
False

addFields

protected final void addFields(org.apache.lucene.document.Document newDoc,
                               org.apache.lucene.document.Document existingDoc,
                               File sourceFile)
                        throws Exception
Adds fields to the index that are part of the news-opps Document.

Specified by:
addFields in class XMLFileIndexingWriter
Parameters:
newDoc - The new Document that is being created for this resource
existingDoc - An existing Document that currently resides in the index for the given resource, or null if none was previously present
sourceFile - The sourceFile that is being indexed.
Throws:
Exception - If an error occurs

DLESE Tools
v1.6.0