Search in sources :

Example 71 with CommandContext

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

the class TestVariableEventListenerStore method onEvent.

@Override
public void onEvent(ActivitiEvent event) {
    if (event instanceof ActivitiVariableEvent) {
        eventsReceived.add(event);
        EventLogEntryEntity eventLogEntry = new EventLogEntryEntity();
        eventLogEntry.setProcessDefinitionId(event.getProcessDefinitionId());
        eventLogEntry.setProcessInstanceId(event.getProcessInstanceId());
        eventLogEntry.setExecutionId(event.getExecutionId());
        eventLogEntry.setTaskId(((ActivitiVariableEvent) event).getTaskId());
        eventLogEntry.setType(event.getType().name());
        eventLogEntry.setTimeStamp(new Date());
        CommandContext commandContext = Context.getCommandContext();
        commandContext.getEventLogEntryEntityManager().insert(eventLogEntry);
    }
}
Also used : EventLogEntryEntity(org.activiti.engine.impl.persistence.entity.EventLogEntryEntity) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) ActivitiVariableEvent(org.activiti.engine.delegate.event.ActivitiVariableEvent) Date(java.util.Date)

Example 72 with CommandContext

use of org.activiti.engine.impl.interceptor.CommandContext 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

CommandContext (org.activiti.engine.impl.interceptor.CommandContext)72 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)18 DbSqlSession (org.activiti.engine.impl.db.DbSqlSession)13 SignalEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)8 Date (java.util.Date)7 ActivitiException (org.activiti.engine.ActivitiException)7 CommandConfig (org.activiti.engine.impl.interceptor.CommandConfig)7 EventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity)7 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)7 MessageEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)6 HashMap (java.util.HashMap)4 TimerEntity (org.activiti.engine.impl.persistence.entity.TimerEntity)4 Job (org.activiti.engine.runtime.Job)4 Deployment (org.activiti.engine.test.Deployment)4 ArrayList (java.util.ArrayList)3 GregorianCalendar (java.util.GregorianCalendar)3 List (java.util.List)3 ExtensionElement (org.activiti.bpmn.model.ExtensionElement)3 DynamicBpmnService (org.activiti.engine.DynamicBpmnService)3 JobEntity (org.activiti.engine.impl.persistence.entity.JobEntity)3