Search in sources :

Example 11 with CaseWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.

the class QCaseWorkItemMapping method insert.

// about duplication see the comment in QObjectMapping.toRowObjectWithoutFullObject
@SuppressWarnings("DuplicatedCode")
@Override
public MCaseWorkItem insert(CaseWorkItemType workItem, MCase ownerRow, JdbcSession jdbcSession) {
    MCaseWorkItem row = initRowObject(workItem, ownerRow);
    row.closeTimestamp = MiscUtil.asInstant(workItem.getCloseTimestamp());
    row.createTimestamp = MiscUtil.asInstant(workItem.getCreateTimestamp());
    row.deadline = MiscUtil.asInstant(workItem.getDeadline());
    setReference(workItem.getOriginalAssigneeRef(), o -> row.originalAssigneeRefTargetOid = o, t -> row.originalAssigneeRefTargetType = t, r -> row.originalAssigneeRefRelationId = r);
    AbstractWorkItemOutputType output = workItem.getOutput();
    if (output != null) {
        row.outcome = output.getOutcome();
    }
    setReference(workItem.getPerformerRef(), o -> row.performerRefTargetOid = o, t -> row.performerRefTargetType = t, r -> row.performerRefRelationId = r);
    row.stageNumber = workItem.getStageNumber();
    insert(row, jdbcSession);
    storeRefs(row, workItem.getAssigneeRef(), QCaseWorkItemReferenceMapping.getForCaseWorkItemAssignee(), jdbcSession);
    storeRefs(row, workItem.getCandidateRef(), QCaseWorkItemReferenceMapping.getForCaseWorkItemCandidate(), jdbcSession);
    return row;
}
Also used : AbstractWorkItemOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.AbstractWorkItemOutputType)

Example 12 with CaseWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.

the class CaseWorkitemsPanel method initLayout.

protected void initLayout() {
    setOutputMarkupId(true);
    PrismContainerWrapperModel<CaseType, CaseWorkItemType> workitemsModel = PrismContainerWrapperModel.fromContainerWrapper(getObjectWrapperModel(), CaseType.F_WORK_ITEM);
    add(new CaseWorkItemsTableWithDetailsPanel(ID_WORKITEMS_PANEL, workitemsModel) {

        private static final long serialVersionUID = 1L;

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return UserProfileStorage.TableId.PAGE_CASE_WORKITEMS_TAB;
        }
    });
}
Also used : CaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType) CaseWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType) CaseWorkItemsTableWithDetailsPanel(com.evolveum.midpoint.web.page.admin.cases.CaseWorkItemsTableWithDetailsPanel)

Example 13 with CaseWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.

the class ReleaseWorkItemsAction method executeInternal.

@Override
@Nullable
public Action executeInternal(OperationResult result) {
    for (ReleaseWorkItemsRequest.SingleRelease release : request.getReleases()) {
        CaseWorkItemType workItem = operation.getWorkItemById(release.getWorkItemId());
        if (workItem.getCloseTimestamp() != null) {
            LOGGER.debug("Work item {} in {} cannot be released because it's already closed", workItem, operation.getCurrentCase());
            result.recordNotApplicable("There are no candidates this work item can be offered to");
        } else if (workItem.getAssigneeRef().isEmpty()) {
            throw new SystemException("The work item is not assigned to a user");
        } else if (workItem.getAssigneeRef().size() > 1) {
            throw new SystemException("The work item is assigned to more than one user, so it cannot be released");
        } else if (!operation.getPrincipal().getOid().equals(workItem.getAssigneeRef().get(0).getOid())) {
            throw new SystemException("The work item is not assigned to the current user");
        } else if (workItem.getCandidateRef().isEmpty()) {
            result.recordNotApplicable("There are no candidates this work item can be offered to");
        } else {
            workItem.getAssigneeRef().clear();
        }
    }
    return null;
}
Also used : ReleaseWorkItemsRequest(com.evolveum.midpoint.cases.api.request.ReleaseWorkItemsRequest) SystemException(com.evolveum.midpoint.util.exception.SystemException) CaseWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with CaseWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.

the class SimpleStageOpeningHelper method createWorkItems.

private List<CaseWorkItemType> createWorkItems(Collection<ObjectReferenceType> allAssignees, CaseType aCase, SimpleCaseSchemaType schema) {
    XMLGregorianCalendar now = clock.currentTimeXMLGregorianCalendar();
    XMLGregorianCalendar deadline;
    if (schema != null && schema.getDuration() != null) {
        deadline = CloneUtil.clone(now);
        deadline.add(schema.getDuration());
    } else {
        deadline = null;
    }
    return allAssignees.stream().map(assignee -> new CaseWorkItemType(prismContext).originalAssigneeRef(assignee.clone()).assigneeRef(assignee.clone()).name(aCase.getName().getOrig()).createTimestamp(now).deadline(deadline)).collect(Collectors.toList());
}
Also used : com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) CaseEngineOperation(com.evolveum.midpoint.cases.api.CaseEngineOperation) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) DebugUtil(com.evolveum.midpoint.util.DebugUtil) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) PrismContext(com.evolveum.midpoint.prism.PrismContext) Qualifier(org.springframework.beans.factory.annotation.Qualifier) RelationRegistry(com.evolveum.midpoint.schema.RelationRegistry) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) CloneUtil(com.evolveum.midpoint.prism.util.CloneUtil) Collection(java.util.Collection) PrismObject(com.evolveum.midpoint.prism.PrismObject) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Collectors(java.util.stream.Collectors) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Component(org.springframework.stereotype.Component) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) NotNull(org.jetbrains.annotations.NotNull) Clock(com.evolveum.midpoint.common.Clock) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 15 with CaseWorkItemType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType in project midpoint by Evolveum.

the class PageWorkItemsClaimable method createRowActions.

@Override
protected List<InlineMenuItem> createRowActions() {
    List<InlineMenuItem> menu = new ArrayList<>();
    menu.add(new ButtonInlineMenuItem(createStringResource("pageWorkItem.button.claim")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<PrismContainerValueWrapper<CaseWorkItemType>>() {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    claimWorkItemPerformed(getRowModel(), target);
                }
            };
        }

        @Override
        public IModel<Boolean> getEnabled() {
            IModel<PrismContainerValueWrapper<CaseWorkItemType>> rowModel = ((ColumnMenuAction<PrismContainerValueWrapper<CaseWorkItemType>>) getAction()).getRowModel();
            if (rowModel != null && rowModel.getObject() != null && rowModel.getObject().getRealValue() != null) {
                CaseWorkItemType workItem = rowModel.getObject().getRealValue();
                return Model.of(CaseWorkItemUtil.isCaseWorkItemNotClosed(workItem));
            } else {
                return super.getEnabled();
            }
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            return createStringResource("CaseWorkItemsPanel.confirmWorkItemsClaimAction");
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_ICON_CLAIM);
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) CaseWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Aggregations

CaseWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)13 Task (com.evolveum.midpoint.task.api.Task)11 List (java.util.List)8 Test (org.testng.annotations.Test)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)7 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)6 CaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType)6 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)5 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)5 Collectors (java.util.stream.Collectors)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)5 QName (javax.xml.namespace.QName)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 File (java.io.File)3 Collection (java.util.Collection)3 NotNull (org.jetbrains.annotations.NotNull)3 DirtiesContext (org.springframework.test.annotation.DirtiesContext)3 ContextConfiguration (org.springframework.test.context.ContextConfiguration)3 CaseEngineOperation (com.evolveum.midpoint.cases.api.CaseEngineOperation)2