aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/model
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-19 15:24:55 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-19 15:24:55 +0500
commita9478ded48de140d47d17def1ee5329267fe6088 (patch)
treeadc5a9177fd5adcf10a8b56ee4620780dfc13cd9 /src/org/traccar/model
parentcb0d7cccaecfe049e04defd90884976ac1e982f9 (diff)
downloadtrackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.tar.gz
trackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.tar.bz2
trackermap-server-a9478ded48de140d47d17def1ee5329267fe6088.zip
Refactored four managers
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r--src/org/traccar/model/Attribute.java12
-rw-r--r--src/org/traccar/model/AttributeAlias.java12
-rw-r--r--src/org/traccar/model/AttributePermission.java17
-rw-r--r--src/org/traccar/model/BaseDevicePermission.java31
-rw-r--r--src/org/traccar/model/BaseGroupPermission.java31
-rw-r--r--src/org/traccar/model/BasePermission.java23
-rw-r--r--src/org/traccar/model/BaseUserPermission.java31
-rw-r--r--src/org/traccar/model/CalendarPermission.java17
-rw-r--r--src/org/traccar/model/DeviceAttribute.java17
-rw-r--r--src/org/traccar/model/DeviceDriver.java17
-rw-r--r--src/org/traccar/model/DeviceGeofence.java17
-rw-r--r--src/org/traccar/model/DriverPermission.java17
-rw-r--r--src/org/traccar/model/Extensible.java12
-rw-r--r--src/org/traccar/model/GeofencePermission.java17
-rw-r--r--src/org/traccar/model/GroupAttribute.java17
-rw-r--r--src/org/traccar/model/GroupDriver.java17
-rw-r--r--src/org/traccar/model/GroupGeofence.java17
-rw-r--r--src/org/traccar/model/Identifiable.java31
18 files changed, 210 insertions, 143 deletions
diff --git a/src/org/traccar/model/Attribute.java b/src/org/traccar/model/Attribute.java
index 9c3b5e43b..ab12cd2c4 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 Identifiable {
private String description;
diff --git a/src/org/traccar/model/AttributeAlias.java b/src/org/traccar/model/AttributeAlias.java
index 2835c0558..5aa8a5122 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 Identifiable {
private long deviceId;
diff --git a/src/org/traccar/model/AttributePermission.java b/src/org/traccar/model/AttributePermission.java
index fe2fe7b6e..e6bbb0f91 100644
--- a/src/org/traccar/model/AttributePermission.java
+++ b/src/org/traccar/model/AttributePermission.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class AttributePermission {
-
- private long userId;
-
- public long getUserId() {
- return userId;
- }
-
- public void setUserId(long userId) {
- this.userId = userId;
- }
+public class AttributePermission extends BaseUserPermission {
private long attributeId;
@@ -38,4 +28,9 @@ public class AttributePermission {
this.attributeId = attributeId;
}
+ @Override
+ public long getSlaveId() {
+ return attributeId;
+ }
+
}
diff --git a/src/org/traccar/model/BaseDevicePermission.java b/src/org/traccar/model/BaseDevicePermission.java
new file mode 100644
index 000000000..6eda15d0e
--- /dev/null
+++ b/src/org/traccar/model/BaseDevicePermission.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 abstract class BaseDevicePermission implements BasePermission {
+
+ private long deviceId;
+
+ public long getDeviceId() {
+ return deviceId;
+ }
+
+ public void setDeviceId(long deviceId) {
+ this.deviceId = deviceId;
+ }
+
+}
diff --git a/src/org/traccar/model/BaseGroupPermission.java b/src/org/traccar/model/BaseGroupPermission.java
new file mode 100644
index 000000000..5a289cad2
--- /dev/null
+++ b/src/org/traccar/model/BaseGroupPermission.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 abstract class BaseGroupPermission implements BasePermission {
+
+ private long groupId;
+
+ public long getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(long groupId) {
+ this.groupId = groupId;
+ }
+
+}
diff --git a/src/org/traccar/model/BasePermission.java b/src/org/traccar/model/BasePermission.java
new file mode 100644
index 000000000..6f1baffdc
--- /dev/null
+++ b/src/org/traccar/model/BasePermission.java
@@ -0,0 +1,23 @@
+/*
+ * 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 interface BasePermission {
+
+ long getSlaveId();
+
+}
diff --git a/src/org/traccar/model/BaseUserPermission.java b/src/org/traccar/model/BaseUserPermission.java
new file mode 100644
index 000000000..64a7be82a
--- /dev/null
+++ b/src/org/traccar/model/BaseUserPermission.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 abstract class BaseUserPermission implements BasePermission {
+
+ private long userId;
+
+ public long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(long userId) {
+ this.userId = userId;
+ }
+
+}
diff --git a/src/org/traccar/model/CalendarPermission.java b/src/org/traccar/model/CalendarPermission.java
index 59f54e07b..d95e51b0e 100644
--- a/src/org/traccar/model/CalendarPermission.java
+++ b/src/org/traccar/model/CalendarPermission.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class CalendarPermission {
-
- private long userId;
-
- public long getUserId() {
- return userId;
- }
-
- public void setUserId(long userId) {
- this.userId = userId;
- }
+public class CalendarPermission extends BaseUserPermission {
private long calendarId;
@@ -37,4 +27,9 @@ public class CalendarPermission {
public void setCalendarId(long calendarId) {
this.calendarId = calendarId;
}
+
+ @Override
+ public long getSlaveId() {
+ return calendarId;
+ }
}
diff --git a/src/org/traccar/model/DeviceAttribute.java b/src/org/traccar/model/DeviceAttribute.java
index e0ac6dd98..bfcd873fa 100644
--- a/src/org/traccar/model/DeviceAttribute.java
+++ b/src/org/traccar/model/DeviceAttribute.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class DeviceAttribute {
-
- private long deviceId;
-
- public long getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(long deviceId) {
- this.deviceId = deviceId;
- }
+public class DeviceAttribute extends BaseDevicePermission {
private long attributeId;
@@ -37,4 +27,9 @@ public class DeviceAttribute {
public void setAttributeId(long attributeId) {
this.attributeId = attributeId;
}
+
+ @Override
+ public long getSlaveId() {
+ return attributeId;
+ }
}
diff --git a/src/org/traccar/model/DeviceDriver.java b/src/org/traccar/model/DeviceDriver.java
index 2008aaddf..f5257531d 100644
--- a/src/org/traccar/model/DeviceDriver.java
+++ b/src/org/traccar/model/DeviceDriver.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class DeviceDriver {
-
- private long deviceId;
-
- public long getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(long deviceId) {
- this.deviceId = deviceId;
- }
+public class DeviceDriver extends BaseDevicePermission {
private long driverId;
@@ -38,4 +28,9 @@ public class DeviceDriver {
this.driverId = driverId;
}
+ @Override
+ public long getSlaveId() {
+ return driverId;
+ }
+
}
diff --git a/src/org/traccar/model/DeviceGeofence.java b/src/org/traccar/model/DeviceGeofence.java
index 00c99add6..7ea4d3bea 100644
--- a/src/org/traccar/model/DeviceGeofence.java
+++ b/src/org/traccar/model/DeviceGeofence.java
@@ -15,17 +15,7 @@
*/
package org.traccar.model;
-public class DeviceGeofence {
-
- private long deviceId;
-
- public long getDeviceId() {
- return deviceId;
- }
-
- public void setDeviceId(long deviceId) {
- this.deviceId = deviceId;
- }
+public class DeviceGeofence extends BaseDevicePermission {
private long geofenceId;
@@ -37,4 +27,9 @@ public class DeviceGeofence {
this.geofenceId = geofenceId;
}
+ @Override
+ public long getSlaveId() {
+ return geofenceId;
+ }
+
}
diff --git a/src/org/traccar/model/DriverPermission.java b/src/org/traccar/model/DriverPermission.java
index cdbcc4a50..44f34c8e6 100644
--- a/src/org/traccar/model/DriverPermission.java
+++ b/src/org/traccar/model/DriverPermission.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class DriverPermission {
-
- private long userId;
-
- public long getUserId() {
- return userId;
- }
-
- public void setUserId(long userId) {
- this.userId = userId;
- }
+public class DriverPermission extends BaseUserPermission {
private long driverId;
@@ -37,4 +27,9 @@ public class DriverPermission {
public void setDriverId(long driverId) {
this.driverId = driverId;
}
+
+ @Override
+ public long getSlaveId() {
+ return driverId;
+ }
}
diff --git a/src/org/traccar/model/Extensible.java b/src/org/traccar/model/Extensible.java
index b7953d8a6..3b382838e 100644
--- a/src/org/traccar/model/Extensible.java
+++ b/src/org/traccar/model/Extensible.java
@@ -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 Extensible extends Identifiable {
private Map<String, Object> attributes = new LinkedHashMap<>();
diff --git a/src/org/traccar/model/GeofencePermission.java b/src/org/traccar/model/GeofencePermission.java
index 464f4e9eb..8606cc3e7 100644
--- a/src/org/traccar/model/GeofencePermission.java
+++ b/src/org/traccar/model/GeofencePermission.java
@@ -15,17 +15,7 @@
*/
package org.traccar.model;
-public class GeofencePermission {
-
- private long userId;
-
- public long getUserId() {
- return userId;
- }
-
- public void setUserId(long userId) {
- this.userId = userId;
- }
+public class GeofencePermission extends BaseUserPermission {
private long geofenceId;
@@ -37,4 +27,9 @@ public class GeofencePermission {
this.geofenceId = geofenceId;
}
+ @Override
+ public long getSlaveId() {
+ return geofenceId;
+ }
+
}
diff --git a/src/org/traccar/model/GroupAttribute.java b/src/org/traccar/model/GroupAttribute.java
index a7e8a80bc..cfaf9cc2f 100644
--- a/src/org/traccar/model/GroupAttribute.java
+++ b/src/org/traccar/model/GroupAttribute.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class GroupAttribute {
-
- private long groupId;
-
- public long getGroupId() {
- return groupId;
- }
-
- public void setGroupId(long groupId) {
- this.groupId = groupId;
- }
+public class GroupAttribute extends BaseGroupPermission {
private long attributeId;
@@ -37,4 +27,9 @@ public class GroupAttribute {
public void setAttributeId(long attributeId) {
this.attributeId = attributeId;
}
+
+ @Override
+ public long getSlaveId() {
+ return attributeId;
+ }
}
diff --git a/src/org/traccar/model/GroupDriver.java b/src/org/traccar/model/GroupDriver.java
index 91b205923..9bf74c214 100644
--- a/src/org/traccar/model/GroupDriver.java
+++ b/src/org/traccar/model/GroupDriver.java
@@ -16,17 +16,7 @@
*/
package org.traccar.model;
-public class GroupDriver {
-
- private long groupId;
-
- public long getGroupId() {
- return groupId;
- }
-
- public void setGroupId(long groupId) {
- this.groupId = groupId;
- }
+public class GroupDriver extends BaseGroupPermission {
private long driverId;
@@ -38,4 +28,9 @@ public class GroupDriver {
this.driverId = driverId;
}
+ @Override
+ public long getSlaveId() {
+ return driverId;
+ }
+
}
diff --git a/src/org/traccar/model/GroupGeofence.java b/src/org/traccar/model/GroupGeofence.java
index 736e6c704..89830324d 100644
--- a/src/org/traccar/model/GroupGeofence.java
+++ b/src/org/traccar/model/GroupGeofence.java
@@ -15,17 +15,7 @@
*/
package org.traccar.model;
-public class GroupGeofence {
-
- private long groupId;
-
- public long getGroupId() {
- return groupId;
- }
-
- public void setGroupId(long groupId) {
- this.groupId = groupId;
- }
+public class GroupGeofence extends BaseGroupPermission {
private long geofenceId;
@@ -37,4 +27,9 @@ public class GroupGeofence {
this.geofenceId = geofenceId;
}
+ @Override
+ public long getSlaveId() {
+ return geofenceId;
+ }
+
}
diff --git a/src/org/traccar/model/Identifiable.java b/src/org/traccar/model/Identifiable.java
new file mode 100644
index 000000000..f22cfe800
--- /dev/null
+++ b/src/org/traccar/model/Identifiable.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 Identifiable {
+
+ private long id;
+
+ public final long getId() {
+ return id;
+ }
+
+ public final void setId(long id) {
+ this.id = id;
+ }
+
+}