Search in sources :

Example 1 with ProcessInstanceDto

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

the class TaskDto method fillInWorkflowAttributes.

private void fillInWorkflowAttributes(TaskType taskType, ModelInteractionService modelInteractionService, WorkflowManager workflowManager, PrismContext prismContext, Task opTask, OperationResult thisOpResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
    workflowDeltasIn = retrieveDeltasToProcess(taskType, modelInteractionService, opTask, thisOpResult);
    workflowDeltasOut = retrieveResultingDeltas(taskType, modelInteractionService, opTask, thisOpResult);
    final TaskType rootTask;
    if (parentTaskType == null) {
        rootTask = taskType;
    } else {
        rootTask = parentTaskType;
    }
    WfContextType wfc = taskType.getWorkflowContext();
    if (wfc != null && parentTaskType != null && (wfc.getProcessorSpecificState() instanceof WfPrimaryChangeProcessorStateType)) {
        ChangesByState changesByState = workflowManager.getChangesByState(taskType, rootTask, modelInteractionService, prismContext, thisOpResult);
        List<TaskChangesDto> changeCategories = computeChangesCategorizationList(changesByState, modelInteractionService, prismContext, opTask, thisOpResult);
        if (changeCategories.size() > 1) {
            throw new IllegalStateException("More than one task change category for task " + taskType + ": " + changeCategories);
        } else if (changeCategories.size() == 1) {
            changesBeingApproved = changeCategories.get(0);
        }
    }
    workflowRequests = new ArrayList<>();
    for (TaskType wfSubtask : rootTask.getSubtask()) {
        final WfContextType subWfc = wfSubtask.getWorkflowContext();
        if (subWfc != null && subWfc.getProcessInstanceId() != null) {
            if (this.getOid() == null || !this.getOid().equals(wfSubtask.getOid())) {
                workflowRequests.add(new ProcessInstanceDto(wfSubtask));
            }
        }
    }
    ChangesByState changesByState = workflowManager.getChangesByState(rootTask, modelInteractionService, prismContext, opTask, thisOpResult);
    this.changesCategorizationList = computeChangesCategorizationList(changesByState, modelInteractionService, prismContext, opTask, thisOpResult);
}
Also used : ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) ChangesByState(com.evolveum.midpoint.wf.util.ChangesByState)

Example 2 with ProcessInstanceDto

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

the class TaskWfChildPanel method initLayout.

