Пример #1
0
    @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);
    }
Пример #2
0
  @Override
  public synchronized void jobToBeExecuted(JobExecutionContext jec) {
    if (processBusiness == null) {
      this.processBusiness = SpringHelper.getBean(IProcessBusiness.class);
    }

    final Job job = jec.getJobInstance();
    if (!(job instanceof ProcessJob)) return;

    // attach a listener on the process
    final ProcessJob pj = (ProcessJob) job;
    final ProcessJobDetail detail = (ProcessJobDetail) jec.getJobDetail();
    final QuartzTask quartzTask =
        (QuartzTask) detail.getJobDataMap().get(QuartzJobListener.PROPERTY_TASK);
    final String quartzTaskId = quartzTask.getId();

    final Task taskEntity = new Task();
    taskEntity.setIdentifier(UUID.randomUUID().toString());
    taskEntity.setState(TaskState.PENDING.name());
    taskEntity.setTaskParameterId(quartzTask.getTaskParameterId());
    taskEntity.setOwner(quartzTask.getUserId());
    taskEntity.setType(""); // TODO
    processBusiness.addTask(taskEntity);

    final ProcessListener listener =
        new StateListener(taskEntity.getIdentifier(), quartzTask.getTitle());
    pj.addListener(listener);
    LOGGER.log(Level.INFO, "Run task " + taskEntity.getIdentifier());
  }
Пример #3
0
 @Override
 public void resumed(ProcessEvent event) {
   taskEntity.setState(TaskState.RUNNING.name());
   taskEntity.setMessage(toString(event.getTask()));
   roundProgression(event);
   updateTask(taskEntity);
 }
Пример #4
0
 @Override
 public void started(ProcessEvent event) {
   taskEntity.setState(TaskState.RUNNING.name());
   taskEntity.setDateStart(System.currentTimeMillis());
   taskEntity.setMessage(toString(event.getTask()));
   roundProgression(event);
   updateTask(taskEntity);
 }
Пример #5
0
    @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);
    }
Пример #6
0
    @Override
    public void progressing(ProcessEvent event) {
      taskEntity.setState(TaskState.RUNNING.name());
      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 (event.getException() != null) {
        warnings.add(event);
      }

      updateTask(taskEntity);
    }