- bug fixed in class GWTdbManagerServiceImpl modified adding the class ComputationOutput to manage the mapValues and the mapKey related to an algorithm computation.

- bug fixed for multiple submit query dialogs and associated dialog results.ID added in the header of these two dialog types (passed in the SubmitQueryEvent). "Dialog.getBody" masked and unmasked.(in GxtBorderLyoutPanel and GxtToolbarFunctionality classes)

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@99021 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Loredana Liccardo 2014-07-25 18:03:14 +00:00
parent 3913c2d6cf
commit e219cfcb11
5 changed files with 396 additions and 225 deletions

View File

@ -0,0 +1,34 @@
package org.gcube.portlets.user.databasesmanager.client.datamodel;
import java.util.LinkedHashMap;
public class ComputationOutput {
private LinkedHashMap<String, String> mapValues;
private LinkedHashMap<String, String> mapKeys;
public ComputationOutput() {
mapKeys = new LinkedHashMap<String, String>();
mapValues = new LinkedHashMap<String, String>();
}
public void setMapValues(LinkedHashMap<String, String> mapValues) {
this.mapValues = mapValues;
}
public void setmapKeys(LinkedHashMap<String, String> mapKeys) {
this.mapKeys = mapKeys;
}
public LinkedHashMap<String, String> getMapValues() {
return mapValues;
}
public LinkedHashMap<String, String> getmapKeys() {
return mapKeys;
}
}

View File

