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:
Loredana Liccardo 2014-07-17 15:14:34 +00:00
parent 4a8e86436d
commit 38a7e3daa5
2 changed files with 70 additions and 39 deletions

View File

@ -675,7 +675,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.SEVERE,
"FAILURE RPC getTables");
caught.printStackTrace();
// caught.printStackTrace();
callback.onFailure(caught);
@ -725,10 +725,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// tablesLoaded.show();
tablesLoaded.hide();
// tablesLoaded.hide();
MessageBox.alert("Error ", "<br/>Message:"
+ "no tables available", null);
// MessageBox.alert("Error ", "<br/>Message:"
// + "no tables available", null);
// if
// (((EditorGrid<Result>)tablesLoaded.getWidget(0)).isMasked())
@ -954,6 +954,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
public void handleEvent(GridEvent<Result> be) {
rootLogger.log(Level.INFO, "event Attach handled");
PagingLoadConfig config = new BasePagingLoadConfig();
@ -963,18 +967,21 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// The number of records being requested.
config.setLimit(100);
Map<String, Object> state = grid.getState();
// Map<String, Object> state = grid.getState();
if (state.containsKey("offset")) {
int offset = (Integer) state.get("offset");
rootLogger.log(Level.INFO, "offset: " + offset);
int limit = (Integer) state.get("limit");
rootLogger.log(Level.INFO, "limit: " + limit);
config.setOffset(offset);
config.setLimit(limit);
}
// if (state.containsKey("offset")) {
//
//// rootLogger.log(Level.INFO, "state contains offset");
//
// int offset = (Integer) state.get("offset");
// rootLogger.log(Level.INFO, "offset: " + offset);
//
// int limit = (Integer) state.get("limit");
// rootLogger.log(Level.INFO, "limit: " + limit);
//
// config.setOffset(offset);
// config.setLimit(limit);
// }
// if (state.containsKey("sortField")) {
// config.setSortField((String) state.get("sortField"));
// config.setSortDir(SortDir.valueOf((String) state
@ -3299,7 +3306,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
private void displayTableName(String tableName) {
rootLogger.log(Level.INFO, "displaying table name" + table
rootLogger.log(Level.INFO, "displaying table name" + tableName
+ " in the panel");
Result table = new Result("selected table is", tableName);

View File

@ -405,53 +405,64 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
List<Result> result = null;
String currentDB = "";
String previousDB = "";
private List<Result> result = null;
private String currentDB = "";
private String previousDB = "";
private String currentSchema="";
private String previousSchema="";
@Override
public PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
LinkedHashMap<String, String> dataInput, boolean SearchTable,
String keyword) throws Exception {
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;
System.gc();
}
previousDB = currentDB;
previousSchema=currentSchema;
// get tables
if (result == null)
result = getTables(dataInput);
// Create a sublist and add data to list according
// to the limit and offset value of the config
List<Result> sublist = new ArrayList<Result>();
BasePagingLoadResult loadResult = null;
rootLogger.log(Level.INFO, "Searching in the table: "+SearchTable);
rootLogger.log(Level.INFO, "Keyword to search: "+keyword);
rootLogger.log(Level.INFO, "Searching in the table: " + SearchTable);
rootLogger.log(Level.INFO, "Keyword to search: " + keyword);
int start = config.getOffset();
int limit = result.size();
if (config.getLimit() > 0) {
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();
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 {
rootLogger.log(Level.INFO, "searching the table");
// search the table
for (int i = 0; i < result.size(); i++) {
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();
if (start<sublen-1){
totalNumber = sublen;
if (start < sublen - 1) {
limit = Math.min(sublen, limit);
totalNumber = sublist.size();
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,
config.getOffset(), totalNumber);
//
// if (totalNumber==0){
// loadResult=new BasePagingLoadResult<>(sublist);
// }
return loadResult;
}