diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-27 23:08:06 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-27 23:08:06 -0800 |
commit | 15f0744893304a3f2a77d36734cdc2a2706286dd (patch) | |
tree | 5dee934a55b6e1f699390a5cda56af60fee84313 /src/org/traccar/handler/events | |
parent | 08754125ed5d152efe29926728033da3658c69fc (diff) | |
download | trackermap-server-15f0744893304a3f2a77d36734cdc2a2706286dd.tar.gz trackermap-server-15f0744893304a3f2a77d36734cdc2a2706286dd.tar.bz2 trackermap-server-15f0744893304a3f2a77d36734cdc2a2706286dd.zip |
Minor refactoring
Diffstat (limited to 'src/org/traccar/handler/events')
-rw-r--r-- | src/org/traccar/handler/events/AlertEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/BaseEventHandler.java (renamed from src/org/traccar/handler/events/TextMessageEventHandler.java) | 27 | ||||
-rw-r--r-- | src/org/traccar/handler/events/CommandResultEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/DriverEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/FuelDropEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/GeofenceEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/IgnitionEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/MaintenanceEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/MotionEventHandler.java | 1 | ||||
-rw-r--r-- | src/org/traccar/handler/events/OverspeedEventHandler.java | 1 |
10 files changed, 14 insertions, 22 deletions
diff --git a/src/org/traccar/handler/events/AlertEventHandler.java b/src/org/traccar/handler/events/AlertEventHandler.java index c6d61538b..09a6e2b6b 100644 --- a/src/org/traccar/handler/events/AlertEventHandler.java +++ b/src/org/traccar/handler/events/AlertEventHandler.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.model.Event; import org.traccar.model.Position; diff --git a/src/org/traccar/handler/events/TextMessageEventHandler.java b/src/org/traccar/handler/events/BaseEventHandler.java index b5e2c72b0..41f677f6c 100644 --- a/src/org/traccar/handler/events/TextMessageEventHandler.java +++ b/src/org/traccar/handler/events/BaseEventHandler.java @@ -1,6 +1,5 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2016 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,22 +15,24 @@ */ package org.traccar.handler.events; +import java.util.Map; + +import org.traccar.BaseDataHandler; import org.traccar.Context; -import org.traccar.model.Device; import org.traccar.model.Event; +import org.traccar.model.Position; -public final class TextMessageEventHandler { - - private TextMessageEventHandler() { - } +public abstract class BaseEventHandler extends BaseDataHandler { - public static void handleTextMessage(String phone, String message) { - Device device = Context.getDeviceManager().getDeviceByPhone(phone); - if (device != null && Context.getNotificationManager() != null) { - Event event = new Event(Event.TYPE_TEXT_MESSAGE, device.getId()); - event.set("message", message); - Context.getNotificationManager().updateEvent(event, null); + @Override + protected Position handlePosition(Position position) { + Map<Event, Position> events = analyzePosition(position); + if (events != null && Context.getNotificationManager() != null) { + Context.getNotificationManager().updateEvents(events); } + return position; } + protected abstract Map<Event, Position> analyzePosition(Position position); + } diff --git a/src/org/traccar/handler/events/CommandResultEventHandler.java b/src/org/traccar/handler/events/CommandResultEventHandler.java index 3acddc1b9..cfe676653 100644 --- a/src/org/traccar/handler/events/CommandResultEventHandler.java +++ b/src/org/traccar/handler/events/CommandResultEventHandler.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.model.Event; import org.traccar.model.Position; diff --git a/src/org/traccar/handler/events/DriverEventHandler.java b/src/org/traccar/handler/events/DriverEventHandler.java index ef73d6d2d..dbb980c89 100644 --- a/src/org/traccar/handler/events/DriverEventHandler.java +++ b/src/org/traccar/handler/events/DriverEventHandler.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.model.Event; import org.traccar.model.Position; diff --git a/src/org/traccar/handler/events/FuelDropEventHandler.java b/src/org/traccar/handler/events/FuelDropEventHandler.java index 7de3930ca..f13b8c7bb 100644 --- a/src/org/traccar/handler/events/FuelDropEventHandler.java +++ b/src/org/traccar/handler/events/FuelDropEventHandler.java @@ -16,7 +16,6 @@ package org.traccar.handler.events; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.model.Device; import org.traccar.model.Event; diff --git a/src/org/traccar/handler/events/GeofenceEventHandler.java b/src/org/traccar/handler/events/GeofenceEventHandler.java index 3bddfe7a4..878331c84 100644 --- a/src/org/traccar/handler/events/GeofenceEventHandler.java +++ b/src/org/traccar/handler/events/GeofenceEventHandler.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.database.GeofenceManager; import org.traccar.model.Calendar; diff --git a/src/org/traccar/handler/events/IgnitionEventHandler.java b/src/org/traccar/handler/events/IgnitionEventHandler.java index 4930ef901..7a83f45b7 100644 --- a/src/org/traccar/handler/events/IgnitionEventHandler.java +++ b/src/org/traccar/handler/events/IgnitionEventHandler.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.model.Device; import org.traccar.model.Event; diff --git a/src/org/traccar/handler/events/MaintenanceEventHandler.java b/src/org/traccar/handler/events/MaintenanceEventHandler.java index e7f641431..80d9c0d91 100644 --- a/src/org/traccar/handler/events/MaintenanceEventHandler.java +++ b/src/org/traccar/handler/events/MaintenanceEventHandler.java @@ -20,7 +20,6 @@ import java.util.HashMap; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.model.Event; import org.traccar.model.Maintenance; diff --git a/src/org/traccar/handler/events/MotionEventHandler.java b/src/org/traccar/handler/events/MotionEventHandler.java index c03b394e5..5e88d34b5 100644 --- a/src/org/traccar/handler/events/MotionEventHandler.java +++ b/src/org/traccar/handler/events/MotionEventHandler.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.model.Device; import org.traccar.model.DeviceState; diff --git a/src/org/traccar/handler/events/OverspeedEventHandler.java b/src/org/traccar/handler/events/OverspeedEventHandler.java index 567758de5..34344fb47 100644 --- a/src/org/traccar/handler/events/OverspeedEventHandler.java +++ b/src/org/traccar/handler/events/OverspeedEventHandler.java @@ -20,7 +20,6 @@ import java.util.Collections; import java.util.Map; import io.netty.channel.ChannelHandler; -import org.traccar.BaseEventHandler; import org.traccar.Context; import org.traccar.model.Device; import org.traccar.model.DeviceState; |