aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/GeofenceManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-06-20 22:56:18 +1200
committerGitHub <noreply@github.com>2016-06-20 22:56:18 +1200
commit63aa4472c7d851a0b414dd3c295ccce2bc8c827f (patch)
treefca526a145f48ba07128649dd77348dbab257721 /src/org/traccar/database/GeofenceManager.java
parentcc26f01471506935d6f438a102fbf9478dcebb1b (diff)
parentf82970ac21ec2f050a09493fa7bc46c7178b57c3 (diff)
downloadtrackermap-server-63aa4472c7d851a0b414dd3c295ccce2bc8c827f.tar.gz
trackermap-server-63aa4472c7d851a0b414dd3c295ccce2bc8c827f.tar.bz2
trackermap-server-63aa4472c7d851a0b414dd3c295ccce2bc8c827f.zip
Merge pull request #2030 from Abyss777/master
Link and unlink geofences in web client
Diffstat (limited to 'src/org/traccar/database/GeofenceManager.java')
-rw-r--r--src/org/traccar/database/GeofenceManager.java25
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;