Skip to content

Commit

Permalink
Merge pull request #12674 from ashera96/master
Browse files Browse the repository at this point in the history
Fix application retrieval not working as expected when searched based on owner and app name
  • Loading branch information
RakhithaRR authored Oct 17, 2024
2 parents 29fe770 + 74e353c commit d9ca6e2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4415,8 +4415,22 @@ public Application[] getApplicationsWithPagination(String user, String owner, in
sqlQuery = sqlQuery.replace("$2", sortOrder);
prepStmt = connection.prepareStatement(sqlQuery);
prepStmt.setInt(1, tenantId);
prepStmt.setString(2, "%" + owner + "%");
prepStmt.setString(3, "%" + appName + "%");

if (owner.isEmpty() && appName.isEmpty()) {
owner = "%";
appName = "%";
} else {
if (!owner.isEmpty()) {
owner = "%" + owner + "%";
}
if (!appName.isEmpty()){
appName = "%" + appName + "%";
}
}

prepStmt.setString(2, owner);
prepStmt.setString(3, appName);

prepStmt.setInt(4, offset);
prepStmt.setInt(5, limit);
rs = prepStmt.executeQuery();
Expand Down Expand Up @@ -4457,8 +4471,22 @@ public int getApplicationsCount(int tenantId, String searchOwner, String searchA
sqlQuery = SQLConstants.GET_APPLICATIONS_COUNT;
prepStmt = connection.prepareStatement(sqlQuery);
prepStmt.setInt(1, tenantId);
prepStmt.setString(2, "%" + searchOwner + "%");
prepStmt.setString(3, "%" + searchApplication + "%");

if (searchOwner.isEmpty() && searchApplication.isEmpty()) {
searchOwner = "%";
searchApplication = "%";
} else {
if (!searchOwner.isEmpty()) {
searchOwner = "%" + searchOwner + "%";
}
if (!searchApplication.isEmpty()){
searchApplication = "%" + searchApplication + "%";
}
}

prepStmt.setString(2, searchOwner);
prepStmt.setString(3, searchApplication);

resultSet = prepStmt.executeQuery();
int applicationCount = 0;
if (resultSet != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ public class SQLConstants {
" SUB.TENANT_ID=?" +
" And "+
" ( SUB.CREATED_BY like ?" +
" AND APP.NAME like ? )";
" OR APP.NAME like ? )";

public static final String GET_APPLICATION_BY_SUBSCRIBERID_AND_NAME_SQL =
" SELECT " +
Expand Down

0 comments on commit d9ca6e2

Please sign in to comment.