use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.
the class PageWorkItem method loadWorkItemDtoIfNecessary.
private WorkItemDto loadWorkItemDtoIfNecessary() {
if (workItemDtoModel.isLoaded()) {
return workItemDtoModel.getObject();
}
Task task = createSimpleTask(OPERATION_LOAD_WORK_ITEM);
OperationResult result = task.getResult();
WorkItemDto workItemDto = null;
try {
final ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, getPrismContext()).item(F_EXTERNAL_ID).eq(taskId).build();
final Collection<SelectorOptions<GetOperationOptions>> options = resolveItemsNamed(F_ASSIGNEE_REF, F_ORIGINAL_ASSIGNEE_REF);
List<WorkItemType> workItems = getModelService().searchContainers(WorkItemType.class, query, options, task, result);
if (workItems.size() > 1) {
throw new SystemException("More than one work item with ID of " + taskId);
} else if (workItems.size() == 0) {
throw new SystemException("No work item with ID of " + taskId);
}
final WorkItemType workItem = workItems.get(0);
//final String taskOid = workItem.getTaskRef() != null ? workItem.getTaskRef().getOid() : null;
final String taskOid = WfContextUtil.getTask(workItem).getOid();
TaskType taskType = null;
List<TaskType> relatedTasks = new ArrayList<>();
if (taskOid != null) {
final Collection<SelectorOptions<GetOperationOptions>> getTaskOptions = resolveItemsNamed(new ItemPath(F_WORKFLOW_CONTEXT, F_REQUESTER_REF));
getTaskOptions.addAll(retrieveItemsNamed(new ItemPath(F_WORKFLOW_CONTEXT, F_WORK_ITEM)));
try {
taskType = getModelService().getObject(TaskType.class, taskOid, getTaskOptions, task, result).asObjectable();
} catch (AuthorizationException e) {
LoggingUtils.logExceptionOnDebugLevel(LOGGER, "Access to the task {} was denied", e, taskOid);
}
if (taskType != null && taskType.getParent() != null) {
final ObjectQuery relatedTasksQuery = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(F_PARENT).eq(taskType.getParent()).build();
List<PrismObject<TaskType>> relatedTaskObjects = getModelService().searchObjects(TaskType.class, relatedTasksQuery, null, task, result);
for (PrismObject<TaskType> relatedObject : relatedTaskObjects) {
relatedTasks.add(relatedObject.asObjectable());
}
}
}
workItemDto = new WorkItemDto(workItem, taskType, relatedTasks);
workItemDto.prepareDeltaVisualization("pageWorkItem.delta", getPrismContext(), getModelInteractionService(), task, result);
result.recordSuccessIfUnknown();
} catch (CommonException | RuntimeException ex) {
result.recordFatalError("Couldn't get work item.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get work item.", ex);
}
showResult(result, false);
if (!result.isSuccess()) {
throw getRestartResponseException(PageDashboard.class);
}
return workItemDto;
}
use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.
the class PageWorkItems method releaseWorkItemsPerformed.
private void releaseWorkItemsPerformed(AjaxRequestTarget target) {
List<WorkItemDto> workItemDtoList = getWorkItemsPanel().getSelectedWorkItems();
if (!isSomeItemSelected(workItemDtoList, target)) {
return;
}
OperationResult mainResult = new OperationResult(OPERATION_RELEASE_ITEMS);
WorkflowService workflowService = getWorkflowService();
for (WorkItemDto workItemDto : workItemDtoList) {
OperationResult result = mainResult.createSubresult(OPERATION_RELEASE_ITEM);
try {
workflowService.releaseWorkItem(workItemDto.getWorkItemId(), result);
result.computeStatusIfUnknown();
} catch (ObjectNotFoundException | SecurityViolationException | RuntimeException e) {
result.recordPartialError("Couldn't release work item due to an unexpected exception.", e);
}
}
if (mainResult.isUnknown()) {
mainResult.recomputeStatus();
}
if (mainResult.isSuccess()) {
mainResult.recordStatus(OperationResultStatus.SUCCESS, "The work item(s) have been successfully released.");
}
showResult(mainResult);
resetWorkItemCountModel();
target.add(this);
}
use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.
the class PageWorkItems method approveOrRejectWorkItemsPerformed.
private void approveOrRejectWorkItemsPerformed(AjaxRequestTarget target, boolean approve) {
List<WorkItemDto> workItemDtoList = getWorkItemsPanel().getSelectedWorkItems();
if (!isSomeItemSelected(workItemDtoList, target)) {
return;
}
OperationResult mainResult = new OperationResult(OPERATION_APPROVE_OR_REJECT_ITEMS);
WorkflowService workflowService = getWorkflowService();
for (WorkItemDto workItemDto : workItemDtoList) {
OperationResult result = mainResult.createSubresult(OPERATION_APPROVE_OR_REJECT_ITEM);
try {
workflowService.completeWorkItem(workItemDto.getWorkItemId(), approve, null, null, result);
result.computeStatus();
} catch (Exception e) {
result.recordPartialError("Couldn't approve/reject work item due to an unexpected exception.", e);
}
}
if (mainResult.isUnknown()) {
mainResult.recomputeStatus();
}
if (mainResult.isSuccess()) {
mainResult.recordStatus(OperationResultStatus.SUCCESS, "The work item(s) have been successfully " + (approve ? "approved." : "rejected."));
}
showResult(mainResult);
resetWorkItemCountModel();
target.add(this);
}
use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.
the class PageWorkItems method claimWorkItemsPerformed.
private void claimWorkItemsPerformed(AjaxRequestTarget target) {
List<WorkItemDto> workItemDtoList = getWorkItemsPanel().getSelectedWorkItems();
if (!isSomeItemSelected(workItemDtoList, target)) {
return;
}
OperationResult mainResult = new OperationResult(OPERATION_CLAIM_ITEMS);
WorkflowService workflowService = getWorkflowService();
for (WorkItemDto workItemDto : workItemDtoList) {
OperationResult result = mainResult.createSubresult(OPERATION_CLAIM_ITEM);
try {
workflowService.claimWorkItem(workItemDto.getWorkItemId(), result);
result.computeStatusIfUnknown();
} catch (ObjectNotFoundException | SecurityViolationException | RuntimeException e) {
result.recordPartialError("Couldn't claim work item due to an unexpected exception.", e);
}
}
if (mainResult.isUnknown()) {
mainResult.recomputeStatus();
}
if (mainResult.isSuccess()) {
mainResult.recordStatus(OperationResultStatus.SUCCESS, "The work item(s) have been successfully claimed.");
}
showResult(mainResult);
resetWorkItemCountModel();
target.add(this);
}
Aggregations