Class ProcessCaseRepository
- java.lang.Object
-
- com.aquima.interactions.process.impl.ProcessCaseRepository
-
public class ProcessCaseRepository extends Object
Utility wrapper for the case dao. Adds logic to the dao layer.- Since:
- 9.1
- Author:
- A. Pragt
-
-
Constructor Summary
Constructors Constructor Description ProcessCaseRepository(IProcessCaseDao caseDao)
ProcessCaseRepository(IProcessCaseDao caseDao, IProcessEngineSettings settings)
Creates a new instance.ProcessCaseRepository(IProcessCaseDao caseDao, IProcessEngineSettings settings, ILegacyToggles legacyToggles)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ICaseModel
acquireCaseLock(long caseId, String userId)
Method for setting a Case to locked.ITaskModel
acquireTaskLock(long taskId)
Method for setting a Task to Started(which means locked).void
clearDelayedEvent(long caseId, long eventId)
Notifies the persistence layer that an event is no longer delayed.ITaskModel
completeTask(ITaskModel task, String executedBy)
ICaseModel
createCase(String name, String appId, IMultilingualText displayName)
ICaseEventModel
createEvent(ApplicationID appId, String name, Long caseId, Long taskId, CaseEventType type, CaseEventStatusType status, Date timestamp, String user, Map<String,IValue> content)
ICaseDataInstance
createInstance(long caseId, String entityName, GUID instanceId, String instanceName)
ICaseDataValue
createValue(long instanceId, String attributeName, IValue attrValue)
void
delayEvent(long caseId, ICaseEventModel caseEventModel)
Delays the event with the given id for the case with the given id.void
deleteCase(long caseId)
void
deleteInstance(long instanceId)
void
deleteValue(long instanceId, String attributeName)
ICaseEventModel[]
findAllCaseEvents()
CaseViewResult
findByCriteria(CaseViewCriteria criteria)
TaskViewResult
findByCriteria(TaskViewCriteria criteria)
ICaseEventModel
findCaseEventById(Long eventId)
ICaseEventModel[]
findCaseEventsByCriteria(CaseEventCriteria criteria)
long[]
findCaseIdsWithTasks(String appId, String[] guids)
Finds the IDs of cases that have open tasks with the specified node IDs.ICaseModel[]
findCases(CaseStatusType status, String appId)
This method returns all the cases with a certain status for a specific application.ICaseEventModel[]
findDelayedEvents(long caseId)
Returns events whose processing has have been delayed due to the case being locked.ITaskModel[]
findOpenEventsForCaseByEventName(long caseId, String eventName)
ITaskModel[]
findTasks(Long caseId, TaskType type, TaskStatusType status, String[] nodeIds)
ITaskModel[]
findTasks(Long caseId, TaskType type, TaskStatusType status, String assignee, DateTimeValue timeOutBefore)
ICaseEventModel
findTimerEvent(Long caseId, Long taskId)
long[]
findWaitingCaseIds(String appId, DateTimeValue currentTime, boolean ignoreLocked)
Finds the id of the cases that are in the waiting state.ICaseModel[]
findWaitingCases(String appId, String eventName, Set<Long> caseIds)
Returns cases that have an open incoming message event task waiting for an event with the specified name.ITaskModel[]
getAvailableTasks(Long caseId, String userId)
ICaseModel
getCase(long caseId)
This method returns the case for the specified id.ITaskModel[]
getChildTasks(long taskParentId)
ICaseQueryResult[]
getExtendedCases(CaseCriteria filterContext)
ITaskQueryResult[]
getExtendedTasks(TaskCriteria filterContext)
ICaseDataInstance[]
getInstancesForCase(long caseId)
Map<Long,ICaseDataInstance[]>
getInstancesForCases(long[] caseIds)
ITaskModel[]
getStartedTasks(String appId)
ITaskModel
getTask(long taskId)
This method returns the task of a certain id.ITaskModel[]
getTasksForCase(long caseId)
ITaskModel[]
getUnassignedTasks()
ICaseDataValue[]
getValuesForCase(long caseId)
Map<Long,ICaseDataValue[]>
getValuesForInstances(long[] instanceIds)
boolean
isCaseLocked(long caseId)
ITaskModel
openCallTask(long caseId, Long parentId, String name, GUID nodeId, DateTimeValue timeoutDate, boolean isConditional, boolean isRequired)
ITaskModel
openConditionalTask(long caseId, long parentId, String taskName, GUID nodeId, DateTimeValue timeoutDate, boolean isAdHoc)
ITaskModel
openDynamicTask(long caseId, String taskName, DateTimeValue startDate, IMultilingualText displayName)
ITaskModel
openEventTask(long caseId, long parentId, String taskName, GUID nodeId, DateTimeValue startDate, String eventName, boolean isAdHoc)
ITaskModel
openGroupTask(long caseId, long parentId, String taskName, GUID nodeId)
ITaskModel
openRootTask(long caseId, String taskName, GUID nodeId)
ITaskModel
openTask(long caseId, Long parentId, String taskName, IAssigneeInfo assignee, GUID nodeId, DateTimeValue startDate, DateTimeValue timeoutDate, DateTimeValue dueDate, boolean isConditional, boolean isRequired, boolean isUserSet, Integer priority, DateTimeValue lastPriorityCheck, Map<String,String> properties, String[] unauthorizedUserIds, IMultilingualText displayName)
ITaskModel
openTimerTask(long caseId, long parentId, String taskName, GUID nodeId, DateTimeValue startDate, DateTimeValue timeoutDate, boolean isAdHoc)
ICaseEventModel
replayEvent(ICaseEventModel originalEvent, Long caseId, String user)
Creates a replay copy of the event with the given id.void
setCaseEventStatus(ICaseEventModel caseEvent, CaseEventStatusType status)
ITaskModel
setTaskAssignment(ITaskModel task, IAssigneeInfo assigneeInfo)
ITaskModel
setTaskAssignment(ITaskModel task, IAssigneeInfo assigneeInfo, boolean isAssigneeSetByUser)
ITaskModel
setTaskLastPriorityCheck(ITaskModel task, DateTimeValue lastPriorityCheck)
ITaskModel
setTaskPriority(ITaskModel task, Integer priority, DateTimeValue lastPriorityCheck)
ITaskModel
setTaskRequired(ITaskModel task, boolean isRequired)
ITaskModel
setTaskStartDate(long id, DateTimeValue startDate)
ITaskModel
setTaskStatus(ITaskModel task, TaskStatusType status)
ICaseModel
unlockCase(long caseId)
ICaseModel
updateCaseDisplayName(long caseId, IMultilingualText displayName)
ITaskModel
updateTask(long id, TaskStatusType status, IAssigneeInfo assignee, DateTimeValue timeoutDate, String exitState, String executedBy, boolean isRequired, boolean isUserSet, Integer priority, DateTimeValue lastPriorityCheck, IMultilingualText displayName)
ITaskModel
updateTaskDueDate(long taskId, DateTimeValue dueDate)
ITaskModel
updateTaskExitState(long taskId, String newExitState)
ITaskModel
updateTaskTimeoutDate(long taskId, DateTimeValue timeoutDate)
ITaskModel
updateTaskUnauthorizedUsers(long taskId, String[] unauthorizedUsers)
ICaseDataValue
updateValue(long instanceId, String attributeName, IValue attrValue)
-
-
-
Constructor Detail
-
ProcessCaseRepository
public ProcessCaseRepository(IProcessCaseDao caseDao)
-
ProcessCaseRepository
public ProcessCaseRepository(IProcessCaseDao caseDao, IProcessEngineSettings settings)
Creates a new instance. If the settings parameter is given, then the global and application-specific IgnoreMode setting will be upheld.- Parameters:
caseDao
- the underlying DAO.settings
- the process engine settings (may be null).- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
ProcessCaseRepository
public ProcessCaseRepository(IProcessCaseDao caseDao, IProcessEngineSettings settings, ILegacyToggles legacyToggles)
Creates a new instance. If the settings parameter is given, then the global and application-specific IgnoreMode setting will be upheld.- Parameters:
caseDao
- the underlying DAO.settings
- the process engine settings (may be null).- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
-
Method Detail
-
getCase
public ICaseModel getCase(long caseId) throws ProcessDataAccessException
This method returns the case for the specified id.- Parameters:
caseId
- The id of the case.- Returns:
- The model for the specified case, or null if the case could not be found.
- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
findCases
public ICaseModel[] findCases(CaseStatusType status, String appId) throws ProcessDataAccessException
This method returns all the cases with a certain status for a specific application.- Parameters:
status
- The status of the case.appId
- The corresponding application id.- Returns:
- A list of case model objects.
- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
findCaseIdsWithTasks
public long[] findCaseIdsWithTasks(String appId, String[] guids) throws ProcessDataAccessException
Finds the IDs of cases that have open tasks with the specified node IDs.- Parameters:
appId
- The corresponding application id.guids
- task node ids.- Returns:
- the matching case IDs.
- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
findWaitingCases
public ICaseModel[] findWaitingCases(String appId, String eventName, Set<Long> caseIds) throws ProcessDataAccessException
Returns cases that have an open incoming message event task waiting for an event with the specified name.If
appId
is not null, only cases with a matching application ID will be returnedIf
eventName
is not null, only cases with open incoming message event tasks waiting for the specified event will be returnedIf
caseIds
is not null, only cases having their ID in this set will be returned- Parameters:
appId
- the application ID of the matching cases (may be null).eventName
- the name of the event (may be null).- Returns:
- the matching cases.
- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
findWaitingCaseIds
public long[] findWaitingCaseIds(String appId, DateTimeValue currentTime, boolean ignoreLocked) throws ProcessDataAccessException
Finds the id of the cases that are in the waiting state.- Parameters:
appId
- The corresponding application id.currentTime
- Current time.ignoreLocked
- Flag indicating if locked should be ignored or not.- Returns:
- A list of matching case model ids.
- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
createCase
public ICaseModel createCase(String name, String appId, IMultilingualText displayName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
updateCaseDisplayName
public ICaseModel updateCaseDisplayName(long caseId, IMultilingualText displayName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
acquireCaseLock
public ICaseModel acquireCaseLock(long caseId, String userId) throws ProcessDataAccessException
Method for setting a Case to locked. Will return null when the case is already locked or does not exist.- Parameters:
caseId
- The caseId of the to be locked caseuserId
- The userId of the user that locks the case- Returns:
- updated casemodel
- Throws:
ProcessDataAccessException
- if something goes wrong during the data access operation.
-
unlockCase
public ICaseModel unlockCase(long caseId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
acquireTaskLock
public ITaskModel acquireTaskLock(long taskId) throws StartProcessTaskException, UnknownTaskException
Method for setting a Task to Started(which means locked). Will throw a StartProcessTaskException when the task does not have the status 'open'. Only open tasks kan be started, tasks with a different status should never be set to started.- Parameters:
taskId
- The taskId of the task to be set to started- Returns:
- updated taskModel
- Throws:
StartProcessTaskException
- when the requested task for taskId does not have the status 'open'UnknownTaskException
- when the requested task for taskId does not exists
-
deleteCase
public void deleteCase(long caseId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getTask
public ITaskModel getTask(long taskId) throws ProcessDataAccessException
This method returns the task of a certain id.- Parameters:
taskId
- The id of the task.- Returns:
- The model for the task, or null if a task model with the given id is not found.
- Throws:
ProcessDataAccessException
-
getChildTasks
public ITaskModel[] getChildTasks(long taskParentId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getTasksForCase
public ITaskModel[] getTasksForCase(long caseId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findOpenEventsForCaseByEventName
public ITaskModel[] findOpenEventsForCaseByEventName(long caseId, String eventName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findTasks
public ITaskModel[] findTasks(Long caseId, TaskType type, TaskStatusType status, String assignee, DateTimeValue timeOutBefore) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findTasks
public ITaskModel[] findTasks(Long caseId, TaskType type, TaskStatusType status, String[] nodeIds) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openRootTask
public ITaskModel openRootTask(long caseId, String taskName, GUID nodeId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openGroupTask
public ITaskModel openGroupTask(long caseId, long parentId, String taskName, GUID nodeId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openConditionalTask
public ITaskModel openConditionalTask(long caseId, long parentId, String taskName, GUID nodeId, DateTimeValue timeoutDate, boolean isAdHoc) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openTimerTask
public ITaskModel openTimerTask(long caseId, long parentId, String taskName, GUID nodeId, DateTimeValue startDate, DateTimeValue timeoutDate, boolean isAdHoc) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openEventTask
public ITaskModel openEventTask(long caseId, long parentId, String taskName, GUID nodeId, DateTimeValue startDate, String eventName, boolean isAdHoc) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openDynamicTask
public ITaskModel openDynamicTask(long caseId, String taskName, DateTimeValue startDate, IMultilingualText displayName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openCallTask
public ITaskModel openCallTask(long caseId, Long parentId, String name, GUID nodeId, DateTimeValue timeoutDate, boolean isConditional, boolean isRequired) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
openTask
public ITaskModel openTask(long caseId, Long parentId, String taskName, IAssigneeInfo assignee, GUID nodeId, DateTimeValue startDate, DateTimeValue timeoutDate, DateTimeValue dueDate, boolean isConditional, boolean isRequired, boolean isUserSet, Integer priority, DateTimeValue lastPriorityCheck, Map<String,String> properties, String[] unauthorizedUserIds, IMultilingualText displayName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
setTaskStatus
public ITaskModel setTaskStatus(ITaskModel task, TaskStatusType status) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
setTaskPriority
public ITaskModel setTaskPriority(ITaskModel task, Integer priority, DateTimeValue lastPriorityCheck) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
setTaskLastPriorityCheck
public ITaskModel setTaskLastPriorityCheck(ITaskModel task, DateTimeValue lastPriorityCheck) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
setTaskAssignment
public ITaskModel setTaskAssignment(ITaskModel task, IAssigneeInfo assigneeInfo)
-
setTaskAssignment
public ITaskModel setTaskAssignment(ITaskModel task, IAssigneeInfo assigneeInfo, boolean isAssigneeSetByUser)
-
setTaskRequired
public ITaskModel setTaskRequired(ITaskModel task, boolean isRequired)
-
completeTask
public ITaskModel completeTask(ITaskModel task, String executedBy) throws ProcessDataAccessException, AppException
-
updateTask
public ITaskModel updateTask(long id, TaskStatusType status, IAssigneeInfo assignee, DateTimeValue timeoutDate, String exitState, String executedBy, boolean isRequired, boolean isUserSet, Integer priority, DateTimeValue lastPriorityCheck, IMultilingualText displayName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
updateTaskExitState
public ITaskModel updateTaskExitState(long taskId, String newExitState)
-
setTaskStartDate
public ITaskModel setTaskStartDate(long id, DateTimeValue startDate)
-
updateTaskDueDate
public ITaskModel updateTaskDueDate(long taskId, DateTimeValue dueDate)
-
updateTaskTimeoutDate
public ITaskModel updateTaskTimeoutDate(long taskId, DateTimeValue timeoutDate)
-
updateTaskUnauthorizedUsers
public ITaskModel updateTaskUnauthorizedUsers(long taskId, String[] unauthorizedUsers) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getAvailableTasks
public ITaskModel[] getAvailableTasks(Long caseId, String userId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getUnassignedTasks
public ITaskModel[] getUnassignedTasks() throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getExtendedTasks
public ITaskQueryResult[] getExtendedTasks(TaskCriteria filterContext) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getExtendedCases
public ICaseQueryResult[] getExtendedCases(CaseCriteria filterContext) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getInstancesForCase
public ICaseDataInstance[] getInstancesForCase(long caseId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getInstancesForCases
public Map<Long,ICaseDataInstance[]> getInstancesForCases(long[] caseIds) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
createInstance
public ICaseDataInstance createInstance(long caseId, String entityName, GUID instanceId, String instanceName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
deleteInstance
public void deleteInstance(long instanceId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getValuesForCase
public ICaseDataValue[] getValuesForCase(long caseId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getValuesForInstances
public Map<Long,ICaseDataValue[]> getValuesForInstances(long[] instanceIds) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
createValue
public ICaseDataValue createValue(long instanceId, String attributeName, IValue attrValue) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
updateValue
public ICaseDataValue updateValue(long instanceId, String attributeName, IValue attrValue) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
deleteValue
public void deleteValue(long instanceId, String attributeName) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
getStartedTasks
public ITaskModel[] getStartedTasks(String appId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
createEvent
public ICaseEventModel createEvent(ApplicationID appId, String name, Long caseId, Long taskId, CaseEventType type, CaseEventStatusType status, Date timestamp, String user, Map<String,IValue> content) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
replayEvent
public ICaseEventModel replayEvent(ICaseEventModel originalEvent, Long caseId, String user) throws ProcessDataAccessException
Creates a replay copy of the event with the given id.- Parameters:
originalEvent
- original event that needs to be replayedcaseId
- the id of the event to be replayeduser
- user to use to replay the event- Returns:
- the created event or null if the original event could not be found
- Throws:
ProcessDataAccessException
-
findTimerEvent
public ICaseEventModel findTimerEvent(Long caseId, Long taskId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
setCaseEventStatus
public void setCaseEventStatus(ICaseEventModel caseEvent, CaseEventStatusType status) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findCaseEventById
public ICaseEventModel findCaseEventById(Long eventId) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findAllCaseEvents
public ICaseEventModel[] findAllCaseEvents() throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findCaseEventsByCriteria
public ICaseEventModel[] findCaseEventsByCriteria(CaseEventCriteria criteria) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findDelayedEvents
public ICaseEventModel[] findDelayedEvents(long caseId) throws ProcessDataAccessException
Returns events whose processing has have been delayed due to the case being locked. The returned events are in ordered by timestamp ascending.- Parameters:
caseId
- the ID of the case for which delayed events are retrieved- Returns:
- the delayed events for the given case, never null
- Throws:
ProcessDataAccessException
- Since:
- 9.6
-
delayEvent
public void delayEvent(long caseId, ICaseEventModel caseEventModel) throws ProcessDataAccessException
Delays the event with the given id for the case with the given id. If the event with the given id is already delayed for the given case, this method has no effect.- Parameters:
caseId
- the ID of the casecaseEventModel
- the event- Throws:
ProcessDataAccessException
- Since:
- 9.6
-
clearDelayedEvent
public void clearDelayedEvent(long caseId, long eventId) throws ProcessDataAccessException
Notifies the persistence layer that an event is no longer delayed.- Parameters:
caseId
- the ID of the caseeventId
- the ID of the event- Throws:
ProcessDataAccessException
- Since:
- 9.6
-
findByCriteria
public TaskViewResult findByCriteria(TaskViewCriteria criteria) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
findByCriteria
public CaseViewResult findByCriteria(CaseViewCriteria criteria) throws ProcessDataAccessException
- Throws:
ProcessDataAccessException
-
isCaseLocked
public boolean isCaseLocked(long caseId)
-
-