bug fixed in GWTdbManagerServiceImpl class for the cancel of a submit query operation.comments removed in the other classes.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@99269 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e5274527bf
commit
94c8594bf2
|
@ -1,7 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.portlets.user.databasesmanager.client;
|
|||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.FileModel;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package org.gcube.portlets.user.databasesmanager.client.toolbar;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.gcube.portlets.user.databasesmanager.client.GWTdbManagerServiceAsync;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryData;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.LoadTablesEvent;
|
||||
import org.gcube.portlets.user.databasesmanager.client.events.RandomSamplingEvent;
|
||||
|
@ -56,35 +53,35 @@ public class GxtToolbarFunctionality {
|
|||
private LinkedHashMap<Integer, Dialog> dialogList = new LinkedHashMap<Integer, Dialog>();
|
||||
private LinkedHashMap<Integer, SubmitQueryData> submitQueryDataList = new LinkedHashMap<Integer, SubmitQueryData>();
|
||||
private static int ID = 0; // ID associated to a dialog form
|
||||
//uid list related to submit query operations
|
||||
// uid list related to submit query operations
|
||||
private LinkedHashMap<Integer, String> uidSubmitQueryList = new LinkedHashMap<Integer, String>();
|
||||
// GWT logger
|
||||
private static Logger rootLogger = Logger
|
||||
.getLogger("GxtToolbarFunctionality");
|
||||
|
||||
// RPC service
|
||||
private GWTdbManagerServiceAsync RPCservice = null;
|
||||
private GWTdbManagerServiceAsync RPCservice = null;
|
||||
|
||||
// Constructor
|
||||
// public GxtToolbarFunctionality(HandlerManager eBus) {
|
||||
// eventBus = eBus;
|
||||
// toolBar = new ToolBar();
|
||||
// initToolBar();
|
||||
// addHandler();
|
||||
// addSelectionListenersOnToolBar();
|
||||
// }
|
||||
// public GxtToolbarFunctionality(HandlerManager eBus) {
|
||||
// eventBus = eBus;
|
||||
// toolBar = new ToolBar();
|
||||
// initToolBar();
|
||||
// addHandler();
|
||||
// addSelectionListenersOnToolBar();
|
||||
// }
|
||||
|
||||
// Constructor with GWTdbManagerServiceAsync service parameter
|
||||
public GxtToolbarFunctionality(HandlerManager eBus,
|
||||
GWTdbManagerServiceAsync service) {
|
||||
|
||||
eventBus = eBus;
|
||||
RPCservice = service;
|
||||
toolBar = new ToolBar();
|
||||
initToolBar();
|
||||
addHandler();
|
||||
addSelectionListenersOnToolBar();
|
||||
}
|
||||
public GxtToolbarFunctionality(HandlerManager eBus,
|
||||
GWTdbManagerServiceAsync service) {
|
||||
|
||||
eventBus = eBus;
|
||||
RPCservice = service;
|
||||
toolBar = new ToolBar();
|
||||
initToolBar();
|
||||
addHandler();
|
||||
addSelectionListenersOnToolBar();
|
||||
}
|
||||
|
||||
private void initToolBar() {
|
||||
|
||||
|
@ -215,8 +212,7 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
// form to submit a query
|
||||
final GxtFormSubmitQuery form = new GxtFormSubmitQuery();
|
||||
|
||||
|
||||
|
||||
dialog.add(form);
|
||||
dialog.show();
|
||||
|
||||
|
@ -250,7 +246,7 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
|
||||
// recover info from dialog
|
||||
setInfoOnSubmitQuery(form, dialog,
|
||||
dialogID);
|
||||
|
@ -269,8 +265,7 @@ public class GxtToolbarFunctionality {
|
|||
ButtonEvent ce) {
|
||||
rootLogger.log(Level.INFO,
|
||||
"button Cancel event");
|
||||
|
||||
|
||||
|
||||
// remove computation
|
||||
RPCservice.removeComputation(
|
||||
uidSubmitQueryList
|
||||
|
@ -472,26 +467,25 @@ public class GxtToolbarFunctionality {
|
|||
|
||||
SubmitQueryData data = form.getSubmitQueryData();
|
||||
// data = form.getSubmitQueryData();
|
||||
|
||||
|
||||
String query = data.getQuery();
|
||||
|
||||
|
||||
if ((query == null) || (query.equals(""))) {
|
||||
MessageBox.alert("Warning", "Query field null", null);
|
||||
} else {
|
||||
dialogList.put(new Integer(dialogID), SubmtQueryDialog);
|
||||
submitQueryDataList.put(new Integer(dialogID), data);
|
||||
|
||||
|
||||
//generate a UID for this request
|
||||
|
||||
// generate a UID for this request
|
||||
UIDGenerator generator = new UIDGenerator();
|
||||
String uidSubmitQuery = generator.get();
|
||||
//add uid for the submit query operation
|
||||
// add uid for the submit query operation
|
||||
uidSubmitQueryList.put(new Integer(dialogID), uidSubmitQuery);
|
||||
|
||||
// System.out.println("UID: " + uidSubmitQuery);
|
||||
|
||||
|
||||
// System.out.println("UID: " + uidSubmitQuery);
|
||||
|
||||
SubmtQueryDialog.getBody().mask("Loading", "x-mask-loading");
|
||||
|
||||
|
||||
// fire event
|
||||
eventBus.fireEvent(new SubmitQueryEvent(dialogID));
|
||||
}
|
||||
|
@ -513,7 +507,7 @@ public class GxtToolbarFunctionality {
|
|||
public LinkedHashMap<Integer, SubmitQueryData> getSubmitQueryDataList() {
|
||||
return submitQueryDataList;
|
||||
}
|
||||
|
||||
|
||||
public LinkedHashMap<Integer, String> getUIDSubmitQueryList() {
|
||||
return uidSubmitQueryList;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.HashMap;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
@ -105,6 +104,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HashMap<String, String> computationIDMap = new HashMap<String, String>();
|
||||
session.setAttribute("ComputationIDList", computationIDMap);
|
||||
|
||||
// Hashmap that contains the job status with a uid key
|
||||
HashMap<String, String> JobStatusMap = new HashMap<String, String>();
|
||||
session.setAttribute("JobStatusList", JobStatusMap);
|
||||
|
||||
}
|
||||
|
||||
// to get resources from IS
|
||||
|
@ -561,7 +564,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
mapValues = outputData.getMapValues();
|
||||
mapKeys = outputData.getmapKeys();
|
||||
|
||||
|
||||
if (mapValues.size() != 0) {
|
||||
output = new ArrayList<Result>();
|
||||
|
||||
|
@ -580,188 +583,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return output;
|
||||
}
|
||||
|
||||
// // to submit a query
|
||||
// public String startSubmitQueryComputation(
|
||||
// LinkedHashMap<String, String> dataDB, String query,
|
||||
// boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
|
||||
// String language) {
|
||||
//
|
||||
// logger.info("Dialect used for smart correction: " + language);
|
||||
//
|
||||
// // data input
|
||||
// List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// // data output
|
||||
// List<Result> output = new ArrayList<Result>();
|
||||
//
|
||||
// // get list of algorithms
|
||||
// List<String> algorithms = new ArrayList<String>();
|
||||
// algorithms = getDatabaseManagerAlgorithms();
|
||||
//
|
||||
// // get algorithmId
|
||||
// String algorithmId = null;
|
||||
//
|
||||
// for (int i = 0; i < algorithms.size(); i++) {
|
||||
// if (algorithms.get(i).equals("SUBMITQUERY")) {
|
||||
// algorithmId = algorithms.get(i);
|
||||
//
|
||||
// // print check
|
||||
// // logger.info("algorithmId: " + algorithmId);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // get input parameters of the algorithm
|
||||
// inputParameters = getParameters(algorithmId);
|
||||
//
|
||||
// if (inputParameters.size() != 0) {
|
||||
// // print check
|
||||
// logger.info("algorithm input parameters retrieved");
|
||||
// }
|
||||
//
|
||||
// // print check
|
||||
// // for (int i = 0; i < inputParameters.size(); i++) {
|
||||
// // logger.info(inputParameters.get(i).getName());
|
||||
// // }
|
||||
//
|
||||
// // print check
|
||||
// logger.info("ResourceName: " + dataDB.get("ResourceName"));
|
||||
// logger.info("DatabaseName: " + dataDB.get("DatabaseName"));
|
||||
// logger.info("Query: " + query);
|
||||
// logger.info("SmartCorrections check: " + smartCorrectionQuery);
|
||||
//
|
||||
// inputParameters.get(0).setValue(dataDB.get("ResourceName"));
|
||||
// inputParameters.get(1).setValue(dataDB.get("DatabaseName"));
|
||||
// inputParameters.get(2).setValue(String.valueOf(valueReadOnlyQuery));
|
||||
// inputParameters.get(3).setValue(String.valueOf(smartCorrectionQuery));
|
||||
// inputParameters.get(4).setValue(language);
|
||||
// inputParameters.get(5).setValue(query);
|
||||
//
|
||||
// // // create data structure
|
||||
// // ComputationOutput outputData = new ComputationOutput();
|
||||
//
|
||||
// // get computation id
|
||||
//
|
||||
// SMComputationConfig config = new SMComputationConfig();
|
||||
// SMInputEntry[] list = new SMInputEntry[inputParameters.size()];
|
||||
// int i = 0;
|
||||
//
|
||||
// for (Parameter p : inputParameters)
|
||||
// list[i++] = new SMInputEntry(p.getName(), p.getValue());
|
||||
// config.parameters(new SMEntries(list));
|
||||
// config.algorithm(algorithmId);
|
||||
//
|
||||
// // create a computation request
|
||||
// SMComputationRequest request = new SMComputationRequest();
|
||||
// request.user(getUsername());
|
||||
// request.config(config);
|
||||
//
|
||||
// // execute computation
|
||||
// StatisticalManagerFactory factory = getFactory();
|
||||
// String computationId = factory.executeComputation(request);
|
||||
//
|
||||
// return computationId;
|
||||
// }
|
||||
|
||||
// public float startCheckSubmitQueryComputation(String computationId) {
|
||||
//
|
||||
// String scope = getScope();
|
||||
// String user = getUsername();
|
||||
//
|
||||
// ScopeProvider.instance.set(scope);
|
||||
//
|
||||
// StatisticalManagerFactory factory = StatisticalManagerDSL
|
||||
// .createStateful().build();
|
||||
//
|
||||
// SMComputation computation = factory.getComputation(computationId);
|
||||
//
|
||||
// SMOperationStatus status = SMOperationStatus.values()[computation
|
||||
// .operationStatus()];
|
||||
//
|
||||
// float percentage = 0;
|
||||
//
|
||||
// if (status == SMOperationStatus.RUNNING) {
|
||||
//
|
||||
// // logger.info("RUNNING");
|
||||
// SMOperationInfo infos = factory.getComputationInfo(computationId,
|
||||
// user);
|
||||
// // percentage = Float.parseFloat(infos.percentage());
|
||||
// // logger.info("Percentage:" +
|
||||
// // percentage);
|
||||
// // computation = factory.getComputation(computationId);
|
||||
//
|
||||
// status = SMOperationStatus.values()[computation.operationStatus()];
|
||||
// } else if ((status == SMOperationStatus.COMPLETED)
|
||||
// || (status == SMOperationStatus.FAILED)) {
|
||||
//
|
||||
// // logger.info("COMPLETED OR FAILED");
|
||||
//
|
||||
// SMAbstractResource abstractResource = computation
|
||||
// .abstractResource();
|
||||
// SMResource smResource = abstractResource.resource();
|
||||
// int resourceTypeIndex = smResource.resourceType();
|
||||
// SMResourceType smResType = SMResourceType.values()[resourceTypeIndex];
|
||||
//
|
||||
// // displayOutput(smResource, smResType, outputData);
|
||||
//
|
||||
// // print check
|
||||
// // logger.info("SM resource Name: " + smResource.name());
|
||||
// // logger.info("SM resource Name: " + smResource.name());
|
||||
// // logger.info("SM resource ID: " + smResource.resourceId());
|
||||
// // logger.info("SM resource ID: " + smResource.resourceId());
|
||||
// // logger.info("SM resource Description: " +
|
||||
// // smResource.description());
|
||||
//
|
||||
// percentage = 100;
|
||||
// }
|
||||
// return percentage;
|
||||
//
|
||||
// }
|
||||
|
||||
// public List<Result> getSubmitQueryOutput(String computationId)
|
||||
// throws Exception {
|
||||
//
|
||||
// String scope = getScope();
|
||||
//
|
||||
// ScopeProvider.instance.set(scope);
|
||||
//
|
||||
// StatisticalManagerFactory factory = StatisticalManagerDSL
|
||||
// .createStateful().build();
|
||||
//
|
||||
// SMComputation computation = factory.getComputation(computationId);
|
||||
//
|
||||
// SMAbstractResource abstractResource = computation.abstractResource();
|
||||
// SMResource smResource = abstractResource.resource();
|
||||
// int resourceTypeIndex = smResource.resourceType();
|
||||
// SMResourceType smResType = SMResourceType.values()[resourceTypeIndex];
|
||||
//
|
||||
// // create data structure
|
||||
// ComputationOutput outputData = new ComputationOutput();
|
||||
//
|
||||
// displayOutput(smResource, smResType, outputData);
|
||||
//
|
||||
// // print check on retrieving data
|
||||
// logger.info("output data retrieved");
|
||||
//
|
||||
// // data output
|
||||
// List<Result> output = new ArrayList<Result>();
|
||||
//
|
||||
// // 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);
|
||||
// }
|
||||
//
|
||||
// return output;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<Result> sample(LinkedHashMap<String, String> dataInput)
|
||||
|
@ -1181,6 +1002,37 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return params;
|
||||
}
|
||||
|
||||
//update job with the related status
|
||||
private synchronized void updateJobStatus(String jobID, String status) {
|
||||
if (jobID != null) {
|
||||
// add the job status
|
||||
ASLSession session = WsUtil.getAslSession(this
|
||||
.getThreadLocalRequest().getSession());
|
||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||
.getAttribute("JobStatusList");
|
||||
JobStatusMap.put(jobID, status);
|
||||
session.setAttribute("JobStatusList", JobStatusMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//remove job with the related status
|
||||
private synchronized void removeJobStatus(String jobID) {
|
||||
ASLSession session = WsUtil.getAslSession(this.getThreadLocalRequest()
|
||||
.getSession());
|
||||
|
||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||
.getAttribute("JobStatusList");
|
||||
|
||||
String status = JobStatusMap.get(jobID);
|
||||
if (status != null) {
|
||||
|
||||
JobStatusMap.remove(jobID);
|
||||
session.setAttribute("JobStatusList", JobStatusMap);
|
||||
}
|
||||
}
|
||||
|
||||
//update job with the computation id
|
||||
private synchronized void updateJob(String jobID, String computationId) {
|
||||
if (jobID != null) {
|
||||
// add the computation in the map
|
||||
|
@ -1193,8 +1045,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
//remove job with the computation id
|
||||
private synchronized String removeJob(String jobID) {
|
||||
if (jobID != null) {
|
||||
// System.out.println("remove jobID " + job);
|
||||
// add the computation in the map
|
||||
ASLSession session = WsUtil.getAslSession(this
|
||||
.getThreadLocalRequest().getSession());
|
||||
|
@ -1242,6 +1096,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
String scope = getScope();
|
||||
String username = getUsername();
|
||||
|
||||
updateJobStatus(jobID, "computation started");
|
||||
updateJob(jobID, computationId);
|
||||
logger.info("startComputation->The computation has started!");
|
||||
while (percentage < 100) {
|
||||
|
@ -1250,6 +1105,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
Thread.sleep(3000);
|
||||
}
|
||||
logger.info("startComputation->The computation has finished!");
|
||||
updateJobStatus(jobID, "computation finished");
|
||||
removeJob(jobID);
|
||||
|
||||
return computationId;
|
||||
|
@ -1263,6 +1119,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
private float checkComputationStatus(String scope, String computationId,
|
||||
String user, ComputationOutput outputData) throws Exception {
|
||||
|
||||
// System.out.println("checkComputation " + computationId);
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
StatisticalManagerFactory factory = StatisticalManagerDSL
|
||||
|
@ -1428,14 +1285,34 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
private String getScope() {
|
||||
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
||||
return SessionUtil.getScope(httpSession);
|
||||
|
||||
}
|
||||
|
||||
//remove the computation
|
||||
public Boolean removeComputation(String uidSubmitQuery) throws Exception {
|
||||
|
||||
// System.out.println("server UID: " + uidSubmitQuery);
|
||||
|
||||
String computationId = removeJob(uidSubmitQuery);
|
||||
String computationId = null;
|
||||
|
||||
if ((uidSubmitQuery != null) && (!(uidSubmitQuery.equals("")))) {
|
||||
// get job status
|
||||
ASLSession session = WsUtil.getAslSession(this
|
||||
.getThreadLocalRequest().getSession());
|
||||
HashMap<String, String> JobStatusMap = (HashMap<String, String>) session
|
||||
.getAttribute("JobStatusList");
|
||||
String status = JobStatusMap.get(uidSubmitQuery);
|
||||
|
||||
if (status == null) {
|
||||
// the computation has not started
|
||||
while (computationId == null) {
|
||||
computationId = removeJob(uidSubmitQuery);
|
||||
}
|
||||
} else if (status.equals("computation started")) {
|
||||
// the computation has started
|
||||
computationId = removeJob(uidSubmitQuery);
|
||||
}
|
||||
}
|
||||
|
||||
if (computationId != null) {
|
||||
StatisticalManagerFactory factory = getFactory();
|
||||
try {
|
||||
|
@ -1450,6 +1327,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
// remove job status
|
||||
removeJobStatus(uidSubmitQuery);
|
||||
return (new Boolean(true));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue