aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/model/Device.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/model/Device.java')
-rw-r--r--src/main/java/org/traccar/model/Device.java140
1 files changed, 122 insertions, 18 deletions
diff --git a/src/main/java/org/traccar/model/Device.java b/src/main/java/org/traccar/model/Device.java
index 0c9be932d..b8c87921d 100644
--- a/src/main/java/org/traccar/model/Device.java
+++ b/src/main/java/org/traccar/model/Device.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2022 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,11 +17,14 @@ package org.traccar.model;
import java.util.Date;
import java.util.List;
+import java.util.stream.Collectors;
-import org.traccar.database.QueryExtended;
-import org.traccar.database.QueryIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.traccar.storage.QueryIgnore;
+import org.traccar.storage.StorageName;
-public class Device extends GroupedModel {
+@StorageName("tc_devices")
+public class Device extends GroupedModel implements Disableable {
private String name;
@@ -55,26 +58,18 @@ public class Device extends GroupedModel {
}
public void setStatus(String status) {
- this.status = status;
+ this.status = status != null ? status.trim() : null;
}
private Date lastUpdate;
- @QueryExtended
+ @QueryIgnore
public Date getLastUpdate() {
- if (lastUpdate != null) {
- return new Date(lastUpdate.getTime());
- } else {
- return null;
- }
+ return this.lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
- if (lastUpdate != null) {
- this.lastUpdate = new Date(lastUpdate.getTime());
- } else {
- this.lastUpdate = null;
- }
+ this.lastUpdate = lastUpdate;
}
private long positionId;
@@ -95,8 +90,12 @@ public class Device extends GroupedModel {
return geofenceIds;
}
- public void setGeofenceIds(List<Long> geofenceIds) {
- this.geofenceIds = geofenceIds;
+ public void setGeofenceIds(List<? extends Number> geofenceIds) {
+ if (geofenceIds != null) {
+ this.geofenceIds = geofenceIds.stream().map(Number::longValue).collect(Collectors.toList());
+ } else {
+ this.geofenceIds = null;
+ }
}
private String phone;
@@ -141,12 +140,117 @@ public class Device extends GroupedModel {
private boolean disabled;
+ @Override
public boolean getDisabled() {
return disabled;
}
+ @Override
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
+ private Date expirationTime;
+
+ @Override
+ public Date getExpirationTime() {
+ return expirationTime;
+ }
+
+ @Override
+ public void setExpirationTime(Date expirationTime) {
+ this.expirationTime = expirationTime;
+ }
+
+ private boolean motionStreak;
+
+ @QueryIgnore
+ @JsonIgnore
+ public boolean getMotionStreak() {
+ return motionStreak;
+ }
+
+ @JsonIgnore
+ public void setMotionStreak(boolean motionStreak) {
+ this.motionStreak = motionStreak;
+ }
+
+ private boolean motionState;
+
+ @QueryIgnore
+ @JsonIgnore
+ public boolean getMotionState() {
+ return motionState;
+ }
+
+ @JsonIgnore
+ public void setMotionState(boolean motionState) {
+ this.motionState = motionState;
+ }
+
+ private Date motionTime;
+
+ @QueryIgnore
+ @JsonIgnore
+ public Date getMotionTime() {
+ return motionTime;
+ }
+
+ @JsonIgnore
+ public void setMotionTime(Date motionTime) {
+ this.motionTime = motionTime;
+ }
+
+ private double motionDistance;
+
+ @QueryIgnore
+ @JsonIgnore
+ public double getMotionDistance() {
+ return motionDistance;
+ }
+
+ @JsonIgnore
+ public void setMotionDistance(double motionDistance) {
+ this.motionDistance = motionDistance;
+ }
+
+ private boolean overspeedState;
+
+ @QueryIgnore
+ @JsonIgnore
+ public boolean getOverspeedState() {
+ return overspeedState;
+ }
+
+ @JsonIgnore
+ public void setOverspeedState(boolean overspeedState) {
+ this.overspeedState = overspeedState;
+ }
+
+ private Date overspeedTime;
+
+ @QueryIgnore
+ @JsonIgnore
+ public Date getOverspeedTime() {
+ return overspeedTime;
+ }
+
+ @JsonIgnore
+ public void setOverspeedTime(Date overspeedTime) {
+ this.overspeedTime = overspeedTime;
+ }
+
+ private long overspeedGeofenceId;
+
+ @QueryIgnore
+ @JsonIgnore
+ public long getOverspeedGeofenceId() {
+ return overspeedGeofenceId;
+ }
+
+ @JsonIgnore
+ public void setOverspeedGeofenceId(long overspeedGeofenceId) {
+ this.overspeedGeofenceId = overspeedGeofenceId;
+ }
+
}