Skip to content

Commit 632e6ad

Browse files
committed
- Use ternary operator
- Apply server.forceSettings to speed units, distance units and timezone - Use hyphens for date formatting
1 parent 2309d53 commit 632e6ad

30 files changed

+35
-43
lines changed

pom.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@
144144
<version>1.7</version>
145145
</dependency>
146146
<dependency>
147-
<groupId>org.apache.velocity</groupId>
148-
<artifactId>velocity-tools</artifactId>
149-
<version>2.0</version>
150-
</dependency>
147+
<groupId>org.apache.velocity</groupId>
148+
<artifactId>velocity-tools</artifactId>
149+
<version>2.0</version>
150+
</dependency>
151151
<dependency>
152152
<groupId>org.mnode.ical4j</groupId>
153153
<artifactId>ical4j</artifactId>

src/org/traccar/model/Server.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,7 @@ public void setCoordinateFormat(String coordinateFormat) {
171171
private String timezone;
172172

173173
public void setTimezone(String timezone) {
174-
if (timezone != null) {
175-
this.timezone = TimeZone.getTimeZone(timezone).getID();
176-
} else {
177-
this.timezone = null;
178-
}
174+
this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null;
179175
}
180176

181177
public String getTimezone() {

src/org/traccar/model/User.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,7 @@ public boolean isPasswordValid(String password) {
269269
private String timezone;
270270

271271
public void setTimezone(String timezone) {
272-
if (timezone != null) {
273-
this.timezone = TimeZone.getTimeZone(timezone).getID();
274-
} else {
275-
this.timezone = null;
276-
}
272+
this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null;
277273
}
278274

279275
public String getTimezone() {

src/org/traccar/reports/ReportUtils.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ private ReportUtils() {
3333

3434
public static String getDistanceUnit(long userId) {
3535
String unit = Context.getPermissionsManager().getUser(userId).getDistanceUnit();
36-
if (unit == null) {
36+
if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) {
3737
unit = Context.getPermissionsManager().getServer().getDistanceUnit();
3838
}
3939
return unit != null ? unit : "km";
4040
}
4141

4242
public static String getSpeedUnit(long userId) {
4343
String unit = Context.getPermissionsManager().getUser(userId).getSpeedUnit();
44-
if (unit == null) {
44+
if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) {
4545
unit = Context.getPermissionsManager().getServer().getSpeedUnit();
4646
}
4747
return unit != null ? unit : "kn";
4848
}
4949

5050
public static TimeZone getTimezone(long userId) {
5151
String timezone = Context.getPermissionsManager().getUser(userId).getTimezone();
52-
if (timezone == null) {
52+
if (timezone == null || Context.getPermissionsManager().getServer().getForceSettings()) {
5353
timezone = Context.getPermissionsManager().getServer().getTimezone();
5454
}
5555
return timezone != null ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault();

templates/mail/alarm.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Alarm: $position.getString("alarm")<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/mail/commandResult.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Result: $position.getString("result")<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
99
</body>
1010
</html>

templates/mail/deviceMoving.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Moving<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/mail/deviceOffline.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Offline<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
99
</body>
1010
</html>

templates/mail/deviceOnline.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Online<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
99
</body>
1010
</html>

templates/mail/deviceOverspeed.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<body>
1212
Device: $device.name<br>
1313
Exceeds the speed: $speedString<br>
14-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
14+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
1515
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
1616
</body>
1717
</html>

templates/mail/deviceStopped.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Stopped<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/mail/deviceUnknown.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Status is unknown<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Link: <a href="$webUrl?eventId=$event.id">$webUrl?eventId=$event.id</a>
99
</body>
1010
</html>

templates/mail/geofenceEnter.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Has entered geofence: $geofence.name<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/mail/geofenceExit.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Has exited geofence: $geofence.name<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/mail/ignitionOff.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Ignition OFF<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/mail/ignitionOn.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Ignition ON<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/mail/maintenance.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<body>
55
Device: $device.name<br>
66
Maintenance is required<br>
7-
Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
7+
Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)<br>
88
Point: <a href="$webUrl?eventId=$event.id">#{if}($position.address)$position.address#{else}$position.latitude&deg;, $position.longitude&deg;#{end}</a><br>
99
</body>
1010
</html>

templates/sms/alarm.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/commandResult.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name command result received: $position.getString("result") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name command result received: $position.getString("result") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/deviceMoving.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name moving at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name moving at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/deviceOffline.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name offline at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name offline at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/deviceOnline.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name online at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name online at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/deviceOverspeed.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
#else
66
#set($speedString = "$position.speed kn")
77
#end
8-
$device.name exceeds the speed $speedString at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
8+
$device.name exceeds the speed $speedString at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/deviceStopped.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name stopped at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name stopped at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/deviceUnknown.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name status is unknown at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name status is unknown at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/geofenceEnter.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name has entered geofence $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name has entered geofence $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/geofenceExit.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name has exited geofence $geofence.name at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name has exited geofence $geofence.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/ignitionOff.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name ignition OFF at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name ignition OFF at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/ignitionOn.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name ignition ON at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name ignition ON at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

templates/sms/maintenance.vm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
$device.name maintenance is required at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
1+
$device.name maintenance is required at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)

0 commit comments

Comments
 (0)