Generalize JSON keys of application subscription APIs.

appm_improvement
Nipuni Kavindya 5 months ago committed by prathabanKavin
parent e3e0e6de3d
commit 6db42a0f4b

@ -39,6 +39,7 @@ public class DeviceSubscriptionData {
private boolean unsubscribed; private boolean unsubscribed;
private String unsubscribedBy; private String unsubscribedBy;
private Timestamp unsubscribedTimestamp; private Timestamp unsubscribedTimestamp;
private String deviceName;
public String getAction() { public String getAction() {
return action; return action;
@ -159,4 +160,12 @@ public class DeviceSubscriptionData {
public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) { public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) {
this.unsubscribedTimestamp = unsubscribedTimestamp; this.unsubscribedTimestamp = unsubscribedTimestamp;
} }
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
} }

@ -5,9 +5,7 @@ import java.util.List;
public class SubscriptionResponseDTO { public class SubscriptionResponseDTO {
private String UUID; private String UUID;
private List<GroupSubscriptionDetailDTO> GroupsSubscriptions; private List<SubscriptionsDTO> subscriptions;
private List<UserSubscriptionDTO> UserSubscriptions;
private List<RoleSubscriptionDTO> RolesSubscriptions;
private List<DeviceOperationDTO> DevicesOperations; private List<DeviceOperationDTO> DevicesOperations;
public String getUUID() { public String getUUID() {
@ -18,30 +16,6 @@ public class SubscriptionResponseDTO {
this.UUID = UUID; this.UUID = UUID;
} }
public List<GroupSubscriptionDetailDTO> getGroupsSubscriptions() {
return GroupsSubscriptions;
}
public void setGroupsSubscriptions(List<GroupSubscriptionDetailDTO> groupsSubscriptions) {
GroupsSubscriptions = groupsSubscriptions;
}
public List<UserSubscriptionDTO> getUserSubscriptions() {
return UserSubscriptions;
}
public void setUserSubscriptions(List<UserSubscriptionDTO> userSubscriptions) {
UserSubscriptions = userSubscriptions;
}
public List<RoleSubscriptionDTO> getRolesSubscriptions() {
return RolesSubscriptions;
}
public void setRolesSubscriptions(List<RoleSubscriptionDTO> rolesSubscriptions) {
RolesSubscriptions = rolesSubscriptions;
}
public List<DeviceOperationDTO> getDevicesOperations() { public List<DeviceOperationDTO> getDevicesOperations() {
return DevicesOperations; return DevicesOperations;
} }
@ -49,4 +23,12 @@ public class SubscriptionResponseDTO {
public void setDevicesOperations(List<DeviceOperationDTO> devicesOperations) { public void setDevicesOperations(List<DeviceOperationDTO> devicesOperations) {
DevicesOperations = devicesOperations; DevicesOperations = devicesOperations;
} }
public List<SubscriptionsDTO> getSubscriptions() {
return subscriptions;
}
public void setSubscriptions(List<SubscriptionsDTO> subscriptions) {
this.subscriptions = subscriptions;
}
} }

@ -23,45 +23,45 @@ import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionR
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Map; import java.util.Map;
public class GroupSubscriptionDetailDTO { public class SubscriptionsDTO {
private int groupId; private int id;
private String groupName; private String owner;
private String groupOwner; private String name;
private String subscribedBy; private String subscribedBy;
private Timestamp subscribedTimestamp; private Timestamp subscribedTimestamp;
private boolean isUnsubscribed; private boolean unsubscribed;
private String unsubscribedBy; private String unsubscribedBy;
private Timestamp unsubscribedTimestamp; private Timestamp unsubscribedTimestamp;
private String subscribedFrom;
private int appReleaseId; private int appReleaseId;
private int deviceCount; private int deviceCount;
private String deviceOwner; private String deviceOwner;
private String deviceStatus; private String deviceStatus;
private CategorizedSubscriptionResult devices;
private Map<String, Double> statusPercentages; private Map<String, Double> statusPercentages;
private CategorizedSubscriptionResult devices;
// Getters and Setters public int getId() {
public int getGroupId() { return id;
return groupId;
} }
public void setGroupId(int groupId) { public void setId(int id) {
this.groupId = groupId; this.id = id;
} }
public String getGroupName() { public String getOwner() {
return groupName; return owner;
} }
public void setGroupName(String groupName) { public void setOwner(String owner) {
this.groupName = groupName; this.owner = owner;
} }
public String getGroupOwner() { public String getName() {
return groupOwner; return name;
} }
public void setGroupOwner(String groupOwner) { public void setName(String name) {
this.groupOwner = groupOwner; this.name = name;
} }
public String getSubscribedBy() { public String getSubscribedBy() {
@ -80,14 +80,6 @@ public class GroupSubscriptionDetailDTO {
this.subscribedTimestamp = subscribedTimestamp; this.subscribedTimestamp = subscribedTimestamp;
} }
public boolean isUnsubscribed() {
return isUnsubscribed;
}
public void setUnsubscribed(boolean unsubscribed) {
isUnsubscribed = unsubscribed;
}
public String getUnsubscribedBy() { public String getUnsubscribedBy() {
return unsubscribedBy; return unsubscribedBy;
} }
@ -104,6 +96,14 @@ public class GroupSubscriptionDetailDTO {
this.unsubscribedTimestamp = unsubscribedTimestamp; this.unsubscribedTimestamp = unsubscribedTimestamp;
} }
public String getSubscribedFrom() {
return subscribedFrom;
}
public void setSubscribedFrom(String subscribedFrom) {
this.subscribedFrom = subscribedFrom;
}
public int getAppReleaseId() { public int getAppReleaseId() {
return appReleaseId; return appReleaseId;
} }
@ -120,12 +120,20 @@ public class GroupSubscriptionDetailDTO {
this.deviceCount = deviceCount; this.deviceCount = deviceCount;
} }
public CategorizedSubscriptionResult getDevices() { public String getDeviceOwner() {
return devices; return deviceOwner;
} }
public void setDevices(CategorizedSubscriptionResult devices) { public void setDeviceOwner(String deviceOwner) {
this.devices = devices; this.deviceOwner = deviceOwner;
}
public String getDeviceStatus() {
return deviceStatus;
}
public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus;
} }
public Map<String, Double> getStatusPercentages() { public Map<String, Double> getStatusPercentages() {
@ -136,19 +144,19 @@ public class GroupSubscriptionDetailDTO {
this.statusPercentages = statusPercentages; this.statusPercentages = statusPercentages;
} }
public String getDeviceOwner() { public CategorizedSubscriptionResult getDevices() {
return deviceOwner; return devices;
} }
public void setDeviceOwner(String deviceOwner) { public void setDevices(CategorizedSubscriptionResult devices) {
this.deviceOwner = deviceOwner; this.devices = devices;
} }
public String getDeviceStatus() { public boolean getUnsubscribed() {
return deviceStatus; return unsubscribed;
} }
public void setDeviceStatus(String deviceStatus) { public void setUnsubscribed(boolean unsubscribed) {
this.deviceStatus = deviceStatus; this.unsubscribed = unsubscribed;
} }
} }

