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

public class MCRAbstractProcessable extends MCRAbstractProgressable implements MCRProcessable
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 Details

  • Constructor Details

    • MCRAbstractProcessable

      public MCRAbstractProcessable()
  • Method Details

    • setName

      public void setName(String name)
      Sets the name for this process.
      Parameters:
      name - human readable name
    • getName

      public String getName()
      Description copied from interface: MCRProcessable
      Returns a human readable name.
      Specified by:
      getName in interface MCRProcessable
      Returns:
      name of this process
    • setUserId

      public void setUserId(String userId)
      Sets the user identifier responsible for this processable.
      Parameters:
      userId - the user id
    • getUserId

      public String getUserId()
      Description copied from interface: MCRProcessable
      Returns the id of the user who created this processable.
      Specified by:
      getUserId in interface MCRProcessable
      Returns:
      the user id responsible for the processable
    • getError

      public Throwable 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 interface MCRProcessable
      Returns:
      the error occurred while processing
    • setError

      public void setError(Throwable error)
      Sets the internal processable error. This will set the status to failed.
      Parameters:
      error - the error
    • setStatus

      public void setStatus(MCRProcessableStatus status)
      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

      public MCRProcessableStatus getStatus()
      Description copied from interface: MCRProcessable
      The status of this process.
      Specified by:
      getStatus in interface MCRProcessable
      Returns:
      the status
    • getStartTime

      public Instant 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 interface MCRProcessable
      Returns:
      the time the process was started
    • getCreateTime

      public Instant getCreateTime()
      Description copied from interface: MCRProcessable
      Time (instant) this processable was created.
      Specified by:
      getCreateTime in interface MCRProcessable
      Returns:
      the time the processable was created
    • getEndTime

      public Instant 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 interface MCRProcessable
      Returns:
      the time the processable finished
    • getProperties

      public Map<String,Object> getProperties()
      Description copied from interface: MCRProcessable
      Returns a map of properties assigned to this processable.
      Specified by:
      getProperties in interface MCRProcessable
      Returns:
      the properties map
    • addStatusListener

      public void addStatusListener(MCRProcessableStatusListener listener)
      Description copied from interface: MCRProcessable
      Specified by:
      addStatusListener in interface MCRProcessable
      Parameters:
      listener - the listener to add
    • removeStatusListener

      public void removeStatusListener(MCRProcessableStatusListener listener)
      Description copied from interface: MCRProcessable
      Specified by:
      removeStatusListener in interface MCRProcessable
      Parameters:
      listener - the listener to remove
    • fireStatusChanged

      protected void fireStatusChanged(MCRProcessableStatus oldStatus)