aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/model
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-03-31 22:35:39 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-03-31 22:35:39 -0700
commit59416923dcb3a756eaf532cc4259f2f6625c0762 (patch)
tree9082dae6616deac8fda432b7bfd80e4a52b6d9dc /src/main/java/org/traccar/model
parent79a129dd6327d932133d6b9a50190d3f4927bff9 (diff)
downloadtrackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.tar.gz
trackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.tar.bz2
trackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.zip
Convert project to gradle
Diffstat (limited to 'src/main/java/org/traccar/model')
-rw-r--r--src/main/java/org/traccar/model/Attribute.java61
-rw-r--r--src/main/java/org/traccar/model/BaseModel.java31
-rw-r--r--src/main/java/org/traccar/model/Calendar.java82
-rw-r--r--src/main/java/org/traccar/model/CellTower.java115
-rw-r--r--src/main/java/org/traccar/model/Command.java113
-rw-r--r--src/main/java/org/traccar/model/Device.java152
-rw-r--r--src/main/java/org/traccar/model/DeviceAccumulators.java51
-rw-r--r--src/main/java/org/traccar/model/DeviceState.java71
-rw-r--r--src/main/java/org/traccar/model/Driver.java40
-rw-r--r--src/main/java/org/traccar/model/Event.java104
-rw-r--r--src/main/java/org/traccar/model/ExtendedModel.java127
-rw-r--r--src/main/java/org/traccar/model/Geofence.java92
-rw-r--r--src/main/java/org/traccar/model/Group.java30
-rw-r--r--src/main/java/org/traccar/model/GroupedModel.java31
-rw-r--r--src/main/java/org/traccar/model/Maintenance.java61
-rw-r--r--src/main/java/org/traccar/model/ManagedUser.java21
-rw-r--r--src/main/java/org/traccar/model/Message.java40
-rw-r--r--src/main/java/org/traccar/model/MiscFormatter.java56
-rw-r--r--src/main/java/org/traccar/model/Network.java117
-rw-r--r--src/main/java/org/traccar/model/Notification.java72
-rw-r--r--src/main/java/org/traccar/model/Permission.java57
-rw-r--r--src/main/java/org/traccar/model/Position.java302
-rw-r--r--src/main/java/org/traccar/model/ScheduledModel.java30
-rw-r--r--src/main/java/org/traccar/model/Server.java169
-rw-r--r--src/main/java/org/traccar/model/Statistics.java122
-rw-r--r--src/main/java/org/traccar/model/Typed.java33
-rw-r--r--src/main/java/org/traccar/model/User.java276
-rw-r--r--src/main/java/org/traccar/model/WifiAccessPoint.java66
28 files changed, 2522 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/model/Attribute.java b/src/main/java/org/traccar/model/Attribute.java
new file mode 100644
index 000000000..45d40b3ec
--- /dev/null
+++ b/src/main/java/org/traccar/model/Attribute.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 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 Attribute extends BaseModel {
+
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ private String attribute;
+
+ public String getAttribute() {
+ return attribute;
+ }
+
+ public void setAttribute(String attribute) {
+ this.attribute = attribute;
+ }
+
+ private String expression;
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/BaseModel.java b/src/main/java/org/traccar/model/BaseModel.java
new file mode 100644
index 000000000..8bdb916e8
--- /dev/null
+++ b/src/main/java/org/traccar/model/BaseModel.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 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 BaseModel {
+
+ private long id;
+
+ public final long getId() {
+ return id;
+ }
+
+ public final void setId(long id) {
+ this.id = id;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Calendar.java b/src/main/java/org/traccar/model/Calendar.java
new file mode 100644
index 000000000..56d3eb74c
--- /dev/null
+++ b/src/main/java/org/traccar/model/Calendar.java
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Date;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import net.fortuna.ical4j.data.CalendarBuilder;
+import net.fortuna.ical4j.data.ParserException;
+import net.fortuna.ical4j.filter.Filter;
+import net.fortuna.ical4j.filter.PeriodRule;
+import net.fortuna.ical4j.model.DateTime;
+import net.fortuna.ical4j.model.Dur;
+import net.fortuna.ical4j.model.Period;
+import net.fortuna.ical4j.model.component.CalendarComponent;
+import org.apache.commons.collections4.Predicate;
+import org.traccar.database.QueryIgnore;
+
+public class Calendar extends ExtendedModel {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private byte[] data;
+
+ public byte[] getData() {
+ return data.clone();
+ }
+
+ public void setData(byte[] data) throws IOException, ParserException {
+ CalendarBuilder builder = new CalendarBuilder();
+ calendar = builder.build(new ByteArrayInputStream(data));
+ this.data = data.clone();
+ }
+
+ private net.fortuna.ical4j.model.Calendar calendar;
+
+ @QueryIgnore
+ @JsonIgnore
+ public net.fortuna.ical4j.model.Calendar getCalendar() {
+ return calendar;
+ }
+
+ public boolean checkMoment(Date date) {
+ if (calendar != null) {
+ Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0));
+ Predicate<CalendarComponent> periodRule = new PeriodRule<>(period);
+ Filter<CalendarComponent> filter = new Filter<>(new Predicate[] {periodRule}, Filter.MATCH_ANY);
+ Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT));
+ if (events != null && !events.isEmpty()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/CellTower.java b/src/main/java/org/traccar/model/CellTower.java
new file mode 100644
index 000000000..6d1dfbd7f
--- /dev/null
+++ b/src/main/java/org/traccar/model/CellTower.java
@@ -0,0 +1,115 @@
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonInclude;
+import org.traccar.Context;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class CellTower {
+
+ public static CellTower from(int mcc, int mnc, int lac, long cid) {
+ CellTower cellTower = new CellTower();
+ cellTower.setMobileCountryCode(mcc);
+ cellTower.setMobileNetworkCode(mnc);
+ cellTower.setLocationAreaCode(lac);
+ cellTower.setCellId(cid);
+ return cellTower;
+ }
+
+ public static CellTower from(int mcc, int mnc, int lac, long cid, int rssi) {
+ CellTower cellTower = CellTower.from(mcc, mnc, lac, cid);
+ cellTower.setSignalStrength(rssi);
+ return cellTower;
+ }
+
+ public static CellTower fromLacCid(int lac, long cid) {
+ return from(
+ Context.getConfig().getInteger("geolocation.mcc"),
+ Context.getConfig().getInteger("geolocation.mnc"), lac, cid);
+ }
+
+ public static CellTower fromCidLac(long cid, int lac) {
+ return fromLacCid(lac, cid);
+ }
+
+ private String radioType;
+
+ public String getRadioType() {
+ return radioType;
+ }
+
+ public void setRadioType(String radioType) {
+ this.radioType = radioType;
+ }
+
+ private Long cellId;
+
+ public Long getCellId() {
+ return cellId;
+ }
+
+ public void setCellId(Long cellId) {
+ this.cellId = cellId;
+ }
+
+ private Integer locationAreaCode;
+
+ public Integer getLocationAreaCode() {
+ return locationAreaCode;
+ }
+
+ public void setLocationAreaCode(Integer locationAreaCode) {
+ this.locationAreaCode = locationAreaCode;
+ }
+
+ private Integer mobileCountryCode;
+
+ public Integer getMobileCountryCode() {
+ return mobileCountryCode;
+ }
+
+ public void setMobileCountryCode(Integer mobileCountryCode) {
+ this.mobileCountryCode = mobileCountryCode;
+ }
+
+ private Integer mobileNetworkCode;
+
+ public Integer getMobileNetworkCode() {
+ return mobileNetworkCode;
+ }
+
+ public void setMobileNetworkCode(Integer mobileNetworkCode) {
+ this.mobileNetworkCode = mobileNetworkCode;
+ }
+
+ private Integer signalStrength;
+
+ public Integer getSignalStrength() {
+ return signalStrength;
+ }
+
+ public void setSignalStrength(Integer signalStrength) {
+ this.signalStrength = signalStrength;
+ }
+
+ public void setOperator(long operator) {
+ String operatorString = String.valueOf(operator);
+ mobileCountryCode = Integer.parseInt(operatorString.substring(0, 3));
+ mobileNetworkCode = Integer.parseInt(operatorString.substring(3));
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Command.java b/src/main/java/org/traccar/model/Command.java
new file mode 100644
index 000000000..336fc61f4
--- /dev/null
+++ b/src/main/java/org/traccar/model/Command.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2015 - 2017 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 org.traccar.database.QueryIgnore;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Command extends Message implements Cloneable {
+
+ public static final String TYPE_CUSTOM = "custom";
+ public static final String TYPE_IDENTIFICATION = "deviceIdentification";
+ public static final String TYPE_POSITION_SINGLE = "positionSingle";
+ public static final String TYPE_POSITION_PERIODIC = "positionPeriodic";
+ public static final String TYPE_POSITION_STOP = "positionStop";
+ public static final String TYPE_ENGINE_STOP = "engineStop";
+ public static final String TYPE_ENGINE_RESUME = "engineResume";
+ public static final String TYPE_ALARM_ARM = "alarmArm";
+ public static final String TYPE_ALARM_DISARM = "alarmDisarm";
+ public static final String TYPE_SET_TIMEZONE = "setTimezone";
+ public static final String TYPE_REQUEST_PHOTO = "requestPhoto";
+ public static final String TYPE_POWER_OFF = "powerOff";
+ public static final String TYPE_REBOOT_DEVICE = "rebootDevice";
+ public static final String TYPE_SEND_SMS = "sendSms";
+ public static final String TYPE_SEND_USSD = "sendUssd";
+ public static final String TYPE_SOS_NUMBER = "sosNumber";
+ public static final String TYPE_SILENCE_TIME = "silenceTime";
+ public static final String TYPE_SET_PHONEBOOK = "setPhonebook";
+ public static final String TYPE_MESSAGE = "message";
+ public static final String TYPE_VOICE_MESSAGE = "voiceMessage";
+ public static final String TYPE_OUTPUT_CONTROL = "outputControl";
+ public static final String TYPE_VOICE_MONITORING = "voiceMonitoring";
+ public static final String TYPE_SET_AGPS = "setAgps";
+ public static final String TYPE_SET_INDICATOR = "setIndicator";
+ public static final String TYPE_CONFIGURATION = "configuration";
+ public static final String TYPE_GET_VERSION = "getVersion";
+ public static final String TYPE_FIRMWARE_UPDATE = "firmwareUpdate";
+ public static final String TYPE_SET_CONNECTION = "setConnection";
+ public static final String TYPE_SET_ODOMETER = "setOdometer";
+ public static final String TYPE_GET_MODEM_STATUS = "getModemStatus";
+ public static final String TYPE_GET_DEVICE_STATUS = "getDeviceStatus";
+
+ public static final String TYPE_MODE_POWER_SAVING = "modePowerSaving";
+ public static final String TYPE_MODE_DEEP_SLEEP = "modeDeepSleep";
+
+ public static final String TYPE_ALARM_GEOFENCE = "movementAlarm";
+ public static final String TYPE_ALARM_BATTERY = "alarmBattery";
+ public static final String TYPE_ALARM_SOS = "alarmSos";
+ public static final String TYPE_ALARM_REMOVE = "alarmRemove";
+ public static final String TYPE_ALARM_CLOCK = "alarmClock";
+ public static final String TYPE_ALARM_SPEED = "alarmSpeed";
+ public static final String TYPE_ALARM_FALL = "alarmFall";
+ public static final String TYPE_ALARM_VIBRATION = "alarmVibration";
+
+ public static final String KEY_UNIQUE_ID = "uniqueId";
+ public static final String KEY_FREQUENCY = "frequency";
+ public static final String KEY_TIMEZONE = "timezone";
+ public static final String KEY_DEVICE_PASSWORD = "devicePassword";
+ public static final String KEY_RADIUS = "radius";
+ public static final String KEY_MESSAGE = "message";
+ public static final String KEY_ENABLE = "enable";
+ public static final String KEY_DATA = "data";
+ public static final String KEY_INDEX = "index";
+ public static final String KEY_PHONE = "phone";
+ public static final String KEY_SERVER = "server";
+ public static final String KEY_PORT = "port";
+
+ @Override
+ public Command clone() throws CloneNotSupportedException {
+ return (Command) super.clone();
+ }
+
+ private boolean textChannel;
+
+ public boolean getTextChannel() {
+ return textChannel;
+ }
+
+ public void setTextChannel(boolean textChannel) {
+ this.textChannel = textChannel;
+ }
+
+ @QueryIgnore
+ @Override
+ public long getDeviceId() {
+ return super.getDeviceId();
+ }
+
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Device.java b/src/main/java/org/traccar/model/Device.java
new file mode 100644
index 000000000..0c9be932d
--- /dev/null
+++ b/src/main/java/org/traccar/model/Device.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2012 - 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.
+ * 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;
+import java.util.List;
+
+import org.traccar.database.QueryExtended;
+import org.traccar.database.QueryIgnore;
+
+public class Device extends GroupedModel {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private String uniqueId;
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+
+ public static final String STATUS_UNKNOWN = "unknown";
+ public static final String STATUS_ONLINE = "online";
+ public static final String STATUS_OFFLINE = "offline";
+
+ private String status;
+
+ @QueryIgnore
+ public String getStatus() {
+ return status != null ? status : STATUS_OFFLINE;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ private Date lastUpdate;
+
+ @QueryExtended
+ public Date getLastUpdate() {
+ if (lastUpdate != null) {
+ return new Date(lastUpdate.getTime());
+ } else {
+ return null;
+ }
+ }
+
+ public void setLastUpdate(Date lastUpdate) {
+ if (lastUpdate != null) {
+ this.lastUpdate = new Date(lastUpdate.getTime());
+ } else {
+ this.lastUpdate = null;
+ }
+ }
+
+ private long positionId;
+
+ @QueryIgnore
+ public long getPositionId() {
+ return positionId;
+ }
+
+ public void setPositionId(long positionId) {
+ this.positionId = positionId;
+ }
+
+ private List<Long> geofenceIds;
+
+ @QueryIgnore
+ public List<Long> getGeofenceIds() {
+ return geofenceIds;
+ }
+
+ 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;
+ }
+
+ private boolean disabled;
+
+ public boolean getDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/DeviceAccumulators.java b/src/main/java/org/traccar/model/DeviceAccumulators.java
new file mode 100644
index 000000000..8a90826c4
--- /dev/null
+++ b/src/main/java/org/traccar/model/DeviceAccumulators.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 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 DeviceAccumulators {
+
+ 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;
+ }
+
+ private Long hours;
+
+ public Long getHours() {
+ return hours;
+ }
+
+ public void setHours(Long hours) {
+ this.hours = hours;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/DeviceState.java b/src/main/java/org/traccar/model/DeviceState.java
new file mode 100644
index 000000000..75d6726ee
--- /dev/null
+++ b/src/main/java/org/traccar/model/DeviceState.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 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 DeviceState {
+
+ private Boolean motionState;
+
+ public void setMotionState(boolean motionState) {
+ this.motionState = motionState;
+ }
+
+ public Boolean getMotionState() {
+ return motionState;
+ }
+
+ private Position motionPosition;
+
+ public void setMotionPosition(Position motionPosition) {
+ this.motionPosition = motionPosition;
+ }
+
+ public Position getMotionPosition() {
+ return motionPosition;
+ }
+
+ private Boolean overspeedState;
+
+ public void setOverspeedState(boolean overspeedState) {
+ this.overspeedState = overspeedState;
+ }
+
+ public Boolean getOverspeedState() {
+ return overspeedState;
+ }
+
+ private Position overspeedPosition;
+
+ public void setOverspeedPosition(Position overspeedPosition) {
+ this.overspeedPosition = overspeedPosition;
+ }
+
+ public Position getOverspeedPosition() {
+ return overspeedPosition;
+ }
+
+ private long overspeedGeofenceId;
+
+ public void setOverspeedGeofenceId(long overspeedGeofenceId) {
+ this.overspeedGeofenceId = overspeedGeofenceId;
+ }
+
+ public long getOverspeedGeofenceId() {
+ return overspeedGeofenceId;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Driver.java b/src/main/java/org/traccar/model/Driver.java
new file mode 100644
index 000000000..05f52fd4d
--- /dev/null
+++ b/src/main/java/org/traccar/model/Driver.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 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 Driver extends ExtendedModel {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private String uniqueId;
+
+ public String getUniqueId() {
+ return uniqueId;
+ }
+
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
+ }
+}
diff --git a/src/main/java/org/traccar/model/Event.java b/src/main/java/org/traccar/model/Event.java
new file mode 100644
index 000000000..ee7fcc679
--- /dev/null
+++ b/src/main/java/org/traccar/model/Event.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2016 - 2017 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 Event extends Message {
+
+ public Event(String type, long deviceId, long positionId) {
+ this(type, deviceId);
+ setPositionId(positionId);
+ }
+
+ public Event(String type, long deviceId) {
+ setType(type);
+ setDeviceId(deviceId);
+ this.serverTime = new Date();
+ }
+
+ 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";
+ public static final String TYPE_DEVICE_STOPPED = "deviceStopped";
+
+ public static final String TYPE_DEVICE_OVERSPEED = "deviceOverspeed";
+ public static final String TYPE_DEVICE_FUEL_DROP = "deviceFuelDrop";
+
+ public static final String TYPE_GEOFENCE_ENTER = "geofenceEnter";
+ public static final String TYPE_GEOFENCE_EXIT = "geofenceExit";
+
+ public static final String TYPE_ALARM = "alarm";
+
+ public static final String TYPE_IGNITION_ON = "ignitionOn";
+ public static final String TYPE_IGNITION_OFF = "ignitionOff";
+
+ public static final String TYPE_MAINTENANCE = "maintenance";
+
+ public static final String TYPE_TEXT_MESSAGE = "textMessage";
+
+ public static final String TYPE_DRIVER_CHANGED = "driverChanged";
+
+ private Date serverTime;
+
+ public Date getServerTime() {
+ return serverTime;
+ }
+
+ public void setServerTime(Date serverTime) {
+ this.serverTime = serverTime;
+ }
+
+ private long positionId;
+
+ public long getPositionId() {
+ return positionId;
+ }
+
+ public void setPositionId(long positionId) {
+ this.positionId = positionId;
+ }
+
+ private long geofenceId = 0;
+
+ public long getGeofenceId() {
+ return geofenceId;
+ }
+
+ public void setGeofenceId(long geofenceId) {
+ this.geofenceId = geofenceId;
+ }
+
+ private long maintenanceId = 0;
+
+ public long getMaintenanceId() {
+ return maintenanceId;
+ }
+
+ public void setMaintenanceId(long maintenanceId) {
+ this.maintenanceId = maintenanceId;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/ExtendedModel.java b/src/main/java/org/traccar/model/ExtendedModel.java
new file mode 100644
index 000000000..8353d0e66
--- /dev/null
+++ b/src/main/java/org/traccar/model/ExtendedModel.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016 - 2017 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.LinkedHashMap;
+import java.util.Map;
+
+public class ExtendedModel extends BaseModel {
+
+ 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) {
+ if (value != null) {
+ attributes.put(key, value);
+ }
+ }
+
+ public void set(String key, Byte value) {
+ if (value != null) {
+ attributes.put(key, value.intValue());
+ }
+ }
+
+ public void set(String key, Short value) {
+ if (value != null) {
+ attributes.put(key, value.intValue());
+ }
+ }
+
+ public void set(String key, Integer value) {
+ if (value != null) {
+ attributes.put(key, value);
+ }
+ }
+
+ public void set(String key, Long value) {
+ if (value != null) {
+ attributes.put(key, value);
+ }
+ }
+
+ public void set(String key, Float value) {
+ if (value != null) {
+ attributes.put(key, value.doubleValue());
+ }
+ }
+
+ public void set(String key, Double value) {
+ if (value != null) {
+ 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());
+ }
+ }
+
+ 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) attributes.get(key);
+ } 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/main/java/org/traccar/model/Geofence.java b/src/main/java/org/traccar/model/Geofence.java
new file mode 100644
index 000000000..8560d22e9
--- /dev/null
+++ b/src/main/java/org/traccar/model/Geofence.java
@@ -0,0 +1,92 @@
+/*
+ * 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.text.ParseException;
+
+import org.traccar.Context;
+import org.traccar.database.QueryIgnore;
+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;
+
+public class Geofence extends ScheduledModel {
+
+ 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;
+
+ 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 if (area.startsWith("LINESTRING")) {
+ final double distance = getDouble("polylineDistance");
+ geometry = new GeofencePolyline(area, distance > 0 ? distance
+ : Context.getConfig().getDouble("geofence.polylineDistance", 25));
+ } else {
+ throw new ParseException("Unknown geometry type", 0);
+ }
+
+ this.area = area;
+ }
+
+ private GeofenceGeometry geometry;
+
+ @QueryIgnore
+ @JsonIgnore
+ public GeofenceGeometry getGeometry() {
+ return geometry;
+ }
+
+ @QueryIgnore
+ @JsonIgnore
+ public void setGeometry(GeofenceGeometry geometry) {
+ area = geometry.toWkt();
+ this.geometry = geometry;
+ }
+}
diff --git a/src/main/java/org/traccar/model/Group.java b/src/main/java/org/traccar/model/Group.java
new file mode 100644
index 000000000..91ea2319d
--- /dev/null
+++ b/src/main/java/org/traccar/model/Group.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2016 - 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.
+ * 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 Group extends GroupedModel {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/GroupedModel.java b/src/main/java/org/traccar/model/GroupedModel.java
new file mode 100644
index 000000000..6b1aa75b1
--- /dev/null
+++ b/src/main/java/org/traccar/model/GroupedModel.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 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 GroupedModel extends ExtendedModel {
+
+ private long groupId;
+
+ public long getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(long groupId) {
+ this.groupId = groupId;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Maintenance.java b/src/main/java/org/traccar/model/Maintenance.java
new file mode 100644
index 000000000..73f67ea96
--- /dev/null
+++ b/src/main/java/org/traccar/model/Maintenance.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 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 Maintenance extends ExtendedModel {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ private double start;
+
+ public double getStart() {
+ return start;
+ }
+
+ public void setStart(double start) {
+ this.start = start;
+ }
+
+ private double period;
+
+ public double getPeriod() {
+ return period;
+ }
+
+ public void setPeriod(double period) {
+ this.period = period;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/ManagedUser.java b/src/main/java/org/traccar/model/ManagedUser.java
new file mode 100644
index 000000000..03c5ef48d
--- /dev/null
+++ b/src/main/java/org/traccar/model/ManagedUser.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 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 ManagedUser extends User {
+
+}
diff --git a/src/main/java/org/traccar/model/Message.java b/src/main/java/org/traccar/model/Message.java
new file mode 100644
index 000000000..dad9c20f0
--- /dev/null
+++ b/src/main/java/org/traccar/model/Message.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ * 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 Message extends ExtendedModel {
+
+ private long deviceId;
+
+ public long getDeviceId() {
+ return deviceId;
+ }
+
+ public void setDeviceId(long deviceId) {
+ this.deviceId = deviceId;
+ }
+
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/MiscFormatter.java b/src/main/java/org/traccar/model/MiscFormatter.java
new file mode 100644
index 000000000..c6511f063
--- /dev/null
+++ b/src/main/java/org/traccar/model/MiscFormatter.java
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ * 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.text.DecimalFormat;
+import java.util.Map;
+
+public final class MiscFormatter {
+
+ private MiscFormatter() {
+ }
+
+ private static final String XML_ROOT_NODE = "info";
+
+ private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
+
+ private static String format(Object value) {
+ if (value instanceof Double || value instanceof Float) {
+ return DECIMAL_FORMAT.format(value);
+ } else {
+ return value.toString();
+ }
+ }
+
+ public static String toXmlString(Map<String, Object> attributes) {
+ StringBuilder result = new StringBuilder();
+
+ result.append("<").append(XML_ROOT_NODE).append(">");
+
+ for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+
+ result.append("<").append(entry.getKey()).append(">");
+ result.append(format(entry.getValue()));
+ result.append("</").append(entry.getKey()).append(">");
+ }
+
+ result.append("</").append(XML_ROOT_NODE).append(">");
+
+ return result.toString();
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Network.java b/src/main/java/org/traccar/model/Network.java
new file mode 100644
index 000000000..2d56950f1
--- /dev/null
+++ b/src/main/java/org/traccar/model/Network.java
@@ -0,0 +1,117 @@
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonInclude;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class Network {
+
+ public Network() {
+ }
+
+ public Network(CellTower cellTower) {
+ addCellTower(cellTower);
+ }
+
+ private Integer homeMobileCountryCode;
+
+ public Integer getHomeMobileCountryCode() {
+ return homeMobileCountryCode;
+ }
+
+ public void setHomeMobileCountryCode(Integer homeMobileCountryCode) {
+ this.homeMobileCountryCode = homeMobileCountryCode;
+ }
+
+ private Integer homeMobileNetworkCode;
+
+ public Integer getHomeMobileNetworkCode() {
+ return homeMobileNetworkCode;
+ }
+
+ public void setHomeMobileNetworkCode(Integer homeMobileNetworkCode) {
+ this.homeMobileNetworkCode = homeMobileNetworkCode;
+ }
+
+ private String radioType = "gsm";
+
+ public String getRadioType() {
+ return radioType;
+ }
+
+ public void setRadioType(String radioType) {
+ this.radioType = radioType;
+ }
+
+ private String carrier;
+
+ public String getCarrier() {
+ return carrier;
+ }
+
+ public void setCarrier(String carrier) {
+ this.carrier = carrier;
+ }
+
+ private Boolean considerIp = false;
+
+ public Boolean getConsiderIp() {
+ return considerIp;
+ }
+
+ public void setConsiderIp(Boolean considerIp) {
+ this.considerIp = considerIp;
+ }
+
+ private Collection<CellTower> cellTowers;
+
+ public Collection<CellTower> getCellTowers() {
+ return cellTowers;
+ }
+
+ public void setCellTowers(Collection<CellTower> cellTowers) {
+ this.cellTowers = cellTowers;
+ }
+
+ public void addCellTower(CellTower cellTower) {
+ if (cellTowers == null) {
+ cellTowers = new ArrayList<>();
+ }
+ cellTowers.add(cellTower);
+ }
+
+ private Collection<WifiAccessPoint> wifiAccessPoints;
+
+ public Collection<WifiAccessPoint> getWifiAccessPoints() {
+ return wifiAccessPoints;
+ }
+
+ public void setWifiAccessPoints(Collection<WifiAccessPoint> wifiAccessPoints) {
+ this.wifiAccessPoints = wifiAccessPoints;
+ }
+
+ public void addWifiAccessPoint(WifiAccessPoint wifiAccessPoint) {
+ if (wifiAccessPoints == null) {
+ wifiAccessPoints = new ArrayList<>();
+ }
+ wifiAccessPoints.add(wifiAccessPoint);
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Notification.java b/src/main/java/org/traccar/model/Notification.java
new file mode 100644
index 000000000..f1983a03a
--- /dev/null
+++ b/src/main/java/org/traccar/model/Notification.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2016 - 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.
+ * 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.HashSet;
+import java.util.Set;
+
+import org.traccar.database.QueryIgnore;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+public class Notification extends ScheduledModel {
+
+ private boolean always;
+
+ public boolean getAlways() {
+ return always;
+ }
+
+ public void setAlways(boolean always) {
+ this.always = always;
+ }
+
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+
+ private String notificators;
+
+ public String getNotificators() {
+ return notificators;
+ }
+
+ public void setNotificators(String transports) {
+ this.notificators = transports;
+ }
+
+
+ @JsonIgnore
+ @QueryIgnore
+ public Set<String> getNotificatorsTypes() {
+ final Set<String> result = new HashSet<>();
+ if (notificators != null) {
+ final String[] transportsList = notificators.split(",");
+ for (String transport : transportsList) {
+ result.add(transport.trim());
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Permission.java b/src/main/java/org/traccar/model/Permission.java
new file mode 100644
index 000000000..1006b1c47
--- /dev/null
+++ b/src/main/java/org/traccar/model/Permission.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 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;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.traccar.database.DataManager;
+
+public class Permission {
+
+ private Class<?> ownerClass;
+ private long ownerId;
+ private Class<?> propertyClass;
+ private long propertyId;
+
+ public Permission(LinkedHashMap<String, Long> permissionMap) throws ClassNotFoundException {
+ Iterator<Map.Entry<String, Long>> iterator = permissionMap.entrySet().iterator();
+ String owner = iterator.next().getKey();
+ ownerClass = DataManager.getClassByName(owner);
+ String property = iterator.next().getKey();
+ propertyClass = DataManager.getClassByName(property);
+ ownerId = permissionMap.get(owner);
+ propertyId = permissionMap.get(property);
+ }
+
+ public Class<?> getOwnerClass() {
+ return ownerClass;
+ }
+
+ public long getOwnerId() {
+ return ownerId;
+ }
+
+ public Class<?> getPropertyClass() {
+ return propertyClass;
+ }
+
+ public long getPropertyId() {
+ return propertyId;
+ }
+}
diff --git a/src/main/java/org/traccar/model/Position.java b/src/main/java/org/traccar/model/Position.java
new file mode 100644
index 000000000..4b327cbd2
--- /dev/null
+++ b/src/main/java/org/traccar/model/Position.java
@@ -0,0 +1,302 @@
+/*
+ * 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.
+ * 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;
+
+import org.traccar.database.QueryIgnore;
+
+public class Position extends Message {
+
+ public static final String KEY_ORIGINAL = "raw";
+ public static final String KEY_INDEX = "index";
+ public static final String KEY_HDOP = "hdop";
+ public static final String KEY_VDOP = "vdop";
+ public static final String KEY_PDOP = "pdop";
+ public static final String KEY_SATELLITES = "sat"; // in use
+ public static final String KEY_SATELLITES_VISIBLE = "satVisible";
+ public static final String KEY_RSSI = "rssi";
+ public static final String KEY_GPS = "gps";
+ public static final String KEY_ROAMING = "roaming";
+ public static final String KEY_EVENT = "event";
+ public static final String KEY_ALARM = "alarm";
+ public static final String KEY_STATUS = "status";
+ public static final String KEY_ODOMETER = "odometer"; // meters
+ public static final String KEY_ODOMETER_SERVICE = "serviceOdometer"; // meters
+ public static final String KEY_ODOMETER_TRIP = "tripOdometer"; // meters
+ public static final String KEY_HOURS = "hours";
+ public static final String KEY_STEPS = "steps";
+ public static final String KEY_HEART_RATE = "heartRate";
+ public static final String KEY_INPUT = "input";
+ public static final String KEY_OUTPUT = "output";
+ public static final String KEY_IMAGE = "image";
+ public static final String KEY_VIDEO = "video";
+ public static final String KEY_AUDIO = "audio";
+
+ // The units for the below four KEYs currently vary.
+ // The preferred units of measure are specified in the comment for each.
+ public static final String KEY_POWER = "power"; // volts
+ public static final String KEY_BATTERY = "battery"; // volts
+ public static final String KEY_BATTERY_LEVEL = "batteryLevel"; // percentage
+ public static final String KEY_FUEL_LEVEL = "fuel"; // liters
+ public static final String KEY_FUEL_USED = "fuelUsed"; // liters
+ public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour
+
+ public static final String KEY_VERSION_FW = "versionFw";
+ public static final String KEY_VERSION_HW = "versionHw";
+ public static final String KEY_TYPE = "type";
+ public static final String KEY_IGNITION = "ignition";
+ public static final String KEY_FLAGS = "flags";
+ public static final String KEY_ANTENNA = "antenna";
+ public static final String KEY_CHARGE = "charge";
+ public static final String KEY_IP = "ip";
+ public static final String KEY_ARCHIVE = "archive";
+ public static final String KEY_DISTANCE = "distance"; // meters
+ public static final String KEY_TOTAL_DISTANCE = "totalDistance"; // meters
+ public static final String KEY_RPM = "rpm";
+ public static final String KEY_VIN = "vin";
+ public static final String KEY_APPROXIMATE = "approximate";
+ public static final String KEY_THROTTLE = "throttle";
+ public static final String KEY_MOTION = "motion";
+ public static final String KEY_ARMED = "armed";
+ public static final String KEY_GEOFENCE = "geofence";
+ public static final String KEY_ACCELERATION = "acceleration";
+ public static final String KEY_DEVICE_TEMP = "deviceTemp"; // celsius
+ public static final String KEY_COOLANT_TEMP = "coolantTemp"; // celsius
+ public static final String KEY_ENGINE_LOAD = "engineLoad";
+ public static final String KEY_OPERATOR = "operator";
+ public static final String KEY_COMMAND = "command";
+ public static final String KEY_BLOCKED = "blocked";
+ public static final String KEY_DOOR = "door";
+ public static final String KEY_AXLE_WEIGHT = "axleWeight";
+
+ public static final String KEY_DTCS = "dtcs";
+ public static final String KEY_OBD_SPEED = "obdSpeed"; // knots
+ public static final String KEY_OBD_ODOMETER = "obdOdometer"; // meters
+
+ public static final String KEY_RESULT = "result";
+
+ public static final String KEY_DRIVER_UNIQUE_ID = "driverUniqueId";
+
+ // Start with 1 not 0
+ public static final String PREFIX_TEMP = "temp";
+ public static final String PREFIX_ADC = "adc";
+ public static final String PREFIX_IO = "io";
+ public static final String PREFIX_COUNT = "count";
+ public static final String PREFIX_IN = "in";
+ public static final String PREFIX_OUT = "out";
+
+ public static final String ALARM_GENERAL = "general";
+ public static final String ALARM_SOS = "sos";
+ public static final String ALARM_VIBRATION = "vibration";
+ public static final String ALARM_MOVEMENT = "movement";
+ public static final String ALARM_LOW_SPEED = "lowspeed";
+ public static final String ALARM_OVERSPEED = "overspeed";
+ public static final String ALARM_FALL_DOWN = "fallDown";
+ public static final String ALARM_LOW_POWER = "lowPower";
+ 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_LOCK = "lock";
+ public static final String ALARM_UNLOCK = "unlock";
+ public static final String ALARM_GEOFENCE = "geofence";
+ public static final String ALARM_GEOFENCE_ENTER = "geofenceEnter";
+ public static final String ALARM_GEOFENCE_EXIT = "geofenceExit";
+ public static final String ALARM_GPS_ANTENNA_CUT = "gpsAntennaCut";
+ public static final String ALARM_ACCIDENT = "accident";
+ public static final String ALARM_TOW = "tow";
+ public static final String ALARM_IDLE = "idle";
+ public static final String ALARM_HIGH_RPM = "highRpm";
+ public static final String ALARM_ACCELERATION = "hardAcceleration";
+ public static final String ALARM_BRAKING = "hardBraking";
+ public static final String ALARM_CORNERING = "hardCornering";
+ public static final String ALARM_LANE_CHANGE = "laneChange";
+ public static final String ALARM_FATIGUE_DRIVING = "fatigueDriving";
+ public static final String ALARM_POWER_CUT = "powerCut";
+ public static final String ALARM_POWER_RESTORED = "powerRestored";
+ public static final String ALARM_JAMMING = "jamming";
+ public static final String ALARM_TEMPERATURE = "temperature";
+ public static final String ALARM_PARKING = "parking";
+ public static final String ALARM_SHOCK = "shock";
+ public static final String ALARM_BONNET = "bonnet";
+ public static final String ALARM_FOOT_BRAKE = "footBrake";
+ public static final String ALARM_FUEL_LEAK = "fuelLeak";
+ public static final String ALARM_TAMPERING = "tampering";
+ public static final String ALARM_REMOVING = "removing";
+
+ public Position() {
+ }
+
+ public Position(String protocol) {
+ this.protocol = protocol;
+ this.serverTime = new Date();
+ }
+
+ private String protocol;
+
+ public String getProtocol() {
+ return protocol;
+ }
+
+ public void setProtocol(String protocol) {
+ this.protocol = protocol;
+ }
+
+ private Date serverTime;
+
+ public Date getServerTime() {
+ return serverTime;
+ }
+
+ public void setServerTime(Date serverTime) {
+ this.serverTime = serverTime;
+ }
+
+ private Date deviceTime;
+
+ public Date getDeviceTime() {
+ return deviceTime;
+ }
+
+ public void setDeviceTime(Date deviceTime) {
+ this.deviceTime = deviceTime;
+ }
+
+ private Date fixTime;
+
+ public Date getFixTime() {
+ return fixTime;
+ }
+
+ public void setFixTime(Date fixTime) {
+ this.fixTime = fixTime;
+ }
+
+ public void setTime(Date time) {
+ setDeviceTime(time);
+ setFixTime(time);
+ }
+
+ private boolean outdated;
+
+ @QueryIgnore
+ public boolean getOutdated() {
+ return outdated;
+ }
+
+ public void setOutdated(boolean outdated) {
+ this.outdated = outdated;
+ }
+
+ private boolean valid;
+
+ public boolean getValid() {
+ return valid;
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ }
+
+ private double latitude;
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ private double longitude;
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ private double altitude; // value in meters
+
+ public double getAltitude() {
+ return altitude;
+ }
+
+ public void setAltitude(double altitude) {
+ this.altitude = altitude;
+ }
+
+ private double speed; // value in knots
+
+ public double getSpeed() {
+ return speed;
+ }
+
+ public void setSpeed(double speed) {
+ this.speed = speed;
+ }
+
+ private double course;
+
+ public double getCourse() {
+ return course;
+ }
+
+ public void setCourse(double course) {
+ this.course = course;
+ }
+
+ private String address;
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ private double accuracy;
+
+ public double getAccuracy() {
+ return accuracy;
+ }
+
+ public void setAccuracy(double accuracy) {
+ this.accuracy = accuracy;
+ }
+
+ private Network network;
+
+ public Network getNetwork() {
+ return network;
+ }
+
+ public void setNetwork(Network network) {
+ this.network = network;
+ }
+
+ @Override
+ @QueryIgnore
+ public String getType() {
+ return super.getType();
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/ScheduledModel.java b/src/main/java/org/traccar/model/ScheduledModel.java
new file mode 100644
index 000000000..9e6a4b9a6
--- /dev/null
+++ b/src/main/java/org/traccar/model/ScheduledModel.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 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 ScheduledModel extends ExtendedModel {
+
+ private long calendarId;
+
+ public long getCalendarId() {
+ return calendarId;
+ }
+
+ public void setCalendarId(long calendarId) {
+ this.calendarId = calendarId;
+ }
+}
diff --git a/src/main/java/org/traccar/model/Server.java b/src/main/java/org/traccar/model/Server.java
new file mode 100644
index 000000000..ad37e7078
--- /dev/null
+++ b/src/main/java/org/traccar/model/Server.java
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2015 - 2019 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 org.traccar.database.QueryIgnore;
+
+public class Server extends ExtendedModel {
+
+ @QueryIgnore
+ public String getVersion() {
+ return getClass().getPackage().getImplementationVersion();
+ }
+
+ public void setVersion(String version) {
+ }
+
+ private boolean registration;
+
+ public boolean getRegistration() {
+ return registration;
+ }
+
+ public void setRegistration(boolean registration) {
+ this.registration = registration;
+ }
+
+ private boolean readonly;
+
+ public boolean getReadonly() {
+ return readonly;
+ }
+
+ public void setReadonly(boolean readonly) {
+ this.readonly = readonly;
+ }
+
+ private boolean deviceReadonly;
+
+ public boolean getDeviceReadonly() {
+ return deviceReadonly;
+ }
+
+ public void setDeviceReadonly(boolean deviceReadonly) {
+ this.deviceReadonly = deviceReadonly;
+ }
+
+ private String map;
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ private String bingKey;
+
+ public String getBingKey() {
+ return bingKey;
+ }
+
+ public void setBingKey(String bingKey) {
+ this.bingKey = bingKey;
+ }
+
+ private String mapUrl;
+
+ public String getMapUrl() {
+ return mapUrl;
+ }
+
+ public void setMapUrl(String mapUrl) {
+ this.mapUrl = mapUrl;
+ }
+
+ private double latitude;
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ private double longitude;
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ private int zoom;
+
+ public int getZoom() {
+ return zoom;
+ }
+
+ public void setZoom(int zoom) {
+ this.zoom = zoom;
+ }
+
+ private boolean twelveHourFormat;
+
+ public boolean getTwelveHourFormat() {
+ return twelveHourFormat;
+ }
+
+ public void setTwelveHourFormat(boolean twelveHourFormat) {
+ 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;
+ }
+
+ private boolean limitCommands;
+
+ public boolean getLimitCommands() {
+ return limitCommands;
+ }
+
+ public void setLimitCommands(boolean limitCommands) {
+ this.limitCommands = limitCommands;
+ }
+
+ private String poiLayer;
+
+ public String getPoiLayer() {
+ return poiLayer;
+ }
+
+ public void setPoiLayer(String poiLayer) {
+ this.poiLayer = poiLayer;
+ }
+}
diff --git a/src/main/java/org/traccar/model/Statistics.java b/src/main/java/org/traccar/model/Statistics.java
new file mode 100644
index 000000000..cb72c91dd
--- /dev/null
+++ b/src/main/java/org/traccar/model/Statistics.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2016 - 2017 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 ExtendedModel {
+
+ private Date captureTime;
+
+ public Date getCaptureTime() {
+ return captureTime;
+ }
+
+ public void setCaptureTime(Date captureTime) {
+ this.captureTime = captureTime;
+ }
+
+ 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;
+ }
+
+ private int mailSent;
+
+ public int getMailSent() {
+ return mailSent;
+ }
+
+ public void setMailSent(int mailSent) {
+ this.mailSent = mailSent;
+ }
+
+ private int smsSent;
+
+ public int getSmsSent() {
+ return smsSent;
+ }
+
+ public void setSmsSent(int smsSent) {
+ this.smsSent = smsSent;
+ }
+
+ private int geocoderRequests;
+
+ public int getGeocoderRequests() {
+ return geocoderRequests;
+ }
+
+ public void setGeocoderRequests(int geocoderRequests) {
+ this.geocoderRequests = geocoderRequests;
+ }
+
+ private int geolocationRequests;
+
+ public int getGeolocationRequests() {
+ return geolocationRequests;
+ }
+
+ public void setGeolocationRequests(int geolocationRequests) {
+ this.geolocationRequests = geolocationRequests;
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/Typed.java b/src/main/java/org/traccar/model/Typed.java
new file mode 100644
index 000000000..313ec7bcd
--- /dev/null
+++ b/src/main/java/org/traccar/model/Typed.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com)
+ *
+ * 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 Typed {
+
+ private String type;
+
+ public Typed(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+}
diff --git a/src/main/java/org/traccar/model/User.java b/src/main/java/org/traccar/model/User.java
new file mode 100644
index 000000000..976b6aac0
--- /dev/null
+++ b/src/main/java/org/traccar/model/User.java
@@ -0,0 +1,276 @@
+/*
+ * 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.
+ * 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 com.fasterxml.jackson.annotation.JsonIgnore;
+
+import org.traccar.database.QueryExtended;
+import org.traccar.database.QueryIgnore;
+import org.traccar.helper.Hashing;
+
+import java.util.Date;
+
+public class User extends ExtendedModel {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private String login;
+
+ public String getLogin() {
+ return login;
+ }
+
+ public void setLogin(String login) {
+ this.login = login;
+ }
+
+ private String email;
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email.trim();
+ }
+
+ private String phone;
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ private boolean readonly;
+
+ public boolean getReadonly() {
+ return readonly;
+ }
+
+ public void setReadonly(boolean readonly) {
+ this.readonly = readonly;
+ }
+
+ private boolean administrator;
+
+ public boolean getAdministrator() {
+ return administrator;
+ }
+
+ public void setAdministrator(boolean administrator) {
+ this.administrator = administrator;
+ }
+
+ private String map;
+
+ public String getMap() {
+ return map;
+ }
+
+ public void setMap(String map) {
+ this.map = map;
+ }
+
+ private double latitude;
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ private double longitude;
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ private int zoom;
+
+ public int getZoom() {
+ return zoom;
+ }
+
+ public void setZoom(int zoom) {
+ this.zoom = zoom;
+ }
+
+ private boolean twelveHourFormat;
+
+ public boolean getTwelveHourFormat() {
+ return twelveHourFormat;
+ }
+
+ public void setTwelveHourFormat(boolean twelveHourFormat) {
+ this.twelveHourFormat = twelveHourFormat;
+ }
+
+ 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() {
+ return expirationTime;
+ }
+
+ public void setExpirationTime(Date expirationTime) {
+ this.expirationTime = expirationTime;
+ }
+
+ private int deviceLimit;
+
+ public int getDeviceLimit() {
+ return deviceLimit;
+ }
+
+ public void setDeviceLimit(int deviceLimit) {
+ this.deviceLimit = deviceLimit;
+ }
+
+ private int userLimit;
+
+ public int getUserLimit() {
+ return userLimit;
+ }
+
+ public void setUserLimit(int userLimit) {
+ this.userLimit = userLimit;
+ }
+
+ private boolean deviceReadonly;
+
+ public boolean getDeviceReadonly() {
+ return deviceReadonly;
+ }
+
+ public void setDeviceReadonly(boolean deviceReadonly) {
+ this.deviceReadonly = deviceReadonly;
+ }
+
+ 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;
+ }
+ }
+
+ private boolean limitCommands;
+
+ public boolean getLimitCommands() {
+ return limitCommands;
+ }
+
+ public void setLimitCommands(boolean limitCommands) {
+ 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;
+ }
+
+ public void setPassword(String password) {
+ if (password != null && !password.isEmpty()) {
+ Hashing.HashingResult hashingResult = Hashing.createHash(password);
+ hashedPassword = hashingResult.getHash();
+ salt = hashingResult.getSalt();
+ }
+ }
+
+ private String hashedPassword;
+
+ @JsonIgnore
+ @QueryExtended
+ public String getHashedPassword() {
+ return hashedPassword;
+ }
+
+ public void setHashedPassword(String hashedPassword) {
+ this.hashedPassword = hashedPassword;
+ }
+
+ private String salt;
+
+ @JsonIgnore
+ @QueryExtended
+ public String getSalt() {
+ return salt;
+ }
+
+ public void setSalt(String salt) {
+ this.salt = salt;
+ }
+
+ public boolean isPasswordValid(String password) {
+ return Hashing.validatePassword(password, hashedPassword, salt);
+ }
+
+}
diff --git a/src/main/java/org/traccar/model/WifiAccessPoint.java b/src/main/java/org/traccar/model/WifiAccessPoint.java
new file mode 100644
index 000000000..87a77f3c0
--- /dev/null
+++ b/src/main/java/org/traccar/model/WifiAccessPoint.java
@@ -0,0 +1,66 @@
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonInclude;
+
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class WifiAccessPoint {
+
+ public static WifiAccessPoint from(String macAddress, int signalStrength) {
+ WifiAccessPoint wifiAccessPoint = new WifiAccessPoint();
+ wifiAccessPoint.setMacAddress(macAddress);
+ wifiAccessPoint.setSignalStrength(signalStrength);
+ return wifiAccessPoint;
+ }
+
+ public static WifiAccessPoint from(String macAddress, int signalStrength, int channel) {
+ WifiAccessPoint wifiAccessPoint = from(macAddress, signalStrength);
+ wifiAccessPoint.setChannel(channel);
+ return wifiAccessPoint;
+ }
+
+ private String macAddress;
+
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ private Integer signalStrength;
+
+ public Integer getSignalStrength() {
+ return signalStrength;
+ }
+
+ public void setSignalStrength(Integer signalStrength) {
+ this.signalStrength = signalStrength;
+ }
+
+ private Integer channel;
+
+ public Integer getChannel() {
+ return channel;
+ }
+
+ public void setChannel(Integer channel) {
+ this.channel = channel;
+ }
+
+}