use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.
the class DefaultDistributedPollerService method pauseLocationMonitor.
/** {@inheritDoc} */
@Override
public void pauseLocationMonitor(LocationMonitorIdCommand command, BindingResult errors) {
if (command == null) {
throw new IllegalStateException("command argument cannot be null");
}
if (errors == null) {
throw new IllegalStateException("errors argument cannot be null");
}
if (errors.hasErrors()) {
return;
}
OnmsLocationMonitor monitor = m_locationMonitorDao.load(command.getMonitorId());
if (monitor.getStatus() == MonitorStatus.PAUSED) {
errors.addError(new ObjectError(MonitorStatus.class.getName(), new String[] { "distributed.locationMonitor.alreadyPaused" }, new Object[] { command.getMonitorId() }, "Location monitor " + command.getMonitorId() + " is already paused."));
return;
}
monitor.setStatus(MonitorStatus.PAUSED);
m_locationMonitorDao.update(monitor);
}
use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.
the class DefaultDistributedPollerService method getLocationMonitorList.
/**
* <p>getLocationMonitorList</p>
*
* @return a {@link org.opennms.web.svclayer.model.LocationMonitorListModel} object.
*/
@Override
public LocationMonitorListModel getLocationMonitorList() {
List<OnmsLocationMonitor> monitors = m_locationMonitorDao.findAll();
Collections.sort(monitors, m_comparator);
LocationMonitorListModel model = new LocationMonitorListModel();
for (OnmsLocationMonitor monitor : monitors) {
OnmsMonitoringLocation def = m_monitoringLocationDao.get(monitor.getLocation());
model.addLocationMonitor(new LocationMonitorModel(monitor, def));
}
return model;
}
use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.
the class PollerBackEndTest method testReportResultWithBadServiceId.
public void testReportResultWithBadServiceId() {
expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(new OnmsLocationMonitor());
expect(m_monSvcDao.get(1)).andReturn(null);
m_mocks.replayAll();
m_backEnd.reportResult(LOCATION_MONITOR_ID, 1, PollStatus.up());
}
use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.
the class RemotePollerAvailabilityService method getAvailabilityByLocation.
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("availability/{location}")
public OnmsLocationAvailDefinitionList getAvailabilityByLocation(@Context final UriInfo uriInfo, @PathParam("location") String location) {
final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
OnmsMonitoringLocation locationDefinition = m_monitoringLocationDao.get(location);
if (locationDefinition == null) {
throw getException(Status.BAD_REQUEST, "Cannot find location definition: {}", location);
}
Collection<OnmsLocationMonitor> monitors = m_locationMonitorDao.findByLocationDefinition(locationDefinition);
OnmsLocationAvailDefinitionList availList = getAvailabilityList(createTimeChunker(queryParameters), getSortedApplications(), monitors, null);
return availList;
}
use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.
the class RemotePollerAvailabilityService method removeUnneededMonitors.
private static void removeUnneededMonitors(Collection<OnmsLocationSpecificStatus> statusesPeriod, Collection<OnmsLocationMonitor> selectedMonitors) {
if (selectedMonitors != null) {
Collection<OnmsLocationSpecificStatus> unneededStatuses = new ArrayList<OnmsLocationSpecificStatus>();
for (OnmsLocationSpecificStatus status : statusesPeriod) {
for (OnmsLocationMonitor monitor : selectedMonitors) {
if (status.getLocationMonitor().getId() == monitor.getId()) {
unneededStatuses.add(status);
}
}
}
statusesPeriod.removeAll(unneededStatuses);
}
}
Aggregations