From b588b3c723cad4629dcecbce8983933f7ff2a255 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 14 Jun 2016 18:05:05 +0500 Subject: - Overlapping geofences - Simplified user-device link --- src/org/traccar/api/resource/DeviceGeofenceResource.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/api/resource/DeviceGeofenceResource.java b/src/org/traccar/api/resource/DeviceGeofenceResource.java index dc7014d79..99d64292b 100644 --- a/src/org/traccar/api/resource/DeviceGeofenceResource.java +++ b/src/org/traccar/api/resource/DeviceGeofenceResource.java @@ -17,7 +17,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; -import org.traccar.model.UserDeviceGeofence; +import org.traccar.model.DeviceGeofence; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -35,25 +35,21 @@ import java.sql.SQLException; public class DeviceGeofenceResource extends BaseResource { @POST - public Response add(UserDeviceGeofence entity) throws SQLException { + public Response add(DeviceGeofence entity) throws SQLException { Context.getPermissionsManager().checkReadonly(getUserId()); - Context.getPermissionsManager().checkUser(getUserId(), entity.getUserId()); Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId()); Context.getPermissionsManager().checkGeofence(getUserId(), entity.getGeofenceId()); - Context.getDataManager().linkUserDeviceGeofence(entity.getUserId(), - entity.getDeviceId(), entity.getGeofenceId()); + Context.getDataManager().linkDeviceGeofence(entity.getDeviceId(), entity.getGeofenceId()); Context.getGeofenceManager().refresh(); return Response.ok(entity).build(); } @DELETE - public Response remove(UserDeviceGeofence entity) throws SQLException { + public Response remove(DeviceGeofence entity) throws SQLException { Context.getPermissionsManager().checkReadonly(getUserId()); - Context.getPermissionsManager().checkUser(getUserId(), entity.getUserId()); Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId()); Context.getPermissionsManager().checkGeofence(getUserId(), entity.getGeofenceId()); - Context.getDataManager().unlinkUserDeviceGeofence(entity.getUserId(), entity.getDeviceId(), - entity.getGeofenceId()); + Context.getDataManager().unlinkDeviceGeofence(entity.getDeviceId(), entity.getGeofenceId()); Context.getGeofenceManager().refresh(); return Response.noContent().build(); } -- cgit v1.2.3