private void initLayout(final IModel<TaskDto> taskDtoModel) {
    changesModel = new PropertyModel<>(taskDtoModel, TaskDto.F_CHANGE_BEING_APPROVED);
    TaskChangesPanel changesPanel = new TaskChangesPanel(ID_CHANGES, changesModel);
    changesPanel.setOutputMarkupId(true);
    add(changesPanel);
    final ItemApprovalHistoryPanel history = new ItemApprovalHistoryPanel(ID_HISTORY, new PropertyModel<>(taskDtoModel, TaskDto.F_WORKFLOW_CONTEXT), UserProfileStorage.TableId.PAGE_TASK_HISTORY_PANEL, (int) parentPage.getItemsPerPage(UserProfileStorage.TableId.PAGE_TASK_HISTORY_PANEL));
    history.setOutputMarkupId(true);
    add(history);
    add(WebComponentUtil.createHelp(ID_HISTORY_HELP));
    WebMarkupContainer workItemsContainer = new WebMarkupContainer(ID_CURRENT_WORK_ITEMS_CONTAINER);
    final ISortableDataProvider<WorkItemDto, String> provider = new ListDataProvider(this, new PropertyModel<List<WorkItemDto>>(taskDtoModel, TaskDto.F_WORK_ITEMS));
    final WorkItemsPanel workItemsPanel = new WorkItemsPanel(ID_CURRENT_WORK_ITEMS, provider, UserProfileStorage.TableId.PAGE_TASK_CURRENT_WORK_ITEMS_PANEL, (int) parentPage.getItemsPerPage(UserProfileStorage.TableId.PAGE_TASK_CURRENT_WORK_ITEMS_PANEL), WorkItemsPanel.View.ITEMS_FOR_PROCESS);
    workItemsPanel.setOutputMarkupId(true);
    workItemsContainer.add(workItemsPanel);
    workItemsContainer.setOutputMarkupId(true);
    workItemsContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return provider.size() > 0;
        }
    });
    workItemsContainer.add(WebComponentUtil.createHelp(ID_CURRENT_WORK_ITEMS_HELP));
    add(workItemsContainer);
    final PropertyModel<List<ProcessInstanceDto>> relatedRequestsModel = new PropertyModel<>(taskDtoModel, TaskDto.F_WORKFLOW_REQUESTS);
    WebMarkupContainer relatedRequestsContainer = new WebMarkupContainer(ID_RELATED_REQUESTS_CONTAINER);
    relatedRequestsContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return CollectionUtils.isNotEmpty(relatedRequestsModel.getObject());
        }
    });
    relatedRequestsContainer.setOutputMarkupId(true);
    add(relatedRequestsContainer);
    ISortableDataProvider<ProcessInstanceDto, String> requestsProvider = new ListDataProvider(this, relatedRequestsModel);
    relatedRequestsContainer.add(new ProcessInstancesPanel(ID_RELATED_REQUESTS, requestsProvider, null, 10, ProcessInstancesPanel.View.TASKS_FOR_PROCESS, null));
    relatedRequestsContainer.add(WebComponentUtil.createHelp(ID_RELATED_REQUESTS_HELP));
    add(new AjaxFallbackLink(ID_SHOW_PARENT) {

        public void onClick(AjaxRequestTarget target) {
            String oid = taskDtoModel.getObject().getParentTaskOid();
            if (oid != null) {
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, oid);
                ((PageBase) getPage()).navigateToNext(PageTaskEdit.class, parameters);
            }
        }
    });
    add(WebComponentUtil.createHelp(ID_SHOW_PARENT_HELP));
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) ProcessInstancesPanel(com.evolveum.midpoint.web.page.admin.workflow.ProcessInstancesPanel) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxFallbackLink(org.apache.wicket.ajax.markup.html.AjaxFallbackLink) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ItemApprovalHistoryPanel(com.evolveum.midpoint.web.component.wf.processes.itemApproval.ItemApprovalHistoryPanel) WorkItemsPanel(com.evolveum.midpoint.web.component.wf.WorkItemsPanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 3 with ProcessInstanceDto

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

the class TaskWfParentPanel method initLayout.

private void initLayout(final IModel<TaskDto> taskDtoModel) {
    final PropertyModel<List<ProcessInstanceDto>> requestsModel = new PropertyModel<>(taskDtoModel, TaskDto.F_WORKFLOW_REQUESTS);
    final ISortableDataProvider<ProcessInstanceDto, String> requestsProvider = new ListDataProvider<>(this, requestsModel);
    processInstancesPanel = new ProcessInstancesPanel(ID_REQUESTS, requestsProvider, null, 10, ProcessInstancesPanel.View.TASKS_FOR_PROCESS, null);
    processInstancesPanel.setOutputMarkupId(true);
    add(processInstancesPanel);
    add(WebComponentUtil.createHelp(ID_REQUESTS_HELP));
    changesContainer = new WebMarkupContainer(ID_CHANGES_CONTAINER);
    for (int i = 1; i <= CHANGES_NUMBER; i++) {
        final int index = i;
        final String changesId = ID_CHANGES_PREFIX + i;
        final String changesContentId = changesId + ID_CHANGES_CONTENT_SUFFIX;
        final WebMarkupContainer changes = new WebMarkupContainer(changesId);
        final IModel<TaskChangesDto> changesModel = new AbstractReadOnlyModel<TaskChangesDto>() {

            @Override
            public TaskChangesDto getObject() {
                return taskDtoModel.getObject().getChangesForIndex(index);
            }
        };
        final TaskChangesPanel changesPanel = new TaskChangesPanel(changesContentId, changesModel);
        changes.add(changesPanel);
        changes.add(new VisibleEnableBehaviour() {

            @Override
            public boolean isVisible() {
                return changesModel.getObject() != null;
            }
        });
        changesContainer.add(changes);
    }
    changesContainer.setOutputMarkupId(true);
    add(changesContainer);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) ProcessInstancesPanel(com.evolveum.midpoint.web.page.admin.workflow.ProcessInstancesPanel) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) PropertyModel(org.apache.wicket.model.PropertyModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) TaskChangesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskChangesDto)

