Interface ProcessesStorage


public interface ProcessesStorage
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Broadcasts a committed cancel of a request as ProcessesEvents.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.
    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 through saveRequestState(long, Boolean, Boolean, Boolean): a mark seen at any other completion was left by a cancel interrupted before its task's completion.
    boolean
    clearProjectMove(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.
    void
    copyProcessAttachmentsToDraft(Long draftId, WorkFlow workFlow, long userId)
    Copies a process's attachments into a new request draft, as a draft's creation does.
    long
    countRequests(long workFlowId)
    Counts the requests of a process whose task still exists.
    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.
    long
    countRequests(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.
    long
    countRequestsOutsideProject(long workFlowId, long projectId)
    Counts the requests of a process whose task still exists and is not in the given project.
    long
    countWorkDrafts(long workFlowId)
    Counts a process's drafts.
    int
     
    int
    countWorks(long userIdentityId, WorkFilter workFilter)
    Counts the requests a user created that match a filter, as getWorks(long, WorkFilter, int, int) lists them.
    int
    countWorksByWorkflow(long projectId, boolean isCompleted)
     
    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 of saveWork(Work, long) for a new request, before its values are written.
    void
    deleteRequestRecord(long taskId)
    Deletes the request record of a task that no longer exists.
    void
    Delete a work by its given id
    void
    Delete a work draft by its given id
    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 type WorkFlow only.
    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.
    default List<WorkFlow>
    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 workflows
    Retrieves the list of available statuses in all workflows
    Reads the processes whose move a pass may claim now.
    Retrieves an illustration image by its given id
    getRequesterFormIds(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.
    Reads the processes of the tasks that are requests, one query per page of 1000 task 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 id
    getWorkDraftIds(long workFlowId, Long afterDraftId, int limit)
    Reads one page of a process's draft ids, by ascending id.
    Reads what describes some request drafts, one query per page of 1,000 ids.
    getWorkDraftyId(long id)
    Retrieves a work draft by its given id
    getWorkFlowById(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 works
    void
    linkWorkFlowAttachments(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.
    void
    releaseProjectMove(long workFlowId, String token)
    Releases the claim a pass holds, if it still holds it.
    void
    removeRequest(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.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.
    void
    requestProjectMove(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.
    boolean
    rescheduleProjectMove(long workFlowId, long seq, String token, long now, long nextAttempt, boolean failed)
    Schedules the next pass of a process's move, conditioned as clearProjectMove(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.
    saveWork(Work work, long userId)
    Saving a work and deletes its related draft if it was created from draft
    saveWorkDraft(Work work, long userId)
    Save a draft of a work
    saveWorkDraftRow(Work work, long userId)
    Saves a request draft's row only: what saveWorkDraft(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.
    boolean
    stopProjectMove(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 type WorkFlow only. The ownerId of filter object will be used to select the list of accessible WorkFlows to retrieve.
      Parameters:
      filter - ProcessesFilter that contains filtering criteria
      offset - Offset of the result list
      limit - Limit of the result list
      userIdentityId - Identity technical identifier of the user acessing files
      Returns:
      List of WorkFlow
    • findEnabledWorkFlowsByUser

      List<WorkFlow> findEnabledWorkFlowsByUser(ProcessesFilter filter, int offset, int limit, long userIdentityId)
    • findAllWorkFlows

      List<WorkFlow> findAllWorkFlows(int offset, int limit)
    • findEnabledWorkFlows

      List<WorkFlow> findEnabledWorkFlows(int offset, int limit)
    • findDisabledWorkFlows

      List<WorkFlow> findDisabledWorkFlows(int offset, int limit)
      Retrieves a list of disabled workflows, The returned results will be of type WorkFlow only.
      Parameters:
      offset - Offset of the result list
      limit - Limit of the result list
      Returns:
      List of WorkFlow
    • getWorkFlowById

      WorkFlow getWorkFlowById(long id, Long userIdentityId)
    • getRequesterFormIds

      List<Long> getRequesterFormIds(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.
      Parameters:
      workFlowId - the process id
      Returns:
      the form ids, in id order; empty when the process does not exist
    • getWorkFlowByProjectId

      @Deprecated(since="7.3.0.50", forRemoval=true) WorkFlow 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. 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

      Map<Long, List<ProcessReference>> 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.
      Parameters:
      projectIds - the task project ids
      spaceId - the managing space id the processes must have
      Returns:
      the processes of each project that has some
    • saveWorkFlow

      WorkFlow saveWorkFlow(WorkFlow workFlow, long userId) throws IllegalArgumentException
      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 update
      userId - 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

      WorkFlow 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. 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 process
      attachments - the attachments the Service selected
      userId - 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
      Parameters:
      userIdentityId - user identity ide
      workFilter - works filter
      offset - Offset of the result list
      limit - Limit of the result list
      Returns:
      List of Work
      Throws:
      Exception
    • countWorks

      int countWorks(long userIdentityId, WorkFilter workFilter) throws Exception
      Counts the requests a user created that match a filter, as getWorks(long, WorkFilter, int, int) lists them.
      Parameters:
      userIdentityId - the creator's identity id
      workFilter - the filter: status, text and completion
      Returns:
      the count
      Throws:
      Exception - when the Task add-on fails to count
    • getWorkById

      Work getWorkById(long id)
    • saveWork

      Work saveWork(Work work, long userId) throws IllegalArgumentException
      Saving a work and deletes its related draft if it was created from draft
      Parameters:
      work - Work Object
      userId - user Id
      Returns:
      Work
      Throws:
      IllegalArgumentException
    • createRequest

      Work createRequest(Work work, long userId)
      Creates a new request's task, its request record and its process's labels: the first steps of saveWork(Work, long) for a new request, before its values are written.
      Parameters:
      work - the new request, its project set
      userId - 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

      Work 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.
      Parameters:
      request - the request createRequest(Work, long) answered
      work - the new request as submitted, with its draft id
      userId - 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

      Work getWorkById(long userIdentityId, long workId) throws jakarta.persistence.EntityNotFoundException
      Retrieves a Work by its given id
      Parameters:
      userIdentityId - user identity id
      workId - Work id
      Returns:
      Work
      Throws:
      jakarta.persistence.EntityNotFoundException
    • countWorksByWorkflow

      int countWorksByWorkflow(long projectId, boolean isCompleted) throws Exception
      Parameters:
      projectId - : Tasks project id
      isCompleted - : filter by completed and uncompleted tasks
      Returns:
      Filtered tasks count
      Throws:
      Exception
    • deleteWorkById

      void deleteWorkById(Long workId)
      Delete a work by its given id
      Parameters:
      workId - : Work id
    • updateWorkCompleted

      Work updateWorkCompleted(Long workId, boolean completed)
      update the completed property of the task of a work to completed or uncompleted
      Parameters:
      workId - work id
      completed - work completed property, can be true or false
      Returns:
      Work
    • saveRequestState

      Work 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. 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 id
      canceled - the cancelled flag to write, null to keep it
      archived - the archived flag to write, null to keep it
      completed - 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 through saveRequestState(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 as ProcessesEvents.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.
      Parameters:
      workFilter - work filter
      offset - Offset of the result list
      limit - Limit of the result list
      userIdentityId - Identity technical identifier of the user
      Returns:
      List of Work
    • saveWorkDraft

      Work saveWorkDraft(Work work, long userId)
      Save a draft of a work
      Parameters:
      work - work draft object
      userId - user id of the creator
      Returns:
      Work
    • saveWorkDraftRow

      Work saveWorkDraftRow(Work work, long userId)
      Saves a request draft's row only: what saveWorkDraft(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 draft
      userId - the owner's identity id
      Returns:
      the saved draft
    • copyProcessAttachmentsToDraft

      void copyProcessAttachmentsToDraft(Long draftId, WorkFlow workFlow, long userId)
      Copies a process's attachments into a new request draft, as a draft's creation does.
      Parameters:
      draftId - the new draft's id
      workFlow - the draft's stored process
      userId - the owner's identity id
    • getWorkDraftyId

      Work getWorkDraftyId(long id)
      Retrieves a work draft by its given id
      Parameters:
      id - Work draft id
      Returns:
      Work
    • 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:
      List of WorkStatus
    • findWorkFlows

      List<WorkFlow> findWorkFlows(ProcessesFilter processesFilter, long userIdentityId, int offset, int limit)
      Retrieves list of filtered workflows
      Parameters:
      processesFilter - processes filter
      userIdentityId - Identity technical identifier of the user
      offset - Offset of result list
      limit - limit of result list
      Returns:
      List of WorkFlow
    • findWorkFlowRights

      default List<WorkFlow> 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. 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 filter
      userIdentityId - Identity technical 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.FileStorageException
      org.exoplatform.commons.exception.ObjectNotFoundException
      IOException
    • countWorkFlows

      int countWorkFlows(ProcessesFilter processesFilter)
    • getRequestWorkFlowId

      Long getRequestWorkFlowId(long taskId)
      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

      Map<Long,Long> getRequestWorkFlowIds(Collection<Long> taskIds)
      Reads the processes of the tasks that are requests, one query per page of 1000 task 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

      List<Long> getRequestTaskIds(long workFlowId, Long afterTaskId, int limit)
      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 id
      afterTaskId - the last task id of the previous page, or null for the first page
      limit - the page size, strictly positive
      Returns:
      the task ids of the page, ascending
    • getRequestProjectIds

      Set<Long> 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. 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 id
      completed - true to count the completed requests, false the open ones
      Returns:
      the number of request tasks of the process in that state
    • countRequests

      long countRequests(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. It is the platform's own read, with no user's permission.
      Parameters:
      workFlowIds - the process ids
      completed - 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

      List<Long> getWorkFlowIdsByProjectId(long projectId)
      Reads the ids of every process feeding a task project.
      Parameters:
      projectId - the task project id
      Returns:
      the process ids, ascending
    • 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. See ProcessesService.requestOf(CriteriaBuilder, CommonAbstractCriteria, Expression, Collection).
      Parameters:
      cb - the criteria builder of the query
      query - the query, to create the subquery from
      taskId - the task id expression of the query
      workFlowIds - the process ids
      Returns:
      the restriction; one that no task meets when no process is given
    • getWorkDraftRefs

      Map<Long, WorkDraftRef> getWorkDraftRefs(Collection<Long> draftIds)
      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

      List<Long> getWorkDraftIds(long workFlowId, Long afterDraftId, int limit)
      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 id
      afterDraftId - the last id of the previous page, or null
      limit - 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

      void requestProjectMove(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. The move sequence is incremented and the next attempt is due at once.
      Parameters:
      workFlowId - the process id
      requestedBy - the user id of the editor who changed the project
      now - the current time, in epoch milliseconds
    • claimProjectMove

      ProjectMoveState 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.
      Parameters:
      workFlowId - the process id
      token - the pass's own random token
      now - the current time, in epoch milliseconds
      until - when the claim expires, in epoch milliseconds
      Returns:
      the state the pass starts from, or null when it holds no claim
    • renewProjectMove

      ProjectMoveState renewProjectMove(long workFlowId, String token, long now, long until)
      Extends the claim a pass holds, while it has not expired.
      Parameters:
      workFlowId - the process id
      token - the pass's token
      now - the current time, in epoch milliseconds
      until - the new expiry, in epoch milliseconds
      Returns:
      the state the move is in, or null when the pass no longer holds the claim
    • releaseProjectMove

      void releaseProjectMove(long workFlowId, String token)
      Releases the claim a pass holds, if it still holds it.
      Parameters:
      workFlowId - the process id
      token - the pass's token
    • stopProjectMove

      boolean stopProjectMove(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.
      Parameters:
      workFlowId - the process id
      seq - the move sequence the pass started with
      token - the pass's token
      Returns:
      true when the move was stopped
    • clearProjectMove

      boolean clearProjectMove(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.
      Parameters:
      workFlowId - the process id
      seq - the move sequence the pass started with
      token - the pass's token
      now - 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 as clearProjectMove(long, long, String, long).
      Parameters:
      workFlowId - the process id
      seq - the move sequence the pass started with
      token - the pass's token
      now - the current time, in epoch milliseconds
      nextAttempt - when the next pass is due, in epoch milliseconds
      failed - 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

      List<Long> getDueProjectMoves(long now)
      Reads the processes whose move a pass may claim now.
      Parameters:
      now - the current time, in epoch milliseconds
      Returns:
      their ids, the most overdue first
    • getStoredProjectId

      Long getStoredProjectId(long workFlowId)
      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

      List<Long> 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.
      Parameters:
      workFlowId - the process id
      afterTaskId - the last task id of the previous page, 0 for the first
      limit - 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 id
      projectId - the project the requests should be in
      Returns:
      the number of those requests
    • moveTaskToProject

      TaskMoveResult 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. 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 Task
      projectId - the target project id
      Returns:
      what the move did