Return device type and identifier with subscription list

master
prathabanKavin 5 months ago
parent 6099c68d88
commit e024283f25

@ -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;
}

@ -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 " +
@ -1480,19 +1484,20 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
stmt.setInt(3, limit);
stmt.setInt(4, offset);
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
if (groupDetails.getGroupId() == 0) {
groupDetails.setGroupId(rs.getInt("GROUP_ID"));
groupDetails.setGroupName(rs.getString("GROUP_NAME"));
groupDetails.setGroupOwner(rs.getString("GROUP_OWNER"));
}
int deviceId = rs.getInt("DEVICE_ID");
deviceIds.add(deviceId);
deviceOwners.put(deviceId, rs.getString("DEVICE_OWNER"));
deviceStatuses.put(deviceId, rs.getString("DEVICE_STATUS"));
deviceNames.put(deviceId, rs.getString("DEVICE_NAME"));
try (ResultSet rs = stmt.executeQuery()) {
while (rs.next()) {
if (groupDetails.getGroupId() == 0) {
groupDetails.setGroupId(rs.getInt("GROUP_ID"));
groupDetails.setGroupName(rs.getString("GROUP_NAME"));
groupDetails.setGroupOwner(rs.getString("GROUP_OWNER"));
}
int deviceId = rs.getInt("DEVICE_ID");
deviceIds.add(deviceId);
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) {
@ -1505,6 +1510,8 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
groupDetails.setDeviceOwners(deviceOwners);
groupDetails.setDeviceStatuses(deviceStatuses);
groupDetails.setDeviceNames(deviceNames);
groupDetails.setDeviceTypes(deviceTypes);
groupDetails.setDeviceIdentifiers(deviceIdentifiers);
return groupDetails;
}
}
}

@ -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