Package org.mycore.common.processing
Interface MCRProcessable
- All Superinterfaces:
MCRListenableProgressable
,MCRProgressable
- All Known Implementing Classes:
MCRAbstractProcessable
,MCRJobThread
,MCRProcessableSupplier
,MCRProcessableTask
,MCRUploadHandler
,MCRUploadHandlerIFS
Describes an object which can be processed. A processable has a
name, a user id, a status, a create-, start- and end time and is
MCRProgressable
.- Author:
- Matthas Eichner
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a newMCRProcessableStatusListener
to thisMCRProcessable
.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.default Object
getProperty
(String name) A shortcut for getProperties().get(name).default <T> T
getPropertyAs
(String name, Class<T> type) Returns the property for the given name.Time (instant) the process was started.The status of this process.Returns the id of the user who created this processable.default boolean
Returns true if this task was cancelled before it completed normally.default boolean
Returns true if this task was created but not started yet.default boolean
isDone()
Returns true if this processable completed.default boolean
isFailed()
Returns true if this task failed before it completed normally.default boolean
Returns true if this task is currently processing.default boolean
Returns true if this task was successful and completed normally.void
Removes aMCRProcessableStatusListener
from thisMCRProcessable
.default Duration
took()
Calculates the duration between starting and finishing the processable.Methods inherited from interface org.mycore.common.processing.MCRListenableProgressable
addProgressListener, removeProgressListener
Methods inherited from interface org.mycore.common.processing.MCRProgressable
getProgress, getProgressText
-
Method Details
-
getName
String getName()Returns a human readable name.- Returns:
- name of this process
-
getUserId
String getUserId()Returns the id of the user who created this processable.- Returns:
- the user id responsible for the processable
-
getStatus
MCRProcessableStatus getStatus()The status of this process.- Returns:
- the status
-
isCreated
default boolean isCreated()Returns true if this task was created but not started yet.- Returns:
- true if this task is just created.
-
isProcessing
default boolean isProcessing()Returns true if this task is currently processing.- Returns:
- true if this task is processing
-
isCanceled
default boolean isCanceled()Returns true if this task was cancelled before it completed normally.- Returns:
- true if this task is cancelled
-
isFailed
default boolean isFailed()Returns true if this task failed before it completed normally. One can assume thatgetError()
does not return null in such case.- Returns:
- true if the process failed
-
isSuccessful
default boolean isSuccessful()Returns true if this task was successful and completed normally.- Returns:
- true if this task was successful
-
isDone
default boolean isDone()Returns true if this processable completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.- Returns:
- true if this processable completed
-
getError
Throwable getError()Returns the error if the processable failed. This will return null if the status != failed.- Returns:
- the error occurred while processing
-
getStartTime
Instant getStartTime()Time (instant) the process was started. Returns null if the process was not started yet.- Returns:
- the time the process was started
-
getCreateTime
Instant getCreateTime()Time (instant) this processable was created.- Returns:
- the time the processable was created
-
getEndTime
Instant getEndTime()Time (instant) this processable finished. Either successfully, canceled or with an error. If the processable is not finished this will return null.- Returns:
- the time the processable finished
-
took
Calculates the duration between starting and finishing the processable.- Returns:
- the duration or null if the processable is not finished yet
-
getProperties
Returns a map of properties assigned to this processable.- Returns:
- the properties map
-
getProperty
A shortcut for getProperties().get(name).- Parameters:
name
- the name of the property- Returns:
- the property value or null
-
getPropertyAs
Returns the property for the given name. The property will be cast to the specified type. Be aware that a ClassCastException is thrown if the type does not match.- Parameters:
name
- name of propertytype
- object type of the property- Returns:
- the property value or null
-
addStatusListener
Adds a newMCRProcessableStatusListener
to thisMCRProcessable
.- Parameters:
listener
- the listener to add
-
removeStatusListener
Removes aMCRProcessableStatusListener
from thisMCRProcessable
.- Parameters:
listener
- the listener to remove
-