diff options
author | Philipp Prangenberg <philipp.prangenberg@derkurier.de> | 2016-12-05 12:03:08 +0100 |
---|---|---|
committer | Philipp Prangenberg <philipp.prangenberg@derkurier.de> | 2016-12-05 12:03:08 +0100 |
commit | a21f436a58133f7da0cae06366d729665f3b8f9c (patch) | |
tree | 72ff1743d96f79e4a9d85b0d48715e5f9aa67cf9 /src/org/traccar/model | |
parent | 960bf899414d89221e92138fdb98777c3f4f73ec (diff) | |
parent | 40607036c5aa6385a7ae3f3a283bf107238a5944 (diff) | |
download | trackermap-server-a21f436a58133f7da0cae06366d729665f3b8f9c.tar.gz trackermap-server-a21f436a58133f7da0cae06366d729665f3b8f9c.tar.bz2 trackermap-server-a21f436a58133f7da0cae06366d729665f3b8f9c.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r-- | src/org/traccar/model/AttributeAlias.java | 4 | ||||
-rw-r--r-- | src/org/traccar/model/Command.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/Device.java | 42 | ||||
-rw-r--r-- | src/org/traccar/model/DeviceGeofence.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/DevicePermission.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/DeviceTotalDistance.java | 41 | ||||
-rw-r--r-- | src/org/traccar/model/Event.java | 7 | ||||
-rw-r--r-- | src/org/traccar/model/Extensible.java | 42 | ||||
-rw-r--r-- | src/org/traccar/model/Geofence.java | 7 | ||||
-rw-r--r-- | src/org/traccar/model/GeofencePermission.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/Group.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/GroupGeofence.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/GroupPermission.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/Message.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/MiscFormatter.java | 2 | ||||
-rw-r--r-- | src/org/traccar/model/Notification.java | 21 | ||||
-rw-r--r-- | src/org/traccar/model/Position.java | 9 | ||||
-rw-r--r-- | src/org/traccar/model/Server.java | 31 | ||||
-rw-r--r-- | src/org/traccar/model/Statistics.java | 90 | ||||
-rw-r--r-- | src/org/traccar/model/User.java | 72 |
20 files changed, 362 insertions, 22 deletions
diff --git a/src/org/traccar/model/AttributeAlias.java b/src/org/traccar/model/AttributeAlias.java index 023925ac3..2835c0558 100644 --- a/src/org/traccar/model/AttributeAlias.java +++ b/src/org/traccar/model/AttributeAlias.java @@ -1,6 +1,6 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) - * Copyright 2016 Andrey Kunitsyn (abyss@fox5.ru) + * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/org/traccar/model/Command.java b/src/org/traccar/model/Command.java index 67c624fcd..51a61b966 100644 --- a/src/org/traccar/model/Command.java +++ b/src/org/traccar/model/Command.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 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. diff --git a/src/org/traccar/model/Device.java b/src/org/traccar/model/Device.java index e90742836..e492a6120 100644 --- a/src/org/traccar/model/Device.java +++ b/src/org/traccar/model/Device.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 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. @@ -101,4 +101,44 @@ public class Device extends Extensible { public void setGeofenceIds(List<Long> geofenceIds) { this.geofenceIds = geofenceIds; } + + private String phone; + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + private String model; + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + private String contact; + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + private String category; + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } } diff --git a/src/org/traccar/model/DeviceGeofence.java b/src/org/traccar/model/DeviceGeofence.java index 05f06bb3d..00c99add6 100644 --- a/src/org/traccar/model/DeviceGeofence.java +++ b/src/org/traccar/model/DeviceGeofence.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. diff --git a/src/org/traccar/model/DevicePermission.java b/src/org/traccar/model/DevicePermission.java index b3bc0cae0..c62173132 100644 --- a/src/org/traccar/model/DevicePermission.java +++ b/src/org/traccar/model/DevicePermission.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 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. diff --git a/src/org/traccar/model/DeviceTotalDistance.java b/src/org/traccar/model/DeviceTotalDistance.java new file mode 100644 index 000000000..4c89b7689 --- /dev/null +++ b/src/org/traccar/model/DeviceTotalDistance.java @@ -0,0 +1,41 @@ +/* + * Copyright 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 Andrey Kunitsyn (andrey@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.model; + +public class DeviceTotalDistance { + + private long deviceId; + + public long getDeviceId() { + return deviceId; + } + + public void setDeviceId(long deviceId) { + this.deviceId = deviceId; + } + + private double totalDistance; + + public double getTotalDistance() { + return totalDistance; + } + + public void setTotalDistance(double totalDistance) { + this.totalDistance = totalDistance; + } + +} diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java index c3c8b5320..ee62f9776 100644 --- a/src/org/traccar/model/Event.java +++ b/src/org/traccar/model/Event.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. @@ -35,9 +35,12 @@ public class Event extends Message { public Event() { } + public static final String ALL_EVENTS = "allEvents"; + public static final String TYPE_COMMAND_RESULT = "commandResult"; public static final String TYPE_DEVICE_ONLINE = "deviceOnline"; + public static final String TYPE_DEVICE_UNKNOWN = "deviceUnknown"; public static final String TYPE_DEVICE_OFFLINE = "deviceOffline"; public static final String TYPE_DEVICE_MOVING = "deviceMoving"; @@ -53,6 +56,8 @@ public class Event extends Message { public static final String TYPE_IGNITION_ON = "ignitionOn"; public static final String TYPE_IGNITION_OFF = "ignitionOff"; + public static final String TYPE_MAINTENANCE = "maintenance"; + private Date serverTime; public Date getServerTime() { diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/Extensible.java index eceeccadf..b8c83bb21 100644 --- a/src/org/traccar/model/Extensible.java +++ b/src/org/traccar/model/Extensible.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. @@ -68,4 +68,44 @@ public class Extensible { } } + public String getString(String key) { + if (attributes.containsKey(key)) { + return (String) attributes.get(key); + } else { + return null; + } + } + + public double getDouble(String key) { + if (attributes.containsKey(key)) { + return ((Number) attributes.get(key)).doubleValue(); + } else { + return 0.0; + } + } + + public boolean getBoolean(String key) { + if (attributes.containsKey(key)) { + return Boolean.parseBoolean(attributes.get(key).toString()); + } else { + return false; + } + } + + public int getInteger(String key) { + if (attributes.containsKey(key)) { + return ((Number) attributes.get(key)).intValue(); + } else { + return 0; + } + } + + public long getLong(String key) { + if (attributes.containsKey(key)) { + return ((Number) attributes.get(key)).longValue(); + } else { + return 0; + } + } + } diff --git a/src/org/traccar/model/Geofence.java b/src/org/traccar/model/Geofence.java index 9a60f784f..326c45b5f 100644 --- a/src/org/traccar/model/Geofence.java +++ b/src/org/traccar/model/Geofence.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. @@ -17,9 +17,11 @@ package org.traccar.model; import java.text.ParseException; +import org.traccar.Context; import org.traccar.geofence.GeofenceCircle; import org.traccar.geofence.GeofenceGeometry; import org.traccar.geofence.GeofencePolygon; +import org.traccar.geofence.GeofencePolyline; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -27,6 +29,7 @@ public class Geofence extends Extensible { public static final String TYPE_GEOFENCE_CILCLE = "geofenceCircle"; public static final String TYPE_GEOFENCE_POLYGON = "geofencePolygon"; + public static final String TYPE_GEOFENCE_POLYLINE = "geofencePolyline"; private String name; @@ -60,6 +63,8 @@ public class Geofence extends Extensible { geometry = new GeofenceCircle(area); } else if (area.startsWith("POLYGON")) { geometry = new GeofencePolygon(area); + } else if (area.startsWith("LINESTRING")) { + geometry = new GeofencePolyline(area, Context.getConfig().getDouble("geofence.polylineDistance", 25)); } else { throw new ParseException("Unknown geometry type", 0); } diff --git a/src/org/traccar/model/GeofencePermission.java b/src/org/traccar/model/GeofencePermission.java index 269918d66..464f4e9eb 100644 --- a/src/org/traccar/model/GeofencePermission.java +++ b/src/org/traccar/model/GeofencePermission.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. diff --git a/src/org/traccar/model/Group.java b/src/org/traccar/model/Group.java index e70b3f3d5..c21d43127 100644 --- a/src/org/traccar/model/Group.java +++ b/src/org/traccar/model/Group.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. diff --git a/src/org/traccar/model/GroupGeofence.java b/src/org/traccar/model/GroupGeofence.java index 0e261fd54..736e6c704 100644 --- a/src/org/traccar/model/GroupGeofence.java +++ b/src/org/traccar/model/GroupGeofence.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. diff --git a/src/org/traccar/model/GroupPermission.java b/src/org/traccar/model/GroupPermission.java index 9b0011575..59b41b049 100644 --- a/src/org/traccar/model/GroupPermission.java +++ b/src/org/traccar/model/GroupPermission.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. diff --git a/src/org/traccar/model/Message.java b/src/org/traccar/model/Message.java index 55d9fd0c7..ab472202b 100644 --- a/src/org/traccar/model/Message.java +++ b/src/org/traccar/model/Message.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2013 - 2016 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. diff --git a/src/org/traccar/model/MiscFormatter.java b/src/org/traccar/model/MiscFormatter.java index 9bb856400..6194a998f 100644 --- a/src/org/traccar/model/MiscFormatter.java +++ b/src/org/traccar/model/MiscFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2013 - 2015 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. diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java index 0664d6a00..dd5f66f15 100644 --- a/src/org/traccar/model/Notification.java +++ b/src/org/traccar/model/Notification.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2016 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. @@ -37,4 +37,23 @@ public class Notification extends Extensible { 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; + } + + public void setMail(boolean mail) { + this.mail = mail; + } } diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java index c1058aef9..8ca2588e2 100644 --- a/src/org/traccar/model/Position.java +++ b/src/org/traccar/model/Position.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2016 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. @@ -35,6 +35,7 @@ public class Position extends Message { public static final String KEY_OUTPUT = "output"; public static final String KEY_POWER = "power"; public static final String KEY_BATTERY = "battery"; + public static final String KEY_CELL_TOWERS = "cellTowers"; public static final String KEY_MCC = "mcc"; public static final String KEY_MNC = "mnc"; public static final String KEY_LAC = "lac"; @@ -58,7 +59,9 @@ public class Position extends Message { public static final String KEY_MOTION = "motion"; public static final String KEY_ARMED = "armed"; public static final String KEY_ACCURACY = "accuracy"; + public static final String KEY_GEOFENCE = "geofence"; + public static final String KEY_DTCS = "dtcs"; public static final String KEY_OBD_SPEED = "obdSpeed"; public static final String KEY_OBD_ODOMETER = "obdOdometer"; @@ -81,6 +84,8 @@ public class Position extends Message { public static final String ALARM_LOW_BATTERY = "lowBattery"; public static final String ALARM_FAULT = "fault"; public static final String ALARM_POWER_OFF = "powerOff"; + public static final String ALARM_POWER_ON = "powerOn"; + public static final String ALARM_DOOR = "door"; public static final String ALARM_GEOFENCE = "geofence"; public static final String ALARM_GEOFENCE_ENTER = "geofenceEnter"; public static final String ALARM_GEOFENCE_EXIT = "geofenceExit"; @@ -91,6 +96,8 @@ public class Position extends Message { public static final String ALARM_BREAKING = "hardBreaking"; public static final String ALARM_FATIGUE_DRIVING = "fatigueDriving"; public static final String ALARM_POWER_CUT = "powerCut"; + public static final String ALARM_JAMMING = "jamming"; + public static final String ALARM_TEMPERATURE = "temperature"; private String protocol; diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java index b1557bf8f..5cf26f7f2 100644 --- a/src/org/traccar/model/Server.java +++ b/src/org/traccar/model/Server.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2015 - 2016 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. @@ -15,8 +15,17 @@ */ package org.traccar.model; +import org.traccar.helper.Log; + public class Server extends Extensible { + public String getVersion() { + return Log.getAppVersion(); + } + + public void setVersion(String version) { + } + private boolean registration; public boolean getRegistration() { @@ -127,4 +136,24 @@ public class Server extends Extensible { this.twelveHourFormat = twelveHourFormat; } + private boolean forceSettings; + + public boolean getForceSettings() { + return forceSettings; + } + + public void setForceSettings(boolean forceSettings) { + this.forceSettings = forceSettings; + } + + private String coordinateFormat; + + public String getCoordinateFormat() { + return coordinateFormat; + } + + public void setCoordinateFormat(String coordinateFormat) { + this.coordinateFormat = coordinateFormat; + } + } diff --git a/src/org/traccar/model/Statistics.java b/src/org/traccar/model/Statistics.java new file mode 100644 index 000000000..f458ddfad --- /dev/null +++ b/src/org/traccar/model/Statistics.java @@ -0,0 +1,90 @@ +/* + * Copyright 2016 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.model; + +import java.util.Date; + +public class Statistics extends Extensible { + + private Date captureTime; + + public Date getCaptureTime() { + if (captureTime != null) { + return new Date(captureTime.getTime()); + } else { + return null; + } + } + + public void setCaptureTime(Date captureTime) { + if (captureTime != null) { + this.captureTime = new Date(captureTime.getTime()); + } else { + this.captureTime = null; + } + } + + private int activeUsers; + + public int getActiveUsers() { + return activeUsers; + } + + public void setActiveUsers(int activeUsers) { + this.activeUsers = activeUsers; + } + + private int activeDevices; + + public int getActiveDevices() { + return activeDevices; + } + + public void setActiveDevices(int activeDevices) { + this.activeDevices = activeDevices; + } + + private int requests; + + public int getRequests() { + return requests; + } + + public void setRequests(int requests) { + this.requests = requests; + } + + private int messagesReceived; + + public int getMessagesReceived() { + return messagesReceived; + } + + public void setMessagesReceived(int messagesReceived) { + this.messagesReceived = messagesReceived; + } + + private int messagesStored; + + public int getMessagesStored() { + return messagesStored; + } + + public void setMessagesStored(int messagesStored) { + this.messagesStored = messagesStored; + } + +} diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index aa73cfcff..e6b9d663f 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2016 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2013 - 2016 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. @@ -18,6 +18,8 @@ package org.traccar.model; import com.fasterxml.jackson.annotation.JsonIgnore; import org.traccar.helper.Hashing; +import java.util.Date; + public class User extends Extensible { private String name; @@ -130,14 +132,76 @@ public class User extends Extensible { this.twelveHourFormat = twelveHourFormat; } - private String password; + private String coordinateFormat; + + public String getCoordinateFormat() { + return coordinateFormat; + } + + public void setCoordinateFormat(String coordinateFormat) { + this.coordinateFormat = coordinateFormat; + } + + private boolean disabled; + + public boolean getDisabled() { + return disabled; + } + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + private Date expirationTime; + + public Date getExpirationTime() { + if (expirationTime != null) { + return new Date(expirationTime.getTime()); + } else { + return null; + } + } + + public void setExpirationTime(Date expirationTime) { + if (expirationTime != null) { + this.expirationTime = new Date(expirationTime.getTime()); + } else { + this.expirationTime = null; + } + } + + private int deviceLimit; + + public int getDeviceLimit() { + return deviceLimit; + } + + public void setDeviceLimit(int deviceLimit) { + this.deviceLimit = deviceLimit; + } + + private String token; + + public String getToken() { + return token; + } + + public void setToken(String token) { + if (token != null && !token.isEmpty()) { + if (!token.matches("^[a-zA-Z0-9]{16,}$")) { + throw new IllegalArgumentException("Illegal token"); + } + this.token = token; + } else { + this.token = null; + } + } public String getPassword() { - return password; + return null; } public void setPassword(String password) { - this.password = password; if (password != null && !password.isEmpty()) { Hashing.HashingResult hashingResult = Hashing.createHash(password); hashedPassword = hashingResult.getHash(); |