aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/BaseEventHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/BaseEventHandler.java')
-rw-r--r--src/org/traccar/BaseEventHandler.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/org/traccar/BaseEventHandler.java b/src/org/traccar/BaseEventHandler.java
new file mode 100644
index 000000000..fde57748c
--- /dev/null
+++ b/src/org/traccar/BaseEventHandler.java
@@ -0,0 +1,35 @@
+package org.traccar;
+
+import org.traccar.model.Device;
+import org.traccar.model.Event;
+import org.traccar.model.Position;
+
+public abstract class BaseEventHandler extends BaseDataHandler {
+
+ private boolean isLastPosition = false;
+
+ public boolean isLastPosition() {
+ return isLastPosition;
+ }
+
+ @Override
+ protected Position handlePosition(Position position) {
+
+ Device device = Context.getDataManager().getDeviceById(position.getDeviceId());
+ if (device != null) {
+ long lastPositionId = device.getPositionId();
+ if (position.getId() == lastPositionId) {
+ isLastPosition = true;
+ }
+ }
+
+ Event event = analizePosition(position);
+ if (event != null) {
+ Context.getConnectionManager().updateEvent(event);
+ }
+ return position;
+ }
+
+ protected abstract Event analizePosition(Position position);
+
+}