Package org.mycore.common.processing
Class MCRAbstractProcessable
java.lang.Object
org.mycore.common.processing.MCRAbstractProgressable
org.mycore.common.processing.MCRAbstractProcessable
- All Implemented Interfaces:
MCRListenableProgressable
,MCRProcessable
,MCRProgressable
- Direct Known Subclasses:
MCRJobThread
,MCRProcessableTask
,MCRUploadHandler
Can be used as base class for an
MCRProcessable
. This class offers some
convenient methods but does not handle everything.
If you extend this class make sure to call setStatus(MCRProcessableStatus)
,
MCRAbstractProgressable.setProgress(Integer)
and MCRAbstractProgressable.setProgressText(String)
. Otherwise the
event handlers are not fired.
- Author:
- Matthias Eichner
-
Field Summary
Modifier and TypeFieldDescriptionprotected Instant
protected Instant
protected Throwable
protected String
protected Instant
protected MCRProcessableStatus
protected final List<MCRProcessableStatusListener>
protected String
Fields inherited from class org.mycore.common.processing.MCRAbstractProgressable
progress, progressListener, progressText
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a newMCRProcessableStatusListener
to thisMCRProcessable
.protected void
fireStatusChanged
(MCRProcessableStatus oldStatus) Time (instant) this processable was created.Time (instant) this processable finished.getError()
Returns the error if the processable failed.getName()
Returns a human readable name.Returns a map of properties assigned to this processable.Time (instant) the process was started.The status of this process.Returns the id of the user who created this processable.void
Removes aMCRProcessableStatusListener
from thisMCRProcessable
.void
Sets the internal processable error.void
Sets the name for this process.void
setStatus
(MCRProcessableStatus status) Sets the new status.void
Sets the user identifier responsible for this processable.Methods inherited from class org.mycore.common.processing.MCRAbstractProgressable
addProgressListener, fireProgressChanged, fireProgressTextChanged, getProgress, getProgressText, removeProgressListener, setProgress, setProgressText
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.mycore.common.processing.MCRListenableProgressable
addProgressListener, removeProgressListener
Methods inherited from interface org.mycore.common.processing.MCRProcessable
getProperty, getPropertyAs, isCanceled, isCreated, isDone, isFailed, isProcessing, isSuccessful, took
Methods inherited from interface org.mycore.common.processing.MCRProgressable
getProgress, getProgressText
-
Field Details
-
name
-
userId
-
status
-
error
-
createTime
-
startTime
-
endTime
-
properties
-
statusListener
-
-
Constructor Details
-
MCRAbstractProcessable
public MCRAbstractProcessable()
-
-
Method Details
-
setName
Sets the name for this process.- Parameters:
name
- human readable name
-
getName
Description copied from interface:MCRProcessable
Returns a human readable name.- Specified by:
getName
in interfaceMCRProcessable
- Returns:
- name of this process
-
setUserId
Sets the user identifier responsible for this processable.- Parameters:
userId
- the user id
-
getUserId
Description copied from interface:MCRProcessable
Returns the id of the user who created this processable.- Specified by:
getUserId
in interfaceMCRProcessable
- Returns:
- the user id responsible for the processable
-
getError
Description copied from interface:MCRProcessable
Returns the error if the processable failed. This will return null if the status != failed.- Specified by:
getError
in interfaceMCRProcessable
- Returns:
- the error occurred while processing
-
setError
Sets the internal processable error. This will set the status to failed.- Parameters:
error
- the error
-
setStatus
Sets the new status. If the status is equal "processing" the startTime is set, if the status is equal "successful", "failed" or "canceled" the endTime is set. This will call the fireStatusChanged method.- Parameters:
status
- the new status
-
getStatus
Description copied from interface:MCRProcessable
The status of this process.- Specified by:
getStatus
in interfaceMCRProcessable
- Returns:
- the status
-
getStartTime
Description copied from interface:MCRProcessable
Time (instant) the process was started. Returns null if the process was not started yet.- Specified by:
getStartTime
in interfaceMCRProcessable
- Returns:
- the time the process was started
-
getCreateTime
Description copied from interface:MCRProcessable
Time (instant) this processable was created.- Specified by:
getCreateTime
in interfaceMCRProcessable
- Returns:
- the time the processable was created
-
getEndTime
Description copied from interface:MCRProcessable
Time (instant) this processable finished. Either successfully, canceled or with an error. If the processable is not finished this will return null.- Specified by:
getEndTime
in interfaceMCRProcessable
- Returns:
- the time the processable finished
-
getProperties
Description copied from interface:MCRProcessable
Returns a map of properties assigned to this processable.- Specified by:
getProperties
in interfaceMCRProcessable
- Returns:
- the properties map
-
addStatusListener
Description copied from interface:MCRProcessable
Adds a newMCRProcessableStatusListener
to thisMCRProcessable
.- Specified by:
addStatusListener
in interfaceMCRProcessable
- Parameters:
listener
- the listener to add
-
removeStatusListener
Description copied from interface:MCRProcessable
Removes aMCRProcessableStatusListener
from thisMCRProcessable
.- Specified by:
removeStatusListener
in interfaceMCRProcessable
- Parameters:
listener
- the listener to remove
-
fireStatusChanged
-