aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r--src/org/traccar/model/Device.java9
-rw-r--r--src/org/traccar/model/Event.java20
-rw-r--r--src/org/traccar/model/Extensible.java56
-rw-r--r--src/org/traccar/model/Geofence.java67
-rw-r--r--src/org/traccar/model/GeofencePermission.java25
-rw-r--r--src/org/traccar/model/GroupGeofence.java25
-rw-r--r--src/org/traccar/model/Message.java43
-rw-r--r--src/org/traccar/model/Position.java10
-rw-r--r--src/org/traccar/model/UserDeviceGeofence.java35
9 files changed, 228 insertions, 62 deletions
diff --git a/src/org/traccar/model/Device.java b/src/org/traccar/model/Device.java
index d32f9f851..45c3d46dc 100644
--- a/src/org/traccar/model/Device.java
+++ b/src/org/traccar/model/Device.java
@@ -114,4 +114,13 @@ public class Device {
this.motion = motion;
}
+ private long geofenceId;
+
+ public long getGeofenceId() {
+ return geofenceId;
+ }
+
+ public void setGeofenceId(long geofenceId) {
+ this.geofenceId = geofenceId;
+ }
}
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java
index 6de885c70..863acd621 100644
--- a/src/org/traccar/model/Event.java
+++ b/src/org/traccar/model/Event.java
@@ -20,16 +20,6 @@ public class Event extends Message {
public Event() {
}
- private long id;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
public static final String TYPE_COMMAND_RESULT = "commandResult";
public static final String TYPE_DEVICE_ONLINE = "deviceOnline";
@@ -71,4 +61,14 @@ public class Event extends Message {
this.positionId = positionId;
}
+ private long geofenceId = 0;
+
+ public long getGeofenceId() {
+ return geofenceId;
+ }
+
+ public void setGeofenceId(long geofenceId) {
+ this.geofenceId = geofenceId;
+ }
+
}
diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/Extensible.java
new file mode 100644
index 000000000..b4052dbda
--- /dev/null
+++ b/src/org/traccar/model/Extensible.java
@@ -0,0 +1,56 @@
+package org.traccar.model;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class Extensible {
+
+ private long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ private Map<String, Object> attributes = new LinkedHashMap<>();
+
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Map<String, Object> attributes) {
+ this.attributes = attributes;
+ }
+
+ public void set(String key, boolean value) {
+ attributes.put(key, value);
+ }
+
+ public void set(String key, int value) {
+ attributes.put(key, value);
+ }
+
+ public void set(String key, long value) {
+ attributes.put(key, value);
+ }
+
+ public void set(String key, double value) {
+ attributes.put(key, value);
+ }
+
+ public void set(String key, String value) {
+ if (value != null && !value.isEmpty()) {
+ attributes.put(key, value);
+ }
+ }
+
+ public void add(Map.Entry<String, Object> entry) {
+ if (entry != null && entry.getValue() != null) {
+ attributes.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+}
diff --git a/src/org/traccar/model/Geofence.java b/src/org/traccar/model/Geofence.java
new file mode 100644
index 000000000..0723c21e0
--- /dev/null
+++ b/src/org/traccar/model/Geofence.java
@@ -0,0 +1,67 @@
+package org.traccar.model;
+
+import java.text.ParseException;
+
+import org.traccar.geofence.GeofenceCircle;
+import org.traccar.geofence.GeofenceGeometry;
+import org.traccar.geofence.GeofencePolygon;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class Geofence extends Extensible {
+
+ public static final String TYPE_GEOFENCE_CILCLE = "geofenceCircle";
+ public static final String TYPE_GEOFENCE_POLYGON = "geofencePolygon";
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ private String area;
+
+ public String getArea() {
+ return area;
+ }
+
+ public void setArea(String area) throws ParseException {
+
+ if (area.startsWith("CIRCLE")) {
+ geometry = new GeofenceCircle(area);
+ } else if (area.startsWith("POLYGON")) {
+ geometry = new GeofencePolygon(area);
+ } else {
+ throw new ParseException("Unknown geometry type", 0);
+ }
+
+ this.area = area;
+ }
+
+ private GeofenceGeometry geometry;
+
+ @JsonIgnore
+ public GeofenceGeometry getGeometry() {
+ return geometry;
+ }
+
+ public void setGeometry(GeofenceGeometry geometry) {
+ area = geometry.toWKT();
+ this.geometry = geometry;
+ }
+
+}
diff --git a/src/org/traccar/model/GeofencePermission.java b/src/org/traccar/model/GeofencePermission.java
new file mode 100644
index 000000000..38fe7b6c1
--- /dev/null
+++ b/src/org/traccar/model/GeofencePermission.java
@@ -0,0 +1,25 @@
+package org.traccar.model;
+
+public class GeofencePermission {
+
+ private long userId;
+
+ public long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(long userId) {
+ this.userId = userId;
+ }
+
+ private long geofenceId;
+
+ public long getGeofenceId() {
+ return geofenceId;
+ }
+
+ public void setGeofenceId(long geofenceId) {
+ this.geofenceId = geofenceId;
+ }
+
+}
diff --git a/src/org/traccar/model/GroupGeofence.java b/src/org/traccar/model/GroupGeofence.java
new file mode 100644
index 000000000..a8f6bd475
--- /dev/null
+++ b/src/org/traccar/model/GroupGeofence.java
@@ -0,0 +1,25 @@
+package org.traccar.model;
+
+public class GroupGeofence {
+
+ private long groupId;
+
+ public long getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(long groupId) {
+ this.groupId = groupId;
+ }
+
+ private long geofenceId;
+
+ public long getGeofenceId() {
+ return geofenceId;
+ }
+
+ public void setGeofenceId(long geofenceId) {
+ this.geofenceId = geofenceId;
+ }
+
+}
diff --git a/src/org/traccar/model/Message.java b/src/org/traccar/model/Message.java
index 8722acc16..5015b9339 100644
--- a/src/org/traccar/model/Message.java
+++ b/src/org/traccar/model/Message.java
@@ -15,10 +15,7 @@
*/
package org.traccar.model;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-public class Message {
+public class Message extends Extensible {
private long deviceId;
@@ -40,42 +37,4 @@ public class Message {
this.type = type;
}
- private Map<String, Object> attributes = new LinkedHashMap<>();
-
- public Map<String, Object> getAttributes() {
- return attributes;
- }
-
- public void setAttributes(Map<String, Object> attributes) {
- this.attributes = attributes;
- }
-
- public void set(String key, boolean value) {
- attributes.put(key, value);
- }
-
- public void set(String key, int value) {
- attributes.put(key, value);
- }
-
- public void set(String key, long value) {
- attributes.put(key, value);
- }
-
- public void set(String key, double value) {
- attributes.put(key, value);
- }
-
- public void set(String key, String value) {
- if (value != null && !value.isEmpty()) {
- attributes.put(key, value);
- }
- }
-
- public void add(Map.Entry<String, Object> entry) {
- if (entry != null && entry.getValue() != null) {
- attributes.put(entry.getKey(), entry.getValue());
- }
- }
-
}
diff --git a/src/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 22d1be846..b4079dae6 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -66,16 +66,6 @@ public class Position extends Message {
public static final String PREFIX_IO = "io";
public static final String PREFIX_COUNT = "count";
- private long id;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
private String protocol;
public String getProtocol() {
diff --git a/src/org/traccar/model/UserDeviceGeofence.java b/src/org/traccar/model/UserDeviceGeofence.java
new file mode 100644
index 000000000..c84aa46b8
--- /dev/null
+++ b/src/org/traccar/model/UserDeviceGeofence.java
@@ -0,0 +1,35 @@
+package org.traccar.model;
+
+public class UserDeviceGeofence {
+
+ private long userId;
+
+ public long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(long userId) {
+ this.userId = userId;
+ }
+
+ private long deviceId;
+
+ public long getDeviceId() {
+ return deviceId;
+ }
+
+ public void setDeviceId(long deviceId) {
+ this.deviceId = deviceId;
+ }
+
+ private long geofenceId;
+
+ public long getGeofenceId() {
+ return geofenceId;
+ }
+
+ public void setGeofenceId(long geofenceId) {
+ this.geofenceId = geofenceId;
+ }
+
+}