Return device type and identifier with subscription list

#11349
Lasantha Dharmakeerthi 5 months ago
commit 89b4d3f0a5

@ -40,6 +40,8 @@ public class DeviceSubscriptionData {
private String unsubscribedBy;
private Timestamp unsubscribedTimestamp;
private String deviceName;
private String deviceIdentifier;
private String type;
public String getAction() {
return action;
@ -168,4 +170,20 @@ public class DeviceSubscriptionData {
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDeviceIdentifier() {
return deviceIdentifier;
}
public void setDeviceIdentifier(String deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier;
}
}

@ -1792,6 +1792,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceDetail.setUnsubscribed(subscription.isUnsubscribed());
deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy());
deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp());
deviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId));
deviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId));
status = subscription.getStatus();
switch (status) {
@ -1829,6 +1831,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp());
subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom());
subscribedDeviceDetail.setStatus(subscribedDevice.getStatus());
subscribedDeviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId));
subscribedDeviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId));
subscribedDevices.add(subscribedDeviceDetail);
statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1);
isSubscribedDevice = true;
@ -1841,6 +1845,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId));
newDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId));
newDeviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId));
newDeviceDetail.setType(groupDetailWithDevices.getDeviceTypes().get(deviceId));
newDeviceDetail.setDeviceIdentifier(groupDetailWithDevices.getDeviceIdentifiers().get(deviceId));
newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1);
}
@ -1975,6 +1981,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceDetail.setUnsubscribed(subscription.isUnsubscribed());
deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy());
deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp());
deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes());
deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers());
status = subscription.getStatus();
switch (status) {
@ -2012,6 +2020,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp());
subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom());
subscribedDeviceDetail.setStatus(subscribedDevice.getStatus());
subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes());
subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers());
subscribedDevices.add(subscribedDeviceDetail);
statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1);
isSubscribedDevice = true;
@ -2024,6 +2034,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes());
newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers());
newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1);
}
@ -2166,6 +2178,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceDetail.setUnsubscribed(deviceSubscription.isUnsubscribed());
deviceDetail.setUnsubscribedBy(deviceSubscription.getUnsubscribedBy());
deviceDetail.setUnsubscribedTimestamp(deviceSubscription.getUnsubscribedTimestamp());
deviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes());
deviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers());
status = deviceSubscription.getStatus();
switch (status) {
@ -2203,6 +2217,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp());
subscribedDeviceDetail.setActionType(subscribedDevice.getActionTriggeredFrom());
subscribedDeviceDetail.setStatus(subscribedDevice.getStatus());
subscribedDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes());
subscribedDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers());
subscribedDevices.add(subscribedDeviceDetail);
statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1);
isSubscribedDevice = true;
@ -2215,6 +2231,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
newDeviceDetail.setType(ownerDetailsWithDevices.getDeviceTypes());
newDeviceDetail.setDeviceIdentifier(ownerDetailsWithDevices.getDeviceIdentifiers());
newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1);
}
@ -2359,6 +2377,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceDetail.setUnsubscribed(subscription.isUnsubscribed());
deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy());
deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp());
deviceDetail.setType(ownerWithDevice.getDeviceTypes());
deviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers());
String status = subscription.getStatus();
switch (status) {
@ -2393,6 +2413,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
subscribedDeviceDetail.setActionTriggeredTimestamp(allSubscription.getSubscribedTimestamp());
subscribedDeviceDetail.setActionType(allSubscription.getActionTriggeredFrom());
subscribedDeviceDetail.setStatus(allSubscription.getStatus());
subscribedDeviceDetail.setType(ownerWithDevice.getDeviceTypes());
subscribedDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers());
subscribedDevices.add(subscribedDeviceDetail);
statusCounts.put("SUBSCRIBED", statusCounts.get("SUBSCRIBED") + 1);
}
@ -2402,6 +2424,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceId(deviceId);
newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
newDeviceDetail.setType(ownerWithDevice.getDeviceTypes());
newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers());
newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1);
} else if (!unsubscribe && !allSubscriptionForSubscribedMap.containsKey(deviceId) && !deviceSubscriptionMap.containsKey(deviceId)
@ -2411,6 +2435,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames());
newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
newDeviceDetail.setType(ownerWithDevice.getDeviceTypes());
newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers());
newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1);
}
@ -2521,6 +2547,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceDetail.setUnsubscribed(subscription.isUnsubscribed());
deviceDetail.setUnsubscribedBy(subscription.getUnsubscribedBy());
deviceDetail.setUnsubscribedTimestamp(subscription.getUnsubscribedTimestamp());
deviceDetail.setType(ownerWithDevice.getDeviceTypes());
deviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers());
String status = subscription.getStatus();
switch (status) {
@ -2547,6 +2575,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames());
newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
newDeviceDetail.setType(ownerWithDevice.getDeviceTypes());
newDeviceDetail.setDeviceIdentifier(ownerWithDevice.getDeviceIdentifiers());
newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1);
}

