use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class TaskDetailPanel method initProcessLink.
protected void initProcessLink() {
if (task.getProcessInstanceId() != null) {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
Button showProcessInstanceButton = new Button(i18nManager.getMessage(Messages.TASK_PART_OF_PROCESS, getProcessDisplayName(processDefinition)));
showProcessInstanceButton.addStyleName(Reindeer.BUTTON_LINK);
showProcessInstanceButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
viewManager.showMyProcessInstancesPage(task.getProcessInstanceId());
}
});
centralLayout.addComponent(showProcessInstanceButton);
addEmptySpace(centralLayout);
}
}
use of org.activiti.engine.repository.ProcessDefinition 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.repository.ProcessDefinition in project Activiti by Activiti.
the class MyProcessInstancesListQuery method getProcessDefinition.
protected ProcessDefinition getProcessDefinition(String id) {
ProcessDefinition processDefinition = cachedProcessDefinitions.get(id);
if (processDefinition == null) {
processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
cachedProcessDefinitions.put(id, processDefinition);
}
return processDefinition;
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class MyProcessInstancesListQuery method createItem.
protected ProcessInstanceItem createItem(HistoricProcessInstance processInstance) {
ProcessInstanceItem item = new ProcessInstanceItem();
item.addItemProperty("id", new ObjectProperty<String>(processInstance.getId(), String.class));
ProcessDefinition processDefinition = getProcessDefinition(processInstance.getProcessDefinitionId());
String itemName = getProcessDisplayName(processDefinition) + " (" + processInstance.getId() + ")" + (processInstance.getBusinessKey() != null ? processInstance.getBusinessKey() : "");
item.addItemProperty("name", new ObjectProperty<String>(itemName, String.class));
return item;
}
use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testTaskOperationsFailAfterProcessInstanceSuspend.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskOperationsFailAfterProcessInstanceSuspend() {
// Start a new process instance with one task
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertNotNull(task);
// Suspend the process instance
runtimeService.suspendProcessInstanceById(processInstance.getId());
// Completing the task should fail
try {
taskService.complete(task.getId());
fail("It is not allowed to complete a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Claiming the task should fail
try {
taskService.claim(task.getId(), "jos");
fail("It is not allowed to claim a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Setting variable on the task should fail
try {
taskService.setVariable(task.getId(), "someVar", "someValue");
fail("It is not allowed to set a variable on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Setting variable on the task should fail
try {
taskService.setVariableLocal(task.getId(), "someVar", "someValue");
fail("It is not allowed to set a variable on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Setting variables on the task should fail
try {
HashMap<String, String> variables = new HashMap<String, String>();
variables.put("varOne", "one");
variables.put("varTwo", "two");
taskService.setVariables(task.getId(), variables);
fail("It is not allowed to set variables on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Setting variables on the task should fail
try {
HashMap<String, String> variables = new HashMap<String, String>();
variables.put("varOne", "one");
variables.put("varTwo", "two");
taskService.setVariablesLocal(task.getId(), variables);
fail("It is not allowed to set variables on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Removing variable on the task should fail
try {
taskService.removeVariable(task.getId(), "someVar");
fail("It is not allowed to remove a variable on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Removing variable on the task should fail
try {
taskService.removeVariableLocal(task.getId(), "someVar");
fail("It is not allowed to remove a variable on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Removing variables on the task should fail
try {
taskService.removeVariables(task.getId(), Arrays.asList("one", "two"));
fail("It is not allowed to remove variables on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Removing variables on the task should fail
try {
taskService.removeVariablesLocal(task.getId(), Arrays.asList("one", "two"));
fail("It is not allowed to remove variables on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Adding candidate groups on the task should fail
try {
taskService.addCandidateGroup(task.getId(), "blahGroup");
fail("It is not allowed to add a candidate group on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Adding candidate users on the task should fail
try {
taskService.addCandidateUser(task.getId(), "blahUser");
fail("It is not allowed to add a candidate user on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Adding candidate users on the task should fail
try {
taskService.addGroupIdentityLink(task.getId(), "blahGroup", IdentityLinkType.CANDIDATE);
fail("It is not allowed to add a candidate user on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Adding an identity link on the task should fail
try {
taskService.addUserIdentityLink(task.getId(), "blahUser", IdentityLinkType.OWNER);
fail("It is not allowed to add an identityLink on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Adding a comment on the task should fail
try {
taskService.addComment(task.getId(), processInstance.getId(), "test comment");
fail("It is not allowed to add a comment on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Adding an attachment on the task should fail
try {
taskService.createAttachment("text", task.getId(), processInstance.getId(), "testName", "testDescription", "http://test.com");
fail("It is not allowed to add an attachment on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Set an assignee on the task should fail
try {
taskService.setAssignee(task.getId(), "mispiggy");
fail("It is not allowed to set an assignee on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Set an owner on the task should fail
try {
taskService.setOwner(task.getId(), "kermit");
fail("It is not allowed to set an owner on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
// Set priority on the task should fail
try {
taskService.setPriority(task.getId(), 99);
fail("It is not allowed to set a priority on a task of a suspended process instance");
} catch (ActivitiException e) {
// This is good
}
}
Aggregations