Interface ProcessesStorage
public interface ProcessesStorage
-
Method Summary
Modifier and TypeMethodDescriptionvoidbroadcastRequestCanceled(long workId) Broadcasts a committed cancel of a request asProcessesEvents.REQUEST_CANCELED, with the request's task as source and its project as data.claimProjectMove(long workFlowId, String token, long now, long until) Claims the move of a process for one pass, when a move is pending, its next attempt is due and no other pass holds an unexpired claim.booleanclearLeftoverCancel(long workId) Clears the cancelled mark of a request whose task was just completed, unless that completion is the one a cancel runs on the current thread throughsaveRequestState(long, Boolean, Boolean, Boolean): a mark seen at any other completion was left by a cancel interrupted before its task's completion.booleanclearProjectMove(long workFlowId, long seq, String token, long now) Clears the move flag of a process; written only when no save changed the project since the pass started and the pass still holds an unexpired claim.completeRequest(Work request, Work work, long userId) Ends a new request's creation once its values are written: moves its draft's attachments, deletes its draft and announces it, then announces the request.voidcopyProcessAttachmentsToDraft(Long draftId, WorkFlow workFlow, long userId) Copies a process's attachments into a new request draft, as a draft's creation does.longcountRequests(long workFlowId) Counts the requests of a process whose task still exists.longcountRequests(long workFlowId, boolean completed) Counts the requests of a process whose task still exists and is, or is not, completed, whatever project the task is in.longcountRequests(Collection<Long> workFlowIds, Boolean completed) Counts the requests of several processes whose task still exists, open, completed or all, whatever project the task is in.longcountRequestsOutsideProject(long workFlowId, long projectId) Counts the requests of a process whose task still exists and is not in the given project.longcountWorkDrafts(long workFlowId) Counts a process's drafts.intcountWorkFlows(ProcessesFilter processesFilter) intcountWorks(long userIdentityId, WorkFilter workFilter) Counts the requests a user created that match a filter, asgetWorks(long, WorkFilter, int, int)lists them.intcountWorksByWorkflow(long projectId, boolean isCompleted) createProject(WorkFlow workFlow) Creates the task project of a new process in its managing space, with Task's initial columns, and gives the process that project and the space's memberships.createRequest(Work work, long userId) Creates a new request's task, its request record and its process's labels: the first steps ofsaveWork(Work, long)for a new request, before its values are written.voiddeleteRequestRecord(long taskId) Deletes the request record of a task that no longer exists.voiddeleteWorkById(Long workId) Delete a work by its given idvoiddeleteWorkDraftById(long id) Delete a work draft by its given iddeleteWorkflowById(Long workflowId) Deletes a process, its drafts and its request records, in one transaction.findAllWorkDraftsByUser(WorkFilter workFilter, int offset, int limit, long userIdentityId) Retrieves a list of accessible WorkDraft, for a selected user.findAllWorkFlows(int offset, int limit) findAllWorkFlowsByUser(ProcessesFilter filter, int offset, int limit, long userIdentityId) Retrieves a list of accessible WorkFlows, for a selected user, by applying the designated filter.findDisabledWorkFlows(int offset, int limit) Retrieves a list of disabled workflows, The returned results will be of typeWorkFlowonly.findEnabledWorkFlows(int offset, int limit) findEnabledWorkFlowsByUser(ProcessesFilter filter, int offset, int limit, long userIdentityId) findProcessesOfProjects(List<Long> projectIds, long spaceId) Reads the processes of a space that feed some task projects, by title, the ids being read in chunks the database accepts as parameters.findWorkFlowRights(ProcessesFilter processesFilter, long userIdentityId) Lists every process the filter lists to a user, in one unpaged listing query, with at least its id, its enabled flag and the user's rights on it.findWorkFlows(ProcessesFilter processesFilter, long userIdentityId, int offset, int limit) Retrieves list of filtered workflowsRetrieves the list of available statuses in all workflowsgetDueProjectMoves(long now) Reads the processes whose move a pass may claim now.getIllustrationImageById(Long illustrationId) Retrieves an illustration image by its given idgetRequesterFormIds(long workFlowId) Reads the stored ids of the forms of a process's task project that its requesters fill, with no other read of the process.getRequestProjectIds(long workFlowId) Reads the task projects that hold the requests of a process, in one query: the current projects of its request tasks, which may differ from the process's stored project.getRequestRecordTaskIds(long workFlowId, long afterTaskId, int limit) Reads a page of the task ids of a process's request records, by task id, whether the task still exists or not.getRequestTaskIds(long workFlowId, Long afterTaskId, int limit) Reads one page of the tasks of a process's requests that still exist, by ascending id.getRequestWorkFlowId(long taskId) Reads the process a task was created for, from its request record.getRequestWorkFlowIds(Collection<Long> taskIds) Reads the processes of the tasks that are requests, one query per page of1000task ids.getStoredProjectId(long workFlowId) Reads the stored project of a process from the database, never from a copy loaded earlier.getWorkById(long id) getWorkById(long userIdentityId, long workId) Retrieves a Work by its given idgetWorkDraftIds(long workFlowId, Long afterDraftId, int limit) Reads one page of a process's draft ids, by ascending id.getWorkDraftRefs(Collection<Long> draftIds) Reads what describes some request drafts, one query per page of 1,000 ids.getWorkDraftyId(long id) Retrieves a work draft by its given idgetWorkFlowById(long id, Long userIdentityId) getWorkFlowByProjectId(long projectId) Deprecated, for removal: This API element is subject to removal in a future version.a task project may now be fed by several processes: read the process of a request from its request record instead.getWorkFlowIdsByProjectId(long projectId) Reads the ids of every process feeding a task project.getWorks(long userIdentityId, WorkFilter workFilter, int offset, int limit) Retrieves list of filtered worksvoidlinkWorkFlowAttachments(WorkFlow savedWorkFlow, org.exoplatform.services.attachments.model.Attachment[] attachments, long userId) Links attachments to a saved process, in the process's project.moveTaskToProject(long taskId, long projectId) Moves a request's task to a project, unless it is already there or no longer exists: first its labels of its former project are removed, so that a task found in the target has nothing left to do; then it takes the target's column of the same name, read as a label only, else the one whose name equals it trimmed, case aside, of lowest id, else the target's first column, never creating one; then the task is saved.voidreleaseProjectMove(long workFlowId, String token) Releases the claim a pass holds, if it still holds it.voidremoveRequest(long taskId) Removes a request whose values were refused after its task was created: its task, then its record.renewProjectMove(long workFlowId, String token, long now, long until) Extends the claim a pass holds, while it has not expired.jakarta.persistence.criteria.PredicaterequestOf(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CommonAbstractCriteria query, jakarta.persistence.criteria.Expression<Long> taskId, Collection<Long> workFlowIds) Builds the restriction of a query to the tasks that are requests of some processes.voidrequestProjectMove(long workFlowId, String requestedBy, long now) Flags a process whose project the save changed, in the save's transaction: its requests may be outside its project until a pass moves them.booleanrescheduleProjectMove(long workFlowId, long seq, String token, long now, long nextAttempt, boolean failed) Schedules the next pass of a process's move, conditioned asclearProjectMove(long, long, String, long).saveRequestState(long workId, Boolean canceled, Boolean archived, Boolean completed) Writes a request's own state, which no column of its task project carries: the requester's cancel and archive flags on its request record, and its task's completion; when the completion fails, the flags are written back as they were, unless that write fails too, and the completion's failure is thrown.Saving a work and deletes its related draft if it was created from draftsaveWorkDraft(Work work, long userId) Save a draft of a worksaveWorkDraftRow(Work work, long userId) Saves a request draft's row only: whatsaveWorkDraft(Work, long)does but the copy of its process's attachments into a new draft.saveWorkFlow(WorkFlow workFlow, long userId) Saves a process's own rows: the process, its illustration and its label ids.booleanstopProjectMove(long workFlowId, long seq, String token) Stops the move of a process whose project no longer exists, until a save sets another project; written only when no save changed the project since the pass started and the pass still holds the claim.updateWorkCompleted(Long workId, boolean completed) update the completed property of the task of a work to completed or uncompleted
-
Method Details
-
findAllWorkFlowsByUser
List<WorkFlow> findAllWorkFlowsByUser(ProcessesFilter filter, int offset, int limit, long userIdentityId) Retrieves a list of accessible WorkFlows, for a selected user, by applying the designated filter. The returned results will be of typeWorkFlowonly. The ownerId of filter object will be used to select the list of accessible WorkFlows to retrieve.- Parameters:
filter-ProcessesFilterthat contains filtering criteriaoffset- Offset of the result listlimit- Limit of the result listuserIdentityId-Identitytechnical identifier of the user acessing files- Returns:
ListofWorkFlow
-
findEnabledWorkFlowsByUser
List<WorkFlow> findEnabledWorkFlowsByUser(ProcessesFilter filter, int offset, int limit, long userIdentityId) -
findAllWorkFlows
-
findEnabledWorkFlows
-
findDisabledWorkFlows
-
getWorkFlowById
-
getRequesterFormIds
-
getWorkFlowByProjectId
Deprecated, for removal: This API element is subject to removal in a future version.a task project may now be fed by several processes: read the process of a request from its request record instead. Since 7.3.0.50, for removal.Reads the first process feeding a task project.- Parameters:
projectId- the task project id- Returns:
- the process of lowest id feeding it, or null when none does
-
findProcessesOfProjects
Reads the processes of a space that feed some task projects, by title, the ids being read in chunks the database accepts as parameters.- Parameters:
projectIds- the task project idsspaceId- the managing space id the processes must have- Returns:
- the processes of each project that has some
-
saveWorkFlow
Saves a process's own rows: the process, its illustration and its label ids. It writes nothing through Task, whose labels it only reads back, so it may run inside one transaction; a new process's project is created before it (createProject(WorkFlow)), and its attachments are linked after it (linkWorkFlowAttachments(WorkFlow, Attachment[], long)).- Parameters:
workFlow- the process, whose labels the Service resolved to labels of its project; null labels keep the stored ones of an updateuserId- the saving user's identity id- Returns:
- the saved process
- Throws:
IllegalArgumentException- when the process or the user is missing, a new process has no project yet, or a label has no id
-
createProject
Creates the task project of a new process in its managing space, with Task's initial columns, and gives the process that project and the space's memberships. Task commits each write on its own.- Parameters:
workFlow- the new process- Returns:
- the process, with its project id
- Throws:
IllegalArgumentException- when the managing space does not exist
-
linkWorkFlowAttachments
void linkWorkFlowAttachments(WorkFlow savedWorkFlow, org.exoplatform.services.attachments.model.Attachment[] attachments, long userId) Links attachments to a saved process, in the process's project.- Parameters:
savedWorkFlow- the saved processattachments- the attachments the Service selecteduserId- the saving user's identity id
-
getWorks
List<Work> getWorks(long userIdentityId, WorkFilter workFilter, int offset, int limit) throws Exception Retrieves list of filtered works -
countWorks
Counts the requests a user created that match a filter, asgetWorks(long, WorkFilter, int, int)lists them.- Parameters:
userIdentityId- the creator's identity idworkFilter- the filter: status, text and completion- Returns:
- the count
- Throws:
Exception- when the Task add-on fails to count
-
getWorkById
-
saveWork
Saving a work and deletes its related draft if it was created from draft- Parameters:
work- Work ObjectuserId- user Id- Returns:
Work- Throws:
IllegalArgumentException
-
createRequest
Creates a new request's task, its request record and its process's labels: the first steps ofsaveWork(Work, long)for a new request, before its values are written.- Parameters:
work- the new request, its project setuserId- the requester's identity id- Returns:
- the request, its id being its task's
- Throws:
IllegalStateException- when the record cannot be saved, the task being removed
-
completeRequest
Ends a new request's creation once its values are written: moves its draft's attachments, deletes its draft and announces it, then announces the request.- Parameters:
request- the requestcreateRequest(Work, long)answeredwork- the new request as submitted, with its draft iduserId- the requester's identity id- Returns:
- the created request
-
removeRequest
void removeRequest(long taskId) Removes a request whose values were refused after its task was created: its task, then its record. A failure of either is logged, so the caller answers the refusal that made it remove the request.- Parameters:
taskId- the request's task id
-
deleteWorkflowById
ProcessDeletion deleteWorkflowById(Long workflowId) throws jakarta.persistence.EntityNotFoundException Deletes a process, its drafts and its request records, in one transaction. The request tasks stay as plain tasks.- Parameters:
workflowId- the process id- Returns:
- the task ids its request records held and the ids of its drafts
- Throws:
jakarta.persistence.EntityNotFoundException- when the process does not exist
-
getWorkById
-
countWorksByWorkflow
-
deleteWorkById
-
updateWorkCompleted
-
saveRequestState
Writes a request's own state, which no column of its task project carries: the requester's cancel and archive flags on its request record, and its task's completion; when the completion fails, the flags are written back as they were, unless that write fails too, and the completion's failure is thrown. It is the platform's own write, with no user's permission: the caller checks the user's right.- Parameters:
workId- the request's task idcanceled- the cancelled flag to write, null to keep itarchived- the archived flag to write, null to keep itcompleted- the task's completion to write, null to keep it- Returns:
- the request as stored after the write
-
clearLeftoverCancel
boolean clearLeftoverCancel(long workId) Clears the cancelled mark of a request whose task was just completed, unless that completion is the one a cancel runs on the current thread throughsaveRequestState(long, Boolean, Boolean, Boolean): a mark seen at any other completion was left by a cancel interrupted before its task's completion. It is the platform's own write, with no user's permission.- Parameters:
workId- the completed request's task id- Returns:
- true when a leftover mark was cleared, false when the task has no request record, the record has no mark, or the completion is the cancel's own
-
broadcastRequestCanceled
void broadcastRequestCanceled(long workId) Broadcasts a committed cancel of a request asProcessesEvents.REQUEST_CANCELED, with the request's task as source and its project as data.- Parameters:
workId- the cancelled request's task id
-
findAllWorkDraftsByUser
List<Work> findAllWorkDraftsByUser(WorkFilter workFilter, int offset, int limit, long userIdentityId) Retrieves a list of accessible WorkDraft, for a selected user. -
saveWorkDraft
-
saveWorkDraftRow
Saves a request draft's row only: whatsaveWorkDraft(Work, long)does but the copy of its process's attachments into a new draft. The server sets the row's draft state.- Parameters:
work- the draftuserId- the owner's identity id- Returns:
- the saved draft
-
copyProcessAttachmentsToDraft
-
getWorkDraftyId
-
deleteWorkDraftById
void deleteWorkDraftById(long id) throws jakarta.persistence.EntityNotFoundException Delete a work draft by its given id- Parameters:
id- Work draft id- Throws:
jakarta.persistence.EntityNotFoundException
-
getAvailableWorkStatuses
List<WorkStatus> getAvailableWorkStatuses()Retrieves the list of available statuses in all workflows- Returns:
ListofWorkStatus
-
findWorkFlows
List<WorkFlow> findWorkFlows(ProcessesFilter processesFilter, long userIdentityId, int offset, int limit) Retrieves list of filtered workflows -
findWorkFlowRights
Lists every process the filter lists to a user, in one unpaged listing query, with at least its id, its enabled flag and the user's rights on it. The rights read each process's managers and participators. An implementation should map nothing else (no request makers, illustration, managing space or pending-requests flag); this default falls back to the full, unpaged listing.- Parameters:
processesFilter- processes filteruserIdentityId-Identitytechnical identifier of the user- Returns:
- every process listed, with its
acl(the user's rights on it) set
-
getIllustrationImageById
IllustrativeAttachment getIllustrationImageById(Long illustrationId) throws org.exoplatform.commons.file.services.FileStorageException, org.exoplatform.commons.exception.ObjectNotFoundException, IOException Retrieves an illustration image by its given id- Parameters:
illustrationId- illustration file id- Returns:
IllustrativeAttachment- Throws:
org.exoplatform.commons.file.services.FileStorageExceptionorg.exoplatform.commons.exception.ObjectNotFoundExceptionIOException
-
countWorkFlows
-
getRequestWorkFlowId
Reads the process a task was created for, from its request record. It is the platform's own read, with no user's permission: a caller that serves a user checks that user's rights on what it returns.- Parameters:
taskId- the task id- Returns:
- the id of the process whose request the task is, or null when the task is no request
-
getRequestWorkFlowIds
Reads the processes of the tasks that are requests, one query per page of1000task ids. It is the platform's own read, with no user's permission.- Parameters:
taskIds- the task ids- Returns:
- task id → process id, for the tasks that have a request record
-
getRequestTaskIds
Reads one page of the tasks of a process's requests that still exist, by ascending id. It is the platform's own read, with no user's permission.- Parameters:
workFlowId- the process idafterTaskId- the last task id of the previous page, or null for the first pagelimit- the page size, strictly positive- Returns:
- the task ids of the page, ascending
-
getRequestProjectIds
Reads the task projects that hold the requests of a process, in one query: the current projects of its request tasks, which may differ from the process's stored project. It is the platform's own read, with no user's permission.- Parameters:
workFlowId- the process id- Returns:
- the distinct project ids
-
countRequests
long countRequests(long workFlowId) Counts the requests of a process whose task still exists. It is the platform's own read, with no user's permission.- Parameters:
workFlowId- the process id- Returns:
- the number of request tasks of the process
-
countRequests
long countRequests(long workFlowId, boolean completed) Counts the requests of a process whose task still exists and is, or is not, completed, whatever project the task is in. It is the platform's own read, with no user's permission.- Parameters:
workFlowId- the process idcompleted- true to count the completed requests, false the open ones- Returns:
- the number of request tasks of the process in that state
-
countRequests
Counts the requests of several processes whose task still exists, open, completed or all, whatever project the task is in. It is the platform's own read, with no user's permission.- Parameters:
workFlowIds- the process idscompleted- true to count the completed requests, false the open ones, null for all- Returns:
- the number of request tasks of those processes in that state
-
getWorkFlowIdsByProjectId
-
requestOf
jakarta.persistence.criteria.Predicate requestOf(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CommonAbstractCriteria query, jakarta.persistence.criteria.Expression<Long> taskId, Collection<Long> workFlowIds) Builds the restriction of a query to the tasks that are requests of some processes. SeeProcessesService.requestOf(CriteriaBuilder, CommonAbstractCriteria, Expression, Collection).- Parameters:
cb- the criteria builder of the queryquery- the query, to create the subquery fromtaskId- the task id expression of the queryworkFlowIds- the process ids- Returns:
- the restriction; one that no task meets when no process is given
-
getWorkDraftRefs
Reads what describes some request drafts, one query per page of 1,000 ids. The platform's own read, with no user's permission.- Parameters:
draftIds- the draft ids- Returns:
- draft id → its owner, process, title and dates, for the ids that are drafts
-
getWorkDraftIds
Reads one page of a process's draft ids, by ascending id. The platform's own read, with no user's permission.- Parameters:
workFlowId- the process idafterDraftId- the last id of the previous page, or nulllimit- the page size, strictly positive- Returns:
- the draft ids of the page
-
countWorkDrafts
long countWorkDrafts(long workFlowId) Counts a process's drafts. The platform's own read, with no user's permission.- Parameters:
workFlowId- the process id- Returns:
- the number of drafts
-
requestProjectMove
Flags a process whose project the save changed, in the save's transaction: its requests may be outside its project until a pass moves them. The move sequence is incremented and the next attempt is due at once.- Parameters:
workFlowId- the process idrequestedBy- the user id of the editor who changed the projectnow- the current time, in epoch milliseconds
-
claimProjectMove
Claims the move of a process for one pass, when a move is pending, its next attempt is due and no other pass holds an unexpired claim.- Parameters:
workFlowId- the process idtoken- the pass's own random tokennow- the current time, in epoch millisecondsuntil- when the claim expires, in epoch milliseconds- Returns:
- the state the pass starts from, or null when it holds no claim
-
renewProjectMove
Extends the claim a pass holds, while it has not expired.- Parameters:
workFlowId- the process idtoken- the pass's tokennow- the current time, in epoch millisecondsuntil- the new expiry, in epoch milliseconds- Returns:
- the state the move is in, or null when the pass no longer holds the claim
-
releaseProjectMove
Releases the claim a pass holds, if it still holds it.- Parameters:
workFlowId- the process idtoken- the pass's token
-
stopProjectMove
Stops the move of a process whose project no longer exists, until a save sets another project; written only when no save changed the project since the pass started and the pass still holds the claim.- Parameters:
workFlowId- the process idseq- the move sequence the pass started withtoken- the pass's token- Returns:
- true when the move was stopped
-
clearProjectMove
Clears the move flag of a process; written only when no save changed the project since the pass started and the pass still holds an unexpired claim.- Parameters:
workFlowId- the process idseq- the move sequence the pass started withtoken- the pass's tokennow- the current time, in epoch milliseconds- Returns:
- true when the flag was cleared
-
rescheduleProjectMove
boolean rescheduleProjectMove(long workFlowId, long seq, String token, long now, long nextAttempt, boolean failed) Schedules the next pass of a process's move, conditioned asclearProjectMove(long, long, String, long).- Parameters:
workFlowId- the process idseq- the move sequence the pass started withtoken- the pass's tokennow- the current time, in epoch millisecondsnextAttempt- when the next pass is due, in epoch millisecondsfailed- true to count a failed attempt, false for the verification pass after a pass that moved requests- Returns:
- true when the next pass was scheduled
-
getDueProjectMoves
-
getStoredProjectId
Reads the stored project of a process from the database, never from a copy loaded earlier.- Parameters:
workFlowId- the process id- Returns:
- its project id, or null when the process does not exist
-
getRequestRecordTaskIds
Reads a page of the task ids of a process's request records, by task id, whether the task still exists or not.- Parameters:
workFlowId- the process idafterTaskId- the last task id of the previous page, 0 for the firstlimit- the page size, strictly positive- Returns:
- the task ids, ascending
-
deleteRequestRecord
void deleteRequestRecord(long taskId) Deletes the request record of a task that no longer exists.- Parameters:
taskId- the task id
-
countRequestsOutsideProject
long countRequestsOutsideProject(long workFlowId, long projectId) Counts the requests of a process whose task still exists and is not in the given project.- Parameters:
workFlowId- the process idprojectId- the project the requests should be in- Returns:
- the number of those requests
-
moveTaskToProject
Moves a request's task to a project, unless it is already there or no longer exists: first its labels of its former project are removed, so that a task found in the target has nothing left to do; then it takes the target's column of the same name, read as a label only, else the one whose name equals it trimmed, case aside, of lowest id, else the target's first column, never creating one; then the task is saved. A target with no column refuses the move with an IllegalArgumentException processes.project.noStatus. Each Task call commits on its own. The task is saved as read: a copy of it saved in Tasks after this read and before this save is overwritten, and the description goes through Task's sanitizer again, as on every task edit. As on every task edit, Task then queues on its shared asynchronous thread a rewrite of the whole target project from the project as read at this save, which undoes an edit of that project made in Tasks while the rewrite waits.- Parameters:
taskId- the task id, read again from TaskprojectId- the target project id- Returns:
- what the move did
-