Fix issues with adding operation log of a subscription

remotes/1725563413541109883/master
Nipuni Kavindya 5 months ago
parent 61a21edb9d
commit 7c90b43485

@ -293,12 +293,10 @@ public interface SubscriptionManager {
* *
* @param deviceId the deviceId of the device that need to get operation details. * @param deviceId the deviceId of the device that need to get operation details.
* @param uuid the UUID of the application release. * @param uuid the UUID of the application release.
* @param offset the offset for the data set
* @param limit the limit for the data set
* @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @return {@link DeviceOperationDTO} which contains the details of device subscriptions.
* @throws SubscriptionManagementException if there is an error while fetching the details. * @throws SubscriptionManagementException if there is an error while fetching the details.
*/ */
List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid)
throws ApplicationManagementException; throws ApplicationManagementException;
/** /**

@ -378,12 +378,10 @@ public interface SubscriptionDAO {
* @param appReleaseId the appReleaseId of the application release. * @param appReleaseId the appReleaseId of the application release.
* @param deviceId the deviceId of the device that need to get operation details. * @param deviceId the deviceId of the device that need to get operation details.
* @param tenantId id of the current tenant. * @param tenantId id of the current tenant.
* @param offset the offset for the data set
* @param limit the limit for the data set
* @return {@link DeviceOperationDTO} which contains the details of device subscriptions. * @return {@link DeviceOperationDTO} which contains the details of device subscriptions.
* @throws ApplicationManagementDAOException if connection establishment or SQL execution fails. * @throws ApplicationManagementDAOException if connection establishment or SQL execution fails.
*/ */
List<DeviceOperationDTO> getSubscriptionOperationsByAppReleaseIDAndDeviceID(int appReleaseId, int deviceId, int tenantId, int offset, int limit) List<DeviceOperationDTO> getSubscriptionOperationsByAppReleaseIDAndDeviceID(int appReleaseId, int deviceId, int tenantId)
throws ApplicationManagementDAOException; throws ApplicationManagementDAOException;
/** /**

@ -1857,7 +1857,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
@Override @Override
public List<DeviceOperationDTO> getSubscriptionOperationsByAppReleaseIDAndDeviceID( public List<DeviceOperationDTO> getSubscriptionOperationsByAppReleaseIDAndDeviceID(
int appReleaseId, int deviceId, int tenantId, int offset, int limit) throws ApplicationManagementDAOException { int appReleaseId, int deviceId, int tenantId) throws ApplicationManagementDAOException {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Request received in DAO Layer to get device subscriptions related to the given AppReleaseID and DeviceID."); log.debug("Request received in DAO Layer to get device subscriptions related to the given AppReleaseID and DeviceID.");
} }
@ -1877,13 +1877,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
"WHERE ads.AP_APP_RELEASE_ID = ? " + "WHERE ads.AP_APP_RELEASE_ID = ? " +
"AND ads.DM_DEVICE_ID = ? " + "AND ads.DM_DEVICE_ID = ? " +
"AND ads.TENANT_ID = ? " + "AND ads.TENANT_ID = ? " +
"LIMIT ? OFFSET ?"; "ORDER BY aasom.OPERATION_ID DESC " +
"LIMIT 1";
try (PreparedStatement ps = conn.prepareStatement(sql)) { try (PreparedStatement ps = conn.prepareStatement(sql)) {
ps.setInt(1, appReleaseId); ps.setInt(1, appReleaseId);
ps.setInt(2, deviceId); ps.setInt(2, deviceId);
ps.setInt(3, tenantId); ps.setInt(3, tenantId);
ps.setInt(4, limit);
ps.setInt(5, offset);
try (ResultSet rs = ps.executeQuery()) { try (ResultSet rs = ps.executeQuery()) {
DeviceOperationDTO deviceSubscription; DeviceOperationDTO deviceSubscription;
while (rs.next()) { while (rs.next()) {

@ -2612,7 +2612,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
} }
@Override @Override
public List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid, int offset, int limit) public List<DeviceOperationDTO> getSubscriptionOperationsByUUIDAndDeviceID(int deviceId, String uuid)
throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
if (uuid == null || uuid.isEmpty()) { if (uuid == null || uuid.isEmpty()) {
@ -2631,7 +2631,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService(); DeviceManagementProviderService deviceManagementProviderService = HelperUtil.getDeviceManagementProviderService();
List<DeviceOperationDTO> deviceSubscriptions = List<DeviceOperationDTO> deviceSubscriptions =
subscriptionDAO.getSubscriptionOperationsByAppReleaseIDAndDeviceID(appReleaseId, deviceId, tenantId, offset, limit); subscriptionDAO.getSubscriptionOperationsByAppReleaseIDAndDeviceID(appReleaseId, deviceId, tenantId);
for (DeviceOperationDTO deviceSubscription : deviceSubscriptions) { for (DeviceOperationDTO deviceSubscription : deviceSubscriptions) {
Integer operationId = deviceSubscription.getOperationId(); Integer operationId = deviceSubscription.getOperationId();
if (operationId != null) { if (operationId != null) {

Loading…
Cancel
Save