use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionRestServiceQueryTest method testCaseDefinitionTenantIdIncludeDefinitionsWithoutTenantid.
@Test
public void testCaseDefinitionTenantIdIncludeDefinitionsWithoutTenantid() {
List<CaseDefinition> caseDefinitions = Arrays.asList(MockProvider.mockCaseDefinition().tenantId(null).build(), MockProvider.mockCaseDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
mockedQuery = createMockCaseDefinitionQuery(caseDefinitions);
Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID).queryParam("includeCaseDefinitionsWithoutTenantId", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(CASE_DEFINITION_QUERY_URL);
verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(mockedQuery).includeCaseDefinitionsWithoutTenantId();
verify(mockedQuery).list();
String content = response.asString();
List<String> definitions = from(content).getList("");
assertThat(definitions).hasSize(2);
String returnedTenantId1 = from(content).getString("[0].tenantId");
String returnedTenantId2 = from(content).getString("[1].tenantId");
assertThat(returnedTenantId1).isEqualTo(null);
assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionResourceImpl method getCaseDefinitionDiagram.
@Override
public Response getCaseDefinitionDiagram() {
CaseDefinition definition = engine.getRepositoryService().getCaseDefinition(caseDefinitionId);
InputStream caseDiagram = engine.getRepositoryService().getCaseDiagram(caseDefinitionId);
if (caseDiagram == null) {
return Response.noContent().build();
} else {
String fileName = definition.getDiagramResourceName();
return Response.ok(caseDiagram).header("Content-Disposition", "attachment; filename=" + fileName).type(ProcessDefinitionResourceImpl.getMediaTypeForFileSuffix(fileName)).build();
}
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class CaseDefinitionRestServiceImpl method getCaseDefinitions.
@Override
public List<CaseDefinitionDto> getCaseDefinitions(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
CaseDefinitionQueryDto queryDto = new CaseDefinitionQueryDto(getObjectMapper(), uriInfo.getQueryParameters());
List<CaseDefinitionDto> definitions = new ArrayList<CaseDefinitionDto>();
ProcessEngine engine = getProcessEngine();
CaseDefinitionQuery query = queryDto.toQuery(engine);
List<CaseDefinition> matchingDefinitions = null;
if (firstResult != null || maxResults != null) {
matchingDefinitions = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingDefinitions = query.list();
}
for (CaseDefinition definition : matchingDefinitions) {
CaseDefinitionDto def = CaseDefinitionDto.fromCaseDefinition(definition);
definitions.add(def);
}
return definitions;
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class ProcessApplicationManager method logCaseDefinitionRegistrations.
protected void logCaseDefinitionRegistrations(StringBuilder builder, List<CaseDefinition> caseDefinitions) {
if (caseDefinitions.isEmpty()) {
builder.append("Deployment does not provide any case definitions.");
} else {
builder.append("\n");
builder.append("Will execute case definitions ");
builder.append("\n");
for (CaseDefinition caseDefinition : caseDefinitions) {
builder.append("\n");
builder.append(" ");
builder.append(caseDefinition.getKey());
builder.append("[version: ");
builder.append(caseDefinition.getVersion());
builder.append(", id: ");
builder.append(caseDefinition.getId());
builder.append("]");
}
builder.append("\n");
}
}
use of org.camunda.bpm.engine.repository.CaseDefinition in project camunda-bpm-platform by camunda.
the class TenantIdProviderTest method providerCalledWithCaseDefinition_SubCaseInstance.
@Test
public void providerCalledWithCaseDefinition_SubCaseInstance() {
ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
TestTenantIdProvider.delegate = tenantIdProvider;
testRule.deploy(CMMN_SUBPROCESS_FILE, CMMN_FILE);
CaseDefinition deployedCaseDefinition = engineRule.getRepositoryService().createCaseDefinitionQuery().caseDefinitionKey("oneTaskCase").singleResult();
// if a case instance is created
engineRule.getCaseService().withCaseDefinitionByKey(CASE_DEFINITION_KEY).create();
// then the tenant id provider is passed in the case definition
CaseDefinition passedCaseDefinition = tenantIdProvider.caseParameters.get(1).getCaseDefinition();
assertThat(passedCaseDefinition, is(notNullValue()));
assertThat(passedCaseDefinition.getId(), is(deployedCaseDefinition.getId()));
}
Aggregations