magoffin.matt.ma2.lucene
Class AbstractIndexResultCallback<T,PK extends java.io.Serializable>

java.lang.Object
  extended by magoffin.matt.ma2.lucene.AbstractIndexResultCallback<T,PK>
Type Parameters:
T - the domain object type
PK - the primary key type
All Implemented Interfaces:
magoffin.matt.dao.BatchableDao.BatchCallback<T>, magoffin.matt.lucene.IndexResults

public abstract class AbstractIndexResultCallback<T,PK extends java.io.Serializable>
extends java.lang.Object
implements magoffin.matt.lucene.IndexResults, magoffin.matt.dao.BatchableDao.BatchCallback<T>

Abstract implementation that combines IndexResults and BatchableDao.BatchCallback.

Version:
$Revision: 176 $ $Date: 2008-12-28 14:33:18 +1300 (Sun, 28 Dec 2008) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Field Summary
static int DEFAULT_ERROR_PERCENT_MAX_FRACTION_DIGITS
          Default number of error percent fraction digits.
protected  org.apache.log4j.Logger log
          A class logger.
 
Constructor Summary
AbstractIndexResultCallback(org.springframework.context.MessageSource messages)
          Construct.
 
Method Summary
protected abstract  magoffin.matt.dao.BatchableDao.BatchCallbackResult doHandle(T domainObject)
          Handle the domain object callback.
protected  java.util.Map<PK,java.lang.String> getErrorMap()
          Get the map of errors.
 java.util.Map<? extends java.io.Serializable,java.lang.String> getErrors()
           
protected  magoffin.matt.dao.BatchableDao.BatchCallbackResult getExceptionResult(T domainObject, java.lang.Exception e)
          Get the result for when an exception occurs.
protected abstract  java.lang.String getIndexErrorMessage(T domainObject, java.lang.Exception e)
          Get an error message for an index operation.
protected  org.springframework.context.MessageSource getMessages()
           
 int getNumIndexed()
           
 int getNumProcessed()
           
protected abstract  PK getPrimaryKey(T domainObject)
          Get the primary key for a domain object.
protected  org.apache.lucene.index.IndexWriter getWriter()
           
 magoffin.matt.dao.BatchableDao.BatchCallbackResult handle(T domainObject)
           
 boolean isFinished()
           
protected  void setFinished(boolean finished)
           
protected  void setMessages(org.springframework.context.MessageSource messages)
           
protected  void setWriter(org.apache.lucene.index.IndexWriter writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ERROR_PERCENT_MAX_FRACTION_DIGITS

public static final int DEFAULT_ERROR_PERCENT_MAX_FRACTION_DIGITS
Default number of error percent fraction digits.

See Also:
Constant Field Values

log

protected final org.apache.log4j.Logger log
A class logger.

Constructor Detail

AbstractIndexResultCallback

public AbstractIndexResultCallback(org.springframework.context.MessageSource messages)
Construct.

Parameters:
messages - a MessageSource
Method Detail

handle

public final magoffin.matt.dao.BatchableDao.BatchCallbackResult handle(T domainObject)
Specified by:
handle in interface magoffin.matt.dao.BatchableDao.BatchCallback<T>

getExceptionResult

protected magoffin.matt.dao.BatchableDao.BatchCallbackResult getExceptionResult(T domainObject,
                                                                                java.lang.Exception e)
Get the result for when an exception occurs.

Parameters:
domainObject - the domain object that caused the error
e - the exception
Returns:
the result

getIndexErrorMessage

protected abstract java.lang.String getIndexErrorMessage(T domainObject,
                                                         java.lang.Exception e)
Get an error message for an index operation.

Parameters:
domainObject - the domain object that caused the error
e - the exception
Returns:
the message

getPrimaryKey

protected abstract PK getPrimaryKey(T domainObject)
Get the primary key for a domain object.

Parameters:
domainObject - the domain object
Returns:
the primary key

doHandle

protected abstract magoffin.matt.dao.BatchableDao.BatchCallbackResult doHandle(T domainObject)
                                                                        throws java.lang.Exception
Handle the domain object callback.

Parameters:
domainObject - the domain object
Returns:
the callback results
Throws:
java.lang.Exception - if an error occurs

getErrors

public java.util.Map<? extends java.io.Serializable,java.lang.String> getErrors()
Specified by:
getErrors in interface magoffin.matt.lucene.IndexResults

getNumIndexed

public int getNumIndexed()
Specified by:
getNumIndexed in interface magoffin.matt.lucene.IndexResults

getNumProcessed

public int getNumProcessed()
Specified by:
getNumProcessed in interface magoffin.matt.lucene.IndexResults

isFinished

public boolean isFinished()
Specified by:
isFinished in interface magoffin.matt.lucene.IndexResults

setFinished

protected void setFinished(boolean finished)
Parameters:
finished - the finished to set

getErrorMap

protected java.util.Map<PK,java.lang.String> getErrorMap()
Get the map of errors.

Returns:
error map

getMessages

protected org.springframework.context.MessageSource getMessages()
Returns:
the messages

getWriter

protected org.apache.lucene.index.IndexWriter getWriter()
Returns:
the writer

setMessages

protected void setMessages(org.springframework.context.MessageSource messages)
Parameters:
messages - the messages to set

setWriter

protected void setWriter(org.apache.lucene.index.IndexWriter writer)
Parameters:
writer - the writer to set