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;
public enum EventsTypeEnum {
SELECTED_ITEM_EVENT,
SUBMIT_QUERY_EVENT,
SHOW_CREATE_TABLE_EVENT,
@ -11,5 +10,4 @@ public enum EventsTypeEnum {
LOAD_TABLES_EVENT,
SELECTED_TABLE_EVENT,
CANCEL_EXECUTION_QUERY;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.databasesmanager.server.util;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
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.workspace.Workspace;
//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.portlets.user.workspace.client.model.InfoContactModel;
//import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;