Search in sources :

Example 1 with EvaluatedTriggerGroupDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto in project midpoint by Evolveum.

the class PageFocusPreviewChanges method violationsEmpty.

// TODO relocate the logic from the loop to some util method, code repeats in PreviewChangesTabPanel
private boolean violationsEmpty() {
    for (ModelContext<O> modelContext : modelContextMap.values()) {
        PolicyRuleEnforcerPreviewOutputType enforcements = modelContext != null ? modelContext.getPolicyRuleEnforcerPreviewOutput() : null;
        List<EvaluatedTriggerGroupDto> triggerGroups = enforcements != null ? Collections.singletonList(EvaluatedTriggerGroupDto.initializeFromRules(enforcements.getRule(), false, null)) : Collections.emptyList();
        if (!EvaluatedTriggerGroupDto.isEmpty(triggerGroups)) {
            return false;
        }
    }
    return true;
}
Also used : PolicyRuleEnforcerPreviewOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleEnforcerPreviewOutputType) EvaluatedTriggerGroupDto(com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto)

Example 2 with EvaluatedTriggerGroupDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto in project midpoint by Evolveum.

the class EvaluatedTriggerPanel method initLayout.

protected void initLayout() {
    EvaluatedTriggerDto trigger = getModelObject();
    WebMarkupContainer frame = new WebMarkupContainer(ID_FRAME);
    if (trigger.isHighlighted()) {
        // TODO skin
        frame.add(new AttributeAppender("style", "background-color: #fcffd3"));
    }
    add(frame);
    frame.add(new Label(ID_MESSAGE, new LocalizableMessageModel(Model.of(trigger.getMessage()), this)));
    EvaluatedTriggerGroupDto children = trigger.getChildren();
    EvaluatedTriggerGroupPanel childrenPanel = new EvaluatedTriggerGroupPanel(ID_CHILDREN, Model.of(children));
    childrenPanel.setVisible(!children.getTriggers().isEmpty());
    frame.add(childrenPanel);
}
Also used : EvaluatedTriggerDto(com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerDto) Label(org.apache.wicket.markup.html.basic.Label) EvaluatedTriggerGroupDto(com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto) LocalizableMessageModel(com.evolveum.midpoint.web.component.util.LocalizableMessageModel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 3 with EvaluatedTriggerGroupDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto 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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) ArrayList(java.util.ArrayList) ObjectResolver(com.evolveum.midpoint.repo.common.ObjectResolver) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ApprovalProcessExecutionInformationDto(com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalProcessExecutionInformationDto) SystemException(com.evolveum.midpoint.util.exception.SystemException) ApprovalSchemaExecutionInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType) ModelProjectionContext(com.evolveum.midpoint.model.api.context.ModelProjectionContext) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PolicyRuleEnforcerPreviewOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleEnforcerPreviewOutputType) EvaluatedTriggerGroupDto(com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto)

Example 4 with EvaluatedTriggerGroupDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto in project midpoint by Evolveum.

the class PagePreviewChanges method violationsEmpty.

// TODO relocate the logic from the loop to some util method, code repeats in PreviewChangesTabPanel
private boolean violationsEmpty() {
    for (ModelContext<O> modelContext : modelContextMap.values()) {
        PolicyRuleEnforcerPreviewOutputType enforcements = modelContext != null ? modelContext.getPolicyRuleEnforcerPreviewOutput() : null;
        List<EvaluatedTriggerGroupDto> triggerGroups = enforcements != null ? Collections.singletonList(EvaluatedTriggerGroupDto.initializeFromRules(enforcements.getRule(), false, null)) : Collections.emptyList();
        if (!EvaluatedTriggerGroupDto.isEmpty(triggerGroups)) {
            return false;
        }
    }
    return true;
}
Also used : PolicyRuleEnforcerPreviewOutputType(com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleEnforcerPreviewOutputType) EvaluatedTriggerGroupDto(com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto)

Example 5 with EvaluatedTriggerGroupDto

use of com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto in project midpoint by Evolveum.

the class WebComponentUtil method computeTriggers.

public static List<EvaluatedTriggerGroupDto> computeTriggers(ApprovalContextType wfc, Integer stage) {
    List<EvaluatedTriggerGroupDto> triggers = new ArrayList<>();
    if (wfc == null) {
        return triggers;
    }
    EvaluatedTriggerGroupDto.UniquenessFilter uniquenessFilter = new EvaluatedTriggerGroupDto.UniquenessFilter();
    List<List<EvaluatedPolicyRuleType>> rulesPerStageList = ApprovalContextUtil.getRulesPerStage(wfc);
    for (int i = 0; i < rulesPerStageList.size(); i++) {
        Integer stageNumber = i + 1;
        boolean highlighted = stageNumber.equals(stage);
        EvaluatedTriggerGroupDto group = EvaluatedTriggerGroupDto.initializeFromRules(rulesPerStageList.get(i), highlighted, uniquenessFilter);
        triggers.add(group);
    }
    return triggers;
}
Also used : EvaluatedTriggerGroupDto(com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto)

Aggregations

EvaluatedTriggerGroupDto (com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerGroupDto)6 PolicyRuleEnforcerPreviewOutputType (com.evolveum.midpoint.xml.ns._public.common.common_3.PolicyRuleEnforcerPreviewOutputType)4 ModelProjectionContext (com.evolveum.midpoint.model.api.context.ModelProjectionContext)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 ObjectResolver (com.evolveum.midpoint.repo.common.ObjectResolver)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 ApprovalProcessExecutionInformationDto (com.evolveum.midpoint.web.page.admin.workflow.dto.ApprovalProcessExecutionInformationDto)2 ApprovalSchemaExecutionInformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType)2 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)2 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)2 ArrayList (java.util.ArrayList)2 PageFocusPreviewChanges (com.evolveum.midpoint.gui.impl.page.admin.focus.PageFocusPreviewChanges)1 SceneDto (com.evolveum.midpoint.web.component.prism.show.SceneDto)1 WrapperScene (com.evolveum.midpoint.web.component.prism.show.WrapperScene)1 LocalizableMessageModel (com.evolveum.midpoint.web.component.util.LocalizableMessageModel)1 EvaluatedTriggerDto (com.evolveum.midpoint.web.page.admin.workflow.dto.EvaluatedTriggerDto)1