aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model/Data.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/model/Data.java')
-rw-r--r--src/org/traccar/model/Data.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/org/traccar/model/Data.java b/src/org/traccar/model/Data.java
index e329e6c1e..c88c31417 100644
--- a/src/org/traccar/model/Data.java
+++ b/src/org/traccar/model/Data.java
@@ -18,6 +18,8 @@ package org.traccar.model;
import java.sql.ResultSet;
import java.text.ParseException;
import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.Map;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
@@ -30,6 +32,10 @@ public class Data implements Convertable {
public long getId() { return id; }
public void setId(long id) { this.id = id; }
+ private String protocol;
+ public String getProtocol() { return protocol; }
+ public void setProtocol(String protocol) { this.protocol = protocol; }
+
private long deviceId;
public long getDeviceId() { return deviceId; }
public void setDeviceId(long deviceId) { this.deviceId = deviceId; }
@@ -42,14 +48,21 @@ public class Data implements Convertable {
public Date getDeviceTime() { return deviceTime; }
public void setDeviceTime(Date deviceTime) { this.deviceTime = deviceTime; }
- private String extendedInfo;
- public String getExtendedInfo() { return extendedInfo; }
- public void setExtendedInfo(String extendedInfo) { this.extendedInfo = extendedInfo; }
+ private final Map<String, Object> other = new LinkedHashMap<String, Object>();
+ public void set(String key, Object value) {
+ if (value != null && (!(value instanceof String) || !((String) value).isEmpty())) {
+ other.put(key, value);
+ }
+ }
+ public String getOther() {
+ return MiscFormatter.toXmlString(other);
+ }
@Override
public JsonObject toJson() {
JsonObjectBuilder json = Json.createObjectBuilder();
json.add("id", id);
+ json.add("protocol", protocol);
json.add("deviceId", deviceId);
json.add("serverTime", ObjectConverter.dateFormat.format(serverTime));
json.add("deviceTime", ObjectConverter.dateFormat.format(deviceTime));
@@ -60,6 +73,7 @@ public class Data implements Convertable {
@Override
public void fromJson(JsonObject json) throws ParseException {
id = json.getJsonNumber("id").longValue();
+ protocol = json.getString("protocol");
deviceId = json.getJsonNumber("deviceId").longValue();
serverTime = ObjectConverter.dateFormat.parse(json.getString("serverTime"));
deviceTime = ObjectConverter.dateFormat.parse(json.getString("deviceTime"));