diff options
author | Anton Tananaev <anton@traccar.org> | 2023-01-26 15:19:47 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-01-26 15:19:53 -0800 |
commit | 18387265cd9432a906cd16b7d71547be5bf46086 (patch) | |
tree | 609f87c7812eec90255906dc90f50f12ed3b8143 /src/main/java/org/traccar/model | |
parent | 7d1a4120ebe5304217d617e248125e9663bbbf50 (diff) | |
download | trackermap-server-18387265cd9432a906cd16b7d71547be5bf46086.tar.gz trackermap-server-18387265cd9432a906cd16b7d71547be5bf46086.tar.bz2 trackermap-server-18387265cd9432a906cd16b7d71547be5bf46086.zip |
Use period from calendar
Diffstat (limited to 'src/main/java/org/traccar/model')
-rw-r--r-- | src/main/java/org/traccar/model/Calendar.java | 16 | ||||
-rw-r--r-- | src/main/java/org/traccar/model/Report.java | 22 |
2 files changed, 11 insertions, 27 deletions
diff --git a/src/main/java/org/traccar/model/Calendar.java b/src/main/java/org/traccar/model/Calendar.java index c1f98a957..62c51cc4a 100644 --- a/src/main/java/org/traccar/model/Calendar.java +++ b/src/main/java/org/traccar/model/Calendar.java @@ -24,6 +24,7 @@ import net.fortuna.ical4j.filter.predicate.PeriodRule; import net.fortuna.ical4j.model.DateTime; import net.fortuna.ical4j.model.Period; import net.fortuna.ical4j.model.component.CalendarComponent; +import net.fortuna.ical4j.model.component.VEvent; import org.traccar.storage.QueryIgnore; import org.traccar.storage.StorageName; @@ -32,6 +33,7 @@ import java.io.IOException; import java.time.Duration; import java.util.Collection; import java.util.Date; +import java.util.List; @StorageName("tc_calendars") public class Calendar extends ExtendedModel { @@ -66,14 +68,18 @@ public class Calendar extends ExtendedModel { return calendar; } - public boolean checkMoment(Date date) { + public Collection<VEvent> findEvents(Date date) { if (calendar != null) { Period period = new Period(new DateTime(date), Duration.ZERO); - Filter<CalendarComponent> filter = new Filter<>(new PeriodRule<>(period)); - Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT)); - return events != null && !events.isEmpty(); + Filter<VEvent> filter = new Filter<>(new PeriodRule<>(period)); + return filter.filter(calendar.getComponents(CalendarComponent.VEVENT)); + } else { + return List.of(); } - return false; + } + + public boolean checkMoment(Date date) { + return !findEvents(date).isEmpty(); } } diff --git a/src/main/java/org/traccar/model/Report.java b/src/main/java/org/traccar/model/Report.java index 83bb2e920..1556ecc9e 100644 --- a/src/main/java/org/traccar/model/Report.java +++ b/src/main/java/org/traccar/model/Report.java @@ -17,8 +17,6 @@ package org.traccar.model; import org.traccar.storage.StorageName; -import java.util.Date; - @StorageName("tc_reports") public class Report extends ScheduledModel { @@ -42,24 +40,4 @@ public class Report extends ScheduledModel { this.description = description; } - private Date from; - - public Date getFrom() { - return from; - } - - public void setFrom(Date from) { - this.from = from; - } - - private Date to; - - public Date getTo() { - return to; - } - - public void setTo(Date to) { - this.to = to; - } - } |