Search in sources :

Example 1 with ApplicationState

use of org.opennms.features.poller.remote.gwt.client.ApplicationState in project opennms by OpenNMS.

the class DefaultLocationDataService method getLocationDetails.

/**
     * <p>getLocationDetails</p>
     *
     * @param def a {@link org.opennms.netmgt.model.OnmsMonitoringLocationDefinition} object.
     * @return a {@link org.opennms.features.poller.remote.gwt.client.location.LocationDetails} object.
     */
@Transactional
@Override
public LocationDetails getLocationDetails(final OnmsMonitoringLocation def) {
    waitForGeocoding("getLocationDetails");
    final LocationDetails ld = new LocationDetails();
    final DefaultLocationDataService.MonitorStatusTracker mst = new DefaultLocationDataService.MonitorStatusTracker(def.getLocationName());
    final DefaultLocationDataService.ApplicationStatusTracker ast = new DefaultLocationDataService.ApplicationStatusTracker(def.getLocationName());
    final List<GWTLocationMonitor> monitors = new ArrayList<GWTLocationMonitor>();
    for (OnmsLocationMonitor mon : m_locationDao.findByLocationDefinition(def)) {
        monitors.add(transformLocationMonitor(mon));
    }
    final Set<ApplicationInfo> applications = new HashSet<ApplicationInfo>();
    for (final OnmsApplication application : m_applicationDao.findAll()) {
        applications.add(transformApplication(m_monitoredServiceDao.findByApplication(application), application));
    }
    //        for (final OnmsMonitoredService service : m_monitoredServiceDao.findAll()) {
    //            for (final OnmsApplication app : service.getApplications()) {
    //                final String appName = app.getName();
    //                Set<OnmsMonitoredService> serv = services.get(appName);
    //                if (serv == null) {
    //                    serv = new HashSet<OnmsMonitoredService>();
    //                    services.put(appName, serv);
    //                }
    //                serv.add(service);
    //            }
    //        }
    final Date to = new Date();
    final Date from = new Date(to.getTime() - AVAILABILITY_MS);
    for (OnmsLocationSpecificStatus status : m_locationDao.getMostRecentStatusChangesForLocation(def.getLocationName())) {
        mst.onStatus(status);
        ast.onStatus(status);
    }
    ld.setLocationMonitorState(new LocationMonitorState(monitors, mst.drain()));
    ld.setApplicationState(new ApplicationState(from, to, applications, monitors, ast.drainStatuses()));
    LOG.debug("getLocationDetails({}) returning {}", def.getLocationName(), ld);
    return ld;
}
Also used : LocationDetails(org.opennms.features.poller.remote.gwt.client.location.LocationDetails) OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ApplicationState(org.opennms.features.poller.remote.gwt.client.ApplicationState) ArrayList(java.util.ArrayList) ApplicationInfo(org.opennms.features.poller.remote.gwt.client.ApplicationInfo) LocationMonitorState(org.opennms.features.poller.remote.gwt.client.LocationMonitorState) GWTLocationMonitor(org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) Date(java.util.Date) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)1 ApplicationState (org.opennms.features.poller.remote.gwt.client.ApplicationState)1 GWTLocationMonitor (org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor)1 LocationMonitorState (org.opennms.features.poller.remote.gwt.client.LocationMonitorState)1 LocationDetails (org.opennms.features.poller.remote.gwt.client.location.LocationDetails)1 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)1 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)1 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)1 Transactional (org.springframework.transaction.annotation.Transactional)1