use of com.serotonin.m2m2.web.dwr.beans.EventExportDefinition in project ma-core-public by infiniteautomation.
the class EventExportServlet method exportCsv.
/**
* @param response
* @param def
* @param user
* @throws IOException
*/
private void exportCsv(HttpServletResponse response, EventExportDefinition def, User user) throws IOException {
final Translations translations = Common.getTranslations();
List<EventInstance> events = EventDao.instance.search(def.getEventId(), def.getEventType(), def.getStatus(), def.getAlarmLevel(), def.getKeywords(), def.getDateFrom(), def.getDateTo(), user.getId(), translations, 0, Integer.MAX_VALUE, null);
// Stream the content.
response.setContentType("text/csv");
new EventCsvStreamer(response.getWriter(), events, translations);
}
use of com.serotonin.m2m2.web.dwr.beans.EventExportDefinition in project ma-core-public by infiniteautomation.
the class EventsDwr method exportEvents.
@DwrPermission(user = true)
public void exportEvents(int eventId, String eventType, String status, int alarmLevel, String keywordStr, int dateRangeType, int relativeDateType, int previousPeriodCount, int previousPeriodType, int pastPeriodCount, int pastPeriodType, boolean fromNone, int fromYear, int fromMonth, int fromDay, int fromHour, int fromMinute, int fromSecond, boolean toNone, int toYear, int toMonth, int toDay, int toHour, int toMinute, int toSecond) {
User user = Common.getUser();
LongPair dateRange = getDateRange(dateRangeType, relativeDateType, previousPeriodCount, previousPeriodType, pastPeriodCount, pastPeriodType, fromNone, fromYear, fromMonth, fromDay, fromHour, fromMinute, fromSecond, toNone, toYear, toMonth, toDay, toHour, toMinute, toSecond, user.getDateTimeZoneInstance());
EventExportDefinition def = new EventExportDefinition(eventId, eventType, status, alarmLevel, getKeywords(keywordStr), dateRange.getL1(), dateRange.getL2(), user.getId());
Common.getUser().setEventExportDefinition(def);
}
use of com.serotonin.m2m2.web.dwr.beans.EventExportDefinition in project ma-core-public by infiniteautomation.
the class EventExportServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
User user = Common.getUser(request);
if (user == null)
return;
// Eventually Switch on file type
String pathInfo = request.getPathInfo();
if (pathInfo != null) {
if (pathInfo.endsWith(".xlsx"))
this.exportExcel(response, user);
else {
EventExportDefinition def = user.getEventExportDefinition();
if (def == null)
return;
this.exportCsv(response, def, user);
}
}
}
Aggregations