use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceQueryTest method testProcessDefinitionTenantIdIncludeDefinitionsWithoutTenantid.
@Test
public void testProcessDefinitionTenantIdIncludeDefinitionsWithoutTenantid() {
List<ProcessDefinition> processDefinitions = Arrays.asList(MockProvider.mockDefinition().tenantId(null).build(), MockProvider.mockDefinition().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());
mockedQuery = setUpMockDefinitionQuery(processDefinitions);
Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID).queryParam("includeProcessDefinitionsWithoutTenantId", true).then().expect().statusCode(Status.OK.getStatusCode()).when().get(PROCESS_DEFINITION_QUERY_URL);
verify(mockedQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
verify(mockedQuery).includeProcessDefinitionsWithoutTenantId();
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.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessDefinitionQueryImpl method addProcessDefinitionToCacheAndRetrieveDocumentation.
protected void addProcessDefinitionToCacheAndRetrieveDocumentation(List<ProcessDefinition> list) {
for (ProcessDefinition processDefinition : list) {
BpmnModelInstance bpmnModelInstance = Context.getProcessEngineConfiguration().getDeploymentCache().findBpmnModelInstanceForProcessDefinition((ProcessDefinitionEntity) processDefinition);
ModelElementInstance processElement = bpmnModelInstance.getModelElementById(processDefinition.getKey());
if (processElement != null) {
Collection<Documentation> documentations = processElement.getChildElementsByType(Documentation.class);
List<String> docStrings = new ArrayList<String>();
for (Documentation documentation : documentations) {
docStrings.add(documentation.getTextContent());
}
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) processDefinition;
processDefinitionEntity.setProperty(BpmnParse.PROPERTYNAME_DOCUMENTATION, BpmnParse.parseDocumentation(docStrings));
}
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessDefinitionResourceImpl method getProcessDefinition.
@Override
public ProcessDefinitionDto getProcessDefinition() {
RepositoryService repoService = engine.getRepositoryService();
ProcessDefinition definition;
try {
definition = repoService.getProcessDefinition(processDefinitionId);
} catch (ProcessEngineException e) {
throw new InvalidRequestException(Status.NOT_FOUND, e, "No matching definition with id " + processDefinitionId);
}
ProcessDefinitionDto result = ProcessDefinitionDto.fromProcessDefinition(definition);
return result;
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessApplicationManager method logRegistration.
// logger ////////////////////////////////////////////////////////////////////////////
protected void logRegistration(Set<String> deploymentIds, ProcessApplicationReference reference) {
if (!LOG.isInfoEnabled()) {
// building the log message is expensive (db queries) so we avoid it if we can
return;
}
try {
StringBuilder builder = new StringBuilder();
builder.append("ProcessApplication '");
builder.append(reference.getName());
builder.append("' registered for DB deployments ");
builder.append(deploymentIds);
builder.append(". ");
List<ProcessDefinition> processDefinitions = new ArrayList<ProcessDefinition>();
List<CaseDefinition> caseDefinitions = new ArrayList<CaseDefinition>();
CommandContext commandContext = Context.getCommandContext();
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
boolean cmmnEnabled = processEngineConfiguration.isCmmnEnabled();
for (String deploymentId : deploymentIds) {
DeploymentEntity deployment = commandContext.getDbEntityManager().selectById(DeploymentEntity.class, deploymentId);
if (deployment != null) {
processDefinitions.addAll(getDeployedProcessDefinitionArtifacts(deployment));
if (cmmnEnabled) {
caseDefinitions.addAll(getDeployedCaseDefinitionArtifacts(deployment));
}
}
}
logProcessDefinitionRegistrations(builder, processDefinitions);
if (cmmnEnabled) {
logCaseDefinitionRegistrations(builder, caseDefinitions);
}
LOG.registrationSummary(builder.toString());
} catch (Throwable e) {
LOG.exceptionWhileLoggingRegistrationSummary(e);
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ExecutionEntity method provideTenantId.
protected void provideTenantId(Map<String, Object> variables) {
if (tenantId == null) {
TenantIdProvider tenantIdProvider = Context.getProcessEngineConfiguration().getTenantIdProvider();
if (tenantIdProvider != null) {
VariableMap variableMap = Variables.fromMap(variables);
ProcessDefinition processDefinition = getProcessDefinition();
TenantIdProviderProcessInstanceContext ctx;
if (superExecutionId != null) {
ctx = new TenantIdProviderProcessInstanceContext(processDefinition, variableMap, getSuperExecution());
} else if (superCaseExecutionId != null) {
ctx = new TenantIdProviderProcessInstanceContext(processDefinition, variableMap, getSuperCaseExecution());
} else {
ctx = new TenantIdProviderProcessInstanceContext(processDefinition, variableMap);
}
tenantId = tenantIdProvider.provideTenantIdForProcessInstance(ctx);
}
}
}
Aggregations