Search in sources :

Example 61 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class BpmnDeployer method persistProcessDefinitionsAndAuthorizations.

/**
 * Saves each process definition.  It is assumed that the deployment is new, the definitions
 * have never been saved before, and that they have all their values properly set up.
 */
protected void persistProcessDefinitionsAndAuthorizations(ParsedDeployment parsedDeployment) {
    CommandContext commandContext = Context.getCommandContext();
    ProcessDefinitionEntityManager processDefinitionManager = commandContext.getProcessDefinitionEntityManager();
    for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
        processDefinitionManager.insert(processDefinition, false);
        bpmnDeploymentHelper.addAuthorizationsForNewProcessDefinition(parsedDeployment.getProcessModelForProcessDefinition(processDefinition), processDefinition);
    }
}
Also used : ProcessDefinitionEntityManager(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 62 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class BpmnDeployer method setProcessDefinitionDiagramNames.

// 
// /**
// * Creates new diagrams for process definitions if the deployment is new, the process definition in
// * question supports it, and the engine is configured to make new diagrams.
// *
// * When this method creates a new diagram, it also persists it via the ResourceEntityManager
// * and adds it to the resources of the deployment.
// */
// protected void createAndPersistNewDiagramsIfNeeded(ParsedDeployment parsedDeployment) {
// 
// final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
// final DeploymentEntity deploymentEntity = parsedDeployment.getDeployment();
// 
// final ResourceEntityManager resourceEntityManager = processEngineConfiguration.getResourceEntityManager();
// 
// for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
// if (processDefinitionDiagramHelper.shouldCreateDiagram(processDefinition, deploymentEntity)) {
// ResourceEntity resource = processDefinitionDiagramHelper.createDiagramForProcessDefinition(
// processDefinition, parsedDeployment.getBpmnParseForProcessDefinition(processDefinition));
// if (resource != null) {
// resourceEntityManager.insert(resource, false);
// deploymentEntity.addResource(resource);  // now we'll find it if we look for the diagram name later.
// }
// }
// }
// }
/**
 * Updates all the process definition entities to have the correct diagram resource name.  Must
 * be called after createAndPersistNewDiagramsAsNeeded to ensure that any newly-created diagrams
 * already have their resources attached to the deployment.
 */
protected void setProcessDefinitionDiagramNames(ParsedDeployment parsedDeployment) {
    Map<String, ResourceEntity> resources = parsedDeployment.getDeployment().getResources();
    for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
        String diagramResourceName = ResourceNameUtil.getProcessDiagramResourceNameFromDeployment(processDefinition, resources);
        processDefinition.setDiagramResourceName(diagramResourceName);
    }
}
Also used : ResourceEntity(org.activiti.engine.impl.persistence.entity.ResourceEntity) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 63 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class BpmnDeployer method makeProcessDefinitionsConsistentWithPersistedVersions.

/**
 * Loads the persisted version of each process definition and set values on the in-memory
 * version to be consistent.
 */
protected void makeProcessDefinitionsConsistentWithPersistedVersions(ParsedDeployment parsedDeployment) {
    for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
        ProcessDefinitionEntity persistedProcessDefinition = bpmnDeploymentHelper.getPersistedInstanceOfProcessDefinition(processDefinition);
        if (persistedProcessDefinition != null) {
            processDefinition.setId(persistedProcessDefinition.getId());
            processDefinition.setVersion(persistedProcessDefinition.getVersion());
            processDefinition.setAppVersion(persistedProcessDefinition.getAppVersion());
            processDefinition.setSuspensionState(persistedProcessDefinition.getSuspensionState());
        }
    }
}
Also used : ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 64 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class MybatisProcessDefinitionDataManager method findProcessDefinitionByKeyAndVersionAndTenantId.

@Override
@SuppressWarnings("unchecked")
public ProcessDefinitionEntity findProcessDefinitionByKeyAndVersionAndTenantId(String processDefinitionKey, Integer processDefinitionVersion, String tenantId) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("processDefinitionKey", processDefinitionKey);
    params.put("processDefinitionVersion", processDefinitionVersion);
    params.put("tenantId", tenantId);
    List<ProcessDefinitionEntity> results = getDbSqlSession().selectList("selectProcessDefinitionsByKeyAndVersionAndTenantId", params);
    if (results.size() == 1) {
        return results.get(0);
    } else if (results.size() > 1) {
        throw new ActivitiException("There are " + results.size() + " process definitions with key = '" + processDefinitionKey + "' and version = '" + processDefinitionVersion + "'.");
    }
    return null;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) HashMap(java.util.HashMap) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 65 with ProcessDefinitionEntity

use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.

the class MybatisProcessDefinitionDataManager method findProcessDefinitionByKeyAndVersion.

@Override
public ProcessDefinitionEntity findProcessDefinitionByKeyAndVersion(String processDefinitionKey, Integer processDefinitionVersion) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("processDefinitionKey", processDefinitionKey);
    params.put("processDefinitionVersion", processDefinitionVersion);
    List<ProcessDefinitionEntity> results = getDbSqlSession().selectList("selectProcessDefinitionsByKeyAndVersion", params);
    if (results.size() == 1) {
        return results.get(0);
    } else if (results.size() > 1) {
        throw new ActivitiException("There are " + results.size() + " process definitions with key = '" + processDefinitionKey + "' and version = '" + processDefinitionVersion + "'.");
    }
    return null;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) HashMap(java.util.HashMap) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)67 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)12 ActivitiException (org.activiti.engine.ActivitiException)11 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)9 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)8 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)8 BpmnModel (org.activiti.bpmn.model.BpmnModel)7 InputStream (java.io.InputStream)6 ArrayList (java.util.ArrayList)6 RepositoryService (org.activiti.engine.RepositoryService)6 ProcessDefinitionEntityManager (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager)6 StreamResource (com.vaadin.terminal.StreamResource)5 HashMap (java.util.HashMap)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)5 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)4 TaskDefinition (org.activiti.engine.impl.task.TaskDefinition)4 Deployment (org.activiti.engine.test.Deployment)4 Embedded (com.vaadin.ui.Embedded)3 Label (com.vaadin.ui.Label)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)3