Updated DMConverter

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167514 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-05-16 12:35:55 +00:00
parent 488d3ce0e5
commit 7d7c091bc2
3 changed files with 38 additions and 40 deletions

View File

@ -4,6 +4,8 @@
package org.gcube.common.workspacetaskexecutor.dataminer;
import org.gcube.common.workspacetaskexecutor.shared.TaskParameter;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ColumnListParameter;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ColumnParameter;
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.DateParameter;
@ -33,6 +35,37 @@ public class DMConverter {
/** The logger. */
private static Logger logger = LoggerFactory.getLogger(DMConverter.class);
/**
* To dm computation id.
*
* @param computationId the computation id
* @return the task computation
*/
public static TaskComputation toDMComputationId(ComputationId computationId){
if(computationId==null)
return null;
return new TaskComputation(computationId.getId(), computationId.getUrlId(), computationId.getOperatorId(), computationId.getOperatorName(), computationId.getEquivalentRequest());
}
/**
* To computation id.
*
* @param taskComputation the task computation
* @return the computation id
*/
public static ComputationId toComputationId(TaskComputation taskComputation){
if(taskComputation==null)
return null;
return new ComputationId(taskComputation.getId(), taskComputation.getUrlId(), taskComputation.getOperatorId(), taskComputation.getOperatorName(), taskComputation.getEquivalentRequest());
}
/**
* To dm parameter.

View File

@ -17,7 +17,6 @@ import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskConfiguration
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskExecutionStatus;
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskErrorException;
import org.gcube.common.workspacetaskexecutor.shared.exception.TaskNotExecutableException;
import org.gcube.common.workspacetaskexecutor.util.Converter;
import org.gcube.common.workspacetaskexecutor.util.EncrypterUtil;
import org.gcube.data.analysis.dataminermanagercl.server.DataMinerService;
import org.gcube.data.analysis.dataminermanagercl.server.dmservice.SClient;
@ -111,7 +110,7 @@ public class DataMinerAccessPoint {
SClient sClient;
try {
sClient = dataMinerService.getClient();
sClient.cancelComputation(Converter.toComputationId(task.getTaskComputation()));
sClient.cancelComputation(DMConverter.toComputationId(task.getTaskComputation()));
}
catch (Exception e) {
String error = "Error on get Client or the Operator for id: "+taskConfiguration.getTaskId();
@ -153,7 +152,7 @@ public class DataMinerAccessPoint {
logger.debug("Start Computation");
ComputationId computationId = sClient.startComputation(operator);
logger.debug("Started ComputationId: " + computationId);
return getTaskStatus(taskConfiguration, Converter.toDMComputationId(computationId));
return getTaskStatus(taskConfiguration, DMConverter.toDMComputationId(computationId));
}
catch (Exception e) {
@ -184,7 +183,7 @@ public class DataMinerAccessPoint {
SClient sClient;
ComputationId computationId = Converter.toComputationId(taskComputation);
ComputationId computationId = DMConverter.toComputationId(taskComputation);
try {
String token = EncrypterUtil.decryptString(taskConfiguration.getMaskedToken());
sClient = dataMinerService.getClient(token);

View File

@ -7,49 +7,15 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.common.workspacetaskexecutor.shared.dataminer.TaskComputation;
import org.gcube.data.analysis.dataminermanagercl.shared.data.computations.ComputationId;
/**
* The Class Converter.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* May 3, 2018
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* May 16, 2018
*/
public class Converter {
/**
* To dm computation id.
*
* @param computationId the computation id
* @return the DM computation id
*/
public static TaskComputation toDMComputationId(ComputationId computationId){
if(computationId==null)
return null;
return new TaskComputation(computationId.getId(), computationId.getUrlId(), computationId.getOperatorId(), computationId.getOperatorName(), computationId.getEquivalentRequest());
}
/**
* To computation id.
*
* @param computationId the computation id
* @return the computation id
*/
public static ComputationId toComputationId(TaskComputation computationId){
if(computationId==null)
return null;
return new ComputationId(computationId.getId(), computationId.getUrlId(), computationId.getOperatorId(), computationId.getOperatorName(), computationId.getEquivalentRequest());
}
/**
* Gets the enum list.
*