Search in sources :

Example 1 with EventExportDefinition

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);
}
Also used : EventInstance(com.serotonin.m2m2.rt.event.EventInstance) EventCsvStreamer(com.serotonin.m2m2.vo.export.EventCsvStreamer) Translations(com.serotonin.m2m2.i18n.Translations)

Example 2 with EventExportDefinition

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);
}
Also used : User(com.serotonin.m2m2.vo.User) LongPair(com.serotonin.m2m2.vo.pair.LongPair) EventExportDefinition(com.serotonin.m2m2.web.dwr.beans.EventExportDefinition) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 3 with EventExportDefinition

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);
        }
    }
}
Also used : User(com.serotonin.m2m2.vo.User) EventExportDefinition(com.serotonin.m2m2.web.dwr.beans.EventExportDefinition)

Aggregations

User (com.serotonin.m2m2.vo.User)2 EventExportDefinition (com.serotonin.m2m2.web.dwr.beans.EventExportDefinition)2 Translations (com.serotonin.m2m2.i18n.Translations)1 EventInstance (com.serotonin.m2m2.rt.event.EventInstance)1 EventCsvStreamer (com.serotonin.m2m2.vo.export.EventCsvStreamer)1 LongPair (com.serotonin.m2m2.vo.pair.LongPair)1 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1