Search in sources :

Example 6 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class MigrationBoundaryEventsTest method testMigrateTimerBoundaryEventKeepTrigger.

@Test
public void testMigrateTimerBoundaryEventKeepTrigger() {
    // given
    BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDuration("PT5S").userTask(AFTER_BOUNDARY_TASK).endEvent().done();
    BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDuration("PT10M").userTask(AFTER_BOUNDARY_TASK).endEvent().done();
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
    Map<String, String> activities = new HashMap<String, String>();
    activities.put(USER_TASK_ID, USER_TASK_ID);
    activities.put(BOUNDARY_ID, BOUNDARY_ID);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(BOUNDARY_ID, BOUNDARY_ID).build();
    // when
    testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertJobMigrated(BOUNDARY_ID, BOUNDARY_ID, TimerExecuteNestedActivityJobHandler.TYPE);
    // and it is possible to trigger the event and successfully complete the migrated instance
    ManagementService managementService = rule.getManagementService();
    Job job = managementService.createJobQuery().singleResult();
    managementService.executeJob(job.getId());
    testHelper.completeTask(AFTER_BOUNDARY_TASK);
    testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) HashMap(java.util.HashMap) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Job(org.camunda.bpm.engine.runtime.Job) Test(org.junit.Test)

Example 7 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class BatchHelper method setRetries.

public void setRetries(Batch batch, int count, int retries) {
    List<Job> jobs = getExecutionJobs(batch);
    assertTrue(jobs.size() >= count);
    ManagementService managementService = getManagementService();
    for (int i = 0; i < count; i++) {
        managementService.setJobRetries(jobs.get(i).getId(), retries);
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) Job(org.camunda.bpm.engine.runtime.Job)

Example 8 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class MockedProcessEngineProvider method mockServices.

private void mockServices(ProcessEngine engine) {
    RepositoryService repoService = mock(RepositoryService.class);
    IdentityService identityService = mock(IdentityService.class);
    TaskService taskService = mock(TaskService.class);
    RuntimeService runtimeService = mock(RuntimeService.class);
    FormService formService = mock(FormService.class);
    HistoryService historyService = mock(HistoryService.class);
    ManagementService managementService = mock(ManagementService.class);
    CaseService caseService = mock(CaseService.class);
    FilterService filterService = mock(FilterService.class);
    ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
    when(engine.getRepositoryService()).thenReturn(repoService);
    when(engine.getIdentityService()).thenReturn(identityService);
    when(engine.getTaskService()).thenReturn(taskService);
    when(engine.getRuntimeService()).thenReturn(runtimeService);
    when(engine.getFormService()).thenReturn(formService);
    when(engine.getHistoryService()).thenReturn(historyService);
    when(engine.getManagementService()).thenReturn(managementService);
    when(engine.getCaseService()).thenReturn(caseService);
    when(engine.getFilterService()).thenReturn(filterService);
    when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) ManagementService(org.camunda.bpm.engine.ManagementService) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) FormService(org.camunda.bpm.engine.FormService) FilterService(org.camunda.bpm.engine.FilterService) HistoryService(org.camunda.bpm.engine.HistoryService) CaseService(org.camunda.bpm.engine.CaseService) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 9 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class JobDefinitionResourceImpl method setJobRetries.

public void setJobRetries(RetriesDto dto) {
    try {
        ManagementService managementService = engine.getManagementService();
        managementService.setJobRetriesByJobDefinitionId(jobDefinitionId, dto.getRetries());
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 10 with ManagementService

use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.

the class JobResourceImpl method getJob.

@Override
public JobDto getJob() {
    ManagementService managementService = engine.getManagementService();
    Job job = managementService.createJobQuery().jobId(jobId).singleResult();
    if (job == null) {
        throw new InvalidRequestException(Status.NOT_FOUND, "Job with id " + jobId + " does not exist");
    }
    return JobDto.fromJob(job);
}
Also used : ManagementService(org.camunda.bpm.engine.ManagementService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) Job(org.camunda.bpm.engine.runtime.Job)

Aggregations

ManagementService (org.camunda.bpm.engine.ManagementService)20 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)11 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 HistoryService (org.camunda.bpm.engine.HistoryService)4 Batch (org.camunda.bpm.engine.batch.Batch)4 ArrayList (java.util.ArrayList)3 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)3 Job (org.camunda.bpm.engine.runtime.Job)3 StatisticsResultDto (org.camunda.bpm.engine.rest.dto.StatisticsResultDto)2 RestException (org.camunda.bpm.engine.rest.exception.RestException)2 HashMap (java.util.HashMap)1 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 CaseService (org.camunda.bpm.engine.CaseService)1 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 FilterService (org.camunda.bpm.engine.FilterService)1 FormService (org.camunda.bpm.engine.FormService)1 IdentityService (org.camunda.bpm.engine.IdentityService)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1