* @return Whether the calendar was loaded successfully.
*/
private boolean reloadCalendar() {
+ logger.trace("reloading calendar of {}", getThing().getUID());
if (!calendarFile.isFile()) {
logger.info("Local file for reloading calendar is missing.");
return false;
ICalendarHandler.this.updateStates();
ICalendarHandler.this.rescheduleCalendarStateUpdate();
}, currentEvent.end.getEpochSecond() - now.getEpochSecond(), TimeUnit.SECONDS);
+ logger.debug("Scheduled update in {} seconds", currentEvent.end.getEpochSecond() - now.getEpochSecond());
} else {
final Event nextEvent = currentCalendar.getNextEvent(now);
final ICalendarConfiguration currentConfig = this.configuration;
updateJobFuture = scheduler.schedule(() -> {
ICalendarHandler.this.rescheduleCalendarStateUpdate();
}, 1L, TimeUnit.DAYS);
+ logger.debug("Scheduled reschedule in 1 day");
} else {
updateJobFuture = scheduler.schedule(() -> {
ICalendarHandler.this.updateStates();
ICalendarHandler.this.rescheduleCalendarStateUpdate();
}, nextEvent.start.getEpochSecond() - now.getEpochSecond(), TimeUnit.SECONDS);
+ logger.debug("Scheduled update in {} seconds", nextEvent.start.getEpochSecond() - now.getEpochSecond());
+
}
}
}
* Updates the states of the Thing and its channels.
*/
private void updateStates() {
+ logger.trace("updating states of {}", getThing().getUID());
final AbstractPresentableCalendar calendar = runtimeCalendar;
if (calendar == null) {
updateStatus(ThingStatus.OFFLINE);
@Override
public List<Event> getFilteredEventsBetween(Instant begin, Instant end, @Nullable EventTextFilter filter,
int maximumCount) {
- List<VEventWPeriod> candidates = this.getVEventWPeriodsBetween(begin, end);
+ List<VEventWPeriod> candidates = this.getVEventWPeriodsBetween(begin, end, maximumCount);
final List<Event> results = new ArrayList<>(candidates.size());
if (filter != null) {
*
* @param frameBegin Begin of the frame where to search events.
* @param frameEnd End of the time frame where to search events.
+ * @param maximumPerSeries Limit the results per series. Set to 0 for no limit.
* @return All events which begin in the time frame.
*/
- private List<VEventWPeriod> getVEventWPeriodsBetween(Instant frameBegin, Instant frameEnd) {
+ private List<VEventWPeriod> getVEventWPeriodsBetween(Instant frameBegin, Instant frameEnd, int maximumPerSeries) {
final List<VEvent> positiveEvents = new ArrayList<>();
final List<VEvent> negativeEvents = new ArrayList<>();
classifyEvents(positiveEvents, negativeEvents);
for (final VEvent positiveEvent : positiveEvents) {
final DateIterator positiveBeginDates = getRecurredEventDateIterator(positiveEvent);
positiveBeginDates.advanceTo(Date.from(frameBegin));
+ int foundInSeries = 0;
while (positiveBeginDates.hasNext()) {
final Instant begInst = positiveBeginDates.next().toInstant();
if (begInst.isAfter(frameEnd)) {
if (eventUid != null) {
if (!isCounteredBy(begInst, eventUid, negativeEvents)) {
eventList.add(resultingVEWP);
+ foundInSeries++;
+ if (maximumPerSeries != 0 && foundInSeries >= maximumPerSeries) {
+ break;
+ }
}
} else {
eventList.add(resultingVEWP);
+ foundInSeries++;
+ if (maximumPerSeries != 0 && foundInSeries >= maximumPerSeries) {
+ break;
+ }
}
}
}