Search in sources :

Example 36 with CommandExecutor

use of org.activiti.engine.impl.interceptor.CommandExecutor in project Activiti by Activiti.

the class TimerEventCompatibilityTest method changeConfigurationToPlainText.

protected void changeConfigurationToPlainText(JobEntity job) {
    String activityId = TimerEventHandler.getActivityIdFromConfiguration(job.getJobHandlerConfiguration());
    final JobEntity finalJob = job;
    CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor();
    CommandConfig config = new CommandConfig().transactionNotSupported();
    final String finalActivityId = activityId;
    commandExecutor.execute(config, new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            DbSqlSession session = commandContext.getSession(DbSqlSession.class);
            session.delete(finalJob);
            session.flush();
            session.commit();
            return null;
        }
    });
    commandExecutor.execute(config, new Command<Object>() {

        public Object execute(CommandContext commandContext) {
            DbSqlSession session = commandContext.getSession(DbSqlSession.class);
            finalJob.setJobHandlerConfiguration(finalActivityId);
            finalJob.setId(null);
            session.insert(finalJob);
            session.flush();
            session.commit();
            return null;
        }
    });
}
Also used : JobEntity(org.activiti.engine.impl.persistence.entity.JobEntity) CommandConfig(org.activiti.engine.impl.interceptor.CommandConfig) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) DbSqlSession(org.activiti.engine.impl.db.DbSqlSession)

Aggregations

CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)36 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)18 Deployment (org.activiti.engine.test.Deployment)11 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)10 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)8 SetProcessDefinitionVersionCmd (org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd)8 CommandConfig (org.activiti.engine.impl.interceptor.CommandConfig)7 Date (java.util.Date)6 Execution (org.activiti.engine.runtime.Execution)6 DbSqlSession (org.activiti.engine.impl.db.DbSqlSession)5 JobEntity (org.activiti.engine.impl.persistence.entity.JobEntity)5 TimerEntity (org.activiti.engine.impl.persistence.entity.TimerEntity)5 ActivitiOptimisticLockingException (org.activiti.engine.ActivitiOptimisticLockingException)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)4 ActivitiException (org.activiti.engine.ActivitiException)3 ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)3 AcquireTimerJobsCmd (org.activiti.engine.impl.cmd.AcquireTimerJobsCmd)3 JobEntityManager (org.activiti.engine.impl.persistence.entity.JobEntityManager)3 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)3 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)2