@ -1,132 +0,0 @@
/*
* Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.entgra.device.mgt.core.application.mgt.common.dto;
import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionResult;
import java.sql.Timestamp;
import java.util.Map;
public class UserSubscriptionDTO {
private String userName;
private String subscribedBy;
private Timestamp subscribedTimestamp;
private boolean unsubscribed;
private String unsubscribedBy;
private Timestamp unsubscribedTimestamp;
private int appReleaseId;
private int deviceCount;
private String deviceStatus;
private Map<String, Double> statusPercentages;
private CategorizedSubscriptionResult devices;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getSubscribedBy() {
return subscribedBy;
}
public void setSubscribedBy(String subscribedBy) {
this.subscribedBy = subscribedBy;
}
public Timestamp getSubscribedTimestamp() {
return subscribedTimestamp;
}
public void setSubscribedTimestamp(Timestamp subscribedTimestamp) {
this.subscribedTimestamp = subscribedTimestamp;
}
public boolean isUnsubscribed() {
return unsubscribed;
}
public boolean getUnsubscribed() {
return unsubscribed;
}
public void setUnsubscribed(boolean unsubscribed) {
this.unsubscribed = unsubscribed;
}
public String getUnsubscribedBy() {
return unsubscribedBy;
}
public void setUnsubscribedBy(String unsubscribedBy) {
this.unsubscribedBy = unsubscribedBy;
}
public Timestamp getUnsubscribedTimestamp() {
return unsubscribedTimestamp;
}
public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) {
this.unsubscribedTimestamp = unsubscribedTimestamp;
}
public int getAppReleaseId() {
return appReleaseId;
}
public void setAppReleaseId(int appReleaseId) {
this.appReleaseId = appReleaseId;
}
public int getDeviceCount() {
return deviceCount;
}
public void setDeviceCount(int deviceCount) {
this.deviceCount = deviceCount;
}
public Map<String, Double> getStatusPercentages() {
return statusPercentages;
}
public void setStatusPercentages(Map<String, Double> statusPercentages) {
this.statusPercentages = statusPercentages;
}
public CategorizedSubscriptionResult getDevices() {
return devices;
}
public void setDevices(CategorizedSubscriptionResult devices) {
this.devices = devices;
}
public String getDeviceStatus() {
return deviceStatus;
}
public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus;
}
}

@ -22,10 +22,8 @@ import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionR
import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus;
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType; import io.entgra.device.mgt.core.application.mgt.common.SubscriptionType;
import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDetailDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.UserSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.RoleSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionResponseDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionResponseDTO;
import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException;
@ -232,10 +230,10 @@ public interface SubscriptionManager {
* @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed)
* @param offset the offset for the data set * @param offset the offset for the data set
* @param limit the limit for the data set * @param limit the limit for the data set
* @return {@link GroupSubscriptionDetailDTO} which contains the details of group subscriptions. * @return {@link SubscriptionsDTO} which contains the details of subscriptions.
* @throws ApplicationManagementException if an error occurs while fetching the group details * @throws ApplicationManagementException if an error occurs while fetching the group details
*/ */
List<GroupSubscriptionDetailDTO> getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit) List<SubscriptionsDTO> getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, int limit)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**
@ -245,10 +243,10 @@ public interface SubscriptionManager {
* @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed)
* @param offset the offset for the data set * @param offset the offset for the data set
* @param limit the limit for the data set * @param limit the limit for the data set
* @return {@link UserSubscriptionDTO} which contains the details of user subscriptions. * @return {@link SubscriptionsDTO} which contains the details of subscriptions.
* @throws ApplicationManagementException if an error occurs while fetching the user details * @throws ApplicationManagementException if an error occurs while fetching the user details
*/ */
List<UserSubscriptionDTO> getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) List<SubscriptionsDTO> getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**
@ -258,10 +256,10 @@ public interface SubscriptionManager {
* @param subscriptionStatus the status of the subscription (subscribed or unsubscribed) * @param subscriptionStatus the status of the subscription (subscribed or unsubscribed)
* @param offset the offset for the data set * @param offset the offset for the data set
* @param limit the limit for the data set * @param limit the limit for the data set
* @return {@link RoleSubscriptionDTO} which contains the details of role subscriptions. * @return {@link SubscriptionsDTO} which contains the details of subscriptions.
* @throws ApplicationManagementException if an error occurs while fetching the role details * @throws ApplicationManagementException if an error occurs while fetching the role details
*/ */
List<RoleSubscriptionDTO> getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) List<SubscriptionsDTO> getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**

