paging implemeneted in a dialog

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@98561 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-07-11 10:35:26 +00:00
parent b1020383fc
commit 33da8115af
8 changed files with 628 additions and 156 deletions

View File

@ -6,11 +6,13 @@ import java.util.List;
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel; import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result; import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row; import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
//import org.gcube.portlets.user.dbmanager.client.datamodel.FileModel; //import org.gcube.portlets.user.dbmanager.client.datamodel.FileModel;
//import org.gcube.portlets.user.dbmanager.client.datamodel.Result; //import org.gcube.portlets.user.dbmanager.client.datamodel.Result;
//import org.gcube.portlets.user.dbmanager.client.datamodel.Row; //import org.gcube.portlets.user.dbmanager.client.datamodel.Row;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -20,8 +22,7 @@ public interface GWTdbManagerService extends RemoteService {
List<FileModel> getResource() throws Exception; List<FileModel> getResource() throws Exception;
List<FileModel> getTables(LinkedHashMap<String, String> dataInput)
throws Exception;
LinkedHashMap<String, FileModel> getDBInfo(String resourceName) LinkedHashMap<String, FileModel> getDBInfo(String resourceName)
throws Exception; throws Exception;
@ -45,5 +46,7 @@ public interface GWTdbManagerService extends RemoteService {
LinkedHashMap<String, FileModel> getTableDetails(LinkedHashMap<String, String> dataInput) throws Exception; LinkedHashMap<String, FileModel> getTableDetails(LinkedHashMap<String, String> dataInput) throws Exception;
PagingLoadResult<Result> LoadTables(PagingLoadConfig config, LinkedHashMap<String, String> dataInput) throws Exception;
} }

View File

