From 49bc317d20068a3c2baf0c50f4e1c902145c4891 Mon Sep 17 00:00:00 2001 From: ashvini Date: Wed, 29 May 2024 12:44:59 +0530 Subject: [PATCH] Add filter to get Web apps in Enrollment Application Install Add filter file (cherry picked from commit 7616c2255c054e21a10f4f85ced02513f94ab385) --- .../mgt/core/application/mgt/common/Filter.java | 13 +++++++++++++ .../impl/application/GenericApplicationDAOImpl.java | 12 ++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java index 272e9ba8a3..88f7e90a0a 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/src/main/java/io/entgra/device/mgt/core/application/mgt/common/Filter.java @@ -118,6 +118,11 @@ public class Filter { */ private boolean isNotRetired; + /** + * To check whether web applications should be returned + */ + private boolean withWebApps; + public int getLimit() { return limit; } @@ -221,4 +226,12 @@ public class Filter { public void setNotRetired(boolean notRetired) { isNotRetired = notRetired; } + + public boolean isWithWebApps() { + return withWebApps; + } + + public void setWithWebApps(boolean withWebApps) { + this.withWebApps = withWebApps; + } } diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 7c71880fa6..618149cd72 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -178,7 +178,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic sql += "AND AP_APP_RELEASE.CURRENT_STATE = ? "; } if (deviceTypeId != -1) { - sql += "AND AP_APP.DEVICE_TYPE_ID = ? "; + sql += "AND (AP_APP.DEVICE_TYPE_ID = ? "; + if (filter.isWithWebApps()) { + sql += "OR AP_APP.DEVICE_TYPE_ID = 0 "; + } + sql += ") "; } if (filter.isNotRetired()) { sql += "AND AP_APP.STATUS != 'RETIRED' "; @@ -309,7 +313,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic sql += " AND AP_APP_RELEASE.CURRENT_STATE = ?"; } if (deviceTypeId != -1) { - sql += " AND AP_APP.DEVICE_TYPE_ID = ?"; + sql += "AND (AP_APP.DEVICE_TYPE_ID = ? "; + if (filter.isWithWebApps()) { + sql += "OR AP_APP.DEVICE_TYPE_ID = 0 "; + } + sql += ") "; } if (filter.isNotRetired()) { sql += " AND AP_APP.STATUS != 'RETIRED'";