use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class GetRenderedTaskFormCmd method execute.
public Object execute(CommandContext commandContext) {
TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
if (task == null) {
throw new ActivitiObjectNotFoundException("Task '" + taskId + "' not found", Task.class);
}
if (task.getTaskDefinition() == null) {
throw new ActivitiException("Task form definition for '" + taskId + "' not found");
}
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
if (taskFormHandler == null) {
return null;
}
FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
if (formEngine == null) {
throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
}
TaskFormData taskForm = taskFormHandler.createTaskForm(task);
return formEngine.renderTaskForm(taskForm);
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class GetStartFormCmd method execute.
public StartFormData execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
if (startFormHandler == null) {
throw new ActivitiException("No startFormHandler defined in process '" + processDefinitionId + "'");
}
return startFormHandler.createStartFormData(processDefinition);
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class HistoricTaskInstanceTest method testHistoricIdentityLinksOnTask.
@Deployment
public void testHistoricIdentityLinksOnTask() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("historicIdentityLinks");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
// Set additional identity-link not coming from process
taskService.addUserIdentityLink(task.getId(), "gonzo", "customUseridentityLink");
assertEquals(4, taskService.getIdentityLinksForTask(task.getId()).size());
// Check historic identity-links when task is still active
List<HistoricIdentityLink> historicIdentityLinks = historyService.getHistoricIdentityLinksForTask(task.getId());
assertEquals(4, historicIdentityLinks.size());
// Validate all links
boolean foundCandidateUser = false, foundCandidateGroup = false, foundAssignee = false, foundCustom = false;
for (HistoricIdentityLink link : historicIdentityLinks) {
assertEquals(task.getId(), link.getTaskId());
if (link.getGroupId() != null) {
assertEquals("sales", link.getGroupId());
foundCandidateGroup = true;
} else {
if (link.getType().equals("candidate")) {
assertEquals("fozzie", link.getUserId());
foundCandidateUser = true;
} else if (link.getType().equals("assignee")) {
assertEquals("kermit", link.getUserId());
foundAssignee = true;
} else if (link.getType().equals("customUseridentityLink")) {
assertEquals("gonzo", link.getUserId());
foundCustom = true;
}
}
}
assertTrue(foundAssignee);
assertTrue(foundCandidateGroup);
assertTrue(foundCandidateUser);
assertTrue(foundCustom);
// Now complete the task and check if links are still there
taskService.complete(task.getId());
assertEquals(4, historyService.getHistoricIdentityLinksForTask(task.getId()).size());
// After deleting historic task, exception should be thrown when trying to get links
historyService.deleteHistoricTaskInstance(task.getId());
try {
historyService.getHistoricIdentityLinksForTask(task.getId()).size();
fail("Exception expected");
} catch (ActivitiObjectNotFoundException aonfe) {
assertEquals(HistoricTaskInstance.class, aonfe.getObjectClass());
}
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class ProcessInstanceMigrationTest method testSetProcessDefinitionVersionNonExistingPD.
@Deployment(resources = { TEST_PROCESS })
public void testSetProcessDefinitionVersionNonExistingPD() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("receiveTask");
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
try {
commandExecutor.execute(new SetProcessDefinitionVersionCmd(pi.getId(), 23));
fail("ActivitiException expected");
} catch (ActivitiObjectNotFoundException ae) {
assertTextPresent("no processes deployed with key = 'receiveTask' and version = '23'", ae.getMessage());
assertEquals(ProcessDefinition.class, ae.getObjectClass());
}
}
use of org.activiti.engine.ActivitiObjectNotFoundException in project Activiti by Activiti.
the class TaskServiceTest method testClaimUnexistingTaskId.
public void testClaimUnexistingTaskId() {
User user = identityService.newUser("user");
identityService.saveUser(user);
try {
taskService.claim("unexistingtaskid", user.getId());
fail("ActivitiException expected");
} catch (ActivitiObjectNotFoundException ae) {
assertTextPresent("Cannot find task with id unexistingtaskid", ae.getMessage());
assertEquals(Task.class, ae.getObjectClass());
}
identityService.deleteUser(user.getId());
}
Aggregations