aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-03-14 09:11:11 +0500
committerAbyss777 <abyss@fox5.ru>2017-03-14 09:11:11 +0500
commit632e6ad06c435ca8d044e5ae3209cde36cf42743 (patch)
tree959a7791c6c436f1a8452de9adf0b3d5e0d36dcf
parent2309d53f52f25efe00f2195a58c448506a2605ab (diff)
downloadtrackermap-server-632e6ad06c435ca8d044e5ae3209cde36cf42743.tar.gz
trackermap-server-632e6ad06c435ca8d044e5ae3209cde36cf42743.tar.bz2
trackermap-server-632e6ad06c435ca8d044e5ae3209cde36cf42743.zip
- Use ternary operator
- Apply server.forceSettings to speed units, distance units and timezone - Use hyphens for date formatting
-rw-r--r--pom.xml8
-rw-r--r--src/org/traccar/model/Server.java6
-rw-r--r--src/org/traccar/model/User.java6
-rw-r--r--src/org/traccar/reports/ReportUtils.java6
-rw-r--r--templates/mail/alarm.vm2
-rw-r--r--templates/mail/commandResult.vm2
-rw-r--r--templates/mail/deviceMoving.vm2
-rw-r--r--templates/mail/deviceOffline.vm2
-rw-r--r--templates/mail/deviceOnline.vm2
-rw-r--r--templates/mail/deviceOverspeed.vm2
-rw-r--r--templates/mail/deviceStopped.vm2
-rw-r--r--templates/mail/deviceUnknown.vm2
-rw-r--r--templates/mail/geofenceEnter.vm2
-rw-r--r--templates/mail/geofenceExit.vm2
-rw-r--r--templates/mail/ignitionOff.vm2
-rw-r--r--templates/mail/ignitionOn.vm2
-rw-r--r--templates/mail/maintenance.vm2
-rw-r--r--templates/sms/alarm.vm2
-rw-r--r--templates/sms/commandResult.vm2
-rw-r--r--templates/sms/deviceMoving.vm2
-rw-r--r--templates/sms/deviceOffline.vm2
-rw-r--r--templates/sms/deviceOnline.vm2
-rw-r--r--templates/sms/deviceOverspeed.vm2
-rw-r--r--templates/sms/deviceStopped.vm2
-rw-r--r--templates/sms/deviceUnknown.vm2
-rw-r--r--templates/sms/geofenceEnter.vm2
-rw-r--r--templates/sms/geofenceExit.vm2
-rw-r--r--templates/sms/ignitionOff.vm2
-rw-r--r--templates/sms/ignitionOn.vm2
-rw-r--r--templates/sms/maintenance.vm2
30 files changed, 35 insertions, 43 deletions
diff --git a/pom.xml b/pom.xml
index 4ef3bb40f..8700c6ff1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -144,10 +144,10 @@
<version>1.7</version>
</dependency>
<dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity-tools</artifactId>
- <version>2.0</version>
- </dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-tools</artifactId>
+ <version>2.0</version>
+ </dependency>
<dependency>
<groupId>org.mnode.ical4j</groupId>
<artifactId>ical4j</artifactId>
diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java
index db3f021a9..4ded65204 100644
--- a/src/org/traccar/model/Server.java
+++ b/src/org/traccar/model/Server.java
@@ -171,11 +171,7 @@ public class Server extends Extensible {
private String timezone;
public void setTimezone(String timezone) {
- if (timezone != null) {
- this.timezone = TimeZone.getTimeZone(timezone).getID();
- } else {
- this.timezone = null;
- }
+ this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null;
}
public String getTimezone() {
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java
index 71bb563a8..366ced503 100644
--- a/src/org/traccar/model/User.java
+++ b/src/org/traccar/model/User.java
@@ -269,11 +269,7 @@ public class User extends Extensible {
private String timezone;
public void setTimezone(String timezone) {
- if (timezone != null) {
- this.timezone = TimeZone.getTimeZone(timezone).getID();
- } else {
- this.timezone = null;
- }
+ this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null;
}
public String getTimezone() {
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index 968fb357b..3699b1bea 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -33,7 +33,7 @@ public final class ReportUtils {
public static String getDistanceUnit(long userId) {
String unit = Context.getPermissionsManager().getUser(userId).getDistanceUnit();
- if (unit == null) {
+ if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) {
unit = Context.getPermissionsManager().getServer().getDistanceUnit();
}
return unit != null ? unit : "km";
@@ -41,7 +41,7 @@ public final class ReportUtils {
public static String getSpeedUnit(long userId) {
String unit = Context.getPermissionsManager().getUser(userId).getSpeedUnit();
- if (unit == null) {
+ if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) {
unit = Context.getPermissionsManager().getServer().getSpeedUnit();
}
return unit != null ? unit : "kn";
@@ -49,7 +49,7 @@ public final class ReportUtils {
public static TimeZone getTimezone(long userId) {
String timezone = Context.getPermissionsManager().getUser(userId).getTimezone();
- if (timezone == null) {
+ if (timezone == null || Context.getPermissionsManager().getServer().getForceSettings()) {
timezone = Context.getPermissionsManager().getServer().getTimezone();
}
return timezone != null ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault();
diff --git a/templates/mail/alarm.vm b/templates/mail/alarm.vm
index 253c0b7a3..8f1164291 100644
--- a/templates/mail/alarm.vm
+++ b/templates/mail/alarm.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Alarm: $position.getString("alarm")<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/commandResult.vm b/templates/mail/commandResult.vm
index 3d2a7ceb8..5b6d8ef3e 100644
--- a/templates/mail/commandResult.vm
+++ b/templates/mail/commandResult.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Result: $position.getString("result")<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
</body>
</html>
diff --git a/templates/mail/deviceMoving.vm b/templates/mail/deviceMoving.vm
index a734e59b4..6e98af1de 100644
--- a/templates/mail/deviceMoving.vm
+++ b/templates/mail/deviceMoving.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Moving<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/deviceOffline.vm b/templates/mail/deviceOffline.vm
index d77f4e6a9..1f6d02fb2 100644
--- a/templates/mail/deviceOffline.vm
+++ b/templates/mail/deviceOffline.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Offline<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
</body>
</html>
diff --git a/templates/mail/deviceOnline.vm b/templates/mail/deviceOnline.vm
index 9ea65c843..9211eff11 100644
--- a/templates/mail/deviceOnline.vm
+++ b/templates/mail/deviceOnline.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Online<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
</body>
</html>
diff --git a/templates/mail/deviceOverspeed.vm b/templates/mail/deviceOverspeed.vm
index 1836dacd5..3b203ddcd 100644
--- a/templates/mail/deviceOverspeed.vm
+++ b/templates/mail/deviceOverspeed.vm
@@ -11,7 +11,7 @@
<body>
Device: $device.name<br>
Exceeds the speed: $speedString<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/deviceStopped.vm b/templates/mail/deviceStopped.vm
index 45f97e463..2ec0f8db9 100644
--- a/templates/mail/deviceStopped.vm
+++ b/templates/mail/deviceStopped.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Stopped<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/deviceUnknown.vm b/templates/mail/deviceUnknown.vm
index 73696bc47..34fa01a8a 100644
--- a/templates/mail/deviceUnknown.vm
+++ b/templates/mail/deviceUnknown.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Status is unknown<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
</body>
</html>
diff --git a/templates/mail/geofenceEnter.vm b/templates/mail/geofenceEnter.vm
index f0f84fb67..e83a0de62 100644
--- a/templates/mail/geofenceEnter.vm
+++ b/templates/mail/geofenceEnter.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Has entered geofence: $geofence.name<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/geofenceExit.vm b/templates/mail/geofenceExit.vm
index 90e61b618..3557f6eb2 100644
--- a/templates/mail/geofenceExit.vm
+++ b/templates/mail/geofenceExit.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Has exited geofence: $geofence.name<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/ignitionOff.vm b/templates/mail/ignitionOff.vm
index 407577640..0281eef02 100644
--- a/templates/mail/ignitionOff.vm
+++ b/templates/mail/ignitionOff.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Ignition OFF<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/ignitionOn.vm b/templates/mail/ignitionOn.vm
index ad039a849..27135a7f0 100644
--- a/templates/mail/ignitionOn.vm
+++ b/templates/mail/ignitionOn.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Ignition ON<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/mail/maintenance.vm b/templates/mail/maintenance.vm
index 2951fdfda..7f69b6c0d 100644
--- a/templates/mail/maintenance.vm
+++ b/templates/mail/maintenance.vm
@@ -4,7 +4,7 @@
<body>
Device: $device.name<br>
Maintenance is required<br>
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
</body>
</html>
diff --git a/templates/sms/alarm.vm b/templates/sms/alarm.vm
index 0277fbddf..389341cf1 100644
--- a/templates/sms/alarm.vm
+++ b/templates/sms/alarm.vm
@@ -1 +1 @@
-$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 4962eaa36..4a327d850 100644
--- a/templates/sms/commandResult.vm
+++ b/templates/sms/commandResult.vm
@@ -1 +1 @@
-$device.name command result received: $position.getString("result") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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/deviceMoving.vm b/templates/sms/deviceMoving.vm
index 4f62421b2..aaa72ab0d 100644
--- a/templates/sms/deviceMoving.vm
+++ b/templates/sms/deviceMoving.vm
@@ -1 +1 @@
-$device.name moving at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 7df007f81..8c4a02335 100644
--- a/templates/sms/deviceOffline.vm
+++ b/templates/sms/deviceOffline.vm
@@ -1 +1 @@
-$device.name offline at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 48e81ec75..62854feb0 100644
--- a/templates/sms/deviceOnline.vm
+++ b/templates/sms/deviceOnline.vm
@@ -1 +1 @@
-$device.name online at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 4e3219a18..3c9eae628 100644
--- a/templates/sms/deviceOverspeed.vm
+++ b/templates/sms/deviceOverspeed.vm
@@ -5,4 +5,4 @@
#else
#set($speedString = "$position.speed kn")
#end
-$device.name exceeds the speed $speedString at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$device.name exceeds the speed $speedString 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
index 80e2c085f..c2437b5f6 100644
--- a/templates/sms/deviceStopped.vm
+++ b/templates/sms/deviceStopped.vm
@@ -1 +1 @@
-$device.name stopped at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 150d05df1..07f39f3a9 100644
--- a/templates/sms/deviceUnknown.vm
+++ b/templates/sms/deviceUnknown.vm
@@ -1 +1 @@
-$device.name status is unknown at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$device.name status is unknown 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
index 443b1c0a8..9dd861931 100644
--- a/templates/sms/geofenceEnter.vm
+++ b/templates/sms/geofenceEnter.vm
@@ -1 +1 @@
-$device.name has entered geofence $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$device.name has entered geofence $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
diff --git a/templates/sms/geofenceExit.vm b/templates/sms/geofenceExit.vm
index 1314a7ebc..8553458f7 100644
--- a/templates/sms/geofenceExit.vm
+++ b/templates/sms/geofenceExit.vm
@@ -1 +1 @@
-$device.name has exited geofence $geofence.name at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 2795dc1a5..ddf860413 100644
--- a/templates/sms/ignitionOff.vm
+++ b/templates/sms/ignitionOff.vm
@@ -1 +1 @@
-$device.name ignition OFF at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 76a8fc676..00b365be9 100644
--- a/templates/sms/ignitionOn.vm
+++ b/templates/sms/ignitionOn.vm
@@ -1 +1 @@
-$device.name ignition ON at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$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
index 2375feefb..554b74400 100644
--- a/templates/sms/maintenance.vm
+++ b/templates/sms/maintenance.vm
@@ -1 +1 @@
-$device.name maintenance is required at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+$device.name maintenance is required at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)