Class 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:
  • Field Details

  • Constructor Details

    • NewsOppsFileIndexingWriter

      public NewsOppsFileIndexingWriter()
      Create a NewsOppsFileIndexingWriter.
  • Method Details

    • _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