Class ImportEntryProcessor.ImportEntryProcessRunnable
- java.lang.Object
-
- org.openbravo.service.importprocess.ImportEntryProcessor.ImportEntryProcessRunnable
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
VariantChDescUpdateProcessor.VariantChDescUpdateRunnable
- Enclosing class:
- ImportEntryProcessor
public abstract static class ImportEntryProcessor.ImportEntryProcessRunnable extends Object implements Runnable
The default implementation of the ImportEntryProcessRunnable. It performs the following actions:- able to get new
ImportEntry
records while the processing of otherImportEntry
records happens. - processes the ImportEntry, creates a new OBContext based on the user data of the
ImportEntry
- makes sure that there is a
VariablesSecureApp
in theRequestContext
. - OBContexts are temporary cached in a
WeakHashMap
- the process checks the
ImportEntry
status just before it is processed, it also prevents the sameImportEntry
to be processed twice by one thread - each
ImportEntry
is processed in its own connection and transaction. Note that the class delegates into the implementing subclass the ability of handling the commit/rollback of the transaction. But in order to prevent possible connection leaks, this class closes all the opened connections (if any) before ending. - the process sets admin mode, before calling the subclass
- an error which ends up in the main loop here is stored in the
ImportEntry
in the errorInfo property - subclasses implement the
processEntry(ImportEntry)
method.
- Author:
- mtaal
-
-
Constructor Summary
Constructors Constructor Description ImportEntryProcessRunnable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
cleanUpThreadForNextCycle()
protected void
doRunCycle()
protected Queue<org.openbravo.service.importprocess.ImportEntryProcessor.ImportEntryProcessRunnable.QueuedEntry>
getImportEntryQueue()
String
getKey()
protected String
getProcessIdForAudit()
Returns the identifier to be set for this process for audit trail: It can be, at most, 32 characters length If anAD_Message
entry with the same value exists, it will be used in UIprotected abstract void
processEntry(ImportEntry importEntry)
Must be implemented by a subclass.void
run()
void
setImportEntryManager(ImportEntryManager importEntryManager)
void
setImportEntryProcessor(ImportEntryProcessor importEntryProcessor)
void
setKey(String key)
protected void
setOBContext(org.openbravo.service.importprocess.ImportEntryProcessor.ImportEntryProcessRunnable.QueuedEntry queuedEntry)
protected void
setVariablesSecureApp(OBContext obContext)
String
toString()
-
-
-
Method Detail
-
doRunCycle
protected void doRunCycle()
-
getImportEntryQueue
protected Queue<org.openbravo.service.importprocess.ImportEntryProcessor.ImportEntryProcessRunnable.QueuedEntry> getImportEntryQueue()
-
setOBContext
protected void setOBContext(org.openbravo.service.importprocess.ImportEntryProcessor.ImportEntryProcessRunnable.QueuedEntry queuedEntry)
-
getProcessIdForAudit
protected String getProcessIdForAudit()
Returns the identifier to be set for this process for audit trail:- It can be, at most, 32 characters length
- If an
AD_Message
entry with the same value exists, it will be used in UI
-
setVariablesSecureApp
protected void setVariablesSecureApp(OBContext obContext)
-
cleanUpThreadForNextCycle
protected void cleanUpThreadForNextCycle()
-
processEntry
protected abstract void processEntry(ImportEntry importEntry) throws Exception
Must be implemented by a subclass. Note subclass implementation must perform a commit and close (OBDal.commitAndClose()
) at the end of the processEntry, before it returns. So that at the end of processing there should not an active Session anymore the implementor is responsible for correctly closing any open session/transaction. A warning will be logged if this is somehow forgotten.- Throws:
Exception
-
setImportEntryManager
public void setImportEntryManager(ImportEntryManager importEntryManager)
-
setKey
public void setKey(String key)
-
setImportEntryProcessor
public void setImportEntryProcessor(ImportEntryProcessor importEntryProcessor)
-
getKey
public String getKey()
-
-