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
Abstract workflow store for Jackrabbit
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Namespace for node type names, node names and property names.static final String
Prefix used for this namespace.static final String
Prefix with colon for this namespace.static final String
Root node type.protected final Logger
Log instance for logging events, errors, warnings, etc.protected javax.jcr.Repository
JCR Repository -
Constructor Summary
ConstructorDescriptionAbstractJackrabbitWorkflowStore
(javax.jcr.Repository repository) Create a JackrabbitWorkflowStore. -
Method Summary
Modifier and TypeMethodDescriptionprotected static Calendar
__toCalendar
(Date date) Convert a Date to a Calendar.protected abstract void
Create the root node.protected long
Generate an unique entry id.protected long
_getNextStepId
(javax.jcr.Node entry) Generate an unique step id for an entry.protected abstract javax.jcr.Node
_getOrCreateParentEntryNode
(javax.jcr.Node root, long id) Retrieves the parent node of a workflow entry.protected abstract javax.jcr.Node
_getRootNode
(javax.jcr.Session session) Get the workflow store root nodeprotected javax.jcr.Session
Open a session to the _repository.protected void
_release
(javax.jcr.Session session) Release a session.protected String
buildFieldExpression
(com.opensymphony.workflow.query.WorkflowQuery query) Build a field expression.protected String
buildNestedExpression
(com.opensymphony.workflow.query.NestedExpression nestedExpr) Build a nested expression.void
clearHistory
(long entryId) Removes all history steps of an instance from the database.
All future calls to the history will return an empty List of Step.com.opensymphony.workflow.spi.Step
createCurrentStep
(long entryId, int stepId, String owner, Date startDate, Date dueDate, String status, long[] previousIds) com.opensymphony.workflow.spi.WorkflowEntry
createEntry
(String workflowName) void
deleteInstance
(long entryId) Deletes a workflow instance from the database.
All future calls from the workflow to this instance will failed.findCurrentSteps
(long entryId) com.opensymphony.workflow.spi.WorkflowEntry
findEntry
(long entryId) findHistorySteps
(long entryId) protected String
getCondition
(com.opensymphony.workflow.query.WorkflowQuery query) Get the condition from the query.javax.jcr.Node
getEntryNode
(javax.jcr.Session session, long entryId) Retrieve an entry node from its id.protected com.opensymphony.workflow.query.FieldExpression
getFirstFieldExpression
(com.opensymphony.workflow.query.Expression expression) Retrieve the first field expression from an expression.protected String
getPredicate
(com.opensymphony.workflow.query.WorkflowExpressionQuery query) Build a predicate from the query.protected String
getPropertyName
(int field) Retrieve a propertyName from a field id.com.opensymphony.module.propertyset.PropertySet
getPropertySet
(long entryId) protected String
getSortCriteria
(com.opensymphony.workflow.query.WorkflowExpressionQuery query) Get the JCR sort criteria from the query.void
com.opensymphony.workflow.spi.Step
markFinished
(com.opensymphony.workflow.spi.Step step, int actionId, Date finishDate, String status, String caller) void
moveToHistory
(com.opensymphony.workflow.spi.Step step) query
(com.opensymphony.workflow.query.WorkflowExpressionQuery query) query
(com.opensymphony.workflow.query.WorkflowQuery query) void
removeEntry
(long entryId) Remove a workflow entryvoid
setEntryState
(long entryId, int state) protected void
storeNewEntry
(com.opensymphony.workflow.spi.WorkflowEntry workflowEntry) Store a new workflow entry into the JCR repositoryprotected String
translateValue
(Object value) Convert and maybe escape a value to support XPath grammar.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.plugins.workflow.store.AmetysWorkflowStore
shouldClearHistory
-
Field Details
-
__NAMESPACE
Namespace for node type names, node names and property names.- See Also:
-
__NAMESPACE_PREFIX
Prefix used for this namespace.- See Also:
-
__NM_PREFIX
Prefix with colon for this namespace.- See Also:
-
__ROOT_NT
Root node type.- See Also:
-
_log
Log instance for logging events, errors, warnings, etc. -
_repository
JCR Repository
-
-
Constructor Details
-
AbstractJackrabbitWorkflowStore
Create a JackrabbitWorkflowStore.- Parameters:
repository
- the JCR Repository to use.
-
-
Method Details
-
_getSession
Open a session to the _repository.- Returns:
- the session opened.
- Throws:
javax.jcr.RepositoryException
- if an error occurs.
-
_release
Release a session.Default implementation calls logout on the session.
- Parameters:
session
- the session to release.
-
__toCalendar
Convert a Date to a Calendar.- Parameters:
date
- The date to convert.- Returns:
- The date converted as a Calendar.
-
init
- Specified by:
init
in interfacecom.opensymphony.workflow.spi.WorkflowStore
- Throws:
com.opensymphony.workflow.StoreException
-
_createRootNode
Create the root node.- Throws:
javax.jcr.RepositoryException
- if an error occurs.
-
_getRootNode
protected abstract javax.jcr.Node _getRootNode(javax.jcr.Session session) throws javax.jcr.RepositoryException Get the workflow store root node- Parameters:
session
- the session to use- Returns:
- The workflow store root node
- Throws:
javax.jcr.RepositoryException
- if an error occurs.
-
setEntryState
- Specified by:
setEntryState
in interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.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
Remove a workflow entry- Parameters:
entryId
- The id of workflow entry- Throws:
com.opensymphony.workflow.StoreException
- if an error occurred
-
_getOrCreateParentEntryNode
protected abstract javax.jcr.Node _getOrCreateParentEntryNode(javax.jcr.Node root, long id) throws javax.jcr.RepositoryException Retrieves the parent node of a workflow entry. Creates non existing ancestor nodes when necessary.- Parameters:
root
- The workflow store root nodeid
- The workflow entry id- Returns:
- The parent node
- Throws:
javax.jcr.RepositoryException
- on repository error
-
getEntryNode
public javax.jcr.Node getEntryNode(javax.jcr.Session session, long entryId) throws javax.jcr.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:
javax.jcr.RepositoryException
- if there is no entry for this id.
-
_getNextEntryId
Generate an unique entry id.- Returns:
- A new entry id.
- Throws:
javax.jcr.RepositoryException
- if an error occurs.
-
_getNextStepId
Generate an unique step id for an entry.- Parameters:
entry
- The entry.- Returns:
- A new step id.
- Throws:
javax.jcr.RepositoryException
- if an error occurs.
-
findCurrentSteps
- Specified by:
findCurrentSteps
in interfacecom.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 interfacecom.opensymphony.workflow.spi.WorkflowStore
- Throws:
com.opensymphony.workflow.StoreException
-
findHistorySteps
- Specified by:
findHistorySteps
in interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.opensymphony.workflow.spi.WorkflowStore
- Throws:
com.opensymphony.workflow.StoreException
-
clearHistory
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 interfaceAmetysWorkflowStore
- Parameters:
entryId
- the id of a workflow instance.- Throws:
com.opensymphony.workflow.StoreException
- if an error occurs.
-
deleteInstance
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 interfaceAmetysWorkflowStore
- 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 interfacecom.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
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
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
-