use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class MigrateProcessInstanceCmd method execute.
public Void execute(final CommandContext commandContext) {
final MigrationPlan migrationPlan = executionBuilder.getMigrationPlan();
final Collection<String> processInstanceIds = collectProcessInstanceIds(commandContext);
ensureNotNull(BadUserRequestException.class, "Migration plan cannot be null", "migration plan", migrationPlan);
ensureNotEmpty(BadUserRequestException.class, "Process instance ids cannot empty", "process instance ids", processInstanceIds);
ensureNotContainsNull(BadUserRequestException.class, "Process instance ids cannot be null", "process instance ids", processInstanceIds);
ProcessDefinitionEntity sourceDefinition = resolveSourceProcessDefinition(commandContext);
final ProcessDefinitionEntity targetDefinition = resolveTargetProcessDefinition(commandContext);
checkAuthorizations(commandContext, sourceDefinition, targetDefinition, processInstanceIds);
if (writeOperationLog) {
writeUserOperationLog(commandContext, sourceDefinition, targetDefinition, processInstanceIds.size(), false);
}
commandContext.runWithoutAuthorization(new Callable<Void>() {
@Override
public Void call() throws Exception {
for (String processInstanceId : processInstanceIds) {
migrateProcessInstance(commandContext, processInstanceId, migrationPlan, targetDefinition);
}
return null;
}
});
return null;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity 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();
}
};
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testShouldNotIncrementExecutionListenerCountOnStartAndEndOfProcessInstance.
@Deployment(resources = { "org/camunda/bpm/application/impl/event/ProcessApplicationEventListenerTest.testExecutionListener.bpmn20.xml" })
public void testShouldNotIncrementExecutionListenerCountOnStartAndEndOfProcessInstance() {
final AtomicInteger eventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
// this process application returns an execution listener
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
if (!(((CoreExecution) execution).getEventSource() instanceof ProcessDefinitionEntity))
eventCount.incrementAndGet();
}
};
}
};
// register app so that it receives events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// Start process instance.
runtimeService.startProcessInstanceByKey("startToEnd");
assertEquals(5, eventCount.get());
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class ProcessApplicationEventListenerTest method testShouldInvokeExecutionListenerOnStartAndEndOfProcessInstance.
@Deployment(resources = { "org/camunda/bpm/application/impl/event/ProcessApplicationEventListenerTest.testExecutionListener.bpmn20.xml" })
public void testShouldInvokeExecutionListenerOnStartAndEndOfProcessInstance() {
final AtomicInteger processDefinitionEventCount = new AtomicInteger();
EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
public ExecutionListener getExecutionListener() {
// this process application returns an execution listener
return new ExecutionListener() {
public void notify(DelegateExecution execution) throws Exception {
if (((CoreExecution) execution).getEventSource() instanceof ProcessDefinitionEntity)
processDefinitionEventCount.incrementAndGet();
}
};
}
};
// register app so that it receives events
managementService.registerProcessApplication(deploymentId, processApplication.getReference());
// Start process instance.
runtimeService.startProcessInstanceByKey("startToEnd");
// Start and end of the process
assertEquals(2, processDefinitionEventCount.get());
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class HistoricProcessInstanceManagerProcessInstancesForCleanupTest method updateTimeToLive.
private void updateTimeToLive(CommandContext commandContext, String businessKey, int timeToLive) {
List<ProcessDefinition> processDefinitions = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(businessKey).list();
assertEquals(1, processDefinitions.size());
ProcessDefinitionEntity processDefinition1 = (ProcessDefinitionEntity) processDefinitions.get(0);
processDefinition1.setHistoryTimeToLive(timeToLive);
commandContext.getDbEntityManager().merge(processDefinition1);
}
Aggregations