@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());
  }
 public StateListener(String taskId, String title) {
   this.taskId = taskId;
   if (processBusiness == null) {
     this.processBusiness = SpringHelper.getBean(IProcessBusiness.class);
   }
   this.taskEntity = processBusiness.getTask(taskId);
   this.title = title;
 }
    private void updateTask(Task taskEntity) {
      if (processBusiness == null) {
        this.processBusiness = SpringHelper.getBean(IProcessBusiness.class);
      }
      // update in database
      processBusiness.updateTask(taskEntity);

      // send event
      final TaskStatusDTO taskStatus = new TaskStatusDTO();
      taskStatus.setId(taskEntity.getIdentifier());
      taskStatus.setTaskId(taskEntity.getTaskParameterId());
      taskStatus.setTitle(title);
      taskStatus.setStatus(taskEntity.getState());
      taskStatus.setMessage(taskEntity.getMessage());
      taskStatus.setPercent(taskEntity.getProgress().floatValue());
      taskStatus.setStart(taskEntity.getDateStart());
      taskStatus.setEnd(taskEntity.getDateEnd());
      taskStatus.setOutput(taskEntity.getTaskOutput());

      SpringHelper.sendEvent(taskStatus);
    }
 public AbstractCstlProcess(final ProcessDescriptor desc, final ParameterValueGroup parameter) {
   super(desc, parameter);
   SpringHelper.injectDependencies(this);
 }
 public CoveragesGroupProvider(
     String providerId, final ProviderFactory service, final ParameterValueGroup param) {
   super(providerId, service, param);
   this.visited = false;
   SpringHelper.injectDependencies(this);
 }