bug fixed related to presentation of the result when the submitquery with the smart correction is called. Now dialog result displays the query and the grid result.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100161 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-09-24 09:02:22 +00:00
parent e3d7a79504
commit 341caee51f
3 changed files with 58 additions and 82 deletions

View File

@ -10,13 +10,15 @@ public class SubmitQueryResultWithFileFromServlet extends BaseModelData
private static final long serialVersionUID = 1L;
private List<String> output;
private String convertedQuery;
private String fileName;
public SubmitQueryResultWithFileFromServlet() {
}
public SubmitQueryResultWithFileFromServlet(List<String> result, String fileName) {
public SubmitQueryResultWithFileFromServlet(List<String> result, String query, String fileName) {
set("output", result);
set("convertedQuery", query);
set("fileName", fileName);
}
@ -27,5 +29,9 @@ public class SubmitQueryResultWithFileFromServlet extends BaseModelData
public String getFileName() {
return get("fileName");
}
public String getConvertedQuery() {
return get("convertedQuery");
}
}

View File

@ -34,6 +34,8 @@ import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SubmitQ
import org.gcube.portlets.user.databasesmanager.client.resources.Images;
import org.gcube.portlets.user.databasesmanager.client.toolbar.GxtToolbarFunctionality;
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
import com.extjs.gxt.ui.client.Style;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode;
@ -44,6 +46,7 @@ import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
@ -55,6 +58,7 @@ import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.PagingToolBar;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.event.dom.client.KeyCodes;
@ -904,7 +908,14 @@ public class GxtBorderLayoutPanel extends ContentPanel {
+ "The query returned 0 values", null);
return;
}
String query = "";
if (dataQuery.getSmartCorrection()==false){
query = dataQuery.getQuery();
}else{
query = obj.getConvertedQuery();
}
// if ((listAttributes == null)
// || (listAttributes.size() == 0)) {
//
@ -954,7 +965,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// get path
String fileName = obj.getFileName();
parseSubmitQueryResult(form, dialogID,
listAttributes, fileName, UID);
listAttributes, query, fileName, UID);
}
@ -964,7 +975,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// 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, String fileName, final String UID) {
final List<String> listAttributes, String query, String fileName, final String UID) {
final Dialog form = dialog;
// define the proxy and create the grid to display in the dialog
@ -1120,7 +1131,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
};
submitResult.setLayout(new FitLayout());
// submitResult.setLayout(new FitLayout());
submitResult.setHeading("Result Query " + dialogID);
submitResult.setResizable(false);
submitResult.setSize(600, 400);
@ -1128,8 +1139,23 @@ public class GxtBorderLayoutPanel extends ContentPanel {
submitResult.setHideOnButtonClick(true);
submitResult.setMaximizable(true);
submitResult.setMinimizable(true);
submitResult.setBottomComponent(toolBar);
// submitResult.setBottomComponent(toolBar);
submitResult.setLayout(new RowLayout(Style.Orientation.VERTICAL));
//to add the panel of the converted query and the panel that display the query's result
ContentPanel q= new ContentPanel();
q.setLayout(new FitLayout());
q.setHeaderVisible(false);
q.addText(query);
submitResult.add(q, new RowData(1, 0.3));
ContentPanel g = new ContentPanel();
g.setLayout(new FitLayout());
g.setHeaderVisible(false);
g.setBottomComponent(toolBar);
g.add(grid);
g.layout(true);
// mimimize event handled
submitResult.addListener(Events.Minimize, new Listener<WindowEvent>() {
@Override
@ -1181,7 +1207,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
});
submitResult.addButton(download);
submitResult.add(grid);
// submitResult.add(grid);
submitResult.add(g,new RowData(1, 0.7));
submitResult.show();
}
@ -2014,12 +2041,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// column.setEditor(new CellEditor(textValue));
column.setEditor(new CellEditor(textValue) {
// public Object preProcessValue(Object value) {
// System.out.println("value 1: " +
// System.out.println("value preProcess: " +
// store.getModels().get(0).getValue());
// return store.getModels().get(0).getValue();
// }
public Object postProcessValue(Object value) {
// System.out.println("value: " +
// System.out.println("value postProcess: " +
// store.findModel(table).getValue());
return store.findModel(table).getValue();
}

View File

@ -760,6 +760,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// list that contains table attributes
List<String> listAttributes = null;
//converted query
String convertedQuery="";
String algorithmId = "SUBMITQUERY";
@ -844,6 +847,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("output size submit: " +
// output.size());
// logger.info("build the result - finished");
//get the converted query
if (smartCorrectionQuery==true){
convertedQuery=output.get(0).getValue();
output.remove(0);
}
// get the attributes list for the result table
listAttributes = new ArrayList<String>();
@ -881,82 +891,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// logger.info("dbmanager-> Application Path: " + applicationPath);
String partialPathFile = applicationPath + "/computationResult/"
+ fileName;
SubmitQueryResultWithFileFromServlet obj = new SubmitQueryResultWithFileFromServlet(
listAttributes, partialPathFile);
listAttributes, convertedQuery, 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
public SamplingResultWithFileFromServlet sample(