diff options
author | Abyss777 <abyss@fox5.ru> | 2018-06-26 12:29:08 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2018-06-26 12:29:08 +0500 |
commit | 253f11afa0e31d97d332ca3269111eff36ee347b (patch) | |
tree | 98866ec1ffed872995b4a71c0c1deb99a4f9c656 | |
parent | 825ee0d178a24620f075cb4ffb8d49c75b046484 (diff) | |
download | traccar-server-253f11afa0e31d97d332ca3269111eff36ee347b.tar.gz traccar-server-253f11afa0e31d97d332ca3269111eff36ee347b.tar.bz2 traccar-server-253f11afa0e31d97d332ca3269111eff36ee347b.zip |
Rename transports to notificators
-rw-r--r-- | schema/changelog-4.0.xml | 16 | ||||
-rw-r--r-- | src/org/traccar/api/resource/NotificationResource.java | 23 | ||||
-rw-r--r-- | src/org/traccar/database/NotificationManager.java | 9 | ||||
-rw-r--r-- | src/org/traccar/model/Notification.java | 16 | ||||
-rw-r--r-- | src/org/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 @@ <changeSet author="author" id="changelog-4.0"> <addColumn tableName="tc_notifications"> - <column name="transports" type="VARCHAR(128)" /> + <column name="notificators" type="VARCHAR(128)" /> </addColumn> <update tableName="tc_notifications"> - <column name="transports" value="web,mail,sms" /> + <column name="notificators" value="web,mail,sms" /> <where>web = 1 AND mail = 1 AND sms = 1</where> </update> <update tableName="tc_notifications"> - <column name="transports" value="web,mail" /> + <column name="notificators" value="web,mail" /> <where>web = 1 AND mail = 1 AND sms = 0</where> </update> <update tableName="tc_notifications"> - <column name="transports" value="web" /> + <column name="notificators" value="web" /> <where>web = 1 AND mail = 0 AND sms = 0</where> </update> <update tableName="tc_notifications"> - <column name="transports" value="web,sms" /> + <column name="notificators" value="web,sms" /> <where>web = 1 AND mail = 0 AND sms = 1</where> </update> <update tableName="tc_notifications"> - <column name="transports" value="mail,sms" /> + <column name="notificators" value="mail,sms" /> <where>web = 0 AND mail = 1 AND sms = 1</where> </update> <update tableName="tc_notifications"> - <column name="transports" value="mail" /> + <column name="notificators" value="mail" /> <where>web = 0 AND mail = 1 AND sms = 0</where> </update> <update tableName="tc_notifications"> - <column name="transports" value="sms" /> + <column name="notificators" value="sms" /> <where>web = 0 AND mail = 0 AND sms = 1</where> </update> 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<Notification> { public Collection<Typed> get() { return Context.getNotificationManager().getAllNotificationTypes(); } + + @GET + @Path("notificators") + public Collection<Typed> 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<Notification> { } @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<Typed> 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<Notification> { if (usersToForward != null) { usersToForward.add(userId); } - final Set<String> notificationMethods = new HashSet<>(); + final Set<String> 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<String> getTransportMethods() { + public Set<String> getNotificatorsTypes() { final Set<String> 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<Typed> getNotificatorTypes() { + public Set<Typed> getAllNotificatorTypes() { Set<Typed> result = new HashSet<>(); for (String notificator : notificators.keySet()) { result.add(new Typed(notificator)); |