Search in sources :

Example 6 with Request

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());
}
Also used : TaskInfo(cern.modesti.workflow.task.TaskInfo) Request(cern.modesti.request.Request)

Example 7 with Request

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);
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) User(cern.modesti.user.User) Authentication(org.springframework.security.core.Authentication) Request(cern.modesti.request.Request) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken)

Example 8 with 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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) Request(cern.modesti.request.Request) Resource(org.springframework.hateoas.Resource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Request

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());
}
Also used : TaskInfo(cern.modesti.workflow.task.TaskInfo) Request(cern.modesti.request.Request)

Example 10 with Request

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);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) Task(org.activiti.engine.task.Task) Execution(org.activiti.engine.runtime.Execution) Request(cern.modesti.request.Request) Resource(org.springframework.hateoas.Resource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Request (cern.modesti.request.Request)19 Resource (org.springframework.hateoas.Resource)5 ArrayList (java.util.ArrayList)4 ResponseEntity (org.springframework.http.ResponseEntity)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 Point (cern.modesti.point.Point)3 RequestImpl (cern.modesti.request.RequestImpl)3 TaskInfo (cern.modesti.workflow.task.TaskInfo)3 User (cern.modesti.user.User)2 Task (org.activiti.engine.task.Task)2 Link (org.springframework.hateoas.Link)2 RequestProvider (cern.modesti.plugin.RequestProvider)1 UnsupportedRequestException (cern.modesti.plugin.UnsupportedRequestException)1 RequestParseResult (cern.modesti.request.upload.parser.RequestParseResult)1 ObjectDiffer (de.danielbechler.diff.ObjectDiffer)1 DiffNode (de.danielbechler.diff.node.DiffNode)1 HashMap (java.util.HashMap)1 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)1 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)1 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)1