Merge branch 'master' into 'master'

Add DeviceName to Geo Cluster Locations Details

See merge request entgra/carbon-device-mgt!640
revert-70ac1926
Dharmakeerthi Lasantha 4 years ago
commit 92cca00af0

@ -47,10 +47,10 @@ public class GeoLocationBasedServiceImplTest {
List<GeoCluster> geoClusters = new ArrayList<>(); List<GeoCluster> geoClusters = new ArrayList<>();
geoClusters.add(new GeoCluster(new GeoCoordinate(1.5, 80.7), geoClusters.add(new GeoCluster(new GeoCoordinate(1.5, 80.7),
new GeoCoordinate(1.1, 79.5), new GeoCoordinate(1.9, 82.1), 3, new GeoCoordinate(1.1, 79.5), new GeoCoordinate(1.9, 82.1), 3,
"tb32", "aegtew234", "android", "1234")); "tb32", "aegtew234", "test1", "android", "1234"));
geoClusters.add(new GeoCluster(new GeoCoordinate(10.2, 86.1), geoClusters.add(new GeoCluster(new GeoCoordinate(10.2, 86.1),
new GeoCoordinate(9.8, 84.7), new GeoCoordinate(11.1, 88.1), 4, new GeoCoordinate(9.8, 84.7), new GeoCoordinate(11.1, 88.1), 4,
"t1gd", "swerty12s", "android", "1234")); "t1gd", "swerty12s", "t2test", "android", "1234"));
Mockito.doReturn(geoClusters).when(deviceManagementProviderService) Mockito.doReturn(geoClusters).when(deviceManagementProviderService)
.findGeoClusters(null, Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt()); .findGeoClusters(null, Mockito.any(GeoCoordinate.class), Mockito.any(GeoCoordinate.class), Mockito.anyInt());
Response response = geoLocationBasedService.getGeoDeviceLocations(null, 0.4, 15, 75.6, Response response = geoLocationBasedService.getGeoDeviceLocations(null, 0.4, 15, 75.6,

@ -1733,6 +1733,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
" MAX(DEVICE_LOCATION.LONGITUDE) AS MAX_LONGITUDE," + " MAX(DEVICE_LOCATION.LONGITUDE) AS MAX_LONGITUDE," +
" SUBSTRING(DEVICE_LOCATION.GEO_HASH,1,?) AS GEOHASH_PREFIX, COUNT(*) AS COUNT," + " SUBSTRING(DEVICE_LOCATION.GEO_HASH,1,?) AS GEOHASH_PREFIX, COUNT(*) AS COUNT," +
" MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION," + " MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION," +
" MIN(DEVICE.NAME) AS NAME," +
" MIN(DEVICE_TYPE.NAME) AS TYPE, " + " MIN(DEVICE_TYPE.NAME) AS TYPE, " +
" MIN(DEVICE.LAST_UPDATED_TIMESTAMP) AS LAST_UPDATED_TIMESTAMP " + " MIN(DEVICE.LAST_UPDATED_TIMESTAMP) AS LAST_UPDATED_TIMESTAMP " +
"FROM DM_DEVICE_LOCATION AS DEVICE_LOCATION,DM_DEVICE AS DEVICE, DM_DEVICE_TYPE AS DEVICE_TYPE " + "FROM DM_DEVICE_LOCATION AS DEVICE_LOCATION,DM_DEVICE AS DEVICE, DM_DEVICE_TYPE AS DEVICE_TYPE " +
@ -1763,13 +1764,14 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
double min_longitude = rs.getDouble("MIN_LONGITUDE"); double min_longitude = rs.getDouble("MIN_LONGITUDE");
double max_longitude = rs.getDouble("MAX_LONGITUDE"); double max_longitude = rs.getDouble("MAX_LONGITUDE");
String device_identification = rs.getString("DEVICE_IDENTIFICATION"); String device_identification = rs.getString("DEVICE_IDENTIFICATION");
String device_name = rs.getString("NAME");
String device_type = rs.getString("TYPE"); String device_type = rs.getString("TYPE");
String last_seen = rs.getString("LAST_UPDATED_TIMESTAMP"); String last_seen = rs.getString("LAST_UPDATED_TIMESTAMP");
long count = rs.getLong("COUNT"); long count = rs.getLong("COUNT");
String geohashPrefix = rs.getString("GEOHASH_PREFIX"); String geohashPrefix = rs.getString("GEOHASH_PREFIX");
geoClusters.add(new GeoCluster(new GeoCoordinate(latitude, longitude), geoClusters.add(new GeoCluster(new GeoCoordinate(latitude, longitude),
new GeoCoordinate(min_latitude, min_longitude), new GeoCoordinate(max_latitude, max_longitude), new GeoCoordinate(min_latitude, min_longitude), new GeoCoordinate(max_latitude, max_longitude),
count, geohashPrefix, device_identification, device_type, last_seen)); count, geohashPrefix, device_identification, device_name, device_type, last_seen));
} }
} catch (SQLException e) { } catch (SQLException e) {
throw new DeviceManagementDAOException("Error occurred while retrieving information of " + throw new DeviceManagementDAOException("Error occurred while retrieving information of " +

@ -30,6 +30,8 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.impl.AbstractDeviceDAOImpl; import org.wso2.carbon.device.mgt.core.dao.impl.AbstractDeviceDAOImpl;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.geo.GeoCluster;
import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate;
import org.wso2.carbon.device.mgt.core.report.mgt.Constants; import org.wso2.carbon.device.mgt.core.report.mgt.Constants;
import java.sql.Connection; import java.sql.Connection;

@ -968,6 +968,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ ") AS GEOHASH_PREFIX, " + ") AS GEOHASH_PREFIX, "
+ "COUNT(*) AS COUNT, " + "COUNT(*) AS COUNT, "
+ "MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION, " + "MIN(DEVICE.DEVICE_IDENTIFICATION) AS DEVICE_IDENTIFICATION, "
+ "MIN(DEVICE.NAME) AS NAME, "
+ "MIN(DEVICE_TYPE.NAME) AS TYPE, " + "MIN(DEVICE_TYPE.NAME) AS TYPE, "
+ "MIN(DEVICE.LAST_UPDATED_TIMESTAMP) AS LAST_UPDATED_TIMESTAMP, " + "MIN(DEVICE.LAST_UPDATED_TIMESTAMP) AS LAST_UPDATED_TIMESTAMP, "
+ "COUNT(DEVICE_LOCATION.GEO_HASH) " + "COUNT(DEVICE_LOCATION.GEO_HASH) "
@ -1004,6 +1005,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
double min_longitude = rs.getDouble("MIN_LONGITUDE"); double min_longitude = rs.getDouble("MIN_LONGITUDE");
double max_longitude = rs.getDouble("MAX_LONGITUDE"); double max_longitude = rs.getDouble("MAX_LONGITUDE");
String device_identification = rs.getString("DEVICE_IDENTIFICATION"); String device_identification = rs.getString("DEVICE_IDENTIFICATION");
String device_name = rs.getString("NAME");
String device_type = rs.getString("TYPE"); String device_type = rs.getString("TYPE");
String last_seen = rs.getString("LAST_UPDATED_TIMESTAMP"); String last_seen = rs.getString("LAST_UPDATED_TIMESTAMP");
long count = rs.getLong("COUNT"); long count = rs.getLong("COUNT");
@ -1011,7 +1013,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
geoClusters.add(new GeoCluster(new GeoCoordinate(latitude, longitude), geoClusters.add(new GeoCluster(new GeoCoordinate(latitude, longitude),
new GeoCoordinate(min_latitude, min_longitude), new GeoCoordinate(min_latitude, min_longitude),
new GeoCoordinate(max_latitude, max_longitude), count, geohashPrefix, new GeoCoordinate(max_latitude, max_longitude), count, geohashPrefix,
device_identification, device_type, last_seen)); device_identification, device_name, device_type, last_seen));
} }
} }
} }

