Class AbstractJackrabbitWorkflowStore

java.lang.Object
org.ametys.plugins.workflow.store.AbstractJackrabbitWorkflowStore
All Implemented Interfaces:
com.opensymphony.workflow.spi.WorkflowStore, AmetysWorkflowStore
Direct Known Subclasses:
AmetysObjectWorkflowStore, GenericWorkflowStore

public abstract class AbstractJackrabbitWorkflowStore extends Object implements AmetysWorkflowStore
Abstract workflow store for Jackrabbit
  • Field Details

  • Constructor Details

  • Method Details

    • _getSession

      Open a session to the _repository.
      Returns:
      the session opened.
      Throws:
      RepositoryException - if an error occurs.
    • _release

      protected void _release(Session session)
      Release a session.

      Default implementation calls logout on the session.

      Parameters:
      session - the session to release.
    • __toCalendar

      protected static Calendar __toCalendar(Date date)
      Convert a Date to a Calendar.
      Parameters:
      date - The date to convert.
      Returns:
      The date converted as a Calendar.
    • init

      public void init(Map props) throws com.opensymphony.workflow.StoreException
      Specified by:
      init in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • _createRootNode

      protected abstract void _createRootNode() throws RepositoryException
      Create the root node.
      Throws:
      RepositoryException - if an error occurs.
    • _getRootNode

      protected abstract Node _getRootNode(Session session) throws RepositoryException
      Get the workflow store root node
      Parameters:
      session - the session to use
      Returns:
      The workflow store root node
      Throws:
      RepositoryException - if an error occurs.
    • setEntryState

      public void setEntryState(long entryId, int state) throws com.opensymphony.workflow.StoreException
      Specified by:
      setEntryState in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • getPropertySet

      public com.opensymphony.module.propertyset.PropertySet getPropertySet(long entryId) throws com.opensymphony.workflow.StoreException
      Specified by:
      getPropertySet in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • createCurrentStep

      public com.opensymphony.workflow.spi.Step createCurrentStep(long entryId, int stepId, String owner, Date startDate, Date dueDate, String status, long[] previousIds) throws com.opensymphony.workflow.StoreException
      Specified by:
      createCurrentStep in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • createEntry

      public com.opensymphony.workflow.spi.WorkflowEntry createEntry(String workflowName) throws com.opensymphony.workflow.StoreException
      Specified by:
      createEntry in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • storeNewEntry

      protected void storeNewEntry(com.opensymphony.workflow.spi.WorkflowEntry workflowEntry) throws com.opensymphony.workflow.StoreException
      Store a new workflow entry into the JCR repository
      Parameters:
      workflowEntry - The new entry
      Throws:
      com.opensymphony.workflow.StoreException - on error
    • removeEntry

      public void removeEntry(long entryId) throws com.opensymphony.workflow.StoreException
      Remove a workflow entry
      Parameters:
      entryId - The id of workflow entry
      Throws:
      com.opensymphony.workflow.StoreException - if an error occurred
    • _getOrCreateParentEntryNode

      protected abstract Node _getOrCreateParentEntryNode(Node root, long id) throws RepositoryException
      Retrieves the parent node of a workflow entry. Creates non existing ancestor nodes when necessary.
      Parameters:
      root - The workflow store root node
      id - The workflow entry id
      Returns:
      The parent node
      Throws:
      RepositoryException - on repository error
    • getEntryNode

      public Node getEntryNode(Session session, long entryId) throws RepositoryException
      Retrieve an entry node from its id.
      Parameters:
      session - the session to use.
      entryId - the id of the entry.
      Returns:
      the entry node.
      Throws:
      RepositoryException - if there is no entry for this id.
    • _getNextEntryId

      protected long _getNextEntryId() throws RepositoryException
      Generate an unique entry id.
      Returns:
      A new entry id.
      Throws:
      RepositoryException - if an error occurs.
    • _getNextStepId

      protected long _getNextStepId(Node entry) throws RepositoryException
      Generate an unique step id for an entry.
      Parameters:
      entry - The entry.
      Returns:
      A new step id.
      Throws:
      RepositoryException - if an error occurs.
    • findCurrentSteps

      public List findCurrentSteps(long entryId) throws com.opensymphony.workflow.StoreException
      Specified by:
      findCurrentSteps in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • findEntry

      public com.opensymphony.workflow.spi.WorkflowEntry findEntry(long entryId) throws com.opensymphony.workflow.StoreException
      Specified by:
      findEntry in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • findHistorySteps

      public List findHistorySteps(long entryId) throws com.opensymphony.workflow.StoreException
      Specified by:
      findHistorySteps in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • markFinished

      public com.opensymphony.workflow.spi.Step markFinished(com.opensymphony.workflow.spi.Step step, int actionId, Date finishDate, String status, String caller) throws com.opensymphony.workflow.StoreException
      Specified by:
      markFinished in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • moveToHistory

      public void moveToHistory(com.opensymphony.workflow.spi.Step step) throws com.opensymphony.workflow.StoreException
      Specified by:
      moveToHistory in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • query

      public List query(com.opensymphony.workflow.query.WorkflowQuery query) throws com.opensymphony.workflow.StoreException
      Specified by:
      query in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • clearHistory

      public void clearHistory(long entryId) throws com.opensymphony.workflow.StoreException
      Description copied from interface: AmetysWorkflowStore
      Removes all history steps of an instance from the database.
      All future calls to the history will return an empty List of Step.
      Specified by:
      clearHistory in interface AmetysWorkflowStore
      Parameters:
      entryId - the id of a workflow instance.
      Throws:
      com.opensymphony.workflow.StoreException - if an error occurs.
    • deleteInstance

      public void deleteInstance(long entryId) throws com.opensymphony.workflow.StoreException
      Description copied from interface: AmetysWorkflowStore
      Deletes a workflow instance from the database.
      All future calls from the workflow to this instance will failed.
      Specified by:
      deleteInstance in interface AmetysWorkflowStore
      Parameters:
      entryId - The id of a workflow instance.
      Throws:
      com.opensymphony.workflow.StoreException - if an error occurs.
    • getCondition

      protected String getCondition(com.opensymphony.workflow.query.WorkflowQuery query) throws com.opensymphony.workflow.StoreException
      Get the condition from the query.
      Parameters:
      query - The query.
      Returns:
      The resulting condition.
      Throws:
      com.opensymphony.workflow.StoreException - if the query is not valid.
    • buildFieldExpression

      protected String buildFieldExpression(com.opensymphony.workflow.query.WorkflowQuery query) throws com.opensymphony.workflow.StoreException
      Build a field expression.
      Parameters:
      query - The query.
      Returns:
      The resulting field expression.
      Throws:
      com.opensymphony.workflow.StoreException - if the query is not valid.
    • query

      public List query(com.opensymphony.workflow.query.WorkflowExpressionQuery query) throws com.opensymphony.workflow.StoreException
      Specified by:
      query in interface com.opensymphony.workflow.spi.WorkflowStore
      Throws:
      com.opensymphony.workflow.StoreException
    • getSortCriteria

      protected String getSortCriteria(com.opensymphony.workflow.query.WorkflowExpressionQuery query) throws com.opensymphony.workflow.StoreException
      Get the JCR sort criteria from the query.
      Parameters:
      query - The query.
      Returns:
      The sort criteria.
      Throws:
      com.opensymphony.workflow.StoreException - if the criteria is not valid.
    • getFirstFieldExpression

      protected com.opensymphony.workflow.query.FieldExpression getFirstFieldExpression(com.opensymphony.workflow.query.Expression expression)
      Retrieve the first field expression from an expression.
      Parameters:
      expression - the expression to inspect.
      Returns:
      the first field expression.
    • getPredicate

      protected String getPredicate(com.opensymphony.workflow.query.WorkflowExpressionQuery query) throws com.opensymphony.workflow.StoreException
      Build a predicate from the query.
      Parameters:
      query - The query.
      Returns:
      The predicate.
      Throws:
      com.opensymphony.workflow.StoreException - if the query is not valid.
    • buildNestedExpression

      protected String buildNestedExpression(com.opensymphony.workflow.query.NestedExpression nestedExpr) throws com.opensymphony.workflow.StoreException
      Build a nested expression.
      Parameters:
      nestedExpr - The nested expression.
      Returns:
      The resulting condition.
      Throws:
      com.opensymphony.workflow.StoreException - if the expression is not valid.
    • translateValue

      protected String translateValue(Object value) throws com.opensymphony.workflow.StoreException
      Convert and maybe escape a value to support XPath grammar.
      Parameters:
      value - The value to translate.
      Returns:
      The translated value.
      Throws:
      com.opensymphony.workflow.StoreException - if the value cannot be translated.
    • getPropertyName

      protected String getPropertyName(int field) throws com.opensymphony.workflow.StoreException
      Retrieve a propertyName from a field id.
      Parameters:
      field - The field id.
      Returns:
      The corresponding property name.
      Throws:
      com.opensymphony.workflow.StoreException - if the field is not valid.
      See Also:
      • FieldExpression