本文整理汇总了Java中org.activiti.engine.TaskService.getIdentityLinksForTask方法的典型用法代码示例。如果您正苦于以下问题:Java TaskService.getIdentityLinksForTask方法的具体用法?Java TaskService.getIdentityLinksForTask怎么用?Java TaskService.getIdentityLinksForTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.TaskService
的用法示例。
在下文中一共展示了TaskService.getIdentityLinksForTask方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setNewAssignees
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
private void setNewAssignees(Task task, List<ObjectReferenceType> assigneeRefList, TaskService taskService) {
List<String> assignees = MiscDataUtil.refsToStrings(assigneeRefList);
// check and optionally set task assignee
if (task.getAssignee() != null && !assignees.contains(task.getAssignee())
|| task.getAssignee() == null && !assignees.isEmpty()) {
// we will nominate the first delegate (if present) as a new assignee
taskService.setAssignee(task.getId(), !assignees.isEmpty() ? assignees.get(0) : null);
}
// set task identity links
List<IdentityLink> currentLinks = taskService.getIdentityLinksForTask(task.getId());
for (IdentityLink currentLink : currentLinks) {
if (!CommonProcessVariableNames.MIDPOINT_ASSIGNEE.equals(currentLink.getType())) {
continue;
}
String assigneeFromLink = currentLink.getUserId() != null ? currentLink.getUserId() : currentLink.getGroupId();
if (assignees.contains(assigneeFromLink)) {
assignees.remove(assigneeFromLink);
} else {
if (currentLink.getUserId() != null) {
taskService.deleteUserIdentityLink(task.getId(), currentLink.getUserId(), CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
} else {
taskService.deleteGroupIdentityLink(task.getId(), currentLink.getGroupId(), CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
}
}
}
// process remaining assignees
for (String assignee : assignees) {
ObjectReferenceType assigneeRef = MiscDataUtil.stringToRef(assignee);
if (assigneeRef.getType() == null || QNameUtil.match(UserType.COMPLEX_TYPE, assigneeRef.getType())) {
taskService.addUserIdentityLink(task.getId(), assignee, CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
} else {
taskService.addGroupIdentityLink(task.getId(), assignee, CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
}
}
}
示例2: isAmongCandidates
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
private boolean isAmongCandidates(MidPointPrincipal principal, String taskId) {
String currentUserOid = principal.getOid();
List<IdentityLink> identityLinks;
try {
TaskService taskService = activitiEngine.getTaskService();
// working around activiti bug, see MID-3799.6 (the NPE when task does not exist)
org.activiti.engine.task.Task task = taskService.createTaskQuery()
.taskId(taskId)
.singleResult();
if (task == null) {
return false;
}
identityLinks = taskService.getIdentityLinksForTask(taskId);
} catch (ActivitiException e) {
throw new SystemException("Couldn't determine user authorization, because the task candidate users and groups couldn't be retrieved: " + e.getMessage(), e);
}
for (IdentityLink identityLink : identityLinks) {
if (identityLink.getUserId() != null && identityLink.getUserId().equals(currentUserOid)) {
return true;
}
if (identityLink.getGroupId() != null) {
if (isMemberOfActivitiGroup(principal.getUser(), identityLink.getGroupId())) {
return true;
}
}
}
return false;
}
示例3: getTaskProperties
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
public Map<QName, Serializable> getTaskProperties(Task task)
{
// retrieve type definition for task
TypeDefinition taskDef = typeManager.getFullTaskDefinition(task);
Map<QName, PropertyDefinition> taskProperties = taskDef.getProperties();
Map<QName, AssociationDefinition> taskAssociations = taskDef.getAssociations();
TaskService taskService = activitiUtil.getTaskService();
// Get all task variables including execution vars.
Map<String, Object> variables = taskService.getVariables(task.getId());
Map<String, Object> localVariables = taskService.getVariablesLocal(task.getId());
// Map the arbitrary properties
Map<QName, Serializable> properties =mapArbitraryProperties(variables, localVariables, taskProperties, taskAssociations);
// Map activiti task instance fields to properties
properties.put(WorkflowModel.PROP_TASK_ID, task.getId());
properties.put(WorkflowModel.PROP_DESCRIPTION, task.getDescription());
// Since the task is never started explicitally, we use the create time
properties.put(WorkflowModel.PROP_START_DATE, task.getCreateTime());
// Due date is present on the task
properties.put(WorkflowModel.PROP_DUE_DATE, task.getDueDate());
// Since this is a runtime-task, it's not completed yet
properties.put(WorkflowModel.PROP_COMPLETION_DATE, null);
properties.put(WorkflowModel.PROP_PRIORITY, task.getPriority());
properties.put(ContentModel.PROP_CREATED, task.getCreateTime());
properties.put(ContentModel.PROP_OWNER, task.getAssignee());
// Be sure to fetch the outcome
String outcomeVarName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME);
if(variables.get(outcomeVarName) != null)
{
properties.put(WorkflowModel.PROP_OUTCOME, (Serializable) variables.get(outcomeVarName));
}
List<IdentityLink> links = taskService.getIdentityLinksForTask(task.getId());
mapPooledActors(links, properties);
return filterTaskProperties(properties);
}
示例4: releaseWorkItem
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
public void releaseWorkItem(String workItemId, OperationResult parentResult) throws ObjectNotFoundException, SecurityViolationException {
OperationResult result = parentResult.createSubresult(OPERATION_RELEASE_WORK_ITEM);
result.addParam("workItemId", workItemId);
try {
MidPointPrincipal principal = securityEnforcer.getPrincipal();
result.addContext("user", toShortString(principal.getUser()));
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Releasing work item {} by {}", workItemId, toShortString(principal.getUser()));
}
TaskService taskService = activitiEngine.getTaskService();
Task task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
if (task.getAssignee() == null) {
throw new SystemException("The work item is not assigned to a user");
}
if (!MiscDataUtil.stringToRef(task.getAssignee()).getOid().equals(principal.getOid())) {
throw new SystemException("The work item is not assigned to the current user");
}
boolean candidateFound = false;
for (IdentityLink link : taskService.getIdentityLinksForTask(workItemId)) {
if (IdentityLinkType.CANDIDATE.equals(link.getType())) {
candidateFound = true;
break;
}
}
if (!candidateFound) {
throw new SystemException("It has no candidates to be offered to");
}
taskService.unclaim(workItemId);
task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
setNewAssignees(task, Collections.emptyList(), taskService);
} catch (ObjectNotFoundException|SecurityViolationException|RuntimeException e) {
result.recordFatalError("Couldn't release work item " + workItemId + ": " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
示例5: test210TestQueryByIdentityLink
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
@Test
public void test210TestQueryByIdentityLink() throws Exception {
final String TEST_NAME = "test210TestQueryByIdentityLink";
TestUtil.displayTestTile(this, TEST_NAME);
login(userAdministrator);
TaskService taskService = activitiEngine.getTaskService();
TaskQuery tq = taskService.createTaskQuery();
org.activiti.engine.task.Task task = tq.singleResult();
System.out.println("Task = " + task);
assertNotNull("No task", task);
final String TASK_NAME = "Approve assigning Role1a to jack";
List<IdentityLink> linksBefore = taskService.getIdentityLinksForTask(task.getId());
System.out.println("Identity links (before)" + linksBefore);
taskService.addUserIdentityLink(task.getId(), "123", CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
taskService.addUserIdentityLink(task.getId(), "456", CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
List<IdentityLink> linksAfter = taskService.getIdentityLinksForTask(task.getId());
System.out.println("Identity links (after)" + linksAfter);
TaskQuery tq1 = taskService.createTaskQuery()
.taskInvolvedUser("UserType:"+userLead1Oid)
.taskName(TASK_NAME);
assertFound(tq1, "involved user (assignee)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("123")
.taskName(TASK_NAME),
"involved user (midpoint-assignee 123)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("456")
.taskName(TASK_NAME),
"involved user (midpoint-assignee 456)");
assertNotFound(taskService.createTaskQuery()
.taskInvolvedUser("123xxx")
.taskName(TASK_NAME),
"involved user (wrong user)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("123;124")
.taskName(TASK_NAME),
"involved user (123 or 124)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("124;123")
.taskName(TASK_NAME),
"involved user (124 or 123)");
assertNotFound(taskService.createTaskQuery()
.taskInvolvedUser("124x;123x")
.taskName(TASK_NAME),
"involved user (124x or 123x)");
assertFound(taskService.createTaskQuery()
.or()
.taskInvolvedUser("123")
.taskCandidateGroup("xxxxxxx")
.endOr()
.taskName(TASK_NAME),
"involved user (123 or candidate group xxxxxxx)");
assertFound(taskService.createTaskQuery()
.or()
.taskInvolvedUser("123;124")
.taskCandidateGroup("xxxxxxx")
.endOr()
.taskName(TASK_NAME),
"involved user (123 or 124 or candidate group xxxxxxx)");
assertNotFound(taskService.createTaskQuery()
.or()
.taskInvolvedUser("123x;124x")
.taskCandidateGroup("xxxxxxx")
.endOr()
.taskName(TASK_NAME),
"involved user (123x or 124x or candidate group xxxxxxx)");
}
示例6: releaseWorkItem
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
public void releaseWorkItem(String workItemId, OperationResult parentResult) throws ObjectNotFoundException, SecurityViolationException {
OperationResult result = parentResult.createSubresult(OPERATION_RELEASE_WORK_ITEM);
result.addParam("workItemId", workItemId);
try {
MidPointPrincipal principal = securityContextManager.getPrincipal();
result.addContext("user", toShortString(principal.getUser()));
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Releasing work item {} by {}", workItemId, toShortString(principal.getUser()));
}
TaskService taskService = activitiEngine.getTaskService();
Task task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
if (task.getAssignee() == null) {
throw new SystemException("The work item is not assigned to a user");
}
if (!MiscDataUtil.stringToRef(task.getAssignee()).getOid().equals(principal.getOid())) {
throw new SystemException("The work item is not assigned to the current user");
}
boolean candidateFound = false;
for (IdentityLink link : taskService.getIdentityLinksForTask(workItemId)) {
if (IdentityLinkType.CANDIDATE.equals(link.getType())) {
candidateFound = true;
break;
}
}
if (!candidateFound) {
result.recordStatus(OperationResultStatus.NOT_APPLICABLE, "There are no candidates this work item can be offered to");
return;
}
taskService.unclaim(workItemId);
task = taskService.createTaskQuery().taskId(workItemId).singleResult();
if (task == null) {
throw new ObjectNotFoundException("The work item does not exist");
}
setNewAssignees(task, Collections.emptyList(), taskService);
} catch (ObjectNotFoundException|SecurityViolationException|RuntimeException e) {
result.recordFatalError("Couldn't release work item " + workItemId + ": " + e.getMessage(), e);
throw e;
} finally {
result.computeStatusIfUnknown();
}
}
示例7: test210TestQueryByIdentityLink
import org.activiti.engine.TaskService; //导入方法依赖的package包/类
@Test
public void test210TestQueryByIdentityLink() throws Exception {
final String TEST_NAME = "test210TestQueryByIdentityLink";
TestUtil.displayTestTitle(this, TEST_NAME);
login(userAdministrator);
TaskService taskService = activitiEngine.getTaskService();
TaskQuery tq = taskService.createTaskQuery();
org.activiti.engine.task.Task task = tq.singleResult();
System.out.println("Task = " + task);
assertNotNull("No task", task);
final String TASK_NAME = "Assigning role \"Role1a\" to user \"jack\"";
List<IdentityLink> linksBefore = taskService.getIdentityLinksForTask(task.getId());
System.out.println("Identity links (before)" + linksBefore);
taskService.addUserIdentityLink(task.getId(), "123", CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
taskService.addUserIdentityLink(task.getId(), "456", CommonProcessVariableNames.MIDPOINT_ASSIGNEE);
List<IdentityLink> linksAfter = taskService.getIdentityLinksForTask(task.getId());
System.out.println("Identity links (after)" + linksAfter);
TaskQuery tq1 = taskService.createTaskQuery()
.taskInvolvedUser("UserType:"+userLead1Oid)
.taskName(TASK_NAME);
assertFound(tq1, "involved user (assignee)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("123")
.taskName(TASK_NAME),
"involved user (midpoint-assignee 123)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("456")
.taskName(TASK_NAME),
"involved user (midpoint-assignee 456)");
assertNotFound(taskService.createTaskQuery()
.taskInvolvedUser("123xxx")
.taskName(TASK_NAME),
"involved user (wrong user)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("123;124")
.taskName(TASK_NAME),
"involved user (123 or 124)");
assertFound(taskService.createTaskQuery()
.taskInvolvedUser("124;123")
.taskName(TASK_NAME),
"involved user (124 or 123)");
assertNotFound(taskService.createTaskQuery()
.taskInvolvedUser("124x;123x")
.taskName(TASK_NAME),
"involved user (124x or 123x)");
assertFound(taskService.createTaskQuery()
.or()
.taskInvolvedUser("123")
.taskCandidateGroup("xxxxxxx")
.endOr()
.taskName(TASK_NAME),
"involved user (123 or candidate group xxxxxxx)");
assertFound(taskService.createTaskQuery()
.or()
.taskInvolvedUser("123;124")
.taskCandidateGroup("xxxxxxx")
.endOr()
.taskName(TASK_NAME),
"involved user (123 or 124 or candidate group xxxxxxx)");
assertNotFound(taskService.createTaskQuery()
.or()
.taskInvolvedUser("123x;124x")
.taskCandidateGroup("xxxxxxx")
.endOr()
.taskName(TASK_NAME),
"involved user (123x or 124x or candidate group xxxxxxx)");
}