public IdentityLinkEntity addIdentityLink(String userId, String groupId) {
   IdentityLinkEntity identityLinkEntity = IdentityLinkEntity.createAndInsert();
   getIdentityLinks().add(identityLinkEntity);
   identityLinkEntity.setProcessDef(this);
   identityLinkEntity.setUserId(userId);
   identityLinkEntity.setGroupId(groupId);
   identityLinkEntity.setType(IdentityLinkType.CANDIDATE);
   return identityLinkEntity;
 }
 public IdentityLinkEntity addIdentityLink(String userId, String groupId, String type) {
   IdentityLinkEntity identityLinkEntity = new IdentityLinkEntity();
   getIdentityLinks().add(identityLinkEntity);
   identityLinkEntity.setTask(this);
   identityLinkEntity.setUserId(userId);
   identityLinkEntity.setGroupId(groupId);
   identityLinkEntity.setType(type);
   identityLinkEntity.insert();
   if (userId != null && processInstanceId != null) {
     getProcessInstance().involveUser(userId, IdentityLinkType.PARTICIPANT);
   }
   return identityLinkEntity;
 }
 private void addAuthorizationsFromIterator(
     Set<Expression> exprSet, ProcessDefinitionEntity processDefinition, ExprType exprType) {
   if (exprSet != null) {
     Iterator<Expression> iterator = exprSet.iterator();
     while (iterator.hasNext()) {
       Expression expr = (Expression) iterator.next();
       IdentityLinkEntity identityLink = new IdentityLinkEntity();
       identityLink.setProcessDef(processDefinition);
       if (exprType.equals(ExprType.USER)) {
         identityLink.setUserId(expr.toString());
       } else if (exprType.equals(ExprType.GROUP)) {
         identityLink.setGroupId(expr.toString());
       }
       identityLink.setType(IdentityLinkType.CANDIDATE);
       identityLink.insert();
     }
   }
 }