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);
}
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;
}
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();
}
Aggregations