Search in sources :

Example 6 with CertCampaignStageEvent

use of com.evolveum.midpoint.notifications.api.events.CertCampaignStageEvent in project midpoint by Evolveum.

the class CertificationListener method onCampaignStageEnd.

@Override
public void onCampaignStageEnd(AccessCertificationCampaignType campaign, Task task, OperationResult result) {
    CertCampaignStageEvent event = certEventFactory.createOnCampaignStageEndEvent(campaign, task, result);
    processEvent(event, task, result);
}
Also used : CertCampaignStageEvent(com.evolveum.midpoint.notifications.api.events.CertCampaignStageEvent)

Example 7 with CertCampaignStageEvent

use of com.evolveum.midpoint.notifications.api.events.CertCampaignStageEvent in project midpoint by Evolveum.

the class CertEventFactory method createOnCampaignStageStartEvent.

public CertCampaignStageEvent createOnCampaignStageStartEvent(AccessCertificationCampaignType campaign, Task task, OperationResult result) {
    CertCampaignStageEvent event = new CertCampaignStageEvent(idGenerator, campaign, EventOperationType.ADD);
    fillInEvent(campaign, task, event);
    return event;
}
Also used : CertCampaignStageEvent(com.evolveum.midpoint.notifications.api.events.CertCampaignStageEvent)

Example 8 with CertCampaignStageEvent

use of com.evolveum.midpoint.notifications.api.events.CertCampaignStageEvent 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

CertCampaignStageEvent (com.evolveum.midpoint.notifications.api.events.CertCampaignStageEvent)8 AccessCertificationCampaignType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)1 AccessCertificationStageType (com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationStageType)1 Date (java.util.Date)1