Search in sources :

Example 1 with LongPair

use of com.serotonin.m2m2.vo.pair.LongPair in project ma-modules-public by infiniteautomation.

the class PointValueFftCalculator method setupDates.

/**
 * Setup the dates based on available data
 */
private void setupDates() {
    // Determine the start and end times.
    if (from == -1) {
        // Get the start and end from the point values table.
        LongPair lp = Common.databaseProxy.newPointValueDao().getStartAndEndTime(Collections.singletonList(vo.getId()));
        from = lp.getL1();
        to = lp.getL2();
    }
}
Also used : LongPair(com.serotonin.m2m2.vo.pair.LongPair)

Example 2 with LongPair

use of com.serotonin.m2m2.vo.pair.LongPair in project ma-core-public by infiniteautomation.

the class EventsDwr method getDateRange.

private LongPair getDateRange(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, DateTimeZone dtz) {
    LongPair range = new LongPair(-1, -1);
    if (dateRangeType == DATE_RANGE_TYPE_RELATIVE) {
        if (relativeDateType == RELATIVE_DATE_TYPE_PREVIOUS) {
            DateTime dt = DateUtils.truncateDateTime(new DateTime(dtz), previousPeriodType);
            range.setL2(dt.getMillis());
            dt = DateUtils.minus(dt, previousPeriodType, previousPeriodCount);
            range.setL1(dt.getMillis());
        } else {
            DateTime dt = new DateTime(dtz);
            range.setL2(dt.getMillis());
            dt = DateUtils.minus(dt, pastPeriodType, pastPeriodCount);
            range.setL1(dt.getMillis());
        }
    } else if (dateRangeType == DATE_RANGE_TYPE_SPECIFIC) {
        if (!fromNone) {
            DateTime dt = new DateTime(fromYear, fromMonth, fromDay, fromHour, fromMinute, fromSecond, 0, dtz);
            range.setL1(dt.getMillis());
        }
        if (!toNone) {
            DateTime dt = new DateTime(toYear, toMonth, toDay, toHour, toMinute, toSecond, 0, dtz);
            range.setL2(dt.getMillis());
        }
    }
    return range;
}
Also used : LongPair(com.serotonin.m2m2.vo.pair.LongPair) DateTime(org.joda.time.DateTime)

Example 3 with LongPair

use of com.serotonin.m2m2.vo.pair.LongPair in project ma-modules-public by infiniteautomation.

the class AbstractPointValueRollupCalculator method setupDates.

/**
 * Round off the period for rollups and ensure the date bounds are set
 */
private void setupDates() {
    // Determine the start and end times.
    if (from == null) {
        // Get the start and end from the point values table.
        LongPair lp = getStartEndTimes();
        from = new DateTime(lp.getL1());
        if (to == null)
            to = new DateTime(lp.getL2());
    } else if (to == null) {
        to = new DateTime();
    }
    // Round off the period if we are using periodic rollup
    if (period != null) {
        from = DateUtils.truncateDateTime(from, TimePeriodType.convertFrom(this.period.getType()), this.period.getPeriods());
        to = DateUtils.truncateDateTime(to, TimePeriodType.convertFrom(this.period.getType()), this.period.getPeriods());
    }
}
Also used : LongPair(com.serotonin.m2m2.vo.pair.LongPair) DateTime(org.joda.time.DateTime)

Example 4 with LongPair

use of com.serotonin.m2m2.vo.pair.LongPair 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 5 with LongPair

use of com.serotonin.m2m2.vo.pair.LongPair in project ma-core-public by infiniteautomation.

the class EventsDwr method search.

@DwrPermission(user = true)
public ProcessResult search(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, int page, Date date) {
    ProcessResult response = new ProcessResult();
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    User user = Common.getUser(request);
    int from = PAGE_SIZE * page;
    int to = from + PAGE_SIZE;
    // excluding all of the events for that day. So, // we need to add 1 day to it.
    if (date != null)
        date = DateUtils.minus(new DateTime(date.getTime()), Common.TimePeriods.DAYS, -1).toDate();
    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());
    EventDao eventDao = EventDao.instance;
    List<EventInstance> results = eventDao.search(eventId, eventType, status, alarmLevel, getKeywords(keywordStr), dateRange.getL1(), dateRange.getL2(), user.getId(), getTranslations(), from, to, date);
    Map<String, Object> model = new HashMap<String, Object>();
    int searchRowCount = eventDao.getSearchRowCount();
    int pages = (int) Math.ceil(((double) searchRowCount) / PAGE_SIZE);
    if (date != null) {
        int startRow = eventDao.getStartRow();
        if (startRow == -1)
            page = pages - 1;
        else
            page = eventDao.getStartRow() / PAGE_SIZE;
    }
    if (pages > 1) {
        model.put("displayPagination", true);
        if (page - PAGINATION_RADIUS > 1)
            model.put("leftEllipsis", true);
        else
            model.put("leftEllipsis", false);
        int linkFrom = page + 1 - PAGINATION_RADIUS;
        if (linkFrom < 2)
            linkFrom = 2;
        model.put("linkFrom", linkFrom);
        int linkTo = page + 1 + PAGINATION_RADIUS;
        if (linkTo >= pages)
            linkTo = pages - 1;
        model.put("linkTo", linkTo);
        if (page + PAGINATION_RADIUS < pages - 2)
            model.put("rightEllipsis", true);
        else
            model.put("rightEllipsis", false);
        model.put("numberOfPages", pages);
    } else
        model.put("displayPagination", false);
    model.put(MODEL_ATTR_EVENTS, results);
    model.put("page", page);
    model.put("pendingEvents", false);
    response.addData("content", generateContent(request, "eventList.jsp", model));
    response.addData("resultCount", new TranslatableMessage("events.search.resultCount", searchRowCount));
    return response;
}
Also used : EventInstance(com.serotonin.m2m2.rt.event.EventInstance) User(com.serotonin.m2m2.vo.User) LongPair(com.serotonin.m2m2.vo.pair.LongPair) HashMap(java.util.HashMap) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DateTime(org.joda.time.DateTime) HttpServletRequest(javax.servlet.http.HttpServletRequest) EventDao(com.serotonin.m2m2.db.dao.EventDao) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

LongPair (com.serotonin.m2m2.vo.pair.LongPair)7 DateTime (org.joda.time.DateTime)3 User (com.serotonin.m2m2.vo.User)2 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)2 InvalidArgumentException (com.serotonin.InvalidArgumentException)1 LogStopWatch (com.serotonin.log.LogStopWatch)1 EventDao (com.serotonin.m2m2.db.dao.EventDao)1 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)1 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)1 EventInstance (com.serotonin.m2m2.rt.event.EventInstance)1 PointTimeSeriesCollection (com.serotonin.m2m2.util.chart.PointTimeSeriesCollection)1 EventExportDefinition (com.serotonin.m2m2.web.dwr.beans.EventExportDefinition)1 Synchronizer (com.serotonin.timer.sync.Synchronizer)1 Color (java.awt.Color)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TimeZone (java.util.TimeZone)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1