Search in sources :

Example 1 with ProcessDefinitionInfoCacheObject

use of org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject in project Activiti by Activiti.

the class GetProcessDefinitionInfoCmd method execute.

public ObjectNode execute(CommandContext commandContext) {
    if (processDefinitionId == null) {
        throw new ActivitiIllegalArgumentException("process definition id is null");
    }
    ObjectNode resultNode = null;
    DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
    // make sure the process definition is in the cache
    deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
    ProcessDefinitionInfoCacheObject definitionInfoCacheObject = deploymentManager.getProcessDefinitionInfoCache().get(processDefinitionId);
    if (definitionInfoCacheObject != null) {
        resultNode = definitionInfoCacheObject.getInfoNode();
    }
    return resultNode;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionInfoCacheObject(org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject)

Example 2 with ProcessDefinitionInfoCacheObject

use of org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject in project Activiti by Activiti.

the class Context method getProcessDefinitionInfoNode.

protected static ObjectNode getProcessDefinitionInfoNode(String processDefinitionId) {
    Map<String, ObjectNode> bpmnOverrideMap = getBpmnOverrideContext();
    if (bpmnOverrideMap.containsKey(processDefinitionId) == false) {
        ProcessDefinitionInfoCacheObject cacheObject = getProcessEngineConfiguration().getDeploymentManager().getProcessDefinitionInfoCache().get(processDefinitionId);
        addBpmnOverrideElement(processDefinitionId, cacheObject.getInfoNode());
    }
    return getBpmnOverrideContext().get(processDefinitionId);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessDefinitionInfoCacheObject(org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject)

Example 3 with ProcessDefinitionInfoCacheObject

use of org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject in project Activiti by Activiti.

the class BpmnDeployer method addDefinitionInfoToCache.

protected void addDefinitionInfoToCache(ProcessDefinitionEntity processDefinition, ProcessEngineConfigurationImpl processEngineConfiguration, CommandContext commandContext) {
    if (processEngineConfiguration.isEnableProcessDefinitionInfoCache() == false) {
        return;
    }
    DeploymentManager deploymentManager = processEngineConfiguration.getDeploymentManager();
    ProcessDefinitionInfoEntityManager definitionInfoEntityManager = commandContext.getProcessDefinitionInfoEntityManager();
    ObjectMapper objectMapper = commandContext.getProcessEngineConfiguration().getObjectMapper();
    ProcessDefinitionInfoEntity definitionInfoEntity = definitionInfoEntityManager.findProcessDefinitionInfoByProcessDefinitionId(processDefinition.getId());
    ObjectNode infoNode = null;
    if (definitionInfoEntity != null && definitionInfoEntity.getInfoJsonId() != null) {
        byte[] infoBytes = definitionInfoEntityManager.findInfoJsonById(definitionInfoEntity.getInfoJsonId());
        if (infoBytes != null) {
            try {
                infoNode = (ObjectNode) objectMapper.readTree(infoBytes);
            } catch (Exception e) {
                throw new ActivitiException("Error deserializing json info for process definition " + processDefinition.getId());
            }
        }
    }
    ProcessDefinitionInfoCacheObject definitionCacheObject = new ProcessDefinitionInfoCacheObject();
    if (definitionInfoEntity == null) {
        definitionCacheObject.setRevision(0);
    } else {
        definitionCacheObject.setId(definitionInfoEntity.getId());
        definitionCacheObject.setRevision(definitionInfoEntity.getRevision());
    }
    if (infoNode == null) {
        infoNode = objectMapper.createObjectNode();
    }
    definitionCacheObject.setInfoNode(infoNode);
    deploymentManager.getProcessDefinitionInfoCache().add(processDefinition.getId(), definitionCacheObject);
}
Also used : ProcessDefinitionInfoEntityManager(org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntityManager) ActivitiException(org.activiti.engine.ActivitiException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinitionInfoEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntity) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionInfoCacheObject(org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject)

Aggregations

ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ProcessDefinitionInfoCacheObject (org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject)3 DeploymentManager (org.activiti.engine.impl.persistence.deploy.DeploymentManager)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ProcessDefinitionInfoEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntity)1 ProcessDefinitionInfoEntityManager (org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntityManager)1