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:
parent
d68735e2ca
commit
d1524d1a24
|
@ -10,22 +10,31 @@ public class SamplingResultWithFileFromServlet extends BaseModelData implements
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private List<Result> output;
|
private List<Result> output;
|
||||||
private String fileName;
|
// private String fileName;
|
||||||
|
private String urlFile;
|
||||||
|
|
||||||
public SamplingResultWithFileFromServlet() {
|
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("output", result);
|
||||||
set("fileName", fileName);
|
set("urlFile", urlFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Result> getListOutput() {
|
public List<Result> getListOutput() {
|
||||||
return get("output");
|
return get("output");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileName() {
|
// public String getFileName() {
|
||||||
return get("fileName");
|
// return get("fileName");
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
public String getUrlFile(){
|
||||||
|
return get("urlFile");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1401,10 +1401,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
+ result.size());
|
+ result.size());
|
||||||
|
|
||||||
// get path
|
// get path
|
||||||
String fileName = samplingResult.getFileName();
|
// String fileName = samplingResult.getFileName();
|
||||||
|
String urlFile = samplingResult.getUrlFile();
|
||||||
// parse the result in order to obtain a
|
// parse the result in order to obtain a
|
||||||
// table
|
// table
|
||||||
parseResult(result, listAttributes, fileName);
|
parseResult(result, listAttributes, urlFile);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MessageBox.alert("Error ", "<br/>Message: "
|
MessageBox.alert("Error ", "<br/>Message: "
|
||||||
|
@ -1520,10 +1521,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
rootLogger.log(Level.SEVERE, "output size: "
|
rootLogger.log(Level.SEVERE, "output size: "
|
||||||
+ result.size());
|
+ result.size());
|
||||||
// get path
|
// get path
|
||||||
String fileName = samplingResult.getFileName();
|
// String fileName = samplingResult.getFileName();
|
||||||
|
String urlFile = samplingResult.getUrlFile();
|
||||||
// parse the result in order to obtain a
|
// parse the result in order to obtain a
|
||||||
// table
|
// table
|
||||||
parseResult(result, listAttributes, fileName);
|
parseResult(result, listAttributes, urlFile);
|
||||||
} else {
|
} else {
|
||||||
MessageBox.alert("Error ", "<br/>Message: "
|
MessageBox.alert("Error ", "<br/>Message: "
|
||||||
+ "no data available", null);
|
+ "no data available", null);
|
||||||
|
@ -1641,10 +1643,11 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
rootLogger.log(Level.SEVERE, "output size: "
|
rootLogger.log(Level.SEVERE, "output size: "
|
||||||
+ result.size());
|
+ result.size());
|
||||||
// get path
|
// get path
|
||||||
String fileName = samplingResult.getFileName();
|
// String fileName = samplingResult.getFileName();
|
||||||
|
String urlFile = samplingResult.getUrlFile();
|
||||||
// parse the result in order to obtain a
|
// parse the result in order to obtain a
|
||||||
// table
|
// table
|
||||||
parseResult(result, listAttributes, fileName);
|
parseResult(result, listAttributes, urlFile);
|
||||||
} else {
|
} else {
|
||||||
MessageBox.alert("Error ", "<br/>Message: "
|
MessageBox.alert("Error ", "<br/>Message: "
|
||||||
+ "no data available", null);
|
+ "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
|
// 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 String fileName) {
|
final List<String> listAttributes, final String urlFile) {
|
||||||
// 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;
|
||||||
|
@ -1778,10 +1781,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
// add the button to download the result
|
// add the button to download the result
|
||||||
final String urlFile = Window.Location
|
// final String urlFile = Window.Location
|
||||||
.getProtocol()
|
// .getProtocol()
|
||||||
+ "//"
|
// + "//"
|
||||||
+ Window.Location.getHost() + fileName;
|
// + Window.Location.getHost() + fileName;
|
||||||
|
|
||||||
Button download = new Button("Download",
|
Button download = new Button("Download",
|
||||||
new SelectionListener<ButtonEvent>() {
|
new SelectionListener<ButtonEvent>() {
|
||||||
|
|
|
@ -714,7 +714,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
|
|
||||||
//file name
|
//file name
|
||||||
String FileName = "QueryResult"+"_" + System.currentTimeMillis() + ".csv";
|
String FileName = "QueryResult_" + System.currentTimeMillis() + ".csv";
|
||||||
|
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
|
@ -865,6 +865,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||||
// output sample result
|
// output sample result
|
||||||
List<Result> output = new ArrayList<Result>();
|
List<Result> output = new ArrayList<Result>();
|
||||||
|
// List<Result> outputForFile = new ArrayList<Result>();
|
||||||
SamplingResultWithFileFromServlet result;
|
SamplingResultWithFileFromServlet result;
|
||||||
|
|
||||||
String algorithmId = ConstantsPortlet.ALGID_SAMPLEONTABLE;
|
String algorithmId = ConstantsPortlet.ALGID_SAMPLEONTABLE;
|
||||||
|
@ -954,9 +955,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// start computation
|
// start computation
|
||||||
// create data structure
|
// create data structure
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
|
//file name
|
||||||
|
String FileName = "Sampling_"+ System.currentTimeMillis() + ".csv";
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, FileName);
|
||||||
|
|
||||||
// print check on retrieving data
|
// print check on retrieving data
|
||||||
// logger.info("output data retrieved");
|
// logger.info("output data retrieved");
|
||||||
|
@ -972,20 +975,30 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
for (int i = 0; i < mapValues.size(); i++) {
|
for (int i = 0; i < mapValues.size(); i++) {
|
||||||
Result row = new Result(mapKeys.get(String.valueOf(i)),
|
Result row = new Result(mapKeys.get(String.valueOf(i)),
|
||||||
mapValues.get(String.valueOf(i)));
|
mapValues.get(String.valueOf(i)));
|
||||||
|
|
||||||
output.add(row);
|
output.add(row);
|
||||||
|
//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;
|
//TODO ** COMMENTED
|
||||||
String fileName = storeResultIntoCSVFile(output, name);
|
// 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 urlFile=outputData.getUrlFile();
|
||||||
String applicationPath = request.getContextPath();
|
result = new SamplingResultWithFileFromServlet(output, urlFile);
|
||||||
// logger.info("dbmanager-> Application Path: " +
|
|
||||||
// applicationPath);
|
|
||||||
String partialPathFile = applicationPath
|
|
||||||
+ "/computationResult/" + fileName;
|
|
||||||
result = new SamplingResultWithFileFromServlet(output,
|
|
||||||
partialPathFile);
|
|
||||||
|
|
||||||
// put data in cache
|
// put data in cache
|
||||||
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
|
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
|
||||||
|
@ -1110,9 +1123,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
smComputationQuerySamplingNumber++;
|
smComputationQuerySamplingNumber++;
|
||||||
// create data structure
|
// create data structure
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
|
|
||||||
|
//file name
|
||||||
|
String FileName = "SmartSampling_"+ System.currentTimeMillis() + ".csv";
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, FileName);
|
||||||
|
|
||||||
// print check on retrieving data
|
// print check on retrieving data
|
||||||
// logger.info("dbmanager-> output data retrieved");
|
// logger.info("dbmanager-> output data retrieved");
|
||||||
|
@ -1131,17 +1147,21 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
output.add(row);
|
output.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = "SmartSampling" + "_" + tab;
|
//TODO ***COMMENTED
|
||||||
String fileName = storeResultIntoCSVFile(output, name);
|
// 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 urlFile=outputData.getUrlFile();
|
||||||
String applicationPath = request.getContextPath();
|
result = new SamplingResultWithFileFromServlet(output, urlFile);
|
||||||
// logger.info("dbmanager-> Application Path: " +
|
|
||||||
// applicationPath);
|
|
||||||
String partialPathFile = applicationPath
|
|
||||||
+ "/computationResult/" + fileName;
|
|
||||||
result = new SamplingResultWithFileFromServlet(output,
|
|
||||||
partialPathFile);
|
|
||||||
|
|
||||||
// put data in cache
|
// put data in cache
|
||||||
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
|
net.sf.ehcache.Element dataToCache = new net.sf.ehcache.Element(
|
||||||
|
@ -1242,9 +1262,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
// create data structure
|
// create data structure
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
|
//file name
|
||||||
|
String FileName = "RandomSampling_"+ System.currentTimeMillis() + ".csv";
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, FileName);
|
||||||
|
|
||||||
// print check on retrieving data
|
// print check on retrieving data
|
||||||
// logger.info("dbmanager-> output data retrieved");
|
// logger.info("dbmanager-> output data retrieved");
|
||||||
|
@ -1263,16 +1285,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
output.add(row);
|
output.add(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = "RandomSampling" + "_" + tab;
|
//TODO ***COMMENTED
|
||||||
String fileName = storeResultIntoCSVFile(output, name);
|
// 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 urlFile=outputData.getUrlFile();
|
||||||
String applicationPath = request.getContextPath();
|
SamplingResultWithFileFromServlet obj = new SamplingResultWithFileFromServlet(output, urlFile);
|
||||||
// logger.info("dbmanager-> Application Path: " + applicationPath);
|
|
||||||
String partialPathFile = applicationPath + "/computationResult/"
|
|
||||||
+ fileName;
|
|
||||||
SamplingResultWithFileFromServlet obj = new SamplingResultWithFileFromServlet(
|
|
||||||
output, partialPathFile);
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1339,7 +1365,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, null);
|
||||||
|
|
||||||
// print check on retrieving data
|
// print check on retrieving data
|
||||||
// logger.info("output data retrieved");
|
// logger.info("output data retrieved");
|
||||||
|
@ -1781,9 +1807,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
private String startComputation(String algorithmName,
|
private String startComputation(String algorithmName,
|
||||||
List<Parameter> parameters, ComputationOutput outputData,
|
List<Parameter> parameters, ComputationOutput outputData,
|
||||||
String scope) throws Exception {
|
String scope, String FileName) throws Exception {
|
||||||
return startComputation(algorithmName, parameters, outputData, scope,
|
return startComputation(algorithmName, parameters, outputData, scope,
|
||||||
null, null);
|
null, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String startComputation(String algorithmName,
|
private String startComputation(String algorithmName,
|
||||||
|
@ -1991,8 +2017,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
if (smsubResType == SMResourceType.OBJECT) {
|
if (smsubResType == SMResourceType.OBJECT) {
|
||||||
SMObject obje = (SMObject) smres;
|
SMObject obje = (SMObject) smres;
|
||||||
String outstring = obje.url();
|
String outstring = obje.url();
|
||||||
// logger.info("key: " + smsubResType);
|
// logger.info("key: " + smsubResType);
|
||||||
// logger.info("object: " + outstring);
|
// logger.info("object: " + outstring);
|
||||||
mapValues.put(String.valueOf(i), outstring);
|
mapValues.put(String.valueOf(i), outstring);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -2277,7 +2303,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
//check file name
|
//check file name
|
||||||
if(elem.getFileName()==null){
|
if(elem.getUrlFile()==null){
|
||||||
safe=false;
|
safe=false;
|
||||||
logger.trace("dbmanager-> file name not safe");
|
logger.trace("dbmanager-> file name not safe");
|
||||||
// System.out.println("status variable safe: " + safe);
|
// System.out.println("status variable safe: " + safe);
|
||||||
|
@ -2914,7 +2940,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
// computationId
|
// computationId
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, null);
|
||||||
|
|
||||||
// print check
|
// print check
|
||||||
// retrieve data
|
// retrieve data
|
||||||
|
@ -2999,7 +3025,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, null);
|
||||||
|
|
||||||
// print check
|
// print check
|
||||||
// retrieve data
|
// retrieve data
|
||||||
|
@ -3126,7 +3152,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, null);
|
||||||
|
|
||||||
// print check
|
// print check
|
||||||
// retrieve data
|
// retrieve data
|
||||||
|
@ -3256,7 +3282,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
ComputationOutput outputData = new ComputationOutput();
|
ComputationOutput outputData = new ComputationOutput();
|
||||||
// computation id
|
// computation id
|
||||||
String computationId = startComputation(algorithmId,
|
String computationId = startComputation(algorithmId,
|
||||||
inputParameters, outputData, scope);
|
inputParameters, outputData, scope, null);
|
||||||
|
|
||||||
// print check on retrieving data
|
// print check on retrieving data
|
||||||
// logger.info("output data retrieved");
|
// logger.info("output data retrieved");
|
||||||
|
|
Loading…
Reference in New Issue