use of cern.modesti.request.Request in project modesti by jlsalmon.
the class BaseIntegrationTest method assertTaskNameAndRequestStatus.
public void assertTaskNameAndRequestStatus(String requestId, String taskName, String status) {
TaskInfo task = taskService.getActiveTask(requestId);
assertNotNull(task);
assertEquals(taskName, task.getName());
Request request = requestService.findOneByRequestId(requestId);
assertEquals(status, request.getStatus());
}
use of cern.modesti.request.Request in project modesti by jlsalmon.
the class UserTaskAssignmentHandler method notify.
@Override
public void notify(DelegateTask task) {
log.debug(format("handling assignment of task %s", task.getName()));
// Save the new assignee to the request object
Request request = requestService.findOneByRequestId((String) task.getVariable("requestId"));
if (task.getEventName().equals(TaskListener.EVENTNAME_ASSIGNMENT)) {
User assignee = userService.findOneByUsername(task.getAssignee());
String username = assignee == null ? null : assignee.getUsername();
request.setAssignee(username);
} else if (task.getEventName().equals(TaskListener.EVENTNAME_DELETE)) {
request.setAssignee(null);
}
// service account (which has admin privileges).
if (userService.getCurrentUser() == null) {
Authentication authentication = new UsernamePasswordAuthenticationToken("modesti", null, Collections.singletonList(new SimpleGrantedAuthority("modesti-administrators")));
SecurityContextHolder.getContext().setAuthentication(authentication);
}
requestService.save(request);
}
use of cern.modesti.request.Request in project modesti by jlsalmon.
the class CoreValidationController method validate.
@RequestMapping(value = "/api/requests/{id}/validate", method = POST)
public HttpEntity<Resource<Request>> validate(@PathVariable("id") String id) {
Request request = requestService.findOneByRequestId(id);
if (request == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
validationService.validateRequest(request);
Resource<Request> resource = new Resource<>(request);
return new ResponseEntity<>(resource, HttpStatus.OK);
}
use of cern.modesti.request.Request in project modesti by jlsalmon.
the class BaseIntegrationTest method assertTaskNameAndRequestStatus.
public void assertTaskNameAndRequestStatus(String requestId, String taskName, String status) {
TaskInfo task = taskService.getActiveTask(requestId);
assertNotNull(task);
assertEquals(taskName, task.getName());
Request request = requestService.findOneByRequestId(requestId);
assertEquals(status, request.getStatus());
}
use of cern.modesti.request.Request in project modesti by jlsalmon.
the class SignalController method getSignal.
@RequestMapping(value = "/{name}", method = GET)
public ResponseEntity<Resource<SignalInfo>> getSignal(@PathVariable("id") String id, @PathVariable("name") String name) {
Request request = getRequest(id);
if (request == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
List<Task> tasks = taskService.createTaskQuery().processInstanceBusinessKey(request.getRequestId()).list();
for (Task task : tasks) {
Execution execution = runtimeService.createExecutionQuery().executionId(task.getExecutionId()).signalEventSubscriptionName(name).singleResult();
if (execution != null) {
Resource<SignalInfo> resource = new Resource<>(new SignalInfo(name));
resource.add(linkTo(methodOn(SignalController.class).getSignal(id, resource.getContent().getName())).withSelfRel());
return new ResponseEntity<>(resource, HttpStatus.OK);
}
}
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
Aggregations