use of com.serotonin.m2m2.web.dwr.beans.EventInstanceBean in project ma-core-public by infiniteautomation.
the class DataSourceDwr method getAlarms.
/**
* Get the current alarms for a datasource
*
* @param id
* @return
*/
@DwrPermission(user = true)
public List<EventInstanceBean> getAlarms(int id) {
DataSourceVO<?> ds = Common.runtimeManager.getDataSource(id);
List<EventInstanceBean> beans = new ArrayList<>();
if (ds != null) {
List<EventInstance> events = EventDao.instance.getPendingEventsForDataSource(ds.getId(), Common.getUser().getId());
if (events != null) {
for (EventInstance event : events) beans.add(new EventInstanceBean(event.isActive(), event.getAlarmLevel(), Functions.getTime(event.getActiveTimestamp()), translate(event.getMessage())));
}
}
return beans;
}
use of com.serotonin.m2m2.web.dwr.beans.EventInstanceBean in project ma-core-public by infiniteautomation.
the class DataSourceEditDwr method getAlarms.
@DwrPermission(user = true)
public List<EventInstanceBean> getAlarms() {
DataSourceVO<?> ds = Common.getUser().getEditDataSource();
List<EventInstance> events = EventDao.instance.getPendingEventsForDataSource(ds.getId(), Common.getUser().getId());
List<EventInstanceBean> beans = new ArrayList<>();
if (events != null) {
for (EventInstance event : events) beans.add(new EventInstanceBean(event.isActive(), event.getAlarmLevel(), Functions.getTime(event.getActiveTimestamp()), translate(event.getMessage())));
}
return beans;
}
use of com.serotonin.m2m2.web.dwr.beans.EventInstanceBean in project ma-core-public by infiniteautomation.
the class PublisherEditController method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = Common.getUser(request);
Permissions.ensureAdmin(user);
PublisherVO<? extends PublishedPointVO> publisherVO;
// Get the id.
String idStr = request.getParameter("pid");
if (idStr == null) {
// Adding a new data source? Get the type id.
String typeId = request.getParameter("typeId");
if (StringUtils.isBlank(typeId))
return new ModelAndView(new RedirectView(errorViewName));
// A new publisher
PublisherDefinition def = ModuleRegistry.getPublisherDefinition(typeId);
if (def == null)
return new ModelAndView(new RedirectView(errorViewName));
publisherVO = def.baseCreatePublisherVO();
publisherVO.setXid(PublisherDao.instance.generateUniqueXid());
} else {
// An existing configuration.
int id = Integer.parseInt(idStr);
publisherVO = Common.runtimeManager.getPublisher(id);
if (publisherVO == null)
return new ModelAndView(new RedirectView(errorViewName));
}
// Set the id of the data source in the user object for the DWR.
user.setEditPublisher(publisherVO);
// Create the model.
Map<String, Object> model = new HashMap<>();
model.put("publisher", publisherVO);
if (publisherVO.getId() != Common.NEW_ID) {
List<EventInstance> events = EventDao.instance.getPendingEventsForPublisher(publisherVO.getId(), user.getId());
List<EventInstanceBean> beans = new ArrayList<>();
if (events != null) {
Translations translations = ControllerUtils.getTranslations(request);
for (EventInstance event : events) beans.add(new EventInstanceBean(event.isActive(), event.getAlarmLevel(), Functions.getTime(event.getActiveTimestamp()), event.getMessage().translate(translations)));
}
model.put("publisherEvents", beans);
}
publisherVO.addEditContext(model);
return new ModelAndView(getViewName(), model);
}
Aggregations