@ -571,7 +571,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
List<Integer> deviceIds = new ArrayList<>();
int deviceCount = 0;
String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " +
String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE AS DEVICE_TYPE, e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION " +
"FROM DM_ENROLMENT e " +
"JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE e.OWNER = ? AND e.TENANT_ID = ?";
@ -600,6 +600,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
ownerDetails.setDeviceIds(deviceIds);
ownerDetails.setDeviceStatus("DEVICE_STATUS");
ownerDetails.setDeviceNames("DEVICE_NAME");
ownerDetails.setDeviceTypes("DEVICE_TYPE");
ownerDetails.setDeviceIdentifiers("DEVICE_IDENTIFICATION");
ownerDetails.setDeviceCount(deviceCount);
return ownerDetails;
}
@ -609,7 +611,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
throws DeviceManagementDAOException {
OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO();
Connection conn = null;
String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " +
String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME, e.DEVICE_TYPE, e.DEVICE_IDENTIFICATION " +
"FROM DM_ENROLMENT e " +
"JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?";
@ -627,6 +629,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
deviceIds.add(rs.getInt("DEVICE_ID"));
deviceOwnerWithStatus.setDeviceIds(deviceIds);
deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME"));
deviceOwnerWithStatus.setDeviceTypes(rs.getString("DEVICE_TYPE"));
deviceOwnerWithStatus.setDeviceIdentifiers(rs.getString("DEVICE_IDENTIFICATION"));
}
}
}
@ -642,7 +646,9 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
public List<DeviceDetailsDTO> getDevicesByTenantId(int tenantId)
throws DeviceManagementDAOException {
List<DeviceDetailsDTO> devices = new ArrayList<>();
String sql = "SELECT DEVICE_ID, OWNER, STATUS FROM DM_ENROLMENT WHERE TENANT_ID = ?";
String sql = "SELECT DEVICE_ID, OWNER, STATUS, DEVICE_TYPE, DEVICE_IDENTIFICATION " +
"FROM DM_ENROLMENT " +
"WHERE TENANT_ID = ?";
Connection conn = null;
try {
@ -656,6 +662,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
device.setDeviceId(rs.getInt("DEVICE_ID"));
device.setOwner(rs.getString("OWNER"));
device.setStatus(rs.getString("STATUS"));
device.setType(rs.getString("DEVICE_TYPE"));
device.setDeviceIdentifier(rs.getString("DEVICE_IDENTIFICATION"));
devices.add(device);
}
}

