use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.
the class DefaultLocationDataService method getUpdatedLocationsBetween.
/**
* {@inheritDoc}
*/
@Transactional
@Override
public Collection<LocationInfo> getUpdatedLocationsBetween(final Date startDate, final Date endDate) {
waitForGeocoding("getApplicationDetails");
final Collection<LocationInfo> locations = new ArrayList<LocationInfo>();
final Map<String, OnmsMonitoringLocation> definitions = new HashMap<String, OnmsMonitoringLocation>();
// check for any monitors that have changed status
for (OnmsMonitoringLocation def : m_monitoringLocationDao.findAll()) {
for (OnmsLocationMonitor mon : m_locationDao.findByLocationDefinition(def)) {
final MonitorStatus status = m_monitorStatuses.get(mon.getLocation());
if (status == null || !status.equals(mon.getStatus())) {
definitions.put(def.getLocationName(), def);
m_monitorStatuses.put(def.getLocationName(), mon.getStatus());
}
}
}
// check for any definitions that have status updates
for (final OnmsLocationSpecificStatus status : m_locationDao.getStatusChangesBetween(startDate, endDate)) {
final String definitionName = status.getLocationMonitor().getLocation();
if (!definitions.containsKey(definitionName)) {
definitions.put(definitionName, m_monitoringLocationDao.get(definitionName));
}
}
for (final OnmsMonitoringLocation def : definitions.values()) {
final LocationInfo location = getLocationInfo(def);
locations.add(location);
}
return locations;
}
use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.
the class DefaultLocationDataService method getInfoForAllLocations.
/**
* <p>getInfoForAllLocations</p>
*
* @return a {@link java.util.List} object.
*/
@Transactional
@Override
public List<LocationInfo> getInfoForAllLocations() {
waitForGeocoding("getInfoForAllLocations");
Map<String, StatusDetails> statusDetails = getStatusDetailsForAllLocations();
List<LocationInfo> locations = new ArrayList<LocationInfo>();
for (Map.Entry<String, StatusDetails> entry : statusDetails.entrySet()) {
OnmsMonitoringLocation def = m_monitoringLocationDao.get(entry.getKey());
LocationInfo locationInfo = this.getLocationInfo(def, entry.getValue());
locations.add(locationInfo);
}
return locations;
}
use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.
the class DefaultLocationDataService method getLocationInfo.
private LocationInfo getLocationInfo(final OnmsMonitoringLocation def, final StatusDetails monitorStatus) {
GWTLatLng latLng = getLatLng(def, false);
if (latLng == null) {
LOG.debug("no geolocation or coordinates found, using OpenNMS World HQ");
latLng = new GWTLatLng(35.715751, -79.16262);
}
final GWTMarkerState state = new GWTMarkerState(def.getLocationName(), latLng, Status.UNKNOWN);
Set<String> tags = new TreeSet<String>();
if (def.getTags() != null) {
for (String tag : def.getTags()) {
tags.add(tag);
}
}
final LocationInfo locationInfo = new LocationInfo(def.getLocationName(), def.getMonitoringArea(), def.getGeolocation(), latLng.getCoordinates(), def.getPriority(), state, null, tags);
state.setStatus(monitorStatus.getStatus());
locationInfo.setStatusDetails(monitorStatus);
// LOG.debug("getLocationInfo({}) returning {}", def.getLocationName(), locationInfo);
return locationInfo;
}
use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.
the class LocationAddedToMapTest method testStatusMessage.
@Test
public void testStatusMessage() {
int numLocations = 10;
Set<LocationInfo> locations = new HashSet<>();
createLocations(numLocations, locations);
m_testServer.sendDomainEvent(new LocationsUpdatedRemoteEvent(locations));
int updated = 0;
while (!m_testExecutor.runOnePass()) {
updated++;
assertEquals("Updated " + updated + " of 10", m_testApplicationView.getStatusMessage());
}
}
use of org.opennms.features.poller.remote.gwt.client.location.LocationInfo in project opennms by OpenNMS.
the class LocationAddedToMapTest method createApps.
private Set<ApplicationInfo> createApps(int numApps, Set<LocationInfo> locations) {
Set<String> locNames = new HashSet<>();
for (LocationInfo location : locations) {
locNames.add(location.getName());
}
Set<ApplicationInfo> apps = new HashSet<>();
for (int i = 1; i <= numApps; i++) {
apps.add(new ApplicationInfo(i, "app" + i, Collections.<GWTMonitoredService>emptySet(), locNames, new StatusDetails(Status.UP, "All things good here")));
}
return apps;
}
Aggregations