From e3f117e8fe5a64f586eb18d7fe92cc45b5ce915f Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sat, 23 Apr 2016 00:07:54 +0530 Subject: [PATCH] few changes in virtual firealarm stats api --- .../service/impl/VirtualFireAlarmControllerService.java | 3 +-- .../impl/VirtualFireAlarmControllerServiceImpl.java | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java index a25f7da3c..9c73acf29 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerService.java @@ -106,8 +106,7 @@ public interface VirtualFireAlarmControllerService { @Consumes("application/json") @Produces("application/json") Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, - @PathParam("sensorName") String sensor, - @QueryParam("username") String user, @QueryParam("from") long from, + @PathParam("sensorName") String sensor, @QueryParam("from") long from, @QueryParam("to") long to); } diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java index e7172b38c..a489685ad 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java +++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmControllerServiceImpl.java @@ -179,12 +179,11 @@ public class VirtualFireAlarmControllerServiceImpl implements VirtualFireAlarmCo @Consumes("application/json") @Produces("application/json") public Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, - @PathParam("sensorName") String sensor, - @QueryParam("username") String user, @QueryParam("from") long from, + @PathParam("sensorName") String sensor, @QueryParam("from") long from, @QueryParam("to") long to) { String fromDate = String.valueOf(from); String toDate = String.valueOf(to); - String query = "owner:" + user + " AND deviceId:" + deviceId + " AND deviceType:" + + String query = "deviceId:" + deviceId + " AND deviceType:" + VirtualFireAlarmConstants.DEVICE_TYPE + " AND time : [" + fromDate + " TO " + toDate + "]"; String sensorTableName = getSensorEventTableName(sensor); try { @@ -194,7 +193,7 @@ public class VirtualFireAlarmControllerServiceImpl implements VirtualFireAlarmCo } if (sensorTableName != null) { List sortByFields = new ArrayList<>(); - SortByField sortByField = new SortByField("time", SORT.ASC, false); + SortByField sortByField = new SortByField("time", SORT.DESC, true); sortByFields.add(sortByField); List sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields); return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();