From bb289a69fa4d292378c5c534e10985be65b2e392 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Sun, 25 Mar 2018 22:16:09 -0300 Subject: generalization for notifications processing --- src/org/traccar/model/Notification.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/org/traccar/model/Notification.java') diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java index cc80f2ae2..0d0b34cd4 100644 --- a/src/org/traccar/model/Notification.java +++ b/src/org/traccar/model/Notification.java @@ -15,6 +15,9 @@ */ package org.traccar.model; +import java.util.HashSet; +import java.util.Set; + public class Notification extends ScheduledModel { private boolean always; @@ -66,4 +69,19 @@ public class Notification extends ScheduledModel { public void setSms(boolean sms) { this.sms = sms; } + + public Set getMethods() { + final Set set = new HashSet<>(); + if (web) { + set.add("web"); + } + if (mail) { + set.add("mail"); + } + if (sms) { + set.add("sms"); + } + return set; + } + } -- cgit v1.2.3 From 25eb3d86b97f8a0eb806f3e0c572d80c495257d6 Mon Sep 17 00:00:00 2001 From: Ivan Martinez Date: Fri, 1 Jun 2018 07:29:09 -0300 Subject: replace database definition with comma separated list --- schema/changelog-3.18.xml | 57 +++++++++++++++++++++++ src/org/traccar/database/NotificationManager.java | 2 +- src/org/traccar/model/Notification.java | 41 ++++------------ 3 files changed, 67 insertions(+), 33 deletions(-) create mode 100644 schema/changelog-3.18.xml (limited to 'src/org/traccar/model/Notification.java') diff --git a/schema/changelog-3.18.xml b/schema/changelog-3.18.xml new file mode 100644 index 000000000..85c3b0c33 --- /dev/null +++ b/schema/changelog-3.18.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + web = 1 AND mail = 1 AND sms = 1 + + + + + web = 1 AND mail = 1 AND sms = 0 + + + + + web = 1 AND mail = 0 AND sms = 0 + + + + + web = 1 AND mail = 0 AND sms = 1 + + + + + web = 0 AND mail = 1 AND sms = 1 + + + + + web = 0 AND mail = 1 AND sms = 0 + + + + + web = 0 AND mail = 0 AND sms = 1 + + + + + + diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 37c6b720c..10c76181a 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -86,7 +86,7 @@ public class NotificationManager extends ExtendedObjectManager { for (long notificationId : getEffectiveNotifications(userId, deviceId, event.getServerTime())) { Notification notification = getById(notificationId); if (getById(notificationId).getType().equals(event.getType())) { - notificationMethods.addAll(notification.getMethods()); + notificationMethods.addAll(notification.getTransportMethods()); } } for (String nm : notificationMethods) { diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java index 0d0b34cd4..0b632c861 100644 --- a/src/org/traccar/model/Notification.java +++ b/src/org/traccar/model/Notification.java @@ -40,46 +40,23 @@ public class Notification extends ScheduledModel { this.type = type; } - private boolean web; - public boolean getWeb() { - return web; - } - - public void setWeb(boolean web) { - this.web = web; - } - - private boolean mail; - - public boolean getMail() { - return mail; - } + private String transports; - public void setMail(boolean mail) { - this.mail = mail; + public String getTransports() { + return transports; } - private boolean sms; - - public boolean getSms() { - return sms; + public void setTransports(String transports) { + this.transports = transports; } - public void setSms(boolean sms) { - this.sms = sms; - } - public Set getMethods() { + public Set getTransportMethods() { final Set set = new HashSet<>(); - if (web) { - set.add("web"); - } - if (mail) { - set.add("mail"); - } - if (sms) { - set.add("sms"); + final String[] tmp = transports.split(","); + for (String t : tmp) { + set.add(t.trim()); } return set; } -- cgit v1.2.3 From 825ee0d178a24620f075cb4ffb8d49c75b046484 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 26 Jun 2018 12:05:16 +0500 Subject: Cleanup and some adjustments --- schema/changelog-3.18.xml | 57 ---------------------- schema/changelog-4.0.xml | 47 ++++++++++++++++++ setup/default.xml | 2 +- .../traccar/api/resource/NotificationResource.java | 9 ++-- src/org/traccar/database/NotificationManager.java | 5 +- src/org/traccar/model/Notification.java | 18 +++++-- .../notification/NotificationException.java | 4 +- src/org/traccar/notification/NotificationMail.java | 4 +- src/org/traccar/notification/NotificationNull.java | 4 +- src/org/traccar/notification/NotificationSms.java | 4 +- src/org/traccar/notification/NotificationWeb.java | 4 +- src/org/traccar/notification/Notificator.java | 4 +- .../traccar/notification/NotificatorManager.java | 26 ++++++---- src/org/traccar/sms/SMSException.java | 4 +- src/org/traccar/sms/SMSManager.java | 16 ++++++ templates/full/alarm.vm | 10 ++++ templates/full/commandResult.vm | 10 ++++ templates/full/deviceFuelDrop.vm | 9 ++++ templates/full/deviceMoving.vm | 10 ++++ templates/full/deviceOffline.vm | 10 ++++ templates/full/deviceOnline.vm | 10 ++++ templates/full/deviceOverspeed.vm | 19 ++++++++ templates/full/deviceStopped.vm | 10 ++++ templates/full/deviceUnknown.vm | 10 ++++ templates/full/driverChanged.vm | 10 ++++ templates/full/geofenceEnter.vm | 10 ++++ templates/full/geofenceExit.vm | 10 ++++ templates/full/ignitionOff.vm | 10 ++++ templates/full/ignitionOn.vm | 10 ++++ templates/full/maintenance.vm | 10 ++++ templates/full/test.vm | 7 +++ templates/full/textMessage.vm | 9 ++++ templates/full/unknown.vm | 7 +++ templates/mail/alarm.vm | 10 ---- templates/mail/commandResult.vm | 10 ---- templates/mail/deviceFuelDrop.vm | 9 ---- templates/mail/deviceMoving.vm | 10 ---- templates/mail/deviceOffline.vm | 10 ---- templates/mail/deviceOnline.vm | 10 ---- templates/mail/deviceOverspeed.vm | 19 -------- templates/mail/deviceStopped.vm | 10 ---- templates/mail/deviceUnknown.vm | 10 ---- templates/mail/driverChanged.vm | 10 ---- templates/mail/geofenceEnter.vm | 10 ---- templates/mail/geofenceExit.vm | 10 ---- templates/mail/ignitionOff.vm | 10 ---- templates/mail/ignitionOn.vm | 10 ---- templates/mail/maintenance.vm | 10 ---- templates/mail/test.vm | 7 --- templates/mail/textMessage.vm | 9 ---- templates/mail/unknown.vm | 7 --- templates/short/alarm.vm | 1 + templates/short/commandResult.vm | 1 + templates/short/deviceFuelDrop.vm | 1 + templates/short/deviceMoving.vm | 1 + templates/short/deviceOffline.vm | 1 + templates/short/deviceOnline.vm | 1 + templates/short/deviceOverspeed.vm | 10 ++++ templates/short/deviceStopped.vm | 1 + templates/short/deviceUnknown.vm | 1 + templates/short/driverChanged.vm | 6 +++ templates/short/geofenceEnter.vm | 1 + templates/short/geofenceExit.vm | 1 + templates/short/ignitionOff.vm | 1 + templates/short/ignitionOn.vm | 1 + templates/short/maintenance.vm | 1 + templates/short/test.vm | 1 + templates/short/textMessage.vm | 1 + templates/short/unknown.vm | 1 + templates/sms/alarm.vm | 1 - templates/sms/commandResult.vm | 1 - templates/sms/deviceFuelDrop.vm | 1 - templates/sms/deviceMoving.vm | 1 - templates/sms/deviceOffline.vm | 1 - templates/sms/deviceOnline.vm | 1 - templates/sms/deviceOverspeed.vm | 10 ---- templates/sms/deviceStopped.vm | 1 - templates/sms/deviceUnknown.vm | 1 - templates/sms/driverChanged.vm | 6 --- templates/sms/geofenceEnter.vm | 1 - templates/sms/geofenceExit.vm | 1 - templates/sms/ignitionOff.vm | 1 - templates/sms/ignitionOn.vm | 1 - templates/sms/maintenance.vm | 1 - templates/sms/test.vm | 1 - templates/sms/textMessage.vm | 1 - templates/sms/unknown.vm | 1 - 87 files changed, 328 insertions(+), 306 deletions(-) delete mode 100644 schema/changelog-3.18.xml create mode 100644 templates/full/alarm.vm create mode 100644 templates/full/commandResult.vm create mode 100644 templates/full/deviceFuelDrop.vm create mode 100644 templates/full/deviceMoving.vm create mode 100644 templates/full/deviceOffline.vm create mode 100644 templates/full/deviceOnline.vm create mode 100644 templates/full/deviceOverspeed.vm create mode 100644 templates/full/deviceStopped.vm create mode 100644 templates/full/deviceUnknown.vm create mode 100644 templates/full/driverChanged.vm create mode 100644 templates/full/geofenceEnter.vm create mode 100644 templates/full/geofenceExit.vm create mode 100644 templates/full/ignitionOff.vm create mode 100644 templates/full/ignitionOn.vm create mode 100644 templates/full/maintenance.vm create mode 100644 templates/full/test.vm create mode 100644 templates/full/textMessage.vm create mode 100644 templates/full/unknown.vm delete mode 100644 templates/mail/alarm.vm delete mode 100644 templates/mail/commandResult.vm delete mode 100644 templates/mail/deviceFuelDrop.vm delete mode 100644 templates/mail/deviceMoving.vm delete mode 100644 templates/mail/deviceOffline.vm delete mode 100644 templates/mail/deviceOnline.vm delete mode 100644 templates/mail/deviceOverspeed.vm delete mode 100644 templates/mail/deviceStopped.vm delete mode 100644 templates/mail/deviceUnknown.vm delete mode 100644 templates/mail/driverChanged.vm delete mode 100644 templates/mail/geofenceEnter.vm delete mode 100644 templates/mail/geofenceExit.vm delete mode 100644 templates/mail/ignitionOff.vm delete mode 100644 templates/mail/ignitionOn.vm delete mode 100644 templates/mail/maintenance.vm delete mode 100644 templates/mail/test.vm delete mode 100644 templates/mail/textMessage.vm delete mode 100644 templates/mail/unknown.vm create mode 100644 templates/short/alarm.vm create mode 100644 templates/short/commandResult.vm create mode 100644 templates/short/deviceFuelDrop.vm create mode 100644 templates/short/deviceMoving.vm create mode 100644 templates/short/deviceOffline.vm create mode 100644 templates/short/deviceOnline.vm create mode 100644 templates/short/deviceOverspeed.vm create mode 100644 templates/short/deviceStopped.vm create mode 100644 templates/short/deviceUnknown.vm create mode 100644 templates/short/driverChanged.vm create mode 100644 templates/short/geofenceEnter.vm create mode 100644 templates/short/geofenceExit.vm create mode 100644 templates/short/ignitionOff.vm create mode 100644 templates/short/ignitionOn.vm create mode 100644 templates/short/maintenance.vm create mode 100644 templates/short/test.vm create mode 100644 templates/short/textMessage.vm create mode 100644 templates/short/unknown.vm delete mode 100644 templates/sms/alarm.vm delete mode 100644 templates/sms/commandResult.vm delete mode 100644 templates/sms/deviceFuelDrop.vm delete mode 100644 templates/sms/deviceMoving.vm delete mode 100644 templates/sms/deviceOffline.vm delete mode 100644 templates/sms/deviceOnline.vm delete mode 100644 templates/sms/deviceOverspeed.vm delete mode 100644 templates/sms/deviceStopped.vm delete mode 100644 templates/sms/deviceUnknown.vm delete mode 100644 templates/sms/driverChanged.vm delete mode 100644 templates/sms/geofenceEnter.vm delete mode 100644 templates/sms/geofenceExit.vm delete mode 100644 templates/sms/ignitionOff.vm delete mode 100644 templates/sms/ignitionOn.vm delete mode 100644 templates/sms/maintenance.vm delete mode 100644 templates/sms/test.vm delete mode 100644 templates/sms/textMessage.vm delete mode 100644 templates/sms/unknown.vm (limited to 'src/org/traccar/model/Notification.java') diff --git a/schema/changelog-3.18.xml b/schema/changelog-3.18.xml deleted file mode 100644 index 85c3b0c33..000000000 --- a/schema/changelog-3.18.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - web = 1 AND mail = 1 AND sms = 1 - - - - - web = 1 AND mail = 1 AND sms = 0 - - - - - web = 1 AND mail = 0 AND sms = 0 - - - - - web = 1 AND mail = 0 AND sms = 1 - - - - - web = 0 AND mail = 1 AND sms = 1 - - - - - web = 0 AND mail = 1 AND sms = 0 - - - - - web = 0 AND mail = 0 AND sms = 1 - - - - - - diff --git a/schema/changelog-4.0.xml b/schema/changelog-4.0.xml index 04e9fe0c4..82403c83c 100644 --- a/schema/changelog-4.0.xml +++ b/schema/changelog-4.0.xml @@ -53,4 +53,51 @@ + + + + + + + + + web = 1 AND mail = 1 AND sms = 1 + + + + + web = 1 AND mail = 1 AND sms = 0 + + + + + web = 1 AND mail = 0 AND sms = 0 + + + + + web = 1 AND mail = 0 AND sms = 1 + + + + + web = 0 AND mail = 1 AND sms = 1 + + + + + web = 0 AND mail = 1 AND sms = 0 + + + + + web = 0 AND mail = 0 AND sms = 1 + + + + + + + + diff --git a/setup/default.xml b/setup/default.xml index 353ba36a7..d7c1e5f0f 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -30,8 +30,8 @@ web,mail org.traccar.notification.NotificationWeb - org.traccar.notification.NotificationSms org.traccar.notification.NotificationMail + org.traccar.notification.NotificationSms https://www.traccar.org/analytics/ diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java index 2347b43fa..9046569a0 100644 --- a/src/org/traccar/api/resource/NotificationResource.java +++ b/src/org/traccar/api/resource/NotificationResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2018 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. @@ -52,8 +52,9 @@ public class NotificationResource extends ExtendedObjectResource { @POST @Path("test") public Response testMessage() throws NotificationException, InterruptedException { - for (String method : Context.getNotificatorManager().getNotificatorTypes()) { - Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null); + for (Typed method : Context.getNotificatorManager().getNotificatorTypes()) { + Context.getNotificatorManager() + .getNotificator(method.getType()).sendSync(getUserId(), new Event("test", 0), null); } return Response.noContent().build(); } @@ -68,7 +69,7 @@ public class NotificationResource extends ExtendedObjectResource { @GET @Path("notificators") - public Collection getNotificators() { + public Collection getNotificators() { return Context.getNotificatorManager().getNotificatorTypes(); } diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index 2c1ffc09c..b2a30e4f1 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -90,8 +90,9 @@ public class NotificationManager extends ExtendedObjectManager { notificationMethods.addAll(notification.getTransportMethods()); } } - for (String nm : notificationMethods) { - Context.getNotificatorManager().getNotificator(nm).sendAsync(userId, event, position); + for (String notificationMethod : notificationMethods) { + Context.getNotificatorManager() + .getNotificator(notificationMethod).sendAsync(userId, event, position); } } } diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java index 0b632c861..4923798c2 100644 --- a/src/org/traccar/model/Notification.java +++ b/src/org/traccar/model/Notification.java @@ -18,6 +18,10 @@ package org.traccar.model; import java.util.HashSet; import java.util.Set; +import org.traccar.database.QueryIgnore; + +import com.fasterxml.jackson.annotation.JsonIgnore; + public class Notification extends ScheduledModel { private boolean always; @@ -52,13 +56,17 @@ public class Notification extends ScheduledModel { } + @JsonIgnore + @QueryIgnore public Set getTransportMethods() { - final Set set = new HashSet<>(); - final String[] tmp = transports.split(","); - for (String t : tmp) { - set.add(t.trim()); + final Set result = new HashSet<>(); + if (transports != null) { + final String[] transportsList = transports.split(","); + for (String transport : transportsList) { + result.add(transport.trim()); + } } - return set; + return result; } } diff --git a/src/org/traccar/notification/NotificationException.java b/src/org/traccar/notification/NotificationException.java index 34d5a80f7..525e5ee37 100644 --- a/src/org/traccar/notification/NotificationException.java +++ b/src/org/traccar/notification/NotificationException.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index fb89bf5bd..76387c73b 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -1,6 +1,6 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/notification/NotificationNull.java b/src/org/traccar/notification/NotificationNull.java index fd7950a80..3ee954c24 100644 --- a/src/org/traccar/notification/NotificationNull.java +++ b/src/org/traccar/notification/NotificationNull.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/notification/NotificationSms.java b/src/org/traccar/notification/NotificationSms.java index 63fd57895..dd3304d85 100644 --- a/src/org/traccar/notification/NotificationSms.java +++ b/src/org/traccar/notification/NotificationSms.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/notification/NotificationWeb.java b/src/org/traccar/notification/NotificationWeb.java index c6a1ae281..8e04fc2c4 100644 --- a/src/org/traccar/notification/NotificationWeb.java +++ b/src/org/traccar/notification/NotificationWeb.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/notification/Notificator.java b/src/org/traccar/notification/Notificator.java index 7192d25c0..09f98d3ad 100644 --- a/src/org/traccar/notification/Notificator.java +++ b/src/org/traccar/notification/Notificator.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java index 20c7749d2..87a294345 100644 --- a/src/org/traccar/notification/NotificatorManager.java +++ b/src/org/traccar/notification/NotificatorManager.java @@ -1,6 +1,6 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ package org.traccar.notification; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; import org.traccar.Context; import org.traccar.helper.Log; +import org.traccar.model.Typed; public final class NotificatorManager { @@ -33,13 +35,13 @@ public final class NotificatorManager { final String className = Context.getConfig().getString("notificator." + type + ".class", ""); if (className.length() > 0) { try { - final Class c = (Class) Class.forName(className); + final Class clazz = (Class) Class.forName(className); try { - final Constructor constructor = c.getConstructor(new Class[]{String.class}); + final Constructor constructor = clazz.getConstructor(new Class[]{String.class}); notificators.put(type, constructor.newInstance(type)); } catch (NoSuchMethodException e) { // No constructor with String argument - notificators.put(type, c.newInstance()); + notificators.put(type, clazz.newInstance()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException e) { @@ -53,17 +55,21 @@ public final class NotificatorManager { private static final Notificator NULL_NOTIFICATOR = new NotificationNull(); public Notificator getNotificator(String type) { - final Notificator n = notificators.get(type); - if (n == null) { + final Notificator notificator = notificators.get(type); + if (notificator == null) { Log.error("No notificator configured for type : " + type); return NULL_NOTIFICATOR; } - return n; + return notificator; } - public Set getNotificatorTypes() { - return notificators.keySet(); + public Set getNotificatorTypes() { + Set result = new HashSet<>(); + for (String notificator : notificators.keySet()) { + result.add(new Typed(notificator)); + } + return result; } diff --git a/src/org/traccar/sms/SMSException.java b/src/org/traccar/sms/SMSException.java index c9c0b3128..22ca95296 100644 --- a/src/org/traccar/sms/SMSException.java +++ b/src/org/traccar/sms/SMSException.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/sms/SMSManager.java b/src/org/traccar/sms/SMSManager.java index b40dae867..c4cb68fb7 100644 --- a/src/org/traccar/sms/SMSManager.java +++ b/src/org/traccar/sms/SMSManager.java @@ -1,3 +1,19 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.traccar.sms; public interface SMSManager { diff --git a/templates/full/alarm.vm b/templates/full/alarm.vm new file mode 100644 index 000000000..8f1164291 --- /dev/null +++ b/templates/full/alarm.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: alarm!") + + + +Device: $device.name
+Alarm: $position.getString("alarm")
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/commandResult.vm b/templates/full/commandResult.vm new file mode 100644 index 000000000..5b6d8ef3e --- /dev/null +++ b/templates/full/commandResult.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: command result received") + + + +Device: $device.name
+Result: $position.getString("result")
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Link: $webUrl?eventId=$event.id + + diff --git a/templates/full/deviceFuelDrop.vm b/templates/full/deviceFuelDrop.vm new file mode 100644 index 000000000..c30ec3a1c --- /dev/null +++ b/templates/full/deviceFuelDrop.vm @@ -0,0 +1,9 @@ +#set($subject = "$device.name: fuel drop") + + + +Device: $device.name
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/deviceMoving.vm b/templates/full/deviceMoving.vm new file mode 100644 index 000000000..6e98af1de --- /dev/null +++ b/templates/full/deviceMoving.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: moving") + + + +Device: $device.name
+Moving
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/deviceOffline.vm b/templates/full/deviceOffline.vm new file mode 100644 index 000000000..1f6d02fb2 --- /dev/null +++ b/templates/full/deviceOffline.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: offline") + + + +Device: $device.name
+Offline
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Link: $webUrl?eventId=$event.id + + diff --git a/templates/full/deviceOnline.vm b/templates/full/deviceOnline.vm new file mode 100644 index 000000000..9211eff11 --- /dev/null +++ b/templates/full/deviceOnline.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: online") + + + +Device: $device.name
+Online
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Link: $webUrl?eventId=$event.id + + diff --git a/templates/full/deviceOverspeed.vm b/templates/full/deviceOverspeed.vm new file mode 100644 index 000000000..e5e576f3a --- /dev/null +++ b/templates/full/deviceOverspeed.vm @@ -0,0 +1,19 @@ +#set($subject = "$device.name: exceeds the speed") +#if($speedUnit == 'kmh') +#set($speedValue = $position.speed * 1.852) +#set($speedString = $numberTool.format("0.0 km/h", $speedValue)) +#elseif($speedUnit == 'mph') +#set($speedValue = $position.speed * 1.15078) +#set($speedString = $numberTool.format("0.0 mph", $speedValue)) +#else +#set($speedString = $numberTool.format("0.0 kn", $position.speed)) +#end + + + +Device: $device.name
+Exceeds the speed: $speedString#{if}($geofence) in $geofence.name#{else}#{end}
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/deviceStopped.vm b/templates/full/deviceStopped.vm new file mode 100644 index 000000000..2ec0f8db9 --- /dev/null +++ b/templates/full/deviceStopped.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: stopped") + + + +Device: $device.name
+Stopped
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/deviceUnknown.vm b/templates/full/deviceUnknown.vm new file mode 100644 index 000000000..34fa01a8a --- /dev/null +++ b/templates/full/deviceUnknown.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: status is unknown") + + + +Device: $device.name
+Status is unknown
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Link: $webUrl?eventId=$event.id + + diff --git a/templates/full/driverChanged.vm b/templates/full/driverChanged.vm new file mode 100644 index 000000000..ba1e68661 --- /dev/null +++ b/templates/full/driverChanged.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: driver has changed") + + + +Device: $device.name
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+Driver: #{if}($driver)$driver.name#{else}$event.getString("driverUniqueId")#{end} + + diff --git a/templates/full/geofenceEnter.vm b/templates/full/geofenceEnter.vm new file mode 100644 index 000000000..e83a0de62 --- /dev/null +++ b/templates/full/geofenceEnter.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: has entered geofence") + + + +Device: $device.name
+Has entered geofence: $geofence.name
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/geofenceExit.vm b/templates/full/geofenceExit.vm new file mode 100644 index 000000000..3557f6eb2 --- /dev/null +++ b/templates/full/geofenceExit.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: has exited geofence") + + + +Device: $device.name
+Has exited geofence: $geofence.name
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/ignitionOff.vm b/templates/full/ignitionOff.vm new file mode 100644 index 000000000..0281eef02 --- /dev/null +++ b/templates/full/ignitionOff.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: ignition OFF") + + + +Device: $device.name
+Ignition OFF
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/ignitionOn.vm b/templates/full/ignitionOn.vm new file mode 100644 index 000000000..27135a7f0 --- /dev/null +++ b/templates/full/ignitionOn.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: ignition ON") + + + +Device: $device.name
+Ignition ON
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/maintenance.vm b/templates/full/maintenance.vm new file mode 100644 index 000000000..c6973f97a --- /dev/null +++ b/templates/full/maintenance.vm @@ -0,0 +1,10 @@ +#set($subject = "$device.name: maintenance is required") + + + +Device: $device.name
+Maintenance is required: $maintenance.name
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
+ + diff --git a/templates/full/test.vm b/templates/full/test.vm new file mode 100644 index 000000000..93cbdc549 --- /dev/null +++ b/templates/full/test.vm @@ -0,0 +1,7 @@ +#set($subject = "Test message") + + + +Test message + + diff --git a/templates/full/textMessage.vm b/templates/full/textMessage.vm new file mode 100644 index 000000000..174173c85 --- /dev/null +++ b/templates/full/textMessage.vm @@ -0,0 +1,9 @@ +#set($subject = "$device.name: text message received") + + + +Device: $device.name
+Message: $event.getString("message")
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+ + diff --git a/templates/full/unknown.vm b/templates/full/unknown.vm new file mode 100644 index 000000000..566ce0d42 --- /dev/null +++ b/templates/full/unknown.vm @@ -0,0 +1,7 @@ +#set($subject = "Unknown type") + + + +Unknown type + + diff --git a/templates/mail/alarm.vm b/templates/mail/alarm.vm deleted file mode 100644 index 8f1164291..000000000 --- a/templates/mail/alarm.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: alarm!") - - - -Device: $device.name
-Alarm: $position.getString("alarm")
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/commandResult.vm b/templates/mail/commandResult.vm deleted file mode 100644 index 5b6d8ef3e..000000000 --- a/templates/mail/commandResult.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: command result received") - - - -Device: $device.name
-Result: $position.getString("result")
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Link: $webUrl?eventId=$event.id - - diff --git a/templates/mail/deviceFuelDrop.vm b/templates/mail/deviceFuelDrop.vm deleted file mode 100644 index c30ec3a1c..000000000 --- a/templates/mail/deviceFuelDrop.vm +++ /dev/null @@ -1,9 +0,0 @@ -#set($subject = "$device.name: fuel drop") - - - -Device: $device.name
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/deviceMoving.vm b/templates/mail/deviceMoving.vm deleted file mode 100644 index 6e98af1de..000000000 --- a/templates/mail/deviceMoving.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: moving") - - - -Device: $device.name
-Moving
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/deviceOffline.vm b/templates/mail/deviceOffline.vm deleted file mode 100644 index 1f6d02fb2..000000000 --- a/templates/mail/deviceOffline.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: offline") - - - -Device: $device.name
-Offline
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Link: $webUrl?eventId=$event.id - - diff --git a/templates/mail/deviceOnline.vm b/templates/mail/deviceOnline.vm deleted file mode 100644 index 9211eff11..000000000 --- a/templates/mail/deviceOnline.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: online") - - - -Device: $device.name
-Online
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Link: $webUrl?eventId=$event.id - - diff --git a/templates/mail/deviceOverspeed.vm b/templates/mail/deviceOverspeed.vm deleted file mode 100644 index e5e576f3a..000000000 --- a/templates/mail/deviceOverspeed.vm +++ /dev/null @@ -1,19 +0,0 @@ -#set($subject = "$device.name: exceeds the speed") -#if($speedUnit == 'kmh') -#set($speedValue = $position.speed * 1.852) -#set($speedString = $numberTool.format("0.0 km/h", $speedValue)) -#elseif($speedUnit == 'mph') -#set($speedValue = $position.speed * 1.15078) -#set($speedString = $numberTool.format("0.0 mph", $speedValue)) -#else -#set($speedString = $numberTool.format("0.0 kn", $position.speed)) -#end - - - -Device: $device.name
-Exceeds the speed: $speedString#{if}($geofence) in $geofence.name#{else}#{end}
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/deviceStopped.vm b/templates/mail/deviceStopped.vm deleted file mode 100644 index 2ec0f8db9..000000000 --- a/templates/mail/deviceStopped.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: stopped") - - - -Device: $device.name
-Stopped
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/deviceUnknown.vm b/templates/mail/deviceUnknown.vm deleted file mode 100644 index 34fa01a8a..000000000 --- a/templates/mail/deviceUnknown.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: status is unknown") - - - -Device: $device.name
-Status is unknown
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Link: $webUrl?eventId=$event.id - - diff --git a/templates/mail/driverChanged.vm b/templates/mail/driverChanged.vm deleted file mode 100644 index ba1e68661..000000000 --- a/templates/mail/driverChanged.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: driver has changed") - - - -Device: $device.name
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
-Driver: #{if}($driver)$driver.name#{else}$event.getString("driverUniqueId")#{end} - - diff --git a/templates/mail/geofenceEnter.vm b/templates/mail/geofenceEnter.vm deleted file mode 100644 index e83a0de62..000000000 --- a/templates/mail/geofenceEnter.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: has entered geofence") - - - -Device: $device.name
-Has entered geofence: $geofence.name
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/geofenceExit.vm b/templates/mail/geofenceExit.vm deleted file mode 100644 index 3557f6eb2..000000000 --- a/templates/mail/geofenceExit.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: has exited geofence") - - - -Device: $device.name
-Has exited geofence: $geofence.name
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/ignitionOff.vm b/templates/mail/ignitionOff.vm deleted file mode 100644 index 0281eef02..000000000 --- a/templates/mail/ignitionOff.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: ignition OFF") - - - -Device: $device.name
-Ignition OFF
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/ignitionOn.vm b/templates/mail/ignitionOn.vm deleted file mode 100644 index 27135a7f0..000000000 --- a/templates/mail/ignitionOn.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: ignition ON") - - - -Device: $device.name
-Ignition ON
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/maintenance.vm b/templates/mail/maintenance.vm deleted file mode 100644 index c6973f97a..000000000 --- a/templates/mail/maintenance.vm +++ /dev/null @@ -1,10 +0,0 @@ -#set($subject = "$device.name: maintenance is required") - - - -Device: $device.name
-Maintenance is required: $maintenance.name
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
-Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
- - diff --git a/templates/mail/test.vm b/templates/mail/test.vm deleted file mode 100644 index 93cbdc549..000000000 --- a/templates/mail/test.vm +++ /dev/null @@ -1,7 +0,0 @@ -#set($subject = "Test message") - - - -Test message - - diff --git a/templates/mail/textMessage.vm b/templates/mail/textMessage.vm deleted file mode 100644 index 174173c85..000000000 --- a/templates/mail/textMessage.vm +++ /dev/null @@ -1,9 +0,0 @@ -#set($subject = "$device.name: text message received") - - - -Device: $device.name
-Message: $event.getString("message")
-Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
- - diff --git a/templates/mail/unknown.vm b/templates/mail/unknown.vm deleted file mode 100644 index 566ce0d42..000000000 --- a/templates/mail/unknown.vm +++ /dev/null @@ -1,7 +0,0 @@ -#set($subject = "Unknown type") - - - -Unknown type - - diff --git a/templates/short/alarm.vm b/templates/short/alarm.vm new file mode 100644 index 000000000..389341cf1 --- /dev/null +++ b/templates/short/alarm.vm @@ -0,0 +1 @@ +$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/commandResult.vm b/templates/short/commandResult.vm new file mode 100644 index 000000000..4a327d850 --- /dev/null +++ b/templates/short/commandResult.vm @@ -0,0 +1 @@ +$device.name command result received: $position.getString("result") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/deviceFuelDrop.vm b/templates/short/deviceFuelDrop.vm new file mode 100644 index 000000000..5e51396d4 --- /dev/null +++ b/templates/short/deviceFuelDrop.vm @@ -0,0 +1 @@ +$device.name fuel drop at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/deviceMoving.vm b/templates/short/deviceMoving.vm new file mode 100644 index 000000000..aaa72ab0d --- /dev/null +++ b/templates/short/deviceMoving.vm @@ -0,0 +1 @@ +$device.name moving at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/deviceOffline.vm b/templates/short/deviceOffline.vm new file mode 100644 index 000000000..8c4a02335 --- /dev/null +++ b/templates/short/deviceOffline.vm @@ -0,0 +1 @@ +$device.name offline at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/deviceOnline.vm b/templates/short/deviceOnline.vm new file mode 100644 index 000000000..62854feb0 --- /dev/null +++ b/templates/short/deviceOnline.vm @@ -0,0 +1 @@ +$device.name online at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/deviceOverspeed.vm b/templates/short/deviceOverspeed.vm new file mode 100644 index 000000000..5e92f662c --- /dev/null +++ b/templates/short/deviceOverspeed.vm @@ -0,0 +1,10 @@ +#if($speedUnit == 'kmh') +#set($speedValue = $position.speed * 1.852) +#set($speedString = $numberTool.format("0.0 km/h", $speedValue)) +#elseif($speedUnit == 'mph') +#set($speedValue = $position.speed * 1.15078) +#set($speedString = $numberTool.format("0.0 mph", $speedValue)) +#else +#set($speedString = $numberTool.format("0.0 kn", $position.speed)) +#end +$device.name exceeds the speed $speedString#{if}($geofence) in $geofence.name#{else}#{end} at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/deviceStopped.vm b/templates/short/deviceStopped.vm new file mode 100644 index 000000000..c2437b5f6 --- /dev/null +++ b/templates/short/deviceStopped.vm @@ -0,0 +1 @@ +$device.name stopped at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/deviceUnknown.vm b/templates/short/deviceUnknown.vm new file mode 100644 index 000000000..07f39f3a9 --- /dev/null +++ b/templates/short/deviceUnknown.vm @@ -0,0 +1 @@ +$device.name status is unknown at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/driverChanged.vm b/templates/short/driverChanged.vm new file mode 100644 index 000000000..50849df7c --- /dev/null +++ b/templates/short/driverChanged.vm @@ -0,0 +1,6 @@ +#if($driver) +#set($driverName = $driver.name) +#else +#set($driverName = $event.getString("driverUniqueId")) +#end +Driver $driverName has changed in $device.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/geofenceEnter.vm b/templates/short/geofenceEnter.vm new file mode 100644 index 000000000..debdbf356 --- /dev/null +++ b/templates/short/geofenceEnter.vm @@ -0,0 +1 @@ +$device.name has entered geofence $geofence.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/geofenceExit.vm b/templates/short/geofenceExit.vm new file mode 100644 index 000000000..8553458f7 --- /dev/null +++ b/templates/short/geofenceExit.vm @@ -0,0 +1 @@ +$device.name has exited geofence $geofence.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/ignitionOff.vm b/templates/short/ignitionOff.vm new file mode 100644 index 000000000..ddf860413 --- /dev/null +++ b/templates/short/ignitionOff.vm @@ -0,0 +1 @@ +$device.name ignition OFF at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/ignitionOn.vm b/templates/short/ignitionOn.vm new file mode 100644 index 000000000..00b365be9 --- /dev/null +++ b/templates/short/ignitionOn.vm @@ -0,0 +1 @@ +$device.name ignition ON at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/maintenance.vm b/templates/short/maintenance.vm new file mode 100644 index 000000000..621beae46 --- /dev/null +++ b/templates/short/maintenance.vm @@ -0,0 +1 @@ +$device.name maintenance $maintenance.name is required at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/test.vm b/templates/short/test.vm new file mode 100644 index 000000000..d25f218ce --- /dev/null +++ b/templates/short/test.vm @@ -0,0 +1 @@ +Test message diff --git a/templates/short/textMessage.vm b/templates/short/textMessage.vm new file mode 100644 index 000000000..dc42f29f1 --- /dev/null +++ b/templates/short/textMessage.vm @@ -0,0 +1 @@ +Text message received from $device.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/short/unknown.vm b/templates/short/unknown.vm new file mode 100644 index 000000000..fd20b50cc --- /dev/null +++ b/templates/short/unknown.vm @@ -0,0 +1 @@ +Unknown type diff --git a/templates/sms/alarm.vm b/templates/sms/alarm.vm deleted file mode 100644 index 389341cf1..000000000 --- a/templates/sms/alarm.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/commandResult.vm b/templates/sms/commandResult.vm deleted file mode 100644 index 4a327d850..000000000 --- a/templates/sms/commandResult.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name command result received: $position.getString("result") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceFuelDrop.vm b/templates/sms/deviceFuelDrop.vm deleted file mode 100644 index 5e51396d4..000000000 --- a/templates/sms/deviceFuelDrop.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name fuel drop at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceMoving.vm b/templates/sms/deviceMoving.vm deleted file mode 100644 index aaa72ab0d..000000000 --- a/templates/sms/deviceMoving.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name moving at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOffline.vm b/templates/sms/deviceOffline.vm deleted file mode 100644 index 8c4a02335..000000000 --- a/templates/sms/deviceOffline.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name offline at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOnline.vm b/templates/sms/deviceOnline.vm deleted file mode 100644 index 62854feb0..000000000 --- a/templates/sms/deviceOnline.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name online at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOverspeed.vm b/templates/sms/deviceOverspeed.vm deleted file mode 100644 index 5e92f662c..000000000 --- a/templates/sms/deviceOverspeed.vm +++ /dev/null @@ -1,10 +0,0 @@ -#if($speedUnit == 'kmh') -#set($speedValue = $position.speed * 1.852) -#set($speedString = $numberTool.format("0.0 km/h", $speedValue)) -#elseif($speedUnit == 'mph') -#set($speedValue = $position.speed * 1.15078) -#set($speedString = $numberTool.format("0.0 mph", $speedValue)) -#else -#set($speedString = $numberTool.format("0.0 kn", $position.speed)) -#end -$device.name exceeds the speed $speedString#{if}($geofence) in $geofence.name#{else}#{end} at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceStopped.vm b/templates/sms/deviceStopped.vm deleted file mode 100644 index c2437b5f6..000000000 --- a/templates/sms/deviceStopped.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name stopped at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceUnknown.vm b/templates/sms/deviceUnknown.vm deleted file mode 100644 index 07f39f3a9..000000000 --- a/templates/sms/deviceUnknown.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name status is unknown at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/driverChanged.vm b/templates/sms/driverChanged.vm deleted file mode 100644 index 50849df7c..000000000 --- a/templates/sms/driverChanged.vm +++ /dev/null @@ -1,6 +0,0 @@ -#if($driver) -#set($driverName = $driver.name) -#else -#set($driverName = $event.getString("driverUniqueId")) -#end -Driver $driverName has changed in $device.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/geofenceEnter.vm b/templates/sms/geofenceEnter.vm deleted file mode 100644 index debdbf356..000000000 --- a/templates/sms/geofenceEnter.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name has entered geofence $geofence.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/geofenceExit.vm b/templates/sms/geofenceExit.vm deleted file mode 100644 index 8553458f7..000000000 --- a/templates/sms/geofenceExit.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name has exited geofence $geofence.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/ignitionOff.vm b/templates/sms/ignitionOff.vm deleted file mode 100644 index ddf860413..000000000 --- a/templates/sms/ignitionOff.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name ignition OFF at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/ignitionOn.vm b/templates/sms/ignitionOn.vm deleted file mode 100644 index 00b365be9..000000000 --- a/templates/sms/ignitionOn.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name ignition ON at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/maintenance.vm b/templates/sms/maintenance.vm deleted file mode 100644 index 621beae46..000000000 --- a/templates/sms/maintenance.vm +++ /dev/null @@ -1 +0,0 @@ -$device.name maintenance $maintenance.name is required at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/test.vm b/templates/sms/test.vm deleted file mode 100644 index d25f218ce..000000000 --- a/templates/sms/test.vm +++ /dev/null @@ -1 +0,0 @@ -Test message diff --git a/templates/sms/textMessage.vm b/templates/sms/textMessage.vm deleted file mode 100644 index dc42f29f1..000000000 --- a/templates/sms/textMessage.vm +++ /dev/null @@ -1 +0,0 @@ -Text message received from $device.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/unknown.vm b/templates/sms/unknown.vm deleted file mode 100644 index fd20b50cc..000000000 --- a/templates/sms/unknown.vm +++ /dev/null @@ -1 +0,0 @@ -Unknown type -- cgit v1.2.3 From 253f11afa0e31d97d332ca3269111eff36ee347b Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 26 Jun 2018 12:29:08 +0500 Subject: Rename transports to notificators --- schema/changelog-4.0.xml | 16 +++++++-------- .../traccar/api/resource/NotificationResource.java | 23 +++++++++++----------- src/org/traccar/database/NotificationManager.java | 9 ++++----- src/org/traccar/model/Notification.java | 16 +++++++-------- .../traccar/notification/NotificatorManager.java | 2 +- 5 files changed, 32 insertions(+), 34 deletions(-) (limited to 'src/org/traccar/model/Notification.java') diff --git a/schema/changelog-4.0.xml b/schema/changelog-4.0.xml index 82403c83c..9a5cd1526 100644 --- a/schema/changelog-4.0.xml +++ b/schema/changelog-4.0.xml @@ -56,41 +56,41 @@ - + - + web = 1 AND mail = 1 AND sms = 1 - + web = 1 AND mail = 1 AND sms = 0 - + web = 1 AND mail = 0 AND sms = 0 - + web = 1 AND mail = 0 AND sms = 1 - + web = 0 AND mail = 1 AND sms = 1 - + web = 0 AND mail = 1 AND sms = 0 - + web = 0 AND mail = 0 AND sms = 1 diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java index 9046569a0..bec1ce3ab 100644 --- a/src/org/traccar/api/resource/NotificationResource.java +++ b/src/org/traccar/api/resource/NotificationResource.java @@ -48,11 +48,17 @@ public class NotificationResource extends ExtendedObjectResource { public Collection get() { return Context.getNotificationManager().getAllNotificationTypes(); } + + @GET + @Path("notificators") + public Collection getNotificators() { + return Context.getNotificatorManager().getAllNotificatorTypes(); + } @POST @Path("test") public Response testMessage() throws NotificationException, InterruptedException { - for (Typed method : Context.getNotificatorManager().getNotificatorTypes()) { + for (Typed method : Context.getNotificatorManager().getAllNotificatorTypes()) { Context.getNotificatorManager() .getNotificator(method.getType()).sendSync(getUserId(), new Event("test", 0), null); } @@ -60,18 +66,11 @@ public class NotificationResource extends ExtendedObjectResource { } @POST - @Path("test/{method}") - public Response testMessage(@PathParam("method") String method) throws NotificationException, InterruptedException { - Context.getNotificatorManager().getNotificator(method).sendSync(getUserId(), new Event("test", 0), null); + @Path("test/{notificator}") + public Response testMessage(@PathParam("notificator") String notificator) + throws NotificationException, InterruptedException { + Context.getNotificatorManager().getNotificator(notificator).sendSync(getUserId(), new Event("test", 0), null); return Response.noContent().build(); } - - @GET - @Path("notificators") - public Collection getNotificators() { - return Context.getNotificatorManager().getNotificatorTypes(); - } - - } diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java index b2a30e4f1..5dcb1d317 100644 --- a/src/org/traccar/database/NotificationManager.java +++ b/src/org/traccar/database/NotificationManager.java @@ -83,16 +83,15 @@ public class NotificationManager extends ExtendedObjectManager { if (usersToForward != null) { usersToForward.add(userId); } - final Set notificationMethods = new HashSet<>(); + final Set notificators = new HashSet<>(); for (long notificationId : getEffectiveNotifications(userId, deviceId, event.getServerTime())) { Notification notification = getById(notificationId); if (getById(notificationId).getType().equals(event.getType())) { - notificationMethods.addAll(notification.getTransportMethods()); + notificators.addAll(notification.getNotificatorsTypes()); } } - for (String notificationMethod : notificationMethods) { - Context.getNotificatorManager() - .getNotificator(notificationMethod).sendAsync(userId, event, position); + for (String notificator : notificators) { + Context.getNotificatorManager().getNotificator(notificator).sendAsync(userId, event, position); } } } diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java index 4923798c2..f1983a03a 100644 --- a/src/org/traccar/model/Notification.java +++ b/src/org/traccar/model/Notification.java @@ -45,23 +45,23 @@ public class Notification extends ScheduledModel { } - private String transports; + private String notificators; - public String getTransports() { - return transports; + public String getNotificators() { + return notificators; } - public void setTransports(String transports) { - this.transports = transports; + public void setNotificators(String transports) { + this.notificators = transports; } @JsonIgnore @QueryIgnore - public Set getTransportMethods() { + public Set getNotificatorsTypes() { final Set result = new HashSet<>(); - if (transports != null) { - final String[] transportsList = transports.split(","); + if (notificators != null) { + final String[] transportsList = notificators.split(","); for (String transport : transportsList) { result.add(transport.trim()); } diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java index 87a294345..bb55844f3 100644 --- a/src/org/traccar/notification/NotificatorManager.java +++ b/src/org/traccar/notification/NotificatorManager.java @@ -64,7 +64,7 @@ public final class NotificatorManager { } - public Set getNotificatorTypes() { + public Set getAllNotificatorTypes() { Set result = new HashSet<>(); for (String notificator : notificators.keySet()) { result.add(new Typed(notificator)); -- cgit v1.2.3