Search in sources :

Example 1 with AccessCertificationService

use of com.evolveum.midpoint.model.api.AccessCertificationService in project midpoint by Evolveum.

the class PageCertCampaign method executeCampaignStateOperation.

private void executeCampaignStateOperation(AjaxRequestTarget target, String action) {
    OperationResult result = new OperationResult(OPERATION_ADVANCE_LIFECYCLE);
    try {
        AccessCertificationService acs = getCertificationService();
        Task task;
        switch(action) {
            case OP_START_CAMPAIGN:
            case OP_OPEN_NEXT_STAGE:
                task = createSimpleTask(OPERATION_OPEN_NEXT_STAGE);
                acs.openNextStage(campaignOid, task, result);
                break;
            case OP_CLOSE_STAGE:
                task = createSimpleTask(OPERATION_CLOSE_STAGE);
                acs.closeCurrentStage(campaignOid, task, result);
                break;
            case OP_START_REMEDIATION:
                task = createSimpleTask(OPERATION_START_REMEDIATION);
                acs.startRemediation(campaignOid, task, result);
                break;
            case OP_CLOSE_CAMPAIGN:
                task = createSimpleTask(OPERATION_CLOSE_CAMPAIGN);
                acs.closeCampaign(campaignOid, task, result);
                break;
            default:
                throw new IllegalStateException("Unknown action: " + action);
        }
    } catch (Exception ex) {
        result.recordFatalError(ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    WebComponentUtil.safeResultCleanup(result, LOGGER);
    showResult(result);
    statModel.reset();
    campaignModel.reset();
    target.add(get(createComponentPath(ID_MAIN_FORM)));
    // ???
    target.add((Component) getOutcomesTable());
    target.add(getFeedbackPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService)

Example 2 with AccessCertificationService

use of com.evolveum.midpoint.model.api.AccessCertificationService in project midpoint by Evolveum.

the class PageCertCampaigns method openNextStagePerformed.

private void openNextStagePerformed(AjaxRequestTarget target, AccessCertificationCampaignType campaign) {
    LOGGER.debug("Start campaign / open next stage performed for {}", campaign.asPrismObject());
    OperationResult result = new OperationResult(OPERATION_OPEN_NEXT_STAGE);
    AccessCertificationService acs = getCertificationService();
    try {
        Task task = createSimpleTask(OPERATION_OPEN_NEXT_STAGE);
        int currentStage = campaign.getStageNumber();
        acs.openNextStage(campaign.getOid(), task, result);
    } catch (Exception ex) {
        result.recordFatalError(ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    WebComponentUtil.safeResultCleanup(result, LOGGER);
    showResult(result);
    target.add((Component) getCampaignsTable());
    target.add(getFeedbackPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService)

Example 3 with AccessCertificationService

use of com.evolveum.midpoint.model.api.AccessCertificationService in project midpoint by Evolveum.

the class PageCertCampaigns method reiterateCampaignConfirmedPerformed.

private void reiterateCampaignConfirmedPerformed(AjaxRequestTarget target, CertCampaignListItemDto campaignDto) {
    AccessCertificationCampaignType campaign = campaignDto.getCampaign();
    LOGGER.debug("Reiterate certification campaign performed for {}", campaign.asPrismObject());
    OperationResult result = new OperationResult(OPERATION_REITERATE_CAMPAIGN);
    try {
        AccessCertificationService acs = getCertificationService();
        Task task = createSimpleTask(OPERATION_REITERATE_CAMPAIGN);
        acs.reiterateCampaign(campaign.getOid(), task, result);
    } catch (Exception ex) {
        result.recordFatalError(ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    WebComponentUtil.safeResultCleanup(result, LOGGER);
    showResult(result);
    target.add((Component) getCampaignsTable());
    target.add(getFeedbackPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Example 4 with AccessCertificationService

use of com.evolveum.midpoint.model.api.AccessCertificationService in project midpoint by Evolveum.

the class PageCertCampaigns method startRemediationPerformed.

private void startRemediationPerformed(AjaxRequestTarget target, AccessCertificationCampaignType campaign) {
    LOGGER.debug("Start remediation performed for {}", campaign.asPrismObject());
    OperationResult result = new OperationResult(OPERATION_START_REMEDIATION);
    AccessCertificationService acs = getCertificationService();
    try {
        Task task = createSimpleTask(OPERATION_START_REMEDIATION);
        acs.startRemediation(campaign.getOid(), task, result);
    } catch (Exception ex) {
        result.recordFatalError(ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    WebComponentUtil.safeResultCleanup(result, LOGGER);
    showResult(result);
    target.add((Component) getCampaignsTable());
    target.add(getFeedbackPanel());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService)

Example 5 with AccessCertificationService

use of com.evolveum.midpoint.model.api.AccessCertificationService in project midpoint by Evolveum.

the class PageCertCampaigns method actOnCampaignsPerformed.

private void actOnCampaignsPerformed(AjaxRequestTarget target, String operationName, List<CertCampaignListItemDto> items) {
    int processed = 0;
    AccessCertificationService acs = getCertificationService();
    OperationResult result = new OperationResult(operationName);
    for (CertCampaignListItemDto item : items) {
        try {
            AccessCertificationCampaignType campaign = item.getCampaign();
            Task task = createSimpleTask(operationName);
            if (OPERATION_START_CAMPAIGN.equals(operationName)) {
                if (campaign.getState() == AccessCertificationCampaignStateType.CREATED) {
                    acs.openNextStage(campaign.getOid(), task, result);
                    processed++;
                }
            } else if (OPERATION_CLOSE_CAMPAIGN.equals(operationName)) {
                if (campaign.getState() != AccessCertificationCampaignStateType.CLOSED) {
                    acs.closeCampaign(campaign.getOid(), task, result);
                    processed++;
                }
            } else if (OPERATION_REITERATE_CAMPAIGN.equals(operationName)) {
                if (item.isReiterable()) {
                    acs.reiterateCampaign(campaign.getOid(), task, result);
                    processed++;
                }
            } else {
                throw new IllegalStateException("Unknown action: " + operationName);
            }
        } catch (Exception ex) {
            result.recordPartialError(createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.partialError").getString(), ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't process campaign", ex);
        }
    }
    if (processed == 0) {
        warn(getString("PageCertCampaigns.message.noCampaignsSelected"));
        target.add(getFeedbackPanel());
        return;
    }
    result.recomputeStatus();
    if (result.isSuccess()) {
        result.recordStatus(OperationResultStatus.SUCCESS, createStringResource("PageCertCampaigns.message.actOnCampaignsPerformed.success", processed).getString());
    }
    WebComponentUtil.safeResultCleanup(result, LOGGER);
    showResult(result);
    target.add(getFeedbackPanel(), (Component) getCampaignsTable());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CertCampaignListItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Aggregations

AccessCertificationService (com.evolveum.midpoint.model.api.AccessCertificationService)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Task (com.evolveum.midpoint.task.api.Task)9 AccessCertificationCampaignType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)2 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 CertCampaignListItemDto (com.evolveum.midpoint.web.page.admin.certification.dto.CertCampaignListItemDto)1 AccessCertificationWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)1