@@ 130-140 (lines=11) @@ | ||
127 | return resultService.getResultsForClass(userContext.getTenantId(), userContext.getOrgId(), classId); |
|
128 | } |
|
129 | ||
130 | @RequestMapping(value= "/{classId:.+}/results", method = RequestMethod.POST) |
|
131 | public ResponseEntity<?> postResult(JwtAuthenticationToken token, @PathVariable final String classId, @RequestBody Result result, @RequestParam(value="check", required=false) Boolean check) { |
|
132 | UserContext userContext = (UserContext) token.getPrincipal(); |
|
133 | Result savedResult = this.resultService.save(userContext.getTenantId(), userContext.getOrgId(), classId, result, (check == null) ? true : check); |
|
134 | HttpHeaders httpHeaders = new HttpHeaders(); |
|
135 | httpHeaders.setLocation(ServletUriComponentsBuilder.fromCurrentRequest() |
|
136 | .path("/{id}") |
|
137 | .buildAndExpand(savedResult.getSourcedId()) |
|
138 | .toUri()); |
|
139 | ||
140 | return new ResponseEntity<>(savedResult, httpHeaders, HttpStatus.CREATED); |
|
141 | } |
|
142 | ||
143 | @RequestMapping(value= "/{classId:.+}/enrollments", method = RequestMethod.POST) |
|
@@ 143-151 (lines=9) @@ | ||
140 | return new ResponseEntity<>(savedResult, httpHeaders, HttpStatus.CREATED); |
|
141 | } |
|
142 | ||
143 | @RequestMapping(value= "/{classId:.+}/enrollments", method = RequestMethod.POST) |
|
144 | public ResponseEntity<?> postEnrollment(JwtAuthenticationToken token, @PathVariable final String classId, @RequestBody Enrollment enrollment, @RequestParam(value="check", required=false) Boolean check) { |
|
145 | UserContext userContext = (UserContext) token.getPrincipal(); |
|
146 | Enrollment savedEnrollment = enrollmentService.save(userContext.getTenantId(), userContext.getOrgId(), classId, enrollment, (check == null) ? true : check); |
|
147 | HttpHeaders httpHeaders = new HttpHeaders(); |
|
148 | httpHeaders.setLocation(ServletUriComponentsBuilder |
|
149 | .fromCurrentRequest().path("/{id}") |
|
150 | .buildAndExpand(savedEnrollment.getSourcedId()).toUri()); |
|
151 | return new ResponseEntity<>(savedEnrollment, httpHeaders, HttpStatus.CREATED); |
|
152 | } |
|
153 | ||
154 | @RequestMapping(value = "/{classId:.+}/enrollments", method = RequestMethod.GET) |
|
@@ 113-121 (lines=9) @@ | ||
110 | return resultService.getResultsForlineItem(userContext.getTenantId(), userContext.getOrgId(), lineitemId); |
|
111 | } |
|
112 | ||
113 | @RequestMapping(value= "/{classId:.+}/lineitems", method = RequestMethod.POST) |
|
114 | public ResponseEntity<?> postLineItem(JwtAuthenticationToken token, @RequestBody LineItem lineItem, @RequestParam(value="check", required=false) Boolean check) { |
|
115 | UserContext userContext = (UserContext) token.getPrincipal(); |
|
116 | LineItem savedLineItem = this.lineItemService.save(userContext.getTenantId(), userContext.getOrgId(), lineItem, (check == null) ? true : check); |
|
117 | HttpHeaders httpHeaders = new HttpHeaders(); |
|
118 | httpHeaders.setLocation(ServletUriComponentsBuilder |
|
119 | .fromCurrentRequest().path("/{id}") |
|
120 | .buildAndExpand(savedLineItem.getSourcedId()).toUri()); |
|
121 | return new ResponseEntity<>(savedLineItem, httpHeaders, HttpStatus.CREATED); |
|
122 | } |
|
123 | ||
124 | @RequestMapping(value = "/{classId:.+}/results", method = RequestMethod.GET) |
@@ 65-74 (lines=10) @@ | ||
62 | * @param check boolean to know if it has to check duplicates (takes more time) |
|
63 | * @return HTTP Response |
|
64 | */ |
|
65 | @RequestMapping(method = RequestMethod.POST) |
|
66 | public ResponseEntity<?> post(JwtAuthenticationToken token, @RequestBody User user, @RequestParam(value="check", required=false) Boolean check) { |
|
67 | UserContext userContext = (UserContext) token.getPrincipal(); |
|
68 | User savedUser = this.userService.save(userContext.getTenantId(), userContext.getOrgId(), user, (check == null) ? true : check); |
|
69 | HttpHeaders httpHeaders = new HttpHeaders(); |
|
70 | httpHeaders.setLocation(ServletUriComponentsBuilder |
|
71 | .fromCurrentRequest().path("/{id}") |
|
72 | .buildAndExpand(savedUser.getSourcedId()).toUri()); |
|
73 | ||
74 | return new ResponseEntity<>(savedUser, httpHeaders, HttpStatus.CREATED); |
|
75 | } |
|
76 | ||
77 | /** |
@@ 63-69 (lines=7) @@ | ||
60 | * @return LineItem the object created |
|
61 | * @throws IllegalArgumentException |
|
62 | */ |
|
63 | @RequestMapping(method = RequestMethod.POST) |
|
64 | public ResponseEntity<?> postLineItem(JwtAuthenticationToken token, @RequestBody LineItem lineItem, @RequestParam(value="check", required=false) Boolean check) throws IllegalArgumentException { |
|
65 | UserContext userContext = (UserContext) token.getPrincipal(); |
|
66 | LineItem savedLineItem = this.lineItemService.save(userContext.getTenantId(), userContext.getOrgId(), lineItem, (check == null) ? true : check); |
|
67 | HttpHeaders httpHeaders = new HttpHeaders(); |
|
68 | httpHeaders.setLocation(ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(savedLineItem.getSourcedId()).toUri()); |
|
69 | return new ResponseEntity<>(savedLineItem, httpHeaders, HttpStatus.CREATED); |
|
70 | } |
|
71 | ||
72 | } |