Search in sources :

Example 71 with ProcessDefinitionEntity

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;
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException)

Example 72 with ProcessDefinitionEntity

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();
        }
    };
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Command(org.camunda.bpm.engine.impl.interceptor.Command) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 73 with ProcessDefinitionEntity

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());
}
Also used : EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 74 with ProcessDefinitionEntity

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());
}
Also used : EmbeddedProcessApplication(org.camunda.bpm.application.impl.EmbeddedProcessApplication) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelegateExecution(org.camunda.bpm.engine.delegate.DelegateExecution) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 75 with ProcessDefinitionEntity

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);
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)75 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)15 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)14 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)13 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)10 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)10 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)8 ArrayList (java.util.ArrayList)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)4 Deployment (org.camunda.bpm.engine.test.Deployment)4 InputStream (java.io.InputStream)3 ProcessInstanceModificationBuilderImpl (org.camunda.bpm.engine.impl.ProcessInstanceModificationBuilderImpl)3 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)3 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)3 IncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity)3 ProcessInstanceWithVariablesImpl (org.camunda.bpm.engine.impl.persistence.entity.ProcessInstanceWithVariablesImpl)3 Element (org.camunda.bpm.engine.impl.util.xml.Element)3 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2