Search in sources :

Example 1 with LocationMonitorListModel

use of org.opennms.web.svclayer.model.LocationMonitorListModel in project opennms by OpenNMS.

the class LocationMonitorDetailsController method handle.

@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView handle(HttpServletRequest request, @ModelAttribute("command") LocationMonitorIdCommand cmd, BindingResult errors) {
    m_validator.validate(cmd, errors);
    LocationMonitorListModel model = null;
    if (!errors.hasErrors()) {
        model = m_distributedPollerService.getLocationMonitorDetails(cmd, errors);
    }
    if (errors.hasErrors()) {
        return new ModelAndView(ERROR_VIEW);
    } else {
        ModelAndView modelAndView = new ModelAndView(SUCCESS_VIEW, "model", model);
        if (request.isUserInRole(Authentication.ROLE_ADMIN)) {
            modelAndView.addObject("isAdmin", "true");
        }
        return modelAndView;
    }
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) LocationMonitorListModel(org.opennms.web.svclayer.model.LocationMonitorListModel) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with LocationMonitorListModel

use of org.opennms.web.svclayer.model.LocationMonitorListModel 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;
}
Also used : LocationMonitorListModel(org.opennms.web.svclayer.model.LocationMonitorListModel) LocationMonitorModel(org.opennms.web.svclayer.model.LocationMonitorListModel.LocationMonitorModel) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 3 with LocationMonitorListModel

use of org.opennms.web.svclayer.model.LocationMonitorListModel in project opennms by OpenNMS.

the class DefaultDistributedPollerService method getLocationMonitorDetails.

/**
 * {@inheritDoc}
 */
@Override
public LocationMonitorListModel getLocationMonitorDetails(LocationMonitorIdCommand cmd, BindingResult errors) {
    LocationMonitorListModel model = new LocationMonitorListModel();
    model.setErrors(errors);
    if (errors.getErrorCount() > 0) {
        return model;
    }
    OnmsLocationMonitor monitor = m_locationMonitorDao.load(cmd.getMonitorId());
    OnmsMonitoringLocation def = m_monitoringLocationDao.get(monitor.getLocation());
    model.addLocationMonitor(new LocationMonitorModel(monitor, def));
    return model;
}
Also used : LocationMonitorListModel(org.opennms.web.svclayer.model.LocationMonitorListModel) LocationMonitorModel(org.opennms.web.svclayer.model.LocationMonitorListModel.LocationMonitorModel) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 4 with LocationMonitorListModel

use of org.opennms.web.svclayer.model.LocationMonitorListModel in project opennms by OpenNMS.

the class LocationMonitorListController method handleRequestInternal.

/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    LocationMonitorListModel model = m_distributedPollerService.getLocationMonitorList();
    ModelAndView modelAndView = new ModelAndView("distributed/locationMonitorList", "model", model);
    if (request.isUserInRole(Authentication.ROLE_ADMIN)) {
        modelAndView.addObject("isAdmin", "true");
    }
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) LocationMonitorListModel(org.opennms.web.svclayer.model.LocationMonitorListModel)

Aggregations

LocationMonitorListModel (org.opennms.web.svclayer.model.LocationMonitorListModel)4 OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)2 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)2 LocationMonitorModel (org.opennms.web.svclayer.model.LocationMonitorListModel.LocationMonitorModel)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1