Search in sources :

Example 6 with WorkItemDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.

the class PageSelfDashboard method loadWorkItems.

private CallableResult<List<WorkItemDto>> loadWorkItems() {
    LOGGER.debug("Loading work items.");
    AccountCallableResult callableResult = new AccountCallableResult();
    List<WorkItemDto> list = new ArrayList<>();
    callableResult.setValue(list);
    if (!getWorkflowManager().isEnabled()) {
        return callableResult;
    }
    PrismObject<UserType> user = principalModel.getObject();
    if (user == null) {
        return callableResult;
    }
    Task task = createSimpleTask(OPERATION_LOAD_WORK_ITEMS);
    OperationResult result = task.getResult();
    callableResult.setResult(result);
    try {
        ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, getPrismContext()).item(WorkItemType.F_ASSIGNEE_REF).ref(user.getOid()).desc(F_CREATE_TIMESTAMP).build();
        Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF), new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
        List<WorkItemType> workItems = getModelService().searchContainers(WorkItemType.class, query, options, task, result);
        for (WorkItemType workItem : workItems) {
            list.add(new WorkItemDto(workItem));
        }
    } catch (Exception e) {
        result.recordFatalError("Couldn't get list of work items.", e);
    }
    result.recordSuccessIfUnknown();
    result.recomputeStatus();
    LOGGER.debug("Finished work items loading.");
    return callableResult;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 7 with WorkItemDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.

the class WorkItemsPanel method getSelectedWorkItems.

public List<WorkItemDto> getSelectedWorkItems() {
    DataTable table = getWorkItemTable().getDataTable();
    WorkItemDtoProvider provider = (WorkItemDtoProvider) table.getDataProvider();
    List<WorkItemDto> selected = new ArrayList<>();
    for (WorkItemDto row : provider.getAvailableData()) {
        if (row.isSelected()) {
            selected.add(row);
        }
    }
    return selected;
}
Also used : WorkItemDtoProvider(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDtoProvider) ArrayList(java.util.ArrayList) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto)

Example 8 with WorkItemDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.

the class WorkItemsPanel method createTargetNameColumn.

IColumn<WorkItemDto, String> createTargetNameColumn(final String headerKey) {
    return new LinkColumn<WorkItemDto>(createStringResource(headerKey), WorkItemDto.F_TARGET_NAME) {

        @Override
        protected IModel<String> createLinkModel(IModel<WorkItemDto> rowModel) {
            return Model.of(WebModelServiceUtils.resolveReferenceName(rowModel.getObject().getTargetRef(), getPageBase()));
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
            WorkItemDto dto = rowModel.getObject();
            dispatchToObjectDetailsPage(dto.getTargetRef(), getPageBase(), false);
        }

        @Override
        public void populateItem(Item<ICellPopulator<WorkItemDto>> cellItem, String componentId, final IModel<WorkItemDto> rowModel) {
            super.populateItem(cellItem, componentId, rowModel);
            Component c = cellItem.get(componentId);
            c.add(new AttributeAppender("title", getTargetObjectDescription(rowModel)));
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PageWorkItem(com.evolveum.midpoint.web.page.admin.workflow.PageWorkItem) Item(org.apache.wicket.markup.repeater.Item) IModel(org.apache.wicket.model.IModel) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) Component(org.apache.wicket.Component) DateLabelComponent(com.evolveum.midpoint.web.component.DateLabelComponent) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 9 with WorkItemDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.

the class WorkItemsPanel method createObjectNameColumn.

IColumn<WorkItemDto, String> createObjectNameColumn(final String headerKey) {
    return new LinkColumn<WorkItemDto>(createStringResource(headerKey), WorkItemDto.F_OBJECT_NAME) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createLinkModel(IModel<WorkItemDto> rowModel) {
            return Model.of(WebModelServiceUtils.resolveReferenceName(rowModel.getObject().getObjectRef(), getPageBase()));
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<WorkItemDto> rowModel) {
            WorkItemDto dto = rowModel.getObject();
            dispatchToObjectDetailsPage(dto.getObjectRef(), getPageBase(), false);
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) LinkColumn(com.evolveum.midpoint.web.component.data.column.LinkColumn)

Example 10 with WorkItemDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto in project midpoint by Evolveum.

the class PageWorkItem method savePerformed.

private void savePerformed(AjaxRequestTarget target, boolean decision) {
    OperationResult result = new OperationResult(OPERATION_SAVE_WORK_ITEM);
    try {
        WorkItemDto dto = workItemDtoModel.getObject();
        ObjectDelta delta = getWorkItemPanel().getDeltaFromForm();
        getWorkflowService().completeWorkItem(dto.getWorkItemId(), decision, dto.getApproverComment(), delta, result);
    } catch (Exception ex) {
        result.recordFatalError("Couldn't save work item.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save work item", ex);
    }
    processResult(target, result, false);
}
Also used : WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Aggregations

WorkItemDto (com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto)14 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 IModel (org.apache.wicket.model.IModel)4 WorkflowService (com.evolveum.midpoint.model.api.WorkflowService)3 Task (com.evolveum.midpoint.task.api.Task)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)3 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)3 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 WorkItemsPanel (com.evolveum.midpoint.web.component.wf.WorkItemsPanel)3 ProcessInstanceDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto)3 ArrayList (java.util.ArrayList)3 PropertyModel (org.apache.wicket.model.PropertyModel)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)2 LinkColumn (com.evolveum.midpoint.web.component.data.column.LinkColumn)2 ItemApprovalHistoryPanel (com.evolveum.midpoint.web.component.wf.processes.itemApproval.ItemApprovalHistoryPanel)2