Search in sources :

Example 1 with CaseDetailsModels

use of com.evolveum.midpoint.gui.impl.page.admin.cases.CaseDetailsModels in project midpoint by Evolveum.

the class WorkItemDetailsPanel method initLayout.

private void initLayout() {
    LinkedReferencePanel requestedBy = new LinkedReferencePanel(ID_REQUESTED_BY, Model.of(WorkItemTypeUtil.getRequestorReference(getModelObject())));
    requestedBy.setOutputMarkupId(true);
    add(requestedBy);
    LinkedReferencePanel requestedFor;
    AssignmentHolderType object = WebComponentUtil.getObjectFromAddDeltyForCase(CaseTypeUtil.getCase(getModelObject()));
    if (object == null) {
        requestedFor = new LinkedReferencePanel(ID_REQUESTED_FOR, Model.of(WorkItemTypeUtil.getObjectReference(getModelObject())));
    } else {
        ObjectReferenceType ort = new ObjectReferenceType();
        ort.setOid(object.getOid());
        ort.setType(WebComponentUtil.classToQName(getPageBase().getPrismContext(), object.getClass()));
        PrismReferenceValue referenceValue = getPageBase().getPrismContext().itemFactory().createReferenceValue(object.getOid(), WebComponentUtil.classToQName(getPageBase().getPrismContext(), object.getClass()));
        referenceValue.setObject(object.asPrismObject());
        ort.setupReferenceValue(referenceValue);
        requestedFor = new LinkedReferencePanel(ID_REQUESTED_FOR, Model.of(ort));
    }
    requestedFor.setOutputMarkupId(true);
    add(requestedFor);
    LinkedReferencePanel approver = new LinkedReferencePanel(ID_APPROVER, getApproverModel());
    approver.setOutputMarkupId(true);
    add(approver);
    WebMarkupContainer candidateContainer = new WebMarkupContainer(ID_CANDIDATE_CONTAINER);
    candidateContainer.setOutputMarkupId(true);
    candidateContainer.add(new VisibleBehaviour(() -> CaseWorkItemUtil.isWorkItemClaimable(getModelObject())));
    add(candidateContainer);
    RepeatingView candidateLinksPanel = new RepeatingView(ID_CANDIDATE);
    candidateLinksPanel.setOutputMarkupId(true);
    List<ObjectReferenceType> candidates = getModelObject() != null ? getModelObject().getCandidateRef() : null;
    if (candidates != null) {
        candidates.forEach(candidate -> {
            LinkedReferencePanel candidatePanel = new LinkedReferencePanel(candidateLinksPanel.newChildId(), Model.of(candidate));
            candidatePanel.setOutputMarkupId(true);
            candidateLinksPanel.add(candidatePanel);
        });
    }
    candidateContainer.add(candidateLinksPanel);
    WebMarkupContainer parentCaseContainer = new WebMarkupContainer(ID_PARENT_CASE_CONTAINER);
    parentCaseContainer.add(new VisibleBehaviour(() -> getPageBase() instanceof PageCaseWorkItem));
    parentCaseContainer.setOutputMarkupId(true);
    add(parentCaseContainer);
    CaseType parentCaseObj = getModelObject() != null && CaseTypeUtil.getCase(getModelObject()) != null ? CaseTypeUtil.getCase(getModelObject()) : null;
    ObjectReferenceType parentCaseRef = null;
    if (parentCaseObj != null) {
        parentCaseRef = new ObjectReferenceType();
        parentCaseRef.setOid(parentCaseObj.getOid());
        parentCaseRef.setType(CaseType.COMPLEX_TYPE);
        parentCaseRef.setupReferenceValue(getPageBase().getPrismContext().itemFactory().createReferenceValue(parentCaseObj.asPrismObject()));
    }
    LinkedReferencePanel parentCaseLink = new LinkedReferencePanel(ID_PARENT_CASE, Model.of(parentCaseRef));
    parentCaseLink.setOutputMarkupId(true);
    parentCaseContainer.add(parentCaseLink);
    LinkedReferencePanel target = new LinkedReferencePanel(ID_TARGET, Model.of(WorkItemTypeUtil.getTargetReference(getModelObject())));
    target.setOutputMarkupId(true);
    add(target);
    CaseType parentCase = CaseTypeUtil.getCase(getModelObject());
    add(new Label(ID_COMMENT, CaseTypeUtil.getRequesterComment(parentCase)));
    EvaluatedTriggerGroupListPanel reasonPanel = new EvaluatedTriggerGroupListPanel(ID_REASON, Model.ofList(WebComponentUtil.computeTriggers(parentCase != null ? parentCase.getApprovalContext() : null, parentCase != null && parentCase.getStageNumber() != null ? parentCase.getStageNumber() : 0)));
    reasonPanel.setOutputMarkupId(true);
    add(reasonPanel);
    if (CaseTypeUtil.isApprovalCase(parentCase) || CaseTypeUtil.isManualProvisioningCase(parentCase)) {
        ScenePanel scenePanel = new ScenePanel(ID_DELTAS_TO_APPROVE, sceneModel);
        scenePanel.setOutputMarkupId(true);
        add(scenePanel);
    } else if (CaseTypeUtil.isCorrelationCase(parentCase)) {
        add(new CorrelationContextPanel(ID_DELTAS_TO_APPROVE, new CaseDetailsModels(caseModel, getPageBase()), new ContainerPanelConfigurationType()));
    } else {
        add(new WebMarkupContainer(ID_DELTAS_TO_APPROVE));
    }
    InformationListPanel additionalInformation = new InformationListPanel(ID_ADDITIONAL_INFORMATION, Model.ofList(getModelObject().getAdditionalInformation()));
    additionalInformation.setOutputMarkupId(true);
    add(additionalInformation);
    ApprovalStageDefinitionType level = ApprovalContextUtil.getCurrentStageDefinition(parentCase);
    WebMarkupContainer additionalAttributes = new WebMarkupContainer(ID_ADDITIONAL_ATTRIBUTES);
    add(additionalAttributes);
    additionalAttributes.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        public boolean isVisible() {
            return (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null);
        }
    });
    if (level != null && level.getFormRef() != null && level.getFormRef().getOid() != null) {
        String formOid = level.getFormRef().getOid();
        ObjectType focus = getCaseFocusObject(parentCase);
        if (focus == null) {
            // TODO (this should not occur anyway)
            focus = new UserType(getPageBase().getPrismContext());
        }
        Task task = getPageBase().createSimpleTask(OPERATION_LOAD_CUSTOM_FORM);
        DynamicFormPanel<?> customForm = new DynamicFormPanel<>(ID_CUSTOM_FORM, focus.asPrismObject(), formOid, null, task, getPageBase(), false);
        additionalAttributes.add(customForm);
    } else {
        additionalAttributes.add(new Label(ID_CUSTOM_FORM));
    }
    Form evidenceForm = new Form(ID_CASE_WORK_ITEM_EVIDENCE_FORM);
    evidenceForm.add(new VisibleBehaviour(() -> CaseTypeUtil.isManualProvisioningCase(parentCase) && (!isParentCaseClosed() || WorkItemTypeUtil.getEvidence(getModelObject()) != null)));
    evidenceForm.setMultiPart(true);
    add(evidenceForm);
    UploadDownloadPanel evidencePanel = new UploadDownloadPanel(ID_CASE_WORK_ITEM_EVIDENCE, isParentCaseClosed() && WorkItemTypeUtil.getEvidence(getModelObject()) != null) {

        private static final long serialVersionUID = 1L;

        @Override
        public void updateValue(byte[] file) {
            if (file != null) {
                WorkItemTypeUtil.setEvidence(getModelObject(), file);
            }
        }

        @Override
        public InputStream getStream() {
            byte[] evidenceFile = WorkItemTypeUtil.getEvidence(getModelObject());
            return evidenceFile != null ? new ByteArrayInputStream((byte[]) evidenceFile) : new ByteArrayInputStream(new byte[0]);
        }

        @Override
        public String getDownloadContentType() {
            return "image/jpeg";
        }
    };
    evidenceForm.add(evidencePanel);
    evidencePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    evidencePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            CaseWorkItemType workItem = WorkItemDetailsPanel.this.getModelObject();
            CaseType caseObj = CaseTypeUtil.getCase(workItem);
            return CaseTypeUtil.isManualProvisioningCase(caseObj);
        }
    });
    WebMarkupContainer commentContainer = new WebMarkupContainer(ID_APPROVER_CONTAINER);
    commentContainer.setOutputMarkupId(true);
    commentContainer.add(new VisibleBehaviour(() -> isAuthorizedForActions()));
    add(commentContainer);
    TextArea<String> approverComment = new TextArea<String>(ID_APPROVER_COMMENT, new PropertyModel<>(getModel(), "output.comment"));
    approverComment.add(new EnableBehaviour(() -> !isParentCaseClosed()));
    approverComment.setOutputMarkupId(true);
    approverComment.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    commentContainer.add(approverComment);
}
Also used : CorrelationContextPanel(com.evolveum.midpoint.gui.impl.page.admin.cases.component.CorrelationContextPanel) ScenePanel(com.evolveum.midpoint.web.component.prism.show.ScenePanel) Task(com.evolveum.midpoint.task.api.Task) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) Form(org.apache.wicket.markup.html.form.Form) TextArea(org.apache.wicket.markup.html.form.TextArea) UploadDownloadPanel(com.evolveum.midpoint.web.component.input.UploadDownloadPanel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) Label(org.apache.wicket.markup.html.basic.Label) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) CaseDetailsModels(com.evolveum.midpoint.gui.impl.page.admin.cases.CaseDetailsModels) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageCaseWorkItem(com.evolveum.midpoint.web.page.admin.cases.PageCaseWorkItem) LinkedReferencePanel(com.evolveum.midpoint.web.component.data.LinkedReferencePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) EnableBehaviour(com.evolveum.midpoint.web.component.util.EnableBehaviour) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) DynamicFormPanel(com.evolveum.midpoint.web.component.prism.DynamicFormPanel) ByteArrayInputStream(java.io.ByteArrayInputStream)

Aggregations

CaseDetailsModels (com.evolveum.midpoint.gui.impl.page.admin.cases.CaseDetailsModels)1 CorrelationContextPanel (com.evolveum.midpoint.gui.impl.page.admin.cases.component.CorrelationContextPanel)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 Task (com.evolveum.midpoint.task.api.Task)1 LinkedReferencePanel (com.evolveum.midpoint.web.component.data.LinkedReferencePanel)1 UploadDownloadPanel (com.evolveum.midpoint.web.component.input.UploadDownloadPanel)1 DynamicFormPanel (com.evolveum.midpoint.web.component.prism.DynamicFormPanel)1 ScenePanel (com.evolveum.midpoint.web.component.prism.show.ScenePanel)1 EnableBehaviour (com.evolveum.midpoint.web.component.util.EnableBehaviour)1 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 PageCaseWorkItem (com.evolveum.midpoint.web.page.admin.cases.PageCaseWorkItem)1 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 Form (org.apache.wicket.markup.html.form.Form)1 TextArea (org.apache.wicket.markup.html.form.TextArea)1 RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)1