Example 4 with ProcessInstanceDto

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

the class ProcessInstancesPanel method createTypeIconColumn.

public IColumn<ProcessInstanceDto, String> createTypeIconColumn(final boolean object) {
    // true = object, false = target
    return new IconColumn<ProcessInstanceDto>(createStringResource("")) {

        @Override
        protected IModel<String> createIconModel(IModel<ProcessInstanceDto> rowModel) {
            if (getObjectType(rowModel) == null) {
                return null;
            }
            ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(rowModel);
            String icon = guiDescriptor != null ? guiDescriptor.getBlackIcon() : ObjectTypeGuiDescriptor.ERROR_ICON;
            return new Model<>(icon);
        }

        private ObjectTypeGuiDescriptor getObjectTypeDescriptor(IModel<ProcessInstanceDto> rowModel) {
            QName type = getObjectType(rowModel);
            return ObjectTypeGuiDescriptor.getDescriptor(ObjectTypes.getObjectTypeFromTypeQName(type));
        }

        private QName getObjectType(IModel<ProcessInstanceDto> rowModel) {
            return object ? rowModel.getObject().getObjectType() : rowModel.getObject().getTargetType();
        }

        @Override
        public void populateItem(Item<ICellPopulator<ProcessInstanceDto>> item, String componentId, IModel<ProcessInstanceDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor(rowModel);
            if (guiDescriptor != null) {
                item.add(AttributeModifier.replace("title", createStringResource(guiDescriptor.getLocalizationKey())));
                item.add(new TooltipBehavior());
            }
        }
    };
}
Also used : Item(org.apache.wicket.markup.repeater.Item) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) IModel(org.apache.wicket.model.IModel) IconColumn(com.evolveum.midpoint.web.component.data.column.IconColumn) QName(javax.xml.namespace.QName) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) ObjectTypeGuiDescriptor(com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model)

Example 5 with ProcessInstanceDto

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

the class ProcessInstancesPanel method initLayout.

private void initLayout(UserProfileStorage.TableId tableId, int pageSize, View view, final IModel<String> currentInstanceIdModel) {
    BoxedTablePanel<ProcessInstanceDto> table = new BoxedTablePanel<ProcessInstanceDto>(ID_REQUESTS_TABLE, provider, initColumns(view), tableId, pageSize) {

        @Override
        protected Item<ProcessInstanceDto> customizeNewRowItem(Item<ProcessInstanceDto> item, final IModel<ProcessInstanceDto> rowModel) {
            item.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    if (currentInstanceIdModel == null || currentInstanceIdModel.getObject() == null) {
                        return "";
                    }
                    ProcessInstanceDto rowDto = rowModel.getObject();
                    if (currentInstanceIdModel.getObject().equals(rowDto.getProcessInstanceId())) {
                        return "info";
                    } else {
                        return "";
                    }
                }
            }));
            return item;
        }
    };
    table.setOutputMarkupId(true);
    table.setAdditionalBoxCssClasses("without-box-header-top-border");
    add(table);
}
Also used : Item(org.apache.wicket.markup.repeater.Item) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) IModel(org.apache.wicket.model.IModel) ProcessInstanceDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

ProcessInstanceDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDto)15 IModel (org.apache.wicket.model.IModel)7 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)5 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)4 ProcessInstanceDtoProvider (com.evolveum.midpoint.web.page.admin.workflow.dto.ProcessInstanceDtoProvider)4 LinkColumn (com.evolveum.midpoint.web.component.data.column.LinkColumn)3 WorkItemsPanel (com.evolveum.midpoint.web.component.wf.WorkItemsPanel)3 ProcessInstancesPanel (com.evolveum.midpoint.web.page.admin.workflow.ProcessInstancesPanel)3 WorkItemDto (com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 PropertyModel (org.apache.wicket.model.PropertyModel)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 IconColumn (com.evolveum.midpoint.web.component.data.column.IconColumn)2 ItemApprovalHistoryPanel (com.evolveum.midpoint.web.component.wf.processes.itemApproval.ItemApprovalHistoryPanel)2 AccountCallableResult (com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)2