Return device type and identifier with subscription list

pull/433/head
prathabanKavin 5 months ago
parent 6099c68d88
commit e024283f25

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

@ -571,7 +571,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
List<Integer> deviceIds = new ArrayList<>(); List<Integer> deviceIds = new ArrayList<>();
int deviceCount = 0; 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 " + "FROM DM_ENROLMENT e " +
"JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " + "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE e.OWNER = ? AND e.TENANT_ID = ?"; "WHERE e.OWNER = ? AND e.TENANT_ID = ?";
@ -600,6 +600,8 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
ownerDetails.setDeviceIds(deviceIds); ownerDetails.setDeviceIds(deviceIds);
ownerDetails.setDeviceStatus("DEVICE_STATUS"); ownerDetails.setDeviceStatus("DEVICE_STATUS");
ownerDetails.setDeviceNames("DEVICE_NAME"); ownerDetails.setDeviceNames("DEVICE_NAME");
ownerDetails.setDeviceTypes("DEVICE_TYPE");
ownerDetails.setDeviceIdentifiers("DEVICE_IDENTIFICATION");
ownerDetails.setDeviceCount(deviceCount); ownerDetails.setDeviceCount(deviceCount);
return ownerDetails; return ownerDetails;
} }

@ -1451,6 +1451,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
Map<Integer, String> deviceOwners = new HashMap<>(); Map<Integer, String> deviceOwners = new HashMap<>();
Map<Integer, String> deviceStatuses = new HashMap<>(); Map<Integer, String> deviceStatuses = new HashMap<>();
Map<Integer, String> deviceNames = new HashMap<>(); Map<Integer, String> deviceNames = new HashMap<>();
Map<Integer, String> deviceTypes = new HashMap<>();
Map<Integer, String> deviceIdentifiers = new HashMap<>();
String sql = String sql =
"SELECT " + "SELECT " +
@ -1459,6 +1461,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
" g.OWNER AS GROUP_OWNER, " + " g.OWNER AS GROUP_OWNER, " +
" e.OWNER AS DEVICE_OWNER, " + " e.OWNER AS DEVICE_OWNER, " +
" e.STATUS AS DEVICE_STATUS, " + " e.STATUS AS DEVICE_STATUS, " +
" e.DEVICE_TYPE AS DEVICE_TYPE, " +
" e.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " +
" dgm.DEVICE_ID, " + " dgm.DEVICE_ID, " +
" d.NAME AS DEVICE_NAME " + " d.NAME AS DEVICE_NAME " +
"FROM " + "FROM " +
@ -1492,7 +1496,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER")); deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER"));
deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS")); deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS"));
deviceNames.put(deviceId, rs.getString("DEVICE_NAME")); deviceNames.put(deviceId, rs.getString("DEVICE_NAME"));
} deviceTypes.put(deviceId, rs.getString("DEVICE_TYPE"));
deviceIdentifiers.put(deviceId, rs.getString("DEVICE_IDENTIFICATION"));
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -1505,6 +1510,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
groupDetails.setDeviceOwners(deviceOwners); groupDetails.setDeviceOwners(deviceOwners);
groupDetails.setDeviceStatuses(deviceStatuses); groupDetails.setDeviceStatuses(deviceStatuses);
groupDetails.setDeviceNames(deviceNames); groupDetails.setDeviceNames(deviceNames);
groupDetails.setDeviceTypes(deviceTypes);
groupDetails.setDeviceIdentifiers(deviceIdentifiers);
return groupDetails; return groupDetails;
} }
} }

@ -32,6 +32,8 @@ public class GroupDetailsDTO {
private Map<Integer, String> deviceOwners; private Map<Integer, String> deviceOwners;
private Map<Integer, String> deviceStatuses; private Map<Integer, String> deviceStatuses;
private Map<Integer, String> deviceNames; private Map<Integer, String> deviceNames;
private Map<Integer, String> deviceTypes;
private Map<Integer, String> deviceIdentifiers;
public int getGroupId() { public int getGroupId() {
return groupId; return groupId;
@ -112,4 +114,20 @@ public class GroupDetailsDTO {
public void setDeviceNames(Map<Integer, String> deviceNames) { public void setDeviceNames(Map<Integer, String> deviceNames) {
this.deviceNames = 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 int deviceCount;
private String deviceStatus; private String deviceStatus;
private String deviceNames; private String deviceNames;
private String deviceTypes;
private String deviceIdentifiers;
public String getUserName() { public String getUserName() {
return userName; return userName;
@ -67,4 +69,20 @@ public class OwnerWithDeviceDTO {
public void setDeviceNames(String deviceNames) { public void setDeviceNames(String deviceNames) {
this.deviceNames = 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