Search in sources :

Example 6 with OnmsSeverity

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);
}
Also used : Ticket(org.opennms.api.integration.ticketing.Ticket) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) PluginException(org.opennms.api.integration.ticketing.PluginException)

Example 7 with OnmsSeverity

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);
}
Also used : OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) PluginException(org.opennms.api.integration.ticketing.PluginException)

Example 8 with OnmsSeverity

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("&nbsp;&nbsp;&nbsp;&nbsp;" + escapeHtml(label), Label.CONTENT_XML);
    }
}
Also used : OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) Label(com.vaadin.ui.Label)

Example 9 with OnmsSeverity

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;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm)

Example 10 with OnmsSeverity

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();
}
Also used : OnmsSeverity(org.opennms.netmgt.model.OnmsSeverity) AlarmSummary(org.opennms.netmgt.model.alarm.AlarmSummary)

Aggregations

OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)18 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)7 ArrayList (java.util.ArrayList)5 OnmsNode (org.opennms.netmgt.model.OnmsNode)5 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)4 SyndContent (com.sun.syndication.feed.synd.SyndContent)2 SyndContentImpl (com.sun.syndication.feed.synd.SyndContentImpl)2 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)2 SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)2 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)2 SyndFeedImpl (com.sun.syndication.feed.synd.SyndFeedImpl)2 Label (com.vaadin.ui.Label)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 PluginException (org.opennms.api.integration.ticketing.PluginException)2 Restrictions (org.opennms.core.criteria.restrictions.Restrictions)2