samplings and submitQuery changed in order to return as a result a map with column values truncated to 255 characters and a file with the whole columns values in order to manage so to manage big data properly and the conversion of a geometry data type in a multipolygon representation applying the function st_astext().

GWTdbManagerServiceImpl, GxtBorderLayoutPanel and SamplingResultWithFileFromServlet classes changed in order to manage the truncated map and the file recovered from the statistical through a smp url and converted in a http url.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@101765 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-11-28 11:51:32 +00:00
parent d68735e2ca
commit d1524d1a24
3 changed files with 102 additions and 64 deletions

View File

@ -10,22 +10,31 @@ public class SamplingResultWithFileFromServlet extends BaseModelData implements
private static final long serialVersionUID = 1L;
private List<Result> output;
private String fileName;
// private String fileName;
private String urlFile;
public SamplingResultWithFileFromServlet() {
}
public SamplingResultWithFileFromServlet(List<Result> result, String fileName) {
// public SamplingResultWithFileFromServlet(List<Result> result, String fileName) {
// set("output", result);
// set("fileName", fileName);
// }
public SamplingResultWithFileFromServlet(List<Result> result, String urlFile) {
set("output", result);
set("fileName", fileName);
set("urlFile", urlFile);
}
public List<Result> getListOutput() {
return get("output");
}
public String getFileName() {
return get("fileName");
}
// public String getFileName() {
// return get("fileName");
// }
public String getUrlFile(){
return get("urlFile");
}
}

View File

