Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.jbpm.core.service
Class JbpmServiceImpl

java.lang.Object
  extended by org.nuxeo.ecm.platform.jbpm.core.service.JbpmServiceImpl
All Implemented Interfaces:
JbpmService

public class JbpmServiceImpl
extends Object
implements JbpmService

Author:
arussel

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuxeo.ecm.platform.jbpm.JbpmService
JbpmService.HibernateQueries, JbpmService.TaskVariableName, JbpmService.VariableName
 
Field Summary
static ThreadLocal<JbpmContext> contexts
           
 
Fields inherited from interface org.nuxeo.ecm.platform.jbpm.JbpmService
ACL_PREFIX
 
Constructor Summary
JbpmServiceImpl()
           
 
Method Summary
 ProcessInstance createProcessInstance(NuxeoPrincipal user, String processDefinitionName, DocumentModel dm, Map<String,Serializable> variables, Map<String,Serializable> transientVariables)
          Returns the created and started process instance.
 void deleteProcessInstance(NuxeoPrincipal principal, Long processId)
          Deletes the process instance and related tasks.
 void deleteTaskInstance(NuxeoPrincipal principal, Long taskId)
          Deletes a task instance (attached to a process or not)
 void endProcessInstance(Long processId)
          Terminates this process and all the tokens in it.
 void endTask(Long taskInstanceId, String transition, Map<String,Serializable> taskVariables, Map<String,Serializable> variables, Map<String,Serializable> transientVariables, NuxeoPrincipal principal)
          Ends the task following the transition.
 Serializable executeJbpmOperation(JbpmOperation operation)
          Executes a JbpmOperation.
 List<String> getAvailableTransitions(Long taskInstanceId, NuxeoPrincipal principal)
          Returns a list of of possible transition for this user.
 JbpmConfiguration getConfiguration()
          Return the configuration.
 List<ProcessInstance> getCurrentProcessInstances(List<String> actors, JbpmActorsListFilter filter)
          Returns a list of all current process instances that has been started by one of the actors in the list.
 List<ProcessInstance> getCurrentProcessInstances(NuxeoPrincipal principal, JbpmListFilter filter)
          Returns a list of all current process instances this user has started.
 List<TaskInstance> getCurrentTaskInstances(List<String> actors, JbpmActorsListFilter filter)
          Returns a list of task instances assigned to one of the actors in the list or to its pool.
 List<TaskInstance> getCurrentTaskInstances(NuxeoPrincipal currentUser, JbpmListFilter filter)
          Returns a list of task instances assigned to this user or one of its group.
 DocumentModel getDocumentModel(ProcessInstance pi, NuxeoPrincipal user)
          Returns the document used in this process.
 DocumentModel getDocumentModel(TaskInstance ti, NuxeoPrincipal user)
          Returns the document used in this task.
 Boolean getPermission(ProcessInstance pi, JbpmSecurityPolicy.Action action, DocumentModel dm, NuxeoPrincipal principal)
          Returns true if this user has this permission for this process instance and document.
 ProcessDefinition getProcessDefinitionByName(String name)
          Returns the latest process definition with this name.
 List<ProcessDefinition> getProcessDefinitions(NuxeoPrincipal user, DocumentModel dm, JbpmListFilter filter)
          Returns a list of available Process Definition Name available for this document and user.
 List<ProcessDefinition> getProcessDefinitionsByType(String type)
          Returns the latest process definitions attached to a type.
 ProcessInstance getProcessInstance(Long processInstanceId)
          Return the process instance.
 List<ProcessInstance> getProcessInstances(DocumentModel dm, NuxeoPrincipal user, JbpmListFilter jbpmListFilter)
          Returns the list of process instances associated with this document.
 List<TaskInstance> getTaskInstances(DocumentModel dm, List<String> actors, JbpmActorsListFilter filter)
          Returns the list of task instances associated with this document assigned to one of the actor in the list or its pool.
 List<TaskInstance> getTaskInstances(DocumentModel dm, NuxeoPrincipal user, JbpmListFilter filter)
          Returns the list of task instances associated with this document for which the user is the actor or belongs to the pooled actor list.
 List<TaskInstance> getTaskInstances(Long processInstanceId, NuxeoPrincipal principal, JbpmListFilter filter)
          Returns a list of task instance for this process instance.
 Map<String,List<String>> getTypeFilterConfiguration()
          Returns a map, whose key is the type of document, and value is a list of process definitions.
 boolean isTransactionEnabled(JbpmContext context)
           
 void notifyEventListeners(String name, String comment, String[] recipients, CoreSession session, NuxeoPrincipal principal, DocumentModel doc)
          Notify the event producer on the machine the jbpm service is.
 ProcessInstance persistProcessInstance(ProcessInstance pi)
          Persists a process instance.
 void saveTaskInstances(List<TaskInstance> taskInstances)
          Saves the task instances.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contexts

