From 198bfc11f6996d35e9ea842c5c51cda5ce1bb8e6 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Fri, 19 Jul 2019 14:04:22 +0530 Subject: [PATCH] Fix app installing issue in APPM --- .../device/application/mgt/core/dao/SubscriptionDAO.java | 3 ++- .../dao/impl/subscription/GenericSubscriptionDAOImpl.java | 8 +++++--- .../mgt/core/impl/SubscriptionManagerImpl.java | 2 +- .../src/components/apps/release/install/DeviceInstall.js | 1 - 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java index c41dda76d7..469ee44030 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java @@ -77,7 +77,8 @@ public interface SubscriptionDAO { void updateSubscriptions(int tenantId, String updateBy, List paramList, int releaseId, String subType, String action) throws ApplicationManagementDAOException; - List getSubscribedDeviceIds(List deviceIds, int tenantId) throws ApplicationManagementDAOException; + List getSubscribedDeviceIds(List deviceIds, int applicationReleaseId, int tenantId) + throws ApplicationManagementDAOException; List getDeviceSubIdsForOperation (int operationId, int tenantId) throws ApplicationManagementDAOException; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 9eabccb38c..cc6938c934 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -533,7 +533,8 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } @Override - public List getSubscribedDeviceIds(List deviceIds, int tenantId) + public List getSubscribedDeviceIds(List deviceIds, int applicationReleaseId, + int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received to DAO Layer to get already subscribed dvice Ids for given list of device Ids."); @@ -545,14 +546,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc StringJoiner joiner = new StringJoiner(",", "SELECT DS.DM_DEVICE_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " - + "WHERE DS.DM_DEVICE_ID IN (", ") AND TENANT_ID = ?"); + + "WHERE DS.DM_DEVICE_ID IN (", ") AND AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"); deviceIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); try (PreparedStatement ps = conn.prepareStatement(query)) { for (Integer deviceId : deviceIds) { ps.setObject(index++, deviceId); } - ps.setInt(index, tenantId); + ps.setInt(index++, tenantId); + ps.setInt(index, applicationReleaseId); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { subscribedDevices.add(rs.getInt("DM_DEVICE_ID")); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 5cbe5b8696..c49167f90b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -366,7 +366,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List operationAddedDeviceIds = getOperationAddedDeviceIds(activity, subscribingDeviceIdHolder.getSubscribableDevices()); List alreadySubscribedDevices = subscriptionDAO - .getSubscribedDeviceIds(operationAddedDeviceIds, tenantId); + .getSubscribedDeviceIds(operationAddedDeviceIds, applicationReleaseId, tenantId); if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { if (!alreadySubscribedDevices.isEmpty()) { List deviceResubscribingIds = subscriptionDAO diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js index 7946dd833a..57bbf1c532 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js @@ -190,7 +190,6 @@ class DeviceInstall extends React.Component { this.props.onInstall("devices", payload); }; - render() { const {data,pagination,loading,selectedRows} = this.state; return (