@ -1401,10 +1401,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
+ result.size());
// get path
String fileName = samplingResult.getFileName();
// String fileName = samplingResult.getFileName();
String urlFile = samplingResult.getUrlFile();
// parse the result in order to obtain a
// table
parseResult(result, listAttributes, fileName);
parseResult(result, listAttributes, urlFile);
} else {
MessageBox.alert("Error ", "<br/>Message: "
@ -1520,10 +1521,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.SEVERE, "output size: "
+ result.size());
// get path
String fileName = samplingResult.getFileName();
// String fileName = samplingResult.getFileName();
String urlFile = samplingResult.getUrlFile();
// parse the result in order to obtain a
// table
parseResult(result, listAttributes, fileName);
parseResult(result, listAttributes, urlFile);
} else {
MessageBox.alert("Error ", "<br/>Message: "
+ "no data available", null);
@ -1641,10 +1643,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
rootLogger.log(Level.SEVERE, "output size: "
+ result.size());
// get path
String fileName = samplingResult.getFileName();
// String fileName = samplingResult.getFileName();
String urlFile = samplingResult.getUrlFile();
// parse the result in order to obtain a
// table
parseResult(result, listAttributes, fileName);
parseResult(result, listAttributes, urlFile);
} else {
MessageBox.alert("Error ", "<br/>Message: "
+ "no data available", null);
@ -1660,7 +1663,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// start the parsing of the submit result in order to obtain a table
private void parseResult(List<Result> result,
final List<String> listAttributes, final String fileName) {
final List<String> listAttributes, final String urlFile) {
// to unmask the entire content panel
final GxtBorderLayoutPanel obj = this;
// final Dialog form = dialog;
@ -1778,10 +1781,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
});
// add the button to download the result
final String urlFile = Window.Location
.getProtocol()
+ "//"
+ Window.Location.getHost() + fileName;
// final String urlFile = Window.Location
// .getProtocol()
// + "//"
// + Window.Location.getHost() + fileName;
Button download = new Button("Download",
new SelectionListener<ButtonEvent>() {

View File

@ -714,7 +714,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ComputationOutput outputData = new ComputationOutput();
//file name
String FileName = "QueryResult"+"_" + System.currentTimeMillis() + ".csv";
String FileName = "QueryResult_" + System.currentTimeMillis() + ".csv";
// computation id
String computationId = startComputation(algorithmId,
@ -865,6 +865,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
List<Parameter> inputParameters = new ArrayList<Parameter>();
// output sample result
List<Result> output = new ArrayList<Result>();
// List<Result> outputForFile = new ArrayList<Result>();
SamplingResultWithFileFromServlet result;
String algorithmId = ConstantsPortlet.ALGID_SAMPLEONTABLE;
@ -954,9 +955,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// start computation
// create data structure
ComputationOutput outputData = new ComputationOutput();
//file name
String FileName = "Sampling_"+ System.currentTimeMillis() + ".csv";
// computation id
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, FileName);
// print check on retrieving data
// logger.info("output data retrieved");
@ -972,20 +975,30 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
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);
//TODO ** COMMENTED
//row truncated
// Result rowForFile = new Result(mapKeys.get(String.valueOf(i)),
// mapValues.get(String.valueOf(i)));
// outputForFile.add(rowForFile);
}
String name = "Sampling" + "_" + tab;
String fileName = storeResultIntoCSVFile(output, name);
//TODO ** COMMENTED
// String name = "Sampling" + "_" + tab;
// String fileName = storeResultIntoCSVFile(outputForFile, name);
//
// HttpServletRequest request = this.getThreadLocalRequest();
// String applicationPath = request.getContextPath();
// // logger.info("dbmanager-> Application Path: " +
// // applicationPath);
// String partialPathFile = applicationPath
// + "/computationResult/" + fileName;
// result = new SamplingResultWithFileFromServlet(output,
// partialPathFile);
HttpServletRequest request = this.getThreadLocalRequest();
String applicationPath = request.getContextPath();
// logger.info("dbmanager-> Application Path: " +
// applicationPath);
String partialPathFile = applicationPath
+ "/computationResult/" + fileName;
result = new SamplingResultWithFileFromServlet(output,
partialPathFile);
String urlFile=outputData.getUrlFile();
result = new SamplingResultWithFileFromServlet(output, urlFile);
// put data in cache
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
@ -1110,9 +1123,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
smComputationQuerySamplingNumber++;
// create data structure
ComputationOutput outputData = new ComputationOutput();
//file name
String FileName = "SmartSampling_"+ System.currentTimeMillis() + ".csv";
// computation id
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, FileName);
// print check on retrieving data
// logger.info("dbmanager-> output data retrieved");
@ -1131,17 +1147,21 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
output.add(row);
}
String name = "SmartSampling" + "_" + tab;
String fileName = storeResultIntoCSVFile(output, name);
//TODO ***COMMENTED
// 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;
// result = new SamplingResultWithFileFromServlet(output,
// partialPathFile);
HttpServletRequest request = this.getThreadLocalRequest();
String applicationPath = request.getContextPath();
// logger.info("dbmanager-> Application Path: " +
// applicationPath);
String partialPathFile = applicationPath
+ "/computationResult/" + fileName;
result = new SamplingResultWithFileFromServlet(output,
partialPathFile);
String urlFile=outputData.getUrlFile();
result = new SamplingResultWithFileFromServlet(output, urlFile);
// put data in cache
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
@ -1242,9 +1262,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// create data structure
ComputationOutput outputData = new ComputationOutput();
//file name
String FileName = "RandomSampling_"+ System.currentTimeMillis() + ".csv";
// computation id
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, FileName);
// print check on retrieving data
// logger.info("dbmanager-> output data retrieved");
@ -1263,16 +1285,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
output.add(row);
}
String name = "RandomSampling" + "_" + tab;
String fileName = storeResultIntoCSVFile(output, name);
//TODO ***COMMENTED
// String name = "RandomSampling" + "_" + 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);
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);
String urlFile=outputData.getUrlFile();
SamplingResultWithFileFromServlet obj = new SamplingResultWithFileFromServlet(output, urlFile);
return obj;
} catch (Exception e) {
@ -1339,7 +1365,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ComputationOutput outputData = new ComputationOutput();
// computation id
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, null);
// print check on retrieving data
// logger.info("output data retrieved");
@ -1781,9 +1807,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private String startComputation(String algorithmName,
List<Parameter> parameters, ComputationOutput outputData,
String scope) throws Exception {
String scope, String FileName) throws Exception {
return startComputation(algorithmName, parameters, outputData, scope,
null, null);
null, FileName);
}
private String startComputation(String algorithmName,
@ -2277,7 +2303,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
//check file name
if(elem.getFileName()==null){
if(elem.getUrlFile()==null){
safe=false;
logger.trace("dbmanager-> file name not safe");
// System.out.println("status variable safe: " + safe);
@ -2914,7 +2940,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ComputationOutput outputData = new ComputationOutput();
// computationId
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, null);
// print check
// retrieve data
@ -2999,7 +3025,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ComputationOutput outputData = new ComputationOutput();
// computation id
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, null);
// print check
// retrieve data
@ -3126,7 +3152,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ComputationOutput outputData = new ComputationOutput();
// computation id
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, null);
// print check
// retrieve data
@ -3256,7 +3282,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
ComputationOutput outputData = new ComputationOutput();
// computation id
String computationId = startComputation(algorithmId,
inputParameters, outputData, scope);
inputParameters, outputData, scope, null);
// print check on retrieving data
// logger.info("output data retrieved");