diff options
author | Abyss777 <abyss@fox5.ru> | 2016-06-18 07:59:43 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-06-18 07:59:43 +0500 |
commit | 4109447d0adc778b246543b77672c280d58da8bf (patch) | |
tree | 08ee98636cec128587bbf5f25654c5e3534dfcd9 /src/org/traccar/database/GeofenceManager.java | |
parent | b3b0cd9d6f2d26cef2e64ef38e23203f1f3fa51a (diff) | |
download | trackermap-server-4109447d0adc778b246543b77672c280d58da8bf.tar.gz trackermap-server-4109447d0adc778b246543b77672c280d58da8bf.tar.bz2 trackermap-server-4109447d0adc778b246543b77672c280d58da8bf.zip |
- Update Geofences API and Manager a bit
- Show geofence name in event toasts
- Link/Unlink geofences to users, devices and groups
Diffstat (limited to 'src/org/traccar/database/GeofenceManager.java')
-rw-r--r-- | src/org/traccar/database/GeofenceManager.java | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/org/traccar/database/GeofenceManager.java b/src/org/traccar/database/GeofenceManager.java index 0a07e2cf3..3f4d4c5ce 100644 --- a/src/org/traccar/database/GeofenceManager.java +++ b/src/org/traccar/database/GeofenceManager.java @@ -70,6 +70,15 @@ public class GeofenceManager { return groupGeofences.get(groupId); } + public Set<Long> getGroupGeofencesIds(long groupId) { + groupGeofencesLock.readLock().lock(); + try { + return getGroupGeofences(groupId); + } finally { + groupGeofencesLock.readLock().unlock(); + } + } + public Set<Long> getAllDeviceGeofences(long deviceId) { deviceGeofencesLock.readLock().lock(); try { @@ -77,10 +86,9 @@ public class GeofenceManager { } finally { deviceGeofencesLock.readLock().unlock(); } - } - public Set<Long> getDeviceGeofences(long deviceId) { + public Set<Long> getDeviceGeofencesIds(long deviceId) { deviceGeofencesLock.readLock().lock(); try { return getDeviceGeofences(deviceGeofences, deviceId); @@ -174,11 +182,20 @@ public class GeofenceManager { } } - public final Collection<Geofence> getUserGeofences(long userId) { + public final Set<Long> getAllGeofencesIds() { + geofencesLock.readLock().lock(); + try { + return geofences.keySet(); + } finally { + geofencesLock.readLock().unlock(); + } + } + + public final Collection<Geofence> getGeofences(Set<Long> geofencesIds) { geofencesLock.readLock().lock(); try { Collection<Geofence> result = new LinkedList<>(); - for (Long geofenceId : getUserGeofencesIds(userId)) { + for (Long geofenceId : geofencesIds) { result.add(getGeofence(geofenceId)); } return result; |