Package org.activiti.engine.impl.persistence.entity

Examples of org.activiti.engine.impl.persistence.entity.JobEntity


    this.jobId = jobId;
    this.exception = exception;
  }

  public Object execute(CommandContext commandContext)  {
    JobEntity job = commandContext.getJobEntityManager().findJobById(jobId);
    if (job == null) {
      return null;
    }
    
    ActivityImpl activity = getCurrentActivity(commandContext, job);
    ProcessEngineConfiguration processEngineConfig = commandContext.getProcessEngineConfiguration();
  
    if (activity == null || activity.getFailedJobRetryTimeCycleValue() == null) {
      log.error("activitiy or FailedJobRetryTimerCycleValue is null in job " + jobId + "'. only decrementing retries.");
      job.setRetries(job.getRetries() - 1);
      job.setLockOwner(null);
      job.setLockExpirationTime(null);
      if (job.getDuedate() == null) {
        // add wait time for failed async job
        job.setDuedate(calculateDueDate(commandContext, processEngineConfig.getAsyncFailedJobWaitTime(), null));
      } else {
        // add default wait time for failed job
        job.setDuedate(calculateDueDate(commandContext, processEngineConfig.getDefaultFailedJobWaitTime(), job.getDuedate()));
      }
     
    } else {     
      String failedJobRetryTimeCycle = activity.getFailedJobRetryTimeCycleValue();
      try {
        DurationHelper durationHelper = new DurationHelper(failedJobRetryTimeCycle, processEngineConfig.getClock());
        job.setLockOwner(null);
        job.setLockExpirationTime(null);
        job.setDuedate(durationHelper.getDateAfter());
        
        if (job.getExceptionMessage() == null) {  // is it the first exception
          log.debug("Applying JobRetryStrategy '" + failedJobRetryTimeCycle+ "' the first time for job " + job.getId() + " with "+ durationHelper.getTimes()+" retries");
          // then change default retries to the ones configured
          job.setRetries(durationHelper.getTimes());
         
        } else {
          log.debug("Decrementing retries of JobRetryStrategy '" + failedJobRetryTimeCycle+ "' for job " + job.getId());
        }
        job.setRetries(job.getRetries() - 1);
        
      } catch (Exception e) {
        throw new ActivitiException("failedJobRetryTimeCylcle has wrong format:" + failedJobRetryTimeCycle, exception);
     
    }
   
    if (exception != null) {
      job.setExceptionMessage(exception.getMessage());
      job.setExceptionStacktrace(getExceptionStacktrace());
    }
   
    // Dispatch both an update and a retry-decrement event
    ActivitiEventDispatcher eventDispatcher = commandContext.getEventDispatcher();
    if (eventDispatcher.isEnabled()) {
View Full Code Here


    this.jobId = jobId;
    this.retries = retries;
  }

  public Void execute(CommandContext commandContext) {
    JobEntity job = commandContext
            .getJobEntityManager()
            .findJobById(jobId);
    if (job != null) {
      job.setRetries(retries);
     
      if(commandContext.getEventDispatcher().isEnabled()) {
        commandContext.getEventDispatcher().dispatchEvent(
            ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, job));
      }
View Full Code Here

    super(jobId);
  }

  @Override
  public Object execute(CommandContext commandContext) {
    JobEntity jobToDelete = getJobToDelete(commandContext);

    sendCancelEvent(jobToDelete);

    jobToDelete.delete();
    return null;
  }
View Full Code Here

  public String execute(CommandContext commandContext) {
    if(jobId == null) {
      throw new ActivitiIllegalArgumentException("jobId is null");
    }
   
    JobEntity job = commandContext
      .getJobEntityManager()
      .findJobById(jobId);
   
    if(job == null) {
      throw new ActivitiObjectNotFoundException("No job found with id " + jobId, Job.class);
    }
   
    return job.getExceptionStacktrace();
  }
View Full Code Here

    this.jobIds = new ArrayList<String>();
    jobIds.add(jobId);
  }

  public Void execute(CommandContext commandContext) {
    JobEntity jobToDelete = null;
    for (String jobId: jobIds) {
      jobToDelete = commandContext
        .getJobEntityManager()
        .findJobById(jobId);
     
      if(jobToDelete != null) {
        // When given job doesn't exist, ignore
        if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
          commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
            ActivitiEventBuilder.createEntityEvent(ActivitiEventType.JOB_CANCELED, jobToDelete));
        }

        jobToDelete.delete();
      }
    }
    return null;
  }
