use of cz.metacentrum.perun.taskslib.model.TaskResult.TaskResultStatus in project perun by CESNET.
the class AuditParser method createTaskResult.
private static TaskResult createTaskResult(Map<String, String> beanAttr) {
if (beanAttr == null)
return null;
TaskResult taskResult = new TaskResult();
taskResult.setId(Integer.valueOf(beanAttr.get("id")));
taskResult.setTaskId(Integer.valueOf(beanAttr.get("taskId")));
taskResult.setDestinationId(Integer.valueOf(beanAttr.get("destinationId")));
String errorMessage;
if (beanAttr.get("errorMessage").equals("\\0"))
errorMessage = null;
else {
errorMessage = BeansUtils.eraseEscaping(beanAttr.get("errorMessage"));
}
taskResult.setErrorMessage(errorMessage);
String standardMessage;
if (beanAttr.get("standardMessage").equals("\\0"))
standardMessage = null;
else {
standardMessage = BeansUtils.eraseEscaping(beanAttr.get("standardMessage"));
}
taskResult.setStandardMessage(standardMessage);
taskResult.setReturnCode(Integer.valueOf(beanAttr.get("returnCode")));
try {
taskResult.setTimestamp(BeansUtils.getDateFormatter().parse(BeansUtils.eraseEscaping(beanAttr.get("timestamp"))));
} catch (ParseException e) {
throw new InternalErrorException("Error when date was parsing from String to Date.", e);
}
String status = BeansUtils.eraseEscaping(beanAttr.get("status"));
TaskResultStatus st;
if (status.equals("\\0"))
st = null;
else {
if (status.equals("DENIED"))
st = TaskResultStatus.DENIED;
else if (status.equals("DONE"))
st = TaskResultStatus.DONE;
else if (status.equals("ERROR"))
st = TaskResultStatus.ERROR;
else if (status.equals("WARNING"))
st = TaskResultStatus.WARNING;
else
st = null;
}
taskResult.setStatus(st);
Service service;
if (beanAttr.get("service").equals("\\0"))
service = null;
else {
List<Pair<String, Map<String, String>>> serviceList = beansToMap(beanAttr.get("service"));
if (serviceList.size() > 0) {
service = createService(serviceList.get(0).getRight());
} else
service = null;
}
taskResult.setService(service);
return taskResult;
}
Aggregations