From 422e106c36c26315b1d4d0cc772a28dacdec3353 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Sun, 20 Oct 2019 09:41:07 +0530 Subject: [PATCH 1/4] MS sql related bug fixes --- .../GenericSubscriptionDAOImpl.java | 23 +++++++++++-------- .../impl/device/SQLServerDeviceDAOImpl.java | 2 +- 2 files changed, 14 insertions(+), 11 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/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 ace7d41f75..f6719c1526 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 @@ -107,13 +107,15 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc public void updateDeviceSubscription(String updateBy, List deviceIds, String action, String actionTriggeredFrom, String installStatus, int releaseId, int tenantId) throws ApplicationManagementDAOException { + boolean unsubscribed = false; try { String sql = "UPDATE AP_DEVICE_SUBSCRIPTION SET "; if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { - sql += "UNSUBSCRIBED = true, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ?, "; + sql += "UNSUBSCRIBED = ?, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ?, "; + unsubscribed = true; } else if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { - sql += "UNSUBSCRIBED = false, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ?, "; + sql += "UNSUBSCRIBED = ?, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ?, "; } else { String msg = "Found invalid action " + action + ". Hence can't construct the query."; log.error(msg); @@ -131,13 +133,14 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc Calendar calendar = Calendar.getInstance(); Timestamp timestamp = new Timestamp(calendar.getTime().getTime()); for (Integer deviceId : deviceIds) { - stmt.setString(1, updateBy); - stmt.setTimestamp(2, timestamp); - stmt.setString(3, actionTriggeredFrom); - stmt.setString(4, installStatus); - stmt.setInt(5, deviceId); - stmt.setInt(6, releaseId); - stmt.setInt(7, tenantId); + stmt.setBoolean(1, unsubscribed); + stmt.setString(2, updateBy); + stmt.setTimestamp(3, timestamp); + stmt.setString(4, actionTriggeredFrom); + stmt.setString(5, installStatus); + stmt.setInt(6, deviceId); + stmt.setInt(7, releaseId); + stmt.setInt(8, tenantId); stmt.addBatch(); } stmt.executeBatch(); @@ -554,7 +557,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc int index = 1; List subscribedDevices = new ArrayList<>(); StringJoiner joiner = new StringJoiner(",", - "SELECT DS.ID " + "SELECT DS.ID AS DM_DEVICE_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " + "WHERE DS.DM_DEVICE_ID IN (", ") AND AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"); deviceIds.stream().map(ignored -> "?").forEach(joiner::add); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java index e8517b00cc..1b9134343e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/device/SQLServerDeviceDAOImpl.java @@ -552,7 +552,7 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl { isStatusProvided = true; } - query = query + " LIMIT ?,?"; + query = query + " ORDER BY f.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; try (PreparedStatement ps = conn.prepareStatement(query)) { From bb681c43d00c47b982f1614a765308b1439db8ff Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Mon, 21 Oct 2019 13:50:21 +0530 Subject: [PATCH 2/4] Message to display in view when a selected corrective policy is changed to general or deleted --- .../units/cdmf.unit.policy.view/public/js/view.js | 12 +++++++++++- .../app/units/cdmf.unit.policy.view/view.hbs | 13 ++++++++++++- .../app/units/cdmf.unit.policy.view/view.js | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js index 5e3b17092d..a7fd6e461a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/public/js/view.js @@ -73,7 +73,17 @@ var displayPolicy = function (policyPayloadObj) { policyPayloadObj.correctiveActions && policyPayloadObj.correctiveActions.length > 0) { policyPayloadObj.correctiveActions.forEach(function (correctiveAction) { if ("POLICY" === correctiveAction.actionType) { - $("#corrective-action-type-policy-id").html(correctiveAction.policyId); + $("#corrective-action-type-policy-id").html(correctiveAction.policyId); + var correctivePolicies = $("#logged-in-user").data("corrective-policies"); + if (correctivePolicies) { + var i; + for (i = 0; i < correctivePolicies.length; i++) { + if (correctiveAction.policyId === correctivePolicies[i].id) { + $("#corrective-action-policy-id-missing-msg").addClass("hidden"); + break; + } + } + } return true; } }); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs index 8ac41acee8..c65faea981 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.hbs @@ -1,7 +1,8 @@ {{#zone "content"}} {{#if isAuthorized}} + data-tenant-id="{{@user.tenantId}}" data-iscloud="{{isCloud}}" + data-corrective-policies="{{correctivePolicies}}"> {{#defineZone "policy-profile-top"}}
@@ -67,6 +68,16 @@ Policy ID + + + + + Corrective policy having the above Policy ID has been updated to + a GENERAL policy or it has been deleted. Hence this policy will + not be applied till modified correctly. + + +
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js index 8dcefb24bc..417910dc78 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.policy.view/view.js @@ -18,6 +18,8 @@ function onRequest(context) { var utility = require("/app/modules/utility.js").utility; + var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; + var page = {}; var deviceType = request.getParameter("deviceType"); var policyViewSrc = "/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-view"); @@ -42,6 +44,8 @@ function onRequest(context) { var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; page["isCloud"] = devicemgtProps.isCloud; + + page["correctivePolicies"] = JSON.stringify(policyModule.getAllPoliciesByType("CORRECTIVE")["content"]); return page; } \ No newline at end of file From 0db399814b66a8f6c2123f038a4388388501a7e3 Mon Sep 17 00:00:00 2001 From: inoshperera Date: Mon, 21 Oct 2019 13:54:34 +0530 Subject: [PATCH 3/4] MS SQL based syntax fixes --- .../GenericApplicationDAOImpl.java | 36 ++++++------ .../GenericSubscriptionDAOImpl.java | 55 ++++++++++--------- .../SQLServerSubscriptionDAOImpl.java | 4 +- .../core/dao/impl/AbstractDeviceDAOImpl.java | 4 +- .../dbscripts/cdm/application-mgt/mssql.sql | 3 +- 5 files changed, 52 insertions(+), 50 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/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 330bd1ccc6..f860273228 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -562,13 +562,13 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic @Override public boolean updateApplication(ApplicationDTO applicationDTO, int tenantId) throws ApplicationManagementDAOException { - String sql = "UPDATE AP_APP AP " + + String sql = "UPDATE AP_APP " + "SET " + - "AP.NAME = ?, " + - "AP.DESCRIPTION = ?, " + - "AP.SUB_TYPE = ?, " + - "AP.CURRENCY = ? " + - "WHERE AP.ID = ? AND AP.TENANT_ID = ?"; + "NAME = ?, " + + "DESCRIPTION = ?, " + + "SUB_TYPE = ?, " + + "CURRENCY = ? " + + "WHERE ID = ? AND TENANT_ID = ?"; try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -594,12 +594,12 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic @Override public void updateApplicationRating(String uuid, double rating, int tenantId) throws ApplicationManagementDAOException { - String sql = "UPDATE AP_APP AP " + + String sql = "UPDATE AP_APP " + "SET " + - "AP.RATING = ? " + + "RATING = ? " + "WHERE " + - "AP.ID = (SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE UUID = ?) AND " + - "AP.TENANT_ID = ?"; + "ID = (SELECT AP_APP_ID FROM AP_APP_RELEASE WHERE UUID = ?) AND " + + "TENANT_ID = ?"; try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -1013,11 +1013,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic log.debug("Request received in DAO Layer to update a category."); } String sql = "UPDATE " + - "AP_APP_CATEGORY cat " + - "SET cat.CATEGORY = ? " + + "AP_APP_CATEGORY " + + "SET CATEGORY = ? " + "WHERE " + - "cat.ID = ? AND " + - "cat.TENANT_ID = ?"; + "ID = ? AND " + + "TENANT_ID = ?"; try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -1444,11 +1444,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic log.debug("Request received in DAO Layer to update a Tag."); } String sql = "UPDATE " + - "AP_APP_TAG tag " + - "SET tag.TAG = ? " + + "AP_APP_TAG " + + "SET TAG = ? " + "WHERE " + - "tag.ID = ? AND " + - "tag.TENANT_ID = ?"; + "ID = ? AND " + + "TENANT_ID = ?"; try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { 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 f6719c1526..444445a288 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 @@ -436,7 +436,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc int index = 1; List subscribedUsers = new ArrayList<>(); StringJoiner joiner = new StringJoiner(",", - "SELECT US.USER_NAME AS USER " + "SELECT US.USER_NAME AS USER_NAME " + "FROM AP_USER_SUBSCRIPTION US " + "WHERE US.USER_NAME IN (", ") AND TENANT_ID = ?"); users.stream().map(ignored -> "?").forEach(joiner::add); @@ -448,7 +448,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc ps.setInt(index, tenantId); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { - subscribedUsers.add(rs.getString("USER")); + subscribedUsers.add(rs.getString("USER_NAME")); } } } @@ -516,7 +516,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc int index = 1; List subscribedUsers = new ArrayList<>(); StringJoiner joiner = new StringJoiner(",", - "SELECT GS.GROUP_NAME AS GROUP " + "SELECT GS.GROUP_NAME AS GROUP_NAME " + "FROM AP_GROUP_SUBSCRIPTION GS " + "WHERE GS.GROUP_NAME IN (", ") AND TENANT_ID = ?"); groups.stream().map(ignored -> "?").forEach(joiner::add); @@ -528,7 +528,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc ps.setInt(index, tenantId); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { - subscribedUsers.add(rs.getString("GROUP")); + subscribedUsers.add(rs.getString("GROUP_NAME")); } } } @@ -557,7 +557,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc int index = 1; List subscribedDevices = new ArrayList<>(); StringJoiner joiner = new StringJoiner(",", - "SELECT DS.ID AS DM_DEVICE_ID " + "SELECT DS.ID AS DEVICE_SUBSCRIPTION_ID " + "FROM AP_DEVICE_SUBSCRIPTION DS " + "WHERE DS.DM_DEVICE_ID IN (", ") AND AP_APP_RELEASE_ID = ? AND TENANT_ID = ?"); deviceIds.stream().map(ignored -> "?").forEach(joiner::add); @@ -570,7 +570,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc ps.setInt(index, tenantId); try (ResultSet rs = ps.executeQuery()) { while (rs.next()) { - subscribedDevices.add(rs.getInt("DM_DEVICE_ID")); + subscribedDevices.add(rs.getInt("DEVICE_SUBSCRIPTION_ID")); } } } @@ -592,6 +592,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc String subType, String action) throws ApplicationManagementDAOException { try { Connection conn = this.getDBConnection(); + boolean isUnsubscribed = false; String sql = "UPDATE "; if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) { sql += "AP_USER_SUBSCRIPTION SET "; @@ -602,9 +603,10 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc } if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) { - sql += "UNSUBSCRIBED = true, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ? "; + sql += "UNSUBSCRIBED = ?, UNSUBSCRIBED_BY = ?, UNSUBSCRIBED_TIMESTAMP = ? "; + isUnsubscribed = true; } else { - sql += "UNSUBSCRIBED = false, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ? "; + sql += "UNSUBSCRIBED = ?, SUBSCRIBED_BY = ?, SUBSCRIBED_TIMESTAMP = ? "; } if (SubscriptionType.USER.toString().equalsIgnoreCase(subType)) { @@ -621,11 +623,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc Calendar calendar = Calendar.getInstance(); Timestamp timestamp = new Timestamp(calendar.getTime().getTime()); for (String username : paramList) { - stmt.setString(1, updateBy); - stmt.setTimestamp(2, timestamp); - stmt.setString(3, username); - stmt.setInt(4, releaseId); - stmt.setInt(5, tenantId); + stmt.setBoolean(1, isUnsubscribed); + stmt.setString(2, updateBy); + stmt.setTimestamp(3, timestamp); + stmt.setString(4, username); + stmt.setInt(5, releaseId); + stmt.setInt(6, tenantId); stmt.addBatch(); } stmt.executeBatch(); @@ -755,12 +758,12 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public boolean updateScheduledSubscription(int id, LocalDateTime scheduledAt, String scheduledBy) throws ApplicationManagementDAOException { - String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION AP " + String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION " + "SET " - + "AP.SCHEDULED_AT = ?, " - + "AP.SCHEDULED_BY = ?, " - + "AP.SCHEDULED_TIMESTAMP = ? " - + "WHERE AP.ID = ?"; + + "SCHEDULED_AT = ?, " + + "SCHEDULED_BY = ?, " + + "SCHEDULED_TIMESTAMP = ? " + + "WHERE ID = ?"; try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -786,9 +789,9 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public boolean deleteScheduledSubscription(List subscriptionIdList) throws ApplicationManagementDAOException { - String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION AP " - + "SET AP.DELETED = ? " - + "WHERE AP.ID = ?"; + String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION " + + "SET DELETED = ? " + + "WHERE ID = ?"; try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -816,9 +819,9 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc @Override public boolean updateScheduledSubscriptionStatus(int id, ExecutionStatus status) throws ApplicationManagementDAOException { - String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION AP " - + "SET AP.STATUS = ? " - + "WHERE AP.ID = ?"; + String sql = "UPDATE AP_SCHEDULED_SUBSCRIPTION " + + "SET STATUS = ? " + + "WHERE ID = ?"; try { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -850,7 +853,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc Connection conn = this.getDBConnection(); List subscribedUsers = new ArrayList<>(); String sql = "SELECT " - + "US.USER_NAME AS USER " + + "US.USER_NAME AS USER_NAME " + "FROM AP_USER_SUBSCRIPTION US " + "WHERE " + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? LIMIT ? OFFSET ?"; @@ -861,7 +864,7 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc stmt.setInt(4, offsetValue); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { - subscribedUsers.add(rs.getString("USER")); + subscribedUsers.add(rs.getString("USER_NAME")); } } return subscribedUsers; 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/SQLServerSubscriptionDAOImpl.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/SQLServerSubscriptionDAOImpl.java index 63e830cdfe..2c725dde07 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/SQLServerSubscriptionDAOImpl.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/SQLServerSubscriptionDAOImpl.java @@ -51,7 +51,7 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { Connection conn = this.getDBConnection(); List subscribedUsers = new ArrayList<>(); String sql = "SELECT " - + "US.USER_NAME AS USER " + + "US.USER_NAME AS USER_NAME " + "FROM AP_USER_SUBSCRIPTION US " + "WHERE " + "AP_APP_RELEASE_ID = ? AND TENANT_ID = ? ORDER BY US.ID OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; @@ -62,7 +62,7 @@ public class SQLServerSubscriptionDAOImpl extends GenericSubscriptionDAOImpl { stmt.setInt(4, limitValue); try (ResultSet rs = stmt.executeQuery()) { while (rs.next()) { - subscribedUsers.add(rs.getString("USER")); + subscribedUsers.add(rs.getString("USER_NAME")); } } return subscribedUsers; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index 0fe6a8215f..30bd1d13c7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -787,8 +787,8 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { " e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " + "AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " + "e.DEVICE_ID, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " + - "e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?) ORDER BY e.DATE_OF_LAST_UPDATE DESC) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " + - "AND t.ID = d.DEVICE_TYPE_ID"; + "e.TENANT_ID = ? AND LOWER(e.OWNER) = LOWER(?)) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " + + "AND t.ID = d.DEVICE_TYPE_ID ORDER BY e1.DATE_OF_LAST_UPDATE DESC"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); stmt.setString(2, username); diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql index dbaffe4733..4d45a828da 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/dbscripts/cdm/application-mgt/mssql.sql @@ -268,8 +268,7 @@ CREATE TABLE AP_SCHEDULED_SUBSCRIPTION( ID INTEGER NOT NULL IDENTITY, TASK_NAME VARCHAR(100) NOT NULL, APPLICATION_UUID VARCHAR(200) NOT NULL, - CONSTRAINT APPLICATION_UUID_CONSTRAINT UNIQUE(APPLICATION_UUID), - SUBSCRIBER_LIST VARCHAR NOT NULL, + SUBSCRIBER_LIST VARCHAR(MAX) NOT NULL, STATUS VARCHAR(15) NOT NULL, SCHEDULED_AT DATETIME2(0) NOT NULL, SCHEDULED_BY VARCHAR(100) NOT NULL, From 78bd339cd46022814bb3cf68eee948f2ad11d3b6 Mon Sep 17 00:00:00 2001 From: Jayasanka Weerasinghe Date: Mon, 21 Oct 2019 09:59:56 +0000 Subject: [PATCH 4/4] Add loading animation when installing/uninstall app in APPM store --- .../components/apps/release/ReleaseView.js | 5 ++- .../apps/release/install/AppInstallModal.js | 44 ++++++++++--------- .../apps/release/install/AppUninstallModal.js | 33 +++++++------- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js index 63bb008e8c..6994f16e47 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js @@ -17,7 +17,7 @@ */ import React from "react"; -import {Divider, Row, Col, Typography, Button, Dropdown, notification, Menu, Icon} from "antd"; +import {Divider, Row, Col, Typography, Button, Dropdown, notification, Menu, Icon, Spin} from "antd"; import "../../../App.css"; import ImgViewer from "../../apps/release/images/ImgViewer"; import StarRatings from "react-star-ratings"; @@ -126,17 +126,18 @@ class ReleaseView extends React.Component { ); - return (
- - - - - - - - - - - - - - + footer={null}> + + + + + + + + + + + + + + + +
); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppUninstallModal.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppUninstallModal.js index 14a729466a..6c1f0ce1f1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppUninstallModal.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/AppUninstallModal.js @@ -16,31 +16,33 @@ * under the License. */ import React from "react"; -import {Modal, Tabs} from "antd"; +import {Modal, Spin, Tabs} from "antd"; import DeviceUninstall from "./DeviceUninstall"; import UserUninstall from "./UserUninstall"; import RoleUninstall from "./RoleUninstall"; import GroupUninstall from "./GroupUninstall"; -const { TabPane } = Tabs; +const {TabPane} = Tabs; -class AppUninstallModal extends React.Component{ - state={ - data:[] +class AppUninstallModal extends React.Component { + state = { + data: [] }; + render() { const {deviceType} = this.props; return ( -
- +
+ + - + @@ -52,8 +54,9 @@ class AppUninstallModal extends React.Component{ - -
+ +
+
); } }