use of org.opennms.netmgt.model.OnmsSeverity in project opennms by OpenNMS.
the class DefaultTicketerServiceLayer method createTicketForAlarm.
/*
* (non-Javadoc)
* @see org.opennms.netmgt.ticketd.TicketerServiceLayer#createTicketForAlarm(int)
*/
/** {@inheritDoc} */
@Override
public void createTicketForAlarm(int alarmId, Map<String, String> attributes) {
OnmsAlarm alarm = m_alarmDao.get(alarmId);
if (alarm == null) {
LOG.error("No alarm with id {} was found. No ticket will be created.", alarmId);
return;
}
if (SKIP_CREATE_WHEN_CLEARED) {
final OnmsSeverity currentSeverity = alarm.getSeverity();
if (currentSeverity != null && currentSeverity.equals(OnmsSeverity.CLEARED)) {
LOG.info("Alarm with id {} is currently cleared. No ticket will be created.", alarmId);
return;
}
}
Ticket ticket = createTicketFromAlarm(alarm, attributes);
try {
m_ticketerPlugin.saveOrUpdate(ticket);
alarm.setTTicketId(ticket.getId());
alarm.setTTicketState(TroubleTicketState.OPEN);
} catch (PluginException e) {
alarm.setTTicketState(TroubleTicketState.CREATE_FAILED);
LOG.error("Unable to create ticket for alarm: {}", e.getMessage(), e);
m_eventIpcManager.sendNow(createEvent(e.getMessage()));
}
m_alarmDao.saveOrUpdate(alarm);
}
use of org.opennms.netmgt.model.OnmsSeverity in project opennms by OpenNMS.
the class DefaultTicketerServiceLayer method closeTicketForAlarm.
/*
* (non-Javadoc)
* @see org.opennms.netmgt.ticketd.TicketerServiceLayer#closeTicketForAlarm(int, java.lang.String)
*/
/** {@inheritDoc} */
@Override
public void closeTicketForAlarm(int alarmId, String ticketId) {
OnmsAlarm alarm = m_alarmDao.get(alarmId);
if (alarm == null) {
LOG.error("No alarm with id {} was found. Ticket with id '{}' will not be closed.", alarmId, ticketId);
return;
}
if (SKIP_CLOSE_WHEN_NOT_CLEARED) {
final OnmsSeverity currentSeverity = alarm.getSeverity();
if (currentSeverity != null && !currentSeverity.equals(OnmsSeverity.CLEARED)) {
LOG.info("Alarm with id {} is not currently cleared. Ticket with id '{}' will not be closed.", alarmId, ticketId);
return;
}
}
try {
setTicketState(ticketId, State.CLOSED);
alarm.setTTicketState(TroubleTicketState.CLOSED);
} catch (PluginException e) {
alarm.setTTicketState(TroubleTicketState.CLOSE_FAILED);
LOG.error("Unable to close ticket for alarm: {}", e.getMessage(), e);
m_eventIpcManager.sendNow(createEvent(e.getMessage()));
}
m_alarmDao.saveOrUpdate(alarm);
}
use of org.opennms.netmgt.model.OnmsSeverity in project opennms by OpenNMS.
the class SeverityGenerator method generateCell.
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
Property<OnmsSeverity> property = source.getContainerProperty(itemId, columnId);
if (property == null || property.getValue() == null) {
return null;
} else {
OnmsSeverity severity = property.getValue();
String label = severity.getLabel();
label = label.toLowerCase();
label = new String(label.substring(0, 1)).toUpperCase() + label.substring(1);
return new Label(" " + escapeHtml(label), Label.CONTENT_XML);
}
}
use of org.opennms.netmgt.model.OnmsSeverity in project opennms by OpenNMS.
the class AlarmSearchProvider method findAlarms.
private List<OnmsAlarm> findAlarms(final List<SearchResult> results, final String queryString) {
CriteriaBuilder bldr = new CriteriaBuilder(OnmsAlarm.class);
OnmsSeverity severity = OnmsSeverity.get(queryString);
List<OnmsAlarm> alarms;
if (!OnmsSeverity.INDETERMINATE.equals(severity)) {
bldr = new CriteriaBuilder(OnmsAlarm.class);
bldr.eq("severity", severity);
alarms = alarmProvider.findMatchingAlarms(bldr.toCriteria());
if (alarms.size() > 0) {
AlarmSearchResult result = new AlarmSearchResult(queryString);
result.setSeverityQuery(true);
results.add(result);
}
} else {
bldr.isNotNull("node").ilike("uei", "%" + queryString + "%").orderBy("node");
alarms = alarmProvider.findMatchingAlarms(bldr.toCriteria());
}
return alarms;
}
use of org.opennms.netmgt.model.OnmsSeverity in project opennms by OpenNMS.
the class AlarmStatusProvider method calculateAlarmStatusForGroup.
private static AlarmStatus calculateAlarmStatusForGroup(List<AlarmSummary> alarmSummaries) {
if (!alarmSummaries.isEmpty()) {
Collections.sort(alarmSummaries, new Comparator<AlarmSummary>() {
@Override
public int compare(AlarmSummary o1, AlarmSummary o2) {
return o1.getMaxSeverity().compareTo(o2.getMaxSeverity());
}
});
OnmsSeverity severity = alarmSummaries.get(0).getMaxSeverity();
int count = 0;
for (AlarmSummary eachSummary : alarmSummaries) {
count += eachSummary.getAlarmCount();
}
return new AlarmStatus(severity.getLabel(), count);
}
return createDefaultStatus();
}
Aggregations