@ -6,11 +6,13 @@ import java.util.List;
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel; import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result; import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row; import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
//import org.gcube.portlets.user.dbmanager.client.datamodel.FileModel; //import org.gcube.portlets.user.dbmanager.client.datamodel.FileModel;
//import org.gcube.portlets.user.dbmanager.client.datamodel.Result; //import org.gcube.portlets.user.dbmanager.client.datamodel.Result;
//import org.gcube.portlets.user.dbmanager.client.datamodel.Row; //import org.gcube.portlets.user.dbmanager.client.datamodel.Row;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
public interface GWTdbManagerServiceAsync { public interface GWTdbManagerServiceAsync {
@ -20,8 +22,10 @@ public interface GWTdbManagerServiceAsync {
void getDBInfo(String resourceName, void getDBInfo(String resourceName,
AsyncCallback<LinkedHashMap<String, FileModel>> asyncCallback); AsyncCallback<LinkedHashMap<String, FileModel>> asyncCallback);
void getTables(LinkedHashMap<String, String> dataInput, // void getTables(LinkedHashMap<String, String> dataInput,
AsyncCallback<List<FileModel>> callback); // AsyncCallback<List<FileModel>> callback);
void getDBSchema(LinkedHashMap<String, String> dataInput, void getDBSchema(LinkedHashMap<String, String> dataInput,
AsyncCallback<List<FileModel>> callback); AsyncCallback<List<FileModel>> callback);
@ -45,4 +49,7 @@ public interface GWTdbManagerServiceAsync {
void randomSample(LinkedHashMap<String, String> dataInput, void randomSample(LinkedHashMap<String, String> dataInput,
AsyncCallback<List<Result>> callback); AsyncCallback<List<Result>> callback);
void LoadTables(PagingLoadConfig config, LinkedHashMap<String, String> dataInput,
AsyncCallback<PagingLoadResult<Result>> callback);
} }

View File

@ -7,6 +7,7 @@ public enum EventsTypeEnum {
SHOW_CREATE_TABLE_EVENT, SHOW_CREATE_TABLE_EVENT,
SAMPLING_EVENT, SAMPLING_EVENT,
SMART_SAMPLING_EVENT, SMART_SAMPLING_EVENT,
RANDOM_SAMPLING_EVENT; RANDOM_SAMPLING_EVENT,
LOAD_TABLES_EVENT;
} }

View File

@ -0,0 +1,33 @@
package org.gcube.portlets.user.databasesmanager.client.events;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.LoadTablesEventHandler;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.RandomSamplingEventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.GwtEvent.Type;
public class LoadTablesEvent extends GwtEvent<LoadTablesEventHandler>{
public static Type<LoadTablesEventHandler> TYPE = new Type<LoadTablesEventHandler>();
@Override
protected void dispatch(LoadTablesEventHandler handler) {
// TODO Auto-generated method stub
handler.onLoadTables(this);
}
@Override
public Type<LoadTablesEventHandler> getAssociatedType() {
// TODO Auto-generated method stub
return TYPE;
}
public EventsTypeEnum getKey() {
// TODO Auto-generated method stub
return EventsTypeEnum.LOAD_TABLES_EVENT;
}
}

View File

@ -0,0 +1,9 @@
package org.gcube.portlets.user.databasesmanager.client.events.interfaces;
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
import com.google.gwt.event.shared.EventHandler;
public interface LoadTablesEventHandler extends EventHandler{
public void onLoadTables(LoadTablesEvent loadTablesEvent);
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.databasesmanager.client.panels;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -12,12 +13,14 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result; import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row; import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData; import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
import org.gcube.portlets.user.databasesmanager.client.events.RandomSamplingEvent; import org.gcube.portlets.user.databasesmanager.client.events.RandomSamplingEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SamplingEvent; import org.gcube.portlets.user.databasesmanager.client.events.SamplingEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SelectedItemEvent; import org.gcube.portlets.user.databasesmanager.client.events.SelectedItemEvent;
import org.gcube.portlets.user.databasesmanager.client.events.ShowCreateTableEvent; import org.gcube.portlets.user.databasesmanager.client.events.ShowCreateTableEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SmartSamplingEvent; import org.gcube.portlets.user.databasesmanager.client.events.SmartSamplingEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SubmitQueryEvent; import org.gcube.portlets.user.databasesmanager.client.events.SubmitQueryEvent;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.LoadTablesEventHandler;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.RandomSamplingEventHandler; import org.gcube.portlets.user.databasesmanager.client.events.interfaces.RandomSamplingEventHandler;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SamplingEventHandler; import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SamplingEventHandler;
import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SelectedItemEventHandler; import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SelectedItemEventHandler;
@ -40,15 +43,29 @@ import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel; import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.EditorGrid; import com.extjs.gxt.ui.client.widget.grid.EditorGrid;
import com.extjs.gxt.ui.client.widget.grid.Grid; import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.LiveGridView;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout; import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData; import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData; import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.toolbar.FillToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.LiveToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
import com.extjs.gxt.ui.client.data.BasePagingLoader;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.extjs.gxt.ui.client.data.PagingLoader;
import com.extjs.gxt.ui.client.data.RpcProxy;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.GridEvent;
import com.extjs.gxt.ui.client.event.Listener; import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent; import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
//class that represents the container of all components //class that represents the container of all components
public class GxtBorderLayoutPanel extends ContentPanel { public class GxtBorderLayoutPanel extends ContentPanel {
@ -77,6 +94,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// variable that keeps track of the managed event // variable that keeps track of the managed event
private boolean submitQueryEventManaged = false; private boolean submitQueryEventManaged = false;
// private PagingToolBar toolBar = new PagingToolBar(100);
public GxtBorderLayoutPanel(HandlerManager eBus, public GxtBorderLayoutPanel(HandlerManager eBus,
GWTdbManagerServiceAsync service) throws Exception { GWTdbManagerServiceAsync service) throws Exception {
@ -151,6 +170,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
centerUpper.setHeading("Database Information"); centerUpper.setHeading("Database Information");
centerUpper.setScrollMode(Scroll.NONE); centerUpper.setScrollMode(Scroll.NONE);
// centerUpper.setBottomComponent(toolBar);
// toolBar.hide();
// CENTER BOTTOM // CENTER BOTTOM
centerBottom = new ContentPanel(); centerBottom = new ContentPanel();
@ -297,6 +320,17 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}); });
eventBus.addHandler(LoadTablesEvent.TYPE, new LoadTablesEventHandler() {
@Override
public void onLoadTables(LoadTablesEvent loadTablesEvent) {
// TODO Auto-generated method stub
loadTables();
}
});
eventBus.addHandler(SubmitQueryEvent.TYPE, eventBus.addHandler(SubmitQueryEvent.TYPE,
new SubmitQueryEventHandler() { new SubmitQueryEventHandler() {
@ -379,6 +413,306 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
private void loadTables() {
// System.out.println("Start RPC - loadTables");
rootLogger.log(Level.SEVERE, "Start RPC - loadTables");
// to mask the entire content panel
// this.mask("Loading", "x-mask-loading");
// get the selected item
List<FileModel> data = treePanel.getTreePanel().getSelectionModel()
.getSelectedItems();
FileModel element = data.get(0);
// recover data inputs
final LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
// check if the table has an associated schema
String resource = "";
String database = "";
String schema = "";
if (element.isDatabase()) { // the selected item is a database
rootLogger.log(Level.INFO, "element is a database ");
database = element.getName();
resource = treePanel.getTreeStore().getParent(element).getName();
dataInput.put("ResourceName", resource);
dataInput.put("DatabaseName", database);
dataInput.put("SchemaName", "");
} else { // the selected item is a schema
rootLogger.log(Level.INFO, "element is a schema ");
FileModel db = treePanel.getTreeStore().getParent(element);
database = db.getName();
resource = treePanel.getTreeStore().getParent(db).getName();
schema = element.getName();
dataInput.put("ResourceName", resource);
dataInput.put("DatabaseName", database);
dataInput.put("SchemaName", schema);
// dataInput.put("ResourceName", resource.getName());
// dataInput.put("DatabaseName", database.getName());
// dataInput.put("SchemaName", element.getName());
}
// FileModel database = store.getParent(element);
// FileModel resource = store.getParent(database);
//
// dataInput.put("ResourceName", resource.getName());
// dataInput.put("DatabaseName", database.getName());
// if (element.getDatabaseType().equals(ConstantsPortlet.POSTGRES)){
//
//
// }
// else{
// dataInput.put("SchemaName", "");
// }
// System.out.println("schema name: " + element.getName());
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
// rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
// rootLogger.log(Level.INFO, "SchemaName: " + element.getName());
rootLogger.log(Level.INFO, "ResourceName: " + resource);
rootLogger.log(Level.INFO, "DatabaseName: " + database);
rootLogger.log(Level.INFO, "SchemaName: " + schema);
// FileModel schema;
// FileModel database;
// FileModel resource;
//
// if (treePanel.getTreeStore().getParent(selectedItem).isDatabase()) {
//
// // the table has not a schema
//
// database = treePanel.getTreeStore().getParent(selectedItem);
// resource = treePanel.getTreeStore().getParent(database);
//
// dataInput.put("ResourceName", resource.getName());
// dataInput.put("DatabaseName", database.getName());
// dataInput.put("SchemaName", "");
// // dataInput.put("TableName", selectedItem.getName());
//
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
// rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
// rootLogger.log(Level.INFO, "SchemaName: " + selectedItem.getName());
//
// // schema = treePanel.getTreeStore().getParent(selectedItem);
// // database = treePanel.getTreeStore().getParent(schema);
// // resource = treePanel.getTreeStore().getParent(database);
// //
// // dataInput.put("ResourceName", resource.getName());
// // dataInput.put("DatabaseName", database.getName());
// // dataInput.put("SchemaName", schema.getName());
// // dataInput.put("TableName", selectedItem.getName());
// //
// // rootLogger.log(Level.INFO, "ResourceName: " +
// // resource.getName());
// // rootLogger.log(Level.INFO, "DatabaseName: " +
// // database.getName());
// // rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
// // rootLogger.log(Level.INFO, "SchemaName: " +
// // selectedItem.getName());
//
// } else {
// // the table has a schema
//
// schema = treePanel.getTreeStore().getParent(selectedItem);
// database = treePanel.getTreeStore().getParent(schema);
// resource = treePanel.getTreeStore().getParent(database);
//
// dataInput.put("ResourceName", resource.getName());
// dataInput.put("DatabaseName", database.getName());
// dataInput.put("SchemaName", schema.getName());
// // dataInput.put("TableName", selectedItem.getName());
//
// rootLogger.log(Level.INFO, "ResourceName: " + resource.getName());
// rootLogger.log(Level.INFO, "DatabaseName: " + database.getName());
// rootLogger.log(Level.INFO, "SchemaName: " + schema.getName());
// // rootLogger.log(Level.INFO, "SchemaName: " +
// selectedItem.getName());
//
// // the table has not a schema
// // database = treePanel.getTreeStore().getParent(selectedItem);
// // resource = treePanel.getTreeStore().getParent(database);
// //
// // dataInput.put("ResourceName", resource.getName());
// // dataInput.put("DatabaseName", database.getName());
// // dataInput.put("SchemaName", "");
// // dataInput.put("TableName", selectedItem.getName());
// //
// // rootLogger.log(Level.INFO, "ResourceName: " +
// // resource.getName());
// // rootLogger.log(Level.INFO, "DatabaseName: " +
// // database.getName());
// // rootLogger.log(Level.INFO, "SchemaName: " + "");
// // rootLogger.log(Level.INFO, "SchemaName: " +
// // selectedItem.getName());
// }
// create RpcProxy object to use the load configuration
RpcProxy<PagingLoadResult<Result>> proxy = new RpcProxy<PagingLoadResult<Result>>() {
@Override
protected void load(Object loadConfig,
AsyncCallback<PagingLoadResult<Result>> callback) {
RPCservice.LoadTables((PagingLoadConfig) loadConfig, dataInput,
callback);
// TODO Auto-generated method stub
}
};
// loader to load page enabled set of data
final PagingLoader<PagingLoadResult<Result>> loader = new BasePagingLoader<PagingLoadResult<Result>>(
proxy);
// loader.setRemoteSort(true);
// to create the lsitstore using the loader
ListStore<Result> result = new ListStore<Result>(loader);
// bind the loader with a PagingToolBar.
final PagingToolBar toolBar = new PagingToolBar(100);
toolBar.bind(loader);
// craete the column configuration
ColumnModel cm = createColumnModelForTables();
// create the grid with a result list and the column model
final Grid<Result> grid = new Grid<Result>(result, cm);
grid.setStateId("pagingGridExample");
grid.setStateful(true);
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
public void handleEvent(GridEvent<Result> be) {
PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0);
config.setLimit(100);
Map<String, Object> state = grid.getState();
if (state.containsKey("offset")) {
int offset = (Integer) state.get("offset");
int limit = (Integer) state.get("limit");
config.setOffset(offset);
config.setLimit(limit);
}
// if (state.containsKey("sortField")) {
// config.setSortField((String) state.get("sortField"));
// config.setSortDir(SortDir.valueOf((String) state
// .get("sortDir")));
// }
loader.load(config);
}
});
// grid.setLoadMask(true);
grid.setBorders(true);
// grid.setAutoExpandColumn("comments");
// grid.setStyleAttribute("borderTop", "none");
// grid.setStripeRows(true);
Dialog tablesLoaded = new Dialog();
tablesLoaded.setLayout(new FitLayout());
tablesLoaded.setHeading("Result");
tablesLoaded.setResizable(false);
tablesLoaded.setModal(true);
tablesLoaded.setBlinkModal(true);
tablesLoaded.setSize(600, 400);
tablesLoaded.setScrollMode(Scroll.NONE);
tablesLoaded.setHideOnButtonClick(true);
tablesLoaded.setMaximizable(true);
//
tablesLoaded.setBottomComponent(toolBar);
// aggiungere la toolbart
// centerUpper.setBottomComponent(toolBar);
// LiveGridView liveView = new LiveGridView();
// liveView.setEmptyText("No rows available on the server.");
// liveView.setRowHeight(32);
// grid.setView(liveView);
//
// ToolBar toolBar = new ToolBar();
// toolBar.add(new FillToolItem());
//
// LiveToolItem item = new LiveToolItem();
// item.bindGrid(grid);
//
// toolBar.add(item);
// tablesLoaded.setBottomComponent(toolBar);
// centerUpper.removeAll();
// centerUpper.setBottomComponent(toolBar);
// ContentPanel tablesLoaded = new ContentPanel();
// tablesLoaded.setLayout(new FitLayout());
// tablesLoaded.setBottomComponent(toolBar);
// tablesLoaded.add(grid);
// centerUpper.removeAll();
// centerUpper.add(tablesLoaded);
// toolBar.show();
// centerUpper.setBottomComponent(toolBar);
// centerUpper.add(grid);
// centerUpper.layout(true);
// centerUpper.show();
// RowData d = new RowData(.5, 1);
// d.setMargins(new Margins(6));
// tablesLoaded.add(grid, d);
tablesLoaded.add(grid);
tablesLoaded.show();
// ContentPanel panel = new ContentPanel();
// panel.setFrame(true);
// panel.setCollapsible(true);
// panel.setAnimCollapse(false);
//
// panel.setHeading("Paging Grid");
// panel.setLayout(new FitLayout());
// panel.add(grid);
// panel.setSize(600, 350);
// panel.setBottomComponent(toolBar);
// grid.getAriaSupport().setLabelledBy(panel.getId());
// add(panel);
}
private void submitQuery() { private void submitQuery() {
// System.out.println("Start RPC - submitQuery"); // System.out.println("Start RPC - submitQuery");
@ -1310,6 +1644,37 @@ public class GxtBorderLayoutPanel extends ContentPanel {
return new ColumnModel(configs); return new ColumnModel(configs);
} }
private ColumnModel createColumnModelForTables() {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("index");
column.setHeader("Index");
column.setWidth(100);
configs.add(column);
column = new ColumnConfig();
column.setId("value");
column.setHeader("Name");
column.setWidth(600);
// column2.setSortable(false);
TextField<String> textValue = new TextField<String>();
// text.setAllowBlank(false);
column.setEditor(new CellEditor(textValue));
configs.add(column);
// ListStore<Result> store = new ListStore<Result>();
// store.add(result);
return new ColumnModel(configs);
}
private void displayDBInfo(FileModel element) { private void displayDBInfo(FileModel element) {
// System.out.println("GxtBorderLayout->displaying info"); // System.out.println("GxtBorderLayout->displaying info");
@ -1322,7 +1687,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (dataDB != null) { if (dataDB != null) {
// System.out.println("GxtBorderLayout->size info: " + dataDB.size()); // System.out.println("GxtBorderLayout->size info: " +
// dataDB.size());
rootLogger.log(Level.INFO, "info size: " + dataDB.size()); rootLogger.log(Level.INFO, "info size: " + dataDB.size());

View File

@ -10,6 +10,7 @@ import java.util.logging.Logger;
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync; import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel; import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result; import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
import org.gcube.portlets.user.databasesmanager.client.events.SelectedItemEvent; import org.gcube.portlets.user.databasesmanager.client.events.SelectedItemEvent;
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet; import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
import com.extjs.gxt.ui.client.Style.SelectionMode; import com.extjs.gxt.ui.client.Style.SelectionMode;
@ -707,6 +708,9 @@ public class GxtTreePanel extends LayoutContainer {
private void loadTables(final FileModel element) { private void loadTables(final FileModel element) {
if (treePanel.isMasked())
treePanel.unmask();
// System.out.println("Start RPC - getTables"); // System.out.println("Start RPC - getTables");
// rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getTables"); // rootLogger.log(Level.SEVERE, "GxtTreePanel-> Start RPC - getTables");
@ -771,6 +775,8 @@ public class GxtTreePanel extends LayoutContainer {
if (element.isDatabase()) { // the selected item is a database if (element.isDatabase()) { // the selected item is a database
rootLogger.log(Level.INFO, "element is a database ");
database = element.getName(); database = element.getName();
resource = store.getParent(element).getName(); resource = store.getParent(element).getName();
@ -780,6 +786,8 @@ public class GxtTreePanel extends LayoutContainer {
} else { // the selected item is a schema } else { // the selected item is a schema
rootLogger.log(Level.INFO, "element is a schema ");
FileModel db = store.getParent(element); FileModel db = store.getParent(element);
database = db.getName(); database = db.getName();
@ -824,102 +832,116 @@ public class GxtTreePanel extends LayoutContainer {
// System.out.println(parent.getName()); // System.out.println(parent.getName());
// System.out.println(element.getName()); // System.out.println(element.getName());
// call remote service // // call remote service
//
RPCservice.getTables(dataInput, new AsyncCallback<List<FileModel>>() { // RPCservice.getTables(dataInput, new AsyncCallback<List<FileModel>>() {
//
@Override // @Override
public void onFailure(Throwable caught) { // public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // // Window.alert(caught.getMessage());
// System.out.println("FAILURE"); // // System.out.println("FAILURE");
rootLogger.log(Level.SEVERE, "FAILURE RPC getTables"); // rootLogger.log(Level.SEVERE, "FAILURE RPC getTables");
//
// no tables are available (the schema has not table) // // no tables are available (the schema has not table)
if (caught.getMessage().equals( // if (caught.getMessage().equals(
"java.lang.Exception: Result not available")) { // "java.lang.Exception: Result not available")) {
//
element.setIsExpanded(false); // element.setIsExpanded(false);
//
treePanel.setExpanded(element, false); // treePanel.setExpanded(element, false);
//
element.setIsLoaded(true);
if (treePanel.isMasked())
treePanel.unmask();
treePanel.enableEvents(true);
}
// MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(),
// null);
}
@Override
public void onSuccess(List<FileModel> result) {
// System.out.println("SUCCESS");
rootLogger.log(Level.SEVERE, "SUCCESS RPC getTables");
if (result.size() == 0) { // the database has not tables
// System.out.println("the database has not tables");
rootLogger.log(Level.SEVERE, "the database has not tables");
// loadTables(element);
element.setIsExpanded(false);
treePanel.setExpanded(element, false);
} else {
for (int i = 0; i < result.size(); i++) {
result.get(i).setIsTable(true);
result.get(i).setIsExpanded(false);
result.get(i).setIsLoaded(true);
// result.get(i).setIsSchema(false);
// element.setIsLoaded(true); // element.setIsLoaded(true);
//
// ppritn check // if (treePanel.isMasked())
// System.out.println(result.get(i).getName()); // treePanel.unmask();
//
// rootLogger.log(Level.INFO, "table: " // treePanel.enableEvents(true);
// + result.get(i).getName()); //
}
// int numChildrenFolder = store.getChildCount(element);
// if (numChildrenFolder == 0) {
addChildren(element, result);
// } // }
} //
// // MessageBox.alert("Error ","<br/>Message:"+caught.getMessage(),
// // null);
//
// }
//
// @Override
// public void onSuccess(List<FileModel> result) {
//
//
//
// // System.out.println("SUCCESS");
//
// rootLogger.log(Level.SEVERE, "SUCCESS RPC getTables");
//
// if (result.size() == 0) { // the database has not tables
//
// // System.out.println("the database has not tables");
//
// rootLogger.log(Level.SEVERE, "the database has not tables");
//
// // loadTables(element);
//// element.setIsExpanded(false);
////
//// treePanel.setExpanded(element, false);
//
// } else {
//
// for (int i = 0; i < result.size(); i++) {
//
// result.get(i).setIsTable(true);
//
//// result.get(i).setIsExpanded(false);
//
// result.get(i).setIsLoaded(true);
//
// // result.get(i).setIsSchema(false);
//
// // element.setIsLoaded(true);
//
// // ppritn check
// // System.out.println(result.get(i).getName());
//
// // rootLogger.log(Level.INFO, "table: "
// // + result.get(i).getName());
//
// }
//
// // int numChildrenFolder = store.getChildCount(element);
//
// // if (numChildrenFolder == 0) {
//
//
// //addChildren(element, result);
//
// //
//
// // }
// }
//
// element.setIsLoaded(true);
//
// element.setIsExpanded(false);
// treePanel.setExpanded(element, false);
//
// if (treePanel.isMasked())
// treePanel.unmask();
//
// treePanel.enableEvents(true);
//
// //fire event
// eventBus.fireEvent(new LoadTablesEvent());
//
//
//
// }
// });
//
// //System.out.println("End RPC - getTables");
//
// rootLogger.log(Level.SEVERE, "End RPC getTables");
element.setIsLoaded(true); //fire event to manage the tables loading
eventBus.fireEvent(new LoadTablesEvent());
if (treePanel.isMasked())
treePanel.unmask();
treePanel.enableEvents(true);
}
});
// System.out.println("End RPC - getTables");
rootLogger.log(Level.SEVERE, "End RPC getTables");
} }

View File

@ -54,6 +54,9 @@ import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
//import org.gcube.portlets.user.dbmanager.client.datamodel.Row; //import org.gcube.portlets.user.dbmanager.client.datamodel.Row;
//import org.gcube.portlets.user.dbmanager.server.util.SessionUtil; //import org.gcube.portlets.user.dbmanager.server.util.SessionUtil;
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.XStream;
@ -190,7 +193,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(i).setValue(resourceName); inputParameters.get(i).setValue(resourceName);
// rootLogger.log(Level.INFO, "ResourceName: " + resourceName); // rootLogger.log(Level.INFO, "ResourceName: " + resourceName);
rootLogger.log(Level.INFO, inputParameters.get(i).getName()); rootLogger.log(Level.INFO, inputParameters.get(i).getName());
@ -276,12 +278,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(0).setValue(dataInput.get("ResourceName")); inputParameters.get(0).setValue(dataInput.get("ResourceName"));
inputParameters.get(1).setValue(dataInput.get("DatabaseName")); inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
rootLogger.log(Level.INFO, "ResourceName: " + dataInput.get("ResourceName")); rootLogger.log(Level.INFO,
"ResourceName: " + dataInput.get("ResourceName"));
rootLogger.log(Level.INFO, "DatabaseName: " + dataInput.get("DatabaseName"));
rootLogger.log(Level.INFO,
"DatabaseName: " + dataInput.get("DatabaseName"));
String computationId = startComputation(algorithmId, inputParameters); String computationId = startComputation(algorithmId, inputParameters);
@ -310,15 +311,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} }
@Override private List<Result> getTables(LinkedHashMap<String, String> dataInput)
public List<FileModel> getTables(LinkedHashMap<String, String> dataInput)
throws Exception { throws Exception {
List<Parameter> inputParameters = new ArrayList<Parameter>(); List<Parameter> inputParameters = new ArrayList<Parameter>();
// List<String> outputParameters = new ArrayList<String>(); // List<String> outputParameters = new ArrayList<String>();
List<FileModel> outputParameters = new ArrayList<FileModel>(); List<Result> outputParameters = new ArrayList<Result>();
// get list of algorithms // get list of algorithms
@ -362,11 +362,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(1).setValue(dataInput.get("DatabaseName")); inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
inputParameters.get(2).setValue(dataInput.get("SchemaName")); inputParameters.get(2).setValue(dataInput.get("SchemaName"));
rootLogger.log(Level.SEVERE, "ResourceName: " + dataInput.get("ResourceName")); rootLogger.log(Level.SEVERE,
rootLogger.log(Level.SEVERE, "DatabaseName: " + dataInput.get("DatabaseName")); "ResourceName: " + dataInput.get("ResourceName"));
rootLogger.log(Level.SEVERE, "SchemaName: " + dataInput.get("SchemaName")); rootLogger.log(Level.SEVERE,
"DatabaseName: " + dataInput.get("DatabaseName"));
rootLogger.log(Level.SEVERE,
"SchemaName: " + dataInput.get("SchemaName"));
// System.out.println("size outputMap pre computation: " // System.out.println("size outputMap pre computation: "
// + outputMap.size()); // + outputMap.size());
@ -387,13 +388,16 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// outputParameters.add(outputKey.get(String.valueOf(i)) + " " // outputParameters.add(outputKey.get(String.valueOf(i)) + " "
// + outputMap.get(String.valueOf(i))); // + outputMap.get(String.valueOf(i)));
FileModel obj = new FileModel(outputMap.get(String.valueOf(i))); // FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
// obj.setIsLoaded(true); // obj.setIsLoaded(true);
// obj.setIsTable(true); // obj.setIsTable(true);
outputParameters.add(obj); Result row = new Result(String.valueOf(i), outputMap.get(String
.valueOf(i)));
outputParameters.add(row);
} }
@ -401,6 +405,35 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} }
@Override
public PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
LinkedHashMap<String, String> dataInput) throws Exception {
// TODO Auto-generated method stub
// get tables
List<Result> result = getTables(dataInput);
// Create a sublist and add data to list according
// to the limit and offset value of the config
ArrayList<Result> sublist = new ArrayList<Result>();
int start = config.getOffset();
int limit = result.size();
if (config.getLimit() > 0) {
limit = Math.min(start + config.getLimit(), limit);
}
for (int i = config.getOffset(); i < limit; i++) {
sublist.add(result.get(i));
}
return new BasePagingLoadResult<Result>(sublist,
config.getOffset(), result.size());
}
@Override @Override
public List<Result> submitQuery(LinkedHashMap<String, String> dataDB, public List<Result> submitQuery(LinkedHashMap<String, String> dataDB,
String query, boolean valueReadOnlyQuery, String query, boolean valueReadOnlyQuery,
@ -466,7 +499,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(0).setValue(dataDB.get("ResourceName")); inputParameters.get(0).setValue(dataDB.get("ResourceName"));
inputParameters.get(1).setValue(dataDB.get("DatabaseName")); inputParameters.get(1).setValue(dataDB.get("DatabaseName"));
rootLogger.log(Level.INFO, "ResourceName " + dataDB.get("ResourceName")); rootLogger
.log(Level.INFO, "ResourceName " + dataDB.get("ResourceName"));
rootLogger.log(Level.INFO, "DatabaseName" + dataDB.get("DatabaseName")); rootLogger.log(Level.INFO, "DatabaseName" + dataDB.get("DatabaseName"));
inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery)); inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
@ -600,7 +634,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
public List<Result> smartSample(LinkedHashMap<String, String> dataInput) public List<Result> smartSample(LinkedHashMap<String, String> dataInput)
throws Exception { throws Exception {
List<Parameter> inputParameters = new ArrayList<Parameter>(); List<Parameter> inputParameters = new ArrayList<Parameter>();
// sample result // sample result
@ -1297,6 +1330,4 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} }
} }