@ -9,18 +9,20 @@ public class GeoCluster {
private long count; private long count;
private String geohashPrefix; private String geohashPrefix;
private String deviceIdentification; private String deviceIdentification;
private String deviceName;
private String deviceType; private String deviceType;
private String lastSeen; private String lastSeen;
public GeoCluster(GeoCoordinate coordinates, GeoCoordinate southWestBound, GeoCoordinate northEastBound, long count, public GeoCluster(GeoCoordinate coordinates, GeoCoordinate southWestBound, GeoCoordinate northEastBound, long count,
String geohashPrefix, String deviceIdentification, String deviceType, String lastSeen){ String geohashPrefix, String deviceIdentification, String deviceName, String deviceType, String lastSeen){
this.coordinates=coordinates; this.coordinates=coordinates;
this.southWestBound=southWestBound; this.southWestBound=southWestBound;
this.northEastBound=northEastBound; this.northEastBound=northEastBound;
this.count=count; this.count=count;
this.geohashPrefix=geohashPrefix; this.geohashPrefix=geohashPrefix;
this.deviceIdentification=deviceIdentification; this.deviceIdentification=deviceIdentification;
this.deviceName=deviceName;
this.deviceType=deviceType; this.deviceType=deviceType;
this.lastSeen = lastSeen; this.lastSeen = lastSeen;
@ -50,6 +52,10 @@ public class GeoCluster {
return deviceIdentification; return deviceIdentification;
} }
public String getDeviceName() {
return deviceName;
}
public String getDeviceType() { return deviceType; public String getDeviceType() { return deviceType;
} }

Loading…
Cancel
Save