- added the file csv download for the submitQuery, sampling, smartsampling and randomsampling
- class FileModel in package datamodel modified. It implements the IsSerializable and not Serializable git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100060 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d9735e3f44
commit
10007df08a
|
@ -7,6 +7,9 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.GeneralOutputFromServlet;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.GeneralOutputFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SamplingResultWithFileFromServlet;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryResultWithFileFromServlet;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
|
@ -24,18 +27,18 @@ public interface GWTdbManagerService extends RemoteService {
|
||||||
List<FileModel> getDBSchema(LinkedHashMap<String, String> dataInput)
|
List<FileModel> getDBSchema(LinkedHashMap<String, String> dataInput)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
List<String> submitQuery(LinkedHashMap<String, String> dataDB,
|
SubmitQueryResultWithFileFromServlet submitQuery(LinkedHashMap<String, String> dataDB,
|
||||||
String query, boolean valueReadOnlyQuery,
|
String query, boolean valueReadOnlyQuery,
|
||||||
boolean smartCorrectionQuery, String language, String UID)
|
boolean smartCorrectionQuery, String language, String UID)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
List<Result> sample(LinkedHashMap<String, String> dataInput)
|
SamplingResultWithFileFromServlet sample(LinkedHashMap<String, String> dataInput)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
List<Result> smartSample(LinkedHashMap<String, String> dataInput)
|
SamplingResultWithFileFromServlet smartSample(LinkedHashMap<String, String> dataInput)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
List<Result> randomSample(LinkedHashMap<String, String> dataInput)
|
SamplingResultWithFileFromServlet randomSample(LinkedHashMap<String, String> dataInput)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
||||||
|
|
|
@ -6,7 +6,10 @@ import java.util.List;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.GeneralOutputFromServlet;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.GeneralOutputFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SamplingResultWithFileFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryResultWithFileFromServlet;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -23,22 +26,22 @@ public interface GWTdbManagerServiceAsync {
|
||||||
|
|
||||||
void submitQuery(LinkedHashMap<String, String> dataDB, String query,
|
void submitQuery(LinkedHashMap<String, String> dataDB, String query,
|
||||||
boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
|
boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
|
||||||
String language, String UID, AsyncCallback<List<String>> callback);
|
String language, String UID, AsyncCallback<SubmitQueryResultWithFileFromServlet> callback);
|
||||||
|
|
||||||
void parseCVSString(List<Result> result, List<String> attrNames,
|
void parseCVSString(List<Result> result, List<String> attrNames,
|
||||||
AsyncCallback<List<Row>> callback);
|
AsyncCallback<List<Row>> callback);
|
||||||
|
|
||||||
void sample(LinkedHashMap<String, String> dataInput,
|
void sample(LinkedHashMap<String, String> dataInput,
|
||||||
AsyncCallback<List<Result>> callback);
|
AsyncCallback<SamplingResultWithFileFromServlet> callback);
|
||||||
|
|
||||||
void getTableDetails(LinkedHashMap<String, String> dataInput,
|
void getTableDetails(LinkedHashMap<String, String> dataInput,
|
||||||
AsyncCallback<LinkedHashMap<String, FileModel>> callback);
|
AsyncCallback<LinkedHashMap<String, FileModel>> callback);
|
||||||
|
|
||||||
void smartSample(LinkedHashMap<String, String> dataInput,
|
void smartSample(LinkedHashMap<String, String> dataInput,
|
||||||
AsyncCallback<List<Result>> callback);
|
AsyncCallback<SamplingResultWithFileFromServlet> callback);
|
||||||
|
|
||||||
void randomSample(LinkedHashMap<String, String> dataInput,
|
void randomSample(LinkedHashMap<String, String> dataInput,
|
||||||
AsyncCallback<List<Result>> callback);
|
AsyncCallback<SamplingResultWithFileFromServlet> callback);
|
||||||
|
|
||||||
void LoadTables(PagingLoadConfig config,
|
void LoadTables(PagingLoadConfig config,
|
||||||
LinkedHashMap<String, String> dataInput, boolean SearchTable,
|
LinkedHashMap<String, String> dataInput, boolean SearchTable,
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package org.gcube.portlets.user.databasesmanager.client.datamodel;
|
package org.gcube.portlets.user.databasesmanager.client.datamodel;
|
||||||
|
|
||||||
import java.io.Serializable;
|
//import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.data.BaseModelData;
|
import com.extjs.gxt.ui.client.data.BaseModelData;
|
||||||
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
//class that represents an item that will be displayed in the tree.
|
//class that represents an item that will be displayed in the tree.
|
||||||
//The item can be a resource, a database, a schema and a table.
|
//The item can be a resource, a database, a schema and a table.
|
||||||
public class FileModel extends BaseModelData implements Serializable {
|
public class FileModel extends BaseModelData implements IsSerializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.gcube.portlets.user.databasesmanager.client.datamodel;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.data.BaseModelData;
|
||||||
|
|
||||||
|
public class SamplingResultWithFileFromServlet extends BaseModelData implements
|
||||||
|
Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private List<Result> output;
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
public SamplingResultWithFileFromServlet() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SamplingResultWithFileFromServlet(List<Result> result, String fileName) {
|
||||||
|
set("output", result);
|
||||||
|
set("fileName", fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Result> getListOutput() {
|
||||||
|
return get("output");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return get("fileName");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package org.gcube.portlets.user.databasesmanager.client.datamodel;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.data.BaseModelData;
|
||||||
|
|
||||||
|
public class SubmitQueryResultWithFileFromServlet extends BaseModelData
|
||||||
|
implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private List<String> output;
|
||||||
|
private String fileName;
|
||||||
|
|
||||||
|
public SubmitQueryResultWithFileFromServlet() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubmitQueryResultWithFileFromServlet(List<String> result, String fileName) {
|
||||||
|
set("output", result);
|
||||||
|
set("fileName", fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getListOutput() {
|
||||||
|
return get("output");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return get("fileName");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,8 +10,10 @@ import java.util.logging.Logger;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
|
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SamplingResultWithFileFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryResultWithFileFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
|
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.events.RandomSamplingEvent;
|
import org.gcube.portlets.user.databasesmanager.client.events.RandomSamplingEvent;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.events.RefreshDataEvent;
|
import org.gcube.portlets.user.databasesmanager.client.events.RefreshDataEvent;
|
||||||
|
@ -57,7 +59,9 @@ import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
|
||||||
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||||
import com.google.gwt.event.dom.client.KeyCodes;
|
import com.google.gwt.event.dom.client.KeyCodes;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
import com.extjs.gxt.ui.client.data.BasePagingLoadConfig;
|
||||||
import com.extjs.gxt.ui.client.data.BasePagingLoader;
|
import com.extjs.gxt.ui.client.data.BasePagingLoader;
|
||||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||||
|
@ -312,12 +316,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(RefreshDataEvent.TYPE, new RefreshDataEventHandler() {
|
eventBus.addHandler(RefreshDataEvent.TYPE,
|
||||||
|
new RefreshDataEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRefreshData(RefreshDataEvent refreshDataEvent) {
|
public void onRefreshData(RefreshDataEvent refreshDataEvent) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -392,11 +396,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// hide the dialog
|
// hide the dialog
|
||||||
tablesLoaded.hide();
|
tablesLoaded.hide();
|
||||||
|
|
||||||
if (caught
|
if (caught.getMessage().contains(
|
||||||
.getMessage()
|
"Result not available")) {
|
||||||
.contains("Result not available")) {
|
MessageBox.alert("Warning ",
|
||||||
MessageBox.alert("Warning ", "<br/>Message:"
|
"<br/>Message:"
|
||||||
+ "no tables available", null);
|
+ "no tables available",
|
||||||
|
null);
|
||||||
} else {
|
} else {
|
||||||
MessageBox.alert("Error ", "<br/>Message:"
|
MessageBox.alert("Error ", "<br/>Message:"
|
||||||
+ caught.getMessage(), null);
|
+ caught.getMessage(), null);
|
||||||
|
@ -423,15 +428,15 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
|
|
||||||
List<Result> data = result.getData();
|
List<Result> data = result.getData();
|
||||||
if (data.size() == 0) {
|
if (data.size() == 0) {
|
||||||
MessageBox.alert("Warning ", "<br/>Message:"
|
MessageBox
|
||||||
+ "no tables availables", null);
|
.alert("Warning ",
|
||||||
|
"<br/>Message:"
|
||||||
|
+ "no tables availables",
|
||||||
|
null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// rootLogger.log(Level.SEVERE, "End RPC LoadTables");
|
// rootLogger.log(Level.SEVERE, "End RPC LoadTables");
|
||||||
|
@ -705,7 +710,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
FileModel selectedItem = data.get(0);
|
FileModel selectedItem = data.get(0);
|
||||||
|
|
||||||
// fire event
|
// fire event
|
||||||
eventBus.fireEvent(new SelectedTableEvent(selectedItem, selectedTable));
|
eventBus.fireEvent(new SelectedTableEvent(selectedItem,
|
||||||
|
selectedTable));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -803,7 +809,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// remote rpc
|
// remote rpc
|
||||||
RPCservice.submitQuery(dataForSubmitQuery, dataQuery.getQuery(), true,
|
RPCservice.submitQuery(dataForSubmitQuery, dataQuery.getQuery(), true,
|
||||||
dataQuery.getSmartCorrection(), language, UID,
|
dataQuery.getSmartCorrection(), language, UID,
|
||||||
new AsyncCallback<List<String>>() {
|
new AsyncCallback<SubmitQueryResultWithFileFromServlet>() {
|
||||||
|
|
||||||
// TODO: TO REMOVE data "true" as input if you manage the
|
// TODO: TO REMOVE data "true" as input if you manage the
|
||||||
// read-only query in the form
|
// read-only query in the form
|
||||||
|
@ -834,8 +840,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
MessageBox.alert("Warning ", "<br/>Message:"
|
MessageBox.alert("Warning ", "<br/>Message:"
|
||||||
+ "The query returned 0 values", null);
|
+ "The query returned 0 values", null);
|
||||||
} else {
|
} else {
|
||||||
MessageBox.alert("Error ",
|
MessageBox.alert("Error ", "<br/>Message:"
|
||||||
"<br/>Message:" + caught.getMessage(), null);
|
+ caught.getMessage(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -854,9 +860,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<String> listAttributes) {
|
public void onSuccess(SubmitQueryResultWithFileFromServlet obj) {
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
|
rootLogger.log(Level.SEVERE, "SUCCESS RPC submitQuery");
|
||||||
|
|
||||||
|
if (obj != null){
|
||||||
|
//get list attributes
|
||||||
|
List<String> listAttributes = obj.getListOutput();
|
||||||
|
|
||||||
if (form.getBody().isMasked())
|
if (form.getBody().isMasked())
|
||||||
form.getBody().unmask();
|
form.getBody().unmask();
|
||||||
|
|
||||||
|
@ -923,15 +933,20 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// parseSubmitQueryResult(result, form, dialogID,
|
// parseSubmitQueryResult(result, form, dialogID,
|
||||||
// listAttributes, dataQuery.getQuery());
|
// listAttributes, dataQuery.getQuery());
|
||||||
|
|
||||||
parseSubmitQueryResult(form, dialogID, listAttributes,
|
// get path
|
||||||
|
String fileName = obj.getFileName();
|
||||||
|
parseSubmitQueryResult(form, dialogID, listAttributes, fileName,
|
||||||
UID);
|
UID);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the parsing of the submit result in order to obtain a table
|
// start the parsing of the submit result in order to obtain a table
|
||||||
private void parseSubmitQueryResult(Dialog dialog, final int dialogID,
|
private void parseSubmitQueryResult(Dialog dialog, final int dialogID,
|
||||||
final List<String> listAttributes, final String UID) {
|
final List<String> listAttributes, String fileName, final String UID) {
|
||||||
|
|
||||||
final Dialog form = dialog;
|
final Dialog form = dialog;
|
||||||
// define the proxy and create the grid to display in the dialog
|
// define the proxy and create the grid to display in the dialog
|
||||||
|
@ -992,8 +1007,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
.log(Level.SEVERE,
|
.log(Level.SEVERE,
|
||||||
"No results have been returned");
|
"No results have been returned");
|
||||||
|
|
||||||
MessageBox.alert("Warning ", "<br/>Message:"
|
MessageBox
|
||||||
+ "The query returned 0 values", null);
|
.alert("Warning ",
|
||||||
|
"<br/>Message:"
|
||||||
|
+ "The query returned 0 values",
|
||||||
|
null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1132,6 +1150,23 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// add the button to download the result
|
||||||
|
final String urlFile = Window.Location
|
||||||
|
.getProtocol()
|
||||||
|
+ "//"
|
||||||
|
+ Window.Location.getHost() + fileName;
|
||||||
|
|
||||||
|
Button download = new Button("Download",
|
||||||
|
new SelectionListener<ButtonEvent>() {
|
||||||
|
@Override
|
||||||
|
public void componentSelected(
|
||||||
|
ButtonEvent ce) {
|
||||||
|
Window.open(urlFile, "Result File",
|
||||||
|
"_blank");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
submitResult.addButton(download);
|
||||||
submitResult.add(grid);
|
submitResult.add(grid);
|
||||||
submitResult.show();
|
submitResult.show();
|
||||||
}
|
}
|
||||||
|
@ -1189,12 +1224,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
obj.mask("Sampling the table", "x-mask-loading");
|
obj.mask("Sampling the table", "x-mask-loading");
|
||||||
|
|
||||||
// call remote service
|
// call remote service
|
||||||
RPCservice.sample(dataInput, new AsyncCallback<List<Result>>() {
|
RPCservice.sample(dataInput,
|
||||||
|
new AsyncCallback<SamplingResultWithFileFromServlet>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
rootLogger.log(Level.SEVERE, "FAILURE RPC sample");
|
rootLogger.log(Level.SEVERE, "FAILURE RPC sample");
|
||||||
if (caught.getMessage().contains("Result not available")) {
|
if (caught.getMessage()
|
||||||
|
.contains("Result not available")) {
|
||||||
MessageBox.alert("Warning ", "<br/>Message:"
|
MessageBox.alert("Warning ", "<br/>Message:"
|
||||||
+ "The table has 0 rows", null);
|
+ "The table has 0 rows", null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1207,21 +1244,68 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Result> result) {
|
public void onSuccess(SamplingResultWithFileFromServlet obj) {
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC sample");
|
rootLogger.log(Level.SEVERE, "SUCCESS RPC sample");
|
||||||
rootLogger.log(Level.SEVERE, "output size: " + result.size());
|
|
||||||
|
if (obj != null) {
|
||||||
|
// get data
|
||||||
|
List<Result> result = obj.getListOutput();
|
||||||
// get the attributes list for the result
|
// get the attributes list for the result
|
||||||
// table
|
// table
|
||||||
List<String> listAttributes = new ArrayList<String>();
|
List<String> listAttributes = new ArrayList<String>();
|
||||||
listAttributes = getListAttributes(result.get(0).getValue());
|
listAttributes = getListAttributes(result.get(0)
|
||||||
|
.getValue());
|
||||||
// remove the header in order to parse only
|
// remove the header in order to parse only
|
||||||
// the result
|
// the result
|
||||||
result.remove(0);
|
result.remove(0);
|
||||||
|
rootLogger.log(Level.SEVERE, "output size: "
|
||||||
|
+ result.size());
|
||||||
|
|
||||||
|
// get path
|
||||||
|
String fileName = obj.getFileName();
|
||||||
// parse the result in order to obtain a
|
// parse the result in order to obtain a
|
||||||
// table
|
// table
|
||||||
parseResult(result, listAttributes);
|
parseResult(result, listAttributes, fileName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// // call remote service
|
||||||
|
// RPCservice.sample(dataInput, new AsyncCallback<List<Result>>() {
|
||||||
|
// @Override
|
||||||
|
// public void onFailure(Throwable caught) {
|
||||||
|
// // Window.alert(caught.getMessage());
|
||||||
|
// rootLogger.log(Level.SEVERE, "FAILURE RPC sample");
|
||||||
|
// if (caught.getMessage().contains("Result not available")) {
|
||||||
|
// MessageBox.alert("Warning ", "<br/>Message:"
|
||||||
|
// + "The table has 0 rows", null);
|
||||||
|
// } else {
|
||||||
|
// MessageBox.alert("Error ",
|
||||||
|
// "<br/>Message:" + caught.getMessage(), null);
|
||||||
|
// }
|
||||||
|
// if (obj.isMasked()) {
|
||||||
|
// 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>();
|
||||||
|
// 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, listAttributes);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
// method that performs the smart sample
|
// method that performs the smart sample
|
||||||
|
@ -1274,12 +1358,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
obj.mask("Sampling the table", "x-mask-loading");
|
obj.mask("Sampling the table", "x-mask-loading");
|
||||||
|
|
||||||
// call remote service
|
// call remote service
|
||||||
RPCservice.smartSample(dataInput, new AsyncCallback<List<Result>>() {
|
RPCservice.smartSample(dataInput,
|
||||||
|
new AsyncCallback<SamplingResultWithFileFromServlet>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
rootLogger.log(Level.SEVERE, "FAILURE RPC smartSample");
|
rootLogger.log(Level.SEVERE, "FAILURE RPC smartSample");
|
||||||
if (caught.getMessage().contains("The table has 0 rows")) {
|
if (caught.getMessage()
|
||||||
|
.contains("The table has 0 rows")) {
|
||||||
MessageBox.alert("Warning ", "<br/>Message:"
|
MessageBox.alert("Warning ", "<br/>Message:"
|
||||||
+ "The table has 0 rows", null);
|
+ "The table has 0 rows", null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1292,19 +1378,28 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Result> result) {
|
public void onSuccess(SamplingResultWithFileFromServlet obj) {
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC smartSample");
|
rootLogger.log(Level.SEVERE, "SUCCESS RPC smartSample");
|
||||||
rootLogger.log(Level.SEVERE, "output size: " + result.size());
|
|
||||||
|
if (obj != null) {
|
||||||
|
// get data
|
||||||
|
List<Result> result = obj.getListOutput();
|
||||||
// get the attributes list for the result
|
// get the attributes list for the result
|
||||||
// table
|
// table
|
||||||
List<String> listAttributes = new ArrayList<String>();
|
List<String> listAttributes = new ArrayList<String>();
|
||||||
listAttributes = getListAttributes(result.get(0).getValue());
|
listAttributes = getListAttributes(result.get(0)
|
||||||
|
.getValue());
|
||||||
// remove the header in order to parse only
|
// remove the header in order to parse only
|
||||||
// the result
|
// the result
|
||||||
result.remove(0);
|
result.remove(0);
|
||||||
|
rootLogger.log(Level.SEVERE, "output size: "
|
||||||
|
+ result.size());
|
||||||
|
// get path
|
||||||
|
String fileName = obj.getFileName();
|
||||||
// parse the result in order to obtain a
|
// parse the result in order to obtain a
|
||||||
// table
|
// table
|
||||||
parseResult(result, listAttributes);
|
parseResult(result, listAttributes, fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1361,12 +1456,15 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
obj.mask("Sampling the table", "x-mask-loading");
|
obj.mask("Sampling the table", "x-mask-loading");
|
||||||
|
|
||||||
// call remote service
|
// call remote service
|
||||||
RPCservice.randomSample(dataInput, new AsyncCallback<List<Result>>() {
|
RPCservice.randomSample(dataInput,
|
||||||
|
new AsyncCallback<SamplingResultWithFileFromServlet>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// Window.alert(caught.getMessage());
|
// Window.alert(caught.getMessage());
|
||||||
rootLogger.log(Level.SEVERE, "FAILURE RPC randomSample");
|
rootLogger
|
||||||
if (caught.getMessage().contains("Result not available")) {
|
.log(Level.SEVERE, "FAILURE RPC randomSample");
|
||||||
|
if (caught.getMessage()
|
||||||
|
.contains("Result not available")) {
|
||||||
MessageBox.alert("Warning ", "<br/>Message:"
|
MessageBox.alert("Warning ", "<br/>Message:"
|
||||||
+ "The table has 0 rows", null);
|
+ "The table has 0 rows", null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1379,26 +1477,36 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<Result> result) {
|
public void onSuccess(SamplingResultWithFileFromServlet obj) {
|
||||||
rootLogger.log(Level.SEVERE, "SUCCESS RPC randomSample");
|
rootLogger
|
||||||
rootLogger.log(Level.SEVERE, "output size: " + result.size());
|
.log(Level.SEVERE, "SUCCESS RPC randomSample");
|
||||||
|
|
||||||
|
if (obj != null) {
|
||||||
|
// get data
|
||||||
|
List<Result> result = obj.getListOutput();
|
||||||
// get the attributes list for the result
|
// get the attributes list for the result
|
||||||
// table
|
// table
|
||||||
List<String> listAttributes = new ArrayList<String>();
|
List<String> listAttributes = new ArrayList<String>();
|
||||||
listAttributes = getListAttributes(result.get(0).getValue());
|
listAttributes = getListAttributes(result.get(0)
|
||||||
|
.getValue());
|
||||||
// remove the header in order to parse only
|
// remove the header in order to parse only
|
||||||
// the result
|
// the result
|
||||||
result.remove(0);
|
result.remove(0);
|
||||||
|
rootLogger.log(Level.SEVERE, "output size: "
|
||||||
|
+ result.size());
|
||||||
|
// get path
|
||||||
|
String fileName = obj.getFileName();
|
||||||
// parse the result in order to obtain a
|
// parse the result in order to obtain a
|
||||||
// table
|
// table
|
||||||
parseResult(result, listAttributes);
|
parseResult(result, listAttributes, fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the parsing of the submit result in order to obtain a table
|
// start the parsing of the submit result in order to obtain a table
|
||||||
private void parseResult(List<Result> result,
|
private void parseResult(List<Result> result,
|
||||||
final List<String> listAttributes) {
|
final List<String> listAttributes, final String fileName) {
|
||||||
// to unmask the entire content panel
|
// to unmask the entire content panel
|
||||||
final GxtBorderLayoutPanel obj = this;
|
final GxtBorderLayoutPanel obj = this;
|
||||||
// final Dialog form = dialog;
|
// final Dialog form = dialog;
|
||||||
|
@ -1436,6 +1544,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
if (rows != null) {
|
if (rows != null) {
|
||||||
// Display the submit query result as a table
|
// Display the submit query result as a table
|
||||||
Dialog sampleResult = new Dialog() {
|
Dialog sampleResult = new Dialog() {
|
||||||
|
|
||||||
// override the maximize event modifying it with
|
// override the maximize event modifying it with
|
||||||
// a different behaviour if the mimimize event
|
// a different behaviour if the mimimize event
|
||||||
// occurs
|
// occurs
|
||||||
|
@ -1446,6 +1555,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
super.maximize();
|
super.maximize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// if (submitQueryEventManaged == true) {
|
// if (submitQueryEventManaged == true) {
|
||||||
|
@ -1506,6 +1616,22 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// add the button to download the result
|
||||||
|
final String urlFile = Window.Location
|
||||||
|
.getProtocol()
|
||||||
|
+ "//"
|
||||||
|
+ Window.Location.getHost() + fileName;
|
||||||
|
|
||||||
|
Button download = new Button("Download",
|
||||||
|
new SelectionListener<ButtonEvent>() {
|
||||||
|
@Override
|
||||||
|
public void componentSelected(
|
||||||
|
ButtonEvent ce) {
|
||||||
|
Window.open(urlFile, "Result File",
|
||||||
|
"_blank");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sampleResult.addButton(download);
|
||||||
sampleResult.add(grid, data);
|
sampleResult.add(grid, data);
|
||||||
sampleResult.show();
|
sampleResult.show();
|
||||||
|
|
||||||
|
@ -1860,11 +1986,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
// column.setEditor(new CellEditor(textValue));
|
// column.setEditor(new CellEditor(textValue));
|
||||||
column.setEditor(new CellEditor(textValue) {
|
column.setEditor(new CellEditor(textValue) {
|
||||||
// public Object preProcessValue(Object value) {
|
// public Object preProcessValue(Object value) {
|
||||||
// System.out.println("value 1: " + store.getModels().get(0).getValue());
|
// System.out.println("value 1: " +
|
||||||
|
// store.getModels().get(0).getValue());
|
||||||
// return store.getModels().get(0).getValue();
|
// return store.getModels().get(0).getValue();
|
||||||
// }
|
// }
|
||||||
public Object postProcessValue(Object value) {
|
public Object postProcessValue(Object value) {
|
||||||
// System.out.println("value: " + store.findModel(table).getValue());
|
// System.out.println("value: " +
|
||||||
|
// store.findModel(table).getValue());
|
||||||
return store.findModel(table).getValue();
|
return store.findModel(table).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -899,6 +899,7 @@ public class GxtTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
// remove children
|
// remove children
|
||||||
|
|
||||||
removeChildren(selectedItem);
|
removeChildren(selectedItem);
|
||||||
tree.layout(true);
|
tree.layout(true);
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,21 @@ import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLStreamHandler;
|
import java.net.URLStreamHandler;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import net.sf.ehcache.CacheManager;
|
import net.sf.ehcache.CacheManager;
|
||||||
|
@ -50,7 +58,9 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.GeneralOutputFromServlet;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.GeneralOutputFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Parameter;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Parameter;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SamplingResultWithFileFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||||
|
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryResultWithFileFromServlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
||||||
import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
|
import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
|
||||||
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
||||||
|
@ -60,7 +70,6 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||||
import com.thoughtworks.xstream.XStream;
|
import com.thoughtworks.xstream.XStream;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
GWTdbManagerService {
|
GWTdbManagerService {
|
||||||
|
|
||||||
|
@ -90,7 +99,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
CacheManager cacheManager = CacheManager.newInstance(url);
|
CacheManager cacheManager = CacheManager.newInstance(url);
|
||||||
// getcache
|
// getcache
|
||||||
employeeCache = cacheManager.getEhcache("DBCache");
|
employeeCache = cacheManager.getEhcache("DBCache");
|
||||||
String path = System.getenv("CATALINA_TMPDIR");
|
// String path = System.getenv("CATALINA_TMPDIR");
|
||||||
// CacheConfiguration config =
|
// CacheConfiguration config =
|
||||||
// employeeCache.getCacheConfiguration();
|
// employeeCache.getCacheConfiguration();
|
||||||
// String DiskCacheFolderName = "DBManagerDisk";
|
// String DiskCacheFolderName = "DBManagerDisk";
|
||||||
|
@ -110,6 +119,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create folder that will contain file samplings and submitquery result
|
||||||
|
// in the /webapps/folder_portlet
|
||||||
|
String path = this.getServletContext().getRealPath("") + "/"
|
||||||
|
+ "computationResult";
|
||||||
|
|
||||||
|
// System.out.println("***PATH FILE: " + path);
|
||||||
|
|
||||||
|
File computationResult = new File(path);
|
||||||
|
if (!computationResult.exists()) {
|
||||||
|
computationResult.mkdir();
|
||||||
|
// System.out.println("***DIRECTORY CREATED");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
@ -137,8 +160,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
private void initVariables() {
|
private void initVariables() {
|
||||||
|
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
|
|
||||||
// the result generated in the LoadTables method
|
// the result generated in the LoadTables method
|
||||||
// List<Result> result = new ArrayList<Result>();
|
// List<Result> result = new ArrayList<Result>();
|
||||||
|
@ -690,10 +713,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
// to submit a query
|
// to submit a query
|
||||||
@Override
|
@Override
|
||||||
public List<String> submitQuery(LinkedHashMap<String, String> dataDB,
|
public SubmitQueryResultWithFileFromServlet submitQuery(
|
||||||
String query, boolean valueReadOnlyQuery,
|
LinkedHashMap<String, String> dataDB, String query,
|
||||||
boolean smartCorrectionQuery, String language, String UID)
|
boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
|
||||||
throws Exception {
|
String language, String UID) throws Exception {
|
||||||
|
|
||||||
logger.info("dbmanager-> Dialect used for smart correction: "
|
logger.info("dbmanager-> Dialect used for smart correction: "
|
||||||
+ language);
|
+ language);
|
||||||
|
@ -796,6 +819,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
|
|
||||||
// TODO TO REMOVE. Exception Statistical management to remove a
|
// TODO TO REMOVE. Exception Statistical management to remove a
|
||||||
// computation
|
// computation
|
||||||
if (e.getMessage()
|
if (e.getMessage()
|
||||||
|
@ -807,12 +831,95 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return listAttributes;
|
// generate the file csv output
|
||||||
|
String name = "SubmitQuery";
|
||||||
|
String fileName = storeResultIntoCSVFile(output, name);
|
||||||
|
// get the web application path
|
||||||
|
HttpServletRequest request = this.getThreadLocalRequest();
|
||||||
|
String applicationPath = request.getContextPath();
|
||||||
|
// logger.info("dbmanager-> Application Path: " + applicationPath);
|
||||||
|
String partialPathFile = applicationPath + "/computationResult/"
|
||||||
|
+ fileName;
|
||||||
|
SubmitQueryResultWithFileFromServlet obj = new SubmitQueryResultWithFileFromServlet(
|
||||||
|
listAttributes, partialPathFile);
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public List<Result> sample(LinkedHashMap<String, String> dataInput)
|
||||||
|
// throws Exception {
|
||||||
|
// // data input
|
||||||
|
// List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||||
|
// // output sample result
|
||||||
|
// List<Result> output = new ArrayList<Result>();
|
||||||
|
//
|
||||||
|
// String algorithmId = "SAMPLEONTABLE";
|
||||||
|
//
|
||||||
|
// // print check
|
||||||
|
// String rs = dataInput.get("ResourceName");
|
||||||
|
// String db = dataInput.get("DatabaseName");
|
||||||
|
// String scm = dataInput.get("SchemaName");
|
||||||
|
// String tab = dataInput.get("TableName");
|
||||||
|
//
|
||||||
|
// // print check
|
||||||
|
// logger.info("dbmanager-> ResourceName: " + rs);
|
||||||
|
// logger.info("dbmanager-> DatabaseName: " + db);
|
||||||
|
// logger.info("dbmanager-> SchemaName: " + scm);
|
||||||
|
// logger.info("dbmanager-> TableName: " + tab);
|
||||||
|
//
|
||||||
|
// // set input parameters
|
||||||
|
// Parameter resource = new Parameter("ResourceName", "", "String", "");
|
||||||
|
// Parameter database = new Parameter("DatabaseName", "", "String", "");
|
||||||
|
// Parameter schema = new Parameter("SchemaName", "", "String", "");
|
||||||
|
// Parameter table = new Parameter("TableName", "", "String", "");
|
||||||
|
// inputParameters.add(resource);
|
||||||
|
// inputParameters.add(database);
|
||||||
|
// inputParameters.add(schema);
|
||||||
|
// inputParameters.add(table);
|
||||||
|
//
|
||||||
|
// inputParameters.get(0).setValue(rs);
|
||||||
|
// inputParameters.get(1).setValue(db);
|
||||||
|
// inputParameters.get(2).setValue(scm);
|
||||||
|
// inputParameters.get(3).setValue(tab);
|
||||||
|
//
|
||||||
|
// // create data structure
|
||||||
|
// ComputationOutput outputData = new ComputationOutput();
|
||||||
|
// // computation id
|
||||||
|
// String computationId = startComputation(algorithmId, inputParameters,
|
||||||
|
// outputData);
|
||||||
|
//
|
||||||
|
// // print check on retrieving data
|
||||||
|
// // logger.info("output data retrieved");
|
||||||
|
//
|
||||||
|
// // data output values
|
||||||
|
// LinkedHashMap<String, String> mapValues = new LinkedHashMap<String,
|
||||||
|
// String>();
|
||||||
|
// // data output keys
|
||||||
|
// LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String,
|
||||||
|
// String>();
|
||||||
|
//
|
||||||
|
// mapValues = outputData.getMapValues();
|
||||||
|
// mapKeys = outputData.getmapKeys();
|
||||||
|
//
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// String partialPathFile = storeResultIntoCSVFile(output);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ResultWithFileFromServlet obj = new ResultWithFileFromServlet(output,
|
||||||
|
// partialPathFile);
|
||||||
|
//
|
||||||
|
// return output;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Result> sample(LinkedHashMap<String, String> dataInput)
|
public SamplingResultWithFileFromServlet sample(
|
||||||
throws Exception {
|
LinkedHashMap<String, String> dataInput) throws Exception {
|
||||||
// data input
|
// data input
|
||||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||||
// output sample result
|
// output sample result
|
||||||
|
@ -870,12 +977,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
output.add(row);
|
output.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
String name = "Sampling" + "_" + tab;
|
||||||
|
String fileName = storeResultIntoCSVFile(output, name);
|
||||||
|
|
||||||
|
HttpServletRequest request = this.getThreadLocalRequest();
|
||||||
|
String applicationPath = request.getContextPath();
|
||||||
|
// logger.info("dbmanager-> Application Path: " + applicationPath);
|
||||||
|
String partialPathFile = applicationPath + "/computationResult/"
|
||||||
|
+ fileName;
|
||||||
|
SamplingResultWithFileFromServlet obj = new SamplingResultWithFileFromServlet(
|
||||||
|
output, partialPathFile);
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Result> smartSample(LinkedHashMap<String, String> dataInput)
|
public SamplingResultWithFileFromServlet smartSample(
|
||||||
throws Exception {
|
LinkedHashMap<String, String> dataInput) throws Exception {
|
||||||
// data input
|
// data input
|
||||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||||
// output sample result
|
// output sample result
|
||||||
|
@ -933,12 +1051,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
output.add(row);
|
output.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
String name = "SmartSampling" + "_" + tab;
|
||||||
|
String fileName = storeResultIntoCSVFile(output, name);
|
||||||
|
|
||||||
|
HttpServletRequest request = this.getThreadLocalRequest();
|
||||||
|
String applicationPath = request.getContextPath();
|
||||||
|
// logger.info("dbmanager-> Application Path: " + applicationPath);
|
||||||
|
String partialPathFile = applicationPath + "/computationResult/"
|
||||||
|
+ fileName;
|
||||||
|
SamplingResultWithFileFromServlet obj = new SamplingResultWithFileFromServlet(
|
||||||
|
output, partialPathFile);
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Result> randomSample(LinkedHashMap<String, String> dataInput)
|
public SamplingResultWithFileFromServlet randomSample(
|
||||||
throws Exception {
|
LinkedHashMap<String, String> dataInput) throws Exception {
|
||||||
|
|
||||||
// data input
|
// data input
|
||||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||||
|
@ -997,7 +1126,18 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
output.add(row);
|
output.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
String name = "SmartSampling" + "_" + tab;
|
||||||
|
String fileName = storeResultIntoCSVFile(output, name);
|
||||||
|
|
||||||
|
HttpServletRequest request = this.getThreadLocalRequest();
|
||||||
|
String applicationPath = request.getContextPath();
|
||||||
|
// logger.info("dbmanager-> Application Path: " + applicationPath);
|
||||||
|
String partialPathFile = applicationPath + "/computationResult/"
|
||||||
|
+ fileName;
|
||||||
|
SamplingResultWithFileFromServlet obj = new SamplingResultWithFileFromServlet(
|
||||||
|
output, partialPathFile);
|
||||||
|
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1260,8 +1400,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private synchronized List<Result> getSubmitQueryResult(String submitQueryUID) {
|
private synchronized List<Result> getSubmitQueryResult(String submitQueryUID) {
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
HashMap<String, List<Result>> submitQueryResult = (HashMap<String, List<Result>>) session
|
HashMap<String, List<Result>> submitQueryResult = (HashMap<String, List<Result>>) session
|
||||||
.getAttribute("submitQueryResult");
|
.getAttribute("submitQueryResult");
|
||||||
if (submitQueryResult.containsKey(submitQueryUID)) {
|
if (submitQueryResult.containsKey(submitQueryUID)) {
|
||||||
|
@ -1273,8 +1413,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
private synchronized List<Row> getSubmitQueryResultParsed(
|
private synchronized List<Row> getSubmitQueryResultParsed(
|
||||||
String submitQueryUID) {
|
String submitQueryUID) {
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
||||||
.getAttribute("submitQueryResultParsed");
|
.getAttribute("submitQueryResultParsed");
|
||||||
|
|
||||||
|
@ -1288,8 +1428,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
private synchronized void updateSubmitQueryResultParsed(
|
private synchronized void updateSubmitQueryResultParsed(
|
||||||
String submitQueryUID, List<Row> data) {
|
String submitQueryUID, List<Row> data) {
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
||||||
.getAttribute("submitQueryResultParsed");
|
.getAttribute("submitQueryResultParsed");
|
||||||
// add data
|
// add data
|
||||||
|
@ -1301,8 +1441,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void removeResultParsed(String submitQueryUID) {
|
private synchronized void removeResultParsed(String submitQueryUID) {
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String, List<Row>>) session
|
||||||
.getAttribute("submitQueryResultParsed");
|
.getAttribute("submitQueryResultParsed");
|
||||||
if (submitQueryResultParsed.containsKey(submitQueryUID)) {
|
if (submitQueryResultParsed.containsKey(submitQueryUID)) {
|
||||||
|
@ -1327,8 +1467,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void removeResult(String submitQueryUID) {
|
private synchronized void removeResult(String submitQueryUID) {
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
HashMap<String, List<Result>> submitQueryResult = (HashMap<String, List<Result>>) session
|
HashMap<String, List<Result>> submitQueryResult = (HashMap<String, List<Result>>) session
|
||||||
.getAttribute("submitQueryResult");
|
.getAttribute("submitQueryResult");
|
||||||
if (submitQueryResult.containsKey(submitQueryUID)) {
|
if (submitQueryResult.containsKey(submitQueryUID)) {
|
||||||
|
@ -1354,8 +1494,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
// remove job with the related status
|
// remove job with the related status
|
||||||
private synchronized void removeJobStatus(String jobID) {
|
private synchronized void removeJobStatus(String jobID) {
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||||
.getAttribute("JobStatusList");
|
.getAttribute("JobStatusList");
|
||||||
String status = JobStatusMap.get(jobID);
|
String status = JobStatusMap.get(jobID);
|
||||||
|
@ -1367,8 +1507,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
// get job status
|
// get job status
|
||||||
private synchronized String getJobStatus(String jobID) {
|
private synchronized String getJobStatus(String jobID) {
|
||||||
ASLSession session = SessionUtil.getAslSession(this.getThreadLocalRequest()
|
ASLSession session = SessionUtil.getAslSession(this
|
||||||
.getSession());
|
.getThreadLocalRequest().getSession());
|
||||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||||
.getAttribute("JobStatusList");
|
.getAttribute("JobStatusList");
|
||||||
String status = JobStatusMap.get(jobID);
|
String status = JobStatusMap.get(jobID);
|
||||||
|
@ -1818,4 +1958,46 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String storeResultIntoCSVFile(List<Result> result, String n)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
// file that will contain result
|
||||||
|
BufferedWriter out = null;
|
||||||
|
|
||||||
|
String path = this.getServletContext().getRealPath("");
|
||||||
|
String fileName = "";
|
||||||
|
fileName = n + "_" + System.currentTimeMillis() + ".csv";
|
||||||
|
|
||||||
|
String filePath = path + "/computationResult/" + fileName;
|
||||||
|
File file = new File(filePath);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// create the file
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.createNewFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
out = new BufferedWriter(new OutputStreamWriter(
|
||||||
|
new FileOutputStream(file), "UTF-8"));
|
||||||
|
|
||||||
|
// write into file
|
||||||
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
out.write(result.get(i).getValue());
|
||||||
|
out.newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e);
|
||||||
|
throw e;
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
if (out != null) {
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue