use of com.evolveum.midpoint.web.page.admin.workflow.dto.ApproverEngagementDto in project midpoint by Evolveum.
the class ApprovalProcessExecutionInformationPanelTextOnly method initLayout.
protected void initLayout() {
add(new TextAreaPanel<>(ID_TEXT, new IModel<String>() {
@Override
public String getObject() {
ApprovalProcessExecutionInformationDto processInfo = getModelObject();
if (processInfo == null) {
return null;
}
int currentStageNumber = processInfo.getCurrentStageNumber();
int numberOfStages = processInfo.getNumberOfStages();
StringBuilder sb = new StringBuilder();
List<ApprovalStageExecutionInformationDto> stages = processInfo.getStages();
for (ApprovalStageExecutionInformationDto stageInfo : stages) {
if (stageInfo.getStageNumber() == currentStageNumber) {
sb.append("====> ");
}
sb.append(stageInfo.getNiceStageName(numberOfStages));
sb.append(" ");
if (stageInfo.getAutomatedOutcome() != null) {
sb.append("[").append(stageInfo.getAutomatedOutcome()).append("] because of ").append(// the reason is localizable
stageInfo.getAutomatedCompletionReason());
} else {
for (ApproverEngagementDto engagement : stageInfo.getApproverEngagements()) {
sb.append("[").append(WebComponentUtil.getDisplayNameOrName(engagement.getApproverRef())).append("] ");
if (engagement.getOutput() != null) {
sb.append("(").append(ApprovalUtils.fromUri(engagement.getOutput().getOutcome()));
if (engagement.getCompletedBy() != null && !ObjectTypeUtil.matchOnOid(engagement.getApproverRef(), engagement.getCompletedBy())) {
sb.append(" by ").append(WebComponentUtil.getDisplayNameOrName(engagement.getCompletedBy()));
}
sb.append(") ");
} else {
sb.append("(?) ");
}
}
}
sb.append("\n");
}
return sb.toString();
}
}, 8));
}
use of com.evolveum.midpoint.web.page.admin.workflow.dto.ApproverEngagementDto in project midpoint by Evolveum.
the class ApprovalProcessExecutionInformationPanel method initLayout.
protected void initLayout() {
// TODO clean this code up!!!
ListView<ApprovalStageExecutionInformationDto> stagesList = new ListView<ApprovalStageExecutionInformationDto>(ID_STAGES, new PropertyModel<>(getModel(), ApprovalProcessExecutionInformationDto.F_STAGES)) {
@Override
protected void populateItem(ListItem<ApprovalStageExecutionInformationDto> stagesListItem) {
ApprovalProcessExecutionInformationDto process = ApprovalProcessExecutionInformationPanel.this.getModelObject();
ApprovalStageExecutionInformationDto stage = stagesListItem.getModelObject();
int stageNumber = stage.getStageNumber();
int numberOfStages = process.getNumberOfStages();
int currentStageNumber = process.getCurrentStageNumber();
WebMarkupContainer arrow = new WebMarkupContainer(ID_ARROW);
arrow.add(new VisibleBehaviour(() -> stageNumber > 1));
stagesListItem.add(arrow);
WebMarkupContainer currentStageMarker = new WebMarkupContainer(ID_CURRENT_STAGE_MARKER);
currentStageMarker.add(new VisibleBehaviour(() -> stageNumber == currentStageNumber && process.isRunning()));
stagesListItem.add(currentStageMarker);
ListView<ApproverEngagementDto> approversList = new ListView<ApproverEngagementDto>(ID_APPROVERS, new PropertyModel<>(stagesListItem.getModel(), ApprovalStageExecutionInformationDto.F_APPROVER_ENGAGEMENTS)) {
@Override
protected void populateItem(ListItem<ApproverEngagementDto> approversListItem) {
ApproverEngagementDto ae = approversListItem.getModelObject();
// original approver name
approversListItem.add(createReferencedObjectLabel(ID_APPROVER_NAME, "ApprovalProcessExecutionInformationPanel.approver", ae.getApproverRef(), true));
// outcome
WorkItemOutcomeType outcome = ae.getOutput() != null ? ApprovalUtils.fromUri(ae.getOutput().getOutcome()) : null;
ApprovalOutcomeIcon outcomeIcon;
if (outcome != null) {
switch(outcome) {
case APPROVE:
outcomeIcon = ApprovalOutcomeIcon.APPROVED;
break;
case REJECT:
outcomeIcon = ApprovalOutcomeIcon.REJECTED;
break;
// perhaps should throw AssertionError instead
default:
outcomeIcon = ApprovalOutcomeIcon.UNKNOWN;
break;
}
} else {
if (stageNumber < currentStageNumber) {
// history: do not show anything for work items with no outcome
outcomeIcon = ApprovalOutcomeIcon.EMPTY;
} else if (stageNumber == currentStageNumber) {
outcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.IN_PROGRESS : // currently open
ApprovalOutcomeIcon.CANCELLED;
} else {
outcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.FUTURE : ApprovalOutcomeIcon.CANCELLED;
}
}
ImagePanel outcomePanel = new ImagePanel(ID_OUTCOME, Model.of(outcomeIcon.getIcon()), Model.of(getString(outcomeIcon.getTitle())));
outcomePanel.add(new VisibleBehaviour(() -> outcomeIcon != ApprovalOutcomeIcon.EMPTY));
approversListItem.add(outcomePanel);
// content (incl. performer)
WebMarkupContainer approvalBoxContent = new WebMarkupContainer(ID_APPROVAL_BOX_CONTENT);
approversListItem.add(approvalBoxContent);
approvalBoxContent.setVisible(performerVisible(ae) || attorneyVisible(ae));
approvalBoxContent.add(createReferencedObjectLabel(ID_PERFORMER_NAME, "ApprovalProcessExecutionInformationPanel.performer", ae.getCompletedBy(), performerVisible(ae)));
approvalBoxContent.add(createReferencedObjectLabel(ID_ATTORNEY_NAME, "ApprovalProcessExecutionInformationPanel.attorney", ae.getAttorney(), attorneyVisible(ae)));
// junction
// or "+" for first decides? probably not
Label junctionLabel = new Label(ID_JUNCTION, stage.isFirstDecides() ? "" : " & ");
// not showing "" to save space (if aligned vertically)
junctionLabel.setVisible(!stage.isFirstDecides() && !ae.isLast());
approversListItem.add(junctionLabel);
}
};
approversList.setVisible(stage.getAutomatedCompletionReason() == null);
stagesListItem.add(approversList);
String autoCompletionKey;
if (stage.getAutomatedCompletionReason() != null) {
switch(stage.getAutomatedCompletionReason()) {
case AUTO_COMPLETION_CONDITION:
autoCompletionKey = "DecisionDto.AUTO_COMPLETION_CONDITION";
break;
case NO_ASSIGNEES_FOUND:
autoCompletionKey = "DecisionDto.NO_ASSIGNEES_FOUND";
break;
// or throw an exception?
default:
autoCompletionKey = null;
}
} else {
autoCompletionKey = null;
}
Label automatedOutcomeLabel = new Label(ID_AUTOMATED_OUTCOME, autoCompletionKey != null ? getString(autoCompletionKey) : "");
automatedOutcomeLabel.setVisible(stage.getAutomatedCompletionReason() != null);
stagesListItem.add(automatedOutcomeLabel);
stagesListItem.add(new Label(ID_STAGE_NAME, getStageNameLabel(stage, stageNumber, numberOfStages)));
ApprovalLevelOutcomeType stageOutcome = stage.getOutcome();
ApprovalOutcomeIcon stageOutcomeIcon;
if (stageOutcome != null) {
switch(stageOutcome) {
case APPROVE:
stageOutcomeIcon = ApprovalOutcomeIcon.APPROVED;
break;
case REJECT:
stageOutcomeIcon = ApprovalOutcomeIcon.REJECTED;
break;
case SKIP:
stageOutcomeIcon = ApprovalOutcomeIcon.SKIPPED;
break;
// perhaps should throw AssertionError instead
default:
stageOutcomeIcon = ApprovalOutcomeIcon.UNKNOWN;
break;
}
} else {
if (stageNumber < currentStageNumber) {
// history: do not show anything (shouldn't occur, as historical stages are filled in)
stageOutcomeIcon = ApprovalOutcomeIcon.EMPTY;
} else if (stageNumber == currentStageNumber) {
stageOutcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.IN_PROGRESS : // currently open
ApprovalOutcomeIcon.CANCELLED;
} else {
stageOutcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.FUTURE : ApprovalOutcomeIcon.CANCELLED;
}
}
ImagePanel stageOutcomePanel = new ImagePanel(ID_STAGE_OUTCOME, Model.of(stageOutcomeIcon.getIcon()), Model.of(getString(stageOutcomeIcon.getTitle())));
stageOutcomePanel.add(new VisibleBehaviour(() -> stageOutcomeIcon != ApprovalOutcomeIcon.EMPTY));
stagesListItem.add(stageOutcomePanel);
}
};
add(stagesList);
}
Aggregations