public static final ThreadLocal<JbpmContext> contexts
Constructor Detail

JbpmServiceImpl

public JbpmServiceImpl()
Method Detail

executeJbpmOperation

public Serializable executeJbpmOperation(JbpmOperation operation)
                                  throws NuxeoJbpmException
Description copied from interface: JbpmService
Executes a JbpmOperation.

The JbpmOperation will be executed inside a context block.

Specified by:
executeJbpmOperation in interface JbpmService
Returns:
The object returned by the run method of the JbpmOperation.
Throws:
NuxeoJbpmException

getConfiguration

public JbpmConfiguration getConfiguration()
Description copied from interface: JbpmService
Return the configuration.

Specified by:
getConfiguration in interface JbpmService

isTransactionEnabled

public boolean isTransactionEnabled(JbpmContext context)

getCurrentTaskInstances

public List<TaskInstance> getCurrentTaskInstances(NuxeoPrincipal currentUser,
                                                  JbpmListFilter filter)
                                           throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns a list of task instances assigned to this user or one of its group.

Specified by:
getCurrentTaskInstances in interface JbpmService
Parameters:
currentUser - the user.
Returns:
A list of task instances.
Throws:
NuxeoJbpmException

createProcessInstance

public ProcessInstance createProcessInstance(NuxeoPrincipal user,
                                             String processDefinitionName,
                                             DocumentModel dm,
                                             Map<String,Serializable> variables,
                                             Map<String,Serializable> transientVariables)
                                      throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the created and started process instance.

Specified by:
createProcessInstance in interface JbpmService
Parameters:
user - the initiator of the process.
processDefinitionName - the name of the process
dm - the document attached to this process.
variables - A list a variables to add to the process instance.
transientVariables - the list of transient variables.
Returns:
the created process instance.
Throws:
NuxeoJbpmException

getCurrentProcessInstances

public List<ProcessInstance> getCurrentProcessInstances(NuxeoPrincipal principal,
                                                        JbpmListFilter filter)
                                                 throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns a list of all current process instances this user has started.

Specified by:
getCurrentProcessInstances in interface JbpmService
Returns:
A list of ProcessInstance
Throws:
NuxeoJbpmException

getDocumentModel

public DocumentModel getDocumentModel(TaskInstance ti,
                                      NuxeoPrincipal user)
                               throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the document used in this task.

Specified by:
getDocumentModel in interface JbpmService
Parameters:
ti - the task.
user - the user.
Returns:
a list of DocumentModel.
Throws:
NuxeoJbpmException

getDocumentModel

public DocumentModel getDocumentModel(ProcessInstance pi,
                                      NuxeoPrincipal user)
                               throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the document used in this process.

Specified by:
getDocumentModel in interface JbpmService
Parameters:
pi - the process instance.
user - the user.
Returns:
a DocumentModel.
Throws:
NuxeoJbpmException

getProcessInstances

public List<ProcessInstance> getProcessInstances(DocumentModel dm,
                                                 NuxeoPrincipal user,
                                                 JbpmListFilter jbpmListFilter)
                                          throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the list of process instances associated with this document.

