use of com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider in project midpoint by Evolveum.
the class PageProcessInstances method deleteProcessInstancesPerformed.
private void deleteProcessInstancesPerformed(AjaxRequestTarget target) {
List<ProcessInstanceDto> processInstanceDtoList = WebComponentUtil.getSelectedData(getTable());
if (!isSomeItemSelected(processInstanceDtoList, false, target)) {
return;
}
Task opTask = createSimpleTask(OPERATION_DELETE_PROCESS_INSTANCES);
OperationResult result = opTask.getResult();
ModelService modelService = getModelService();
for (ProcessInstanceDto processInstanceDto : processInstanceDtoList) {
String taskOid = processInstanceDto.getTaskOid();
try {
ObjectDelta<? extends ObjectType> deleteDelta = ObjectDelta.createDeleteDelta(TaskType.class, taskOid, getPrismContext());
modelService.executeChanges(Collections.<ObjectDelta<? extends ObjectType>>singletonList(deleteDelta), null, opTask, result);
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete task (process instance) {}", e, taskOid);
}
}
if (result.isUnknown()) {
result.recomputeStatus();
}
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "Selected process instance(s) have been successfully deleted.");
}
showResult(result);
ProcessInstanceDtoProvider provider = (ProcessInstanceDtoProvider) getTable().getDataTable().getDataProvider();
provider.clearCache();
//refresh feedback and table
target.add(getFeedbackPanel());
target.add(getTable());
}
use of com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider in project midpoint by Evolveum.
the class PageSelfDashboard method loadMyRequests.
private CallableResult<List<ProcessInstanceDto>> loadMyRequests() {
LOGGER.debug("Loading requests.");
AccountCallableResult<List<ProcessInstanceDto>> callableResult = new AccountCallableResult<>();
List<ProcessInstanceDto> list = new ArrayList<ProcessInstanceDto>();
callableResult.setValue(list);
if (!getWorkflowManager().isEnabled()) {
return callableResult;
}
ProcessInstanceDtoProvider provider = new ProcessInstanceDtoProvider(this, true, false);
provider.iterator(0, Integer.MAX_VALUE);
callableResult.setValue(provider.getAvailableData());
LOGGER.debug("Finished requests loading.");
return callableResult;
}
use of com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider in project midpoint by Evolveum.
the class PageProcessInstances method stopProcessInstancesPerformed.
private void stopProcessInstancesPerformed(AjaxRequestTarget target) {
MidPointPrincipal user = SecurityUtils.getPrincipalUser();
List<ProcessInstanceDto> selectedStoppableInstances = new ArrayList<>();
for (Selectable row : WebComponentUtil.getSelectedData(getTable())) {
ProcessInstanceDto instance = (ProcessInstanceDto) row;
if (instance.getEndTimestamp() == null) {
selectedStoppableInstances.add(instance);
}
}
if (!isSomeItemSelected(selectedStoppableInstances, true, target)) {
return;
}
OperationResult result = new OperationResult(OPERATION_STOP_PROCESS_INSTANCES);
WorkflowService workflowService = getWorkflowService();
for (ProcessInstanceDto instance : selectedStoppableInstances) {
try {
workflowService.stopProcessInstance(instance.getProcessInstanceId(), WebComponentUtil.getOrigStringFromPoly(user.getName()), result);
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | RuntimeException ex) {
result.createSubresult(OPERATION_STOP_PROCESS_INSTANCE).recordPartialError("Couldn't stop process instance " + instance.getName(), ex);
}
}
if (result.isUnknown()) {
result.recomputeStatus();
}
if (result.isSuccess()) {
result.recordStatus(OperationResultStatus.SUCCESS, "Selected process instance(s) have been successfully stopped.");
}
showResult(result);
ProcessInstanceDtoProvider provider = (ProcessInstanceDtoProvider) getTable().getDataTable().getDataProvider();
provider.clearCache();
//refresh feedback and table
target.add(getFeedbackPanel());
target.add(getTable());
}
use of com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider in project midpoint by Evolveum.
the class PageProcessInstances method initLayout.
private void initLayout() {
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
ISortableDataProvider<ProcessInstanceDto, String> provider = new ProcessInstanceDtoProvider(PageProcessInstances.this, requestedBy, requestedFor);
ProcessInstancesPanel panel = new ProcessInstancesPanel(ID_PROCESS_INSTANCES_TABLE, provider, UserProfileStorage.TableId.PAGE_WORKFLOW_REQUESTS, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_WORKFLOW_REQUESTS), ProcessInstancesPanel.View.FULL_LIST, null);
panel.setOutputMarkupId(true);
mainForm.add(panel);
initItemButtons(mainForm);
}
Aggregations