Search in sources :

Example 1 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class DeployCmd method addResources.

protected void addResources(List<ResourceEntity> resources, DeploymentBuilderImpl deploymentBuilder) {
    DeploymentEntity deployment = deploymentBuilder.getDeployment();
    Map<String, ResourceEntity> existingResources = deployment.getResources();
    for (ResourceEntity resource : resources) {
        String resourceName = resource.getName();
        if (existingResources != null && existingResources.containsKey(resourceName)) {
            String message = String.format("Cannot add resource with id '%s' and name '%s' from " + "deployment with id '%s' to new deployment because the new deployment contains " + "already a resource with same name.", resource.getId(), resourceName, resource.getDeploymentId());
            throw new NotValidException(message);
        }
        ByteArrayInputStream inputStream = new ByteArrayInputStream(resource.getBytes());
        deploymentBuilder.addInputStream(resourceName, inputStream);
    }
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) NotValidException(org.camunda.bpm.engine.exception.NotValidException) ByteArrayInputStream(java.io.ByteArrayInputStream) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)

Example 2 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class DeployCmd method getResourcesByDeploymentId.

protected List<ResourceEntity> getResourcesByDeploymentId(Set<String> deploymentIds, CommandContext commandContext) {
    List<ResourceEntity> result = new ArrayList<ResourceEntity>();
    if (!deploymentIds.isEmpty()) {
        DeploymentManager deploymentManager = commandContext.getDeploymentManager();
        for (String deploymentId : deploymentIds) {
            DeploymentEntity deployment = deploymentManager.findDeploymentById(deploymentId);
            Map<String, ResourceEntity> resources = deployment.getResources();
            Collection<ResourceEntity> values = resources.values();
            result.addAll(values);
        }
    }
    return result;
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) DeploymentManager(org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager) ResourceEntity(org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity) ArrayList(java.util.ArrayList)

Example 3 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class DeployCmd method setDeploymentName.

protected void setDeploymentName(String deploymentId, DeploymentBuilderImpl deploymentBuilder, CommandContext commandContext) {
    if (deploymentId != null && !deploymentId.isEmpty()) {
        DeploymentManager deploymentManager = commandContext.getDeploymentManager();
        DeploymentEntity deployment = deploymentManager.findDeploymentById(deploymentId);
        deploymentBuilder.getDeployment().setName(deployment.getName());
    }
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity) DeploymentManager(org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager)

Example 4 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity in project camunda-bpm-platform by camunda.

the class DeployCmd method initDeployment.

protected DeploymentEntity initDeployment() {
    DeploymentEntity deployment = deploymentBuilder.getDeployment();
    deployment.setDeploymentTime(ClockUtil.getCurrentTime());
    return deployment;
}
Also used : DeploymentEntity(org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity)

Example 5 with DeploymentEntity

use of org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity 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)

Aggregations

DeploymentEntity (org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity)11 DeploymentManager (org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager)3 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)2 NotValidException (org.camunda.bpm.engine.exception.NotValidException)2 Before (org.junit.Before)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ProcessApplicationRegistration (org.camunda.bpm.application.ProcessApplicationRegistration)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 CmmnHandlerContext (org.camunda.bpm.engine.impl.cmmn.handler.CmmnHandlerContext)1 DefaultCmmnElementHandlerRegistry (org.camunda.bpm.engine.impl.cmmn.handler.DefaultCmmnElementHandlerRegistry)1 CmmnTransform (org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransform)1 CmmnTransformer (org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformer)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1 ProcessApplicationDeploymentImpl (org.camunda.bpm.engine.impl.persistence.entity.ProcessApplicationDeploymentImpl)1