forked from fli-iam/shanoir-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fli-iam#2388-automatic executions - back
- Loading branch information
1 parent
6b4f1b2
commit d8bbcb3
Showing
9 changed files
with
294 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
...ng-datasets/src/main/java/org/shanoir/ng/vip/planning/controller/PlannedExecutionApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.shanoir.ng.vip.planning.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.shanoir.ng.shared.exception.EntityNotFoundException; | ||
import org.shanoir.ng.shared.exception.RestServiceException; | ||
import org.shanoir.ng.shared.exception.SecurityException; | ||
import org.shanoir.ng.vip.planning.model.PlannedExecution; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/* | ||
Planned execution are VIP execution atuomatically applied after an import. | ||
*/ | ||
@Tag(name = "plannedexecution", description = "the planned execution API") | ||
@RequestMapping("/vip/execution/planned") | ||
public interface PlannedExecutionApi { | ||
|
||
@Operation(summary = "Get list of existing planned executions for the given study_id", description = "Returns the list of existing planned executions for the given study id", tags={ }) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "successful response, returns the list of planned executions"), | ||
@ApiResponse(responseCode = "403", description = "forbidden"), | ||
@ApiResponse(responseCode = "500", description = "unexpected error"), | ||
@ApiResponse(responseCode = "503", description = "Internal error")}) | ||
@GetMapping(value = "/byStudy/{studyId}", | ||
produces = { "application/json", "application/octet-stream" }) | ||
ResponseEntity<List<PlannedExecution>> getPlannedExecutionsByStudyId(@Parameter(description = "The study Id", required=true) @PathVariable("studyId") Long studyId) throws IOException, RestServiceException, EntityNotFoundException, SecurityException; | ||
|
||
@Operation(summary = "Create a new PlannedExecution entity", description = "Creates a new planned execution", tags={ }) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "201", description = "successful creation"), | ||
@ApiResponse(responseCode = "403", description = "forbidden"), | ||
@ApiResponse(responseCode = "500", description = "unexpected error"), | ||
@ApiResponse(responseCode = "503", description = "Internal error")}) | ||
@PostMapping(value = "/create", consumes = "application/json", produces = "application/json") | ||
ResponseEntity<PlannedExecution> createPlannedExecution(@RequestBody PlannedExecution plannedExecution) throws IOException, RestServiceException, SecurityException; | ||
|
||
@Operation(summary = "Delete a PlannedExecution entity", description = "Deletes the planned execution by its ID", tags={ }) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "successful deletion"), | ||
@ApiResponse(responseCode = "403", description = "forbidden"), | ||
@ApiResponse(responseCode = "404", description = "not found"), | ||
@ApiResponse(responseCode = "500", description = "unexpected error"), | ||
@ApiResponse(responseCode = "503", description = "Internal error")}) | ||
@DeleteMapping(value = "/delete/{executionId}") | ||
ResponseEntity<Void> deletePlannedExecution(@Parameter(description = "The PlannedExecution Id", required=true) @PathVariable("executionId") Long executionId) throws IOException, RestServiceException, EntityNotFoundException, SecurityException; | ||
|
||
@Operation(summary = "Get a PlannedExecution entity by ID", description = "Returns a planned execution by its ID", tags={ }) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "successful response, returns the planned execution"), | ||
@ApiResponse(responseCode = "403", description = "forbidden"), | ||
@ApiResponse(responseCode = "404", description = "not found"), | ||
@ApiResponse(responseCode = "500", description = "unexpected error"), | ||
@ApiResponse(responseCode = "503", description = "Internal error")}) | ||
@GetMapping(value = "/{executionId}", produces = "application/json") | ||
ResponseEntity<PlannedExecution> getPlannedExecutionById(@Parameter(description = "The PlannedExecution Id", required=true) @PathVariable("executionId") Long executionId) throws IOException, RestServiceException, EntityNotFoundException, SecurityException; | ||
|
||
@Operation(summary = "Update a PlannedExecution entity", description = "Updates the existing planned execution by its ID", tags={ }) | ||
@ApiResponses(value = { | ||
@ApiResponse(responseCode = "200", description = "successful update, returns the updated planned execution"), | ||
@ApiResponse(responseCode = "403", description = "forbidden"), | ||
@ApiResponse(responseCode = "404", description = "not found"), | ||
@ApiResponse(responseCode = "500", description = "unexpected error"), | ||
@ApiResponse(responseCode = "503", description = "Internal error")}) | ||
@PostMapping(value = "/update/{executionId}", consumes = "application/json", produces = "application/json") | ||
ResponseEntity<PlannedExecution> updatePlannedExecution(@RequestBody PlannedExecution plannedExecution) throws IOException, RestServiceException, EntityNotFoundException, SecurityException; | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...s/src/main/java/org/shanoir/ng/vip/planning/controller/PlannedExecutionApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.shanoir.ng.vip.planning.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Parameter; | ||
import org.shanoir.ng.shared.exception.EntityNotFoundException; | ||
import org.shanoir.ng.shared.exception.RestServiceException; | ||
import org.shanoir.ng.shared.exception.SecurityException; | ||
import org.shanoir.ng.vip.planning.model.PlannedExecution; | ||
import org.shanoir.ng.vip.planning.service.PlannedExecutionService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/* | ||
Planned execution are VIP execution atuomatically applied after an import. | ||
*/ | ||
@Service | ||
public class PlannedExecutionApiController implements PlannedExecutionApi { | ||
|
||
@Autowired | ||
PlannedExecutionService plannedExecutionService; | ||
|
||
@Override | ||
public ResponseEntity<List<PlannedExecution>> getPlannedExecutionsByStudyId (@Parameter(description = "The study Id", required=true) @PathVariable("studyId") Long studyId) { | ||
List<PlannedExecution> executions = this.plannedExecutionService.findByStudyId(studyId); | ||
return new ResponseEntity<>(executions, HttpStatus.OK); | ||
} | ||
|
||
@Override | ||
public ResponseEntity<PlannedExecution> createPlannedExecution(@RequestBody PlannedExecution plannedExecution) throws IOException, RestServiceException, SecurityException { | ||
return new ResponseEntity<PlannedExecution>(this.plannedExecutionService.save(plannedExecution), HttpStatus.OK); | ||
} | ||
@Override | ||
public ResponseEntity<Void> deletePlannedExecution(@Parameter(description = "The PlannedExecution Id", required=true) @PathVariable("executionId") Long executionId) throws IOException, RestServiceException, EntityNotFoundException, SecurityException{ | ||
this.plannedExecutionService.delete(executionId); | ||
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); | ||
} | ||
@Override | ||
public ResponseEntity<PlannedExecution> getPlannedExecutionById(@Parameter(description = "The PlannedExecution Id", required=true) @PathVariable("executionId") Long executionId) throws IOException, RestServiceException, EntityNotFoundException, SecurityException{ | ||
return new ResponseEntity<PlannedExecution>(this.plannedExecutionService.findById(executionId), HttpStatus.OK); | ||
} | ||
@Override | ||
public ResponseEntity<PlannedExecution> updatePlannedExecution(@RequestBody PlannedExecution plannedExecution) throws IOException, RestServiceException, EntityNotFoundException, SecurityException { | ||
return new ResponseEntity<PlannedExecution>(this.plannedExecutionService.update(plannedExecution), HttpStatus.OK); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...sets/src/main/java/org/shanoir/ng/vip/planning/repository/PlannedExecutionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.shanoir.ng.vip.planning.repository; | ||
|
||
import org.shanoir.ng.vip.planning.model.PlannedExecution; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface PlannedExecutionRepository extends CrudRepository<PlannedExecution, Long> { | ||
|
||
List<PlannedExecution> findByStudyId(Long studyId); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...g-datasets/src/main/java/org/shanoir/ng/vip/planning/service/PlannedExecutionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.shanoir.ng.vip.planning.service; | ||
|
||
import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; | ||
import org.shanoir.ng.vip.planning.model.PlannedExecution; | ||
import org.springframework.scheduling.annotation.Async; | ||
|
||
import java.util.List; | ||
|
||
public interface PlannedExecutionService { | ||
|
||
@Async | ||
void checkForPlannedExecutions(List<DatasetAcquisition> createdAcquisitions); | ||
|
||
List<PlannedExecution> findByStudyId(Long studyId); | ||
|
||
PlannedExecution update(PlannedExecution plannedExecution); | ||
|
||
PlannedExecution findById(Long executionId); | ||
|
||
void delete(Long executionId); | ||
|
||
PlannedExecution save(PlannedExecution plannedExecution); | ||
} |
Oops, something went wrong.