@ -6,6 +6,11 @@ import com.google.gwt.event.shared.GwtEvent;
public class SubmitQueryEvent extends GwtEvent<SubmitQueryEventHandler> {
public static Type<SubmitQueryEventHandler> TYPE = new Type<SubmitQueryEventHandler>();
private int dialogID;
public SubmitQueryEvent(int ID){
dialogID=ID;
}
@Override
public Type<SubmitQueryEventHandler> getAssociatedType() {
@ -26,5 +31,9 @@ public class SubmitQueryEvent extends GwtEvent<SubmitQueryEventHandler> {
// TODO Auto-generated method stub
return EventsTypeEnum.SUBMIT_QUERY_EVENT;
}
public int getDialogID(){
return dialogID;
}
}

View File

@ -344,9 +344,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
public void onSubmitQuery(SubmitQueryEvent submitQueryEvent) {
// TODO Auto-generated method stub
Integer dialogID = toolbar.getDialogID();
// Integer dialogID = toolbar.getDialogID();
Integer dialogID = new Integer(submitQueryEvent.getDialogID());
rootLogger.log(Level.INFO, "dialogID: "
+ dialogID);
submitQuery(dialogID);
@ -1047,7 +1050,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
}
// method to submit a query
private void submitQuery(Integer dialogID) {
private void submitQuery(final Integer dialogID) {
// clear variable that keeps track of the managed event
// boolean submitQueryEventManaged = false;
@ -1084,11 +1087,10 @@ public class GxtBorderLayoutPanel extends ContentPanel {
final SubmitQueryData dataQuery = submitQueryDataList.get(dialogID);
// rootLogger.log(Level.INFO, "query: "+ dataQuery.getQuery() + "submitquery->dialogID: "
// + dialogID);
// determine the language
String dialect;
@ -1183,8 +1185,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// Dialog form = toolbar.getDialogForm();
if (form.isMasked())
form.unmask();
if (form.getBody().isMasked())
form.getBody().unmask();
}
};
@ -1235,7 +1237,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// parse the result in order to obtain a table
boolean submitQueryEventManaged = true;
parseResult(result, form, submitQueryEventManaged);
parseResult(result, form, dialogID, submitQueryEventManaged);
}
@ -1357,7 +1359,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// parse the result in order to obtain a
// table
parseResult(result, null, false);
parseResult(result, null, 0, false);
}
@ -1489,7 +1491,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// parse the result in order to obtain a
// table
parseResult(result, null, false);
parseResult(result, null, 0, false);
}
@ -1620,7 +1622,7 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// parse the result in order to obtain a
// table
parseResult(result, null, false);
parseResult(result, null, 0, false);
}
@ -1638,7 +1640,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, Dialog dialog, final boolean submitQueryEventManaged) {
private void parseResult(List<Result> result, Dialog dialog, final int dialogID, final boolean submitQueryEventManaged) {
// to unmask the entire content panel
final GxtBorderLayoutPanel obj = this;
@ -1675,8 +1677,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// Dialog form = toolbar.getDialogForm();
//
if (form.isMasked())
form.unmask();
if (form.getBody().isMasked())
form.getBody().unmask();
// form.hide();
@ -1703,7 +1705,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// Display the submit query result as a table
Dialog submitResult = new Dialog();
submitResult.setLayout(new FitLayout());
submitResult.setHeading("Result");
if (submitQueryEventManaged==true){
submitResult.setHeading("Result Query " + dialogID);
}
else{
submitResult.setHeading("Result");
}
submitResult.setResizable(false);
// submitResult.setHeading("Submit Query");
// submitResult.setWidth(290);
@ -1746,8 +1754,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// Dialog form = toolbar.getDialogForm();
//
if (form.isMasked())
form.unmask();
if (form.getBody().isMasked())
form.getBody().unmask();
//
// form.hide();
@ -1763,8 +1771,8 @@ public class GxtBorderLayoutPanel extends ContentPanel {
// submitQueryEventManaged = false;
// Dialog form = toolbar.getDialogForm();
if (form.isMasked())
form.unmask();
if (form.getBody().isMasked())
form.getBody().unmask();
//
// form.hide();
} else {

View File

@ -199,6 +199,8 @@ public class GxtToolbarFunctionality {
}
};
ID++;
final int dialogID = ID;
dialog.setLayout(new FitLayout());
// dialog.setModal(true);
// dialog.setBlinkModal(true);
@ -208,7 +210,7 @@ public class GxtToolbarFunctionality {
dialog.setResizable(false);
dialog.setMaximizable(true);
dialog.setMinimizable(true);
dialog.setHeading("Submit Query");
dialog.setHeading("Submit Query " + dialogID);
dialog.setSize(600, 500);
// dialog.setConstrain(false);
@ -220,6 +222,8 @@ public class GxtToolbarFunctionality {
final GxtFormSubmitQuery form = new GxtFormSubmitQuery();
dialog.add(form);
dialog.show();
//mimimize event handled
dialog.addListener(Events.Minimize,
@ -258,7 +262,7 @@ public class GxtToolbarFunctionality {
public void componentSelected(ButtonEvent ce) {
// recover info from dialog
setInfoOnSubmitQuery(form, dialog);
setInfoOnSubmitQuery(form, dialog, dialogID);
rootLogger.log(Level.SEVERE,
"query submitted");
@ -492,7 +496,7 @@ public class GxtToolbarFunctionality {
}
private void setInfoOnSubmitQuery(GxtFormSubmitQuery form,
Dialog SubmtQueryDialog) {
Dialog SubmtQueryDialog, int dialogID) {
SubmitQueryData data = form.getSubmitQueryData();
@ -505,13 +509,13 @@ public class GxtToolbarFunctionality {
} else {
dialogList.put(new Integer(ID), SubmtQueryDialog);
submitQueryDataList.put(new Integer(ID), data);
dialogList.put(new Integer(dialogID), SubmtQueryDialog);
submitQueryDataList.put(new Integer(dialogID), data);
SubmtQueryDialog.mask("Loading", "x-mask-loading");
SubmtQueryDialog.getBody().mask("Loading", "x-mask-loading");
// fire event
eventBus.fireEvent(new SubmitQueryEvent());
eventBus.fireEvent(new SubmitQueryEvent(dialogID));
}
}

View File

@ -40,6 +40,7 @@ import org.gcube.data.analysis.statisticalmanager.stubs.types.schema.SMTable;
import org.gcube.data.analysis.statisticalmanager.stubs.types.schema.StatisticalServiceType;
import org.gcube.dataanalysis.ecoengine.datatypes.enumtypes.PrimitiveTypes;
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerService;
import org.gcube.portlets.user.databasesmanager.client.datamodel.ComputationOutput;
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Parameter;
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
@ -56,8 +57,8 @@ import org.apache.log4j.Logger;
public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
GWTdbManagerService {
private LinkedHashMap<String, String> outputMap;
private LinkedHashMap<String, String> outputKey;
// private LinkedHashMap<String, String> outputMap;
// private LinkedHashMap<String, String> outputKey;
// the result generated in the LoadTables method
private List<Result> result = null;
@ -69,12 +70,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
private String previousSchema = "";
// GWT logger
// private static Logger rootLogger = Logger
// .getLogger("GWTdbManagerServiceImpl");
//logger
private static Logger logger = Logger.getLogger(GWTdbManagerServiceImpl.class);
// private static Logger rootLogger = Logger
// .getLogger("GWTdbManagerServiceImpl");
// logger
private static Logger logger = Logger
.getLogger(GWTdbManagerServiceImpl.class);
public GWTdbManagerServiceImpl() {
@ -111,7 +112,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// print check
// System.out.println("getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
// print check
@ -122,17 +123,25 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
//
// }
String computationId = startComputation(algorithmId, inputParameters);
// create data structure
ComputationOutput outputData = new ComputationOutput();
//print check
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// print check
// retrieve data
// System.out.println("output data retrieved");
// rootLogger.log(Level.SEVERE, "output data retrieved");
// logger.info("output data retrieved");
// rootLogger.log(Level.SEVERE, "output data retrieved");
// logger.info("output data retrieved");
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
mapValues = outputData.getMapValues();
for (int i = 0; i < mapValues.size(); i++) {
FileModel obj = new FileModel(mapValues.get(String.valueOf(i)));
// obj.setIsLoaded(true);
outputParameters.add(obj);
}
@ -163,44 +172,54 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// print check
// System.out.println("algorithmId: " + algorithmId);
// rootLogger.log(Level.SEVERE, "algorithmId: " + algorithmId);
// rootLogger.log(Level.SEVERE, "algorithmId: " + algorithmId);
}
}
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
// print check
for (int i = 0; i < inputParameters.size(); i++) {
// System.out.println(inputParameters.get(i).getName());
inputParameters.get(i).setValue(resourceName);
// rootLogger.log(Level.INFO, "ResourceName: " + resourceName);
//print check
// rootLogger.log(Level.INFO, inputParameters.get(i).getName());
}
for (int i = 0; i < inputParameters.size(); i++) {
String computationId = startComputation(algorithmId, inputParameters);
// System.out.println(inputParameters.get(i).getName());
inputParameters.get(i).setValue(resourceName);
////print check
// rootLogger.log(Level.INFO, "ResourceName: " + resourceName);
// print check
// rootLogger.log(Level.INFO, inputParameters.get(i).getName());
}
// create data structure
ComputationOutput outputData = new ComputationOutput();
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// //print check
// retrieve data
// System.out.println("output data retrieved");
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data retrieved");
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
mapValues = outputData.getMapValues();
mapKeys = outputData.getmapKeys();
for (int i = 0; i < mapValues.size(); i++) {
FileModel obj = new FileModel(mapValues.get(String.valueOf(i)));
// obj.setIsLoaded(true);
// System.out.println("value: " + outputMap.get(String.valueOf(i)));
// System.out.println("key: " + outputKey.get(String.valueOf(i)));
// System.out.println("value: " + mapValues.get(String.valueOf(i)));
// System.out.println("key: " + mapKeys.get(String.valueOf(i)));
outputParameters.put(outputKey.get(String.valueOf(i)), obj);
outputParameters.put(mapKeys.get(String.valueOf(i)), obj);
}
return outputParameters;
}
@ -232,7 +251,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
@ -248,27 +267,36 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
// print check
// rootLogger.log(Level.INFO,
// "ResourceName: " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "ResourceName: " + dataInput.get("ResourceName"));
logger.info("ResourceName: " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName: " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO,
// "DatabaseName: " + dataInput.get("DatabaseName"));
logger.info("DatabaseName: " + dataInput.get("DatabaseName"));
String computationId = startComputation(algorithmId, inputParameters);
// create data structure
ComputationOutput outputData = new ComputationOutput();
//print check
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// print check
// retrieve data
// System.out.println("output data retrieved");
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data retrieved");
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
mapValues = outputData.getMapValues();
mapKeys = outputData.getmapKeys();
for (int i = 0; i < mapValues.size(); i++) {
FileModel obj = new FileModel(mapValues.get(String.valueOf(i)));
// obj.setIsSchema(true);
// obj.setIsLoaded(true);
@ -303,7 +331,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
@ -319,27 +347,38 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
inputParameters.get(2).setValue(dataInput.get("SchemaName"));
// rootLogger.log(Level.SEVERE,
// "ResourceName: " + dataInput.get("ResourceName"));
// rootLogger.log(Level.SEVERE,
// "DatabaseName: " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.SEVERE,
// "SchemaName: " + dataInput.get("SchemaName"));
// rootLogger.log(Level.SEVERE,
// "ResourceName: " + dataInput.get("ResourceName"));
// rootLogger.log(Level.SEVERE,
// "DatabaseName: " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.SEVERE,
// "SchemaName: " + dataInput.get("SchemaName"));
logger.info("ResourceName: " + dataInput.get("ResourceName"));
logger.info("DatabaseName: " + dataInput.get("DatabaseName"));
logger.info("SchemaName: " + dataInput.get("SchemaName"));
String computationId = startComputation(algorithmId, inputParameters);
// create data structure
ComputationOutput outputData = new ComputationOutput();
//print check
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// print check
// retrieve data
// System.out.println("output data retrieved");
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " +
// outputMap.size());
// System.out.println("size outputMap: " + outputMap.size());
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
mapValues = outputData.getMapValues();
mapKeys = outputData.getmapKeys();
for (int i = 0; i < mapValues.size(); i++) {
// outputParameters.add(outputKey.get(String.valueOf(i)) + " "
// + outputMap.get(String.valueOf(i)));
@ -347,7 +386,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// obj.setIsLoaded(true);
// obj.setIsTable(true);
Result row = new Result(String.valueOf(i), outputMap.get(String
Result row = new Result(String.valueOf(i), mapValues.get(String
.valueOf(i)));
outputParameters.add(row);
@ -387,8 +426,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
List<Result> sublist = new ArrayList<Result>();
BasePagingLoadResult loadResult = null;
// rootLogger.log(Level.INFO, "Searching in the table: " + SearchTable);
// rootLogger.log(Level.INFO, "Keyword to search: " + keyword);
// rootLogger.log(Level.INFO, "Searching in the table: " + SearchTable);
// rootLogger.log(Level.INFO, "Keyword to search: " + keyword);
int start = config.getOffset();
int limit = result.size();
@ -444,9 +483,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
boolean smartCorrectionQuery, String language) throws Exception {
// System.out.println("language detected: " + language);
// rootLogger.log(Level.SEVERE, "Dialect used for smart correction:: "
// + language);
// rootLogger.log(Level.SEVERE, "Dialect used for smart correction:: "
// + language);
logger.info("Dialect used for smart correction: " + language);
List<Parameter> inputParameters = new ArrayList<Parameter>();
@ -471,9 +510,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
// print check
@ -487,17 +526,18 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
inputParameters.get(1).setValue(dataDB.get("DatabaseName"));
// print check
// rootLogger
// .log(Level.INFO, "ResourceName " + dataDB.get("ResourceName"));
// rootLogger.log(Level.INFO, "DatabaseName" + dataDB.get("DatabaseName"));
// rootLogger.log(Level.INFO, "Query" + query);
// rootLogger.log(Level.INFO, "SmartCorrections check:" + smartCorrectionQuery);
// rootLogger
// .log(Level.INFO, "ResourceName " + dataDB.get("ResourceName"));
// rootLogger.log(Level.INFO, "DatabaseName" +
// dataDB.get("DatabaseName"));
// rootLogger.log(Level.INFO, "Query" + query);
// rootLogger.log(Level.INFO, "SmartCorrections check:" +
// smartCorrectionQuery);
logger.info("ResourceName: " + dataDB.get("ResourceName"));
logger.info("DatabaseName: " + dataDB.get("DatabaseName"));
logger.info("Query: " + query);
logger.info("SmartCorrections check: " + smartCorrectionQuery);
inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery));
@ -507,20 +547,32 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("size outputMap pre computation: "
// + outputMap.size());
String computationId = startComputation(algorithmId, inputParameters);
//print check
// create data structure
ComputationOutput outputData = new ComputationOutput();
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// print check
// retrieve data
// System.out.println("output data retrieved");
// System.out.println("size outputMap: " + outputMap.size());
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " +
// outputMap.size());
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
Result row = new Result(outputKey.get(String.valueOf(i)),
outputMap.get(String.valueOf(i)));
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);
@ -571,7 +623,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
@ -586,21 +638,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// }
// print check
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " + dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " + dataInput.get("TableName"));
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " +
// dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " +
// dataInput.get("TableName"));
logger.info("ResourceName: " + dataInput.get("ResourceName"));
logger.info("DatabaseName: " + dataInput.get("DatabaseName"));
logger.info("SchemaName: " + dataInput.get("SchemaName"));
logger.info("TableName: " + dataInput.get("TableName"));
inputParameters.get(0).setValue(dataInput.get("ResourceName"));
inputParameters.get(1).setValue(dataInput.get("DatabaseName"));
inputParameters.get(2).setValue(dataInput.get("SchemaName"));
@ -609,20 +660,31 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("size outputMap pre computation: "
// + outputMap.size());
String computationId = startComputation(algorithmId, inputParameters);
// create data structure
ComputationOutput outputData = new ComputationOutput();
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// retrieve data
// System.out.println("output data retrieved");
// System.out.println("size outputMap: " + outputMap.size());
// print check
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " +
// outputMap.size());
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
Result row = new Result(outputKey.get(String.valueOf(i)),
outputMap.get(String.valueOf(i)));
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);
@ -667,8 +729,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
@ -683,13 +745,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// }
// print check
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " + dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " + dataInput.get("TableName"));
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " +
// dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " +
// dataInput.get("TableName"));
logger.info("ResourceName: " + dataInput.get("ResourceName"));
logger.info("DatabaseName: " + dataInput.get("DatabaseName"));
logger.info("SchemaName: " + dataInput.get("SchemaName"));
@ -703,20 +767,30 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("size outputMap pre computation: "
// + outputMap.size());
String computationId = startComputation(algorithmId, inputParameters);
// create data structure
ComputationOutput outputData = new ComputationOutput();
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// retrieve data
// System.out.println("output data retrieved");
// System.out.println("size outputMap: " + outputMap.size());
// print check
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " +
// outputMap.size());
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
Result row = new Result(outputKey.get(String.valueOf(i)),
outputMap.get(String.valueOf(i)));
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);
@ -762,7 +836,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
@ -777,13 +851,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// }
// print check
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " + dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " + dataInput.get("TableName"));
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " +
// dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " +
// dataInput.get("TableName"));
logger.info("ResourceName: " + dataInput.get("ResourceName"));
logger.info("DatabaseName: " + dataInput.get("DatabaseName"));
logger.info("SchemaName: " + dataInput.get("SchemaName"));
@ -797,20 +873,31 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("size outputMap pre computation: "
// + outputMap.size());
String computationId = startComputation(algorithmId, inputParameters);
// create data structure
ComputationOutput outputData = new ComputationOutput();
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// retrieve data
// System.out.println("output data retrieved");
// System.out.println("size outputMap: " + outputMap.size());
// print check
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " +
// outputMap.size());
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
Result row = new Result(outputKey.get(String.valueOf(i)),
outputMap.get(String.valueOf(i)));
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);
@ -855,8 +942,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// get input parameters of the algorithm
// rootLogger.log(Level.SEVERE, "getting input parameters");
// rootLogger.log(Level.SEVERE, "getting input parameters");
logger.info("getting input parameters");
inputParameters = getParameters(algorithmId);
@ -871,14 +958,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// }
// print check
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " + dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " + dataInput.get("TableName"));
// rootLogger.log(Level.INFO,
// "ResourceName " + dataInput.get("ResourceName"));
// rootLogger.log(Level.INFO,
// "DatabaseName " + dataInput.get("DatabaseName"));
// rootLogger.log(Level.INFO, "SchemaName " +
// dataInput.get("SchemaName"));
// rootLogger.log(Level.INFO, "TableName " +
// dataInput.get("TableName"));
logger.info("ResourceName: " + dataInput.get("ResourceName"));
logger.info("DatabaseName: " + dataInput.get("DatabaseName"));
logger.info("SchemaName: " + dataInput.get("SchemaName"));
@ -892,22 +980,33 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("size outputMap pre computation: "
// + outputMap.size());
String computationId = startComputation(algorithmId, inputParameters);
// create data structure
ComputationOutput outputData = new ComputationOutput();
String computationId = startComputation(algorithmId, inputParameters,
outputData);
// retrieve data
// System.out.println("output data retrieved");
// System.out.println("size outputMap: " + outputMap.size());
//print check
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " + outputMap.size());
// print check
// rootLogger.log(Level.SEVERE, "output data retrieved");
// rootLogger.log(Level.SEVERE, "output data size: " +
// outputMap.size());
for (int i = 0; i < outputMap.size(); i++) {
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
mapValues = outputData.getMapValues();
mapKeys = outputData.getmapKeys();
for (int i = 0; i < mapValues.size(); i++) {
// outputParameters.add(outputKey.get(String.valueOf(i)) + " "
// + outputMap.get(String.valueOf(i)));
FileModel obj = new FileModel(outputMap.get(String.valueOf(i)));
FileModel obj = new FileModel(mapValues.get(String.valueOf(i)));
// obj.setIsLoaded(true);
@ -917,7 +1016,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// System.out.println("key: " + outputKey.get(String.valueOf(i)));
outputParameters.put(outputKey.get(String.valueOf(i)), obj);
outputParameters.put(mapKeys.get(String.valueOf(i)), obj);
}
@ -925,7 +1024,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
//parse a csv row
// parse a csv row
public List<Row> parseCVSString(List<Result> result, List<String> attrNames)
throws Exception {
@ -940,7 +1039,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
Row element = new Row(attrNames, attrValues, i);
rows.add(element);
}
}
@ -1043,11 +1142,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (groups == null)
// System.out.println("GROUPS OF ALGORITHMS IS NULL!");
// rootLogger.log(Level.SEVERE, "GROUPS OF ALGORITHMS IS NULL!");
// rootLogger.log(Level.SEVERE, "GROUPS OF ALGORITHMS IS NULL!");
logger.info("GROUPS OF ALGORITHMS IS NULL!");
else
// System.out.println("GROUPS OF ALGORITHMS IS NOT NULL!");
// rootLogger.log(Level.SEVERE, "GROUPS OF ALGORITHMS IS NOT NULL!");
// rootLogger.log(Level.SEVERE,
// "GROUPS OF ALGORITHMS IS NOT NULL!");
logger.info("GROUPS OF ALGORITHMS IS NOT NULL!");
// get list categories
@ -1115,7 +1215,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
private String startComputation(String algorithmName,
List<Parameter> parameters) throws Exception{
List<Parameter> parameters, ComputationOutput outputData)
throws Exception {
SMComputationConfig config = new SMComputationConfig();
@ -1143,7 +1244,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
while (percentage < 100) {
percentage = checkComputationStatus(scope, computationId,
username);
username, outputData);
Thread.sleep(1000);
}
@ -1157,7 +1258,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
}
private float checkComputationStatus(String scope, String computationId,
String user) throws Exception {
String user, ComputationOutput outputData) throws Exception {
ScopeProvider.instance.set(scope);
@ -1174,10 +1275,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
float percentage = 0;
if (status == SMOperationStatus.RUNNING) {
// System.out.println("GWTdbManagerServiceImpl->RUNNING");
// rootLogger.log(Level.SEVERE, "RUNNING");
// logger.info("RUNNING");
SMOperationInfo infos = factory.getComputationInfo(computationId,
user);
@ -1189,9 +1288,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
status = SMOperationStatus.values()[computation.operationStatus()];
} else if ((status == SMOperationStatus.COMPLETED)
|| (status == SMOperationStatus.FAILED)) {
// System.out.println("GWTdbManagerServiceImpl->COMPLETED OR FAILED");
// rootLogger.log(Level.SEVERE, "COMPLETED OR FAILED");
// logger.info("COMPLETED OR FAILED");
SMAbstractResource abstractResource = computation
.abstractResource();
@ -1205,13 +1303,13 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
//
// }
// throws(smResource.description());
displayOutput(smResource, smResType);
displayOutput(smResource, smResType, outputData);
// System.out.println("GWTdbManagerServiceImpl-> SM resource Name: "
// + smResource.name());
// rootLogger.log(Level.SEVERE,
// "SM resource Name: " + smResource.name());
// rootLogger.log(Level.SEVERE,
// "SM resource Name: " + smResource.name());
// System.out.println("GWTdbManagerServiceImpl-> SM resource ID: "
// + smResource.resourceId());
@ -1235,15 +1333,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
return percentage;
}
private void displayOutput(SMResource smResource, SMResourceType smResType)
throws Exception {
private void displayOutput(SMResource smResource, SMResourceType smResType,
ComputationOutput outputData) throws Exception {
// System.out.println("displayOutput");
// print check
// rootLogger.log(Level.SEVERE, "displayOutput");
outputMap = new LinkedHashMap<String, String>();
// LinkedHashMap<String, String> mapValues = new LinkedHashMap<String,
// String>();
// mapValues = outputData.getMapValues();
// outputMap = new LinkedHashMap<String, String>();
if (smResType.equals(SMResourceType.OBJECT)) {
@ -1255,29 +1358,36 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// case OBJECT:
SMObject objRes = (SMObject) smResource;
if (objRes.name().contentEquals(PrimitiveTypes.MAP.toString())) {
// System.out.println("Output is a map");
// rootLogger.log(Level.SEVERE, "Output is a map");
// Map<String, String> outputMap = getMap(objRes);
this.outputMap = (LinkedHashMap<String, String>) getMap(objRes);
// this.outputMap = (LinkedHashMap<String, String>)
// getMap(objRes);
// mapValues = (LinkedHashMap<String, String>) getMap(objRes,
// outputData);
logger.info("Output is a map");
getMap(objRes, outputData);
} else if (objRes.name().contentEquals(
PrimitiveTypes.IMAGES.toString())) {
// System.out.println("Output are images");
// rootLogger.log(Level.SEVERE, "Output are images");
}
// else
// System.out.println("Output is other");
// rootLogger.log(Level.SEVERE, "Output is other");
// rootLogger.log(Level.SEVERE, "Output are images");
}
// else
// System.out.println("Output is other");
// rootLogger.log(Level.SEVERE, "Output is other");
}
// EXCEPTION MANAGEMENT
if (smResType.equals(SMResourceType.ERROR)) {
Exception e= new Exception(smResource.description());
Exception e = new Exception(smResource.description());
// e.printStackTrace();
logger.error(e);
throw e;
// throw new Exception(smResource.description());
// throw new Exception(smResource.description());
}
// break;
@ -1288,13 +1398,22 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
// }
}
private Map<String, String> getMap(SMObject objRes) throws Exception {
// private Map<String, String> getMap(SMObject objRes, ComputationOutput
// outputData) throws Exception {
private void getMap(SMObject objRes, ComputationOutput outputData)
throws Exception {
// System.out.println("getMap");
// rootLogger.log(Level.SEVERE, "getMap");
// rootLogger.log(Level.SEVERE, "getMap");
outputKey = new LinkedHashMap<String, String>();
// output data
LinkedHashMap<String, String> mapValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> mapKeys = new LinkedHashMap<String, String>();
// outputKey = new LinkedHashMap<String, String>();
InputStream is = getStorageClientInputStream(objRes.url());
// object serializer
@ -1317,13 +1436,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
.fromXML(is));
is.close();
LinkedHashMap<String, String> outputmap = new LinkedHashMap<String, String>();
// LinkedHashMap<String, String> outputmap = new LinkedHashMap<String,
// String>();
int i = 0;
for (String key : smMap.keySet()) {
// add key value
outputKey.put(String.valueOf(i), key);
mapKeys.put(String.valueOf(i), key);
SMResource smres = smMap.get(key);
int resourceTypeIndex = smres.resourceType();
@ -1337,31 +1457,27 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
if (smsubResType == SMResourceType.OBJECT) {
SMObject obje = (SMObject) smres;
String outstring = obje.url();
// System.out.println("key :" + key);
// rootLogger.log(Level.INFO, "key: " + smsubResType);
// System.out.println("Object:"
// + new String(outstring.getBytes(), "UTF-8"));
// rootLogger.log(Level.INFO,
// "Object: " + new String(outstring.getBytes(), "UTF-8"));
// logger.info("key: " + smsubResType);
// logger.info("object: " + outstring);
// outputmap.put(key, outstring);
outputmap.put(String.valueOf(i), outstring);
mapValues.put(String.valueOf(i), outstring);
i++;
}
}
outputData.setMapValues(mapValues);
outputData.setmapKeys(mapKeys);
// System.out.println("Map retrieved with size: " + smMap.size());
// rootLogger
// .log(Level.SEVERE, "Map retrieved with size: " + smMap.size());
return outputmap;
// rootLogger
// .log(Level.SEVERE, "Map retrieved with size: " + smMap.size());
// return outputmap;
}
private InputStream getStorageClientInputStream(String url)