Search in sources :

Example 71 with JobDefinitionQuery

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

the class JobDefinitionCreationBothAsyncWithParseListenerTest method testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml.

@Test
public void testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml() {
    // given the asyncBefore AND asyncAfter is set in the xml
    String modelFileName = "jobAsyncBothCreationWithinParseListener.bpmn20.xml";
    InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
    DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
    // when the asyncBefore and asyncAfter is set to true in the parse listener
    Deployment deployment = builder.deploy();
    engineRule.manageDeployment(deployment);
    // then there exists two job definitions
    JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
    List<JobDefinition> definitions = query.orderByJobConfiguration().asc().list();
    assertEquals(definitions.size(), 2);
    // asyncAfter
    JobDefinition asyncAfterAfter = definitions.get(0);
    assertEquals(asyncAfterAfter.getProcessDefinitionKey(), "oneTaskProcess");
    assertEquals(asyncAfterAfter.getActivityId(), "servicetask1");
    assertEquals(asyncAfterAfter.getJobConfiguration(), MessageJobDeclaration.ASYNC_AFTER);
    // asyncBefore
    JobDefinition asyncAfterBefore = definitions.get(1);
    assertEquals(asyncAfterBefore.getProcessDefinitionKey(), "oneTaskProcess");
    assertEquals(asyncAfterBefore.getActivityId(), "servicetask1");
    assertEquals(asyncAfterBefore.getJobConfiguration(), MessageJobDeclaration.ASYNC_BEFORE);
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InputStream(java.io.InputStream) Deployment(org.camunda.bpm.engine.repository.Deployment) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 72 with JobDefinitionQuery

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

the class JobDefinitionCreationBothAsyncWithParseListenerTest method testCreateBothJobDefinitionWithParseListenerAndAsyncBeforeInXml.

@Test
public void testCreateBothJobDefinitionWithParseListenerAndAsyncBeforeInXml() {
    // given the asyncBefore is set in the xml
    String modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml";
    InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
    DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
    // when the asyncBefore and asyncAfter is set to true in the parse listener
    Deployment deployment = builder.deploy();
    engineRule.manageDeployment(deployment);
    // then there exists two job definitions
    JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
    List<JobDefinition> definitions = query.orderByJobConfiguration().asc().list();
    assertEquals(definitions.size(), 2);
    // asyncAfter
    JobDefinition asyncAfterAfter = definitions.get(0);
    assertEquals(asyncAfterAfter.getProcessDefinitionKey(), "oneTaskProcess");
    assertEquals(asyncAfterAfter.getActivityId(), "servicetask1");
    assertEquals(asyncAfterAfter.getJobConfiguration(), MessageJobDeclaration.ASYNC_AFTER);
    // asyncBefore
    JobDefinition asyncAfterBefore = definitions.get(1);
    assertEquals(asyncAfterBefore.getProcessDefinitionKey(), "oneTaskProcess");
    assertEquals(asyncAfterBefore.getActivityId(), "servicetask1");
    assertEquals(asyncAfterBefore.getJobConfiguration(), MessageJobDeclaration.ASYNC_BEFORE);
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InputStream(java.io.InputStream) Deployment(org.camunda.bpm.engine.repository.Deployment) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) JobDefinition(org.camunda.bpm.engine.management.JobDefinition) Test(org.junit.Test)

Example 73 with JobDefinitionQuery

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

the class JobDefinitionDeletionWithParseListenerTest method testDeleteJobDefinitionWithParseListenerAndAsyncInXml.

@Test
public void testDeleteJobDefinitionWithParseListenerAndAsyncInXml() {
    // given the asyncBefore is set in the xml
    String modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml";
    InputStream in = JobDefinitionCreationWithParseListenerTest.class.getResourceAsStream(modelFileName);
    DeploymentBuilder builder = engineRule.getRepositoryService().createDeployment().addInputStream(modelFileName, in);
    // when the asyncBefore is set to false in the parse listener
    Deployment deployment = builder.deploy();
    engineRule.manageDeployment(deployment);
    // then there exists no job definition
    JobDefinitionQuery query = engineRule.getManagementService().createJobDefinitionQuery();
    assertNull(query.singleResult());
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) InputStream(java.io.InputStream) Deployment(org.camunda.bpm.engine.repository.Deployment) DeploymentBuilder(org.camunda.bpm.engine.repository.DeploymentBuilder) Test(org.junit.Test)

Example 74 with JobDefinitionQuery

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

the class JobDefinitionRestServiceImpl method queryJobDefinitionsCount.

public CountResultDto queryJobDefinitionsCount(JobDefinitionQueryDto queryDto) {
    queryDto.setObjectMapper(getObjectMapper());
    JobDefinitionQuery query = queryDto.toQuery(getProcessEngine());
    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);
    return result;
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto)

Example 75 with JobDefinitionQuery

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

the class JobDefinitionRestServiceImpl method queryJobDefinitions.

public List<JobDefinitionDto> queryJobDefinitions(JobDefinitionQueryDto queryDto, Integer firstResult, Integer maxResults) {
    queryDto.setObjectMapper(getObjectMapper());
    JobDefinitionQuery query = queryDto.toQuery(getProcessEngine());
    List<JobDefinition> matchingJobDefinitions;
    if (firstResult != null || maxResults != null) {
        matchingJobDefinitions = executePaginatedQuery(query, firstResult, maxResults);
    } else {
        matchingJobDefinitions = query.list();
    }
    List<JobDefinitionDto> jobDefinitionResults = new ArrayList<JobDefinitionDto>();
    for (JobDefinition jobDefinition : matchingJobDefinitions) {
        JobDefinitionDto result = JobDefinitionDto.fromJobDefinition(jobDefinition);
        jobDefinitionResults.add(result);
    }
    return jobDefinitionResults;
}
Also used : JobDefinitionQuery(org.camunda.bpm.engine.management.JobDefinitionQuery) JobDefinitionDto(org.camunda.bpm.engine.rest.dto.management.JobDefinitionDto) ArrayList(java.util.ArrayList) JobDefinition(org.camunda.bpm.engine.management.JobDefinition)

Aggregations

JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)163 Deployment (org.camunda.bpm.engine.test.Deployment)89 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)88 HashMap (java.util.HashMap)86 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)86 Job (org.camunda.bpm.engine.runtime.Job)78 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)54 Test (org.junit.Test)31 Date (java.util.Date)12 InputStream (java.io.InputStream)10 Deployment (org.camunda.bpm.engine.repository.Deployment)10 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)10 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)6 ArrayList (java.util.ArrayList)2 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 JobDefinitionDto (org.camunda.bpm.engine.rest.dto.management.JobDefinitionDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 Matchers.anyString (org.mockito.Matchers.anyString)1