From 8224082fa8ebaf0e78bc6d6a72ed4f04bb277586 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 17 Jan 2018 13:53:59 +0500 Subject: Add poiLayer field to User/Server model --- src/org/traccar/model/User.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/org/traccar/model/User.java') diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index b1883213c..7f97d4781 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -230,6 +230,16 @@ public class User extends ExtendedModel { this.limitCommands = limitCommands; } + private String poiLayer; + + public String getPoiLayer() { + return poiLayer; + } + + public void setPoiLayer(String poiLayer) { + this.poiLayer = poiLayer; + } + @QueryIgnore public String getPassword() { return null; -- cgit v1.2.3 From 48a5bd364b496de70a1a3eff8dd5c57c5d8fec9d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 22 Jan 2018 19:53:48 +1300 Subject: Optimize date assignment --- findbugs.xml | 8 ++++++ src/org/traccar/model/Event.java | 12 ++------- src/org/traccar/model/Position.java | 36 +++++---------------------- src/org/traccar/model/Statistics.java | 12 ++------- src/org/traccar/model/User.java | 12 ++------- src/org/traccar/reports/model/StopReport.java | 24 +++--------------- src/org/traccar/reports/model/TripReport.java | 24 +++--------------- test/org/traccar/ProtocolTest.java | 8 +++--- test/org/traccar/reports/ReportUtilsTest.java | 4 +-- 9 files changed, 32 insertions(+), 108 deletions(-) (limited to 'src/org/traccar/model/User.java') diff --git a/findbugs.xml b/findbugs.xml index 18fba5c9a..d7890baac 100644 --- a/findbugs.xml +++ b/findbugs.xml @@ -1,5 +1,13 @@ + + + + + + + + diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index 47b60af01..465afeb35 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -64,19 +64,11 @@ public class Event extends Message { private Date serverTime; public Date getServerTime() { - if (serverTime != null) { - return new Date(serverTime.getTime()); - } else { - return null; - } + return serverTime; } public void setServerTime(Date serverTime) { - if (serverTime != null) { - this.serverTime = new Date(serverTime.getTime()); - } else { - this.serverTime = null; - } + this.serverTime = serverTime; } private long positionId; diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index 3943c1ef9..981c2292f 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -152,55 +152,31 @@ public class Position extends Message { private Date serverTime; public Date getServerTime() { - if (serverTime != null) { - return new Date(serverTime.getTime()); - } else { - return null; - } + return serverTime; } public void setServerTime(Date serverTime) { - if (serverTime != null) { - this.serverTime = new Date(serverTime.getTime()); - } else { - this.serverTime = null; - } + this.serverTime = serverTime; } private Date deviceTime; public Date getDeviceTime() { - if (deviceTime != null) { - return new Date(deviceTime.getTime()); - } else { - return null; - } + return deviceTime; } public void setDeviceTime(Date deviceTime) { - if (deviceTime != null) { - this.deviceTime = new Date(deviceTime.getTime()); - } else { - this.deviceTime = null; - } + this.deviceTime = deviceTime; } private Date fixTime; public Date getFixTime() { - if (fixTime != null) { - return new Date(fixTime.getTime()); - } else { - return null; - } + return fixTime; } public void setFixTime(Date fixTime) { - if (fixTime != null) { - this.fixTime = new Date(fixTime.getTime()); - } else { - this.fixTime = null; - } + this.fixTime = fixTime; } public void setTime(Date time) { diff --git a/src/org/traccar/model/Statistics.java b/src/org/traccar/model/Statistics.java index 2acf8514f..cb72c91dd 100644 --- a/src/org/traccar/model/Statistics.java +++ b/src/org/traccar/model/Statistics.java @@ -22,19 +22,11 @@ public class Statistics extends ExtendedModel { private Date captureTime; public Date getCaptureTime() { - if (captureTime != null) { - return new Date(captureTime.getTime()); - } else { - return null; - } + return captureTime; } public void setCaptureTime(Date captureTime) { - if (captureTime != null) { - this.captureTime = new Date(captureTime.getTime()); - } else { - this.captureTime = null; - } + this.captureTime = captureTime; } private int activeUsers; diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index 7f97d4781..1a131a4e8 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -158,19 +158,11 @@ public class User extends ExtendedModel { private Date expirationTime; public Date getExpirationTime() { - if (expirationTime != null) { - return new Date(expirationTime.getTime()); - } else { - return null; - } + return expirationTime; } public void setExpirationTime(Date expirationTime) { - if (expirationTime != null) { - this.expirationTime = new Date(expirationTime.getTime()); - } else { - this.expirationTime = null; - } + this.expirationTime = expirationTime; } private int deviceLimit; diff --git a/src/org/traccar/reports/model/StopReport.java b/src/org/traccar/reports/model/StopReport.java index 6b2e86299..245292b63 100644 --- a/src/org/traccar/reports/model/StopReport.java +++ b/src/org/traccar/reports/model/StopReport.java @@ -53,37 +53,21 @@ public class StopReport extends BaseReport { private Date startTime; public Date getStartTime() { - if (startTime != null) { - return new Date(startTime.getTime()); - } else { - return null; - } + return startTime; } public void setStartTime(Date startTime) { - if (startTime != null) { - this.startTime = new Date(startTime.getTime()); - } else { - this.startTime = null; - } + this.startTime = startTime; } private Date endTime; public Date getEndTime() { - if (endTime != null) { - return new Date(endTime.getTime()); - } else { - return null; - } + return endTime; } public void setEndTime(Date endTime) { - if (endTime != null) { - this.endTime = new Date(endTime.getTime()); - } else { - this.endTime = null; - } + this.endTime = endTime; } private String address; diff --git a/src/org/traccar/reports/model/TripReport.java b/src/org/traccar/reports/model/TripReport.java index 42a4240b7..3140f3019 100644 --- a/src/org/traccar/reports/model/TripReport.java +++ b/src/org/traccar/reports/model/TripReport.java @@ -83,19 +83,11 @@ public class TripReport extends BaseReport { private Date startTime; public Date getStartTime() { - if (startTime != null) { - return new Date(startTime.getTime()); - } else { - return null; - } + return startTime; } public void setStartTime(Date startTime) { - if (startTime != null) { - this.startTime = new Date(startTime.getTime()); - } else { - this.startTime = null; - } + this.startTime = startTime; } private String startAddress; @@ -111,19 +103,11 @@ public class TripReport extends BaseReport { private Date endTime; public Date getEndTime() { - if (endTime != null) { - return new Date(endTime.getTime()); - } else { - return null; - } + return endTime; } public void setEndTime(Date endTime) { - if (endTime != null) { - this.endTime = new Date(endTime.getTime()); - } else { - this.endTime = null; - } + this.endTime = endTime; } private String endAddress; diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 1daefabd6..5cbb651bf 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -27,11 +27,9 @@ public class ProtocolTest extends BaseTest { Position position = new Position(); - if (time != null) { - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - position.setTime(dateFormat.parse(time)); - } + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + position.setTime(dateFormat.parse(time)); position.setValid(valid); position.setLatitude(lat); position.setLongitude(lon); diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java index 4f7a4eb68..0e26c7e75 100644 --- a/test/org/traccar/reports/ReportUtilsTest.java +++ b/test/org/traccar/reports/ReportUtilsTest.java @@ -35,9 +35,7 @@ public class ReportUtilsTest extends BaseTest { Position position = new Position(); - if (time != null) { - position.setTime(date(time)); - } + position.setTime(date(time)); position.setValid(true); position.setSpeed(speed); position.set(Position.KEY_TOTAL_DISTANCE, totalDistance); -- cgit v1.2.3