Fix application search issue

remotes/1729253769841084517/master
Pahansith Gunathilake 10 months ago
parent 45d6a27caa
commit 7843514332

@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.core.common;
public class Constants {
public static final String SCHEME_SEPARATOR = "://";
public static final String COLON = ":";
public static final String QUERY_WILDCARD = "%";
public static final String URI_QUERY_SEPARATOR = "?";
public static final String URI_SEPARATOR = "/";
public static final String BASIC_AUTH_HEADER_PREFIX = "Basic ";

@ -17,6 +17,7 @@
*/
package io.entgra.device.mgt.core.device.mgt.core.dao.impl;
import io.entgra.device.mgt.core.device.mgt.core.common.Constants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
@ -298,9 +299,13 @@ public class ApplicationDAOImpl implements ApplicationDAO {
String filter = request.getFilter();
if (filter != null) {
sql = sql + "AND NAME LIKE ? ";
filter = Constants.QUERY_WILDCARD.concat(filter).concat(Constants.QUERY_WILDCARD);
}
boolean isLimitPresent = false;
if (request != null && request.getRowCount() != -1) {
sql = sql + "LIMIT ? OFFSET ?";
isLimitPresent = true;
}
Connection conn = this.getConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) {
@ -312,7 +317,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
if (filter != null){
stmt.setString(paramIdx++, filter);
}
if (request != null && request.getRowCount() != -1) {
if (isLimitPresent) {
stmt.setInt(paramIdx++, request.getRowCount());
stmt.setInt(paramIdx, request.getStartIndex());
}

@ -463,6 +463,8 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
)ENGINE = InnoDB;
CREATE INDEX IDX_DM_APPLICATION ON DM_APPLICATION(DEVICE_ID, ENROLMENT_ID, TENANT_ID);
CREATE INDEX DM_APPLICATION_NAME ON DM_APPLICATION(NAME);
CREATE INDEX DM_APPLICATION_NAME_PLATFORM_TID ON DM_APPLICATION(NAME, PLATFORM, TENANT_ID);
-- END OF POLICY RELATED TABLES --

Loading…
Cancel
Save