@ -19,11 +19,10 @@ package io.entgra.device.mgt.core.application.mgt.core.dao;
import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus; import io.entgra.device.mgt.core.application.mgt.common.ExecutionStatus;
import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.UserSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.RoleSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.ScheduledSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException; import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionManagementException;
import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException;
@ -339,10 +338,10 @@ public interface SubscriptionDAO {
* @param tenantId id of the current tenant. * @param tenantId id of the current tenant.
* @param offset the offset for the data set * @param offset the offset for the data set
* @param limit the limit for the data set * @param limit the limit for the data set
* @return {@link UserSubscriptionDTO} which contains the details of user subscriptions. * @return {@link SubscriptionsDTO} which contains the details of subscriptions.
* @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails.
*/ */
List<UserSubscriptionDTO> getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, List<SubscriptionsDTO> getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId,
int offset, int limit) throws ApplicationManagementDAOException; int offset, int limit) throws ApplicationManagementDAOException;
/** /**
@ -353,10 +352,10 @@ public interface SubscriptionDAO {
* @param tenantId id of the current tenant. * @param tenantId id of the current tenant.
* @param offset the offset for the data set * @param offset the offset for the data set
* @param limit the limit for the data set * @param limit the limit for the data set
* @return {@link RoleSubscriptionDTO} which contains the details of role subscriptions. * @return {@link SubscriptionsDTO} which contains the details of subscriptions.
* @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails.
*/ */
List<RoleSubscriptionDTO> getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit) List<SubscriptionsDTO> getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, int limit)
throws ApplicationManagementDAOException; throws ApplicationManagementDAOException;
/** /**

@ -19,8 +19,7 @@ package io.entgra.device.mgt.core.application.mgt.core.dao.impl.subscription;
import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.RoleSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.UserSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO; import io.entgra.device.mgt.core.application.mgt.core.dao.SubscriptionDAO;
import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.device.mgt.core.application.mgt.core.dao.impl.AbstractDAOImpl;
import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException; import io.entgra.device.mgt.core.application.mgt.core.exception.UnexpectedServerErrorException;
@ -1694,14 +1693,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
} }
@Override @Override
public List<UserSubscriptionDTO> getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, public List<SubscriptionsDTO> getUserSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId,
int offset, int limit) throws ApplicationManagementDAOException { int offset, int limit) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get user subscriptions related to the given UUID."); log.debug("Request received in DAO Layer to get user subscriptions related to the given UUID.");
} }
try { try {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
List<UserSubscriptionDTO> userSubscriptions = new ArrayList<>(); List<SubscriptionsDTO> userSubscriptions = new ArrayList<>();
String subscriptionStatusTime = unsubscribe ? "US.UNSUBSCRIBED_TIMESTAMP" : "US.SUBSCRIBED_TIMESTAMP"; String subscriptionStatusTime = unsubscribe ? "US.UNSUBSCRIBED_TIMESTAMP" : "US.SUBSCRIBED_TIMESTAMP";
String sql = "SELECT US.USER_NAME, US.SUBSCRIBED_BY, US.SUBSCRIBED_TIMESTAMP, US.UNSUBSCRIBED, " + String sql = "SELECT US.USER_NAME, US.SUBSCRIBED_BY, US.SUBSCRIBED_TIMESTAMP, US.UNSUBSCRIBED, " +
@ -1718,9 +1717,9 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
ps.setInt(5, offset); ps.setInt(5, offset);
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) { while (rs.next()) {
UserSubscriptionDTO userSubscription; SubscriptionsDTO userSubscription;
userSubscription = new UserSubscriptionDTO(); userSubscription = new SubscriptionsDTO();
userSubscription.setUserName(rs.getString("USER_NAME")); userSubscription.setName(rs.getString("USER_NAME"));
userSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); userSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY"));
userSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); userSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP"));
userSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); userSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED"));
@ -1745,14 +1744,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
} }
@Override @Override
public List<RoleSubscriptionDTO> getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset, public List<SubscriptionsDTO> getRoleSubscriptionsByAppReleaseID(int appReleaseId, boolean unsubscribe, int tenantId, int offset,
int limit) throws ApplicationManagementDAOException { int limit) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get role subscriptions related to the given AppReleaseID."); log.debug("Request received in DAO Layer to get role subscriptions related to the given AppReleaseID.");
} }
try { try {
Connection conn = this.getDBConnection(); Connection conn = this.getDBConnection();
List<RoleSubscriptionDTO> roleSubscriptions = new ArrayList<>(); List<SubscriptionsDTO> roleSubscriptions = new ArrayList<>();
String subscriptionStatusTime = unsubscribe ? "ARS.UNSUBSCRIBED_TIMESTAMP" : "ARS.SUBSCRIBED_TIMESTAMP"; String subscriptionStatusTime = unsubscribe ? "ARS.UNSUBSCRIBED_TIMESTAMP" : "ARS.SUBSCRIBED_TIMESTAMP";
String sql = "SELECT ARS.ROLE_NAME, ARS.SUBSCRIBED_BY, ARS.SUBSCRIBED_TIMESTAMP, ARS.UNSUBSCRIBED, " + String sql = "SELECT ARS.ROLE_NAME, ARS.SUBSCRIBED_BY, ARS.SUBSCRIBED_TIMESTAMP, ARS.UNSUBSCRIBED, " +
@ -1768,10 +1767,10 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
ps.setInt(4, limit); ps.setInt(4, limit);
ps.setInt(5, offset); ps.setInt(5, offset);
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {
RoleSubscriptionDTO roleSubscription; SubscriptionsDTO roleSubscription;
while (rs.next()) { while (rs.next()) {
roleSubscription = new RoleSubscriptionDTO(); roleSubscription = new SubscriptionsDTO();
roleSubscription.setRoleName(rs.getString("ROLE_NAME")); roleSubscription.setName(rs.getString("ROLE_NAME"));
roleSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY")); roleSubscription.setSubscribedBy(rs.getString("SUBSCRIBED_BY"));
roleSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP")); roleSubscription.setSubscribedTimestamp(rs.getTimestamp("SUBSCRIBED_TIMESTAMP"));
roleSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED")); roleSubscription.setUnsubscribed(rs.getBoolean("UNSUBSCRIBED"));

@ -26,9 +26,7 @@ import io.entgra.device.mgt.core.application.mgt.common.CategorizedSubscriptionR
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData; import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData;
import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.CategorizedSubscriptionCountsDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.GroupSubscriptionDetailDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.UserSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.RoleSubscriptionDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceOperationDTO;
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionResponseDTO; import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionResponseDTO;
import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes; import io.entgra.device.mgt.core.application.mgt.common.DeviceTypes;
@ -1706,8 +1704,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
@Override @Override
public List<GroupSubscriptionDetailDTO> getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset, public List<SubscriptionsDTO> getGroupsSubscriptionDetailsByUUID(String uuid, String subscriptionStatus, int offset,
int limit) throws ApplicationManagementException { int limit) throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); boolean unsubscribe = subscriptionStatus.equals("unsubscribed");
String groupName; String groupName;
@ -1724,7 +1722,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
int appReleaseId = applicationReleaseDTO.getId(); int appReleaseId = applicationReleaseDTO.getId();
List<GroupSubscriptionDetailDTO> groupDetailsWithDevices = new ArrayList<>(); List<SubscriptionsDTO> groupDetailsWithDevices = new ArrayList<>();
List<GroupSubscriptionDTO> groupDetails = List<GroupSubscriptionDTO> groupDetails =
subscriptionDAO.getGroupsSubscriptionDetailsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); subscriptionDAO.getGroupsSubscriptionDetailsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit);
@ -1741,10 +1739,10 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
GroupDetailsDTO groupDetailWithDevices = GroupDetailsDTO groupDetailWithDevices =
groupManagementProviderService.getGroupDetailsWithDevices(groupName, offset, limit); groupManagementProviderService.getGroupDetailsWithDevices(groupName, offset, limit);
GroupSubscriptionDetailDTO groupDetailDTO = new GroupSubscriptionDetailDTO(); SubscriptionsDTO groupDetailDTO = new SubscriptionsDTO();
groupDetailDTO.setGroupId(groupDetailWithDevices.getGroupId()); groupDetailDTO.setId(groupDetailWithDevices.getGroupId());
groupDetailDTO.setGroupName(groupDetail.getGroupName()); groupDetailDTO.setName(groupDetail.getGroupName());
groupDetailDTO.setGroupOwner(groupDetailWithDevices.getGroupOwner()); groupDetailDTO.setOwner(groupDetailWithDevices.getGroupOwner());
groupDetailDTO.setSubscribedBy(groupDetail.getSubscribedBy()); groupDetailDTO.setSubscribedBy(groupDetail.getSubscribedBy());
groupDetailDTO.setSubscribedTimestamp(groupDetail.getSubscribedTimestamp()); groupDetailDTO.setSubscribedTimestamp(groupDetail.getSubscribedTimestamp());
groupDetailDTO.setUnsubscribed(groupDetail.isUnsubscribed()); groupDetailDTO.setUnsubscribed(groupDetail.isUnsubscribed());
@ -1787,6 +1785,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceDetail.setActionType(subscription.getActionTriggeredFrom()); deviceDetail.setActionType(subscription.getActionTriggeredFrom());
deviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); deviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId));
deviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); deviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId));
deviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId));
deviceDetail.setSubId(subscription.getId()); deviceDetail.setSubId(subscription.getId());
deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy()); deviceDetail.setActionTriggeredBy(subscription.getSubscribedBy());
deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp()); deviceDetail.setActionTriggeredTimestamp(subscription.getSubscribedTimestamp());
@ -1824,6 +1823,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId());
subscribedDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId)); subscribedDeviceDetail.setDeviceOwner(groupDetailWithDevices.getDeviceOwners().get(deviceId));
subscribedDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId)); subscribedDeviceDetail.setDeviceStatus(groupDetailWithDevices.getDeviceStatuses().get(deviceId));
subscribedDeviceDetail.setDeviceName(groupDetailWithDevices.getDeviceNames().get(deviceId));
subscribedDeviceDetail.setSubId(subscribedDevice.getId()); subscribedDeviceDetail.setSubId(subscribedDevice.getId());
subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy()); subscribedDeviceDetail.setActionTriggeredBy(subscribedDevice.getSubscribedBy());
subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp()); subscribedDeviceDetail.setActionTriggeredTimestamp(subscribedDevice.getSubscribedTimestamp());
@ -1840,6 +1840,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceId(deviceId); newDeviceDetail.setDeviceId(deviceId);
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));
newDevices.add(newDeviceDetail); newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1); statusCounts.put("NEW", statusCounts.get("NEW") + 1);
} }
@ -1886,7 +1887,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
@Override @Override
public List<UserSubscriptionDTO> getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) public List<SubscriptionsDTO> getUserSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); boolean unsubscribe = subscriptionStatus.equals("unsubscribed");
@ -1904,9 +1905,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
int appReleaseId = applicationReleaseDTO.getId(); int appReleaseId = applicationReleaseDTO.getId();
List<UserSubscriptionDTO> userSubscriptionsWithDevices = new ArrayList<>(); List<SubscriptionsDTO> userSubscriptionsWithDevices = new ArrayList<>();
List<UserSubscriptionDTO> userSubscriptions = List<SubscriptionsDTO> userSubscriptions =
subscriptionDAO.getUserSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); subscriptionDAO.getUserSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit);
if (userSubscriptions == null) { if (userSubscriptions == null) {
throw new ApplicationManagementException("User details not found for appReleaseId: " + appReleaseId); throw new ApplicationManagementException("User details not found for appReleaseId: " + appReleaseId);
@ -1914,15 +1915,15 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService();
for (UserSubscriptionDTO userSubscription : userSubscriptions) { for (SubscriptionsDTO userSubscription : userSubscriptions) {
userName = userSubscription.getUserName(); userName = userSubscription.getName();
// Retrieve owner details and device IDs for the user using the service layer // Retrieve owner details and device IDs for the user using the service layer
OwnerWithDeviceDTO ownerDetailsWithDevices = OwnerWithDeviceDTO ownerDetailsWithDevices =
deviceManagementProviderService.getOwnersWithDeviceIds(userName); deviceManagementProviderService.getOwnersWithDeviceIds(userName);
UserSubscriptionDTO userSubscriptionDTO = new UserSubscriptionDTO(); SubscriptionsDTO userSubscriptionDTO = new SubscriptionsDTO();
userSubscriptionDTO.setUserName(userSubscription.getUserName()); userSubscriptionDTO.setName(userSubscription.getName());
userSubscriptionDTO.setSubscribedBy(userSubscription.getSubscribedBy()); userSubscriptionDTO.setSubscribedBy(userSubscription.getSubscribedBy());
userSubscriptionDTO.setSubscribedTimestamp(userSubscription.getSubscribedTimestamp()); userSubscriptionDTO.setSubscribedTimestamp(userSubscription.getSubscribedTimestamp());
userSubscriptionDTO.setUnsubscribed(userSubscription.getUnsubscribed()); userSubscriptionDTO.setUnsubscribed(userSubscription.getUnsubscribed());
@ -1964,6 +1965,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
deviceDetail.setSubId(subscription.getId()); deviceDetail.setSubId(subscription.getId());
deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
deviceDetail.setActionType(subscription.getActionTriggeredFrom()); deviceDetail.setActionType(subscription.getActionTriggeredFrom());
deviceDetail.setStatus(subscription.getStatus()); deviceDetail.setStatus(subscription.getStatus());
deviceDetail.setActionType(subscription.getActionTriggeredFrom()); deviceDetail.setActionType(subscription.getActionTriggeredFrom());
@ -2001,6 +2003,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (subscribedDevice.getDeviceId() == deviceId) { if (subscribedDevice.getDeviceId() == deviceId) {
DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData();
subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId());
subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
subscribedDeviceDetail.setSubId(subscribedDevice.getId()); subscribedDeviceDetail.setSubId(subscribedDevice.getId());
@ -2019,6 +2022,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
newDeviceDetail.setDeviceId(deviceId); newDeviceDetail.setDeviceId(deviceId);
newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
newDevices.add(newDeviceDetail); newDevices.add(newDeviceDetail);
statusCounts.put("NEW", statusCounts.get("NEW") + 1); statusCounts.put("NEW", statusCounts.get("NEW") + 1);
} }
@ -2063,7 +2067,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
@Override @Override
public List<RoleSubscriptionDTO> getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit) public List<SubscriptionsDTO> getRoleSubscriptionsByUUID(String uuid, String subscriptionStatus, int offset, int limit)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
boolean unsubscribe = subscriptionStatus.equals("unsubscribed"); boolean unsubscribe = subscriptionStatus.equals("unsubscribed");
@ -2081,9 +2085,9 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
int appReleaseId = applicationReleaseDTO.getId(); int appReleaseId = applicationReleaseDTO.getId();
List<RoleSubscriptionDTO> roleSubscriptionsWithDevices = new ArrayList<>(); List<SubscriptionsDTO> roleSubscriptionsWithDevices = new ArrayList<>();
List<RoleSubscriptionDTO> roleSubscriptions = List<SubscriptionsDTO> roleSubscriptions =
subscriptionDAO.getRoleSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit); subscriptionDAO.getRoleSubscriptionsByAppReleaseID(appReleaseId, unsubscribe, tenantId, offset, limit);
if (roleSubscriptions == null) { if (roleSubscriptions == null) {
throw new ApplicationManagementException("Role details not found for appReleaseId: " + appReleaseId); throw new ApplicationManagementException("Role details not found for appReleaseId: " + appReleaseId);
@ -2091,11 +2095,11 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService();
for (RoleSubscriptionDTO roleSubscription : roleSubscriptions) { for (SubscriptionsDTO roleSubscription : roleSubscriptions) {
roleName = roleSubscription.getRoleName(); roleName = roleSubscription.getName();
RoleSubscriptionDTO roleSubscriptionDTO = new RoleSubscriptionDTO(); SubscriptionsDTO roleSubscriptionDTO = new SubscriptionsDTO();
roleSubscriptionDTO.setRoleName(roleSubscription.getRoleName()); roleSubscriptionDTO.setName(roleSubscription.getName());
roleSubscriptionDTO.setSubscribedBy(roleSubscription.getSubscribedBy()); roleSubscriptionDTO.setSubscribedBy(roleSubscription.getSubscribedBy());
roleSubscriptionDTO.setSubscribedTimestamp(roleSubscription.getSubscribedTimestamp()); roleSubscriptionDTO.setSubscribedTimestamp(roleSubscription.getSubscribedTimestamp());
roleSubscriptionDTO.setUnsubscribed(roleSubscription.getUnsubscribed()); roleSubscriptionDTO.setUnsubscribed(roleSubscription.getUnsubscribed());
@ -2148,6 +2152,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (deviceSubscription.getDeviceId() == deviceId) { if (deviceSubscription.getDeviceId() == deviceId) {
DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData();
deviceDetail.setDeviceId(deviceSubscription.getDeviceId()); deviceDetail.setDeviceId(deviceSubscription.getDeviceId());
deviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); deviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); deviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom()); deviceDetail.setActionType(deviceSubscription.getActionTriggeredFrom());
@ -2188,6 +2193,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (subscribedDevice.getDeviceId() == deviceId) { if (subscribedDevice.getDeviceId() == deviceId) {
DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData();
subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId()); subscribedDeviceDetail.setDeviceId(subscribedDevice.getDeviceId());
subscribedDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); subscribedDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); subscribedDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
subscribedDeviceDetail.setSubId(subscribedDevice.getId()); subscribedDeviceDetail.setSubId(subscribedDevice.getId());
@ -2204,6 +2210,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (!isSubscribedDevice) { if (!isSubscribedDevice) {
DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData();
newDeviceDetail.setDeviceId(deviceId); newDeviceDetail.setDeviceId(deviceId);
newDeviceDetail.setDeviceName(ownerDetailsWithDevices.getDeviceNames());
newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName()); newDeviceDetail.setDeviceOwner(ownerDetailsWithDevices.getUserName());
newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus()); newDeviceDetail.setDeviceStatus(ownerDetailsWithDevices.getDeviceStatus());
newDevices.add(newDeviceDetail); newDevices.add(newDeviceDetail);
@ -2339,6 +2346,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData();
deviceDetail.setDeviceId(subscription.getDeviceId()); deviceDetail.setDeviceId(subscription.getDeviceId());
deviceDetail.setSubId(subscription.getId()); deviceDetail.setSubId(subscription.getId());
deviceDetail.setDeviceName(ownerWithDevice.getDeviceNames());
deviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); deviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
deviceDetail.setActionType(subscription.getActionTriggeredFrom()); deviceDetail.setActionType(subscription.getActionTriggeredFrom());
@ -2374,6 +2382,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
if (!allSubscription.isUnsubscribed()) { if (!allSubscription.isUnsubscribed()) {
DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData subscribedDeviceDetail = new DeviceSubscriptionData();
subscribedDeviceDetail.setDeviceId(allSubscription.getDeviceId()); subscribedDeviceDetail.setDeviceId(allSubscription.getDeviceId());
subscribedDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames());
subscribedDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); subscribedDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
subscribedDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); subscribedDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
subscribedDeviceDetail.setSubId(allSubscription.getId()); subscribedDeviceDetail.setSubId(allSubscription.getId());
@ -2396,6 +2405,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
&& (allDevicesMap.containsKey(deviceId))) { && (allDevicesMap.containsKey(deviceId))) {
DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData();
newDeviceDetail.setDeviceId(deviceId); newDeviceDetail.setDeviceId(deviceId);
newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames());
newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
newDevices.add(newDeviceDetail); newDevices.add(newDeviceDetail);
@ -2496,6 +2506,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
DeviceSubscriptionDTO subscription = allSubscriptionMap.get(deviceId); DeviceSubscriptionDTO subscription = allSubscriptionMap.get(deviceId);
DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData deviceDetail = new DeviceSubscriptionData();
deviceDetail.setDeviceId(subscription.getDeviceId()); deviceDetail.setDeviceId(subscription.getDeviceId());
deviceDetail.setDeviceName(ownerWithDevice.getDeviceNames());
deviceDetail.setSubId(subscription.getId()); deviceDetail.setSubId(subscription.getId());
deviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); deviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); deviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
@ -2529,6 +2540,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} else { } else {
DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData(); DeviceSubscriptionData newDeviceDetail = new DeviceSubscriptionData();
newDeviceDetail.setDeviceId(deviceId); newDeviceDetail.setDeviceId(deviceId);
newDeviceDetail.setDeviceName(ownerWithDevice.getDeviceNames());
newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName()); newDeviceDetail.setDeviceOwner(ownerWithDevice.getUserName());
newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus()); newDeviceDetail.setDeviceStatus(ownerWithDevice.getDeviceStatus());
newDevices.add(newDeviceDetail); newDevices.add(newDeviceDetail);

@ -567,9 +567,10 @@ 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 DEVICE_ID, OWNER, STATUS AS DEVICE_STATUS " + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " +
"FROM DM_ENROLMENT " + "FROM DM_ENROLMENT e " +
"WHERE OWNER = ? AND TENANT_ID = ?"; "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE e.OWNER = ? AND e.TENANT_ID = ?";
try (Connection conn = this.getConnection(); try (Connection conn = this.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) { PreparedStatement stmt = conn.prepareStatement(sql)) {
@ -591,6 +592,7 @@ 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.setDeviceCount(deviceCount); ownerDetails.setDeviceCount(deviceCount);
return ownerDetails; return ownerDetails;
} }
@ -600,9 +602,10 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
throws DeviceManagementDAOException { throws DeviceManagementDAOException {
OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO(); OwnerWithDeviceDTO deviceOwnerWithStatus = new OwnerWithDeviceDTO();
String sql = "SELECT DEVICE_ID, OWNER, STATUS AS DEVICE_STATUS " + String sql = "SELECT e.DEVICE_ID, e.OWNER, e.STATUS AS DEVICE_STATUS, d.NAME AS DEVICE_NAME " +
"FROM DM_ENROLMENT " + "FROM DM_ENROLMENT e " +
"WHERE DEVICE_ID = ? AND TENANT_ID = ?"; "JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE e.DEVICE_ID = ? AND e.TENANT_ID = ?";
try (Connection conn = this.getConnection(); try (Connection conn = this.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) { PreparedStatement stmt = conn.prepareStatement(sql)) {
@ -616,6 +619,7 @@ public abstract class AbstractEnrollmentDAOImpl implements EnrollmentDAO {
List<Integer> deviceIds = new ArrayList<>(); List<Integer> deviceIds = new ArrayList<>();
deviceIds.add(rs.getInt("DEVICE_ID")); deviceIds.add(rs.getInt("DEVICE_ID"));
deviceOwnerWithStatus.setDeviceIds(deviceIds); deviceOwnerWithStatus.setDeviceIds(deviceIds);
deviceOwnerWithStatus.setDeviceNames(rs.getString("DEVICE_NAME"));
} }
} }
} catch (SQLException e) { } catch (SQLException e) {

@ -1450,13 +1450,25 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
List<Integer> deviceIds = new ArrayList<>(); List<Integer> deviceIds = new ArrayList<>();
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<>(); // New map for device names
String sql = String sql =
"SELECT g.ID AS GROUP_ID, g.GROUP_NAME, g.OWNER, e.OWNER AS DEVICE_OWNER, e.STATUS AS DEVICE_STATUS, dgm.DEVICE_ID " "SELECT " +
+ "FROM DM_GROUP g " " g.ID AS GROUP_ID, " +
+ "JOIN DM_DEVICE_GROUP_MAP dgm ON g.ID = dgm.GROUP_ID " " g.GROUP_NAME, " +
+ "JOIN DM_ENROLMENT e ON dgm.DEVICE_ID = e.DEVICE_ID " " g.OWNER AS GROUP_OWNER, " +
+ "WHERE g.GROUP_NAME = ? AND g.TENANT_ID = ? " + " e.OWNER AS DEVICE_OWNER, " +
" e.STATUS AS DEVICE_STATUS, " +
" dgm.DEVICE_ID, " +
" d.NAME AS DEVICE_NAME " +
"FROM " +
" DM_GROUP g " +
" JOIN DM_DEVICE_GROUP_MAP dgm ON g.ID = dgm.GROUP_ID " +
" JOIN DM_ENROLMENT e ON dgm.DEVICE_ID = e.DEVICE_ID " +
" JOIN DM_DEVICE d ON e.DEVICE_ID = d.ID " +
"WHERE " +
" g.GROUP_NAME = ? " +
" AND g.TENANT_ID = ? " +
"LIMIT ? OFFSET ?"; "LIMIT ? OFFSET ?";
try (Connection conn = GroupManagementDAOFactory.getConnection(); try (Connection conn = GroupManagementDAOFactory.getConnection();
@ -1471,12 +1483,13 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
if (groupDetails.getGroupId() == 0) { if (groupDetails.getGroupId() == 0) {
groupDetails.setGroupId(rs.getInt("GROUP_ID")); groupDetails.setGroupId(rs.getInt("GROUP_ID"));
groupDetails.setGroupName(rs.getString("GROUP_NAME")); groupDetails.setGroupName(rs.getString("GROUP_NAME"));
groupDetails.setGroupOwner(rs.getString("OWNER")); groupDetails.setGroupOwner(rs.getString("GROUP_OWNER"));
} }
int deviceId = rs.getInt("DEVICE_ID"); int deviceId = rs.getInt("DEVICE_ID");
deviceIds.add(deviceId); deviceIds.add(deviceId);
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"));
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -1488,6 +1501,7 @@ public abstract class AbstractGroupDAOImpl implements GroupDAO {
groupDetails.setDeviceCount(deviceIds.size()); groupDetails.setDeviceCount(deviceIds.size());
groupDetails.setDeviceOwners(deviceOwners); groupDetails.setDeviceOwners(deviceOwners);
groupDetails.setDeviceStatuses(deviceStatuses); groupDetails.setDeviceStatuses(deviceStatuses);
groupDetails.setDeviceNames(deviceNames);
return groupDetails; return groupDetails;
} }
} }

@ -31,6 +31,7 @@ public class GroupDetailsDTO {
private String deviceStatus; private String deviceStatus;
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;
public int getGroupId() { public int getGroupId() {
return groupId; return groupId;
@ -103,4 +104,12 @@ public class GroupDetailsDTO {
public void setDeviceStatuses(Map<Integer, String> deviceStatuses) { public void setDeviceStatuses(Map<Integer, String> deviceStatuses) {
this.deviceStatuses = deviceStatuses; this.deviceStatuses = deviceStatuses;
} }
public Map<Integer, String> getDeviceNames() {
return deviceNames;
}
public void setDeviceNames(Map<Integer, String> deviceNames) {
this.deviceNames = deviceNames;
}
} }

@ -26,6 +26,7 @@ public class OwnerWithDeviceDTO {
private List<Integer> deviceIds; private List<Integer> deviceIds;
private int deviceCount; private int deviceCount;
private String deviceStatus; private String deviceStatus;
private String deviceNames;
public String getUserName() { public String getUserName() {
return userName; return userName;
@ -58,4 +59,12 @@ public class OwnerWithDeviceDTO {
public void setDeviceStatus(String deviceStatus) { public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus; this.deviceStatus = deviceStatus;
} }
public String getDeviceNames() {
return deviceNames;
}
public void setDeviceNames(String deviceNames) {
this.deviceNames = deviceNames;
}
} }

Loading…
Cancel
Save