@Test
  @Transactional
  @JUnitTemporaryDatabase
  public void testCountMatchingAlarmsBySeverity() {
    AlarmCriteria criteria = new AlarmCriteria();
    int[] matchingAlarms =
        m_alarmRepo.countMatchingAlarmsBySeverity(AlarmUtil.getOnmsCriteria(criteria));

    assertEquals(8, matchingAlarms.length);

    // Make sure that the count is correct per severity
    assertEquals(0, matchingAlarms[OnmsSeverity.CLEARED.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.CRITICAL.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.INDETERMINATE.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.MINOR.getId()]);
    assertEquals(1, matchingAlarms[OnmsSeverity.NORMAL.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.WARNING.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.MAJOR.getId()]);
  }
Ejemplo n.º 2
0
  @Override
  public String getStyle(Object itemId, Object propertyId) {
    if (propertyId == null) {
      StringBuffer retval = new StringBuffer();
      Integer severity = (Integer) m_table.getContainerProperty(itemId, "severityId").getValue();
      Property prop = m_table.getContainerProperty(itemId, "acknowledged");
      Boolean acknowledged = false;
      if (prop != null) {
        acknowledged = (Boolean) prop.getValue();
      }

      if (OnmsSeverity.CLEARED.getId() == severity) {
      } else if (OnmsSeverity.CRITICAL.getId() == severity) {
        retval.append("alarm-critical");
      } else if (OnmsSeverity.INDETERMINATE.getId() == severity) {
        retval.append("alarm-indeterminate");
      } else if (OnmsSeverity.MAJOR.getId() == severity) {
        retval.append("alarm-major");
      } else if (OnmsSeverity.MINOR.getId() == severity) {
        retval.append("alarm-minor");
      } else if (OnmsSeverity.NORMAL.getId() == severity) {
        retval.append("alarm-normal");
      } else if (OnmsSeverity.WARNING.getId() == severity) {
        retval.append("alarm-warning");
      }

      if (!acknowledged) {
        retval.append("-noack");
      }

      return retval.toString();
    } else if ("severity".equals(propertyId)) {
      return "bright";
    }
    return null;
  }