Updated retrieveOutput

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/workspace-task-executor-library@167911 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-06-07 09:42:20 +00:00
parent 321ecc49d1
commit 0ca4b15c3d
4 changed files with 36 additions and 38 deletions

View File

@ -260,46 +260,39 @@ public class DMConverter {
/**
* Append output.
* Gets the output message.
*
* @param builder the builder
* @param key the key
* @param res the res
* @return the output message
*/
public static void appendOutput(StringBuilder builder, String key, Resource res){
public static String getOutputMessage(String key, Resource res){
switch (res.getResourceType()) {
case FILE:
FileResource fileResource = (FileResource) res;
String fileName=retrieveFileName(fileResource.getUrl());
logger.debug("Entry: " + key + " = "+ fileResource+", FileName="+fileName);
builder.append("Entry: " + key + " = "+fileResource+", FileName="+fileName);
break;
return "Entry: " + key + " = "+fileResource+", FileName="+fileName;
case IMAGE:
ImageResource imageResource = (ImageResource) res;
String imageName=retrieveFileName(imageResource.getLink());
logger.debug("Entry: " + key + " = "+ imageResource+", ImageName="+imageName);
builder.append("Entry: " + key + " = "+ imageResource+", ImageName="+imageName);
break;
return "Entry: " + key + " = "+ imageResource+", ImageName="+imageName;
case MAP:
logger.debug("Entry: " + key + " = "+ res);
builder.append("Entry: " + key + " = "+ res);
break;
return "Entry: " + key + " = "+ res;
case OBJECT:
logger.debug("Entry: " + key + " = "+ res);
builder.append("Entry: " + key + " = "+ res);
break;
return "Entry: " + key + " = "+ res;
case TABULAR:
TableResource tableResource = (TableResource) res;
String tableName=retrieveFileName(tableResource.getResourceId());
logger.debug("Entry: " + key + " = "+ tableResource+", TableName="+tableName);
builder.append("Entry: " + key + " = "+tableResource+", TableName="+tableName);
break;
return "Entry: " + key + " = "+ tableResource+", TableName="+tableName;
default:
logger.debug("Entry: " + key + " = "+ res);
builder.append("Entry: " + key + " = "+ res);
break;
return "Entry: " + key + " = "+ res;
}
}

View File

@ -323,7 +323,7 @@ public class DataMinerAccessPoint {
throw new TaskErrorException("Error on getting DataMiner client, Try later");
}
String outputMessage = retrieveOutput(computationId, sClient);
List<String> outputMessages = retrieveOutput(computationId, sClient);
//REMOVING THE TASK FROM MEMORY
switch (tes.getStatus()) {
@ -337,21 +337,21 @@ public class DataMinerAccessPoint {
break;
}
return new TaskOutput(tes, outputMessage);
return new TaskOutput(tes, outputMessages);
}
/**
* Retrieve output.
* provided by Giancarlo
*
* @param computationId the computation id
* @param sClient the s client
* @return the string
* @return the list
* @throws TaskErrorException the task error exception
*/
private String retrieveOutput(ComputationId computationId, SClient sClient) throws TaskErrorException {
private List<String> retrieveOutput(ComputationId computationId, SClient sClient) throws TaskErrorException {
try {
StringBuilder builder = new StringBuilder();
List<String> outputMessages = new ArrayList<String>();
OutputData output = sClient.getOutputDataByComputationId(computationId);
logger.debug("Output: " + output);
Resource resource = output.getResource();
@ -360,13 +360,13 @@ public class DataMinerAccessPoint {
MapResource mapResource = (MapResource) resource;
for (String key : mapResource.getMap().keySet()) {
Resource res = mapResource.getMap().get(key);
DMConverter.appendOutput(builder, key, res);
outputMessages.add(DMConverter.getOutputMessage(key, res));
}
}else{
DMConverter.appendOutput(builder, "", resource);
outputMessages.add(DMConverter.getOutputMessage("", resource));
}
return builder.toString();
return outputMessages;
} catch (Exception e) {
logger.error("Error on retrieve the output for computationId: "+computationId, e);
throw new TaskErrorException("Error on retrieve the output for computationId: "+computationId);

View File

@ -3,6 +3,8 @@
*/
package org.gcube.common.workspacetaskexecutor.shared;
import java.util.List;
/**
* The Interface BaseTaskOutput.
@ -26,7 +28,7 @@ public interface BaseTaskOutput {
*
* @return the outputMessage
*/
public String getOutputMessage();
public List<String> getOutputMessages();
}

View File

@ -4,6 +4,7 @@
package org.gcube.common.workspacetaskexecutor.shared;
import java.io.Serializable;
import java.util.List;
@ -20,7 +21,7 @@ public class TaskOutput implements BaseTaskOutput, Serializable{
*/
private static final long serialVersionUID = 4243040464402882775L;
private BaseTaskExecutionStatus taskExecutionStatus;
private String outputMessage;
private List<String> outputMessages;
/**
* Instantiates a new task parameter.
@ -34,11 +35,11 @@ public class TaskOutput implements BaseTaskOutput, Serializable{
* Instantiates a new task output.
*
* @param taskExecutionstatus the task executionstatus
* @param outputMessage the output message
* @param outputMessages the output messages
*/
public TaskOutput(BaseTaskExecutionStatus taskExecutionstatus, String outputMessage) {
public TaskOutput(BaseTaskExecutionStatus taskExecutionstatus, List<String> outputMessages) {
this.taskExecutionStatus = taskExecutionstatus;
this.outputMessage = outputMessage;
this.outputMessages = outputMessages;
}
@ -54,11 +55,11 @@ public class TaskOutput implements BaseTaskOutput, Serializable{
/**
* @return the outputMessage
* @return the outputMessages
*/
public String getOutputMessage() {
public List<String> getOutputMessages() {
return outputMessage;
return outputMessages;
}
@ -74,11 +75,11 @@ public class TaskOutput implements BaseTaskOutput, Serializable{
/**
* @param outputMessage the outputMessage to set
* @param outputMessages the outputMessages to set
*/
public void setOutputMessage(String outputMessage) {
public void setOutputMessages(List<String> outputMessages) {
this.outputMessage = outputMessage;
this.outputMessages = outputMessages;
}
@ -91,11 +92,13 @@ public class TaskOutput implements BaseTaskOutput, Serializable{
StringBuilder builder = new StringBuilder();
builder.append("TaskOutput [taskExecutionStatus=");
builder.append(taskExecutionStatus);
builder.append(", outputMessage=");
builder.append(outputMessage);
builder.append(", outputMessages=");
builder.append(outputMessages);
builder.append("]");
return builder.toString();
}
}