View Full Code Here

            .processDefinitionId(processDefinition.getId()).orderByJobDuedate().asc().list();
    List<JobEntity> suspensionStateJobs = new ArrayList<JobEntity>();
   
    // TODO: this is a hack (ie the cast to JobEntity)... we must clean this in the engine!
    for (Job job : jobs) {
      JobEntity jobEntity = (JobEntity) job;
      if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)
              || jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
        suspensionStateJobs.add(jobEntity);
      }
    }
   
    if (!suspensionStateJobs.isEmpty()) {
     
      // Header
      Label suspensionStateTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_SUSPENSION_STATE));
      suspensionStateTitle.addStyleName(ExplorerLayout.STYLE_H3);
      addComponent(suspensionStateTitle);
      addEmptySpace(this);
     
      // Actual suspend/activation jobs
      for (JobEntity jobEntity : suspensionStateJobs) {
        if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE))  {
          Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_SUSPEND,
                  Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
          addComponent(suspendLabel);
        } else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE))  {
          Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_ACTIVATE,
                  Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
          addComponent(suspendLabel);
        }
      }
    }
   
View Full Code Here

    } else {
     
      if (job.getProcessDefinitionId() != null) {
       
        // This is a hack .. need to cleanify this in the engine
        JobEntity jobEntity = (JobEntity) job;
        if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) {
          addLinkToProcessDefinition(layout, i18nManager.getMessage(Messages.JOB_SUSPEND_PROCESSDEFINITION), false);
        } else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
          addLinkToProcessDefinition(layout, i18nManager.getMessage(Messages.JOB_ACTIVATE_PROCESSDEFINITION), true);
        } else {
          addNotYetExecutedLabel(layout);
        }
       
View Full Code Here

    this.jobIds = new ArrayList<String>();
    jobIds.add(jobId);
  }

  public Void execute(CommandContext commandContext) {
    JobEntity jobToDelete = null;
    for (String jobId: jobIds) {
      jobToDelete = Context
        .getCommandContext()
        .getJobManager()
        .findJobById(jobId);
     
      if(jobToDelete != null) {
        // When given job doesn't exist, ignore
        jobToDelete.delete();
      }
    }
    return null;
  }
View Full Code Here

            .processDefinitionId(processDefinition.getId()).orderByJobDuedate().asc().list();
    List<JobEntity> suspensionStateJobs = new ArrayList<JobEntity>();
   
    // TODO: this is a hack (ie the cast to JobEntity)... we must clean this in the engine!
    for (Job job : jobs) {
      JobEntity jobEntity = (JobEntity) job;
      if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)
              || jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
        suspensionStateJobs.add(jobEntity);
      }
    }
   
    if (suspensionStateJobs.size() > 0) {
     
      // Header
      Label suspensionStateTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_SUSPENSION_STATE));
      suspensionStateTitle.addStyleName(ExplorerLayout.STYLE_H3);
      addComponent(suspensionStateTitle);
      addEmptySpace(this);
     
      // Actual suspend/activation jobs
      for (JobEntity jobEntity : suspensionStateJobs) {
        if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE))  {
          Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_SUSPEND,
                  Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
          addComponent(suspendLabel);
        } else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE))  {
          Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_ACTIVATE,
                  Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
          addComponent(suspendLabel);
        }
      }
    }
   
View Full Code Here

    this.jobId = jobId;
    this.exception = exception;
  }

  public Object execute(CommandContext commandContext) {
    JobEntity job = Context
      .getCommandContext()
      .getJobManager()
      .findJobById(jobId);
    job.setRetries(job.getRetries() - 1);
    job.setLockOwner(null);
    job.setLockExpirationTime(null);
   
    if(exception != null) {
      job.setExceptionMessage(exception.getMessage());
      job.setExceptionStacktrace(getExceptionStacktrace());
    }
   
    JobExecutor jobExecutor = Context.getProcessEngineConfiguration().getJobExecutor();
    MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor);
    TransactionContext transactionContext = commandContext.getTransactionContext();
View Full Code Here

TOP

Related Classes of org.activiti.engine.impl.persistence.entity.JobEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.