bug fixed in LoadTables of GWTdbManagerServiceImpl class and in the callback "onSucces" of the rpc LoadTables if a user inserts a table that non exist in the database. The paging display "no data are displayed" message.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@98768 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4a8e86436d
commit
38a7e3daa5
|
@ -675,7 +675,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
rootLogger.log(Level.SEVERE,
|
rootLogger.log(Level.SEVERE,
|
||||||
"FAILURE RPC getTables");
|
"FAILURE RPC getTables");
|
||||||
|
|
||||||
caught.printStackTrace();
|
// caught.printStackTrace();
|
||||||
|
|
||||||
callback.onFailure(caught);
|
callback.onFailure(caught);
|
||||||
|
|
||||||
|
@ -725,10 +725,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
// tablesLoaded.show();
|
// tablesLoaded.show();
|
||||||
|
|
||||||
tablesLoaded.hide();
|
// tablesLoaded.hide();
|
||||||
|
|
||||||
MessageBox.alert("Error ", "<br/>Message:"
|
// MessageBox.alert("Error ", "<br/>Message:"
|
||||||
+ "no tables available", null);
|
// + "no tables available", null);
|
||||||
|
|
||||||
// if
|
// if
|
||||||
// (((EditorGrid<Result>)tablesLoaded.getWidget(0)).isMasked())
|
// (((EditorGrid<Result>)tablesLoaded.getWidget(0)).isMasked())
|
||||||
|
@ -954,6 +954,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
|
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
|
||||||
public void handleEvent(GridEvent<Result> be) {
|
public void handleEvent(GridEvent<Result> be) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rootLogger.log(Level.INFO, "event Attach handled");
|
||||||
|
|
||||||
PagingLoadConfig config = new BasePagingLoadConfig();
|
PagingLoadConfig config = new BasePagingLoadConfig();
|
||||||
|
|
||||||
|
@ -963,18 +967,21 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// The number of records being requested.
|
// The number of records being requested.
|
||||||
config.setLimit(100);
|
config.setLimit(100);
|
||||||
|
|
||||||
Map<String, Object> state = grid.getState();
|
// Map<String, Object> state = grid.getState();
|
||||||
|
|
||||||
if (state.containsKey("offset")) {
|
// if (state.containsKey("offset")) {
|
||||||
int offset = (Integer) state.get("offset");
|
//
|
||||||
rootLogger.log(Level.INFO, "offset: " + offset);
|
//// rootLogger.log(Level.INFO, "state contains offset");
|
||||||
|
//
|
||||||
int limit = (Integer) state.get("limit");
|
// int offset = (Integer) state.get("offset");
|
||||||
rootLogger.log(Level.INFO, "limit: " + limit);
|
// rootLogger.log(Level.INFO, "offset: " + offset);
|
||||||
|
//
|
||||||
config.setOffset(offset);
|
// int limit = (Integer) state.get("limit");
|
||||||
config.setLimit(limit);
|
// rootLogger.log(Level.INFO, "limit: " + limit);
|
||||||
}
|
//
|
||||||
|
// config.setOffset(offset);
|
||||||
|
// config.setLimit(limit);
|
||||||
|
// }
|
||||||
// if (state.containsKey("sortField")) {
|
// if (state.containsKey("sortField")) {
|
||||||
// config.setSortField((String) state.get("sortField"));
|
// config.setSortField((String) state.get("sortField"));
|
||||||
// config.setSortDir(SortDir.valueOf((String) state
|
// config.setSortDir(SortDir.valueOf((String) state
|
||||||
|
@ -3299,7 +3306,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
private void displayTableName(String tableName) {
|
private void displayTableName(String tableName) {
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "displaying table name" + table
|
rootLogger.log(Level.INFO, "displaying table name" + tableName
|
||||||
+ " in the panel");
|
+ " in the panel");
|
||||||
|
|
||||||
Result table = new Result("selected table is", tableName);
|
Result table = new Result("selected table is", tableName);
|
||||||
|
|
|
@ -405,53 +405,64 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Result> result = null;
|
private List<Result> result = null;
|
||||||
String currentDB = "";
|
private String currentDB = "";
|
||||||
String previousDB = "";
|
private String previousDB = "";
|
||||||
|
|
||||||
|
private String currentSchema="";
|
||||||
|
private String previousSchema="";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
|
public PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
|
||||||
LinkedHashMap<String, String> dataInput, boolean SearchTable,
|
LinkedHashMap<String, String> dataInput, boolean SearchTable,
|
||||||
String keyword) throws Exception {
|
String keyword) throws Exception {
|
||||||
|
|
||||||
currentDB = dataInput.get("DatabaseName");
|
currentDB = dataInput.get("DatabaseName");
|
||||||
if (!currentDB.equals(previousDB)){
|
if (!currentDB.equals(previousDB)) {
|
||||||
|
result = null;
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
|
||||||
|
previousDB = currentDB;
|
||||||
|
|
||||||
|
currentSchema=dataInput.get("SchemaName");
|
||||||
|
if (!currentSchema.equals(previousSchema)){
|
||||||
result = null;
|
result = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
previousDB = currentDB;
|
previousSchema=currentSchema;
|
||||||
|
|
||||||
// get tables
|
// get tables
|
||||||
if (result == null)
|
if (result == null)
|
||||||
result = getTables(dataInput);
|
result = getTables(dataInput);
|
||||||
|
|
||||||
// Create a sublist and add data to list according
|
// Create a sublist and add data to list according
|
||||||
// to the limit and offset value of the config
|
// to the limit and offset value of the config
|
||||||
|
|
||||||
List<Result> sublist = new ArrayList<Result>();
|
List<Result> sublist = new ArrayList<Result>();
|
||||||
|
|
||||||
BasePagingLoadResult loadResult = null;
|
BasePagingLoadResult loadResult = null;
|
||||||
|
|
||||||
rootLogger.log(Level.INFO, "Searching in the table: "+SearchTable);
|
rootLogger.log(Level.INFO, "Searching in the table: " + SearchTable);
|
||||||
rootLogger.log(Level.INFO, "Keyword to search: "+keyword);
|
rootLogger.log(Level.INFO, "Keyword to search: " + keyword);
|
||||||
|
|
||||||
int start = config.getOffset();
|
int start = config.getOffset();
|
||||||
int limit = result.size();
|
int limit = result.size();
|
||||||
|
|
||||||
|
|
||||||
if (config.getLimit() > 0) {
|
if (config.getLimit() > 0) {
|
||||||
limit = Math.min(start + config.getLimit(), limit);
|
limit = Math.min(start + config.getLimit(), limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
//print check
|
|
||||||
rootLogger.log(Level.INFO, "result size: " + result.size());
|
|
||||||
rootLogger.log(Level.INFO, "limit: " + limit);
|
|
||||||
rootLogger.log(Level.INFO, "offset: " + config.getOffset());
|
|
||||||
rootLogger.log(Level.INFO, "start: " + start);
|
|
||||||
|
|
||||||
int totalNumber = result.size();
|
int totalNumber = result.size();
|
||||||
if ((SearchTable == false) || keyword==null || keyword.length()==0) {
|
|
||||||
sublist = new ArrayList<Result>(result.subList(start, limit));
|
if ((SearchTable == false) || keyword == null || keyword.length() == 0) {
|
||||||
|
sublist = new ArrayList<Result>(result.subList(start, limit));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
rootLogger.log(Level.INFO, "searching the table");
|
||||||
|
|
||||||
// search the table
|
// search the table
|
||||||
for (int i = 0; i < result.size(); i++) {
|
for (int i = 0; i < result.size(); i++) {
|
||||||
if ((result.get(i).getValue().toLowerCase()).startsWith(keyword
|
if ((result.get(i).getValue().toLowerCase()).startsWith(keyword
|
||||||
|
@ -460,18 +471,31 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
limit = sublist.size();
|
||||||
|
|
||||||
int sublen = sublist.size();
|
int sublen = sublist.size();
|
||||||
if (start<sublen-1){
|
totalNumber = sublen;
|
||||||
|
|
||||||
|
if (start < sublen - 1) {
|
||||||
limit = Math.min(sublen, limit);
|
limit = Math.min(sublen, limit);
|
||||||
totalNumber = sublist.size();
|
totalNumber = sublist.size();
|
||||||
sublist = new ArrayList<Result>(sublist.subList(start, limit));
|
sublist = new ArrayList<Result>(sublist.subList(start, limit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print check
|
||||||
|
rootLogger.log(Level.INFO, "result size: " + totalNumber);
|
||||||
|
rootLogger.log(Level.INFO, "limit: " + limit);
|
||||||
|
rootLogger.log(Level.INFO, "offset: " + config.getOffset());
|
||||||
|
rootLogger.log(Level.INFO, "start: " + start);
|
||||||
|
|
||||||
loadResult = new BasePagingLoadResult<Result>(sublist,
|
loadResult = new BasePagingLoadResult<Result>(sublist,
|
||||||
config.getOffset(), totalNumber);
|
config.getOffset(), totalNumber);
|
||||||
|
//
|
||||||
|
// if (totalNumber==0){
|
||||||
|
// loadResult=new BasePagingLoadResult<>(sublist);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
return loadResult;
|
return loadResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue