use of com.evolveum.midpoint.web.component.input.UploadDownloadPanel 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);
}
use of com.evolveum.midpoint.web.component.input.UploadDownloadPanel in project midpoint by Evolveum.
the class UploadDownloadPanelFactory method getPanel.
@Override
protected InputPanel getPanel(PrismPropertyPanelContext<T> panelCtx) {
return new // getModel().getObject().isReadonly()
UploadDownloadPanel(// getModel().getObject().isReadonly()
panelCtx.getComponentId(), // getModel().getObject().isReadonly()
false) {
private static final long serialVersionUID = 1L;
@Override
public InputStream getStream() {
T object = panelCtx.getRealValueModel().getObject();
if (object instanceof String) {
return new ByteArrayInputStream(((String) object).getBytes());
}
return object != null ? new ByteArrayInputStream((byte[]) object) : new ByteArrayInputStream(new byte[0]);
}
@Override
public void updateValue(byte[] file) {
panelCtx.getRealValueModel().setObject((T) file);
}
@Override
public void uploadFileFailed(AjaxRequestTarget target) {
super.uploadFileFailed(target);
target.add(((PageBase) getPage()).getFeedbackPanel());
}
};
}
Aggregations