use of com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType in project midpoint by Evolveum.
the class PreviewChangesTabPanel method initModels.
private void initModels() {
final List<ObjectDelta<? extends ObjectType>> primaryDeltas = new ArrayList<>();
final List<ObjectDelta<? extends ObjectType>> secondaryDeltas = new ArrayList<>();
final List<? extends Scene> primaryScenes;
final List<? extends Scene> secondaryScenes;
ModelContext<O> modelContext = getModelObject();
try {
if (modelContext != null) {
if (modelContext.getFocusContext() != null) {
addIgnoreNull(primaryDeltas, CloneUtil.clone(modelContext.getFocusContext().getPrimaryDelta()));
ObjectDelta<O> summarySecondaryDelta = CloneUtil.clone(modelContext.getFocusContext().getSummarySecondaryDelta());
if (summarySecondaryDelta != null && !summarySecondaryDelta.getModifications().isEmpty()) {
secondaryDeltas.add(summarySecondaryDelta);
}
}
for (ModelProjectionContext projCtx : modelContext.getProjectionContexts()) {
ObjectDelta<ShadowType> primaryDelta = CloneUtil.clone(projCtx.getPrimaryDelta());
addIgnoreNull(primaryDeltas, primaryDelta);
if (!isEquivalentWithoutOperationAttr(primaryDelta, CloneUtil.clone(projCtx.getExecutableDelta()))) {
addIgnoreNull(secondaryDeltas, CloneUtil.clone(projCtx.getExecutableDelta()));
}
}
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Primary deltas:\n{}", DebugUtil.debugDump(primaryDeltas));
LOGGER.trace("Secondary deltas:\n{}", DebugUtil.debugDump(secondaryDeltas));
}
Task task = getPageBase().createSimpleTask("visualize");
primaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(primaryDeltas, task, task.getResult());
secondaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(secondaryDeltas, task, task.getResult());
} catch (SchemaException | ExpressionEvaluationException e) {
// TODO
throw new SystemException(e);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Creating context DTO for primary deltas:\n{}", DebugUtil.debugDump(primaryScenes));
LOGGER.trace("Creating context DTO for secondary deltas:\n{}", DebugUtil.debugDump(secondaryScenes));
}
final WrapperScene primaryScene = new WrapperScene(primaryScenes, primaryScenes.size() != 1 ? "PagePreviewChanges.primaryChangesMore" : "PagePreviewChanges.primaryChangesOne", primaryScenes.size());
final WrapperScene secondaryScene = new WrapperScene(secondaryScenes, secondaryScenes.size() != 1 ? "PagePreviewChanges.secondaryChangesMore" : "PagePreviewChanges.secondaryChangesOne", secondaryScenes.size());
final SceneDto primarySceneDto = new SceneDto(primaryScene);
final SceneDto secondarySceneDto = new SceneDto(secondaryScene);
primaryDeltasModel = (IModel<SceneDto>) () -> primarySceneDto;
secondaryDeltasModel = (IModel<SceneDto>) () -> secondarySceneDto;
PolicyRuleEnforcerPreviewOutputType enforcements = modelContext != null ? modelContext.getPolicyRuleEnforcerPreviewOutput() : null;
List<EvaluatedTriggerGroupDto> triggerGroups = enforcements != null ? Collections.singletonList(EvaluatedTriggerGroupDto.initializeFromRules(enforcements.getRule(), false, null)) : Collections.emptyList();
policyViolationsModel = Model.ofList(triggerGroups);
List<ApprovalSchemaExecutionInformationType> approvalsExecutionList = modelContext != null ? modelContext.getHookPreviewResults(ApprovalSchemaExecutionInformationType.class) : Collections.emptyList();
List<ApprovalProcessExecutionInformationDto> approvals = new ArrayList<>();
if (!approvalsExecutionList.isEmpty()) {
// TODO
Task opTask = getPageBase().createSimpleTask(PagePreviewChanges.class + ".createApprovals");
OperationResult result = opTask.getResult();
ObjectResolver modelObjectResolver = getPageBase().getModelObjectResolver();
try {
for (ApprovalSchemaExecutionInformationType execution : approvalsExecutionList) {
approvals.add(ApprovalProcessExecutionInformationDto.createFrom(execution, modelObjectResolver, true, opTask, // TODO reuse session
result));
}
result.computeStatus();
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't prepare approval information", t);
result.recordFatalError(createStringResource("PreviewChangesTabPanel.message.prepareApproval.fatalError", t.getMessage()).getString(), t);
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
}
}
approvalsModel = Model.ofList(approvals);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType in project midpoint by Evolveum.
the class PreviewChangesTabPanel method initModels.
private void initModels() {
final List<ObjectDelta<? extends ObjectType>> primaryDeltas = new ArrayList<>();
final List<ObjectDelta<? extends ObjectType>> secondaryDeltas = new ArrayList<>();
final List<? extends Scene> primaryScenes;
final List<? extends Scene> secondaryScenes;
ModelContext<O> modelContext = getModelObject();
try {
if (modelContext != null) {
if (modelContext.getFocusContext() != null) {
addIgnoreNull(primaryDeltas, CloneUtil.clone(modelContext.getFocusContext().getPrimaryDelta()));
ObjectDelta<O> summarySecondaryDelta = CloneUtil.clone(modelContext.getFocusContext().getSummarySecondaryDelta());
if (summarySecondaryDelta != null && !summarySecondaryDelta.getModifications().isEmpty()) {
secondaryDeltas.add(summarySecondaryDelta);
}
}
for (ModelProjectionContext projCtx : modelContext.getProjectionContexts()) {
ObjectDelta<ShadowType> primaryDelta = CloneUtil.clone(projCtx.getPrimaryDelta());
addIgnoreNull(primaryDeltas, primaryDelta);
if (!isEquivalentWithoutOperationAttr(primaryDelta, CloneUtil.clone(projCtx.getExecutableDelta()))) {
addIgnoreNull(secondaryDeltas, CloneUtil.clone(projCtx.getExecutableDelta()));
}
}
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Primary deltas:\n{}", DebugUtil.debugDump(primaryDeltas));
LOGGER.trace("Secondary deltas:\n{}", DebugUtil.debugDump(secondaryDeltas));
}
Task task = getPageBase().createSimpleTask("visualize");
primaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(primaryDeltas, task, task.getResult());
secondaryScenes = getPageBase().getModelInteractionService().visualizeDeltas(secondaryDeltas, task, task.getResult());
} catch (SchemaException | ExpressionEvaluationException e) {
// TODO
throw new SystemException(e);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Creating context DTO for primary deltas:\n{}", DebugUtil.debugDump(primaryScenes));
LOGGER.trace("Creating context DTO for secondary deltas:\n{}", DebugUtil.debugDump(secondaryScenes));
}
final WrapperScene primaryScene = new WrapperScene(primaryScenes, primaryScenes.size() != 1 ? "PagePreviewChanges.primaryChangesMore" : "PagePreviewChanges.primaryChangesOne", primaryScenes.size());
final WrapperScene secondaryScene = new WrapperScene(secondaryScenes, secondaryScenes.size() != 1 ? "PagePreviewChanges.secondaryChangesMore" : "PagePreviewChanges.secondaryChangesOne", secondaryScenes.size());
final SceneDto primarySceneDto = new SceneDto(primaryScene);
final SceneDto secondarySceneDto = new SceneDto(secondaryScene);
primaryDeltasModel = (IModel<SceneDto>) () -> primarySceneDto;
secondaryDeltasModel = (IModel<SceneDto>) () -> secondarySceneDto;
PolicyRuleEnforcerPreviewOutputType enforcements = modelContext != null ? modelContext.getPolicyRuleEnforcerPreviewOutput() : null;
List<EvaluatedTriggerGroupDto> triggerGroups = enforcements != null ? Collections.singletonList(EvaluatedTriggerGroupDto.initializeFromRules(enforcements.getRule(), false, null)) : Collections.emptyList();
policyViolationsModel = Model.ofList(triggerGroups);
List<ApprovalSchemaExecutionInformationType> approvalsExecutionList = modelContext != null ? modelContext.getHookPreviewResults(ApprovalSchemaExecutionInformationType.class) : Collections.emptyList();
List<ApprovalProcessExecutionInformationDto> approvals = new ArrayList<>();
if (!approvalsExecutionList.isEmpty()) {
// TODO
Task opTask = getPageBase().createSimpleTask(PageFocusPreviewChanges.class + ".createApprovals");
OperationResult result = opTask.getResult();
ObjectResolver modelObjectResolver = getPageBase().getModelObjectResolver();
try {
for (ApprovalSchemaExecutionInformationType execution : approvalsExecutionList) {
approvals.add(ApprovalProcessExecutionInformationDto.createFrom(execution, modelObjectResolver, true, opTask, // TODO reuse session
result));
}
result.computeStatus();
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't prepare approval information", t);
result.recordFatalError(createStringResource("PreviewChangesTabPanel.message.prepareApproval.fatalError", t.getMessage()).getString(), t);
}
if (WebComponentUtil.showResultInPage(result)) {
getPageBase().showResult(result);
}
}
approvalsModel = Model.ofList(approvals);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType in project midpoint by Evolveum.
the class ApprovalProcessExecutionInformationDto method createFrom.
@NotNull
public static ApprovalProcessExecutionInformationDto createFrom(ApprovalSchemaExecutionInformationType info, ObjectResolver resolver, boolean wholeProcess, Task opTask, OperationResult result) {
int currentStageNumber = info.getCurrentStageNumber() != null ? info.getCurrentStageNumber() : 0;
int numberOfStages = info.getStage().size();
ObjectResolver.Session session = resolver.openResolutionSession(null);
String processName = ApprovalContextUtil.getProcessName(info);
String targetName = ApprovalContextUtil.getTargetName(info);
CaseType aCase = ApprovalContextUtil.getCase(info);
boolean running = aCase != null && !SchemaConstants.CASE_STATE_CLOSED.equals(aCase.getState());
EvaluatedTriggerGroupDto triggers = EvaluatedTriggerGroupDto.initializeFromRules(ApprovalContextUtil.getAllRules(info.getPolicyRules()), false, new EvaluatedTriggerGroupDto.UniquenessFilter());
ApprovalProcessExecutionInformationDto rv = new ApprovalProcessExecutionInformationDto(wholeProcess, currentStageNumber, numberOfStages, processName, targetName, triggers, running);
int startingStageNumber = wholeProcess ? 1 : currentStageNumber;
boolean reachable = true;
for (int i = startingStageNumber; i <= numberOfStages; i++) {
ApprovalStageExecutionInformationDto stage = ApprovalStageExecutionInformationDto.createFrom(info, i, resolver, session, opTask, result);
stage.setReachable(reachable);
rv.stages.add(stage);
if (stage.getOutcome() == ApprovalLevelOutcomeType.REJECT) {
// for following stages
reachable = false;
}
}
return rv;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType in project midpoint by Evolveum.
the class SwitchableApprovalProcessPreviewsPanel method createApprovalProcessExecutionInformationDto.
@Nullable
private ApprovalProcessExecutionInformationDto createApprovalProcessExecutionInformationDto(PageBase parentPage, boolean wholeProcess) {
Task opTask = parentPage.createSimpleTask(SwitchableApprovalProcessPreviewsPanel.class.getName() + ".createApprovalProcessExecutionInformationDto");
OperationResult result = opTask.getResult();
ApprovalSchemaExecutionInformationType info = approvalExecutionInfoModel.getObject();
ApprovalProcessExecutionInformationDto rv = null;
try {
if (info != null) {
rv = ApprovalProcessExecutionInformationDto.createFrom(info, parentPage.getModelObjectResolver(), wholeProcess, opTask, result);
}
result.computeStatus();
} catch (Throwable t) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create approval process execution information for {}", t, getModelObject());
opTask.getResult().recordFatalError(createStringResource("SwitchableApprovalProcessPreviewsPanel.message.createApprovalProcess.fatalError", t.getMessage()).getString(), t);
}
return rv;
}
Aggregations