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(-) 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