From 71c4e3b4d072cabd7e6a1cb6945455a3664a644b Mon Sep 17 00:00:00 2001 From: Kavin Prathaban Date: Mon, 12 Dec 2022 08:17:48 +0000 Subject: [PATCH] Add fix for error on searching app with AppType with ALL filter Co-authored-by: Kavin Prathaban Co-committed-by: Kavin Prathaban --- .../core/dao/impl/application/GenericApplicationDAOImpl.java | 5 +++-- .../core/dao/impl/application/OracleApplicationDAOImpl.java | 5 +++-- .../dao/impl/application/SQLServerApplicationDAOImpl.java | 5 +++-- .../application/mgt/core/impl/ApplicationManagerImpl.java | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 5b07d0a0498..362c9086d70 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -31,6 +31,7 @@ import io.entgra.application.mgt.core.util.DAOUtil; import io.entgra.application.mgt.core.dao.impl.AbstractDAOImpl; import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.application.mgt.core.exception.UnexpectedServerErrorException; +import io.entgra.application.mgt.core.util.Constants; import java.sql.Connection; import java.sql.PreparedStatement; @@ -149,7 +150,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } sql += "WHERE AP_APP.TENANT_ID = ? "; - if (StringUtils.isNotEmpty(filter.getAppType())) { + if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { sql += "AND AP_APP.TYPE = ? "; } if (StringUtils.isNotEmpty(filter.getAppName())) { @@ -204,7 +205,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIndex = 1; stmt.setInt(paramIndex++, tenantId); - if (StringUtils.isNotEmpty(filter.getAppType())) { + if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { stmt.setString(paramIndex++, filter.getAppType()); } if (StringUtils.isNotEmpty(filter.getAppName())) { diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java index 6f4c31f1b9f..58e85560a78 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/OracleApplicationDAOImpl.java @@ -26,6 +26,7 @@ import io.entgra.application.mgt.common.dto.ApplicationDTO; import io.entgra.application.mgt.common.exception.DBConnectionException; import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.application.mgt.core.util.DAOUtil; +import io.entgra.application.mgt.core.util.Constants; import java.sql.Connection; import java.sql.PreparedStatement; @@ -94,7 +95,7 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl { || StringUtils.isNotEmpty(filter.getAppReleaseType())) { sql += "LEFT JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "; } - if (StringUtils.isNotEmpty(filter.getAppType())) { + if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { sql += "AND AP_APP.TYPE = ? "; } if (StringUtils.isNotEmpty(filter.getAppName())) { @@ -145,7 +146,7 @@ public class OracleApplicationDAOImpl extends GenericApplicationDAOImpl { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIndex = 1; - if (StringUtils.isNotEmpty(filter.getAppType())) { + if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { stmt.setString(paramIndex++, filter.getAppType()); } if (StringUtils.isNotEmpty(filter.getAppName())) { diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java index 0ddbe3c3339..9ad0b9d4c0c 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/dao/impl/application/SQLServerApplicationDAOImpl.java @@ -25,6 +25,7 @@ import io.entgra.application.mgt.common.dto.ApplicationDTO; import io.entgra.application.mgt.common.exception.DBConnectionException; import io.entgra.application.mgt.core.exception.ApplicationManagementDAOException; import io.entgra.application.mgt.core.util.DAOUtil; +import io.entgra.application.mgt.core.util.Constants; import java.sql.Connection; import java.sql.PreparedStatement; @@ -93,7 +94,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { || StringUtils.isNotEmpty(filter.getAppReleaseType())) { sql += "LEFT JOIN AP_APP_RELEASE ON AP_APP.ID = AP_APP_RELEASE.AP_APP_ID "; } - if (StringUtils.isNotEmpty(filter.getAppType())) { + if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { sql += "AND AP_APP.TYPE = ? "; } if (StringUtils.isNotEmpty(filter.getAppName())) { @@ -144,7 +145,7 @@ public class SQLServerApplicationDAOImpl extends GenericApplicationDAOImpl { Connection conn = this.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { int paramIndex = 1; - if (StringUtils.isNotEmpty(filter.getAppType())) { + if (StringUtils.isNotEmpty(filter.getAppType()) && !Constants.ALL.equalsIgnoreCase(filter.getAppType())) { stmt.setString(paramIndex++, filter.getAppType()); } if (StringUtils.isNotEmpty(filter.getAppName())) { diff --git a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java index 26f97f0caf7..157d73241df 100644 --- a/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.application.mgt.core/src/main/java/io/entgra/application/mgt/core/impl/ApplicationManagerImpl.java @@ -2932,7 +2932,7 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!StringUtils.isEmpty(appType)) { boolean isValidAppType = false; for (ApplicationType applicationType : ApplicationType.values()) { - if (applicationType.toString().equalsIgnoreCase(appType)) { + if (applicationType.toString().equalsIgnoreCase(appType) || Constants.ALL.equalsIgnoreCase(appType)) { isValidAppType = true; break; }