@Override
    public void completed(ProcessEvent event) {
      taskEntity.setDateEnd(System.currentTimeMillis());
      taskEntity.setMessage(toString(event.getTask()));
      roundProgression(event);

      ParameterValueGroup output = event.getOutput();
      if (output != null) {
        try {
          taskEntity.setTaskOutput(ParamUtilities.writeParameterJSON(output));
        } catch (JsonProcessingException e) {
          LOGGER.log(Level.WARNING, "Process output serialization failed", e);
        }
      }

      // If a warning occurred, send exception to the user.
      if (!warnings.isEmpty()) {
        taskEntity.setState(TaskState.WARNING.name());
        taskEntity.setMessage(processWarningMessage());
      } else {
        taskEntity.setState(TaskState.SUCCEED.name());
      }

      updateTask(taskEntity);
    }
    @Override
    public void failed(ProcessEvent event) {
      taskEntity.setState(TaskState.FAILED.name());
      taskEntity.setDateEnd(System.currentTimeMillis());

      final Exception exception = event.getException();
      final String exceptionStr = printException(exception);
      taskEntity.setMessage(toString(event.getTask()) + " cause : " + exceptionStr);
      // taskEntity.setProgress((double) event.getProgress());
      updateTask(taskEntity);
    }