Search in sources :

Example 1 with ProcessInstanceDtoProvider

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());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) ProcessInstanceDtoProvider(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider) ModelService(com.evolveum.midpoint.model.api.ModelService)

Example 2 with ProcessInstanceDtoProvider

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;
}
Also used : ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult) ProcessInstanceDtoProvider(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider)

Example 3 with ProcessInstanceDtoProvider

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());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ProcessInstanceDtoProvider(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider) Selectable(com.evolveum.midpoint.web.component.util.Selectable) WorkflowService(com.evolveum.midpoint.model.api.WorkflowService) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 4 with ProcessInstanceDtoProvider

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);
}
Also used : Form(org.apache.wicket.markup.html.form.Form) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) ProcessInstanceDtoProvider(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider)

Aggregations

ProcessInstanceDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto)4 ProcessInstanceDtoProvider (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ModelService (com.evolveum.midpoint.model.api.ModelService)1 WorkflowService (com.evolveum.midpoint.model.api.WorkflowService)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 Task (com.evolveum.midpoint.task.api.Task)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)1 Selectable (com.evolveum.midpoint.web.component.util.Selectable)1 AccountCallableResult (com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)1 ArrayList (java.util.ArrayList)1 Form (org.apache.wicket.markup.html.form.Form)1