code commented removed

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@99577 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-09-08 10:36:49 +00:00
parent e955f2bc42
commit af9eb785ef
9 changed files with 108 additions and 389 deletions

View File

@ -1,7 +1,6 @@
package org.gcube.portlets.user.databasesmanager.client.events; package org.gcube.portlets.user.databasesmanager.client.events;
public enum EventsTypeEnum { public enum EventsTypeEnum {
SELECTED_ITEM_EVENT, SELECTED_ITEM_EVENT,
SUBMIT_QUERY_EVENT, SUBMIT_QUERY_EVENT,
SHOW_CREATE_TABLE_EVENT, SHOW_CREATE_TABLE_EVENT,
@ -11,5 +10,4 @@ public enum EventsTypeEnum {
LOAD_TABLES_EVENT, LOAD_TABLES_EVENT,
SELECTED_TABLE_EVENT, SELECTED_TABLE_EVENT,
CANCEL_EXECUTION_QUERY; CANCEL_EXECUTION_QUERY;
}
}

View File

@ -20,13 +20,11 @@ public class GxtFormSubmitQuery extends LayoutContainer {
private static Logger rootLogger = Logger.getLogger("GxtFormSubmitQuery"); private static Logger rootLogger = Logger.getLogger("GxtFormSubmitQuery");
public GxtFormSubmitQuery() { public GxtFormSubmitQuery() {
this.setLayout(new FitLayout()); this.setLayout(new FitLayout());
// this.setSize(600, 400); // this.setSize(600, 400);
formData = new FormData("-20"); formData = new FormData("-20");
// vp = new VerticalPanel(); // vp = new VerticalPanel();
// vp.setSpacing(10); // vp.setSpacing(10);
createLayout(); createLayout();
// add(vp); // add(vp);
} }
@ -90,7 +88,6 @@ public class GxtFormSubmitQuery extends LayoutContainer {
// form.add(combo, formData); // form.add(combo, formData);
// vp.add(form); // vp.add(form);
this.add(form); this.add(form);
} }
@ -137,5 +134,4 @@ public class GxtFormSubmitQuery extends LayoutContainer {
// + checkRO.getValue()); // + checkRO.getValue());
// return (checkRO.getValue()); // return (checkRO.getValue());
// } // }
} }

View File

