use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class GetDeploymentProcessDiagramCmd method execute.
public InputStream execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
String deploymentId = processDefinition.getDeploymentId();
String resourceName = processDefinition.getDiagramResourceName();
if (resourceName == null) {
log.info("Resource name is null! No process diagram stream exists.");
return null;
} else {
InputStream processDiagramStream = new GetDeploymentResourceCmd(deploymentId, resourceName).execute(commandContext);
return processDiagramStream;
}
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class GetRenderedStartFormCmd method execute.
public Object execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("Process Definition '" + processDefinitionId + "' not found", ProcessDefinition.class);
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
if (startFormHandler == null) {
return null;
}
FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
if (formEngine == null) {
throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
}
StartFormData startForm = startFormHandler.createStartFormData(processDefinition);
return formEngine.renderStartForm(startForm);
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class NeedsActiveProcessDefinitionCmd method execute.
public T execute(CommandContext commandContext) {
DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
if (deploymentManager.isProcessDefinitionSuspended(processDefinitionId)) {
throw new ActivitiException("Cannot execute operation because process definition '" + processDefinition.getName() + "' (id=" + processDefinition.getId() + ") is supended");
}
return execute(commandContext, processDefinition);
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class DeploymentManager method getBpmnModelById.
public BpmnModel getBpmnModelById(String processDefinitionId) {
if (processDefinitionId == null) {
throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
}
// first try the cache
BpmnModel bpmnModel = bpmnModelCache.get(processDefinitionId);
if (bpmnModel == null) {
ProcessDefinitionEntity processDefinition = findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Fetch the resource
String resourceName = processDefinition.getResourceName();
ResourceEntity resource = Context.getCommandContext().getResourceEntityManager().findResourceByDeploymentIdAndResourceName(processDefinition.getDeploymentId(), resourceName);
if (resource == null) {
if (Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(processDefinition.getDeploymentId()) == null) {
throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " + processDefinition.getDeploymentId(), Deployment.class);
} else {
throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + processDefinition.getDeploymentId() + "'", InputStream.class);
}
}
// Convert the bpmn 2.0 xml to a bpmn model
BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
bpmnModel = bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false);
bpmnModelCache.add(processDefinition.getId(), bpmnModel);
}
return bpmnModel;
}
use of org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity in project Activiti by Activiti.
the class DeploymentManager method findDeployedProcessDefinitionByKeyAndVersion.
public ProcessDefinitionEntity findDeployedProcessDefinitionByKeyAndVersion(String processDefinitionKey, Integer processDefinitionVersion) {
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) Context.getCommandContext().getProcessDefinitionEntityManager().findProcessDefinitionByKeyAndVersion(processDefinitionKey, processDefinitionVersion);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no processes deployed with key = '" + processDefinitionKey + "' and version = '" + processDefinitionVersion + "'", ProcessDefinition.class);
}
processDefinition = resolveProcessDefinition(processDefinition);
return processDefinition;
}
Aggregations