use of org.camunda.bpm.engine.impl.interceptor.Command in project camunda-bpm-platform by camunda.
the class RedeploymentRegistrationTest method caseDefinitionTestProvider.
protected static TestProvider caseDefinitionTestProvider() {
return new TestProvider() {
@Override
public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
return new Command<ProcessApplicationReference>() {
public ProcessApplicationReference execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
CaseDefinitionEntity definition = deploymentCache.findDeployedCaseDefinitionById(definitionId);
return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
}
};
}
@Override
public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
return repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).latestVersion().singleResult().getId();
}
};
}
use of org.camunda.bpm.engine.impl.interceptor.Command in project camunda-bpm-platform by camunda.
the class JobQueryTest method setUp.
/**
* Setup will create
* - 3 process instances, each with one timer, each firing at t1/t2/t3 + 1 hour (see process)
* - 1 message
*/
protected void setUp() throws Exception {
super.setUp();
this.commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
deploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/timerOnTask.bpmn20.xml").deploy().getId();
// Create proc inst that has timer that will fire on t1 + 1 hour
Calendar startTime = Calendar.getInstance();
startTime.set(Calendar.MILLISECOND, 0);
Date t1 = startTime.getTime();
ClockUtil.setCurrentTime(t1);
processInstanceIdOne = runtimeService.startProcessInstanceByKey("timerOnTask").getId();
testStartTime = t1;
timerOneFireTime = new Date(t1.getTime() + ONE_HOUR);
// Create proc inst that has timer that will fire on t2 + 1 hour
startTime.add(Calendar.HOUR_OF_DAY, 1);
// t2 = t1 + 1 hour
Date t2 = startTime.getTime();
ClockUtil.setCurrentTime(t2);
processInstanceIdTwo = runtimeService.startProcessInstanceByKey("timerOnTask").getId();
timerTwoFireTime = new Date(t2.getTime() + ONE_HOUR);
// Create proc inst that has timer that will fire on t3 + 1 hour
startTime.add(Calendar.HOUR_OF_DAY, 1);
// t3 = t2 + 1 hour
Date t3 = startTime.getTime();
ClockUtil.setCurrentTime(t3);
processInstanceIdThree = runtimeService.startProcessInstanceByKey("timerOnTask").getId();
timerThreeFireTime = new Date(t3.getTime() + ONE_HOUR);
// Create one message
messageId = commandExecutor.execute(new Command<String>() {
public String execute(CommandContext commandContext) {
MessageEntity message = new MessageEntity();
commandContext.getJobManager().send(message);
return message.getId();
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.Command in project camunda-bpm-platform by camunda.
the class SpinFunctionMapperTest method executeExpression.
@SuppressWarnings("unchecked")
protected <T> T executeExpression(String expression) {
final TestVariableScope varScope = new TestVariableScope();
final Expression compiledExpression = processEngineConfiguration.getExpressionManager().createExpression(expression);
return (T) processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Object>() {
public Object execute(CommandContext commandContext) {
return compiledExpression.getValue(varScope);
}
});
}
use of org.camunda.bpm.engine.impl.interceptor.Command in project camunda-bpm-platform by camunda.
the class RedeploymentRegistrationTest method decisionRequirementsDefinitionTestProvider.
protected static TestProvider decisionRequirementsDefinitionTestProvider() {
return new TestProvider() {
@Override
public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
return new Command<ProcessApplicationReference>() {
public ProcessApplicationReference execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
DecisionRequirementsDefinitionEntity definition = deploymentCache.findDeployedDecisionRequirementsDefinitionById(definitionId);
return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
}
};
}
@Override
public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
return repositoryService.createDecisionRequirementsDefinitionQuery().decisionRequirementsDefinitionKey(key).latestVersion().singleResult().getId();
}
};
}
use of org.camunda.bpm.engine.impl.interceptor.Command in project camunda-bpm-platform by camunda.
the class RedeploymentRegistrationTest method processDefinitionTestProvider.
protected static TestProvider processDefinitionTestProvider() {
return new TestProvider() {
@Override
public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
return new Command<ProcessApplicationReference>() {
public ProcessApplicationReference execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
ProcessDefinitionEntity definition = deploymentCache.findDeployedProcessDefinitionById(definitionId);
return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
}
};
}
@Override
public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult().getId();
}
};
}
Aggregations