@ -79,7 +79,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
/* Create Root Logger */ /* Create Root Logger */
private static Logger rootLogger = Logger.getLogger("GxtBorderLayoutPanel"); private static Logger rootLogger = Logger.getLogger("GxtBorderLayoutPanel");
private ContentPanel north; private ContentPanel north;
private ContentPanel west; private ContentPanel west;
private LayoutContainer center; private LayoutContainer center;
@ -88,7 +87,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
private GxtTreePanel treePanel; private GxtTreePanel treePanel;
// top toolbar that contains the buttons // top toolbar that contains the buttons
private GxtToolbarFunctionality toolbar; private GxtToolbarFunctionality toolbar;
// private List<String> listAttributes; // private List<String> listAttributes;
// bus to manage events // bus to manage events
private HandlerManager eventBus = null; private HandlerManager eventBus = null;
@ -107,7 +105,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public GxtBorderLayoutPanel(HandlerManager eBus, public GxtBorderLayoutPanel(HandlerManager eBus,
GWTdbManagerServiceAsync service) throws Exception { GWTdbManagerServiceAsync service) throws Exception {
eventBus = eBus; eventBus = eBus;
RPCservice = service; RPCservice = service;
north = new ContentPanel(); north = new ContentPanel();
@ -116,7 +113,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
treePanel = new GxtTreePanel(eventBus, service); treePanel = new GxtTreePanel(eventBus, service);
// toolbar = new GxtToolbarFunctionality(eventBus); // toolbar = new GxtToolbarFunctionality(eventBus);
toolbar = new GxtToolbarFunctionality(eventBus, RPCservice); toolbar = new GxtToolbarFunctionality(eventBus, RPCservice);
this.setHeaderVisible(false); // hide the header of the panel this.setHeaderVisible(false); // hide the header of the panel
initLayout(); initLayout();
@ -125,22 +121,17 @@ public class GxtBorderLayoutPanel extends ContentPanel {
} }
private void initLayout() { private void initLayout() {
north.setLayout(new FitLayout()); north.setLayout(new FitLayout());
north.setTopComponent(toolbar.getToolBar()); north.setTopComponent(toolbar.getToolBar());
north.add(toolbar.getToolBar()); north.add(toolbar.getToolBar());
west.setLayout(new FitLayout()); west.setLayout(new FitLayout());
west.setHeading("Databases Resources"); west.setHeading("Databases Resources");
west.add(treePanel); west.add(treePanel);
west.setScrollMode(Scroll.AUTO); west.setScrollMode(Scroll.AUTO);
center.setLayout(new BorderLayout()); center.setLayout(new BorderLayout());
} }
public void createLayouts() { public void createLayouts() {
// Border layout for the external container // Border layout for the external container
final BorderLayout borderLayoutNordWest = new BorderLayout(); final BorderLayout borderLayoutNordWest = new BorderLayout();
setLayout(borderLayoutNordWest); setLayout(borderLayoutNordWest);
@ -176,7 +167,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
centerUpper.setScrollMode(Scroll.NONE); centerUpper.setScrollMode(Scroll.NONE);
// centerUpper.setBottomComponent(toolBar); // centerUpper.setBottomComponent(toolBar);
// toolBar.hide(); // toolBar.hide();
BorderLayoutData centerUpperData = new BorderLayoutData( BorderLayoutData centerUpperData = new BorderLayoutData(
LayoutRegion.NORTH, 250, 100, 250); LayoutRegion.NORTH, 250, 100, 250);
centerUpperData.setSplit(true); // Split bar between regions centerUpperData.setSplit(true); // Split bar between regions
@ -191,7 +181,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
centerBottom.setLayout(new FitLayout()); centerBottom.setLayout(new FitLayout());
centerBottom.setHeading("Information Details"); centerBottom.setHeading("Information Details");
centerBottom.setScrollMode(Scroll.NONE); centerBottom.setScrollMode(Scroll.NONE);
BorderLayoutData centerBottomData = new BorderLayoutData( BorderLayoutData centerBottomData = new BorderLayoutData(
LayoutRegion.CENTER); LayoutRegion.CENTER);
centerBottomData.setSplit(true); centerBottomData.setSplit(true);
@ -214,10 +203,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
eventBus.addHandler(SelectedItemEvent.TYPE, eventBus.addHandler(SelectedItemEvent.TYPE,
new SelectedItemEventHandler() { new SelectedItemEventHandler() {
public void onSelectedItem( public void onSelectedItem(
SelectedItemEvent selectedItemEvent) { SelectedItemEvent selectedItemEvent) {
// force the clean of the content panel // force the clean of the content panel
centerBottom.removeAll(); centerBottom.removeAll();
centerBottom.layout(true); centerBottom.layout(true);
@ -229,12 +216,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
int DepthSelectedItem = treePanel.getTreeStore() int DepthSelectedItem = treePanel.getTreeStore()
.getDepth(selectedItem); .getDepth(selectedItem);
String text = selectedItem.getName(); String text = selectedItem.getName();
rootLogger.log(Level.INFO, "selected item: " + text); rootLogger.log(Level.INFO, "selected item: " + text);
// disable table details and sampling buttons // disable table details and sampling buttons
toolbar.disableButtonsOperationsOnTable(); toolbar.disableButtonsOperationsOnTable();
// enable appropriate buttons according the selected // enable appropriate buttons according the selected
// item // item
toolbar.enableButtonOnToolbar(DepthSelectedItem, toolbar.enableButtonOnToolbar(DepthSelectedItem,
@ -248,7 +233,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
centerUpper.removeAll(); centerUpper.removeAll();
centerUpper.layout(true); centerUpper.layout(true);
} }
if (DepthSelectedItem == 3) { // the item selected is a if (DepthSelectedItem == 3) { // the item selected is a
// database. // database.
@ -308,7 +292,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
@Override @Override
public void onShowCreateTable( public void onShowCreateTable(
ShowCreateTableEvent showCreateTableEvent) { ShowCreateTableEvent showCreateTableEvent) {
// get the selected item in the tree // get the selected item in the tree
List<FileModel> data = treePanel.getTreePanel() List<FileModel> data = treePanel.getTreePanel()
.getSelectionModel().getSelectedItems(); .getSelectionModel().getSelectedItems();
@ -320,10 +303,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
table.setName(selectedTable); table.setName(selectedTable);
table.setTableDetailsDisplayed(false); table.setTableDetailsDisplayed(false);
} }
rootLogger.log(Level.INFO, rootLogger.log(Level.INFO,
"selected table: " + table.getName()); "selected table: " + table.getName());
// get table details // get table details
getTableDetails(table); getTableDetails(table);
} }
@ -332,13 +313,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// method to load the tables list // method to load the tables list
private void loadTables() { private void loadTables() {
// clean variable // clean variable
selectedTable = null; selectedTable = null;
// disable table details and sampling buttons // disable table details and sampling buttons
toolbar.disableButtonsOperationsOnTable(); toolbar.disableButtonsOperationsOnTable();
// clean the panel // clean the panel
centerBottom.removeAll(); centerBottom.removeAll();
centerBottom.layout(true); centerBottom.layout(true);
@ -347,10 +326,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
List<FileModel> data = treePanel.getTreePanel().getSelectionModel() List<FileModel> data = treePanel.getTreePanel().getSelectionModel()
.getSelectedItems(); .getSelectedItems();
FileModel element = data.get(0); FileModel element = data.get(0);
// recover data inputs // recover data inputs
final LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>(); final LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
// check if the table has an associated schema // check if the table has an associated schema
String resource = ""; String resource = "";
String database = ""; String database = "";
@ -358,23 +335,18 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (element.isDatabase()) { // the selected item is a database if (element.isDatabase()) { // the selected item is a database
rootLogger.log(Level.INFO, "selected element is a database "); rootLogger.log(Level.INFO, "selected element is a database ");
database = element.getName(); database = element.getName();
resource = treePanel.getTreeStore().getParent(element).getName(); resource = treePanel.getTreeStore().getParent(element).getName();
// add data // add data
dataInput.put("ResourceName", resource); dataInput.put("ResourceName", resource);
dataInput.put("DatabaseName", database); dataInput.put("DatabaseName", database);
dataInput.put("SchemaName", ""); dataInput.put("SchemaName", "");
} else { // the selected item is a schema } else { // the selected item is a schema
rootLogger.log(Level.INFO, "selected element is a schema "); rootLogger.log(Level.INFO, "selected element is a schema ");
FileModel db = treePanel.getTreeStore().getParent(element); FileModel db = treePanel.getTreeStore().getParent(element);
database = db.getName(); database = db.getName();
resource = treePanel.getTreeStore().getParent(db).getName(); resource = treePanel.getTreeStore().getParent(db).getName();
schema = element.getName(); schema = element.getName();
// add data // add data
dataInput.put("ResourceName", resource); dataInput.put("ResourceName", resource);
dataInput.put("DatabaseName", database); dataInput.put("DatabaseName", database);
@ -388,7 +360,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// create RpcProxy object to use the load configuration // create RpcProxy object to use the load configuration
RpcProxy<PagingLoadResult<Result>> proxy = new RpcProxy<PagingLoadResult<Result>>() { RpcProxy<PagingLoadResult<Result>> proxy = new RpcProxy<PagingLoadResult<Result>>() {
@Override @Override
protected void load(Object loadConfig, protected void load(Object loadConfig,
final AsyncCallback<PagingLoadResult<Result>> callback) { final AsyncCallback<PagingLoadResult<Result>> callback) {
@ -397,7 +368,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "keyword rpc: " + keyword); rootLogger.log(Level.INFO, "keyword rpc: " + keyword);
rootLogger.log(Level.INFO, "Search Table rpc: " rootLogger.log(Level.INFO, "Search Table rpc: "
+ startSearchTable); + startSearchTable);
// remote rpc // remote rpc
RPCservice.LoadTables((PagingLoadConfig) loadConfig, dataInput, RPCservice.LoadTables((PagingLoadConfig) loadConfig, dataInput,
startSearchTable, keyword, startSearchTable, keyword,
@ -406,10 +376,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
"FAILURE RPC LoadTables"); "FAILURE RPC LoadTables");
// caught.printStackTrace(); // caught.printStackTrace();
callback.onFailure(caught); callback.onFailure(caught);
// hide the dialog // hide the dialog
tablesLoaded.hide(); tablesLoaded.hide();
@ -422,7 +390,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
MessageBox.alert("Error ", "<br/>Message:" MessageBox.alert("Error ", "<br/>Message:"
+ caught.getMessage(), null); + caught.getMessage(), null);
} }
if (keyword == null) { if (keyword == null) {
startSearchTable = false; startSearchTable = false;
} }
@ -433,13 +400,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
PagingLoadResult<Result> result) { PagingLoadResult<Result> result) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
"SUCCESS RPC LoadTables"); "SUCCESS RPC LoadTables");
callback.onSuccess(result); callback.onSuccess(result);
if (keyword == null) { if (keyword == null) {
startSearchTable = false; startSearchTable = false;
} }
// enable toolbar in the dialog // enable toolbar in the dialog
toolBarTop.enable(); toolBarTop.enable();
} }
@ -451,7 +415,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// loader to load page enabled set of data // loader to load page enabled set of data
final PagingLoader<PagingLoadResult<Result>> loader = new BasePagingLoader<PagingLoadResult<Result>>( final PagingLoader<PagingLoadResult<Result>> loader = new BasePagingLoader<PagingLoadResult<Result>>(
proxy); proxy);
// loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() { // loader.addListener(Loader.BeforeLoad, new Listener<LoadEvent>() {
// public void handleEvent(LoadEvent be) { // public void handleEvent(LoadEvent be) {
// BasePagingLoadConfig m = be.<BasePagingLoadConfig> getConfig(); // BasePagingLoadConfig m = be.<BasePagingLoadConfig> getConfig();
@ -463,7 +426,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// // m.set("dir", (m.get("sortDir") == null || (m.get("sortDir") != // // m.set("dir", (m.get("sortDir") == null || (m.get("sortDir") !=
// null && m.<SortDir> get("sortDir").equals( // null && m.<SortDir> get("sortDir").equals(
// // SortDir.NONE))) ? "" : m.get("sortDir")); // // SortDir.NONE))) ? "" : m.get("sortDir"));
//
// } // }
// }); // });
// loader.setRemoteSort(true); // loader.setRemoteSort(true);
@ -480,7 +442,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// create the grid with a result list and the column model // create the grid with a result list and the column model
final EditorGrid<Result> grid = new EditorGrid<Result>(result, cm); final EditorGrid<Result> grid = new EditorGrid<Result>(result, cm);
// set the double click for row edit // set the double click for row edit
grid.setClicksToEdit(ClicksToEdit.TWO); grid.setClicksToEdit(ClicksToEdit.TWO);
// grid.setStateId("TablesList"); // grid.setStateId("TablesList");
@ -490,7 +451,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// grid.setAutoExpandColumn("comments"); // grid.setAutoExpandColumn("comments");
// grid.setStyleAttribute("borderTop", "none"); // grid.setStyleAttribute("borderTop", "none");
grid.setStripeRows(true); grid.setStripeRows(true);
// to manage the table selection in the grid // to manage the table selection in the grid
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
@ -521,14 +481,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
// start search calling the rpc // start search calling the rpc
// get the keyword // get the keyword
keyword = searchTable.getValue(); keyword = searchTable.getValue();
startSearchTable = true; startSearchTable = true;
rootLogger.log(Level.INFO, "keyword: " + keyword); rootLogger.log(Level.INFO, "keyword: " + keyword);
rootLogger.log(Level.INFO, "Search Table: " + startSearchTable); rootLogger.log(Level.INFO, "Search Table: " + startSearchTable);
PagingLoadConfig config = new BasePagingLoadConfig(); PagingLoadConfig config = new BasePagingLoadConfig();
// The offset for the first record to retrieve. // The offset for the first record to retrieve.
config.setOffset(0); config.setOffset(0);
@ -559,11 +516,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
startSearchTable = false; startSearchTable = false;
// clear the textfield // clear the textfield
searchTable.clear(); searchTable.clear();
PagingLoadConfig config = new BasePagingLoadConfig(); PagingLoadConfig config = new BasePagingLoadConfig();
config.setOffset(0); config.setOffset(0);
config.setLimit(100); config.setLimit(100);
loader.load(config); loader.load(config);
} }
}); });
@ -595,11 +550,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
grid.addListener(Events.RowClick, new Listener<GridEvent<Result>>() { grid.addListener(Events.RowClick, new Listener<GridEvent<Result>>() {
@Override @Override
public void handleEvent(final GridEvent<Result> be) { public void handleEvent(final GridEvent<Result> be) {
rootLogger.log(Level.INFO, "table clicked: " rootLogger.log(Level.INFO, "table clicked: "
+ grid.getSelectionModel().getSelectedItems().get(0) + grid.getSelectionModel().getSelectedItems().get(0)
.getValue()); .getValue());
// select the item // select the item
grid.getSelectionModel().select( grid.getSelectionModel().select(
grid.getSelectionModel().getSelectedItems().get(0), grid.getSelectionModel().getSelectedItems().get(0),
@ -629,11 +582,9 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// the Tables List button is selected. // the Tables List button is selected.
// it seems to fire when the event source is attached to the browser's // it seems to fire when the event source is attached to the browser's
// document or detached from it. // document or detached from it.
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"); rootLogger.log(Level.INFO, "event Attach handled");
// disable the top toolbar at the first tables loading in such a // disable the top toolbar at the first tables loading in such a
// way to disallow a user the search. It will be enabled in the // way to disallow a user the search. It will be enabled in the
// rpc when the tables are retrieved. // rpc when the tables are retrieved.
@ -698,24 +649,20 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// loader.load(config); // loader.load(config);
// } // }
// }); // });
tablesLoaded.setTopComponent(toolBarTop); tablesLoaded.setTopComponent(toolBarTop);
// listener to manage the table selection in the grid // listener to manage the table selection in the grid
Button ok = (Button) tablesLoaded.getButtonBar().getWidget(0); Button ok = (Button) tablesLoaded.getButtonBar().getWidget(0);
rootLogger.log(Level.INFO, "button: " + ok.getText()); rootLogger.log(Level.INFO, "button: " + ok.getText());
Button canc = (Button) tablesLoaded.getButtonBar().getWidget(1); Button canc = (Button) tablesLoaded.getButtonBar().getWidget(1);
rootLogger.log(Level.INFO, "button: " + canc.getText()); rootLogger.log(Level.INFO, "button: " + canc.getText());
// listener for buttons // listener for buttons
ok.addSelectionListener(new SelectionListener<ButtonEvent>() { ok.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
keyword = null; keyword = null;
startSearchTable = false; startSearchTable = false;
if (selectedTable != null) { if (selectedTable != null) {
// display the table in the panel "Database Information" // display the table in the panel "Database Information"
displayTableName(selectedTable); displayTableName(selectedTable);
@ -742,7 +689,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// method to submit a query // method to submit a query
private void submitQuery(final Integer dialogID) { private void submitQuery(final Integer dialogID) {
// get the selected item // get the selected item
List<FileModel> data = treePanel.getTreePanel().getSelectionModel() List<FileModel> data = treePanel.getTreePanel().getSelectionModel()
.getSelectedItems(); .getSelectedItems();
@ -761,14 +707,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// get data list (inserted in the form) // get data list (inserted in the form)
LinkedHashMap<Integer, SubmitQueryData> submitQueryDataList = toolbar LinkedHashMap<Integer, SubmitQueryData> submitQueryDataList = toolbar
.getSubmitQueryDataList(); .getSubmitQueryDataList();
// get dialog list // get dialog list
LinkedHashMap<Integer, Dialog> dialogList = toolbar.getDialogFormList(); LinkedHashMap<Integer, Dialog> dialogList = toolbar.getDialogFormList();
// get the dialog related to the ID // get the dialog related to the ID
final Dialog form = dialogList.get(dialogID); final Dialog form = dialogList.get(dialogID);
// get the data form related to the ID // get the data form related to the ID
final SubmitQueryData dataQuery = submitQueryDataList.get(dialogID); final SubmitQueryData dataQuery = submitQueryDataList.get(dialogID);
// get the UID related to submitQuery operation // get the UID related to submitQuery operation
LinkedHashMap<Integer, String> uidSubmitQueryList = toolbar LinkedHashMap<Integer, String> uidSubmitQueryList = toolbar
.getUIDSubmitQueryList(); .getUIDSubmitQueryList();
@ -782,44 +726,31 @@ public class GxtBorderLayoutPanel extends ContentPanel {
String dialect; String dialect;
if (selectedItem.isDatabase()) { // the selected item is a database if (selectedItem.isDatabase()) { // the selected item is a database
// System.out.println("the selected item is a database"); // System.out.println("the selected item is a database");
rootLogger.log(Level.INFO, "the selected item is a database"); rootLogger.log(Level.INFO, "the selected item is a database");
// determine the dialect recovering the dialect // determine the dialect recovering the dialect
dialect = selectedItem.getDBInfo().get(2).getValue(); dialect = selectedItem.getDBInfo().get(2).getValue();
rootLogger.log(Level.INFO, rootLogger.log(Level.INFO,
"determined Dialect for smart correction: " + dialect); "determined Dialect for smart correction: " + dialect);
} else { } else {
FileModel parent1 = treePanel.getTreeStore() FileModel parent1 = treePanel.getTreeStore()
.getParent(selectedItem); .getParent(selectedItem);
if (parent1.isDatabase()) { // the selected item is a schema if (parent1.isDatabase()) { // the selected item is a schema
rootLogger.log(Level.INFO, "the selected item is a schema"); rootLogger.log(Level.INFO, "the selected item is a schema");
// determine the dialect recovering the dialect // determine the dialect recovering the dialect
dialect = parent1.getDBInfo().get(2).getValue(); dialect = parent1.getDBInfo().get(2).getValue();
rootLogger.log(Level.INFO, rootLogger.log(Level.INFO,
"determined Dialect for smart correction: " + dialect); "determined Dialect for smart correction: " + dialect);
} } else { // the selected item is a table
// System.out.println("the selected item is a table");
else { // the selected item is a table
// System.out.println("the selected item is a table");
rootLogger.log(Level.INFO, "the selected item is a table"); rootLogger.log(Level.INFO, "the selected item is a table");
FileModel parent2 = treePanel.getTreeStore().getParent(parent1); FileModel parent2 = treePanel.getTreeStore().getParent(parent1);
// determine the dialect recovering the dialect // determine the dialect recovering the dialect
dialect = parent2.getDBInfo().get(2).getValue(); dialect = parent2.getDBInfo().get(2).getValue();
rootLogger.log(Level.INFO, rootLogger.log(Level.INFO,
"determined Dialect for smart correction: " + dialect); "determined Dialect for smart correction: " + dialect);
} }
} }
String language = ConstantsPortlet.NONE; String language = ConstantsPortlet.NONE;
if (dialect.toUpperCase().contains(ConstantsPortlet.POSTGRES)) { if (dialect.toUpperCase().contains(ConstantsPortlet.POSTGRES)) {
@ -828,7 +759,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (dialect.toUpperCase().contains(ConstantsPortlet.MYSQL)) { if (dialect.toUpperCase().contains(ConstantsPortlet.MYSQL)) {
language = ConstantsPortlet.MYSQL; language = ConstantsPortlet.MYSQL;
} }
rootLogger.log(Level.INFO, "Dialect used for smart correction: " rootLogger.log(Level.INFO, "Dialect used for smart correction: "
+ language); + language);
@ -837,7 +767,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
dataQuery.getSmartCorrection(), language, UID, dataQuery.getSmartCorrection(), language, UID,
new AsyncCallback<List<String>>() { new AsyncCallback<List<String>>() {
// TO REMOVE data "true" as input if you manage the // TODO: TO REMOVE data "true" as input if you manage the
// read-only query in the form // read-only query in the form
@Override @Override
@ -846,22 +776,21 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger rootLogger
.log(Level.SEVERE, "FAILURE RPC submitQuery "); .log(Level.SEVERE, "FAILURE RPC submitQuery ");
// Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() { // Listener<MessageBoxEvent> l = new
// public void handleEvent(MessageBoxEvent ce) { // Listener<MessageBoxEvent>() {
// // Button btn = ce.getButtonClicked(); // public void handleEvent(MessageBoxEvent ce) {
// // Info.display("MessageBox", // // Button btn = ce.getButtonClicked();
// // "The '{0}' button was pressed", // // Info.display("MessageBox",
// // btn.getHtml()); // // "The '{0}' button was pressed",
// // Button btn = ce.getButtonClicked(); // // btn.getHtml());
// // // Button btn = ce.getButtonClicked();
// if (form.getBody().isMasked()) //
// form.getBody().unmask(); // if (form.getBody().isMasked())
// // form.getBody().unmask();
// } // }
// }; // };
if (!(caught.getMessage().equals("ServerException"))) { if (!(caught.getMessage().equals("ServerException"))) {
MessageBox.alert("Error ", MessageBox.alert("Error ",
"<br/>Message:" + caught.getMessage(), null); "<br/>Message:" + caught.getMessage(), null);
} }
@ -871,58 +800,53 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// MessageBox.alert("Error ", // MessageBox.alert("Error ",
// "<br/>Message:" + caught.getMessage(), l); // "<br/>Message:" + caught.getMessage(), l);
// } // }
if (form.getBody().isMasked()) if (form.getBody().isMasked())
form.getBody().unmask(); form.getBody().unmask();
if (form.getButtonById(Dialog.OK).isEnabled() == false){ if (form.getButtonById(Dialog.OK).isEnabled() == false) {
form.getButtonById(Dialog.OK).enable(); form.getButtonById(Dialog.OK).enable();
} }
} }
@Override @Override
public void onSuccess(List<String> listAttributes) { public void onSuccess(List<String> listAttributes) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery"); rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
if (form.getBody().isMasked()) if (form.getBody().isMasked())
form.getBody().unmask(); form.getBody().unmask();
if (form.getButtonById(Dialog.OK).isEnabled() == false){ if (form.getButtonById(Dialog.OK).isEnabled() == false) {
form.getButtonById(Dialog.OK).enable(); form.getButtonById(Dialog.OK).enable();
} }
if (listAttributes == null) {
if (listAttributes==null){
return; return;
} }
if (listAttributes.size() == 0) {
if (listAttributes.size() == 0) {
// if (form.getBody().isMasked()) // if (form.getBody().isMasked())
// form.getBody().unmask(); // form.getBody().unmask();
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
"No results have been returned"); "No results have been returned");
MessageBox.alert("Error ", "<br/>Message:" MessageBox.alert("Error ", "<br/>Message:"
+ "Result not available", null); + "Result not available", null);
return; return;
} }
// if ((listAttributes == null) // if ((listAttributes == null)
// || (listAttributes.size() == 0)) { // || (listAttributes.size() == 0)) {
// //
// // if (form.getBody().isMasked()) // // if (form.getBody().isMasked())
// // form.getBody().unmask(); // // form.getBody().unmask();
// //
// rootLogger.log(Level.SEVERE, // rootLogger.log(Level.SEVERE,
// "No results have been returned"); // "No results have been returned");
// //
// MessageBox.alert("Error ", "<br/>Message:" // MessageBox.alert("Error ", "<br/>Message:"
// + "Result not available", null); // + "Result not available", null);
// return; // return;
// } // }
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery"); rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
rootLogger.log(Level.SEVERE, "output size: " rootLogger.log(Level.SEVERE, "output size: "
@ -966,15 +890,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
final List<String> listAttributes, final String UID) { final List<String> listAttributes, final String UID) {
final Dialog form = dialog; final Dialog form = dialog;
// define the proxy and create the grid to display in the dialog // define the proxy and create the grid to display in the dialog
// create RpcProxy object to use the load configuration // create RpcProxy object to use the load configuration
RpcProxy<PagingLoadResult<Row>> proxy = new RpcProxy<PagingLoadResult<Row>>() { RpcProxy<PagingLoadResult<Row>> proxy = new RpcProxy<PagingLoadResult<Row>>() {
@Override @Override
protected void load(Object loadConfig, protected void load(Object loadConfig,
final AsyncCallback<PagingLoadResult<Row>> callback) { final AsyncCallback<PagingLoadResult<Row>> callback) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
"Start RPC - loadSubmitQueryResult"); "Start RPC - loadSubmitQueryResult");
@ -991,9 +912,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void handleEvent(MessageBoxEvent ce) { public void handleEvent(MessageBoxEvent ce) {
if (form.getBody().isMasked()) if (form.getBody().isMasked())
form.getBody().unmask(); form.getBody().unmask();
if (form.getButtonById(Dialog.OK).isEnabled() == false){ if (form.getButtonById(Dialog.OK)
form.getButtonById(Dialog.OK).enable(); .isEnabled() == false) {
form.getButtonById(Dialog.OK)
.enable();
} }
} }
}; };
@ -1010,11 +933,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (result != null) { if (result != null) {
callback.onSuccess(result); callback.onSuccess(result);
List<Row> rows = result.getData(); List<Row> rows = result.getData();
if (form.getBody().isMasked()) if (form.getBody().isMasked())
form.getBody().unmask(); form.getBody().unmask();
if (form.getButtonById(Dialog.OK).isEnabled() == false){ if (form.getButtonById(Dialog.OK)
.isEnabled() == false) {
form.getButtonById(Dialog.OK).enable(); form.getButtonById(Dialog.OK).enable();
} }
@ -1025,7 +949,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
return; return;
} }
} }
// if (result != null) { // if (result != null) {
// rootLogger.log(Level.SEVERE, // rootLogger.log(Level.SEVERE,
// "rows not null"); // "rows not null");
@ -1041,16 +964,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// to create the listStore using the loader // to create the listStore using the loader
final ListStore<Row> store = new ListStore<Row>(loader); final ListStore<Row> store = new ListStore<Row>(loader);
// bind the loader with a PagingToolBar. // bind the loader with a PagingToolBar.
final PagingToolBar toolBar = new PagingToolBar(100); final PagingToolBar toolBar = new PagingToolBar(100);
toolBar.bind(loader); toolBar.bind(loader);
// create the grid with a result list and the column model // create the grid with a result list and the column model
Grid<Row> grid; Grid<Row> grid;
grid = new Grid<Row>(store, createColumnModel(listAttributes)); grid = new Grid<Row>(store, createColumnModel(listAttributes));
grid.setLoadMask(true); grid.setLoadMask(true);
grid.setBorders(true); grid.setBorders(true);
grid.setStripeRows(true); grid.setStripeRows(true);
@ -1059,7 +979,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
grid.addListener(Events.Attach, new Listener<GridEvent<Row>>() { grid.addListener(Events.Attach, new Listener<GridEvent<Row>>() {
public void handleEvent(GridEvent<Row> be) { public void handleEvent(GridEvent<Row> be) {
rootLogger.log(Level.INFO, "event Attach handled"); rootLogger.log(Level.INFO, "event Attach handled");
// disable the top toolbar at the first tables loading in such a // disable the top toolbar at the first tables loading in such a
@ -1155,7 +1074,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
"FAILURE RPC refreshDataOnServer"); "FAILURE RPC refreshDataOnServer");
} }
@Override @Override
public void onSuccess(Void result) { public void onSuccess(Void result) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
@ -1170,7 +1088,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// method to perform the sample table // method to perform the sample table
private void sample() { private void sample() {
final GxtBorderLayoutPanel obj = this; final GxtBorderLayoutPanel obj = this;
rootLogger.log(Level.SEVERE, "Start RPC - sample"); rootLogger.log(Level.SEVERE, "Start RPC - sample");
@ -1179,7 +1096,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
.getSelectedItems(); .getSelectedItems();
// the selected item // the selected item
FileModel selectedItem = data.get(0); FileModel selectedItem = data.get(0);
// recover data inputs // recover data inputs
final LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>(); final LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
// check if the table has an associated schema // check if the table has an associated schema
@ -1190,7 +1106,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (selectedItem.isDatabase()) { if (selectedItem.isDatabase()) {
// the table has not a schema because the selected item is a // the table has not a schema because the selected item is a
// database // database
database = selectedItem; database = selectedItem;
resource = treePanel.getTreeStore().getParent(database); resource = treePanel.getTreeStore().getParent(database);
@ -1205,7 +1120,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "TableName: " + selectedTable); rootLogger.log(Level.INFO, "TableName: " + selectedTable);
} else { } else {
// the table has a schema because the selected item is a schema // the table has a schema because the selected item is a schema
schema = selectedItem; schema = selectedItem;
database = treePanel.getTreeStore().getParent(schema); database = treePanel.getTreeStore().getParent(schema);
resource = treePanel.getTreeStore().getParent(database); resource = treePanel.getTreeStore().getParent(database);
@ -1226,7 +1140,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// call remote service // call remote service
RPCservice.sample(dataInput, new AsyncCallback<List<Result>>() { RPCservice.sample(dataInput, new AsyncCallback<List<Result>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // Window.alert(caught.getMessage());
@ -1237,12 +1150,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
obj.unmask(); obj.unmask();
} }
} }
@Override @Override
public void onSuccess(List<Result> result) { public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC sample"); rootLogger.log(Level.SEVERE, "SUCCESS RPC sample");
rootLogger.log(Level.SEVERE, "output size: " + result.size()); rootLogger.log(Level.SEVERE, "output size: " + result.size());
// get the attributes list for the result // get the attributes list for the result
// table // table
List<String> listAttributes = new ArrayList<String>(); List<String> listAttributes = new ArrayList<String>();
@ -1259,7 +1170,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// method that performs the smart sample // method that performs the smart sample
private void smartSample() { private void smartSample() {
final GxtBorderLayoutPanel obj = this; final GxtBorderLayoutPanel obj = this;
rootLogger.log(Level.SEVERE, "Start RPC - smartSample"); rootLogger.log(Level.SEVERE, "Start RPC - smartSample");
// get the selected table // get the selected table
@ -1309,7 +1219,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// call remote service // call remote service
RPCservice.smartSample(dataInput, new AsyncCallback<List<Result>>() { RPCservice.smartSample(dataInput, new AsyncCallback<List<Result>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // Window.alert(caught.getMessage());
@ -1325,7 +1234,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onSuccess(List<Result> result) { public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC smartSample"); rootLogger.log(Level.SEVERE, "SUCCESS RPC smartSample");
rootLogger.log(Level.SEVERE, "output size: " + result.size()); rootLogger.log(Level.SEVERE, "output size: " + result.size());
// get the attributes list for the result // get the attributes list for the result
// table // table
List<String> listAttributes = new ArrayList<String>(); List<String> listAttributes = new ArrayList<String>();
@ -1342,7 +1250,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// method to perform the random sample // method to perform the random sample
private void randomSample() { private void randomSample() {
final GxtBorderLayoutPanel obj = this; final GxtBorderLayoutPanel obj = this;
rootLogger.log(Level.SEVERE, "Start RPC - randomSample"); rootLogger.log(Level.SEVERE, "Start RPC - randomSample");
// get the selected table // get the selected table
@ -1409,7 +1316,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onSuccess(List<Result> result) { public void onSuccess(List<Result> result) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC randomSample"); rootLogger.log(Level.SEVERE, "SUCCESS RPC randomSample");
rootLogger.log(Level.SEVERE, "output size: " + result.size()); rootLogger.log(Level.SEVERE, "output size: " + result.size());
// get the attributes list for the result // get the attributes list for the result
// table // table
List<String> listAttributes = new ArrayList<String>(); List<String> listAttributes = new ArrayList<String>();
@ -1427,7 +1333,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// start the parsing of the submit result in order to obtain a table // start the parsing of the submit result in order to obtain a table
private void parseResult(List<Result> result, private void parseResult(List<Result> result,
final List<String> listAttributes) { final List<String> listAttributes) {
// to unmask the entire content panel // to unmask the entire content panel
final GxtBorderLayoutPanel obj = this; final GxtBorderLayoutPanel obj = this;
// final Dialog form = dialog; // final Dialog form = dialog;
@ -1511,14 +1416,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// grid.setAutoExpandColumn("value"); // grid.setAutoExpandColumn("value");
grid.setBorders(true); grid.setBorders(true);
// grid.setAutoWidth(true); // grid.setAutoWidth(true);
RowData data = new RowData(.5, 1); RowData data = new RowData(.5, 1);
data.setMargins(new Margins(6)); data.setMargins(new Margins(6));
// mimimize event handled // mimimize event handled
sampleResult.addListener(Events.Minimize, sampleResult.addListener(Events.Minimize,
new Listener<WindowEvent>() { new Listener<WindowEvent>() {
@Override @Override
public void handleEvent(WindowEvent be) { public void handleEvent(WindowEvent be) {
// collapse the dialog // collapse the dialog
@ -1528,7 +1431,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// maximize event handled // maximize event handled
sampleResult.addListener(Events.Maximize, sampleResult.addListener(Events.Maximize,
new Listener<WindowEvent>() { new Listener<WindowEvent>() {
@Override @Override
public void handleEvent(WindowEvent be) { public void handleEvent(WindowEvent be) {
// expand the dialog // expand the dialog
@ -1578,12 +1480,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// get attributes list for display the result in a table // get attributes list for display the result in a table
private List<String> getListAttributes(String value) { private List<String> getListAttributes(String value) {
List<String> listAttributes = new ArrayList<String>(); List<String> listAttributes = new ArrayList<String>();
// recover attribute fields for the result table // recover attribute fields for the result table
String headers = value; String headers = value;
// rootLogger.log(Level.INFO, "Headers fields table: " + headers); // rootLogger.log(Level.INFO, "Headers fields table: " + headers);
listAttributes = parseAttributesTableResult(headers); listAttributes = parseAttributesTableResult(headers);
rootLogger.log(Level.INFO, rootLogger.log(Level.INFO,
"attributes number: " + listAttributes.size()); "attributes number: " + listAttributes.size());
@ -1593,17 +1493,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// for (int i = 0; i < listAttributes.size(); i++) { // for (int i = 0; i < listAttributes.size(); i++) {
// rootLogger.log(Level.INFO, "attribute: " + listAttributes.get(i)); // rootLogger.log(Level.INFO, "attribute: " + listAttributes.get(i));
// } // }
return listAttributes; return listAttributes;
} }
// create column configuration for the grid // create column configuration for the grid
private ColumnModel createColumnModel(List<String> listAttributes) { private ColumnModel createColumnModel(List<String> listAttributes) {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column; ColumnConfig column;
column = new ColumnConfig(); column = new ColumnConfig();
// column.setId("index"); // column.setId("index");
// column.setHeader("Index"); // column.setHeader("Index");
// column.setWidth(100); // column.setWidth(100);
@ -1611,7 +1508,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// configs.add(column); // configs.add(column);
for (int i = 0; i < listAttributes.size(); i++) { for (int i = 0; i < listAttributes.size(); i++) {
// rootLogger.log(Level.INFO, "attribute: " + // rootLogger.log(Level.INFO, "attribute: " +
// listAttributes.get(i)); // listAttributes.get(i));
column = new ColumnConfig(); column = new ColumnConfig();
@ -1641,7 +1537,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// create column configuration for the grid // create column configuration for the grid
private ColumnModel createColumnModelForDBInfo(List<Result> result) { private ColumnModel createColumnModelForDBInfo(List<Result> result) {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig(); ColumnConfig column = new ColumnConfig();
column.setId("index"); column.setId("index");
@ -1667,13 +1562,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
ListStore<Result> store = new ListStore<Result>(); ListStore<Result> store = new ListStore<Result>();
store.add(result); store.add(result);
return new ColumnModel(configs); return new ColumnModel(configs);
} }
// create column configuration for the grid // create column configuration for the grid
private ColumnModel createColumnModelForTables() { private ColumnModel createColumnModelForTables() {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig(); ColumnConfig column = new ColumnConfig();
// column.setId("index"); // column.setId("index");
@ -1691,33 +1584,26 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// text.setAllowBlank(false); // text.setAllowBlank(false);
column.setEditor(new CellEditor(textValue)); column.setEditor(new CellEditor(textValue));
configs.add(column); configs.add(column);
// ListStore<Result> store = new ListStore<Result>(); // ListStore<Result> store = new ListStore<Result>();
// store.add(result); // store.add(result);
return new ColumnModel(configs); return new ColumnModel(configs);
} }
private void displayDBInfo(FileModel element) { private void displayDBInfo(FileModel element) {
rootLogger.log(Level.INFO, "displaying info"); rootLogger.log(Level.INFO, "displaying info");
List<Result> dataDB = element.getDBInfo(); List<Result> dataDB = element.getDBInfo();
if (dataDB != null) { if (dataDB != null) {
rootLogger.log(Level.INFO, "info size: " + dataDB.size()); rootLogger.log(Level.INFO, "info size: " + dataDB.size());
ListStore<Result> store = new ListStore<Result>(); ListStore<Result> store = new ListStore<Result>();
store.add(dataDB); store.add(dataDB);
EditorGrid<Result> grid = new EditorGrid<Result>(store, EditorGrid<Result> grid = new EditorGrid<Result>(store,
createColumnModelForDBInfo(dataDB)); createColumnModelForDBInfo(dataDB));
// grid.setAutoExpandColumn("name"); // grid.setAutoExpandColumn("name");
grid.setBorders(true); grid.setBorders(true);
// grid.setAutoWidth(true); // grid.setAutoWidth(true);
// RowData data = new RowData(.5, 1); // RowData data = new RowData(.5, 1);
// data.setMargins(new Margins(6)); // data.setMargins(new Margins(6));
centerUpper.removeAll(); centerUpper.removeAll();
// centerUpper.add(grid, data); // centerUpper.add(grid, data);
centerUpper.add(grid); centerUpper.add(grid);
@ -1745,7 +1631,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (selectedItem.isDatabase()) { if (selectedItem.isDatabase()) {
// the table has not a schema // the table has not a schema
database = selectedItem; database = selectedItem;
resource = treePanel.getTreeStore().getParent(database); resource = treePanel.getTreeStore().getParent(database);
@ -1760,7 +1645,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.INFO, "TableName: " + selectedTable); rootLogger.log(Level.INFO, "TableName: " + selectedTable);
} else { } else {
// the table has a schema // the table has a schema
schema = selectedItem; schema = selectedItem;
database = treePanel.getTreeStore().getParent(schema); database = treePanel.getTreeStore().getParent(schema);
resource = treePanel.getTreeStore().getParent(database); resource = treePanel.getTreeStore().getParent(database);
@ -1781,14 +1665,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
if (Table.isTableDetailsDisplayed()) { if (Table.isTableDetailsDisplayed()) {
displayTableDetails(Table); displayTableDetails(Table);
} else { } else {
// to mask the entire content panel // to mask the entire content panel
obj.mask("Loading details", "x-mask-loading"); obj.mask("Loading details", "x-mask-loading");
// call remote service // call remote service
RPCservice.getTableDetails(dataInput, RPCservice.getTableDetails(dataInput,
new AsyncCallback<LinkedHashMap<String, FileModel>>() { new AsyncCallback<LinkedHashMap<String, FileModel>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
@ -1804,14 +1686,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
@Override @Override
public void onSuccess( public void onSuccess(
LinkedHashMap<String, FileModel> result) { LinkedHashMap<String, FileModel> result) {
rootLogger.log(Level.SEVERE, rootLogger.log(Level.SEVERE,
"SUCCESS RPC getTableDetails"); "SUCCESS RPC getTableDetails");
// details are recovered about // details are recovered about
// the selected table // the selected table
if (result.size() != 0) { if (result.size() != 0) {
// recover keys from the // recover keys from the
// result // result
Set<String> keys = result.keySet(); Set<String> keys = result.keySet();
@ -1823,7 +1703,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
if (array[i].toString().contains( if (array[i].toString().contains(
"CreateTable")) { "CreateTable")) {
// recover the // recover the
// showCreateTable // showCreateTable
// statement // statement
@ -1831,7 +1710,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
"Create statement", result.get( "Create statement", result.get(
array[i].toString()) array[i].toString())
.getName()); .getName());
TableDetails.add(row); TableDetails.add(row);
} }
@ -1842,20 +1720,17 @@ public class GxtBorderLayoutPanel extends ContentPanel {
Result row = new Result("Column names", Result row = new Result("Column names",
result.get(array[i].toString()) result.get(array[i].toString())
.getName()); .getName());
TableDetails.add(row); TableDetails.add(row);
} }
if (array[i].toString().contains( if (array[i].toString().contains(
"NumberRows")) { "NumberRows")) {
// recover the // recover the
// column names // column names
Result row = new Result( Result row = new Result(
"Number of rows", result.get( "Number of rows", result.get(
array[i].toString()) array[i].toString())
.getName()); .getName());
TableDetails.add(row); TableDetails.add(row);
} }
} }
@ -1883,7 +1758,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// grid.setAutoWidth(true); // grid.setAutoWidth(true);
// RowData data = new RowData(.5, .1); // RowData data = new RowData(.5, .1);
// data.setMargins(new Margins(6)); // data.setMargins(new Margins(6));
centerBottom.removeAll(); centerBottom.removeAll();
// centerBottom.add(grid, data); // centerBottom.add(grid, data);
centerBottom.add(grid); centerBottom.add(grid);
@ -1898,7 +1772,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
private void displayTableName(String tableName) { private void displayTableName(String tableName) {
rootLogger.log(Level.INFO, "displaying table name " + tableName rootLogger.log(Level.INFO, "displaying table name " + tableName
+ " in the panel"); + " in the panel");
Result table = new Result("Selected table", tableName); Result table = new Result("Selected table", tableName);
// create column configuration // create column configuration
List<ColumnConfig> configs = new ArrayList<ColumnConfig>(); List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

View File

@ -17,11 +17,8 @@ import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode; import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.ModelIconProvider; import com.extjs.gxt.ui.client.data.ModelIconProvider;
import com.extjs.gxt.ui.client.event.ComponentEvent; import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.event.Events; import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener; import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.TreePanelEvent; import com.extjs.gxt.ui.client.event.TreePanelEvent;
import com.extjs.gxt.ui.client.store.TreeStore; import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.LayoutContainer; import com.extjs.gxt.ui.client.widget.LayoutContainer;
@ -36,13 +33,11 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
//class that implements the tree object //class that implements the tree object
public class GxtTreePanel extends LayoutContainer { public class GxtTreePanel extends LayoutContainer {
// to manage the tree // to manage the tree
private TreeStore<FileModel> store; private TreeStore<FileModel> store;
private TreePanel<FileModel> treePanel; private TreePanel<FileModel> treePanel;
// to manage events // to manage events
private HandlerManager eventBus = null; private HandlerManager eventBus = null;
private String value = ""; private String value = "";
private int treeDepthSelectedItem; private int treeDepthSelectedItem;
// the rpc remote service // the rpc remote service
@ -55,7 +50,6 @@ public class GxtTreePanel extends LayoutContainer {
// constructor // constructor
public GxtTreePanel(HandlerManager eBus, GWTdbManagerServiceAsync service) public GxtTreePanel(HandlerManager eBus, GWTdbManagerServiceAsync service)
throws Exception { throws Exception {
RPCservice = service; RPCservice = service;
eventBus = eBus; eventBus = eBus;
store = new TreeStore<FileModel>(); store = new TreeStore<FileModel>();
@ -66,7 +60,6 @@ public class GxtTreePanel extends LayoutContainer {
} }
private void initLayout() throws Exception { private void initLayout() throws Exception {
setLayout(new FlowLayout(10)); setLayout(new FlowLayout(10));
treePanel = new TreePanel<FileModel>(store) { treePanel = new TreePanel<FileModel>(store) {
@Override @Override
@ -80,7 +73,6 @@ public class GxtTreePanel extends LayoutContainer {
public void onComponentEvent(ComponentEvent ce) { public void onComponentEvent(ComponentEvent ce) {
super.onComponentEvent(ce); super.onComponentEvent(ce);
TreePanelEvent<FileModel> tpe = (TreePanelEvent) ce; TreePanelEvent<FileModel> tpe = (TreePanelEvent) ce;
// EventType typeEvent = tpe.getType(); // EventType typeEvent = tpe.getType();
@ -111,7 +103,6 @@ public class GxtTreePanel extends LayoutContainer {
}; };
treePanel.setDisplayProperty("name"); treePanel.setDisplayProperty("name");
// set icons for elements in tree panel // set icons for elements in tree panel
treePanel.setIconProvider(new ModelIconProvider<FileModel>() { treePanel.setIconProvider(new ModelIconProvider<FileModel>() {
@ -147,11 +138,9 @@ public class GxtTreePanel extends LayoutContainer {
} }
private void addListeners() { private void addListeners() {
// to manage item click event // to manage item click event
treePanel.addListener(Events.OnClick, treePanel.addListener(Events.OnClick,
new Listener<TreePanelEvent<FileModel>>() { new Listener<TreePanelEvent<FileModel>>() {
@Override @Override
public void handleEvent(TreePanelEvent<FileModel> be) { public void handleEvent(TreePanelEvent<FileModel> be) {
// get the selected item // get the selected item
@ -165,13 +154,10 @@ public class GxtTreePanel extends LayoutContainer {
// update the current selected item considering the id // update the current selected item considering the id
if (selectedItem.getId() != currentSelectedItem.getId()) { if (selectedItem.getId() != currentSelectedItem.getId()) {
// System.out.println("selected item changed"); // System.out.println("selected item changed");
currentSelectedItem = selectedItem; currentSelectedItem = selectedItem;
// deselect the previous item // deselect the previous item
treePanel.getSelectionModel().deselectAll(); treePanel.getSelectionModel().deselectAll();
// select the current item // select the current item
treePanel.getSelectionModel().select( treePanel.getSelectionModel().select(
currentSelectedItem, true); currentSelectedItem, true);
@ -367,14 +353,11 @@ public class GxtTreePanel extends LayoutContainer {
treePanel.addListener(Events.Collapse, treePanel.addListener(Events.Collapse,
new Listener<TreePanelEvent<FileModel>>() { new Listener<TreePanelEvent<FileModel>>() {
public void handleEvent(final TreePanelEvent<FileModel> be) { public void handleEvent(final TreePanelEvent<FileModel> be) {
// get the item // get the item
FileModel selectedItem = (FileModel) (be.getNode() FileModel selectedItem = (FileModel) (be.getNode()
.getModel()); .getModel());
// set the collapsed state to true value // set the collapsed state to true value
selectedItem.setIsCollapsed(true); selectedItem.setIsCollapsed(true);
rootLogger.log(Level.INFO, "collapsed item: " rootLogger.log(Level.INFO, "collapsed item: "
+ selectedItem.getName()); + selectedItem.getName());
} }
@ -383,13 +366,10 @@ public class GxtTreePanel extends LayoutContainer {
treePanel.addListener(Events.Expand, treePanel.addListener(Events.Expand,
new Listener<TreePanelEvent<FileModel>>() { new Listener<TreePanelEvent<FileModel>>() {
public void handleEvent(final TreePanelEvent<FileModel> be) { public void handleEvent(final TreePanelEvent<FileModel> be) {
// rootLogger.log(Level.INFO, "Expand event"); // rootLogger.log(Level.INFO, "Expand event");
// get the selected item // get the selected item
FileModel selectedItem = (FileModel) (be.getNode() FileModel selectedItem = (FileModel) (be.getNode()
.getModel()); .getModel());
// set the collapsed state of the item to false value // set the collapsed state of the item to false value
selectedItem.setIsCollapsed(false); selectedItem.setIsCollapsed(false);
@ -400,7 +380,6 @@ public class GxtTreePanel extends LayoutContainer {
// update the current selected item considering the id // update the current selected item considering the id
if (selectedItem.getId() != currentSelectedItem.getId()) { if (selectedItem.getId() != currentSelectedItem.getId()) {
currentSelectedItem = selectedItem; currentSelectedItem = selectedItem;
// deselect the previous item // deselect the previous item
treePanel.getSelectionModel().deselectAll(); treePanel.getSelectionModel().deselectAll();
@ -428,7 +407,6 @@ public class GxtTreePanel extends LayoutContainer {
// selected item has not loaded // selected item has not loaded
if ((numChildrenFolder == 0) if ((numChildrenFolder == 0)
&& (selectedItem.isLoaded() != true)) { && (selectedItem.isLoaded() != true)) {
// disable events on the tree panel until the call // disable events on the tree panel until the call
// has ended // has ended
if (treeDepthSelectedItem != 1) { if (treeDepthSelectedItem != 1) {
@ -465,7 +443,6 @@ public class GxtTreePanel extends LayoutContainer {
// load the root // load the root
private void loadRootItemTree() throws Exception { private void loadRootItemTree() throws Exception {
this.mask("Loading", "x-mask-loading"); this.mask("Loading", "x-mask-loading");
final FileModel root = new FileModel("Resources", 0); final FileModel root = new FileModel("Resources", 0);
store.insert(root, 0, true); store.insert(root, 0, true);
@ -480,12 +457,10 @@ public class GxtTreePanel extends LayoutContainer {
// load resources // load resources
private void loadResources(final FileModel element, final GxtTreePanel tree) { private void loadResources(final FileModel element, final GxtTreePanel tree) {
rootLogger.log(Level.SEVERE, "Start RPC - getResource"); rootLogger.log(Level.SEVERE, "Start RPC - getResource");
// call rpc remote service // call rpc remote service
RPCservice.getResource(new AsyncCallback<List<FileModel>>() { RPCservice.getResource(new AsyncCallback<List<FileModel>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // Window.alert(caught.getMessage());
@ -520,13 +495,11 @@ public class GxtTreePanel extends LayoutContainer {
// load information for a database // load information for a database
private void loadDBInfo(final FileModel element, private void loadDBInfo(final FileModel element,
final TreePanel<FileModel> tree) { final TreePanel<FileModel> tree) {
rootLogger.log(Level.SEVERE, "Start RPC - getDBInfo"); rootLogger.log(Level.SEVERE, "Start RPC - getDBInfo");
// call remote service // call remote service
RPCservice.getDBInfo(element.getName(), RPCservice.getDBInfo(element.getName(),
new AsyncCallback<LinkedHashMap<String, FileModel>>() { new AsyncCallback<LinkedHashMap<String, FileModel>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
// Window.alert(caught.getMessage()); // Window.alert(caught.getMessage());
@ -543,7 +516,6 @@ public class GxtTreePanel extends LayoutContainer {
@Override @Override
public void onSuccess( public void onSuccess(
LinkedHashMap<String, FileModel> result) { LinkedHashMap<String, FileModel> result) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBInfo"); rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBInfo");
if (result.size() != 0) { if (result.size() != 0) {
@ -560,17 +532,13 @@ public class GxtTreePanel extends LayoutContainer {
for (i = 0; i < numIterations; i++) { for (i = 0; i < numIterations; i++) {
String DatabaseType = null; String DatabaseType = null;
// System.out.println("index i: " + i); // System.out.println("index i: " + i);
String DBName = null; String DBName = null;
List<Result> DBInfo = new ArrayList<Result>(); List<Result> DBInfo = new ArrayList<Result>();
FileModel child = null; FileModel child = null;
for (j = (i * 5); j < (i + 1) * 5; j++) { for (j = (i * 5); j < (i + 1) * 5; j++) {
// System.out.println("index j: " + j); // System.out.println("index j: " + j);
if (array[j].toString().contains( if (array[j].toString().contains(
"Database Name")) { "Database Name")) {
// recover the database name // recover the database name
@ -595,7 +563,6 @@ public class GxtTreePanel extends LayoutContainer {
if (array[j].toString().contains( if (array[j].toString().contains(
"Driver Name")) { "Driver Name")) {
Result row = new Result("Driver Name", Result row = new Result("Driver Name",
result.get(array[j].toString()) result.get(array[j].toString())
.getName()); .getName());
@ -682,12 +649,9 @@ public class GxtTreePanel extends LayoutContainer {
// load schema // load schema
private void loadSchema(final FileModel element) { private void loadSchema(final FileModel element) {
rootLogger.log(Level.SEVERE, "Start RPC - getDBSchema"); rootLogger.log(Level.SEVERE, "Start RPC - getDBSchema");
// recover data inputs for algorithm // recover data inputs for algorithm
LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> dataInput = new LinkedHashMap<String, String>();
// get information // get information
FileModel parent = store.getParent(element); FileModel parent = store.getParent(element);
dataInput.put("ResourceName", parent.getName()); dataInput.put("ResourceName", parent.getName());
@ -695,7 +659,6 @@ public class GxtTreePanel extends LayoutContainer {
// call remote service // call remote service
RPCservice.getDBSchema(dataInput, new AsyncCallback<List<FileModel>>() { RPCservice.getDBSchema(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());
@ -711,17 +674,13 @@ public class GxtTreePanel extends LayoutContainer {
@Override @Override
public void onSuccess(List<FileModel> result) { public void onSuccess(List<FileModel> result) {
rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBSchema"); rootLogger.log(Level.SEVERE, "SUCCESS RPC getDBSchema");
if (result.size() == 0) { // the database has not schema if (result.size() == 0) { // the database has not schema
// element.setIsSchema(false); // element.setIsSchema(false);
// element.setIsLoaded(false); // element.setIsLoaded(false);
// loadTables(element); // loadTables(element);
rootLogger.log(Level.INFO, "the database has not schema"); rootLogger.log(Level.INFO, "the database has not schema");
element.setIsExpanded(false); element.setIsExpanded(false);
treePanel.setExpanded(element, false); treePanel.setExpanded(element, false);
} else { } else {
@ -731,11 +690,9 @@ public class GxtTreePanel extends LayoutContainer {
result.get(i).setIsExpanded(false); result.get(i).setIsExpanded(false);
treePanel.setExpanded(result.get(i), false); treePanel.setExpanded(result.get(i), false);
} }
addChildren(element, result); addChildren(element, result);
// element.setIsLoaded(true); // element.setIsLoaded(true);
} }
element.setIsLoaded(true); element.setIsLoaded(true);
if (treePanel.isMasked()) if (treePanel.isMasked())
@ -744,7 +701,6 @@ public class GxtTreePanel extends LayoutContainer {
treePanel.enableEvents(true); treePanel.enableEvents(true);
} }
}); });
// rootLogger.log(Level.SEVERE, "End RPC - getDBSchema"); // rootLogger.log(Level.SEVERE, "End RPC - getDBSchema");
} }
@ -759,12 +715,9 @@ public class GxtTreePanel extends LayoutContainer {
// set information (useful for the submitquery operation) for the selected // set information (useful for the submitquery operation) for the selected
// item. The selected item can be a schema, a table and a database. // item. The selected item can be a schema, a table and a database.
private void setInfoOnSelectedItem(FileModel element) { private void setInfoOnSelectedItem(FileModel element) {
// the selected element is a schema // the selected element is a schema
if ((treeDepthSelectedItem == 4) && (element.isSchema() == true)) { if ((treeDepthSelectedItem == 4) && (element.isSchema() == true)) {
rootLogger.log(Level.SEVERE, "setInfo for selected item schema"); rootLogger.log(Level.SEVERE, "setInfo for selected item schema");
// recover database name // recover database name
FileModel database = store.getParent(element); FileModel database = store.getParent(element);
String DatabaseName = database.getName(); String DatabaseName = database.getName();
@ -779,7 +732,6 @@ public class GxtTreePanel extends LayoutContainer {
//the selected element is a table because the database is mysql type //the selected element is a table because the database is mysql type
else if ((treeDepthSelectedItem == 4) && (element.isSchema() == false)) { else if ((treeDepthSelectedItem == 4) && (element.isSchema() == false)) {
rootLogger.log(Level.SEVERE, "setInfo for selected item table"); rootLogger.log(Level.SEVERE, "setInfo for selected item table");
// recover database name // recover database name
@ -792,10 +744,8 @@ public class GxtTreePanel extends LayoutContainer {
element.setResourceName(ResourceName); element.setResourceName(ResourceName);
element.setDatabaseName(DatabaseName); element.setDatabaseName(DatabaseName);
} }
else if (treeDepthSelectedItem == 5) { //the selected item is a table so the database is postgres type else if (treeDepthSelectedItem == 5) { //the selected item is a table so the database is postgres type
rootLogger.log(Level.SEVERE, "setInfo for selected item table"); rootLogger.log(Level.SEVERE, "setInfo for selected item table");
// recover schema name // recover schema name
@ -811,9 +761,7 @@ public class GxtTreePanel extends LayoutContainer {
element.setResourceName(ResourceName); element.setResourceName(ResourceName);
element.setDatabaseName(DatabaseName); element.setDatabaseName(DatabaseName);
} else if (treeDepthSelectedItem == 3) { // the selected item is a database } else if (treeDepthSelectedItem == 3) { // the selected item is a database
rootLogger.log(Level.SEVERE, "setInfo for selected item database"); rootLogger.log(Level.SEVERE, "setInfo for selected item database");
// recover database name // recover database name

View File

@ -24,5 +24,4 @@ public class Images {
return AbstractImagePrototype.create(DatabasesManager.resources return AbstractImagePrototype.create(DatabasesManager.resources
.iconSchema()); .iconSchema());
} }
} }

View File

@ -4,18 +4,16 @@ import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource; import com.google.gwt.resources.client.ImageResource;
public interface Resources extends ClientBundle { public interface Resources extends ClientBundle {
@Source("search.png") @Source("search.png")
ImageResource iconSearch(); ImageResource iconSearch();
@Source("cancel.png") @Source("cancel.png")
ImageResource iconCancel(); ImageResource iconCancel();
@Source("database.png") @Source("database.png")
ImageResource iconDatabase(); ImageResource iconDatabase();
@Source("schema.png") @Source("schema.png")
ImageResource iconSchema(); ImageResource iconSchema();
} }

View File

@ -36,7 +36,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
//toolbar to contain buttons //toolbar to contain buttons
public class GxtToolbarFunctionality { public class GxtToolbarFunctionality {
// event bus // event bus
private HandlerManager eventBus = null; private HandlerManager eventBus = null;
// buttons // buttons
@ -58,7 +57,6 @@ public class GxtToolbarFunctionality {
// GWT logger // GWT logger
private static Logger rootLogger = Logger private static Logger rootLogger = Logger
.getLogger("GxtToolbarFunctionality"); .getLogger("GxtToolbarFunctionality");
// RPC service // RPC service
private GWTdbManagerServiceAsync RPCservice = null; private GWTdbManagerServiceAsync RPCservice = null;
@ -74,7 +72,6 @@ public class GxtToolbarFunctionality {
// Constructor with GWTdbManagerServiceAsync service parameter // Constructor with GWTdbManagerServiceAsync service parameter
public GxtToolbarFunctionality(HandlerManager eBus, public GxtToolbarFunctionality(HandlerManager eBus,
GWTdbManagerServiceAsync service) { GWTdbManagerServiceAsync service) {
eventBus = eBus; eventBus = eBus;
RPCservice = service; RPCservice = service;
toolBar = new ToolBar(); toolBar = new ToolBar();
@ -84,7 +81,6 @@ public class GxtToolbarFunctionality {
} }
private void initToolBar() { private void initToolBar() {
// setLayout(new FlowLayout(10)); // setLayout(new FlowLayout(10));
// Button for tables list // Button for tables list
@ -153,11 +149,9 @@ public class GxtToolbarFunctionality {
eventBus.addHandler(SelectedTableEvent.TYPE, eventBus.addHandler(SelectedTableEvent.TYPE,
new SelectedTableEventHandler() { new SelectedTableEventHandler() {
@Override @Override
public void onSelectedTable( public void onSelectedTable(
SelectedTableEvent selectedTableEvent) { SelectedTableEvent selectedTableEvent) {
// enable button for table details and sampling // enable button for table details and sampling
// operations // operations
btnTablesList.enable(); btnTablesList.enable();
@ -176,7 +170,6 @@ public class GxtToolbarFunctionality {
.addSelectionListener(new SelectionListener<ButtonEvent>() { .addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
public void componentSelected(ButtonEvent ce) { public void componentSelected(ButtonEvent ce) {
// dialog to insert inputs in order to submit a query // dialog to insert inputs in order to submit a query
final Dialog dialog = new Dialog() { final Dialog dialog = new Dialog() {
// override the maximize event modifying it with a // override the maximize event modifying it with a
@ -270,7 +263,6 @@ public class GxtToolbarFunctionality {
uidSubmitQueryList uidSubmitQueryList
.get(dialogID), .get(dialogID),
new AsyncCallback<Boolean>() { new AsyncCallback<Boolean>() {
@Override @Override
public void onSuccess( public void onSuccess(
Boolean result) { Boolean result) {
@ -279,7 +271,6 @@ public class GxtToolbarFunctionality {
"SUCCESS RPC removeComputation"); "SUCCESS RPC removeComputation");
if (result if (result
.booleanValue() == true) { .booleanValue() == true) {
rootLogger rootLogger
.log(Level.INFO, .log(Level.INFO,
"computation removed with uid: " "computation removed with uid: "
@ -287,7 +278,6 @@ public class GxtToolbarFunctionality {
.get(dialogID)); .get(dialogID));
} }
} }
@Override @Override
public void onFailure( public void onFailure(
Throwable caught) { Throwable caught) {
@ -297,7 +287,6 @@ public class GxtToolbarFunctionality {
} }
}); });
} }
dialog.hide(); dialog.hide();
} }
}); });
@ -470,9 +459,7 @@ public class GxtToolbarFunctionality {
String uidSubmitQuery = generator.get(); String uidSubmitQuery = generator.get();
// add uid for the submit query operation // add uid for the submit query operation
uidSubmitQueryList.put(new Integer(dialogID), uidSubmitQuery); uidSubmitQueryList.put(new Integer(dialogID), uidSubmitQuery);
// System.out.println("UID: " + uidSubmitQuery); // System.out.println("UID: " + uidSubmitQuery);
SubmtQueryDialog.getBody().mask("Loading", "x-mask-loading"); SubmtQueryDialog.getBody().mask("Loading", "x-mask-loading");
// fire event // fire event

View File

@ -60,24 +60,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// // the result generated in the LoadTables method // // the result generated in the LoadTables method
// private List<Result> result = null; // private List<Result> result = null;
// information about a database
// private String currentDB = "";
// private String previousDB = "";
// information about a schema
// private String currentSchema = "";
// private String previousSchema = "";
// //Hashmap that contains computationId with a uid key
// HashMap<String, String> computationIDMap = new HashMap<String, String>();
String operation = "";
// logger // logger
private static Logger logger = Logger private static Logger logger = Logger
.getLogger(GWTdbManagerServiceImpl.class); .getLogger(GWTdbManagerServiceImpl.class);
public GWTdbManagerServiceImpl() { public GWTdbManagerServiceImpl() {
} }
private void initVariables() { private void initVariables() {
@ -92,18 +80,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
HashMap<String, List<Result>> submitQueryResult = new HashMap<String, List<Result>>(); HashMap<String, List<Result>> submitQueryResult = new HashMap<String, List<Result>>();
session.setAttribute("submitQueryResult", submitQueryResult); session.setAttribute("submitQueryResult", submitQueryResult);
// map that contains the the submit query result parsed and the related // map that contains the submit query result parsed and the related
// uid // uid
HashMap<String, List<Row>> submitQueryResultParsed = new HashMap<String, List<Row>>(); HashMap<String, List<Row>> submitQueryResultParsed = new HashMap<String, List<Row>>();
session.setAttribute("submitQueryResultParsed", submitQueryResultParsed); session.setAttribute("submitQueryResultParsed", submitQueryResultParsed);
// List<Result> submitQueryResult = new ArrayList<Result>();
// session.setAttribute("submitQueryResult", submitQueryResult);
// attributes name for a result of a submit query operation
// List<String> attributeNames = new ArrayList<String>();
// session.setAttribute("attributeNames", attributeNames);
// information about a database // information about a database
String currentDB = ""; String currentDB = "";
session.setAttribute("currentDB", currentDB); session.setAttribute("currentDB", currentDB);
@ -123,24 +104,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// Hashmap that contains the job status with a uid key // Hashmap that contains the job status with a uid key
HashMap<String, String> JobStatusMap = new HashMap<String, String>(); HashMap<String, String> JobStatusMap = new HashMap<String, String>();
session.setAttribute("JobStatusList", JobStatusMap); session.setAttribute("JobStatusList", JobStatusMap);
// information about query submitted
// String currentQuerySubmitted = "";
// session.setAttribute("currentQuerySubmitted", currentQuerySubmitted);
// String previousQuerySubmitted = "";
// session.setAttribute("previousQuerySubmitted",
// previousQuerySubmitted);
// HashMap<String, List<Result>> obj = new HashMap<String,
// List<Result>>();
// session.setAttribute("", obj);
} }
// to get resources from IS // to get resources from IS
@Override @Override
public List<FileModel> getResource() throws Exception { public List<FileModel> getResource() throws Exception {
// initialize variables with application startup // initialize variables with application startup
initVariables(); initVariables();
@ -159,7 +127,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
for (int i = 0; i < algorithms.size(); i++) { for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("LISTDBNAMES")) { if (algorithms.get(i).equals("LISTDBNAMES")) {
algorithmId = algorithms.get(i); algorithmId = algorithms.get(i);
// print check // print check
// logger.info("algorithmId: " + algorithmId); // logger.info("algorithmId: " + algorithmId);
} }
@ -197,7 +164,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// obj.setIsLoaded(true); // obj.setIsLoaded(true);
outputParameters.add(obj); outputParameters.add(obj);
} }
return outputParameters; return outputParameters;
} }
@ -220,7 +186,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
for (int i = 0; i < algorithms.size(); i++) { for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("LISTDBINFO")) { if (algorithms.get(i).equals("LISTDBINFO")) {
algorithmId = algorithms.get(i); algorithmId = algorithms.get(i);
// print check // print check
// logger.info("algorithmId: " + algorithmId); // logger.info("algorithmId: " + algorithmId);
} }
@ -311,8 +276,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(1).setValue(dataInput.get("DatabaseName")); inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
// print check // print check
logger.info("dbmanager-> ResourceName: " + dataInput.get("ResourceName")); logger.info("dbmanager-> ResourceName: "
logger.info("dbmanager-> DatabaseName: " + dataInput.get("DatabaseName")); + dataInput.get("ResourceName"));
logger.info("dbmanager-> DatabaseName: "
+ dataInput.get("DatabaseName"));
// create data structure // create data structure
ComputationOutput outputData = new ComputationOutput(); ComputationOutput outputData = new ComputationOutput();
@ -322,7 +289,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// print check // print check
// retrieve data // retrieve data
logger.info("dbmanager-> output data retrieved"); // logger.info("dbmanager-> output data retrieved");
// data output values // data output values
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
@ -359,7 +326,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
for (int i = 0; i < algorithms.size(); i++) { for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("LISTTABLES")) { if (algorithms.get(i).equals("LISTTABLES")) {
algorithmId = algorithms.get(i); algorithmId = algorithms.get(i);
// print check // print check
// logger.info("algorithmId: " + algorithmId); // logger.info("algorithmId: " + algorithmId);
} }
@ -383,8 +349,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(2).setValue(dataInput.get("SchemaName")); inputParameters.get(2).setValue(dataInput.get("SchemaName"));
// print check // print check
logger.info("dbmanager-> ResourceName: " + dataInput.get("ResourceName")); logger.info("dbmanager-> ResourceName: "
logger.info("dbmanager-> DatabaseName: " + dataInput.get("DatabaseName")); + dataInput.get("ResourceName"));
logger.info("dbmanager-> DatabaseName: "
+ dataInput.get("DatabaseName"));
logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName")); logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName"));
// create data structure // create data structure
@ -507,9 +475,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
loadResult = new BasePagingLoadResult<Result>(sublist, loadResult = new BasePagingLoadResult<Result>(sublist,
config.getOffset(), totalNumber); config.getOffset(), totalNumber);
session.setAttribute("TablesResult", result); session.setAttribute("TablesResult", result);
return loadResult; return loadResult;
} }
@ -520,7 +486,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
boolean smartCorrectionQuery, String language, String UID) boolean smartCorrectionQuery, String language, String UID)
throws Exception { throws Exception {
logger.info("dbmanager-> Dialect used for smart correction: " + language); logger.info("dbmanager-> Dialect used for smart correction: "
+ language);
// data input // data input
List<Parameter> inputParameters = new ArrayList<Parameter>(); List<Parameter> inputParameters = new ArrayList<Parameter>();
@ -541,7 +508,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
for (int i = 0; i < algorithms.size(); i++) { for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("SUBMITQUERY")) { if (algorithms.get(i).equals("SUBMITQUERY")) {
algorithmId = algorithms.get(i); algorithmId = algorithms.get(i);
// print check // print check
// logger.info("algorithmId: " + algorithmId); // logger.info("algorithmId: " + algorithmId);
} }
@ -564,7 +530,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
logger.info("dbmanager-> ResourceName: " + dataDB.get("ResourceName")); logger.info("dbmanager-> ResourceName: " + dataDB.get("ResourceName"));
logger.info("dbmanager-> DatabaseName: " + dataDB.get("DatabaseName")); logger.info("dbmanager-> DatabaseName: " + dataDB.get("DatabaseName"));
logger.info("dbmanager-> Query: " + query); logger.info("dbmanager-> Query: " + query);
logger.info("dbmanager-> SmartCorrections check: " + smartCorrectionQuery); logger.info("dbmanager-> SmartCorrections check: "
+ smartCorrectionQuery);
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"));
@ -575,16 +542,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// create data structure // create data structure
ComputationOutput outputData = new ComputationOutput(); ComputationOutput outputData = new ComputationOutput();
try { try {
// computation id // computation id
String computationId = startComputation(algorithmId, String computationId = startComputation(algorithmId,
inputParameters, outputData, UID); inputParameters, outputData, UID);
// get JobID // get JobID
if (checkJob(UID)) { if (checkJob(UID)) {
// computationIDMap.put(id, computationId); // computationIDMap.put(id, computationId);
// print check on retrieving data // print check on retrieving data
@ -601,36 +565,33 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (mapValues.size() != 0) { if (mapValues.size() != 0) {
output = new ArrayList<Result>(); output = new ArrayList<Result>();
// logger.info("build the result - started"); // logger.info("build the result - started");
for (int i = 0; i < mapValues.size(); i++) { for (int i = 0; i < mapValues.size(); i++) {
Result row = new Result(mapKeys.get(String.valueOf(i)), Result row = new Result(mapKeys.get(String.valueOf(i)),
mapValues.get(String.valueOf(i))); mapValues.get(String.valueOf(i)));
output.add(row); output.add(row);
} }
// System.out.println("output size submit: " + output.size()); // System.out.println("output size submit: " +
// logger.info("build the result - finished"); // output.size());
// logger.info("build the result - finished");
// get the attributes list for the result table // get the attributes list for the result table
listAttributes = new ArrayList<String>(); listAttributes = new ArrayList<String>();
listAttributes = getListAttributes(output.get(0).getValue()); listAttributes = getListAttributes(output.get(0).getValue());
// remove the header in order to parse only the result // remove the header in order to parse only the result
output.remove(0); output.remove(0);
// store the result of the submit query operation // store the result of the submit query operation
updateSubmitQueryResultMap(UID, output); updateSubmitQueryResultMap(UID, output);
//remove job with the specified uid // remove job with the specified uid
removeJob(UID); removeJob(UID);
} }
} } else {
else{ listAttributes = null;
listAttributes =null;
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception
// e.printStackTrace(); // e.printStackTrace();
// TODO to remove. Exception Statistical management to remove a // TODO TO REMOVE. Exception Statistical management to remove a
// computation // computation
if (e.getMessage() if (e.getMessage()
.contains( .contains(
@ -660,7 +621,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
for (int i = 0; i < algorithms.size(); i++) { for (int i = 0; i < algorithms.size(); i++) {
if (algorithms.get(i).equals("SAMPLEONTABLE")) { if (algorithms.get(i).equals("SAMPLEONTABLE")) {
algorithmId = algorithms.get(i); algorithmId = algorithms.get(i);
// print check // print check
// logger.info("algorithmId: " + algorithmId); // logger.info("algorithmId: " + algorithmId);
} }
@ -680,8 +640,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// } // }
// print check // print check
logger.info("dbmanager-> ResourceName: " + dataInput.get("ResourceName")); logger.info("dbmanager-> ResourceName: "
logger.info("dbmanager-> DatabaseName: " + dataInput.get("DatabaseName")); + dataInput.get("ResourceName"));
logger.info("dbmanager-> DatabaseName: "
+ dataInput.get("DatabaseName"));
logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName")); logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName"));
logger.info("dbmanager-> TableName: " + dataInput.get("TableName")); logger.info("dbmanager-> TableName: " + dataInput.get("TableName"));
@ -712,7 +674,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
mapValues.get(String.valueOf(i))); mapValues.get(String.valueOf(i)));
output.add(row); output.add(row);
} }
return output; return output;
} }
@ -753,8 +714,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// } // }
// print check // print check
logger.info("dbmanager-> ResourceName: " + dataInput.get("ResourceName")); logger.info("dbmanager-> ResourceName: "
logger.info("dbmanager-> DatabaseName: " + dataInput.get("DatabaseName")); + dataInput.get("ResourceName"));
logger.info("dbmanager-> DatabaseName: "
+ dataInput.get("DatabaseName"));
logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName")); logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName"));
logger.info("dbmanager-> TableName: " + dataInput.get("TableName")); logger.info("dbmanager-> TableName: " + dataInput.get("TableName"));
@ -770,7 +733,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
outputData); outputData);
// print check on retrieving data // print check on retrieving data
logger.info("dbmanager-> output data retrieved"); // logger.info("dbmanager-> output data retrieved");
// data output values // data output values
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
@ -826,8 +789,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// } // }
// print check // print check
logger.info("dbmanager-> ResourceName: " + dataInput.get("ResourceName")); logger.info("dbmanager-> ResourceName: "
logger.info("dbmanager-> DatabaseName: " + dataInput.get("DatabaseName")); + dataInput.get("ResourceName"));
logger.info("dbmanager-> DatabaseName: "
+ dataInput.get("DatabaseName"));
logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName")); logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName"));
logger.info("dbmanager-> TableName: " + dataInput.get("TableName")); logger.info("dbmanager-> TableName: " + dataInput.get("TableName"));
@ -843,7 +808,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
outputData); outputData);
// print check on retrieving data // print check on retrieving data
logger.info("dbmanager-> output data retrieved"); // logger.info("dbmanager-> output data retrieved");
// data output values // data output values
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
@ -898,8 +863,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// } // }
// print check // print check
logger.info("dbmanager-> ResourceName: " + dataInput.get("ResourceName")); logger.info("dbmanager-> ResourceName: "
logger.info("dbmanager-> DatabaseName: " + dataInput.get("DatabaseName")); + dataInput.get("ResourceName"));
logger.info("dbmanager-> DatabaseName: "
+ dataInput.get("DatabaseName"));
logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName")); logger.info("dbmanager-> SchemaName: " + dataInput.get("SchemaName"));
logger.info("dbmanager-> TableName: " + dataInput.get("TableName")); logger.info("dbmanager-> TableName: " + dataInput.get("TableName"));
@ -929,7 +896,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
FileModel obj = new FileModel(mapValues.get(String.valueOf(i))); FileModel obj = new FileModel(mapValues.get(String.valueOf(i)));
// obj.setIsLoaded(true); // obj.setIsLoaded(true);
outputParameters.put(mapKeys.get(String.valueOf(i)), obj); outputParameters.put(mapKeys.get(String.valueOf(i)), obj);
// print check // print check
// logger.info("value: " + outputMap.get(String.valueOf(i))); // logger.info("value: " + outputMap.get(String.valueOf(i)));
// logger.info("key: " + outputKey.get(String.valueOf(i))); // logger.info("key: " + outputKey.get(String.valueOf(i)));
@ -940,11 +906,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// parse result for Submit query // parse result for Submit query
public PagingLoadResult<Row> loadSubmitResult(PagingLoadConfig config, public PagingLoadResult<Row> loadSubmitResult(PagingLoadConfig config,
List<String> listAttributes, String UID) throws Exception { List<String> listAttributes, String UID) throws Exception {
// System.out.println("Server - loadSubmitResultMethod");
// check to verify if the submit query result has been already parsed
// boolean checkOnDataParsed = checkOnSubmitQueryResultParsed(UID);
// System.out.println("Server - loadSubmitResultMethod");
// data parsed // data parsed
List<Row> data = new ArrayList<Row>(); List<Row> data = new ArrayList<Row>();
// submit query result // submit query result
@ -960,7 +922,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
data = parseCVSString(result, listAttributes); data = parseCVSString(result, listAttributes);
updateSubmitQueryResultParsed(UID, data); updateSubmitQueryResultParsed(UID, data);
} }
} }
// Create a sublist and add data to list according // Create a sublist and add data to list according
@ -991,20 +952,16 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private List<String> getListAttributes(String value) { private List<String> getListAttributes(String value) {
List<String> listAttributes = new ArrayList<String>(); List<String> listAttributes = new ArrayList<String>();
// recover attribute fields for the result table // recover attribute fields for the result table
String headers = value; String headers = value;
// logger.info("Headers fields table: " + headers); // logger.info("Headers fields table: " + headers);
listAttributes = parseAttributesTableResult(headers); listAttributes = parseAttributesTableResult(headers);
// logger.info("attributes number: " + listAttributes.size()); // logger.info("attributes number: " + listAttributes.size());
// logger.info("attributes list: "); // logger.info("attributes list: ");
// print check // print check
// for (int i = 0; i < listAttributes.size(); i++) { // for (int i = 0; i < listAttributes.size(); i++) {
// logger.info("attribute: " + listAttributes.get(i)); // logger.info("attribute: " + listAttributes.get(i));
// } // }
return listAttributes; return listAttributes;
} }
@ -1040,12 +997,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} }
private List<String> parse(String row) throws Exception { private List<String> parse(String row) throws Exception {
String delimiter = ","; String delimiter = ",";
// print check // print check
// logger.info("row: " + row); // logger.info("row: " + row);
List<String> elements = new ArrayList<String>(); List<String> elements = new ArrayList<String>();
String phrase = row; String phrase = row;
int idxdelim = -1; int idxdelim = -1;
@ -1068,7 +1024,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
phrase = phrase.substring(i0 + 2).trim(); phrase = phrase.substring(i0 + 2).trim();
} }
} }
if (phrase.startsWith(delimiter)) if (phrase.startsWith(delimiter))
phrase = phrase.substring(1); phrase = phrase.substring(1);
@ -1078,7 +1033,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
elements.add(phrase.substring(0, idxdelim)); elements.add(phrase.substring(0, idxdelim));
phrase = phrase.substring(idxdelim + 1).trim(); phrase = phrase.substring(idxdelim + 1).trim();
} }
// logger.info("server token: " + phrase); // logger.info("server token: " + phrase);
} }
if (phrase.startsWith("\"")) if (phrase.startsWith("\""))
@ -1088,17 +1042,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
phrase = phrase.substring(0, phrase.length() - 1); phrase = phrase.substring(0, phrase.length() - 1);
elements.add(phrase); elements.add(phrase);
// logger.info("size: " + elements.size()); // logger.info("size: " + elements.size());
return elements; return elements;
} }
private List<String> getDatabaseManagerAlgorithms() { private List<String> getDatabaseManagerAlgorithms() {
ArrayList<String> dbAlg = new ArrayList<String>(); ArrayList<String> dbAlg = new ArrayList<String>();
StatisticalManagerFactory factory = getFactory(); StatisticalManagerFactory factory = getFactory();
// get and print algorithms // get and print algorithms
SMListGroupedAlgorithms groups = factory.getAlgorithms(); SMListGroupedAlgorithms groups = factory.getAlgorithms();
@ -1117,7 +1067,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} }
private List<Parameter> getParameters(String algorithmId) { private List<Parameter> getParameters(String algorithmId) {
StatisticalManagerFactory factory = getFactory(); StatisticalManagerFactory factory = getFactory();
SMParameters smParams = factory.getAlgorithmParameters(algorithmId); SMParameters smParams = factory.getAlgorithmParameters(algorithmId);
List<Parameter> params = new ArrayList<Parameter>(); List<Parameter> params = new ArrayList<Parameter>();
@ -1165,7 +1114,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
.getAttribute("submitQueryResultParsed"); .getAttribute("submitQueryResultParsed");
if (submitQueryResultParsed.containsKey(submitQueryUID)) { if (submitQueryResultParsed.containsKey(submitQueryUID)) {
// System.out.println("ResultParsed: UID contained"); // System.out.println("ResultParsed: UID contained");
return submitQueryResultParsed.get(submitQueryUID); return submitQueryResultParsed.get(submitQueryUID);
} else { } else {
return null; return null;
@ -1306,7 +1255,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
isContained = false; isContained = false;
} }
} }
// System.out.println("JobID isContained: " + isContained); // System.out.println("JobID isContained: " + isContained);
return isContained; return isContained;
} }
@ -1352,7 +1301,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
} }
logger.info("dbmanager-> startComputation: the computation has finished!"); logger.info("dbmanager-> startComputation: the computation has finished!");
updateJobStatus(jobID, "computation finished"); updateJobStatus(jobID, "computation finished");
// removeJob(jobID); // removeJob(jobID);
return computationId; return computationId;
} catch (Exception e) { } catch (Exception e) {
@ -1364,22 +1313,17 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private float checkComputationStatus(String scope, String computationId, private float checkComputationStatus(String scope, String computationId,
String user, ComputationOutput outputData) throws Exception { String user, ComputationOutput outputData) throws Exception {
// System.out.println("checkComputation " + computationId); // System.out.println("checkComputation " + computationId);
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
StatisticalManagerFactory factory = StatisticalManagerDSL StatisticalManagerFactory factory = StatisticalManagerDSL
.createStateful().build(); .createStateful().build();
SMComputation computation = factory.getComputation(computationId); SMComputation computation = factory.getComputation(computationId);
SMOperationStatus status = SMOperationStatus.values()[computation SMOperationStatus status = SMOperationStatus.values()[computation
.operationStatus()]; .operationStatus()];
float percentage = 0; float percentage = 0;
if (status == SMOperationStatus.RUNNING) { if (status == SMOperationStatus.RUNNING) {
// logger.info("RUNNING"); // logger.info("RUNNING");
SMOperationInfo infos = factory.getComputationInfo(computationId, SMOperationInfo infos = factory.getComputationInfo(computationId,
user); user);
@ -1387,14 +1331,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// logger.info("Percentage:" + // logger.info("Percentage:" +
// percentage); // percentage);
// computation = factory.getComputation(computationId); // computation = factory.getComputation(computationId);
status = SMOperationStatus.values()[computation.operationStatus()]; status = SMOperationStatus.values()[computation.operationStatus()];
} else if ((status == SMOperationStatus.COMPLETED) } else if ((status == SMOperationStatus.COMPLETED)
|| (status == SMOperationStatus.FAILED)) { || (status == SMOperationStatus.FAILED)) {
// logger.info("computation COMPLETED");
// logger.info("computation COMPLETED");
// logger.info("COMPLETED OR FAILED"); // logger.info("COMPLETED OR FAILED");
SMAbstractResource abstractResource = computation SMAbstractResource abstractResource = computation
.abstractResource(); .abstractResource();
SMResource smResource = abstractResource.resource(); SMResource smResource = abstractResource.resource();
@ -1410,7 +1351,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// logger.info("SM resource ID: " + smResource.resourceId()); // logger.info("SM resource ID: " + smResource.resourceId());
// logger.info("SM resource Description: " + // logger.info("SM resource Description: " +
// smResource.description()); // smResource.description());
percentage = 100; percentage = 100;
} }
return percentage; return percentage;
@ -1420,7 +1360,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ComputationOutput outputData) throws Exception { ComputationOutput outputData) throws Exception {
if (smResType.equals(SMResourceType.OBJECT)) { if (smResType.equals(SMResourceType.OBJECT)) {
// switch (smResType) { // switch (smResType) {
// case FILE: // case FILE:
// SMFile fileRes = (SMFile) smResource; // SMFile fileRes = (SMFile) smResource;
@ -1443,10 +1382,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// EXCEPTION MANAGEMENT // EXCEPTION MANAGEMENT
if (smResType.equals(SMResourceType.ERROR)) { if (smResType.equals(SMResourceType.ERROR)) {
Exception e = new Exception(smResource.description()); Exception e = new Exception(smResource.description());
// e.printStackTrace(); // e.printStackTrace();
logger.error("dbmanager-> " +e); logger.error("dbmanager-> " + e);
throw e; throw e;
} }
} }
@ -1454,14 +1392,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get output result // get output result
private void getMap(SMObject objRes, ComputationOutput outputData) private void getMap(SMObject objRes, ComputationOutput outputData)
throws Exception { throws Exception {
// output data values // output data values
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
// output data keys // output data keys
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>(); LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
// logger.info("getStorageInputStream - started"); // logger.info("getStorageInputStream - started");
InputStream is = getStorageClientInputStream(objRes.url()); InputStream is = getStorageClientInputStream(objRes.url());
// object serializer // object serializer
XStream xstream = new XStream(); XStream xstream = new XStream();
@ -1477,44 +1413,36 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
xstream.alias( xstream.alias(
"org.gcube_system.namespaces.data.analysis.statisticalmanager.types.SMTable", "org.gcube_system.namespaces.data.analysis.statisticalmanager.types.SMTable",
SMTable.class); SMTable.class);
// logger.info("streaming");
// logger.info("streaming");
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, SMResource> smMap = (Map<String, SMResource>) (xstream Map<String, SMResource> smMap = (Map<String, SMResource>) (xstream
.fromXML(is)); .fromXML(is));
is.close(); is.close();
// logger.info("getStorageInputStream - finished");
// logger.info("getStorageInputStream - finished"); // logger.info("build the resultMap - started");
// logger.info("build the resultMap - started");
int i = 0; int i = 0;
for (String key : smMap.keySet()) { for (String key : smMap.keySet()) {
// add key value // add key value
mapKeys.put(String.valueOf(i), key); mapKeys.put(String.valueOf(i), key);
SMResource smres = smMap.get(key); SMResource smres = smMap.get(key);
int resourceTypeIndex = smres.resourceType(); int resourceTypeIndex = smres.resourceType();
SMResourceType smsubResType = SMResourceType.values()[resourceTypeIndex]; SMResourceType smsubResType = SMResourceType.values()[resourceTypeIndex];
// logger.info("ResourceType: " + smsubResType); // logger.info("ResourceType: " + smsubResType);
if (smsubResType == SMResourceType.OBJECT) { if (smsubResType == SMResourceType.OBJECT) {
SMObject obje = (SMObject) smres; SMObject obje = (SMObject) smres;
String outstring = obje.url(); String outstring = obje.url();
// logger.info("key: " + smsubResType); // logger.info("key: " + smsubResType);
// logger.info("object: " + outstring); // logger.info("object: " + outstring);
mapValues.put(String.valueOf(i), outstring); mapValues.put(String.valueOf(i), outstring);
i++; i++;
} }
} }
outputData.setMapValues(mapValues); outputData.setMapValues(mapValues);
outputData.setmapKeys(mapKeys); outputData.setmapKeys(mapKeys);
// logger.info("build the resultMap - finished");
// logger.info("build the resultMap - finished");
} }
private InputStream getStorageClientInputStream(String url) private InputStream getStorageClientInputStream(String url)
@ -1545,9 +1473,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// remove the computation // remove the computation
public Boolean removeComputation(String uidSubmitQuery) throws Exception { public Boolean removeComputation(String uidSubmitQuery) throws Exception {
// System.out.println("server UID: " + uidSubmitQuery); // System.out.println("server UID: " + uidSubmitQuery);
String computationId = null; String computationId = null;
if ((uidSubmitQuery != null) && (!(uidSubmitQuery.equals("")))) { if ((uidSubmitQuery != null) && (!(uidSubmitQuery.equals("")))) {
@ -1558,7 +1484,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// session // session
// .getAttribute("JobStatusList"); // .getAttribute("JobStatusList");
// String status = JobStatusMap.get(uidSubmitQuery); // String status = JobStatusMap.get(uidSubmitQuery);
String status = getJobStatus(uidSubmitQuery); String status = getJobStatus(uidSubmitQuery);
if (status == null) { if (status == null) {
@ -1567,11 +1492,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
computationId = removeJob(uidSubmitQuery); computationId = removeJob(uidSubmitQuery);
} }
} else if (status.equals("computation started")) { } else if (status.equals("computation started")) {
// System.out.println("check status: computation started"); // System.out.println("check status: computation started");
// the computation has started // the computation has started
computationId = removeJob(uidSubmitQuery); computationId = removeJob(uidSubmitQuery);
} }
} }
if (computationId != null) { if (computationId != null) {
@ -1580,24 +1504,22 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
factory.removeComputation(computationId); factory.removeComputation(computationId);
// remove submit query result // remove submit query result
refreshDataOnServer(uidSubmitQuery); refreshDataOnServer(uidSubmitQuery);
// System.out.println("computation removed"); // System.out.println("computation removed");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.info("dbmanager-> Could not remove the computation ID " logger.info("dbmanager-> Could not remove the computation ID "
+ computationId + " corresponding to jobID " + computationId + " corresponding to jobID "
+ uidSubmitQuery); + uidSubmitQuery);
logger.error("dbmanager-> " +e); logger.error("dbmanager-> " + e);
} }
} }
// remove job status // remove job status
removeJobStatus(uidSubmitQuery); removeJobStatus(uidSubmitQuery);
return (new Boolean(true)); return (new Boolean(true));
} }
public void refreshDataOnServer(String submitQueryUID) { public void refreshDataOnServer(String submitQueryUID) {
if ((submitQueryUID != null) && (!submitQueryUID.equals(""))) { if ((submitQueryUID != null) && (!submitQueryUID.equals(""))) {
removeResultParsed(submitQueryUID); removeResultParsed(submitQueryUID);
removeResult(submitQueryUID); removeResult(submitQueryUID);

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.databasesmanager.server.util;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.session.SessionManager;
@ -13,7 +12,6 @@ import org.gcube.application.framework.core.session.SessionManager;
//import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; //import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
//import org.gcube.common.homelibrary.home.workspace.Workspace; //import org.gcube.common.homelibrary.home.workspace.Workspace;
//import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException; //import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
//import org.gcube.portlets.user.workspace.client.model.InfoContactModel; //import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
//import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder; //import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;