DLESE Tools
v1.6.0

org.dlese.dpc.schemedit.threadedservices
Class ThreadedService

java.lang.Object
  extended by org.dlese.dpc.schemedit.threadedservices.MonitoredTask
      extended by org.dlese.dpc.schemedit.threadedservices.ThreadedService
Direct Known Subclasses:
ExportingService, ValidatingService

public abstract class ThreadedService
extends MonitoredTask

Provides services over collections, such as Validation and Export, that run in their own thread. Also manages reports generated by the services.

Author:
ostwald

Nested Class Summary
 class ThreadedService.SortReports
          NOT YET DOCUMENTED
 
Field Summary
protected  SimpleDataStore dataStore
           
protected  DcsDataManager dcsDataManager
           
protected  DcsSetInfo dcsSetInfo
           
protected static boolean debug
           
protected  SimpleLuceneIndex index
           
protected  boolean indexOnValidation
           
protected  boolean isProcessing
           
protected static int NUM_STATUS_MESSAGES
           
protected  ServletContext servletContext
           
protected  SessionBean sessionBean
           
protected  String[] statuses
           
protected  boolean stopProcessing
           
protected  boolean validateFiles
           
 
Constructor Summary
ThreadedService(ServletContext servletContext, String threadedServiceDataDir)
          Constructor for the ThreadedService object
 
Method Summary
protected  void addStatusMessage(String msg)
          Adds a feature to the ValidatingMessage attribute of the ThreadedService object
protected  void archiveServiceReport(Report report)
          NOT YET DOCUMENTED
protected  String buildQuery(String collection, String[] statuses)
          Return a query string that will find records for the specified collection.
 void clearServiceReport()
          NOT YET DOCUMENTED
protected  void clearStatusMessages()
          Clear status messages
 Report getArchivedReport(String collection)
          Gets the archivedReport attribute of the ThreadedService object
 List getArchivedReports()
          Gets the archivedReports attribute of the ThreadedService object
static String getDateStamp()
          Return a string for the current time and date, sutiable for display in log files and output to standout:
protected  XMLDocReader getDocReader(String id)
          convience method to retrieve the docReader given a record id
protected  List getIdList(String collection, String[] statuses)
          Build a list of record ids from the results of a query for specified collection and statuses.
 boolean getIndexOnValidation()
          Gets the indexOnValidation attribute of the ThreadedService object
 boolean getIsProcessing()
          Gets the isProcessing attribute of the ThreadedService object
 Report getServiceReport()
          Gets the serviceReport attribute of the ThreadedService object
 String getSessionId()
          Gets the sessionId attribute of the ThreadedService object
static String getSimpleDateStamp()
          Return a string for the current time and date, sutiable for display in log files and output to standout:
 ArrayList getStatusMessages()
          Gets the statusMessages attribute of the ThreadedService object
protected  String list2delimitedString(List list, String delimiter)
          Creates a delimited string from the provided list
protected  void setDcsSetInfo(DcsSetInfo setInfo)
          Sets the dcsSetInfo attribute of the ThreadedService object
 void setIndexOnValidation(boolean indexOnValidation)
          Sets the indexOnValidation attribute of the ThreadedService object
 void setServiceReport(Report report)
          Sets the serviceReport attribute of the ThreadedService object
protected  void setStatuses(String[] statuses)
          Sets the statuses attribute of the ThreadedService object
 void setValidationEnabled(boolean validateFiles)
          Sets whether or not to validate the files being indexed.
 void stopProcessing()
          Halts a threaded service.
protected  void validate(XMLDocReader docReader, DcsDataRecord dcsDataRecord)
          NOT YET DOCUMENTED
protected  boolean validationIsStale(File sourceFile, XMLDocReader docReader)
          Test to see if record has been modified outside of DCS.
 
Methods inherited from class org.dlese.dpc.schemedit.threadedservices.MonitoredTask
getTaskProgress, setTaskProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected static boolean debug

NUM_STATUS_MESSAGES

protected static final int NUM_STATUS_MESSAGES
See Also:
Constant Field Values

dcsSetInfo

protected DcsSetInfo dcsSetInfo

sessionBean

protected SessionBean sessionBean

dataStore

protected SimpleDataStore dataStore

servletContext

protected ServletContext servletContext

index

protected SimpleLuceneIndex index

dcsDataManager

protected DcsDataManager dcsDataManager

validateFiles

protected boolean validateFiles

indexOnValidation

protected boolean indexOnValidation

statuses

protected String[] statuses

isProcessing

protected boolean isProcessing

stopProcessing

protected boolean stopProcessing
Constructor Detail

ThreadedService

public ThreadedService(ServletContext servletContext,
                       String threadedServiceDataDir)
Constructor for the ThreadedService object

Parameters:
servletContext - NOT YET DOCUMENTED
threadedServiceDataDir - NOT YET DOCUMENTED
Method Detail

