aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--schema/changelog-3.18.xml57
-rw-r--r--src/org/traccar/database/NotificationManager.java2
-rw-r--r--src/org/traccar/model/Notification.java41
3 files changed, 67 insertions, 33 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"
+ logicalFilePath="changelog-3.18">
+
+ <changeSet author="author" id="changelog-3.18">
+
+ <addColumn tableName="notifications">
+ <column name="transports" type="VARCHAR(128)" />
+ </addColumn>
+
+ <update tableName="notifications">
+ <column name="transports" value="web, mail, sms" />
+ <where>web = 1 AND mail = 1 AND sms = 1</where>
+ </update>
+
+ <update tableName="notifications">
+ <column name="transports" value="web, mail" />
+ <where>web = 1 AND mail = 1 AND sms = 0</where>
+ </update>
+
+ <update tableName="notifications">
+ <column name="transports" value="web" />
+ <where>web = 1 AND mail = 0 AND sms = 0</where>
+ </update>
+
+ <update tableName="notifications">
+ <column name="transports" value="web, sms" />
+ <where>web = 1 AND mail = 0 AND sms = 1</where>
+ </update>
+
+ <update tableName="notifications">
+ <column name="transports" value="mail, sms" />
+ <where>web = 0 AND mail = 1 AND sms = 1</where>
+ </update>
+
+ <update tableName="notifications">
+ <column name="transports" value="mail" />
+ <where>web = 0 AND mail = 1 AND sms = 0</where>
+ </update>
+
+ <update tableName="notifications">
+ <column name="transports" value="sms" />
+ <where>web = 0 AND mail = 0 AND sms = 1</where>
+ </update>
+
+ <!--
+ <dropColumn tableName="notifications" columnName="web" />
+ <dropColumn tableName="notifications" columnName="mail" />
+ <dropColumn tableName="notifications" columnName="sms" />
+ -->
+
+ </changeSet>
+</databaseChangeLog>
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<Notification> {
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<String> getMethods() {
+ public Set<String> getTransportMethods() {
final Set<String> 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;
}