|
|
@ -382,7 +382,7 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point.
|
|
|
|
* Returns last known data points up to the limit if limit is specified. Otherwise returns last known data point.
|
|
|
|
* Limit need to be zero or positive.
|
|
|
|
* Limit parameter needs to be zero or positive.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@GET
|
|
|
|
@GET
|
|
|
|
@Path("/last-known/{type}/{deviceId}")
|
|
|
|
@Path("/last-known/{type}/{deviceId}")
|
|
|
@ -408,11 +408,10 @@ public class DeviceEventManagementServiceImpl implements DeviceEventManagementSe
|
|
|
|
if (limit == 0) {
|
|
|
|
if (limit == 0) {
|
|
|
|
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
|
|
|
|
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, 1);
|
|
|
|
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
|
|
|
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
|
|
|
} else if(limit>0){
|
|
|
|
} else if (limit > 0) {
|
|
|
|
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
|
|
|
|
EventRecords eventRecords = getAllEventsForDevice(sensorTableName, query, sortByFields, 0, limit);
|
|
|
|
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
|
|
|
return Response.status(Response.Status.OK.getStatusCode()).entity(eventRecords).build();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else{
|
|
|
|
|
|
|
|
String errorMessage = "Invalid limit value";
|
|
|
|
String errorMessage = "Invalid limit value";
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
|
|
|
return Response.status(Response.Status.BAD_REQUEST).entity(errorMessage).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|