Merge pull request #697 from GDLMadushanka/master

Virtual fire alarm streams changed
apim420
Ayyoob Hamza 8 years ago committed by GitHub
commit 23d8134340

@ -136,10 +136,10 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
@Produces("application/json") @Produces("application/json")
public Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from, public Response getVirtualFirealarmStats(@PathParam("deviceId") String deviceId, @QueryParam("from") long from,
@QueryParam("to") long to) { @QueryParam("to") long to) {
String fromDate = String.valueOf(from); String fromDate = String.valueOf(from*1000); // converting time to ms
String toDate = String.valueOf(to); String toDate = String.valueOf(to*1000); // converting time to ms
String query = "deviceId:" + deviceId + " AND deviceType:" + String query = "meta_deviceId:" + deviceId + " AND meta_deviceType:" +
VirtualFireAlarmConstants.DEVICE_TYPE + " AND time : [" + fromDate + " TO " + toDate + "]"; VirtualFireAlarmConstants.DEVICE_TYPE + " AND meta_time : [" + fromDate + " TO " + toDate + "]";
String sensorTableName = VirtualFireAlarmConstants.TEMPERATURE_EVENT_TABLE; String sensorTableName = VirtualFireAlarmConstants.TEMPERATURE_EVENT_TABLE;
try { try {
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized( if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(
@ -148,7 +148,7 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
} }
List<SortByField> sortByFields = new ArrayList<>(); List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("time", SortType.ASC); SortByField sortByField = new SortByField("meta_time", SortType.ASC);
sortByFields.add(sortByField); sortByFields.add(sortByField);
List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields); List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build(); return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();

@ -30,7 +30,7 @@ public class VirtualFireAlarmConstants {
public static final String POLICY_CONTEXT = "POLICY"; public static final String POLICY_CONTEXT = "POLICY";
//sensor events sumerized table name for temperature //sensor events sumerized table name for temperature
public static final String TEMPERATURE_EVENT_TABLE = "DEVICE_TEMPERATURE_SUMMARY"; public static final String TEMPERATURE_EVENT_TABLE = "IOT_PER_DEVICE_STREAM_VIRTUALFIREALARM_TEMPERATURE";
public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super"; public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
//mqtt tranport related constants //mqtt tranport related constants

Loading…
Cancel
Save