public static SLAEventBean createSlaRegistrationEvent(Element eSla, Store store, String slaId, SlaAppType appType, String user,
String groupName) throws Exception {
if (eSla == null) {
return null;
}
SLAEventBean sla = new SLAEventBean();
sla.setAppName(getTagElement(eSla, "app-name"));
sla.setParentClientId(getTagElement(eSla, "parent-child-id"));
sla.setParentSlaId(getTagElement(eSla, "parent-sla-id"));
String strNominalTime = getTagElement(eSla, "nominal-time");
if (strNominalTime == null || strNominalTime.length() == 0) {
throw new RuntimeException("Nominal time is required"); // TODO:
// change to
// CommandException
}
Date nominalTime = DateUtils.parseDateOozieTZ(strNominalTime);
// Setting expected start time
String strRelExpectedStart = getTagElement(eSla, "should-start");
if (strRelExpectedStart != null && strRelExpectedStart.length() > 0) {
int relExpectedStart = Integer.parseInt(strRelExpectedStart);
if (relExpectedStart < 0) {
sla.setExpectedStart(null);
}
else {
Date expectedStart = new Date(nominalTime.getTime() + relExpectedStart * 60 * 1000);
sla.setExpectedStart(expectedStart);
}
} else {
sla.setExpectedStart(null);
}
// Setting expected end time
String strRelExpectedEnd = getTagElement(eSla, "should-end");
if (strRelExpectedEnd == null || strRelExpectedEnd.length() == 0) {
throw new RuntimeException("should-end can't be empty");
}
int relExpectedEnd = Integer.parseInt(strRelExpectedEnd);
if (relExpectedEnd < 0) {
sla.setExpectedEnd(null);
}
else {
Date expectedEnd = new Date(nominalTime.getTime() + relExpectedEnd * 60 * 1000);
sla.setExpectedEnd(expectedEnd);
}
sla.setNotificationMsg(getTagElement(eSla, "notification-msg"));
sla.setAlertContact(getTagElement(eSla, "alert-contact"));
sla.setDevContact(getTagElement(eSla, "dev-contact"));
sla.setQaContact(getTagElement(eSla, "qa-contact"));
sla.setSeContact(getTagElement(eSla, "se-contact"));
sla.setAlertFrequency(getTagElement(eSla, "alert-frequency"));
sla.setAlertPercentage(getTagElement(eSla, "alert-percentage"));
sla.setUpstreamApps(getTagElement(eSla, "upstream-apps"));
// Oozie defined
sla.setSlaId(slaId);
sla.setAppType(appType);
sla.setUser(user);
sla.setGroupName(groupName);
sla.setJobStatus(Status.CREATED);
sla.setStatusTimestamp(new Date());
return sla;
}