use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class ProcessInstanceResourceRepository method create.
@Override
public <S extends T> S create(S resource) {
checkFilter(resource, true);
String processDefinitionKey = resource.getProcessDefinitionKey();
String businessKey = resource.getBusinessKey();
String tenantId = resource.getTenantId();
Map<String, Object> variables = resourceMapper.mapToVariables(resource);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId(processDefinitionKey, businessKey, variables, tenantId);
applyUpdates(processInstance, resource);
return (S) findOne(processInstance.getId(), new QuerySpec(getResourceClass()));
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class ProcessInstanceResourceRepository method save.
@Override
public <S extends T> S save(S resource) {
checkFilter(resource, true);
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(resource.getId()).includeProcessVariables().singleResult();
if (processInstance == null) {
throw new ResourceNotFoundException(resource.getId());
}
checkFilter(processInstance, false);
checkActivate(processInstance, resource);
Map<String, Object> variables = resourceMapper.mapToVariables(resource);
runtimeService.setVariables(processInstance.getId(), variables);
applyUpdates(processInstance, resource);
return (S) findOne(processInstance.getId(), new QuerySpec(getResourceClass()));
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class ProcessInstanceResourceRepository method delete.
@Override
public void delete(String id) {
T resource = findOne(id, new QuerySpec(getResourceClass()));
checkFilter(resource, false);
runtimeService.deleteProcessInstance(id, null);
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class TaskResourceRepository method delete.
@Override
public void delete(String id) {
T resource = findOne(id, new QuerySpec(getResourceClass()));
checkFilter(resource, false);
taskService.deleteTask(id);
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class ApprovalIntTest method verifyApprovalStarted.
private ApproveTask verifyApprovalStarted(Schedule schedule) {
// check approval process started
ResourceList<ScheduleApprovalProcessInstance> scheduleApprovals = approvalRepo.findAll(new QuerySpec(ScheduleApprovalProcessInstance.class));
Assert.assertEquals(1, scheduleApprovals.size());
checkOpenApproval(schedule, scheduleApprovals.get(0));
// check relationship from resource to approval process
ScheduleApprovalProcessInstance scheduleApproval = approvalRelRepo.findOneTarget(schedule.getId().toString(), "approval", new QuerySpec(ScheduleApprovalProcessInstance.class));
checkOpenApproval(schedule, scheduleApproval);
// check relationship from approval process to task
ApproveTask approveTask = processTaskRepo.findOneTarget(scheduleApprovals.get(0).getId(), "approveTask", new QuerySpec(ApproveTask.class));
Assert.assertNotNull(approveTask);
// check task created
QuerySpec taskQuery = new QuerySpec(ApproveTask.class);
taskQuery.includeRelation(Arrays.asList("form"));
ResourceList<ApproveTask> tasks = taskRepo.findAll(taskQuery);
Assert.assertEquals(1, tasks.size());
ApproveTask task = tasks.get(0);
checkApproveTaskCreated(schedule, task);
// check search for task by process
QuerySpec querySpec = new QuerySpec(ApproveTask.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("processInstance", "id"), FilterOperator.EQ, scheduleApproval.getId()));
ResourceList<ApproveTask> results = taskRepo.findAll(querySpec);
Assert.assertEquals(1, results.size());
Assert.assertEquals(scheduleApproval.getId(), results.get(0).getProcessInstanceId());
return task;
}
Aggregations