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();
}
}
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;
}
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());
}
}
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);
}
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;
}
Aggregations