diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-03-23 20:59:09 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2020-03-23 20:59:09 -0700 |
commit | 2816e5ed49e6d237f2a4e48a98cd4a5f1a893246 (patch) | |
tree | ff465c666a3e38f0881b4d3c6169bd475769a8d7 /src/main/java/org/traccar/api | |
parent | f85af44e180c87993d2d8d760f64af775f99531f (diff) | |
download | traccar-server-2816e5ed49e6d237f2a4e48a98cd4a5f1a893246.tar.gz traccar-server-2816e5ed49e6d237f2a4e48a98cd4a5f1a893246.tar.bz2 traccar-server-2816e5ed49e6d237f2a4e48a98cd4a5f1a893246.zip |
Support position for single device
Diffstat (limited to 'src/main/java/org/traccar/api')
-rw-r--r-- | src/main/java/org/traccar/api/resource/PositionResource.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/api/resource/PositionResource.java b/src/main/java/org/traccar/api/resource/PositionResource.java index c031b842f..67aa6dd32 100644 --- a/src/main/java/org/traccar/api/resource/PositionResource.java +++ b/src/main/java/org/traccar/api/resource/PositionResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2020 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. @@ -34,6 +34,7 @@ import javax.ws.rs.core.Response; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; @Path("positions") @@ -63,8 +64,12 @@ public class PositionResource extends BaseResource { return Context.getDeviceManager().getInitialState(getUserId()); } else { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); - return Context.getDataManager().getPositions( - deviceId, DateUtil.parseDate(from), DateUtil.parseDate(to)); + if (from != null && to != null) { + return Context.getDataManager().getPositions( + deviceId, DateUtil.parseDate(from), DateUtil.parseDate(to)); + } else { + return Collections.singleton(Context.getDeviceManager().getLastPosition(deviceId)); + } } } |