Search in sources :

Example 6 with ProcessDefinition

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);
}
Also used : Response(com.jayway.restassured.response.Response) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 7 with ProcessDefinition

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));
        }
    }
}
Also used : ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) Documentation(org.camunda.bpm.model.bpmn.instance.Documentation) ArrayList(java.util.ArrayList) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 8 with ProcessDefinition

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;
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessDefinitionDto(org.camunda.bpm.engine.rest.dto.repository.ProcessDefinitionDto) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 9 with ProcessDefinition

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);
    }
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) CaseDefinition(org.camunda.bpm.engine.repository.CaseDefinition) ArrayList(java.util.ArrayList) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 10 with ProcessDefinition

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);
        }
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) TenantIdProvider(org.camunda.bpm.engine.impl.cfg.multitenancy.TenantIdProvider) PvmProcessDefinition(org.camunda.bpm.engine.impl.pvm.PvmProcessDefinition) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) TenantIdProviderProcessInstanceContext(org.camunda.bpm.engine.impl.cfg.multitenancy.TenantIdProviderProcessInstanceContext)

Aggregations

ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1093 Test (org.junit.Test)761 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)415 Deployment (org.camunda.bpm.engine.test.Deployment)230 Job (org.camunda.bpm.engine.runtime.Job)148 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)119 Batch (org.camunda.bpm.engine.batch.Batch)95 Task (org.camunda.bpm.engine.task.Task)87 HashMap (java.util.HashMap)77 JobDefinition (org.camunda.bpm.engine.management.JobDefinition)64 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)55 JobDefinitionQuery (org.camunda.bpm.engine.management.JobDefinitionQuery)54 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)47 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)42 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)41 MigrationPlanValidationException (org.camunda.bpm.engine.migration.MigrationPlanValidationException)40 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)39 Date (java.util.Date)38 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)35