use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class HistoryCleanupOnEngineStartTest method clearDatabase.
@After
public void clearDatabase() {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) engineRule.getProcessEngine().getProcessEngineConfiguration();
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
List<Job> jobs = engineRule.getProcessEngine().getManagementService().createJobQuery().list();
if (jobs.size() > 0) {
assertEquals(1, jobs.size());
String jobId = jobs.get(0).getId();
commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
}
return null;
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class RepositoryServiceTest method tearDown.
@Override
public void tearDown() throws Exception {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
commandExecutor.execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
commandContext.getHistoricJobLogManager().deleteHistoricJobLogsByHandlerType(TimerActivateProcessDefinitionHandler.TYPE);
return null;
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class UpgradedDBDropper method cleanDatabase.
public void cleanDatabase(ProcessEngine engine) {
// delete all deployments
RepositoryService repositoryService = engine.getRepositoryService();
List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
for (Deployment deployment : deployments) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
// drop DB
((ProcessEngineImpl) engine).getProcessEngineConfiguration().getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
commandContext.getDbSqlSession().dbSchemaDrop();
return null;
}
});
engine.close();
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class JobMigrationScenario method triggerEntryCriterion.
@DescribesScenario("createJob")
public static ScenarioSetup triggerEntryCriterion() {
return new ScenarioSetup() {
public void execute(ProcessEngine engine, final String scenarioName) {
final ProcessEngineConfigurationImpl engineConfiguration = (ProcessEngineConfigurationImpl) engine.getProcessEngineConfiguration();
CommandExecutor commandExecutor = engineConfiguration.getCommandExecutorTxRequired();
// create a job with the scenario name as id and a null suspension state
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();
statement.executeUpdate("INSERT INTO ACT_RU_JOB(ID_, REV_, RETRIES_, TYPE_, EXCLUSIVE_, HANDLER_TYPE_) " + "VALUES (" + "'" + scenarioName + "'," + "1," + "3," + "'timer'," + DbSqlSessionFactory.databaseSpecificTrueConstant.get(engineConfiguration.getDatabaseType()) + "," + "'" + TimerStartEventJobHandler.TYPE + "'" + ")");
connection.commit();
statement.close();
} 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;
}
});
}
};
}
use of org.camunda.bpm.engine.impl.interceptor.CommandContext in project camunda-bpm-platform by camunda.
the class EnvScriptCachingTest method executeScript.
protected void executeScript(final ProcessApplicationInterface processApplication) {
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
return Context.executeWithinProcessApplication(new Callable<Void>() {
public Void call() throws Exception {
ScriptingEngines scriptingEngines = processEngineConfiguration.getScriptingEngines();
ScriptEngine scriptEngine = scriptingEngines.getScriptEngineForLanguage(SCRIPT_LANGUAGE);
SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, SCRIPT);
ScriptingEnvironment scriptingEnvironment = processEngineConfiguration.getScriptingEnvironment();
scriptingEnvironment.execute(script, null, null, scriptEngine);
return null;
}
}, processApplication.getReference());
}
});
}
Aggregations