Specified by:
getProcessInstances in interface JbpmService
Returns:
Throws:
NuxeoJbpmException

getTaskInstances

public List<TaskInstance> getTaskInstances(DocumentModel dm,
                                           NuxeoPrincipal user,
                                           JbpmListFilter filter)
                                    throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the list of task instances associated with this document for which the user is the actor or belongs to the pooled actor list.

If the user is null, then it returns all task instances for the document.

Specified by:
getTaskInstances in interface JbpmService
Parameters:
dm - the document.
Returns:
Throws:
NuxeoJbpmException

endProcessInstance

public void endProcessInstance(Long processId)
                        throws NuxeoJbpmException
Description copied from interface: JbpmService
Terminates this process and all the tokens in it.

Specified by:
endProcessInstance in interface JbpmService
Parameters:
processId - the id of the process instance.
Throws:
NuxeoJbpmException

endTask

public void endTask(Long taskInstanceId,
                    String transition,
                    Map<String,Serializable> taskVariables,
                    Map<String,Serializable> variables,
                    Map<String,Serializable> transientVariables,
                    NuxeoPrincipal principal)
             throws NuxeoJbpmException
Description copied from interface: JbpmService
Ends the task following the transition. If transition is null, follow the default transition.

Specified by:
endTask in interface JbpmService
transition - the transition to follow
taskVariables - the variables attached to the task.
variables - A list a variables to add to the process instance.
transientVariables - the list of transient variables.
principal - the user ending the task. Might be different from task.getActorId()
Throws:
NuxeoJbpmException

getAvailableTransitions

public List<String> getAvailableTransitions(Long taskInstanceId,
                                            NuxeoPrincipal principal)
                                     throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns a list of of possible transition for this user. (If a document is attached to the process, then return only the allowed transition)

Specified by:
getAvailableTransitions in interface JbpmService
Parameters:
taskInstanceId - the id of the taskInstance.
principal - the user
Returns:
Throws:
NuxeoJbpmException

getProcessInstance

public ProcessInstance getProcessInstance(Long processInstanceId)
                                   throws NuxeoJbpmException
Description copied from interface: JbpmService
Return the process instance.

Specified by:
getProcessInstance in interface JbpmService
Parameters:
processInstanceId - the id of the process instance.
Returns:
Throws:
NuxeoJbpmException

getTaskInstances

public List<TaskInstance> getTaskInstances(Long processInstanceId,
                                           NuxeoPrincipal principal,
                                           JbpmListFilter filter)
                                    throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns a list of task instance for this process instance. It returns all task instances, not only the tasks for this principal. The principal is used as an argument to the filter.

Specified by:
getTaskInstances in interface JbpmService
Parameters:
processInstanceId - the id of the process instance.
Returns:
Throws:
NuxeoJbpmException

saveTaskInstances

public void saveTaskInstances(List<TaskInstance> taskInstances)
                       throws NuxeoJbpmException
Description copied from interface: JbpmService
Saves the task instances.

Tasks are created or updated if they already exist.

Specified by:
saveTaskInstances in interface JbpmService
Throws:
NuxeoJbpmException

getProcessDefinitions

public List<ProcessDefinition> getProcessDefinitions(NuxeoPrincipal user,
                                                     DocumentModel dm,
                                                     JbpmListFilter filter)
                                              throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns a list of available Process Definition Name available for this document and user. All process definition if dm is null. The returned process definition is always the latest.

Specified by:
getProcessDefinitions in interface JbpmService
Parameters:
user - the caller.
dm - the document concerned by the process
Returns:
A list of process definition
Throws:
NuxeoJbpmException

getPermission

public Boolean getPermission(ProcessInstance pi,
                             JbpmSecurityPolicy.Action action,
                             DocumentModel dm,
                             NuxeoPrincipal principal)
                      throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns true if this user has this permission for this process instance and document.

