the dialog that shows the submit query result has been realized with the pagination. Further, the two hashmap on the server are refreshed when this dialog is closed from the user removing the not useful data related to the submit query
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@99351 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
94c8594bf2
commit
8e641ab117
|
@ -23,9 +23,10 @@ public interface GWTdbManagerService extends RemoteService {
|
|||
List<FileModel> getDBSchema(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception;
|
||||
|
||||
List<Result> submitQuery(LinkedHashMap<String, String> dataDB,
|
||||
List<String> submitQuery(LinkedHashMap<String, String> dataDB,
|
||||
String query, boolean valueReadOnlyQuery,
|
||||
boolean smartCorrectionQuery, String language, String UID) throws Exception;
|
||||
boolean smartCorrectionQuery, String language, String UID)
|
||||
throws Exception;
|
||||
|
||||
List<Result> sample(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception;
|
||||
|
@ -45,9 +46,11 @@ public interface GWTdbManagerService extends RemoteService {
|
|||
PagingLoadResult<Result> LoadTables(PagingLoadConfig config,
|
||||
LinkedHashMap<String, String> dataInput, boolean SearchTable,
|
||||
String keyword) throws Exception;
|
||||
|
||||
Boolean removeComputation(String uidSubmitQuery) throws Exception;
|
||||
|
||||
|
||||
PagingLoadResult<Row> loadSubmitResult(PagingLoadConfig config,
|
||||
List<String> listAttributes, String UID) throws Exception;
|
||||
|
||||
Boolean removeComputation(String submitQueryUID) throws Exception;
|
||||
|
||||
void refreshDataOnServer(String submitQueryUID);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.portlets.user.databasesmanager.client;
|
|||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||
|
@ -23,7 +22,7 @@ public interface GWTdbManagerServiceAsync {
|
|||
|
||||
void submitQuery(LinkedHashMap<String, String> dataDB, String query,
|
||||
boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
|
||||
String language, String UID, AsyncCallback<List<Result>> callback);
|
||||
String language, String UID, AsyncCallback<List<String>> callback);
|
||||
|
||||
void parseCVSString(List<Result> result, List<String> attrNames,
|
||||
AsyncCallback<List<Row>> callback);
|
||||
|
@ -43,7 +42,13 @@ public interface GWTdbManagerServiceAsync {
|
|||
void LoadTables(PagingLoadConfig config,
|
||||
LinkedHashMap<String, String> dataInput, boolean SearchTable,
|
||||
String keyword, AsyncCallback<PagingLoadResult<Result>> callback);
|
||||
|
||||
|
||||
void removeComputation(String uidSubmitQuery,
|
||||
AsyncCallback<Boolean> callback);
|
||||
|
||||
void loadSubmitResult(PagingLoadConfig config,
|
||||
List<String> listAttributes, String UID,
|
||||
AsyncCallback<PagingLoadResult<Row>> callback);
|
||||
|
||||
void refreshDataOnServer(String submitQueryUID, AsyncCallback<Void> callback);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
// top toolbar that contains the buttons
|
||||
private GxtToolbarFunctionality toolbar;
|
||||
|
||||
private List<String> listAttributes;
|
||||
// private List<String> listAttributes;
|
||||
// bus to manage events
|
||||
private HandlerManager eventBus = null;
|
||||
// RPC service
|
||||
|
@ -114,8 +114,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
west = new ContentPanel();
|
||||
center = new LayoutContainer();
|
||||
treePanel = new GxtTreePanel(eventBus, service);
|
||||
// toolbar = new GxtToolbarFunctionality(eventBus);
|
||||
toolbar = new GxtToolbarFunctionality(eventBus, RPCservice);
|
||||
// toolbar = new GxtToolbarFunctionality(eventBus);
|
||||
toolbar = new GxtToolbarFunctionality(eventBus, RPCservice);
|
||||
|
||||
this.setHeaderVisible(false); // hide the header of the panel
|
||||
|
||||
|
@ -260,7 +260,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
});
|
||||
|
||||
eventBus.addHandler(LoadTablesEvent.TYPE, new LoadTablesEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onLoadTables(LoadTablesEvent loadTablesEvent) {
|
||||
// load tables
|
||||
|
@ -270,7 +269,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
eventBus.addHandler(SubmitQueryEvent.TYPE,
|
||||
new SubmitQueryEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onSubmitQuery(SubmitQueryEvent submitQueryEvent) {
|
||||
Integer dialogID = new Integer(submitQueryEvent
|
||||
|
@ -281,7 +279,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
});
|
||||
|
||||
eventBus.addHandler(SamplingEvent.TYPE, new SamplingEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onSampling(SamplingEvent samplingEvent) {
|
||||
sample();
|
||||
|
@ -290,7 +287,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
eventBus.addHandler(SmartSamplingEvent.TYPE,
|
||||
new SmartSamplingEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onSmartSampling(
|
||||
SmartSamplingEvent smartSamplingEvent) {
|
||||
|
@ -300,7 +296,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
eventBus.addHandler(RandomSamplingEvent.TYPE,
|
||||
new RandomSamplingEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onRandomSampling(
|
||||
RandomSamplingEvent randomSamplingEvent) {
|
||||
|
@ -310,7 +305,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
eventBus.addHandler(ShowCreateTableEvent.TYPE,
|
||||
new ShowCreateTableEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onShowCreateTable(
|
||||
ShowCreateTableEvent showCreateTableEvent) {
|
||||
|
@ -363,7 +357,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
String schema = "";
|
||||
|
||||
if (element.isDatabase()) { // the selected item is a database
|
||||
|
||||
rootLogger.log(Level.INFO, "selected element is a database ");
|
||||
|
||||
database = element.getName();
|
||||
|
@ -373,9 +366,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
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);
|
||||
|
@ -388,7 +379,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
dataInput.put("ResourceName", resource);
|
||||
dataInput.put("DatabaseName", database);
|
||||
dataInput.put("SchemaName", schema);
|
||||
|
||||
}
|
||||
|
||||
// print check
|
||||
|
@ -402,8 +392,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
@Override
|
||||
protected void load(Object loadConfig,
|
||||
final AsyncCallback<PagingLoadResult<Result>> callback) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
rootLogger.log(Level.SEVERE, "Start RPC - getTables");
|
||||
|
||||
rootLogger.log(Level.INFO, "keyword rpc: " + keyword);
|
||||
|
@ -414,7 +402,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
RPCservice.LoadTables((PagingLoadConfig) loadConfig, dataInput,
|
||||
startSearchTable, keyword,
|
||||
new AsyncCallback<PagingLoadResult<Result>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
|
@ -440,7 +427,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
startSearchTable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(
|
||||
PagingLoadResult<Result> result) {
|
||||
|
@ -531,7 +517,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
toolBarTop.add(cancel);
|
||||
|
||||
searchButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
// start search calling the rpc
|
||||
|
@ -566,7 +551,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
});
|
||||
|
||||
cancel.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
// clear variables
|
||||
|
@ -596,7 +580,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
// listener to manage the table selection in the grid
|
||||
grid.getSelectionModel().addSelectionChangedListener(
|
||||
new SelectionChangedListener<Result>() {
|
||||
|
||||
@Override
|
||||
public void selectionChanged(
|
||||
SelectionChangedEvent<Result> se) {
|
||||
|
@ -609,7 +592,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
// listener to manage the table selection in the grid
|
||||
grid.addListener(Events.RowClick, new Listener<GridEvent<Result>>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(final GridEvent<Result> be) {
|
||||
|
||||
|
@ -634,7 +616,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
});
|
||||
|
||||
grid.addListener(Events.BeforeEdit, new Listener<GridEvent<Result>>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(final GridEvent<Result> be) {
|
||||
rootLogger.log(Level.INFO, "table edited: "
|
||||
|
@ -650,7 +631,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
grid.addListener(Events.Attach, new Listener<GridEvent<Result>>() {
|
||||
public void handleEvent(GridEvent<Result> be) {
|
||||
|
||||
rootLogger.log(Level.INFO, "event Attach handled");
|
||||
|
||||
// disable the top toolbar at the first tables loading in such a
|
||||
|
@ -732,7 +712,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
keyword = null;
|
||||
startSearchTable = false;
|
||||
|
||||
|
@ -746,10 +725,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
});
|
||||
|
||||
canc.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
keyword = null;
|
||||
startSearchTable = false;
|
||||
// refresh the database information panel
|
||||
|
@ -758,7 +735,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
tablesLoaded.hide();
|
||||
}
|
||||
});
|
||||
|
||||
tablesLoaded.add(grid);
|
||||
tablesLoaded.show();
|
||||
}
|
||||
|
@ -791,12 +767,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
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();
|
||||
String UID = uidSubmitQueryList.get(dialogID);
|
||||
|
||||
|
||||
// get the UID related to submitQuery operation
|
||||
LinkedHashMap<Integer, String> uidSubmitQueryList = toolbar
|
||||
.getUIDSubmitQueryList();
|
||||
final String UID = uidSubmitQueryList.get(dialogID);
|
||||
|
||||
// rootLogger.log(Level.INFO, "query: "+ dataQuery.getQuery() +
|
||||
// "submitquery->dialogID: "
|
||||
|
@ -849,22 +824,17 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
if (dialect.toUpperCase().contains(ConstantsPortlet.POSTGRES)) {
|
||||
language = ConstantsPortlet.POSTGRES;
|
||||
}
|
||||
|
||||
if (dialect.toUpperCase().contains(ConstantsPortlet.MYSQL)) {
|
||||
language = ConstantsPortlet.MYSQL;
|
||||
}
|
||||
|
||||
rootLogger.log(Level.INFO, "Dialect used for smart correction: "
|
||||
+ language);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// remote rpc
|
||||
RPCservice.submitQuery(dataForSubmitQuery, dataQuery.getQuery(), true,
|
||||
dataQuery.getSmartCorrection(), language, UID,
|
||||
new AsyncCallback<List<Result>>() {
|
||||
dataQuery.getSmartCorrection(), language, UID,
|
||||
new AsyncCallback<List<String>>() {
|
||||
|
||||
// TO REMOVE data "true" as input if you manage the
|
||||
// read-only query in the form
|
||||
|
@ -886,51 +856,249 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
form.getBody().unmask();
|
||||
}
|
||||
};
|
||||
// MessageBox.alert("Error "," <br/>Cause:"+caught.getCause()+"<br/>Message:"+caught.getMessage(),
|
||||
// l);
|
||||
|
||||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<Result> result) {
|
||||
|
||||
if (result == null){
|
||||
|
||||
if (form.getBody().isMasked())
|
||||
form.getBody().unmask();
|
||||
|
||||
rootLogger.log(Level.SEVERE, "No results have been returned");
|
||||
public void onSuccess(List<String> listAttributes) {
|
||||
|
||||
if (form.getBody().isMasked())
|
||||
form.getBody().unmask();
|
||||
|
||||
if ((listAttributes == null)
|
||||
|| (listAttributes.size() == 0)) {
|
||||
|
||||
// if (form.getBody().isMasked())
|
||||
// form.getBody().unmask();
|
||||
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"No results have been returned");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"output size: " + result.size());
|
||||
rootLogger.log(Level.SEVERE, "output size: "
|
||||
+ listAttributes.size());
|
||||
|
||||
// recover query
|
||||
// Result query = result.remove(0);
|
||||
// recover converted query
|
||||
// Result convertedQuery;
|
||||
|
||||
if (dataQuery.getSmartCorrection() == true) {
|
||||
result.remove(0);
|
||||
// convertedQuery = result.get(1);
|
||||
}
|
||||
// if (dataQuery.getSmartCorrection() == true) {
|
||||
// result.remove(0);
|
||||
// // convertedQuery = result.get(1);
|
||||
// }
|
||||
|
||||
// get the attributes list for the result table
|
||||
// List<String> listAttributes = new
|
||||
// ArrayList<String>();
|
||||
// listAttributes = getListAttributes(result.get(0)
|
||||
// .getValue());
|
||||
// // remove the header in order to parse only the
|
||||
// result
|
||||
// result.remove(0);
|
||||
|
||||
// get the attributes list for the result table
|
||||
getListAttributes(result.get(0).getValue());
|
||||
// remove the header in order to parse only the result
|
||||
result.remove(0);
|
||||
|
||||
// parse the result in order to obtain a table
|
||||
boolean submitQueryEventManaged = true;
|
||||
parseResult(result, form, dialogID,
|
||||
submitQueryEventManaged);
|
||||
// boolean submitQueryEventManaged = true;
|
||||
// parseResult(result, form, dialogID,
|
||||
// submitQueryEventManaged);
|
||||
|
||||
// parseSubmitQueryResult(result, form, dialogID,
|
||||
// listAttributes, dataQuery.getQuery());
|
||||
|
||||
parseSubmitQueryResult(form, dialogID, listAttributes,
|
||||
UID);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// start the parsing of the submit result in order to obtain a table
|
||||
private void parseSubmitQueryResult(Dialog dialog, final int dialogID,
|
||||
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");
|
||||
|
||||
// remote rpc
|
||||
RPCservice.loadSubmitResult((PagingLoadConfig) loadConfig,
|
||||
listAttributes, UID,
|
||||
new AsyncCallback<PagingLoadResult<Row>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"FAILURE RPC loadSubmitQueryResult");
|
||||
MessageBox.alert("Error ", "<br/>Message:"
|
||||
+ caught.getMessage(), null);
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(PagingLoadResult<Row> result) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"SUCCESS RPC loadSubmitQueryResult");
|
||||
callback.onSuccess(result);
|
||||
List<Row> rows = result.getData();
|
||||
if (form.getBody().isMasked())
|
||||
form.getBody().unmask();
|
||||
|
||||
if ((rows == null) || (rows.size() == 0)) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"No results have been returned");
|
||||
return;
|
||||
}
|
||||
// if (result != null) {
|
||||
// rootLogger.log(Level.SEVERE,
|
||||
// "rows not null");
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// loader to load page enabled set of data
|
||||
final PagingLoader<PagingLoadResult<Row>> loader = new BasePagingLoader<PagingLoadResult<Row>>(
|
||||
proxy);
|
||||
|
||||
// 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);
|
||||
// to manage the table selection in the grid
|
||||
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
|
||||
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
|
||||
// way to disallow a user the search. It will be enabled in the
|
||||
// rpc when the tables are retrieved.
|
||||
// toolBarTop.disable();
|
||||
|
||||
PagingLoadConfig config = new BasePagingLoadConfig();
|
||||
// The offset for the first record to retrieve.
|
||||
config.setOffset(0);
|
||||
// The number of records being requested.
|
||||
config.setLimit(100);
|
||||
|
||||
// if (state.containsKey("offset")) {
|
||||
// // rootLogger.log(Level.INFO, "state contains offset");
|
||||
// int offset = (Integer) state.get("offset");
|
||||
// rootLogger.log(Level.INFO, "offset: " + offset);
|
||||
// int limit = (Integer) state.get("limit");
|
||||
// rootLogger.log(Level.INFO, "limit: " + limit);
|
||||
// config.setOffset(offset);
|
||||
// config.setLimit(limit);
|
||||
// }
|
||||
// if (state.containsKey("sortField")) {
|
||||
// config.setSortField((String) state.get("sortField"));
|
||||
// config.setSortDir(SortDir.valueOf((String) state
|
||||
// .get("sortDir")));
|
||||
// }
|
||||
loader.load(config);
|
||||
}
|
||||
});
|
||||
|
||||
// // Display the submit query result as a table
|
||||
// Dialog submitResult = new Dialog();
|
||||
// submitResult.setLayout(new FitLayout());
|
||||
//
|
||||
// //TODO DA MODIFICARE
|
||||
// submitResult.setHeading("Result");
|
||||
// submitResult.setSize(600, 400);
|
||||
//
|
||||
// submitResult.add(grid);
|
||||
// submitResult.show();
|
||||
|
||||
// Display the submit query result as a table
|
||||
Dialog submitResult = new Dialog() {
|
||||
// override the maximize event modifying it with
|
||||
// a different behaviour if the mimimize event
|
||||
// occurs
|
||||
public void maximize() {
|
||||
if (isCollapsed()) {
|
||||
expand();
|
||||
} else {
|
||||
super.maximize();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
submitResult.setLayout(new FitLayout());
|
||||
submitResult.setHeading("Result Query " + dialogID);
|
||||
submitResult.setResizable(false);
|
||||
submitResult.setSize(600, 400);
|
||||
submitResult.setScrollMode(Scroll.NONE);
|
||||
submitResult.setHideOnButtonClick(true);
|
||||
submitResult.setMaximizable(true);
|
||||
submitResult.setMinimizable(true);
|
||||
submitResult.setBottomComponent(toolBar);
|
||||
|
||||
// mimimize event handled
|
||||
submitResult.addListener(Events.Minimize, new Listener<WindowEvent>() {
|
||||
@Override
|
||||
public void handleEvent(WindowEvent be) {
|
||||
// collapse the dialog
|
||||
be.getWindow().collapse();
|
||||
}
|
||||
});
|
||||
// maximize event handled
|
||||
submitResult.addListener(Events.Maximize, new Listener<WindowEvent>() {
|
||||
@Override
|
||||
public void handleEvent(WindowEvent be) {
|
||||
// expand the dialog
|
||||
if (be.getWindow().isCollapsed()) {
|
||||
be.getWindow().expand();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
submitResult.addListener(Events.Hide, new Listener<WindowEvent>() {
|
||||
@Override
|
||||
public void handleEvent(WindowEvent be) {
|
||||
// call rpc to remove the stored result
|
||||
RPCservice.refreshDataOnServer(UID, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"FAILURE RPC refreshDataOnServer");
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"SUCCESS RPC refreshDataOnServer");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
submitResult.add(grid);
|
||||
submitResult.show();
|
||||
}
|
||||
|
||||
// method to perform the sample table
|
||||
private void sample() {
|
||||
|
||||
|
@ -1008,13 +1176,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
// get the attributes list for the result
|
||||
// table
|
||||
getListAttributes(result.get(0).getValue());
|
||||
List<String> listAttributes = new ArrayList<String>();
|
||||
listAttributes = getListAttributes(result.get(0).getValue());
|
||||
// remove the header in order to parse only
|
||||
// the result
|
||||
result.remove(0);
|
||||
// parse the result in order to obtain a
|
||||
// table
|
||||
parseResult(result, null, 0, false);
|
||||
parseResult(result, listAttributes);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1090,13 +1259,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
// get the attributes list for the result
|
||||
// table
|
||||
getListAttributes(result.get(0).getValue());
|
||||
List<String> listAttributes = new ArrayList<String>();
|
||||
listAttributes = getListAttributes(result.get(0).getValue());
|
||||
// remove the header in order to parse only
|
||||
// the result
|
||||
result.remove(0);
|
||||
// parse the result in order to obtain a
|
||||
// table
|
||||
parseResult(result, null, 0, false);
|
||||
parseResult(result, listAttributes);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1155,7 +1325,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
// call remote service
|
||||
RPCservice.randomSample(dataInput, new AsyncCallback<List<Result>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
|
@ -1166,7 +1335,6 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
obj.unmask();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<Result> result) {
|
||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC randomSample");
|
||||
|
@ -1174,28 +1342,28 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
// get the attributes list for the result
|
||||
// table
|
||||
getListAttributes(result.get(0).getValue());
|
||||
List<String> listAttributes = new ArrayList<String>();
|
||||
listAttributes = getListAttributes(result.get(0).getValue());
|
||||
// remove the header in order to parse only
|
||||
// the result
|
||||
result.remove(0);
|
||||
// parse the result in order to obtain a
|
||||
// table
|
||||
parseResult(result, null, 0, false);
|
||||
parseResult(result, listAttributes);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// start the parsing of the submit result in order to obtain a table
|
||||
private void parseResult(List<Result> result, Dialog dialog,
|
||||
final int dialogID, final boolean submitQueryEventManaged) {
|
||||
private void parseResult(List<Result> result,
|
||||
final List<String> listAttributes) {
|
||||
|
||||
// to unmask the entire content panel
|
||||
final GxtBorderLayoutPanel obj = this;
|
||||
final Dialog form = dialog;
|
||||
// final Dialog form = dialog;
|
||||
|
||||
RPCservice.parseCVSString(result, listAttributes,
|
||||
new AsyncCallback<List<Row>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
|
@ -1206,24 +1374,26 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
// if the submit query event has been performed the
|
||||
// dialog form is unmasked otherwise if a sampling
|
||||
// operation is performed the entire panel is masked.
|
||||
if (submitQueryEventManaged == true) {
|
||||
|
||||
if (form.getBody().isMasked())
|
||||
form.getBody().unmask();
|
||||
} else {
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
// if (submitQueryEventManaged == true) {
|
||||
//
|
||||
// if (form.getBody().isMasked())
|
||||
// form.getBody().unmask();
|
||||
// } else {
|
||||
// if (obj.isMasked()) {
|
||||
// obj.unmask();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<Row> rows) {
|
||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC parseResult");
|
||||
|
||||
if (rows != null) {
|
||||
// Display the submit query result as a table
|
||||
Dialog submitResult = new Dialog() {
|
||||
Dialog sampleResult = new Dialog() {
|
||||
// override the maximize event modifying it with
|
||||
// a different behaviour if the mimimize event
|
||||
// occurs
|
||||
|
@ -1235,35 +1405,37 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
}
|
||||
}
|
||||
};
|
||||
submitResult.setLayout(new FitLayout());
|
||||
|
||||
if (submitQueryEventManaged == true) {
|
||||
submitResult.setHeading("Result Query "
|
||||
+ dialogID);
|
||||
} else {
|
||||
submitResult.setHeading("Result");
|
||||
}
|
||||
// if (submitQueryEventManaged == true) {
|
||||
// submitResult.setHeading("Result Query "
|
||||
// + dialogID);
|
||||
// } else {
|
||||
// submitResult.setHeading("Result");
|
||||
// }
|
||||
|
||||
submitResult.setResizable(false);
|
||||
sampleResult.setLayout(new FitLayout());
|
||||
sampleResult.setHeading("Result");
|
||||
sampleResult.setResizable(false);
|
||||
// submitResult.setHeading("Submit Query");
|
||||
// submitResult.setWidth(290);
|
||||
// submitResult.setHeight(250);
|
||||
// submitResult.setModal(true);
|
||||
// submitResult.setBlinkModal(true);
|
||||
// submitResult.setBodyStyle("padding:9px;");
|
||||
submitResult.setSize(600, 400);
|
||||
sampleResult.setSize(600, 400);
|
||||
// submitResult.setScrollMode(Scroll.AUTO);
|
||||
submitResult.setScrollMode(Scroll.NONE);
|
||||
submitResult.setHideOnButtonClick(true);
|
||||
submitResult.setMaximizable(true);
|
||||
submitResult.setMinimizable(true);
|
||||
sampleResult.setScrollMode(Scroll.NONE);
|
||||
sampleResult.setHideOnButtonClick(true);
|
||||
sampleResult.setMaximizable(true);
|
||||
sampleResult.setMinimizable(true);
|
||||
// submitResult.addText("Result Table");
|
||||
|
||||
ListStore<Row> store = new ListStore<Row>();
|
||||
store.add(rows);
|
||||
|
||||
Grid<Row> grid;
|
||||
grid = new Grid<Row>(store, createColumnModel());
|
||||
grid = new Grid<Row>(store,
|
||||
createColumnModel(listAttributes));
|
||||
|
||||
// grid.setAutoExpandColumn("value");
|
||||
grid.setBorders(true);
|
||||
|
@ -1273,7 +1445,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
data.setMargins(new Margins(6));
|
||||
|
||||
// mimimize event handled
|
||||
submitResult.addListener(Events.Minimize,
|
||||
sampleResult.addListener(Events.Minimize,
|
||||
new Listener<WindowEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -1283,7 +1455,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
}
|
||||
});
|
||||
// maximize event handled
|
||||
submitResult.addListener(Events.Maximize,
|
||||
sampleResult.addListener(Events.Maximize,
|
||||
new Listener<WindowEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -1295,30 +1467,38 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
}
|
||||
});
|
||||
|
||||
submitResult.add(grid, data);
|
||||
submitResult.show();
|
||||
sampleResult.add(grid, data);
|
||||
sampleResult.show();
|
||||
|
||||
// if the submit query event has been performed the
|
||||
// dialog form is unmasked otherwise if a sampling
|
||||
// operation is performed the entire panel is
|
||||
// masked.
|
||||
|
||||
if (submitQueryEventManaged == true) {
|
||||
if (form.getBody().isMasked())
|
||||
form.getBody().unmask();
|
||||
} else {
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
// if (submitQueryEventManaged == true) {
|
||||
// if (form.getBody().isMasked())
|
||||
// form.getBody().unmask();
|
||||
// } else {
|
||||
// if (obj.isMasked()) {
|
||||
// obj.unmask();
|
||||
// }
|
||||
// }
|
||||
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
} else {
|
||||
if (submitQueryEventManaged == true) {
|
||||
if (form.getBody().isMasked())
|
||||
form.getBody().unmask();
|
||||
} else {
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
// if (submitQueryEventManaged == true) {
|
||||
// if (form.getBody().isMasked())
|
||||
// form.getBody().unmask();
|
||||
// } else {
|
||||
// if (obj.isMasked()) {
|
||||
// obj.unmask();
|
||||
// }
|
||||
// }
|
||||
|
||||
if (obj.isMasked()) {
|
||||
obj.unmask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1326,24 +1506,28 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
// get attributes list for display the result in a table
|
||||
private void getListAttributes(String value) {
|
||||
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);
|
||||
// rootLogger.log(Level.INFO, "Headers fields table: " + headers);
|
||||
|
||||
listAttributes = parseAttributesTableResult(headers);
|
||||
rootLogger.log(Level.INFO,
|
||||
"attributes number: " + listAttributes.size());
|
||||
|
||||
rootLogger.log(Level.INFO, "attributes list: ");
|
||||
for (int i = 0; i < listAttributes.size(); i++) {
|
||||
rootLogger.log(Level.INFO, "attribute: " + listAttributes.get(i));
|
||||
}
|
||||
// rootLogger.log(Level.INFO, "attributes list: ");
|
||||
// print check
|
||||
// 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() {
|
||||
private ColumnModel createColumnModel(List<String> listAttributes) {
|
||||
|
||||
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||
ColumnConfig column;
|
||||
|
@ -1357,7 +1541,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
|
||||
for (int i = 0; i < listAttributes.size(); i++) {
|
||||
|
||||
rootLogger.log(Level.INFO, "attribute: " + listAttributes.get(i));
|
||||
// rootLogger.log(Level.INFO, "attribute: " +
|
||||
// listAttributes.get(i));
|
||||
column = new ColumnConfig();
|
||||
column.setId(listAttributes.get(i));
|
||||
// column.setId("\"" + fields.get(i) + "\"");
|
||||
|
@ -1640,7 +1825,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
private void displayTableName(String tableName) {
|
||||
rootLogger.log(Level.INFO, "displaying table name" + tableName
|
||||
rootLogger.log(Level.INFO, "displaying table name " + tableName
|
||||
+ " in the panel");
|
||||
|
||||
Result table = new Result("Selected table", tableName);
|
||||
|
|
|
@ -174,7 +174,6 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
btnSubmitQuery
|
||||
.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
|
@ -219,7 +218,6 @@ public class GxtToolbarFunctionality {
|
|||
// minimize event handled
|
||||
dialog.addListener(Events.Minimize,
|
||||
new Listener<WindowEvent>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(WindowEvent be) {
|
||||
// collapse the dialog
|
||||
|
@ -230,7 +228,6 @@ public class GxtToolbarFunctionality {
|
|||
// override maximize event
|
||||
dialog.addListener(Events.Maximize,
|
||||
new Listener<WindowEvent>() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(WindowEvent be) {
|
||||
// expand the dialog
|
||||
|
@ -243,10 +240,8 @@ public class GxtToolbarFunctionality {
|
|||
// listener on the dialog "ok" button
|
||||
dialog.getButtonById(Dialog.OK).addSelectionListener(
|
||||
new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
// recover info from dialog
|
||||
setInfoOnSubmitQuery(form, dialog,
|
||||
dialogID);
|
||||
|
@ -259,13 +254,15 @@ public class GxtToolbarFunctionality {
|
|||
dialog.getButtonById(Dialog.CANCEL)
|
||||
.addSelectionListener(
|
||||
new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(
|
||||
ButtonEvent ce) {
|
||||
rootLogger.log(Level.INFO,
|
||||
"button Cancel event");
|
||||
|
||||
if (uidSubmitQueryList
|
||||
.get(dialogID)!=null){
|
||||
|
||||
// remove computation
|
||||
RPCservice.removeComputation(
|
||||
uidSubmitQueryList
|
||||
|
@ -287,7 +284,6 @@ public class GxtToolbarFunctionality {
|
|||
+ uidSubmitQueryList
|
||||
.get(dialogID));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -298,6 +294,7 @@ public class GxtToolbarFunctionality {
|
|||
"FAILURE RPC removeComputation");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.hide();
|
||||
}
|
||||
|
@ -307,10 +304,8 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
btnSimpleSample
|
||||
.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
// fire event
|
||||
eventBus.fireEvent(new SamplingEvent());
|
||||
}
|
||||
|
@ -318,10 +313,8 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
btnSmartSample
|
||||
.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
// fire event
|
||||
eventBus.fireEvent(new SmartSamplingEvent());
|
||||
}
|
||||
|
@ -329,10 +322,8 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
btnRandomSample
|
||||
.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
// fire event
|
||||
eventBus.fireEvent(new RandomSamplingEvent());
|
||||
}
|
||||
|
@ -340,10 +331,8 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
btnShowCreateTable
|
||||
.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
// fire event
|
||||
eventBus.fireEvent(new ShowCreateTableEvent());
|
||||
}
|
||||
|
@ -351,10 +340,8 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
btnTablesList
|
||||
.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
// fire event
|
||||
eventBus.fireEvent(new LoadTablesEvent());
|
||||
}
|
||||
|
|
|
@ -88,6 +88,22 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
List<Result> result = new ArrayList<Result>();
|
||||
session.setAttribute("TablesResult", result);
|
||||
|
||||
// map that contains the submit query result and the related uid
|
||||
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
|
||||
// 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);
|
||||
|
@ -108,6 +124,17 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
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
|
||||
|
@ -488,7 +515,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
// to submit a query
|
||||
@Override
|
||||
public List<Result> submitQuery(LinkedHashMap<String, String> dataDB,
|
||||
public List<String> submitQuery(LinkedHashMap<String, String> dataDB,
|
||||
String query, boolean valueReadOnlyQuery,
|
||||
boolean smartCorrectionQuery, String language, String UID)
|
||||
throws Exception {
|
||||
|
@ -501,6 +528,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// List<Result> output = new ArrayList<Result>();
|
||||
List<Result> output = null;
|
||||
|
||||
// list that contains table attributes
|
||||
List<String> listAttributes = null;
|
||||
|
||||
// get list of algorithms
|
||||
List<String> algorithms = new ArrayList<String>();
|
||||
algorithms = getDatabaseManagerAlgorithms();
|
||||
|
@ -573,17 +603,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
mapValues.get(String.valueOf(i)));
|
||||
output.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
return output;
|
||||
return listAttributes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Result> sample(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception {
|
||||
|
@ -879,6 +915,90 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return outputParameters;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// data parsed
|
||||
List<Row> data = new ArrayList<Row>();
|
||||
// submit query result
|
||||
List<Result> result = new ArrayList<Result>();
|
||||
//get parsed data
|
||||
data = getSubmitQueryResultParsed(UID);
|
||||
|
||||
if ((data == null)) {
|
||||
// parse the submit query result
|
||||
result = getSubmitQueryResult(UID);
|
||||
|
||||
if ((result != null) && (result.size() != 0)) {
|
||||
data = parseCVSString(result, listAttributes);
|
||||
updateSubmitQueryResultParsed(UID, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create a sublist and add data to list according
|
||||
// to the limit and offset value of the config
|
||||
List<Row> sublist = new ArrayList<Row>();
|
||||
BasePagingLoadResult loadResult = null;
|
||||
|
||||
int start = config.getOffset();
|
||||
int limit = data.size();
|
||||
|
||||
if (config.getLimit() > 0) {
|
||||
limit = Math.min(start + config.getLimit(), limit);
|
||||
}
|
||||
|
||||
int totalNumber = data.size();
|
||||
sublist = new ArrayList<Row>(data.subList(start, limit));
|
||||
loadResult = new BasePagingLoadResult<Row>(sublist, config.getOffset(),
|
||||
totalNumber);
|
||||
|
||||
// System.out.println("start: " + start);
|
||||
// System.out.println("limit: " + limit);
|
||||
// System.out.println("sublist size: " + sublist.size());
|
||||
|
||||
return loadResult;
|
||||
}
|
||||
|
||||
// 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;
|
||||
// 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;
|
||||
}
|
||||
|
||||
private List<String> parseAttributesTableResult(String phrase) {
|
||||
String delimiter = ",";
|
||||
List<String> elements = new ArrayList<String>();
|
||||
int idxdelim = -1;
|
||||
phrase = phrase.trim();
|
||||
|
||||
while ((idxdelim = phrase.indexOf(delimiter)) >= 0) {
|
||||
elements.add(phrase.substring(0, idxdelim));
|
||||
phrase = phrase.substring(idxdelim + 1).trim();
|
||||
}
|
||||
elements.add(phrase);
|
||||
return elements;
|
||||
}
|
||||
|
||||
// parse a csv row in a list of values
|
||||
@Override
|
||||
public List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
||||
|
@ -1002,7 +1122,86 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return params;
|
||||
}
|
||||
|
||||
//update job with the related status
|
||||
private synchronized List<Result> getSubmitQueryResult(String submitQueryUID) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
HashMap<String, List<Result>> submitQueryResult = (HashMap<String, List<Result>>) session
|
||||
.getAttribute("submitQueryResult");
|
||||
if (submitQueryResult.containsKey(submitQueryUID)) {
|
||||
return submitQueryResult.get(submitQueryUID);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized List<Row> getSubmitQueryResultParsed(
|
||||
String submitQueryUID) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
||||
.getAttribute("submitQueryResultParsed");
|
||||
|
||||
if (submitQueryResultParsed.containsKey(submitQueryUID)) {
|
||||
return submitQueryResultParsed.get(submitQueryUID);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void updateSubmitQueryResultParsed(
|
||||
String submitQueryUID, List<Row> data) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
||||
.getAttribute("submitQueryResultParsed");
|
||||
// add data
|
||||
if (data.size() != 0) {
|
||||
submitQueryResultParsed.put(submitQueryUID, data);
|
||||
session.setAttribute("submitQueryResultParsed",
|
||||
submitQueryResultParsed);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeResultParsed(String submitQueryUID) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
||||
.getAttribute("submitQueryResultParsed");
|
||||
if (submitQueryResultParsed.containsKey(submitQueryUID)) {
|
||||
// remove data parsed
|
||||
submitQueryResultParsed.remove(submitQueryUID);
|
||||
// update
|
||||
session.setAttribute("submitQueryResultParsed",
|
||||
submitQueryResultParsed);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void updateSubmitQueryResultMap(String submitQueryUID,
|
||||
List<Result> result) {
|
||||
if (submitQueryUID != null) {
|
||||
ASLSession session = WsUtil.getAslSession(this
|
||||
.getThreadLocalRequest().getSession());
|
||||
HashMap<String, List<Result>> submitQueryResult = (HashMap<String, List<Result>>) session
|
||||
.getAttribute("submitQueryResult");
|
||||
submitQueryResult.put(submitQueryUID, result);
|
||||
session.setAttribute("submitQueryResult", submitQueryResult);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void removeResult(String submitQueryUID) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
HashMap<String, List<Result>> submitQueryResult = (HashMap<String, List<Result>>) session
|
||||
.getAttribute("submitQueryResult");
|
||||
if (submitQueryResult.containsKey(submitQueryUID)) {
|
||||
// remove data parsed
|
||||
submitQueryResult.remove(submitQueryUID);
|
||||
// update
|
||||
session.setAttribute("submitQueryResult", submitQueryResult);
|
||||
}
|
||||
}
|
||||
|
||||
// update job with the related status
|
||||
private synchronized void updateJobStatus(String jobID, String status) {
|
||||
if (jobID != null) {
|
||||
// add the job status
|
||||
|
@ -1013,26 +1212,32 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
JobStatusMap.put(jobID, status);
|
||||
session.setAttribute("JobStatusList", JobStatusMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//remove job with the related status
|
||||
// remove job with the related status
|
||||
private synchronized void removeJobStatus(String jobID) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
|
||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||
.getAttribute("JobStatusList");
|
||||
|
||||
String status = JobStatusMap.get(jobID);
|
||||
if (status != null) {
|
||||
|
||||
JobStatusMap.remove(jobID);
|
||||
session.setAttribute("JobStatusList", JobStatusMap);
|
||||
}
|
||||
}
|
||||
|
||||
//update job with the computation id
|
||||
// get job status
|
||||
private synchronized String getJobStatus(String jobID) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||
.getAttribute("JobStatusList");
|
||||
String status = JobStatusMap.get(jobID);
|
||||
return status;
|
||||
}
|
||||
|
||||
// update job with the computation id
|
||||
private synchronized void updateJob(String jobID, String computationId) {
|
||||
if (jobID != null) {
|
||||
// add the computation in the map
|
||||
|
@ -1045,7 +1250,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
//remove job with the computation id
|
||||
// remove job with the computation id
|
||||
private synchronized String removeJob(String jobID) {
|
||||
if (jobID != null) {
|
||||
// System.out.println("remove jobID " + job);
|
||||
|
@ -1287,7 +1492,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return SessionUtil.getScope(httpSession);
|
||||
}
|
||||
|
||||
//remove the computation
|
||||
// remove the computation
|
||||
public Boolean removeComputation(String uidSubmitQuery) throws Exception {
|
||||
|
||||
// System.out.println("server UID: " + uidSubmitQuery);
|
||||
|
@ -1296,11 +1501,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
if ((uidSubmitQuery != null) && (!(uidSubmitQuery.equals("")))) {
|
||||
// get job status
|
||||
ASLSession session = WsUtil.getAslSession(this
|
||||
.getThreadLocalRequest().getSession());
|
||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||
.getAttribute("JobStatusList");
|
||||
String status = JobStatusMap.get(uidSubmitQuery);
|
||||
// ASLSession session = WsUtil.getAslSession(this
|
||||
// .getThreadLocalRequest().getSession());
|
||||
// HashMap<String, String> JobStatusMap = (HashMap<String, String>)
|
||||
// session
|
||||
// .getAttribute("JobStatusList");
|
||||
// String status = JobStatusMap.get(uidSubmitQuery);
|
||||
|
||||
String status = getJobStatus(uidSubmitQuery);
|
||||
|
||||
if (status == null) {
|
||||
// the computation has not started
|
||||
|
@ -1332,4 +1540,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return (new Boolean(true));
|
||||
}
|
||||
|
||||
public void refreshDataOnServer(String submitQueryUID) {
|
||||
|
||||
if ((submitQueryUID != null) && (!submitQueryUID.equals(""))) {
|
||||
removeResultParsed(submitQueryUID);
|
||||
removeResult(submitQueryUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue