use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class DefaultLocationDataService method getApplicationsForLocation.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public Collection<ApplicationInfo> getApplicationsForLocation(final LocationInfo locationInfo) {
waitForGeocoding("getApplicationsForLocation");
final Map<String, ApplicationInfo> apps = new HashMap<String, ApplicationInfo>();
for (final OnmsLocationSpecificStatus status : m_locationDao.getMostRecentStatusChangesForLocation(locationInfo.getName())) {
for (final OnmsApplication app : status.getMonitoredService().getApplications()) {
if (!apps.containsKey(app.getName())) {
apps.put(app.getName(), getApplicationInfo(app));
}
}
}
return apps.values();
}
use of org.opennms.netmgt.model.OnmsApplication 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;
}
use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class DefaultLocationDataService method getInfoForAllApplications.
/**
* <p>getInfoForAllApplications</p>
*
* @return a {@link java.util.List} object.
*/
@Transactional
@Override
public List<ApplicationInfo> getInfoForAllApplications() {
waitForGeocoding("handleAllApplications");
Map<OnmsApplication, StatusDetails> statusDetails = getStatusDetailsForAllApplications();
final List<ApplicationInfo> appInfos = new ArrayList<ApplicationInfo>();
for (Map.Entry<OnmsApplication, StatusDetails> entry : statusDetails.entrySet()) {
final ApplicationInfo appInfo = getApplicationInfo(entry.getKey(), entry.getValue());
appInfos.add(appInfo);
}
return appInfos;
}
use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class DefaultAdminApplicationService method addNewApplication.
/**
* {@inheritDoc}
*/
@Override
public OnmsApplication addNewApplication(String name) {
OnmsApplication application = new OnmsApplication();
application.setName(name);
m_applicationDao.save(application);
return application;
}
use of org.opennms.netmgt.model.OnmsApplication in project opennms by OpenNMS.
the class DefaultAdminApplicationService method findByMonitoredService.
/**
* {@inheritDoc}
*/
@Override
public List<OnmsApplication> findByMonitoredService(int id) {
OnmsMonitoredService service = m_monitoredServiceDao.get(id);
if (service == null) {
throw new IllegalArgumentException("monitored service with " + "id of " + id + " could not be found");
}
List<OnmsApplication> sortedApplications = new ArrayList<OnmsApplication>(service.getApplications());
Collections.sort(sortedApplications);
return sortedApplications;
}
Aggregations