Examples of TimerEntity


Examples of com.catify.processengine.serviceproviders.jpa.beans.TimerEntity

    this.timerRepository = (TimerRepository) AppContextFactory.load(TimerRepository.class);
  }
 
  @Override
  public void saveTimer(TimerBean timer) {
    timerRepository.save(new TimerEntity(timer));
  }
View Full Code Here

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

    return processDefinitionEntities;
  }
 
  protected void createTimerForDelayedExecution(CommandContext commandContext, List<ProcessDefinitionEntity> processDefinitions) {
    for (ProcessDefinitionEntity processDefinition : processDefinitions) {
      TimerEntity timer = new TimerEntity();
      timer.setProcessDefinitionId(processDefinition.getId());
      timer.setDuedate(executionDate);
      timer.setJobHandlerType(getDelayedExecutionJobHandlerType());
      timer.setJobHandlerConfiguration(TimerChangeProcessDefinitionSuspensionStateJobHandler
              .createJobHandlerConfiguration(includeProcessInstances));
      commandContext.getJobManager().schedule(timer);
    }
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {
        JobManager jobManager = commandContext.getJobManager();

        timerEntity = new TimerEntity();
        timerEntity.setLockOwner(UUID.randomUUID().toString());
        timerEntity.setDuedate(new Date());
        timerEntity.setRetries(0);

        StringWriter stringWriter = new StringWriter();
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
    commandExecutor.execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {
        JobManager jobManager = commandContext.getJobManager();

        timerEntity = new TimerEntity();
        timerEntity.setLockOwner(UUID.randomUUID().toString());
        timerEntity.setDuedate(new Date());
        timerEntity.setRetries(0);
        timerEntity.setExceptionMessage("I'm supposed to fail");
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

    Date dueDate = DateTimeUtil.now().plusMinutes(5).toDate();
    variables.put("outerVariable", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(dueDate));
    runtimeService.startProcessInstanceByKey("testProcess", variables);

    Job job = managementService.createJobQuery().singleResult();
    TimerEntity timer = (TimerEntity) job;
    assertDateEquals(dueDate, timer.getDuedate());
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

    if (duedate==null) {
      duedate = businessCalendar.resolveDuedate(dueDateString);
    }

    TimerEntity timer = new TimerEntity(this);
    timer.setDuedate(duedate);
    if (execution != null) {
      timer.setExecution(execution);
    }

    if (type == TimerDeclarationType.CYCLE) {

      // See ACT-1427: A boundary timer with a cancelActivity='true', doesn't need to repeat itself
      if (!isInterruptingTimer) {
        String prepared = prepareRepeat(dueDateString);
        timer.setRepeat(prepared);
      }
    }

    return timer;
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

      return null;
    }
  }

  public TimerEntity createTimer(ExecutionEntity execution) {
    TimerEntity timer = super.createJobInstance(execution);
    Context
    .getCommandContext()
    .getJobManager()
    .schedule(timer);
    return timer;
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

      getSetJobStateCmd().execute(commandContext);
    }
  }

  private void scheduleSuspensionStateUpdate(CommandContext commandContext) {
    TimerEntity timer = new TimerEntity();

    timer.setDuedate(executionDate);
    timer.setJobHandlerType(getDelayedExecutionJobHandlerType());

    String jobConfiguration = null;

    if (jobDefinitionId != null) {
      jobConfiguration = TimerChangeJobDefinitionSuspensionStateJobHandler
          .createJobHandlerConfigurationByJobDefinitionId(jobDefinitionId, includeJobs);
    } else

    if (processDefinitionId != null) {
      jobConfiguration = TimerChangeJobDefinitionSuspensionStateJobHandler
          .createJobHandlerConfigurationByProcessDefinitionId(processDefinitionId, includeJobs);
    } else

    if (processDefinitionKey != null) {
      jobConfiguration = TimerChangeJobDefinitionSuspensionStateJobHandler
          .createJobHandlerConfigurationByProcessDefinitionKey(processDefinitionKey, includeJobs);
    }

    timer.setJobHandlerConfiguration(jobConfiguration);

    commandContext.getJobManager().schedule(timer);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

    message.setJobHandlerConfiguration(msg);
    return message;
  }

  protected TimerEntity createTweetTimer(String msg, Date duedate) {
    TimerEntity timer = new TimerEntity();
    timer.setJobHandlerType("tweet");
    timer.setJobHandlerConfiguration(msg);
    timer.setDuedate(duedate);
    return timer;
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.persistence.entity.TimerEntity

  public void testJobAcquisitionForJobsWithoutSuspensionStateSet() {
    final String processInstanceId = "1";
    final String myCustomTimerEntity = "myCustomTimerEntity";

    final TimerEntity timer = new TimerEntity();
    timer.setRetries(3);
    timer.setDuedate(null);
    timer.setLockOwner(null);
    timer.setLockExpirationTime(null);
    timer.setJobHandlerType(TimerStartEventJobHandler.TYPE);
    timer.setJobHandlerConfiguration(myCustomTimerEntity);
    timer.setProcessInstanceId(processInstanceId);

    final CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();

    try {
      // we create a timer entity
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          commandContext.getJobManager().insert(timer);
          return null;
        }
      });

      // we change the suspension state to null
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          Connection connection = null;
          Statement statement = null;
          ResultSet rs = null;

          try {
            SqlSession sqlSession = commandContext.getDbSqlSession().getSqlSession();
            connection = sqlSession.getConnection();
            statement = connection
                .createStatement();
            int updateResult = statement.executeUpdate("UPDATE ACT_RU_JOB " +
                "SET SUSPENSION_STATE_ = NULL, REV_ = 2" +
                " WHERE SUSPENSION_STATE_ = 1");
            statement.close();
            assertEquals(1, updateResult);

            statement = connection
                .createStatement();
            rs = statement.executeQuery("SELECT * FROM ACT_RU_JOB WHERE SUSPENSION_STATE_ IS NULL");

            int rowNum = 0;
            while (rs.next()) {
              rowNum = rs.getRow();
            }
            assertEquals(1, rowNum);
          } catch (SQLException e) {
            throw new RuntimeException(e);
          } finally {
            try {
              if (statement != null) {
                statement.close();
              }
              if (rs != null) {
                rs.close();
              }
              if (connection != null) {
                connection.close();
              }
            } catch (SQLException e) {
              throw new RuntimeException(e);
            }
          }
          return null;
        }
      });

      // it is picked up by the acquisition queries
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          JobManager jobManager = commandContext.getJobManager();

          List<JobEntity> executableJobs = jobManager.findNextJobsToExecute(new Page(0, 1));

          assertEquals(1, executableJobs.size());
          assertEquals(myCustomTimerEntity, executableJobs.get(0).getJobHandlerConfiguration());

          executableJobs = jobManager.findExclusiveJobsToExecute(processInstanceId);
          assertEquals(1, executableJobs.size());
          assertEquals(myCustomTimerEntity, executableJobs.get(0).getJobHandlerConfiguration());
          return null;
        }
      });

    } finally {
      // cleanup
      commandExecutor.execute(new Command<Void>() {
        public Void execute(CommandContext commandContext) {
          final JobEntity newTimer = commandContext.getJobManager().findJobById(timer.getId());
          newTimer.delete();
          return null;
        }
      });
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.