use of com.serotonin.m2m2.rt.event.EventInstance in project ma-core-public by infiniteautomation.
the class EmailHandlerRT method eventRaised.
@Override
public void eventRaised(EventInstance evt) {
// Get the email addresses to send to
activeRecipients = MailingListDao.instance.getRecipientAddresses(vo.getActiveRecipients(), new DateTime(evt.getActiveTimestamp()));
// Send an email to the active recipients.
sendEmail(evt, NotificationType.ACTIVE, activeRecipients);
// If an inactive notification is to be sent, save the active recipients.
if (vo.isSendInactive()) {
if (vo.isInactiveOverride())
inactiveRecipients = MailingListDao.instance.getRecipientAddresses(vo.getInactiveRecipients(), new DateTime(evt.getActiveTimestamp()));
else
inactiveRecipients = activeRecipients;
}
// If an escalation is to be sent, set up timeout to trigger it.
if (vo.isSendEscalation()) {
long delayMS = Common.getMillis(vo.getEscalationDelayType(), vo.getEscalationDelay());
escalationTask = new ModelTimeoutTask<EventInstance>(delayMS, this, evt);
}
}
use of com.serotonin.m2m2.rt.event.EventInstance in project ma-modules-public by infiniteautomation.
the class UserEventsV2Controller method query.
@ApiOperation(value = "Query User Events", notes = "Query via rql in url against events for the current user", response = EventInstanceModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, value = "")
public ResponseEntity<PageQueryResultModel<EventInstanceModel>> query(@AuthenticationPrincipal User user, HttpServletRequest request) {
// Parse the RQL Query
ASTNode query = parseRQLtoAST(request.getQueryString());
List<EventInstance> results;
List<EventInstance> events = Common.eventManager.getAllActiveUserEvents(user.getId());
if (query != null)
results = query.accept(new RQLToObjectListQuery<EventInstance>(), events);
else
results = events;
List<EventInstanceModel> models = new ArrayList<>();
// Convert to models
for (EventInstance event : results) {
models.add(new EventInstanceModel(event));
}
// Query the models
return new ResponseEntity<>(new PageQueryResultModel<>(models, events.size()), HttpStatus.OK);
}
use of com.serotonin.m2m2.rt.event.EventInstance in project ma-modules-public by infiniteautomation.
the class ReportDao method getReportInstanceEvents.
public List<EventInstance> getReportInstanceEvents(int instanceId) {
// Get the events.
final List<EventInstance> events = query(EVENT_SELECT, new Object[] { instanceId }, new EventDao.EventInstanceRowMapper());
// Add in the comments.
ejt.query(EVENT_COMMENT_SELECT, new Object[] { instanceId, UserCommentVO.TYPE_EVENT }, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
// Create the comment
UserCommentVO c = new UserCommentVO();
c.setUsername(rs.getString(1));
c.setTs(rs.getLong(3));
c.setComment(rs.getString(4));
// Find the event and add the comment
int eventId = rs.getInt(2);
for (EventInstance event : events) {
if (event.getId() == eventId) {
if (event.getEventComments() == null)
event.setEventComments(new ArrayList<UserCommentVO>());
event.addEventComment(c);
}
}
}
});
// Done
return events;
}
use of com.serotonin.m2m2.rt.event.EventInstance in project ma-modules-public by infiniteautomation.
the class ReportEventHandlerRT method eventRaised.
/* (non-Javadoc)
* @see com.serotonin.m2m2.rt.event.handlers.EventHandlerRT#eventRaised(com.serotonin.m2m2.rt.event.EventInstance)
*/
@Override
public void eventRaised(EventInstance evt) {
try {
if (vo.getActiveReportId() != Common.NEW_ID) {
// Schedule the Active Report To Run
ReportVO report = ReportDao.instance.get(vo.getActiveReportId());
if (report != null) {
String host = InetAddress.getLocalHost().getHostName();
int port = Common.envProps.getInt("web.port", 8080);
ReportWorkItem.queueReport(host, port, report);
}
}
} catch (UnknownHostException e) {
LOG.error(e.getMessage(), e);
}
}
use of com.serotonin.m2m2.rt.event.EventInstance in project ma-modules-public by infiniteautomation.
the class ReportEventHandlerRT method eventInactive.
/* (non-Javadoc)
* @see com.serotonin.m2m2.rt.event.handlers.EventHandlerRT#eventInactive(com.serotonin.m2m2.rt.event.EventInstance)
*/
@Override
public void eventInactive(EventInstance evt) {
try {
if (vo.getInactiveReportId() != Common.NEW_ID) {
// Schedule the Inactive Report to run
ReportVO report = ReportDao.instance.get(vo.getInactiveReportId());
if (report != null) {
String host = InetAddress.getLocalHost().getHostName();
int port = Common.envProps.getInt("web.port", 8080);
ReportWorkItem.queueReport(host, port, report);
}
}
} catch (UnknownHostException e) {
LOG.error(e.getMessage(), e);
}
}
Aggregations