use of org.activiti.engine.ActivitiObjectNotFoundException 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.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class DeleteCommentCmd method execute.
public Void execute(CommandContext commandContext) {
CommentEntityManager commentManager = commandContext.getCommentEntityManager();
if (commentId != null) {
// Delete for an individual comment
Comment comment = commentManager.findComment(commentId);
if (comment == null) {
throw new ActivitiObjectNotFoundException("Comment with id '" + commentId + "' doesn't exists.", Comment.class);
}
commentManager.delete((CommentEntity) comment);
} else {
// Delete all comments on a task of process
ArrayList<Comment> comments = new ArrayList<Comment>();
if (processInstanceId != null) {
comments.addAll(commentManager.findCommentsByProcessInstanceId(processInstanceId));
}
if (taskId != null) {
comments.addAll(commentManager.findCommentsByTaskId(taskId));
}
for (Comment comment : comments) {
commentManager.delete((CommentEntity) comment);
}
}
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class DeleteHistoricProcessInstanceCmd method execute.
public Object execute(CommandContext commandContext) {
if (processInstanceId == null) {
throw new ActivitiIllegalArgumentException("processInstanceId is null");
}
// Check if process instance is still running
HistoricProcessInstance instance = commandContext.getHistoricProcessInstanceEntityManager().findHistoricProcessInstance(processInstanceId);
if (instance == null) {
throw new ActivitiObjectNotFoundException("No historic process instance found with id: " + processInstanceId, HistoricProcessInstance.class);
}
if (instance.getEndTime() == null) {
throw new ActivitiException("Process instance is still running, cannot delete historic process instance: " + processInstanceId);
}
commandContext.getHistoricProcessInstanceEntityManager().deleteHistoricProcessInstanceById(processInstanceId);
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class AbstractSetProcessInstanceStateCmd method execute.
public Void execute(CommandContext commandContext) {
if (executionId == null) {
throw new ActivitiIllegalArgumentException("ProcessInstanceId cannot be null.");
}
ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
if (executionEntity == null) {
throw new ActivitiObjectNotFoundException("Cannot find processInstance for id '" + executionId + "'.", Execution.class);
}
if (!executionEntity.isProcessInstanceType()) {
throw new ActivitiException("Cannot set suspension state for execution '" + executionId + "': not a process instance.");
}
SuspensionStateUtil.setSuspensionState(executionEntity, getNewState());
// All child executions are suspended
List<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByProcessInstanceId(executionId);
for (ExecutionEntity childExecution : childExecutions) {
if (!childExecution.getId().equals(executionId)) {
SuspensionStateUtil.setSuspensionState(childExecution, getNewState());
}
}
// All tasks are suspended
List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByProcessInstanceId(executionId);
for (TaskEntity taskEntity : tasks) {
SuspensionStateUtil.setSuspensionState(taskEntity, getNewState());
}
return null;
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class AddIdentityLinkForProcessDefinitionCmd method execute.
public Void execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
}
processDefinition.addIdentityLink(userId, groupId);
return null;
}
Aggregations