当前位置: 首页>>代码示例>>Java>>正文


Java OnmsEvent类代码示例

本文整理汇总了Java中org.opennms.netmgt.model.OnmsEvent的典型用法代码示例。如果您正苦于以下问题:Java OnmsEvent类的具体用法?Java OnmsEvent怎么用?Java OnmsEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OnmsEvent类属于org.opennms.netmgt.model包,在下文中一共展示了OnmsEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEvents

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
@Test
@Transactional
public void testEvents() {
	assertLoadAll(OnmsEvent.class, new EmptyChecker<OnmsEvent>() {

		public void check(OnmsEvent entity) {
			if (entity.getAlarm() != null) {
				assertEquals("event UEI should equal the alarm UEI", entity.getEventUei(), entity.getAlarm().getUei());
			}
			assertNotNull("associated service lost outages list should not be null", entity.getAssociatedServiceLostOutages());
			assertTrue("there should be zero or more associated service lost outages", entity.getAssociatedServiceLostOutages().size() >= 0);
			assertNotNull("associated service regained outages list should not be null", entity.getAssociatedServiceRegainedOutages());
			assertTrue("there should be zero or more associated service regained outages", entity.getAssociatedServiceRegainedOutages().size() >= 0);
			assertNotNull("dist poller should not be null", entity.getDistPoller());
			assertNotNull("dist poller name should not be null", entity.getDistPoller().getName());
			assertNotNull("notifications list should not be null", entity.getNotifications());
			assertTrue("notifications list size should be greater than or equal to zero", entity.getNotifications().size() >= 0);
		}
		
	});
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:AnnotationTest.java

示例2: setUp

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    // clean out any existing nodes
    for (final OnmsNode node : m_nodeDao.findAll()) {
        m_nodeDao.delete(node);
    }
    m_nodeDao.flush();
    for (final OnmsEvent event : m_eventDao.findAll()) {
    	m_eventDao.delete(event);
    }

    MockLogAppender.setupLogging(true, "DEBUG");
    m_anticipator = new EventAnticipator();
    m_eventManager.setEventAnticipator(m_anticipator);
    m_eventManager.setSynchronous(true);
    m_provisioner.start();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:InvalidRequisitionDataTest.java

示例3: afterPropertiesSet

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
/**
 * <p>afterPropertiesSet</p>
 *
 * @throws java.lang.Exception if any.
 */
@Override
public void afterPropertiesSet() throws Exception {
    BeanUtils.assertAutowiring(this);

    m_task = new TimerTask() {
        private Date m_lastRun = new Date();

        @Override
        public void run() {
            final Date now = new Date();
            final OnmsCriteria criteria = new OnmsCriteria(OnmsEvent.class)
                .add(Restrictions.between("eventTime", m_lastRun, now))
                .add(Restrictions.in("eventUei", m_events));
            for (final OnmsEvent e : m_eventDao.findMatching(criteria)) {
                handleLocationEvent(e);
            }
            m_lastRun = now;
        }
    };
    //m_timer.schedule(m_task, UPDATE_PERIOD, UPDATE_PERIOD);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:LocationBroadcastProcessor.java

示例4: processAck

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
@Test 
public void processAck() {
    
    OnmsNode dbNode = m_nodeDao.get(m_populator.getNode1().getId());
    OnmsEvent event = getEvent(dbNode);
    OnmsNotification notif = getNotification(event);
    // OnmsUserNotification un = getUserNotification(notif);
    
    Assert.assertTrue(m_notifDao.countAll() > 0);
    
    List<OnmsNotification> notifs = m_notifDao.findAll();
    Assert.assertTrue((notifs.contains(notif)));
    
    OnmsAcknowledgment ack = new OnmsAcknowledgment();
    ack.setRefId(notif.getNotifyId());
    ack.setAckType(AckType.NOTIFICATION);
    m_ackService.processAck(ack);
    
    List<Acknowledgeable> ackables = m_ackDao.findAcknowledgables(ack);
    Assert.assertEquals(1, ackables.size());
    Acknowledgeable ackable = ackables.get(0);
    Assert.assertEquals("admin", ackable.getAckUser());
    
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:DefaultAckServiceTest.java

示例5: getEvents

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
/**
 * Returns all the events which match the filter/query in the query
 * parameters
 * 
 * @return Collection of OnmsEvents (ready to be XML-ified)
 * @throws java.text.ParseException
 *             if any.
 */
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML})
@Transactional
public OnmsEventCollection getEvents() throws ParseException {
    readLock();

    try {
        final CriteriaBuilder builder = new CriteriaBuilder(OnmsEvent.class);
        applyQueryFilters(m_uriInfo.getQueryParameters(), builder);
        builder.orderBy("eventTime").asc();

        final OnmsEventCollection coll = new OnmsEventCollection(m_eventDao.findMatching(builder.toCriteria()));
        coll.setTotalCount(m_eventDao.countMatching(builder.clearOrder().toCriteria()));

        return coll;
    } finally {
        readUnlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:28,代码来源:EventRestService.java

示例6: updateEvent

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
/**
 * Updates the event with id "eventid" If the "ack" parameter is "true",
 * then acks the events as the current logged in user, otherwise unacks
 * the events
 * 
 * @param eventId
 *            a {@link java.lang.String} object.
 * @param ack
 *            a {@link java.lang.Boolean} object.
 */
@PUT
@Path("{eventId}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Transactional
public Response updateEvent(@PathParam("eventId") final String eventId, @FormParam("ack") final Boolean ack) {
    writeLock();

    try {
        final OnmsEvent event = m_eventDao.get(new Integer(eventId));
        if (ack == null) {
            throw new IllegalArgumentException("Must supply the 'ack' parameter, set to either 'true' or 'false'");
        }
        processEventAck(event, ack);
        return Response.seeOther(getRedirectUri(m_uriInfo)).build();
    } finally {
        writeUnlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:EventRestService.java

示例7: updateEvents

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
/**
 * Updates all the events that match any filter/query supplied in the
 * form. If the "ack" parameter is "true", then acks the events as the
 * current logged in user, otherwise unacks the events
 * 
 * @param formProperties
 *            Map of the parameters passed in by form encoding
 */
@PUT
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Transactional
public Response updateEvents(final MultivaluedMapImpl formProperties) {
    writeLock();

    try {
        Boolean ack = false;
        if (formProperties.containsKey("ack")) {
            ack = "true".equals(formProperties.getFirst("ack"));
            formProperties.remove("ack");
        }

        final CriteriaBuilder builder = new CriteriaBuilder(OnmsEvent.class);
        applyQueryFilters(formProperties, builder);
        builder.orderBy("eventTime").desc();

        for (final OnmsEvent event : m_eventDao.findMatching(builder.toCriteria())) {
            processEventAck(event, ack);
        }
        return Response.seeOther(getRedirectUri(m_uriInfo)).build();
    } finally {
        writeUnlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:34,代码来源:EventRestService.java

示例8: getMatchingEvents

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
/** {@inheritDoc} */
@Transactional
public Event[] getMatchingEvents(EventCriteria criteria) {
    List<Event> events = new ArrayList<Event>();
    log().debug("getMatchingEvents: try to get events for Criteria: " + criteria.toString());
    List<OnmsEvent> onmsEvents = m_eventDao.findMatching(getOnmsCriteria(criteria));

    log().debug("getMatchingEvents: found " + onmsEvents.size() + " events");

    if(onmsEvents.size() > 0){
        Iterator<OnmsEvent> eventIt = onmsEvents.iterator();
        
        while(eventIt.hasNext()){
            events.add(mapOnmsEventToEvent(eventIt.next()));
        }   
    }
    
    return events.toArray(new Event[0]);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:DaoWebEventRepository.java

示例9: createOutageForService

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
protected void createOutageForService(OnmsMonitoredService monSvc) {
    OnmsEvent outageEvent = new OnmsEvent();
    outageEvent.setEventUei("TEST_UEI");
    outageEvent.setDistPoller(monSvc.getIpInterface().getNode().getDistPoller());
    outageEvent.setEventTime(new Date());
    outageEvent.setEventSource("Me");
    outageEvent.setEventCreateTime(new Date());
    outageEvent.setEventSeverity(0);
    outageEvent.setEventLog("L");
    outageEvent.setEventDisplay("D");
    m_eventDao.save(outageEvent);
    m_eventDao.flush();
    
    OnmsOutage outage = new OnmsOutage(new Date(), outageEvent, monSvc); 
    m_outageDao.save(outage);
    m_outageDao.flush();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:DefaultSiteStatusServiceIntegrationTest.java

示例10: testEventsForNodeId

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
@Test
public void testEventsForNodeId() throws Exception {
    OnmsNode node = new OnmsNode();
    node.setId(1);

    OnmsEvent event = new OnmsEvent();
    event.setDistPoller(m_distPollerDao.get("localhost"));
    event.setEventUei("uei.opennms.org/test");
    event.setEventTime(new Date());
    event.setEventSource("test");
    event.setEventCreateTime(new Date());
    event.setEventSeverity(1);
    event.setEventLog("Y");
    event.setEventDisplay("Y");
    event.setNode(node);
    m_eventDao.save(event);

    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("limit", "50");
    parameters.put("node.id", "1");
    String xml = sendRequest(GET, "/events", parameters, 200);
    assertTrue(xml.contains("totalCount=\"1\""));
    assertTrue(xml.contains("uei.opennms.org/test"));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:IPhoneRestServiceTest.java

示例11: createAlarm

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
private void createAlarm(final OnmsSeverity severity) {
    final OnmsEvent event = getEventDao().findAll().get(0);

    final OnmsAlarm alarm = new OnmsAlarm();
    alarm.setDistPoller(getDistPollerDao().load("localhost"));
    alarm.setUei(event.getEventUei());
    alarm.setAlarmType(1);
    alarm.setNode(m_databasePopulator.getNode1());
    alarm.setDescription("This is a test alarm");
    alarm.setLogMsg("this is a test alarm log message");
    alarm.setCounter(1);
    alarm.setIpAddr(InetAddressUtils.getInetAddress("192.168.1.1"));
    alarm.setSeverity(severity);
    alarm.setFirstEventTime(event.getEventTime());
    alarm.setLastEvent(event);
    alarm.setAlarmAckTime(new Date());
    alarm.setAlarmAckUser("admin");

    getAlarmDao().save(alarm);
    getAlarmDao().flush();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:AlarmRestServiceTest.java

示例12: afterServletStart

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
@Override
protected void afterServletStart() throws Exception {
    count = 0;
       MockLogAppender.setupLogging(true, "DEBUG");
       m_context = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
       m_databasePopulator = m_context.getBean("databasePopulator", DatabasePopulator.class);
       m_databasePopulator.populateDatabase();
       final EventDao eventDao = getEventDao();
       for (final OnmsEvent event : eventDao.findAll()) {
           eventDao.delete(event);
       }
       eventDao.flush();
       final AlarmDao alarmDao = getAlarmDao();
       for (final OnmsAlarm alarm : alarmDao.findAll()) {
           alarmDao.delete(alarm);
       }
       alarmDao.flush();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:AlarmStatsRestServiceTest.java

示例13: setUp

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
@Before
public void setUp(){
    m_dbPopulator.populateDatabase();
    
    OnmsEvent event = new OnmsEvent();
    event.setDistPoller(getDistPoller("localhost", "127.0.0.1"));
    event.setAlarm(m_dbPopulator.getAlarmDao().get(1));
    event.setNode(m_dbPopulator.getNode1());
    event.setEventUei("uei.opennms.org/test2");
    event.setEventTime(new Date());
    event.setEventSource("test");
    event.setEventCreateTime(new Date());
    event.setEventSeverity(OnmsSeverity.CLEARED.getId());
    event.setEventLog("Y");
    event.setEventDisplay("Y");
    event.setIfIndex(11);
    event.setIpAddr(InetAddressUtils.getInetAddress("192.168.1.1"));
    event.setEventLogMsg("This is a test log message");
    event.setEventDescr("This is a test event");
    event.setServiceType(m_dbPopulator.getServiceTypeDao().get(1));
    m_dbPopulator.getEventDao().save(event);
    m_dbPopulator.getEventDao().flush();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:WebEventRepositoryFilterTest.java

示例14: afterPropertiesSet

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
/**
 * <p>afterPropertiesSet</p>
 *
 * @throws java.lang.Exception if any.
 */
public void afterPropertiesSet() throws Exception {
    m_task = new TimerTask() {
        private Date m_lastRun = new Date();

        @Override
        public void run() {
            final Date now = new Date();
            final OnmsCriteria criteria = new OnmsCriteria(OnmsEvent.class)
                .add(Restrictions.between("eventTime", m_lastRun, now))
                .add(Restrictions.in("eventUei", m_events));
            for (final OnmsEvent e : m_eventDao.findMatching(criteria)) {
                handleLocationEvent(e);
            }
            m_lastRun = now;
        }
    };
    //m_timer.schedule(m_task, UPDATE_PERIOD, UPDATE_PERIOD);
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:24,代码来源:LocationBroadcastProcessor.java

示例15: getEvents

import org.opennms.netmgt.model.OnmsEvent; //导入依赖的package包/类
/**
 * Returns all the events which match the filter/query in the query parameters
 *
 * @return Collection of OnmsEvents (ready to be XML-ified)
 * @throws java.text.ParseException if any.
 */
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Transactional
public OnmsEventCollection getEvents() throws ParseException {
    readLock();
    
    try {
   	    final CriteriaBuilder builder = new CriteriaBuilder(OnmsEvent.class);
   	    applyQueryFilters(m_uriInfo.getQueryParameters(), builder);
   
   	    final OnmsEventCollection coll = new OnmsEventCollection(m_eventDao.findMatching(builder.toCriteria()));
   		coll.setTotalCount(m_eventDao.countMatching(builder.clearOrder().toCriteria()));
   		
   		return coll;
    } finally {
        readUnlock();
    }
}
 
开发者ID:vishwaabhinav,项目名称:OpenNMS,代码行数:25,代码来源:EventRestService.java


注:本文中的org.opennms.netmgt.model.OnmsEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。