Dynamic assignment flow

The DynamicUserAssignmentStrategy interface defines the following methods. (The Group version is equivalent.)

public Set getCandidateUsers(assignable, group, includeSubGroups)
public Set getLocksForAssignable(assignable, candidateUsers)
public GroupUser findUserToAssign(assignable, candidateGroups, locks)
boolean rollbackAssignment(assignable, assignedEntity)
Object getAssignmentToken(assignable)

The first three methods are the major methods on the interface. Your implementation of these interface methods must have the following assignment flow:

  1. Call DynamicUserAssignmentStrategy.getCandidateUsers, which returns a set of assignable candidates.
  2. Call DynamicUserAssignmentStrategy.getLocksForAssignable, passing in the set of candidates. It returns a set of entities. You must lock the rows in the database for these entities.
  3. Open a new database transaction.
  4. For each entity in the set of locks, lock that row in the transaction.
  5. Call DynamicUserAssignmentStrategy.findUserToAssign, passing in the two sets generated in step 1 and step 2 previously. That method returns a GroupUser entity representing the user and group that you need to assign.
  6. Commit the transaction, which results in the lock entities being updated and unlocked.

    Dynamic assignment is not complete after these steps. The interface methods allow for the failure of the commit operation by adding one last final step.

  7. If the commit fails, roll back all changes made to the user information, if possible. If this is not possible, save the user name and reassign that user to the assignable item later, during a future save operation.