aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/notification/NotificationFormatter.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-11 10:07:42 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-11 10:07:42 +0500
commit834a3d7f337555f579b77e57320583778f0f3d29 (patch)
tree37663280e996d90c71d48402bb96877f98109a04 /src/org/traccar/notification/NotificationFormatter.java
parent16ec66e18af7c421e80591cf6c463c52980665ec (diff)
downloadtrackermap-server-834a3d7f337555f579b77e57320583778f0f3d29.tar.gz
trackermap-server-834a3d7f337555f579b77e57320583778f0f3d29.tar.bz2
trackermap-server-834a3d7f337555f579b77e57320583778f0f3d29.zip
Added message templates for alarm and ignition events
Diffstat (limited to 'src/org/traccar/notification/NotificationFormatter.java')
-rw-r--r--src/org/traccar/notification/NotificationFormatter.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java
index 449426df0..1d5257b4f 100644
--- a/src/org/traccar/notification/NotificationFormatter.java
+++ b/src/org/traccar/notification/NotificationFormatter.java
@@ -70,6 +70,23 @@ public final class NotificationFormatter {
+ "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n"
+ "Time: %2$tc%n";
+ public static final String TITLE_TEMPLATE_TYPE_ALARM = "%1$s: alarm!";
+ public static final String MESSAGE_TEMPLATE_TYPE_ALARM = "Device: %1$s%n"
+ + "Alarm: %5$s%n"
+ + "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n"
+ + "Time: %2$tc%n";
+
+ public static final String TITLE_TEMPLATE_TYPE_IGNITION_ON = "%1$s: ignition ON";
+ public static final String MESSAGE_TEMPLATE_TYPE_IGNITION_ON = "Device: %1$s%n"
+ + "Ignition ON%n"
+ + "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n"
+ + "Time: %2$tc%n";
+ public static final String TITLE_TEMPLATE_TYPE_IGNITION_OFF = "%1$s: ignition OFF";
+ public static final String MESSAGE_TEMPLATE_TYPE_IGNITION_OFF = "Device: %1$s%n"
+ + "Ignition OFF%n"
+ + "Point: http://www.openstreetmap.org/?mlat=%3$f&mlon=%4$f#map=16/%3$f/%4$f%n"
+ + "Time: %2$tc%n";
+
public static String formatTitle(long userId, Event event, Position position) {
Device device = Context.getIdentityManager().getDeviceById(event.getDeviceId());
StringBuilder stringBuilder = new StringBuilder();
@@ -100,6 +117,15 @@ public final class NotificationFormatter {
case Event.TYPE_GEOFENCE_EXIT:
formatter.format(TITLE_TEMPLATE_TYPE_GEOFENCE_EXIT, device.getName());
break;
+ case Event.TYPE_ALARM:
+ formatter.format(TITLE_TEMPLATE_TYPE_ALARM, device.getName());
+ break;
+ case Event.TYPE_IGNITION_ON:
+ formatter.format(TITLE_TEMPLATE_TYPE_IGNITION_ON, device.getName());
+ break;
+ case Event.TYPE_IGNITION_OFF:
+ formatter.format(TITLE_TEMPLATE_TYPE_IGNITION_OFF, device.getName());
+ break;
default:
formatter.format("Unknown type");
break;
@@ -117,7 +143,7 @@ public final class NotificationFormatter {
switch (event.getType()) {
case Event.TYPE_COMMAND_RESULT:
formatter.format(MESSAGE_TEMPLATE_TYPE_COMMAND_RESULT, device.getName(), event.getServerTime(),
- position.getAttributes().get("result"));
+ position.getAttributes().get(Position.KEY_RESULT));
break;
case Event.TYPE_DEVICE_ONLINE:
formatter.format(MESSAGE_TEMPLATE_TYPE_DEVICE_ONLINE, device.getName(), event.getServerTime());
@@ -147,6 +173,19 @@ public final class NotificationFormatter {
position.getLatitude(), position.getLongitude(),
Context.getGeofenceManager().getGeofence(event.getGeofenceId()).getName());
break;
+ case Event.TYPE_ALARM:
+ formatter.format(MESSAGE_TEMPLATE_TYPE_ALARM, device.getName(), event.getServerTime(),
+ position.getLatitude(), position.getLongitude(),
+ position.getAttributes().get(Position.KEY_ALARM));
+ break;
+ case Event.TYPE_IGNITION_ON:
+ formatter.format(MESSAGE_TEMPLATE_TYPE_IGNITION_ON, device.getName(), position.getFixTime(),
+ position.getLatitude(), position.getLongitude());
+ break;
+ case Event.TYPE_IGNITION_OFF:
+ formatter.format(MESSAGE_TEMPLATE_TYPE_IGNITION_OFF, device.getName(), position.getFixTime(),
+ position.getLatitude(), position.getLongitude());
+ break;
default:
formatter.format("Unknown type");
break;