@ -1451,6 +1451,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
Map<Integer, String> deviceOwners = new HashMap<>();
Map<Integer, String> deviceStatuses = new HashMap<>();
Map<Integer, String> deviceNames = new HashMap<>();
Map<Integer, String> deviceTypes = new HashMap<>();
Map<Integer, String> deviceIdentifiers = new HashMap<>();
String sql =
"SELECT " +
@ -1459,6 +1461,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
" g.OWNER AS GROUP_OWNER, " +
" e.OWNER AS DEVICE_OWNER, " +
" e.STATUS AS DEVICE_STATUS, " +
" e.DEVICE_TYPE AS DEVICE_TYPE, " +
" e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " +
" dgm.DEVICE_ID, " +
" d.NAME AS DEVICE_NAME " +
"FROM " +
@ -1492,19 +1496,23 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER"));
deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS"));
deviceNames.put(deviceId, rs.getString("DEVICE_NAME"));
deviceTypes.put(deviceId, rs.getString("DEVICE_TYPE"));
deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION"));
}
}
}
} catch (SQLException e) {
String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName;
log.error(msg, e);
throw new GroupManagementDAOException(msg, e);
groupDetails.setDeviceIds(deviceIds);
groupDetails.setDeviceCount(deviceIds.size());
groupDetails.setDeviceOwners(deviceOwners);
groupDetails.setDeviceStatuses(deviceStatuses);
groupDetails.setDeviceNames(deviceNames);
groupDetails.setDeviceTypes(deviceTypes);
groupDetails.setDeviceIdentifiers(deviceIdentifiers);
return groupDetails;
}
groupDetails.setDeviceIds(deviceIds);
groupDetails.setDeviceCount(deviceIds.size());
groupDetails.setDeviceOwners(deviceOwners);
groupDetails.setDeviceStatuses(deviceStatuses);
groupDetails.setDeviceNames(deviceNames);
return groupDetails;
} catch (SQLException e) {
String msg = "Error occurred while retrieving group details and device IDs for group: " + groupName;
log.error(msg, e);
throw new GroupManagementDAOException(msg, e);
}
}
}
}

@ -22,6 +22,8 @@ public class DeviceDetailsDTO {
private int deviceId;
private String owner;
private String status;
private String type;
private String deviceIdentifier;
public int getDeviceId() {
return deviceId;
@ -46,4 +48,20 @@ public class DeviceDetailsDTO {
public void setStatus(String status) {
this.status = status;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDeviceIdentifier() {
return deviceIdentifier;
}
public void setDeviceIdentifier(String deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier;
}
}

@ -32,6 +32,8 @@ public class GroupDetailsDTO {
private Map<Integer, String> deviceOwners;
private Map<Integer, String> deviceStatuses;
private Map<Integer, String> deviceNames;
private Map<Integer, String> deviceTypes;
private Map<Integer, String> deviceIdentifiers;
public int getGroupId() {
return groupId;
@ -112,4 +114,20 @@ public class GroupDetailsDTO {
public void setDeviceNames(Map<Integer, String> deviceNames) {
this.deviceNames = deviceNames;
}
public Map<Integer, String> getDeviceTypes() {
return deviceTypes;
}
public void setDeviceTypes(Map<Integer, String> deviceTypes) {
this.deviceTypes = deviceTypes;
}
public Map<Integer, String> getDeviceIdentifiers() {
return deviceIdentifiers;
}
public void setDeviceIdentifiers(Map<Integer, String> deviceIdentifiers) {
this.deviceIdentifiers = deviceIdentifiers;
}
}

@ -27,6 +27,8 @@ public class OwnerWithDeviceDTO {
private int deviceCount;
private String deviceStatus;
private String deviceNames;
private String deviceTypes;
private String deviceIdentifiers;
public String getUserName() {
return userName;
@ -67,4 +69,20 @@ public class OwnerWithDeviceDTO {
public void setDeviceNames(String deviceNames) {
this.deviceNames = deviceNames;
}
public String getDeviceTypes() {
return deviceTypes;
}
public void setDeviceTypes(String deviceTypes) {
this.deviceTypes = deviceTypes;
}
public String getDeviceIdentifiers() {
return deviceIdentifiers;
}
public void setDeviceIdentifiers(String deviceIdentifiers) {
this.deviceIdentifiers = deviceIdentifiers;
}
}

Loading…
Cancel
Save