use of com.evolveum.midpoint.web.component.prism.DynamicFormPanel in project midpoint by Evolveum.
the class WorkItemPanel method initLayout.
protected void initLayout(Form mainForm, PageBase pageBase) {
WebMarkupContainer additionalInfoColumn = new WebMarkupContainer(ID_ADDITIONAL_INFO_COLUMN);
WebMarkupContainer historyContainer = new WebMarkupContainer(ID_HISTORY_CONTAINER);
historyContainer.add(new ItemApprovalHistoryPanel(ID_HISTORY, new PropertyModel<>(getModel(), WorkItemDto.F_WORKFLOW_CONTEXT), UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL, (int) pageBase.getItemsPerPage(UserProfileStorage.TableId.PAGE_WORK_ITEM_HISTORY_PANEL)));
final VisibleEnableBehaviour historyContainerVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().hasHistory();
}
};
historyContainer.add(historyContainerVisible);
historyContainer.add(WebComponentUtil.createHelp(ID_HISTORY_HELP));
additionalInfoColumn.add(historyContainer);
WebMarkupContainer relatedWorkItemsContainer = new WebMarkupContainer(ID_RELATED_WORK_ITEMS_CONTAINER);
final IModel<List<WorkItemDto>> relatedWorkItemsModel = new PropertyModel<>(getModel(), WorkItemDto.F_OTHER_WORK_ITEMS);
final ISortableDataProvider<WorkItemDto, String> relatedWorkItemsProvider = new ListDataProvider<>(this, relatedWorkItemsModel);
relatedWorkItemsContainer.add(new WorkItemsPanel(ID_RELATED_WORK_ITEMS, relatedWorkItemsProvider, null, 10, WorkItemsPanel.View.ITEMS_FOR_PROCESS));
final VisibleEnableBehaviour relatedWorkItemsContainerVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !relatedWorkItemsModel.getObject().isEmpty();
}
};
relatedWorkItemsContainer.add(relatedWorkItemsContainerVisible);
relatedWorkItemsContainer.add(WebComponentUtil.createHelp(ID_RELATED_WORK_ITEMS_HELP));
additionalInfoColumn.add(relatedWorkItemsContainer);
final WebMarkupContainer relatedWorkflowRequestsContainer = new WebMarkupContainer(ID_RELATED_REQUESTS_CONTAINER);
final IModel<List<ProcessInstanceDto>> relatedWorkflowRequestsModel = new PropertyModel<>(getModel(), WorkItemDto.F_RELATED_WORKFLOW_REQUESTS);
final ISortableDataProvider<ProcessInstanceDto, String> relatedWorkflowRequestsProvider = new ListDataProvider<>(this, relatedWorkflowRequestsModel);
relatedWorkflowRequestsContainer.add(new ProcessInstancesPanel(ID_RELATED_REQUESTS, relatedWorkflowRequestsProvider, null, 10, ProcessInstancesPanel.View.TASKS_FOR_PROCESS, new PropertyModel<>(getModel(), WorkItemDto.F_PROCESS_INSTANCE_ID)));
final VisibleEnableBehaviour relatedWorkflowRequestsContainerVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !relatedWorkflowRequestsModel.getObject().isEmpty();
}
};
relatedWorkflowRequestsContainer.add(relatedWorkflowRequestsContainerVisible);
relatedWorkflowRequestsContainer.add(WebComponentUtil.createHelp(ID_RELATED_REQUESTS_HELP));
additionalInfoColumn.add(relatedWorkflowRequestsContainer);
final VisibleEnableBehaviour additionalInfoColumnVisible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return historyContainerVisible.isVisible() || relatedWorkItemsContainerVisible.isVisible() || relatedWorkflowRequestsContainerVisible.isVisible();
}
};
additionalInfoColumn.add(additionalInfoColumnVisible);
add(additionalInfoColumn);
WebMarkupContainer primaryInfoColumn = new WebMarkupContainer(ID_PRIMARY_INFO_COLUMN);
// primaryInfoColumn.add(new Label(ID_REQUESTED_BY, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_NAME)));
// primaryInfoColumn.add(new Label(ID_REQUESTED_BY_FULL_NAME, new PropertyModel(getModel(), WorkItemDto.F_REQUESTER_FULL_NAME)));
// primaryInfoColumn.add(new Label(ID_REQUESTED_ON, new PropertyModel(getModel(), WorkItemDto.F_STARTED_FORMATTED_FULL)));
primaryInfoColumn.add(new Label(ID_WORK_ITEM_CREATED_ON, new PropertyModel(getModel(), WorkItemDto.F_CREATED_FORMATTED_FULL)));
primaryInfoColumn.add(new Label(ID_WORK_ITEM_DEADLINE, new PropertyModel(getModel(), WorkItemDto.F_DEADLINE_FORMATTED_FULL)));
primaryInfoColumn.add(new Label(ID_ORIGINALLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_ORIGINAL_ASSIGNEE_FULL)));
primaryInfoColumn.add(new Label(ID_CURRENTLY_ALLOCATED_TO, new PropertyModel(getModel(), WorkItemDto.F_CURRENT_ASSIGNEES_FULL)));
primaryInfoColumn.add(new Label(ID_CANDIDATES, new PropertyModel(getModel(), WorkItemDto.F_CANDIDATES)));
WebMarkupContainer stageInfoContainer = new WebMarkupContainer(ID_STAGE_INFO_CONTAINER);
primaryInfoColumn.add(stageInfoContainer);
stageInfoContainer.add(new Label(ID_STAGE_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_STAGE_INFO)));
stageInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getStageInfo() != null));
WebMarkupContainer escalationLevelInfoContainer = new WebMarkupContainer(ID_ESCALATION_LEVEL_INFO_CONTAINER);
primaryInfoColumn.add(escalationLevelInfoContainer);
escalationLevelInfoContainer.add(new Label(ID_ESCALATION_LEVEL_INFO, new PropertyModel<String>(getModel(), WorkItemDto.F_ESCALATION_LEVEL_INFO)));
escalationLevelInfoContainer.add(new VisibleBehaviour(() -> getModelObject().getEscalationLevelInfo() != null));
WebMarkupContainer requesterCommentContainer = new WebMarkupContainer(ID_REQUESTER_COMMENT_CONTAINER);
requesterCommentContainer.setOutputMarkupId(true);
primaryInfoColumn.add(requesterCommentContainer);
requesterCommentContainer.add(new Label(ID_REQUESTER_COMMENT_MESSAGE, new PropertyModel<String>(getModel(), WorkItemDto.F_REQUESTER_COMMENT)));
//primaryInfoColumn.add(new ScenePanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<SceneDto>(getModel(), WorkItemDto.F_DELTAS)));
primaryInfoColumn.add(new TaskChangesPanel(ID_DELTAS_TO_BE_APPROVED, new PropertyModel<>(getModel(), WorkItemDto.F_CHANGES)));
primaryInfoColumn.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return additionalInfoColumnVisible.isVisible() ? "col-md-5" : "col-md-12";
}
}));
add(primaryInfoColumn);
add(new AjaxFallbackLink(ID_SHOW_REQUEST) {
public void onClick(AjaxRequestTarget target) {
String oid = WorkItemPanel.this.getModelObject().getTaskOid();
if (oid != null) {
PageParameters parameters = new PageParameters();
parameters.add(OnePageParameterEncoder.PARAMETER, oid);
getPageBase().navigateToNext(PageTaskEdit.class, parameters);
}
}
});
add(WebComponentUtil.createHelp(ID_SHOW_REQUEST_HELP));
WebMarkupContainer additionalInformation = new InformationListPanel(ID_ADDITIONAL_INFORMATION, new PropertyModel<>(getModel(), WorkItemDto.F_ADDITIONAL_INFORMATION));
add(additionalInformation);
WorkItemDto dto = getModelObject();
ApprovalStageDefinitionType level = WfContextUtil.getCurrentStageDefinition(dto.getWorkflowContext());
WebMarkupContainer additionalAttribues = new WebMarkupContainer(ID_ADDITIONAL_ATTRIBUTES);
add(additionalAttribues);
additionalAttribues.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 = dto.getFocus(pageBase);
if (focus == null) {
// TODO FIXME (this should not occur anyway)
focus = new UserType(pageBase.getPrismContext());
}
Task task = pageBase.createSimpleTask(OPERATION_LOAD_CUSTOM_FORM);
DynamicFormPanel<?> customForm = new DynamicFormPanel<>(ID_CUSTOM_FORM, focus.asPrismObject(), formOid, mainForm, task, pageBase);
additionalAttribues.add(customForm);
} else {
additionalAttribues.add(new Label(ID_CUSTOM_FORM));
}
add(new TextArea<>(ID_APPROVER_COMMENT, new PropertyModel<String>(getModel(), WorkItemDto.F_APPROVER_COMMENT)));
}
use of com.evolveum.midpoint.web.component.prism.DynamicFormPanel in project midpoint by Evolveum.
the class PageSelfRegistration method initDynamicFormLayout.
private void initDynamicFormLayout(final Form<?> mainForm) {
WebMarkupContainer dynamicRegistrationForm = createMarkupContainer(ID_DYNAMIC_FORM, new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getSelfRegistrationConfiguration().getFormRef() != null;
}
}, mainForm);
DynamicFormPanel<UserType> dynamicForm = runPrivileged(() -> {
final ObjectReferenceType ort = getSelfRegistrationConfiguration().getFormRef();
if (ort == null) {
return null;
}
Task task = createAnonymousTask(OPERATION_LOAD_DYNAMIC_FORM);
return new DynamicFormPanel<UserType>(ID_DYNAMIC_FORM_PANEL, userModel, ort.getOid(), mainForm, task, PageSelfRegistration.this);
});
if (dynamicForm != null) {
dynamicRegistrationForm.add(dynamicForm);
}
}
use of com.evolveum.midpoint.web.component.prism.DynamicFormPanel 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.prism.DynamicFormPanel in project midpoint by Evolveum.
the class WebComponentUtil method workItemApproveActionPerformed.
public static void workItemApproveActionPerformed(AjaxRequestTarget target, CaseWorkItemType workItem, Component formPanel, PrismObject<UserType> powerDonor, boolean approved, OperationResult result, PageBase pageBase) {
if (workItem == null) {
return;
}
CaseType parentCase = CaseWorkItemUtil.getCase(workItem);
AbstractWorkItemOutputType output = workItem.getOutput();
if (output == null) {
output = new AbstractWorkItemOutputType(pageBase.getPrismContext());
}
output.setOutcome(ApprovalUtils.toUri(approved));
if (WorkItemTypeUtil.getComment(workItem) != null) {
output.setComment(WorkItemTypeUtil.getComment(workItem));
}
if (WorkItemTypeUtil.getEvidence(workItem) != null) {
output.setEvidence(WorkItemTypeUtil.getEvidence(workItem));
}
if (CaseTypeUtil.isManualProvisioningCase(parentCase)) {
Task task = pageBase.createSimpleTask(result.getOperation());
try {
WorkItemId workItemId = WorkItemId.create(parentCase.getOid(), workItem.getId());
pageBase.getCaseService().completeWorkItem(workItemId, output, task, result);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Unable to complete work item, ", ex);
result.recordFatalError(ex);
}
} else {
Task task = pageBase.createSimpleTask(result.getOperation());
try {
try {
ObjectDelta additionalDelta = null;
if (formPanel != null && formPanel instanceof DynamicFormPanel) {
if (approved) {
boolean requiredFieldsPresent = ((DynamicFormPanel<?>) formPanel).checkRequiredFields(pageBase);
if (!requiredFieldsPresent) {
target.add(pageBase.getFeedbackPanel());
return;
}
}
additionalDelta = ((DynamicFormPanel<?>) formPanel).getObjectDelta();
if (additionalDelta != null) {
pageBase.getPrismContext().adopt(additionalDelta);
}
}
assumePowerOfAttorneyIfRequested(result, powerDonor, pageBase);
pageBase.getCaseService().completeWorkItem(WorkItemId.of(workItem), output, additionalDelta, task, result);
} finally {
dropPowerOfAttorneyIfRequested(result, powerDonor, pageBase);
}
} catch (Exception ex) {
result.recordFatalError(pageBase.createStringResource("WebModelUtils.couldntSaveWorkItem").getString(), ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save work item", ex);
}
}
result.computeStatusIfUnknown();
pageBase.showResult(result);
}
use of com.evolveum.midpoint.web.component.prism.DynamicFormPanel in project midpoint by Evolveum.
the class PageAuthenticationBase method initDynamicLayout.
protected void initDynamicLayout(final org.apache.wicket.markup.html.form.Form<?> mainForm, PageBase parentPage) {
WebMarkupContainer dynamicLayout = new WebMarkupContainer(ID_DYNAMIC_LAYOUT);
dynamicLayout.setOutputMarkupId(true);
mainForm.add(dynamicLayout);
dynamicLayout.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isDynamicForm();
}
});
DynamicFormPanel<UserType> searchAttributesForm = runPrivileged(() -> {
ObjectReferenceType formRef = getResetPasswordPolicy().getFormRef();
if (formRef == null) {
return null;
}
Task task = createAnonymousTask(OPERATION_LOAD_DYNAMIC_FORM);
return new DynamicFormPanel<UserType>(ID_DYNAMIC_FORM, UserType.COMPLEX_TYPE, formRef.getOid(), mainForm, task, parentPage, true);
});
if (searchAttributesForm != null) {
dynamicLayout.add(searchAttributesForm);
}
}
Aggregations