use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class BusinessProcess method startProcessByName.
@Deprecated
public ProcessInstance startProcessByName(String string, Map<String, Object> variables) {
if (Context.getCommandContext() != null) {
throw new ActivitiCdiException("Cannot use startProcessByName in an activiti command.");
}
ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult();
if (definition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class);
}
Map<String, Object> cachedVariables = getAndClearCachedVariables();
cachedVariables.putAll(variables);
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), cachedVariables);
if (!instance.isEnded()) {
setExecution(instance);
}
return instance;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class BusinessProcess method startProcessByName.
@Deprecated
public ProcessInstance startProcessByName(String string) {
if (Context.getCommandContext() != null) {
throw new ActivitiCdiException("Cannot use startProcessByName in an activiti command.");
}
ProcessDefinition definition = processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionName(string).singleResult();
if (definition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for name: " + string, ProcessDefinition.class);
}
ProcessInstance instance = processEngine.getRuntimeService().startProcessInstanceById(definition.getId(), getAndClearCachedVariables());
if (!instance.isEnded()) {
setExecution(instance);
}
return instance;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class AbstractSetProcessDefinitionStateCmd method findProcessDefinition.
protected List<ProcessDefinitionEntity> findProcessDefinition(CommandContext commandContext) {
// we don't need to do an extra database fetch and we can simply return it, wrapped in a list
if (processDefinitionEntity != null) {
return Arrays.asList(processDefinitionEntity);
}
// Validation of input parameters
if (processDefinitionId == null && processDefinitionKey == null) {
throw new ActivitiIllegalArgumentException("Process definition id or key cannot be null");
}
List<ProcessDefinitionEntity> processDefinitionEntities = new ArrayList<ProcessDefinitionEntity>();
ProcessDefinitionEntityManager processDefinitionManager = commandContext.getProcessDefinitionEntityManager();
if (processDefinitionId != null) {
ProcessDefinitionEntity processDefinitionEntity = processDefinitionManager.findProcessDefinitionById(processDefinitionId);
if (processDefinitionEntity == null) {
throw new ActivitiObjectNotFoundException("Cannot find process definition for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
processDefinitionEntities.add(processDefinitionEntity);
} else {
ProcessDefinitionQueryImpl query = new ProcessDefinitionQueryImpl(commandContext).processDefinitionKey(processDefinitionKey);
if (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) {
query.processDefinitionWithoutTenantId();
} else {
query.processDefinitionTenantId(tenantId);
}
List<ProcessDefinition> processDefinitions = query.list();
if (processDefinitions.isEmpty()) {
throw new ActivitiException("Cannot find process definition for key '" + processDefinitionKey + "'");
}
for (ProcessDefinition processDefinition : processDefinitions) {
processDefinitionEntities.add((ProcessDefinitionEntity) processDefinition);
}
}
return processDefinitionEntities;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class GetExecutionVariableInstancesCmd method execute.
public Map<String, VariableInstance> execute(CommandContext commandContext) {
// Verify existance of execution
if (executionId == null) {
throw new ActivitiIllegalArgumentException("executionId is null");
}
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
}
Map<String, VariableInstance> variables = null;
if (variableNames == null || variableNames.isEmpty()) {
// Fetch all
if (isLocal) {
variables = execution.getVariableInstancesLocal();
} else {
variables = execution.getVariableInstances();
}
} else {
// Fetch specific collection of variables
if (isLocal) {
variables = execution.getVariableInstancesLocal(variableNames, false);
} else {
variables = execution.getVariableInstances(variableNames, false);
}
}
if (variables != null && locale != null) {
for (Entry<String, VariableInstance> entry : variables.entrySet()) {
String variableName = entry.getKey();
VariableInstance variableEntity = entry.getValue();
String localizedName = null;
String localizedDescription = null;
ObjectNode languageNode = Context.getLocalizationElementProperties(locale, variableName, execution.getProcessDefinitionId(), withLocalizationFallback);
if (languageNode != null) {
JsonNode nameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME);
if (nameNode != null) {
localizedName = nameNode.asText();
}
JsonNode descriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION);
if (descriptionNode != null) {
localizedDescription = descriptionNode.asText();
}
}
variableEntity.setLocalizedName(localizedName);
variableEntity.setLocalizedDescription(localizedDescription);
}
}
return variables;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class GetHistoricIdentityLinksForTaskCmd method getLinksForTask.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected List<HistoricIdentityLink> getLinksForTask(CommandContext commandContext) {
HistoricTaskInstanceEntity task = commandContext.getHistoricTaskInstanceEntityManager().findHistoricTaskInstanceById(taskId);
if (task == null) {
throw new ActivitiObjectNotFoundException("No historic task exists with the given id: " + taskId, HistoricTaskInstance.class);
}
List<HistoricIdentityLink> identityLinks = (List) commandContext.getHistoricIdentityLinkEntityManager().findHistoricIdentityLinksByTaskId(taskId);
// Similar to GetIdentityLinksForTask, return assignee and owner as identity link
if (task.getAssignee() != null) {
HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
identityLink.setUserId(task.getAssignee());
identityLink.setTaskId(task.getId());
identityLink.setType(IdentityLinkType.ASSIGNEE);
identityLinks.add(identityLink);
}
if (task.getOwner() != null) {
HistoricIdentityLinkEntity identityLink = new HistoricIdentityLinkEntity();
identityLink.setTaskId(task.getId());
identityLink.setUserId(task.getOwner());
identityLink.setType(IdentityLinkType.OWNER);
identityLinks.add(identityLink);
}
return identityLinks;
}
Aggregations