Search in sources :

Example 51 with AccessCertificationCampaignType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.

the class SimpleReviewerNotifier method getBody.

@Override
protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task task, OperationResult result) {
    StringBuilder body = new StringBuilder();
    CertReviewEvent reviewEvent = (CertReviewEvent) event;
    AccessCertificationCampaignType campaign = reviewEvent.getCampaign();
    body.append("You have been requested to provide a review in a certification campaign.");
    body.append("\n\nCampaign: ").append(certHelper.getCampaignNameAndOid(reviewEvent));
    body.append("\nState: ").append(certHelper.formatState(reviewEvent));
    body.append("\n\n");
    AccessCertificationStageType stage = CertCampaignTypeUtil.getCurrentStage(campaign);
    if (stage != null) {
        body.append("Stage start time: ").append(XmlTypeConverter.toDate(stage.getStartTimestamp()));
        body.append("\nStage deadline: ").append(XmlTypeConverter.toDate(stage.getDeadline()));
        if (stage.getEscalationLevel() != null) {
            body.append("\nEscalation level: ").append(WfContextUtil.getEscalationLevelInfo(stage.getEscalationLevel()));
        }
        if (stage.getDeadline() != null) {
            long delta = XmlTypeConverter.toMillis(stage.getDeadline()) - System.currentTimeMillis();
            if (delta > 0) {
                if (reviewEvent.isModify()) {
                    body.append("\n\nThis is to notify you that the stage ends in ");
                } else {
                    body.append("\n\nThe stage ends in ");
                }
                body.append(DurationFormatUtils.formatDurationWords(delta, true, true));
            } else if (delta < 0) {
                body.append("\n\nThe stage should have ended ");
                body.append(DurationFormatUtils.formatDurationWords(-delta, true, true));
                body.append(" ago");
            }
        }
        body.append("\n\n");
        body.append("There are ").append(reviewEvent.getCases().size()).append(" cases assigned to you. ");
        body.append("Out of them, ").append(reviewEvent.getCasesAwaitingResponseFromRequestee().size()).append(" have no response from you yet.");
    }
    return body.toString();
}
Also used : AccessCertificationStageType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationStageType) CertReviewEvent(com.evolveum.midpoint.notifications.api.events.CertReviewEvent) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Example 52 with AccessCertificationCampaignType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType in project midpoint by Evolveum.

the class SimpleCampaignStageNotifier method getBody.

@Override
protected String getBody(Event event, GeneralNotifierType generalNotifierType, String transport, Task task, OperationResult result) {
    StringBuilder body = new StringBuilder();
    CertCampaignStageEvent csEvent = (CertCampaignStageEvent) event;
    AccessCertificationCampaignType campaign = csEvent.getCampaign();
    body.append("A certification campaign stage ");
    if (csEvent.isAdd()) {
        body.append("has been started");
    } else if (csEvent.isDelete()) {
        body.append("has been closed");
    } else if (csEvent.isModify()) {
        body.append("is about to be closed");
    }
    body.append(".");
    body.append("\n\nCampaign: ");
    body.append(certHelper.getCampaignNameAndOid(csEvent));
    body.append("\nState: ");
    body.append(certHelper.formatState(csEvent));
    // the event is generated in the real time
    body.append("\n\nTime: ").append(new Date());
    AccessCertificationStageType stage = CertCampaignTypeUtil.getCurrentStage(campaign);
    if (stage != null) {
        body.append("\n\nStage start time: ").append(XmlTypeConverter.toDate(stage.getStartTimestamp()));
        body.append("\nStage deadline time: ").append(XmlTypeConverter.toDate(stage.getDeadline()));
        if (csEvent.isModify() && stage.getDeadline() != null) {
            long delta = XmlTypeConverter.toMillis(stage.getDeadline()) - System.currentTimeMillis();
            if (delta > 0) {
                body.append("\n\nStage ends in ");
                body.append(DurationFormatUtils.formatDurationWords(delta, true, true));
            } else if (delta < 0) {
                body.append("\n\nStage should have ended ");
                body.append(DurationFormatUtils.formatDurationWords(-delta, true, true));
                body.append(" ago");
            }
        }
    }
    body.append("\n");
    if (csEvent.isAdd() || csEvent.isDelete()) {
        body.append("\nRequester: ").append(formatRequester(event, result));
        body.append("\nOperation status: ").append(certHelper.formatStatus(csEvent));
        body.append("\n");
    }
    body.append("\n");
    certHelper.appendStatistics(body, campaign, task, result);
    body.append("\n\n");
    functions.addRequesterAndChannelInformation(body, event, result);
    return body.toString();
}
Also used : CertCampaignStageEvent(com.evolveum.midpoint.notifications.api.events.CertCampaignStageEvent) AccessCertificationStageType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationStageType) Date(java.util.Date) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)31 AccessCertificationCampaignType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)28 AccessCertificationCaseType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType)27 Task (com.evolveum.midpoint.task.api.Task)22 Test (org.testng.annotations.Test)18 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)7 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)6 AccessCertificationCampaignStateType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType)5 Date (java.util.Date)5 CertificationHandler (com.evolveum.midpoint.certification.impl.handlers.CertificationHandler)4 ObjectTypeUtil.toShortString (com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString)4 AccessCertificationWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)4 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 DeltaBuilder (com.evolveum.midpoint.prism.delta.builder.DeltaBuilder)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3