Specified by:
getPermission in interface JbpmService
Returns:
Throws:
NuxeoJbpmException
See Also:
extention point

persistProcessInstance

public ProcessInstance persistProcessInstance(ProcessInstance pi)
                                       throws NuxeoJbpmException
Description copied from interface: JbpmService
Persists a process instance.

Specified by:
persistProcessInstance in interface JbpmService
Returns:
the updated instance.
Throws:
NuxeoJbpmException

getTypeFilterConfiguration

public Map<String,List<String>> getTypeFilterConfiguration()
Description copied from interface: JbpmService
Returns a map, whose key is the type of document, and value is a list of process definitions.

Specified by:
getTypeFilterConfiguration in interface JbpmService
Returns:

deleteProcessInstance

public void deleteProcessInstance(NuxeoPrincipal principal,
                                  Long processId)
                           throws NuxeoJbpmException
Description copied from interface: JbpmService
Deletes the process instance and related tasks.

If you don't want to delete the process, add a abandon state and suitable transitions.

Specified by:
deleteProcessInstance in interface JbpmService
Parameters:
principal - the canceller.
Throws:
NuxeoJbpmException

deleteTaskInstance

public void deleteTaskInstance(NuxeoPrincipal principal,
                               Long taskId)
                        throws NuxeoJbpmException
Description copied from interface: JbpmService
Deletes a task instance (attached to a process or not)

Specified by:
deleteTaskInstance in interface JbpmService
Parameters:
principal - the canceller.
Throws:
NuxeoJbpmException

getProcessDefinitionByName

public ProcessDefinition getProcessDefinitionByName(String name)
                                             throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the latest process definition with this name.

Specified by:
getProcessDefinitionByName in interface JbpmService
Parameters:
name - the Name.
Returns:
the process definition.
Throws:
NuxeoJbpmException

getProcessDefinitionsByType

public List<ProcessDefinition> getProcessDefinitionsByType(String type)
                                                    throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the latest process definitions attached to a type.

Matching between type and process definition is done in the typeFilter extension point of the service.

Specified by:
getProcessDefinitionsByType in interface JbpmService
Parameters:
type - the type.
Returns:
A list of process definition.
Throws:
NuxeoJbpmException

getCurrentProcessInstances

public List<ProcessInstance> getCurrentProcessInstances(List<String> actors,
                                                        JbpmActorsListFilter filter)
                                                 throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns a list of all current process instances that has been started by one of the actors in the list.

Specified by:
getCurrentProcessInstances in interface JbpmService
Parameters:
actors - A list of string that would be used as actorId to retrieve the process instances.
Returns:
Throws:
NuxeoJbpmException

getCurrentTaskInstances

public List<TaskInstance> getCurrentTaskInstances(List<String> actors,
                                                  JbpmActorsListFilter filter)
                                           throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns a list of task instances assigned to one of the actors in the list or to its pool.

Specified by:
getCurrentTaskInstances in interface JbpmService
Parameters:
actors - a list used as actorId to retrieve the tasks.
Returns:
Throws:
NuxeoJbpmException

getTaskInstances

public List<TaskInstance> getTaskInstances(DocumentModel dm,
                                           List<String> actors,
                                           JbpmActorsListFilter filter)
                                    throws NuxeoJbpmException
Description copied from interface: JbpmService
Returns the list of task instances associated with this document assigned to one of the actor in the list or its pool.

Specified by:
getTaskInstances in interface JbpmService
Returns:
Throws:
NuxeoJbpmException

notifyEventListeners

public void notifyEventListeners(String name,
                                 String comment,
                                 String[] recipients,
                                 CoreSession session,
                                 NuxeoPrincipal principal,
                                 DocumentModel doc)
                          throws ClientException
Description copied from interface: JbpmService
Notify the event producer on the machine the jbpm service is.

Specified by:
notifyEventListeners in interface JbpmService
Parameters:
name - the name of the event
comment - the comment
recipients - the recipients property of the event context
Throws:
ClientException

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.