diff options
author | Anton Tananaev <anton@traccar.org> | 2023-07-01 16:04:07 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-07-01 16:04:07 -0700 |
commit | 914cc6e85ba8696727edff2d8a600ae695bc410d (patch) | |
tree | 1c4841cb097b9b84bc0234e46ca8a20cd6bf8e24 /src/main/java/org/traccar/handler | |
parent | cad2b8497c7cbd2cde4e50ec1ce2af1ceb37d02c (diff) | |
download | trackermap-server-914cc6e85ba8696727edff2d8a600ae695bc410d.tar.gz trackermap-server-914cc6e85ba8696727edff2d8a600ae695bc410d.tar.bz2 trackermap-server-914cc6e85ba8696727edff2d8a600ae695bc410d.zip |
Add calendar based filtering
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r-- | src/main/java/org/traccar/handler/FilterHandler.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/handler/FilterHandler.java b/src/main/java/org/traccar/handler/FilterHandler.java index 2623c3486..028e4cd09 100644 --- a/src/main/java/org/traccar/handler/FilterHandler.java +++ b/src/main/java/org/traccar/handler/FilterHandler.java @@ -25,6 +25,7 @@ import org.traccar.config.Keys; import org.traccar.database.StatisticsManager; import org.traccar.helper.UnitsConverter; import org.traccar.helper.model.AttributeUtil; +import org.traccar.model.Calendar; import org.traccar.model.Device; import org.traccar.model.Position; import org.traccar.session.cache.CacheManager; @@ -259,9 +260,16 @@ public class FilterHandler extends ChannelInboundHandlerAdapter { } } + Device device = cacheManager.getObject(Device.class, deviceId); + if (device.getCalendarId() > 0) { + Calendar calendar = cacheManager.getObject(Calendar.class, device.getCalendarId()); + if (!calendar.checkMoment(position.getFixTime())) { + filterType.append("Calendar "); + } + } + if (filterType.length() > 0) { - String uniqueId = cacheManager.getObject(Device.class, deviceId).getUniqueId(); - LOGGER.info("Position filtered by {}filters from device: {}", filterType, uniqueId); + LOGGER.info("Position filtered by {}filters from device: {}", filterType, device.getUniqueId()); return true; } |