IDEMPIERE-2050 Improvement to Menu Lookup

This commit is contained in:
Carlos Ruiz 2014-12-03 19:32:14 -05:00
parent 946fd0e942
commit b61adbd398
3 changed files with 19 additions and 6 deletions

View File

@ -171,9 +171,15 @@ public abstract class AbstractDocumentSearch {
}
// search for a String
} else if (msd.getDataType().equals(MSearchDefinition.DATATYPE_STRING)) {
pstmtSO.setString(1, searchString);
if (searchString.endsWith("%"))
pstmtSO.setString(1, searchString);
else
pstmtSO.setString(1, searchString+"%");
if (msd.getPO_Window_ID() != 0) {
pstmtPO.setString(1, searchString);
if (searchString.endsWith("%"))
pstmtPO.setString(1, searchString);
else
pstmtPO.setString(1, searchString+"%");
}
}
// SearchDefinition with a special query
@ -191,7 +197,10 @@ public abstract class AbstractDocumentSearch {
if (msd.getDataType().equals(MSearchDefinition.DATATYPE_INTEGER)) {
pstmtSO.setInt(i, Integer.valueOf(searchString.replaceAll("\\D", "")));
} else if (msd.getDataType().equals(MSearchDefinition.DATATYPE_STRING)) {
pstmtSO.setString(i, searchString + "%");
if (searchString.endsWith("%"))
pstmtSO.setString(i, searchString);
else
pstmtSO.setString(i, searchString+"%");
}
}
}

View File

@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig
/**
*
*/
private static final long serialVersionUID = 8965976274227777648L;
private static final long serialVersionUID = -4290840203977716310L;
public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION";
public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS";
@ -95,6 +95,7 @@ public class MSysConfig extends X_AD_SysConfig
public static final String MAIL_SEND_BCC_TO_FROM = "MAIL_SEND_BCC_TO_FROM";
public static final String MAIL_SEND_CREDENTIALS = "MAIL_SEND_CREDENTIALS";
public static final String MAX_ACTIVITIES_IN_LIST = "MAX_ACTIVITIES_IN_LIST";
public static final String MAX_RESULTS_PER_SEARCH = "MAX_RESULTS_PER_SEARCH";
public static final String MENU_INFOUPDATER_SLEEP_MS = "MENU_INFOUPDATER_SLEEP_MS";
public static final String MFG_ValidateCostsDifferenceOnCreate = "MFG_ValidateCostsDifferenceOnCreate";
public static final String MFG_ValidateCostsOnCreate = "MFG_ValidateCostsOnCreate";

View File

@ -30,6 +30,7 @@ import org.compiere.model.MLookupInfo;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MSearchDefinition;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTable;
import org.compiere.model.MWindow;
import org.compiere.model.Query;
@ -53,6 +54,7 @@ public class DocumentSearchController implements EventListener<Event>{
private static final String SEARCH_RESULT = "search.result";
private static final String ON_SEARCH_DOCUMENTS = "onSearchDocuments";
private int MAX_RESULTS_PER_SEARCH = 3;
private Vlayout layout;
private ArrayList<SearchResult> list;
private int selected = -1;
@ -61,6 +63,7 @@ public class DocumentSearchController implements EventListener<Event>{
*
*/
public DocumentSearchController() {
MAX_RESULTS_PER_SEARCH = MSysConfig.getIntValue(MSysConfig.MAX_RESULTS_PER_SEARCH, 3, Env.getAD_Client_ID(Env.getCtx()));
}
public void create(Component parent) {
@ -119,7 +122,7 @@ public class DocumentSearchController implements EventListener<Event>{
final MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()), Env.getAD_User_ID(Env.getCtx()), true);
selected = -1;
Query query = new Query(Env.getCtx(), I_AD_SearchDefinition.Table_Name, "", null);
Query query = new Query(Env.getCtx(), I_AD_SearchDefinition.Table_Name, "TransactionCode IS NULL", null);
List<MSearchDefinition> definitions = query.setOnlyActiveRecords(true).list();
for(MSearchDefinition msd : definitions) {
MTable table = new MTable(Env.getCtx(), msd.getAD_Table_ID(), null);
@ -216,7 +219,7 @@ public class DocumentSearchController implements EventListener<Event>{
pstmt.setQueryTimeout(1);
rs = pstmt.executeQuery();
int count = 0;
while (rs.next() && count < 3) {
while (rs.next() && count < MAX_RESULTS_PER_SEARCH) {
count++;
int id = rs.getInt(1);
SearchResult result = new SearchResult();