diff options
Diffstat (limited to 'src/org/traccar/model')
27 files changed, 78 insertions, 523 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 index 2835c0558..1599ab939 100644 --- a/src/org/traccar/model/AttributeAlias.java +++ b/src/org/traccar/model/AttributeAlias.java @@ -16,17 +16,7 @@ */ package org.traccar.model; -public class AttributeAlias { - - private long id; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } +public class AttributeAlias extends BaseModel { private long deviceId; diff --git a/src/org/traccar/model/AttributePermission.java b/src/org/traccar/model/AttributePermission.java deleted file mode 100644 index fe2fe7b6e..000000000 --- a/src/org/traccar/model/AttributePermission.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 AttributePermission { - - private long userId; - - public long getUserId() { - return userId; - } - - public void setUserId(long userId) { - this.userId = userId; - } - - private long attributeId; - - public long getAttributeId() { - return attributeId; - } - - public void setAttributeId(long attributeId) { - this.attributeId = attributeId; - } - -} diff --git a/src/org/traccar/model/DriverPermission.java b/src/org/traccar/model/BaseModel.java index cdbcc4a50..8bdb916e8 100644 --- a/src/org/traccar/model/DriverPermission.java +++ b/src/org/traccar/model/BaseModel.java @@ -16,25 +16,16 @@ */ package org.traccar.model; -public class DriverPermission { +public class BaseModel { - private long userId; + private long id; - public long getUserId() { - return userId; + public final long getId() { + return id; } - public void setUserId(long userId) { - this.userId = userId; + public final void setId(long id) { + this.id = id; } - private long driverId; - - public long getDriverId() { - return driverId; - } - - public void setDriverId(long driverId) { - this.driverId = driverId; - } } diff --git a/src/org/traccar/model/Calendar.java b/src/org/traccar/model/Calendar.java index 55f696d50..3d855b1be 100644 --- a/src/org/traccar/model/Calendar.java +++ b/src/org/traccar/model/Calendar.java @@ -34,7 +34,7 @@ import net.fortuna.ical4j.model.Period; import net.fortuna.ical4j.model.component.CalendarComponent; import org.traccar.database.QueryIgnore; -public class Calendar extends Extensible { +public class Calendar extends ExtendedModel { private String name; 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/Device.java b/src/org/traccar/model/Device.java index 2324da532..6a13c2b77 100644 --- a/src/org/traccar/model/Device.java +++ b/src/org/traccar/model/Device.java @@ -18,7 +18,7 @@ package org.traccar.model; import java.util.Date; import java.util.List; -public class Device extends Extensible { +public class Device extends ExtendedModel { private String name; diff --git a/src/org/traccar/model/DeviceAttribute.java b/src/org/traccar/model/DeviceAttribute.java deleted file mode 100644 index e0ac6dd98..000000000 --- a/src/org/traccar/model/DeviceAttribute.java +++ /dev/null @@ -1,40 +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 DeviceAttribute { - - 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/DeviceDriver.java b/src/org/traccar/model/DeviceDriver.java deleted file mode 100644 index 2008aaddf..000000000 --- a/src/org/traccar/model/DeviceDriver.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 DeviceDriver { - - private long deviceId; - - public long getDeviceId() { - return deviceId; - } - - public void setDeviceId(long deviceId) { - this.deviceId = deviceId; - } - - private long driverId; - - public long getDriverId() { - return driverId; - } - - public void setDriverId(long driverId) { - this.driverId = driverId; - } - -} 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/Driver.java b/src/org/traccar/model/Driver.java index 7a51d9151..05f52fd4d 100644 --- a/src/org/traccar/model/Driver.java +++ b/src/org/traccar/model/Driver.java @@ -16,7 +16,7 @@ */ package org.traccar.model; -public class Driver extends Extensible { +public class Driver extends ExtendedModel { private String name; diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/ExtendedModel.java index b7953d8a6..a4bf00e70 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<>(); 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/GroupAttribute.java b/src/org/traccar/model/GroupAttribute.java deleted file mode 100644 index a7e8a80bc..000000000 --- a/src/org/traccar/model/GroupAttribute.java +++ /dev/null @@ -1,40 +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 GroupAttribute { - - private long groupId; - - public long getGroupId() { - return groupId; - } - - public void setGroupId(long groupId) { - this.groupId = groupId; - } - - private long attributeId; - - public long getAttributeId() { - return attributeId; - } - - public void setAttributeId(long attributeId) { - this.attributeId = attributeId; - } -} 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/GroupDriver.java b/src/org/traccar/model/ManagedUser.java index 91b205923..03c5ef48d 100644 --- a/src/org/traccar/model/GroupDriver.java +++ b/src/org/traccar/model/ManagedUser.java @@ -16,26 +16,6 @@ */ package org.traccar.model; -public class GroupDriver { - - private long groupId; - - public long getGroupId() { - return groupId; - } - - public void setGroupId(long groupId) { - this.groupId = groupId; - } - - private long driverId; - - public long getDriverId() { - return driverId; - } - - public void setDriverId(long driverId) { - this.driverId = driverId; - } +public class ManagedUser extends User { } 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..e7bb69903 100644 --- a/src/org/traccar/model/Notification.java +++ b/src/org/traccar/model/Notification.java @@ -15,7 +15,7 @@ */ package org.traccar.model; -public class Notification extends Extensible { +public class Notification extends ExtendedModel { private long userId; 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/Server.java b/src/org/traccar/model/Server.java index 4ded65204..cd5b0624e 100644 --- a/src/org/traccar/model/Server.java +++ b/src/org/traccar/model/Server.java @@ -19,7 +19,7 @@ import java.util.TimeZone; import org.traccar.helper.Log; -public class Server extends Extensible { +public class Server extends ExtendedModel { public String getVersion() { return Log.getAppVersion(); 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/User.java b/src/org/traccar/model/User.java index 366ced503..6e6a079c2 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -21,7 +21,7 @@ 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; 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; - } - -} |