aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model
diff options
context:
space:
mode:
authorIvan Muratov <binakot@gmail.com>2017-10-24 14:52:48 +0300
committerGitHub <noreply@github.com>2017-10-24 14:52:48 +0300
commitdb02157dbb29539dda4b51a5e8b317293cfc536c (patch)
treeb974f082172406e16a92cb9da8136ef856f571a5 /src/org/traccar/model
parent09d3cf2b5416327700ad22b652cf4a0dca09aaf2 (diff)
parent96e15853b9c28bd31295ca2c014e226e4a50aaa1 (diff)
downloadtrackermap-server-db02157dbb29539dda4b51a5e8b317293cfc536c.tar.gz
trackermap-server-db02157dbb29539dda4b51a5e8b317293cfc536c.tar.bz2
trackermap-server-db02157dbb29539dda4b51a5e8b317293cfc536c.zip
Merge branch 'master' into master
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r--src/org/traccar/model/Attribute.java12
-rw-r--r--src/org/traccar/model/AttributeAlias.java61
-rw-r--r--src/org/traccar/model/BaseModel.java (renamed from src/org/traccar/model/GroupAttribute.java)21
-rw-r--r--src/org/traccar/model/Calendar.java8
-rw-r--r--src/org/traccar/model/CalendarPermission.java40
-rw-r--r--src/org/traccar/model/CellTower.java6
-rw-r--r--src/org/traccar/model/Command.java25
-rw-r--r--src/org/traccar/model/Device.java9
-rw-r--r--src/org/traccar/model/DeviceGeofence.java40
-rw-r--r--src/org/traccar/model/DevicePermission.java40
-rw-r--r--src/org/traccar/model/DeviceState.java61
-rw-r--r--src/org/traccar/model/Driver.java (renamed from src/org/traccar/model/AttributePermission.java)23
-rw-r--r--src/org/traccar/model/Event.java14
-rw-r--r--src/org/traccar/model/ExtendedModel.java (renamed from src/org/traccar/model/Extensible.java)20
-rw-r--r--src/org/traccar/model/Geofence.java2
-rw-r--r--src/org/traccar/model/GeofencePermission.java40
-rw-r--r--src/org/traccar/model/Group.java2
-rw-r--r--src/org/traccar/model/GroupGeofence.java40
-rw-r--r--src/org/traccar/model/GroupPermission.java40
-rw-r--r--src/org/traccar/model/ManagedUser.java (renamed from src/org/traccar/model/DeviceAttribute.java)21
-rw-r--r--src/org/traccar/model/Message.java2
-rw-r--r--src/org/traccar/model/Notification.java12
-rw-r--r--src/org/traccar/model/Permission.java57
-rw-r--r--src/org/traccar/model/Position.java18
-rw-r--r--src/org/traccar/model/Server.java36
-rw-r--r--src/org/traccar/model/Statistics.java2
-rw-r--r--src/org/traccar/model/Typed.java (renamed from src/org/traccar/model/CommandType.java)4
-rw-r--r--src/org/traccar/model/User.java50
-rw-r--r--src/org/traccar/model/UserPermission.java41
29 files changed, 246 insertions, 501 deletions
diff --git a/src/org/traccar/model/Attribute.java b/src/org/traccar/model/Attribute.java
index 9c3b5e43b..45d40b3ec 100644
--- a/src/org/traccar/model/Attribute.java
+++ b/src/org/traccar/model/Attribute.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class Attribute {
-
- private long id;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
+public class Attribute extends BaseModel {
private String description;
diff --git a/src/org/traccar/model/AttributeAlias.java b/src/org/traccar/model/AttributeAlias.java
deleted file mode 100644
index 2835c0558..000000000
--- a/src/org/traccar/model/AttributeAlias.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 AttributeAlias {
-
- private long id;
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- private long deviceId;
-
- public long getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(long deviceId) {
- this.deviceId = deviceId;
- }
-
- private String attribute;
-
- public String getAttribute() {
- return attribute;
- }
-
- public void setAttribute(String attribute) {
- this.attribute = attribute;
- }
-
- private String alias;
-
- public String getAlias() {
- return alias;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
-}
diff --git a/src/org/traccar/model/GroupAttribute.java b/src/org/traccar/model/BaseModel.java
index a7e8a80bc..8bdb916e8 100644
--- a/src/org/traccar/model/GroupAttribute.java
+++ b/src/org/traccar/model/BaseModel.java
@@ -16,25 +16,16 @@
*/
package org.traccar.model;
-public class GroupAttribute {
+public class BaseModel {
- private long groupId;
+ private long id;
- public long getGroupId() {
- return groupId;
+ public final long getId() {
+ return id;
}
- public void setGroupId(long groupId) {
- this.groupId = groupId;
+ public final void setId(long id) {
+ this.id = id;
}
- private long attributeId;
-
- public long getAttributeId() {
- return attributeId;
- }
-
- public void setAttributeId(long attributeId) {
- this.attributeId = attributeId;
- }
}
diff --git a/src/org/traccar/model/Calendar.java b/src/org/traccar/model/Calendar.java
index 55f696d50..56d3eb74c 100644
--- a/src/org/traccar/model/Calendar.java
+++ b/src/org/traccar/model/Calendar.java
@@ -27,14 +27,14 @@ 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.filter.Rule;
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 Extensible {
+public class Calendar extends ExtendedModel {
private String name;
@@ -69,8 +69,8 @@ public class Calendar extends Extensible {
public boolean checkMoment(Date date) {
if (calendar != null) {
Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0));
- Rule<CalendarComponent> periodRule = new PeriodRule<>(period);
- Filter<CalendarComponent> filter = new Filter<>(new Rule[] {periodRule}, Filter.MATCH_ANY);
+ 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;
diff --git a/src/org/traccar/model/CalendarPermission.java b/src/org/traccar/model/CalendarPermission.java
deleted file mode 100644
index 59f54e07b..000000000
--- a/src/org/traccar/model/CalendarPermission.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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 CalendarPermission {
-
- private long userId;
-
- public long getUserId() {
- return userId;
- }
-
- public void setUserId(long userId) {
- this.userId = userId;
- }
-
- private long calendarId;
-
- public long getCalendarId() {
- return calendarId;
- }
-
- public void setCalendarId(long calendarId) {
- this.calendarId = calendarId;
- }
-}
diff --git a/src/org/traccar/model/CellTower.java b/src/org/traccar/model/CellTower.java
index 2eb56dd33..6d1dfbd7f 100644
--- a/src/org/traccar/model/CellTower.java
+++ b/src/org/traccar/model/CellTower.java
@@ -106,4 +106,10 @@ public class CellTower {
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/org/traccar/model/Command.java b/src/org/traccar/model/Command.java
index 6a48b14e9..16205ede1 100644
--- a/src/org/traccar/model/Command.java
+++ b/src/org/traccar/model/Command.java
@@ -15,10 +15,12 @@
*/
package org.traccar.model;
+import org.traccar.database.QueryIgnore;
+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
-public class Command extends Message {
+public class Command extends Message implements Cloneable {
public static final String TYPE_CUSTOM = "custom";
public static final String TYPE_IDENTIFICATION = "deviceIdentification";
@@ -75,6 +77,11 @@ public class Command extends Message {
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() {
@@ -85,4 +92,20 @@ public class Command extends Message {
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/org/traccar/model/Device.java b/src/org/traccar/model/Device.java
index 2324da532..c8a28404c 100644
--- a/src/org/traccar/model/Device.java
+++ b/src/org/traccar/model/Device.java
@@ -18,7 +18,10 @@ package org.traccar.model;
import java.util.Date;
import java.util.List;
-public class Device extends Extensible {
+import org.traccar.database.QueryExtended;
+import org.traccar.database.QueryIgnore;
+
+public class Device extends ExtendedModel {
private String name;
@@ -46,6 +49,7 @@ public class Device extends Extensible {
private String status;
+ @QueryIgnore
public String getStatus() {
return status != null ? status : STATUS_OFFLINE;
}
@@ -56,6 +60,7 @@ public class Device extends Extensible {
private Date lastUpdate;
+ @QueryExtended
public Date getLastUpdate() {
if (lastUpdate != null) {
return new Date(lastUpdate.getTime());
@@ -74,6 +79,7 @@ public class Device extends Extensible {
private long positionId;
+ @QueryIgnore
public long getPositionId() {
return positionId;
}
@@ -94,6 +100,7 @@ public class Device extends Extensible {
private List<Long> geofenceIds;
+ @QueryIgnore
public List<Long> getGeofenceIds() {
return geofenceIds;
}
diff --git a/src/org/traccar/model/DeviceGeofence.java b/src/org/traccar/model/DeviceGeofence.java
deleted file mode 100644
index 00c99add6..000000000
--- a/src/org/traccar/model/DeviceGeofence.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-public class DeviceGeofence {
-
- 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;
- }
-
-}
diff --git a/src/org/traccar/model/DevicePermission.java b/src/org/traccar/model/DevicePermission.java
deleted file mode 100644
index c62173132..000000000
--- a/src/org/traccar/model/DevicePermission.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.
- * 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 DevicePermission {
-
- 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;
- }
-
-}
diff --git a/src/org/traccar/model/DeviceState.java b/src/org/traccar/model/DeviceState.java
new file mode 100644
index 000000000..f2d0ff614
--- /dev/null
+++ b/src/org/traccar/model/DeviceState.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 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;
+ }
+
+}
diff --git a/src/org/traccar/model/AttributePermission.java b/src/org/traccar/model/Driver.java
index fe2fe7b6e..05f52fd4d 100644
--- a/src/org/traccar/model/AttributePermission.java
+++ b/src/org/traccar/model/Driver.java
@@ -16,26 +16,25 @@
*/
package org.traccar.model;
-public class AttributePermission {
+public class Driver extends ExtendedModel {
- private long userId;
+ private String name;
- public long getUserId() {
- return userId;
+ public String getName() {
+ return name;
}
- public void setUserId(long userId) {
- this.userId = userId;
+ public void setName(String name) {
+ this.name = name;
}
- private long attributeId;
+ private String uniqueId;
- public long getAttributeId() {
- return attributeId;
+ public String getUniqueId() {
+ return uniqueId;
}
- public void setAttributeId(long attributeId) {
- this.attributeId = attributeId;
+ public void setUniqueId(String uniqueId) {
+ this.uniqueId = uniqueId;
}
-
}
diff --git a/src/org/traccar/model/Event.java b/src/org/traccar/model/Event.java
index 6a24d91c6..47b60af01 100644
--- a/src/org/traccar/model/Event.java
+++ b/src/org/traccar/model/Event.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * 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.
@@ -20,15 +20,13 @@ import java.util.Date;
public class Event extends Message {
public Event(String type, long deviceId, long positionId) {
- this.setType(type);
- this.setDeviceId(deviceId);
- this.setPositionId(positionId);
- this.serverTime = new Date();
+ this(type, deviceId);
+ setPositionId(positionId);
}
public Event(String type, long deviceId) {
- this.setType(type);
- this.setDeviceId(deviceId);
+ setType(type);
+ setDeviceId(deviceId);
this.serverTime = new Date();
}
@@ -61,6 +59,8 @@ public class Event extends Message {
public static final String TYPE_TEXT_MESSAGE = "textMessage";
+ public static final String TYPE_DRIVER_CHANGED = "driverChanged";
+
private Date serverTime;
public Date getServerTime() {
diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/ExtendedModel.java
index b7953d8a6..8353d0e66 100644
--- a/src/org/traccar/model/Extensible.java
+++ b/src/org/traccar/model/ExtendedModel.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * 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.
@@ -18,17 +18,7 @@ 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;
- }
+public class ExtendedModel extends BaseModel {
private Map<String, Object> attributes = new LinkedHashMap<>();
@@ -41,7 +31,9 @@ public class Extensible {
}
public void set(String key, Boolean value) {
- attributes.put(key, value);
+ if (value != null) {
+ attributes.put(key, value);
+ }
}
public void set(String key, Byte value) {
@@ -110,7 +102,7 @@ public class Extensible {
public boolean getBoolean(String key) {
if (attributes.containsKey(key)) {
- return Boolean.parseBoolean(attributes.get(key).toString());
+ return (Boolean) attributes.get(key);
} else {
return false;
}
diff --git a/src/org/traccar/model/Geofence.java b/src/org/traccar/model/Geofence.java
index dfb888852..21c196da9 100644
--- a/src/org/traccar/model/Geofence.java
+++ b/src/org/traccar/model/Geofence.java
@@ -26,7 +26,7 @@ import org.traccar.geofence.GeofencePolyline;
import com.fasterxml.jackson.annotation.JsonIgnore;
-public class Geofence extends Extensible {
+public class Geofence extends ExtendedModel {
public static final String TYPE_GEOFENCE_CILCLE = "geofenceCircle";
public static final String TYPE_GEOFENCE_POLYGON = "geofencePolygon";
diff --git a/src/org/traccar/model/GeofencePermission.java b/src/org/traccar/model/GeofencePermission.java
deleted file mode 100644
index 464f4e9eb..000000000
--- a/src/org/traccar/model/GeofencePermission.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-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/Group.java b/src/org/traccar/model/Group.java
index c21d43127..aad206aad 100644
--- a/src/org/traccar/model/Group.java
+++ b/src/org/traccar/model/Group.java
@@ -15,7 +15,7 @@
*/
package org.traccar.model;
-public class Group extends Extensible {
+public class Group extends ExtendedModel {
private String name;
diff --git a/src/org/traccar/model/GroupGeofence.java b/src/org/traccar/model/GroupGeofence.java
deleted file mode 100644
index 736e6c704..000000000
--- a/src/org/traccar/model/GroupGeofence.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-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/GroupPermission.java b/src/org/traccar/model/GroupPermission.java
deleted file mode 100644
index 59b41b049..000000000
--- a/src/org/traccar/model/GroupPermission.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-public class GroupPermission {
-
- private long userId;
-
- public long getUserId() {
- return userId;
- }
-
- public void setUserId(long userId) {
- this.userId = userId;
- }
-
- private long groupId;
-
- public long getGroupId() {
- return groupId;
- }
-
- public void setGroupId(long groupId) {
- this.groupId = groupId;
- }
-
-}
diff --git a/src/org/traccar/model/DeviceAttribute.java b/src/org/traccar/model/ManagedUser.java
index e0ac6dd98..03c5ef48d 100644
--- a/src/org/traccar/model/DeviceAttribute.java
+++ b/src/org/traccar/model/ManagedUser.java
@@ -16,25 +16,6 @@
*/
package org.traccar.model;
-public class DeviceAttribute {
+public class ManagedUser extends User {
- private long deviceId;
-
- public long getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(long deviceId) {
- this.deviceId = deviceId;
- }
-
- private long attributeId;
-
- public long getAttributeId() {
- return attributeId;
- }
-
- public void setAttributeId(long attributeId) {
- this.attributeId = attributeId;
- }
}
diff --git a/src/org/traccar/model/Message.java b/src/org/traccar/model/Message.java
index ab472202b..dad9c20f0 100644
--- a/src/org/traccar/model/Message.java
+++ b/src/org/traccar/model/Message.java
@@ -15,7 +15,7 @@
*/
package org.traccar.model;
-public class Message extends Extensible {
+public class Message extends ExtendedModel {
private long deviceId;
diff --git a/src/org/traccar/model/Notification.java b/src/org/traccar/model/Notification.java
index 6c61cafaf..9d6034fff 100644
--- a/src/org/traccar/model/Notification.java
+++ b/src/org/traccar/model/Notification.java
@@ -15,16 +15,16 @@
*/
package org.traccar.model;
-public class Notification extends Extensible {
+public class Notification extends ExtendedModel {
- private long userId;
+ private boolean always;
- public long getUserId() {
- return userId;
+ public boolean getAlways() {
+ return always;
}
- public void setUserId(long userId) {
- this.userId = userId;
+ public void setAlways(boolean always) {
+ this.always = always;
}
private String type;
diff --git a/src/org/traccar/model/Permission.java b/src/org/traccar/model/Permission.java
new file mode 100644
index 000000000..1006b1c47
--- /dev/null
+++ b/src/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/org/traccar/model/Position.java b/src/org/traccar/model/Position.java
index 5835310ae..099e6d686 100644
--- a/src/org/traccar/model/Position.java
+++ b/src/org/traccar/model/Position.java
@@ -17,6 +17,8 @@ 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";
@@ -28,6 +30,7 @@ public class Position extends Message {
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";
@@ -35,6 +38,7 @@ public class Position extends Message {
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_INPUT = "input";
public static final String KEY_OUTPUT = "output";
public static final String KEY_IMAGE = "image";
@@ -49,7 +53,6 @@ public class Position extends Message {
public static final String KEY_FUEL_LEVEL = "fuel"; // liters
public static final String KEY_FUEL_CONSUMPTION = "fuelConsumption"; // liters/hour
- public static final String KEY_RFID = "rfid";
public static final String KEY_VERSION_FW = "versionFw";
public static final String KEY_VERSION_HW = "versionHw";
public static final String KEY_TYPE = "type";
@@ -74,6 +77,7 @@ public class Position extends Message {
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_DTCS = "dtcs";
public static final String KEY_OBD_SPEED = "obdSpeed"; // knots
@@ -81,6 +85,8 @@ public class Position extends Message {
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";
@@ -109,7 +115,8 @@ public class Position extends Message {
public static final String ALARM_ACCIDENT = "accident";
public static final String ALARM_TOW = "tow";
public static final String ALARM_ACCELERATION = "hardAcceleration";
- public static final String ALARM_BREAKING = "hardBreaking";
+ public static final String ALARM_BRAKING = "hardBraking";
+ public static final String ALARM_CORNERING = "hardCornering";
public static final String ALARM_FATIGUE_DRIVING = "fatigueDriving";
public static final String ALARM_POWER_CUT = "powerCut";
public static final String ALARM_POWER_RESTORED = "powerRestored";
@@ -194,6 +201,7 @@ public class Position extends Message {
private boolean outdated;
+ @QueryIgnore
public boolean getOutdated() {
return outdated;
}
@@ -292,4 +300,10 @@ public class Position extends Message {
this.network = network;
}
+ @Override
+ @QueryIgnore
+ public String getType() {
+ return super.getType();
+ }
+
}
diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java
index 4ded65204..072e85d55 100644
--- a/src/org/traccar/model/Server.java
+++ b/src/org/traccar/model/Server.java
@@ -15,12 +15,12 @@
*/
package org.traccar.model;
-import java.util.TimeZone;
-
+import org.traccar.database.QueryIgnore;
import org.traccar.helper.Log;
-public class Server extends Extensible {
+public class Server extends ExtendedModel {
+ @QueryIgnore
public String getVersion() {
return Log.getAppVersion();
}
@@ -88,26 +88,6 @@ public class Server extends Extensible {
this.mapUrl = mapUrl;
}
- private String distanceUnit;
-
- public String getDistanceUnit() {
- return distanceUnit;
- }
-
- public void setDistanceUnit(String distanceUnit) {
- this.distanceUnit = distanceUnit;
- }
-
- private String speedUnit;
-
- public String getSpeedUnit() {
- return speedUnit;
- }
-
- public void setSpeedUnit(String speedUnit) {
- this.speedUnit = speedUnit;
- }
-
private double latitude;
public double getLatitude() {
@@ -168,13 +148,13 @@ public class Server extends Extensible {
this.coordinateFormat = coordinateFormat;
}
- private String timezone;
+ private boolean limitCommands;
- public void setTimezone(String timezone) {
- this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null;
+ public boolean getLimitCommands() {
+ return limitCommands;
}
- public String getTimezone() {
- return timezone;
+ public void setLimitCommands(boolean limitCommands) {
+ this.limitCommands = limitCommands;
}
}
diff --git a/src/org/traccar/model/Statistics.java b/src/org/traccar/model/Statistics.java
index c7ae5af7a..2acf8514f 100644
--- a/src/org/traccar/model/Statistics.java
+++ b/src/org/traccar/model/Statistics.java
@@ -17,7 +17,7 @@ package org.traccar.model;
import java.util.Date;
-public class Statistics extends Extensible {
+public class Statistics extends ExtendedModel {
private Date captureTime;
diff --git a/src/org/traccar/model/CommandType.java b/src/org/traccar/model/Typed.java
index 210316f71..313ec7bcd 100644
--- a/src/org/traccar/model/CommandType.java
+++ b/src/org/traccar/model/Typed.java
@@ -15,11 +15,11 @@
*/
package org.traccar.model;
-public class CommandType {
+public class Typed {
private String type;
- public CommandType(String type) {
+ public Typed(String type) {
this.type = type;
}
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java
index 366ced503..5d89dcfae 100644
--- a/src/org/traccar/model/User.java
+++ b/src/org/traccar/model/User.java
@@ -16,12 +16,14 @@
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;
-import java.util.TimeZone;
-public class User extends Extensible {
+public class User extends ExtendedModel {
private String name;
@@ -40,7 +42,7 @@ public class User extends Extensible {
}
public void setEmail(String email) {
- this.email = email;
+ this.email = email.trim();
}
private String phone;
@@ -83,26 +85,6 @@ public class User extends Extensible {
this.map = map;
}
- private String distanceUnit;
-
- public String getDistanceUnit() {
- return distanceUnit;
- }
-
- public void setDistanceUnit(String distanceUnit) {
- this.distanceUnit = distanceUnit;
- }
-
- private String speedUnit;
-
- public String getSpeedUnit() {
- return speedUnit;
- }
-
- public void setSpeedUnit(String speedUnit) {
- this.speedUnit = speedUnit;
- }
-
private double latitude;
public double getLatitude() {
@@ -228,6 +210,17 @@ public class User extends Extensible {
}
}
+ private boolean limitCommands;
+
+ public boolean getLimitCommands() {
+ return limitCommands;
+ }
+
+ public void setLimitCommands(boolean limitCommands) {
+ this.limitCommands = limitCommands;
+ }
+
+ @QueryIgnore
public String getPassword() {
return null;
}
@@ -243,6 +236,7 @@ public class User extends Extensible {
private String hashedPassword;
@JsonIgnore
+ @QueryExtended
public String getHashedPassword() {
return hashedPassword;
}
@@ -254,6 +248,7 @@ public class User extends Extensible {
private String salt;
@JsonIgnore
+ @QueryExtended
public String getSalt() {
return salt;
}
@@ -266,13 +261,4 @@ public class User extends Extensible {
return Hashing.validatePassword(password, hashedPassword, salt);
}
- private String timezone;
-
- public void setTimezone(String timezone) {
- this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null;
- }
-
- public String getTimezone() {
- return timezone;
- }
}
diff --git a/src/org/traccar/model/UserPermission.java b/src/org/traccar/model/UserPermission.java
deleted file mode 100644
index 39ead5ef1..000000000
--- a/src/org/traccar/model/UserPermission.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 UserPermission {
-
- private long userId;
-
- public long getUserId() {
- return userId;
- }
-
- public void setUserId(long userId) {
- this.userId = userId;
- }
-
- private long managedUserId;
-
- public long getManagedUserId() {
- return managedUserId;
- }
-
- public void setManagedUserId(long managedUserId) {
- this.managedUserId = managedUserId;
- }
-
-}