getIsProcessing

public boolean getIsProcessing()
Gets the isProcessing attribute of the ThreadedService object

Specified by:
getIsProcessing in class MonitoredTask
Returns:
The isProcessing value

getIndexOnValidation

public boolean getIndexOnValidation()
Gets the indexOnValidation attribute of the ThreadedService object

Returns:
The indexOnValidation value

validate

protected void validate(XMLDocReader docReader,
                        DcsDataRecord dcsDataRecord)
NOT YET DOCUMENTED

Parameters:
docReader - NOT YET DOCUMENTED
dcsDataRecord - NOT YET DOCUMENTED

getDocReader

protected XMLDocReader getDocReader(String id)
convience method to retrieve the docReader given a record id

Parameters:
id - NOT YET DOCUMENTED
Returns:
The docReader value

validationIsStale

protected boolean validationIsStale(File sourceFile,
                                    XMLDocReader docReader)
Test to see if record has been modified outside of DCS.

Parameters:
sourceFile - file on disk
docReader - the docReader
Returns:
true if file has changed on disk

getIdList

protected List getIdList(String collection,
                         String[] statuses)
Build a list of record ids from the results of a query for specified collection and statuses. This list is used by validate and export to iterate over items to process. The reason we don't use the resultDocs obtained by querying the index is that, for long result lists, the index may change out from under the resultDocs, causing the resultDocs to be unreliable.

Parameters:
collection - NOT YET DOCUMENTED
statuses - NOT YET DOCUMENTED
Returns:
The idList value

list2delimitedString

protected String list2delimitedString(List list,
                                      String delimiter)
Creates a delimited string from the provided list

Parameters:
list - a list to be coverted
delimiter - delimiter used to separate items
Returns:
delmited string of list items

getSessionId

public String getSessionId()
Gets the sessionId attribute of the ThreadedService object

Returns:
The sessionId value

stopProcessing

public void stopProcessing()
Halts a threaded service.


buildQuery

protected String buildQuery(String collection,
                            String[] statuses)
Return a query string that will find records for the specified collection.

Parameters:
collection - collectionKey
statuses - statuses to be included in query
Returns:
a query string to find items in collection with specified statuses

clearStatusMessages

protected void clearStatusMessages()
Clear status messages


addStatusMessage

protected void addStatusMessage(String msg)
Adds a feature to the ValidatingMessage attribute of the ThreadedService object

Parameters:
msg - The feature to be added to the ValidatingMessage attribute

getStatusMessages

public ArrayList getStatusMessages()
Gets the statusMessages attribute of the ThreadedService object

Returns:
The statusMessages value

getServiceReport

public Report getServiceReport()
Gets the serviceReport attribute of the ThreadedService object

Returns:
The serviceReport value

setServiceReport

public void setServiceReport(Report report)
Sets the serviceReport attribute of the ThreadedService object

Parameters:
report - The new serviceReport value

setDcsSetInfo

protected void setDcsSetInfo(DcsSetInfo setInfo)
                      throws Exception
Sets the dcsSetInfo attribute of the ThreadedService object

Parameters:
setInfo - The new dcsSetInfo value
Throws:
Exception - NOT YET DOCUMENTED

setStatuses

protected void setStatuses(String[] statuses)
                    throws Exception
Sets the statuses attribute of the ThreadedService object

Parameters:
statuses - The new statuses value
Throws:
Exception - NOT YET DOCUMENTED

clearServiceReport

public void clearServiceReport()
NOT YET DOCUMENTED


archiveServiceReport

protected void archiveServiceReport(Report report)
NOT YET DOCUMENTED

Parameters:
report - NOT YET DOCUMENTED

getArchivedReport

public Report getArchivedReport(String collection)
Gets the archivedReport attribute of the ThreadedService object

Parameters:
collection - NOT YET DOCUMENTED
Returns:
The archivedReport value

getArchivedReports

public List getArchivedReports()
Gets the archivedReports attribute of the ThreadedService object

Returns:
The archivedReports value

setValidationEnabled

public void setValidationEnabled(boolean validateFiles)
Sets whether or not to validate the files being indexed. If set to true, the files will be validated, otherwise they will not. Default is true.

Parameters:
validateFiles - True to validate, else false.
See Also:
FileIndexingServiceWriter.getValidationReport()

setIndexOnValidation

public void setIndexOnValidation(boolean indexOnValidation)
Sets the indexOnValidation attribute of the ThreadedService object

Parameters:
indexOnValidation - The new indexOnValidation value

getSimpleDateStamp

public static String getSimpleDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout:

Returns:
The dateStamp value

getDateStamp

public static String getDateStamp()
Return a string for the current time and date, sutiable for display in log files and output to standout:

Returns:
The dateStamp value

DLESE Tools
v1.6.0