diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8392507a72..e83537b1db 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -21,10 +21,10 @@ jobs: packages: write contents: read steps: - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 17 - name: Check out the repo uses: actions/checkout@v3 diff --git a/docker-compose/database/db-changes/datasets/0030_create_dataset_property.sql b/docker-compose/database/db-changes/datasets/0030_create_dataset_property.sql new file mode 100644 index 0000000000..ae9f115efb --- /dev/null +++ b/docker-compose/database/db-changes/datasets/0030_create_dataset_property.sql @@ -0,0 +1,13 @@ +CREATE TABLE `dataset_property` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `name` varchar(255) DEFAULT NULL, + `value` varchar(255) DEFAULT NULL, + `dataset_id` bigint(20) DEFAULT NULL, + `dataset_processing_id` bigint(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FK1mcyt0h60808jmj3shlvge9c8` (`dataset_id`), + KEY `FKl09g6qevg8filjycsylycbdxw` (`dataset_processing_id`), + CONSTRAINT `FK1mcyt0h60808jmj3shlvge9c8` FOREIGN KEY (`dataset_id`) REFERENCES `dataset` (`id`), + CONSTRAINT `FKl09g6qevg8filjycsylycbdxw` FOREIGN KEY (`dataset_processing_id`) REFERENCES `dataset_processing` (`id`) +) + diff --git a/docker-compose/database/db-changes/datasets/0031_create_processing_resource.sql b/docker-compose/database/db-changes/datasets/0031_create_processing_resource.sql new file mode 100644 index 0000000000..e6b0bb9c6b --- /dev/null +++ b/docker-compose/database/db-changes/datasets/0031_create_processing_resource.sql @@ -0,0 +1,11 @@ +CREATE TABLE `processing_resource` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `resource_id` varchar(255) NOT NULL, + `dataset_id` bigint(20) DEFAULT NULL, + `processing_id` bigint(20) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `FK7971ykr4l94b3qgns4do405qe` (`dataset_id`), + KEY `FKtkm1ww8m49x3jdwdtocijhrha` (`processing_id`), + CONSTRAINT `FK7971ykr4l94b3qgns4do405qe` FOREIGN KEY (`dataset_id`) REFERENCES `dataset` (`id`), + CONSTRAINT `FKtkm1ww8m49x3jdwdtocijhrha` FOREIGN KEY (`processing_id`) REFERENCES `dataset_processing` (`id`) +) diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/ShanoirDatasetApplication.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/ShanoirDatasetApplication.java index febcd96921..ffe0f9000a 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/ShanoirDatasetApplication.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/ShanoirDatasetApplication.java @@ -14,6 +14,10 @@ package org.shanoir.ng; +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.databind.module.SimpleModule; +import io.swagger.v3.oas.annotations.OpenAPIDefinition; import org.shanoir.ng.shared.paging.PageSerializer; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -22,12 +26,6 @@ import org.springframework.data.web.config.EnableSpringDataWebSupport; import org.springframework.scheduling.annotation.EnableScheduling; -import com.fasterxml.jackson.core.Version; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.module.SimpleModule; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; - /** * Shanoir-NG microservice datasets application. */ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApi.java index a5695f1cf1..7b6e65bc6b 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApi.java @@ -1,8 +1,13 @@ package org.shanoir.ng.bids.controller; -import java.io.IOException; - +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 jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import org.shanoir.ng.bids.model.BidsElement; import org.shanoir.ng.shared.exception.RestServiceException; import org.springframework.http.ResponseEntity; @@ -12,13 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -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 jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; +import java.io.IOException; @Tag(name = "bids") @RequestMapping("/bids") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApiController.java index 5c5ef5d968..b91f320bed 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/bids/controller/BidsApiController.java @@ -1,21 +1,9 @@ package org.shanoir.ng.bids.controller; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.text.SimpleDateFormat; -import java.util.stream.Stream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - +import io.swagger.v3.oas.annotations.Parameter; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; - import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import org.shanoir.ng.bids.BidsDeserializer; @@ -35,7 +23,17 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; -import io.swagger.v3.oas.annotations.Parameter; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.SimpleDateFormat; +import java.util.stream.Stream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; @Controller public class BidsApiController implements BidsApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/amqp/RabbitMQDatasetsService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/amqp/RabbitMQDatasetsService.java index 973c7f98f6..5fabb49765 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/amqp/RabbitMQDatasetsService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/amqp/RabbitMQDatasetsService.java @@ -14,10 +14,8 @@ package org.shanoir.ng.configuration.amqp; -import java.io.IOException; -import java.util.*; - import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.bids.service.BIDSService; import org.shanoir.ng.dataset.dto.StudyStorageVolumeDTO; @@ -46,11 +44,8 @@ import org.slf4j.LoggerFactory; import org.springframework.amqp.AmqpRejectAndDontRequeueException; import org.springframework.amqp.core.ExchangeTypes; -import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Queue; -import org.springframework.amqp.rabbit.annotation.QueueBinding; -import org.springframework.amqp.rabbit.annotation.RabbitHandler; -import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.amqp.rabbit.annotation.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Component; @@ -59,7 +54,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.*; /** * RabbitMQ configuration. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/security/SecurityConfiguration.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/security/SecurityConfiguration.java index 3a6166859c..87b6d801a5 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/security/SecurityConfiguration.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/configuration/security/SecurityConfiguration.java @@ -14,10 +14,6 @@ package org.shanoir.ng.configuration.security; -import java.util.Collection; -import java.util.Map; -import java.util.stream.Collectors; - import org.shanoir.ng.dicom.web.StowRSMultipartRelatedRequestFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -40,6 +36,10 @@ import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; +import java.util.Collection; +import java.util.Map; +import java.util.stream.Collectors; + /** * Spring security configuration. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApi.java index 8aacbaeb15..1f631ae73e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApi.java @@ -15,15 +15,6 @@ package org.shanoir.ng.dataset.controler; -import java.io.IOException; - -import org.shanoir.ng.shared.exception.RestServiceException; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; - import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -32,6 +23,15 @@ import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; +import org.shanoir.ng.shared.exception.EntityNotFoundException; +import org.shanoir.ng.shared.exception.RestServiceException; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; + +import java.io.IOException; /** * @author Alae Es-saki @@ -51,6 +51,6 @@ public interface CarminDataApi { produces = { "application/json", "application/octet-stream" }, method = RequestMethod.GET) ResponseEntity getPath(@Parameter(name = "the complete path on which to request information. It can contain non-encoded slashes. Except for the \"exists\" action, any request on a non-existing path should return an error", required=true) @PathVariable("completePath") String completePath, @NotNull @Parameter(name = "The \"content\" action downloads the raw file. If the path points to a directory, a tarball of this directory is returned. The \"exists\" action returns a BooleanResponse object (see definition) indicating if the path exists or not. The \"properties\" action returns a Path object (see definition) with the path properties. The \"list\" action returns a DirectoryList object (see definition) with the properties of all the files of the directory (if the path is not a directory an error must be returned). The \"md5\" action is optional and returns a PathMd5 object (see definition)." ,required=true - ) @Valid @RequestParam(value = "action", required = true) String action, @Valid @RequestParam(value = "format", required = false, defaultValue = "dcm") final String format, HttpServletResponse response) throws IOException, RestServiceException; + ) @Valid @RequestParam(value = "action", required = true) String action, @Valid @RequestParam(value = "format", required = false, defaultValue = "dcm") final String format, HttpServletResponse response) throws IOException, RestServiceException, EntityNotFoundException; } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApiController.java index 3c65f90ede..edb02db4d7 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/CarminDataApiController.java @@ -15,10 +15,17 @@ package org.shanoir.ng.dataset.controler; -import java.io.IOException; - +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.dataset.service.DatasetDownloaderServiceImpl; +import org.shanoir.ng.processing.carmin.service.ProcessingResourceService; +import org.shanoir.ng.shared.exception.EntityNotFoundException; import org.shanoir.ng.shared.exception.RestServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -26,22 +33,32 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestParam; -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; +import java.io.IOException; +import java.util.List; @Controller public class CarminDataApiController implements CarminDataApi{ + private static final Logger LOG = LoggerFactory.getLogger(CarminDataApiController.class); + private static final String DCM = "dcm"; @Autowired private DatasetDownloaderServiceImpl datasetDownloaderService; + @Autowired + private ProcessingResourceService processingResourceService; + @Override - public ResponseEntity getPath(@Parameter(name = "the complete path on which to request information. It can contain non-encoded slashes. Except for the \"exists\" action, any request on a non-existing path should return an error", required=true) @PathVariable("completePath") String completePath, @NotNull @Parameter(name = "The \"content\" action downloads the raw file. If the path points to a directory, a tarball of this directory is returned. The \"exists\" action returns a BooleanResponse object (see definition) indicating if the path exists or not. The \"properties\" action returns a Path object (see definition) with the path properties. The \"list\" action returns a DirectoryList object (see definition) with the properties of all the files of the directory (if the path is not a directory an error must be returned). The \"md5\" action is optional and returns a PathMd5 object (see definition)." ,required=true - ) @Valid @RequestParam(value = "action", required = true, defaultValue = "content") String action, @Valid @RequestParam(value = "format", required = false, defaultValue = DCM) final String format, HttpServletResponse response) throws IOException, RestServiceException { + public ResponseEntity getPath( + @Parameter(name = "the complete path on which to request information. It can contain non-encoded slashes. Except for the \"exists\" action, any request on a non-existing path should return an error", + required=true) + @PathVariable("completePath") String completePath, + @NotNull @Parameter(name = "The \"content\" action downloads the raw file. If the path points to a directory, a tarball of this directory is returned. The \"exists\" action returns a BooleanResponse object (see definition) indicating if the path exists or not. The \"properties\" action returns a Path object (see definition) with the path properties. The \"list\" action returns a DirectoryList object (see definition) with the properties of all the files of the directory (if the path is not a directory an error must be returned). The \"md5\" action is optional and returns a PathMd5 object (see definition).", + required=true) + @Valid @RequestParam(value = "action", required = true, defaultValue = "content") String action, + @Valid @RequestParam(value = "format", required = false, defaultValue = DCM) final String format, + HttpServletResponse response) throws IOException, RestServiceException, EntityNotFoundException { // TODO implement those actions switch (action){ case "exists": @@ -49,12 +66,22 @@ public ResponseEntity getPath(@Parameter(name = "the complete path on which t case "md5": case "properties": return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); - case "content":{ - datasetDownloaderService.downloadDatasetById(Long.parseLong(completePath),null, format, response, true); + case "content": + + List datasets = this.processingResourceService.findDatasetsByResourceId(completePath); + + if(datasets.isEmpty()){ + LOG.error("No dataset found for resource id [{}]", completePath); + return new ResponseEntity(HttpStatus.BAD_REQUEST); + } + + datasetDownloaderService.massiveDownload(format, datasets, response, true); + return new ResponseEntity(HttpStatus.OK); - } } + return new ResponseEntity(HttpStatus.BAD_REQUEST); + } } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApi.java index a7cbc8b00e..742fc6dc37 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApi.java @@ -14,13 +14,16 @@ package org.shanoir.ng.dataset.controler; -import java.io.IOException; -import java.net.MalformedURLException; -import java.util.List; - +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 jakarta.mail.MessagingException; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import org.shanoir.ng.dataset.dto.DatasetAndProcessingsDTOInterface; import org.shanoir.ng.dataset.dto.DatasetDTO; -import org.shanoir.ng.dataset.dto.StudyStorageVolumeDTO; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.importer.dto.ProcessedDatasetImportJob; import org.shanoir.ng.shared.exception.EntityNotFoundException; @@ -32,24 +35,11 @@ import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; -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 jakarta.mail.MessagingException; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.List; @Tag(name = "dataset") @RequestMapping("/datasets") @@ -126,6 +116,17 @@ ResponseEntity updateDataset( @PreAuthorize("hasRole('ADMIN') or (hasAnyRole('EXPERT', 'USER') and @datasetSecurityService.hasRightOnDatasetAcquisition(#acquisitionId, 'CAN_SEE_ALL'))") ResponseEntity> findDatasetsByAcquisitionId(@Parameter(name = "id of the acquisition", required = true) @PathVariable("acquisitionId") Long acquisitionId); + @Operation(summary = "", description = "Returns a dataset list") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "found datasets"), + @ApiResponse(responseCode = "204", description = "no user found"), + @ApiResponse(responseCode = "401", description = "unauthorized"), + @ApiResponse(responseCode = "403", description = "forbidden"), + @ApiResponse(responseCode = "500", description = "unexpected error") }) + @GetMapping(value = "/examination/{examinationId}", produces = { "application/json" }) + @PreAuthorize("hasRole('ADMIN') or (hasAnyRole('EXPERT', 'USER') and @datasetSecurityService.hasRightOnExamination(#examinationId, 'CAN_SEE_ALL'))") + ResponseEntity> findDatasetsByExaminationId(@Parameter(name = "id of the examination", required = true) @PathVariable("examinationId") Long examinationId); + + @Operation(summary = "", description = "Returns a dataset list") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "found datasets"), @ApiResponse(responseCode = "204", description = "no user found"), @@ -263,6 +264,22 @@ void massiveDownloadByExaminationId( @Parameter(name = "Decide if you want to download dicom (dcm) or nifti (nii) files.") @Valid @RequestParam(value = "format", required = false, defaultValue="dcm") String format, HttpServletResponse response) throws RestServiceException, EntityNotFoundException, IOException; + @Operation(summary = "massiveDownloadDatasetsByAcquisitionId", description = "If exists, returns a zip file of the datasets corresponding to the given acquisition ID") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "zip file"), + @ApiResponse(responseCode = "401", description = "unauthorized"), + @ApiResponse(responseCode = "403", description = "forbidden"), + @ApiResponse(responseCode = "404", description = "no dataset found"), + @ApiResponse(responseCode = "500", description = "unexpected error") }) + @GetMapping(value = "/massiveDownloadByAcquisition") + @PreAuthorize("hasRole('ADMIN') or (hasAnyRole('EXPERT', 'USER') and @datasetSecurityService.hasRightOnDatasetAcquisition(#acquisitionId, 'CAN_DOWNLOAD'))") + void massiveDownloadByAcquisitionId( + @Parameter(name = "id of the acquisition", required=true) @Valid + @RequestParam(value = "acquisitionId", required = true) Long acquisitionId, + @Parameter(name = "Decide if you want to download dicom (dcm) or nifti (nii) files.") @Valid + @RequestParam(value = "format", required = false, defaultValue="dcm") String format, HttpServletResponse response) throws RestServiceException, EntityNotFoundException, IOException; + + @Operation(summary = "downloadStatistics", description = "Download statistics from the entire database") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "exported statistics"), @@ -290,7 +307,7 @@ ResponseEntity downloadStatistics( @ApiResponse(responseCode = "500", description = "unexpected error") }) @PostMapping(value = "/allById", produces = { "application/json" }) @PreAuthorize("hasRole('ADMIN') or (hasAnyRole('EXPERT', 'USER') and @datasetSecurityService.hasRightOnEveryDataset(#datasetIds, 'CAN_SEE_ALL'))") - ResponseEntity> findDatasetsByIds( + ResponseEntity> findDatasetsByIds( @RequestParam(value = "datasetIds", required = true) List datasetIds); } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApiController.java index 26596377ee..de3fbc1a74 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/controler/DatasetApiController.java @@ -15,29 +15,14 @@ package org.shanoir.ng.dataset.controler; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.annotation.PostConstruct; +import jakarta.mail.MessagingException; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.dataset.dto.DatasetAndProcessingsDTOInterface; import org.shanoir.ng.dataset.dto.DatasetDTO; -import org.shanoir.ng.dataset.dto.StudyStorageVolumeDTO; import org.shanoir.ng.dataset.dto.mapper.DatasetMapper; import org.shanoir.ng.dataset.modality.EegDataset; import org.shanoir.ng.dataset.modality.EegDatasetMapper; @@ -78,11 +63,14 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.annotation.PostConstruct; -import jakarta.mail.MessagingException; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Files; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; @Controller public class DatasetApiController implements DatasetApi { @@ -219,13 +207,25 @@ public ResponseEntity> findDatasets(final Pageable pageable) th } @Override - public ResponseEntity> findDatasetsByIds( + public ResponseEntity> findDatasetsByIds( @RequestParam(value = "datasetIds", required = true) List datasetIds) { List datasets = datasetService.findByIdIn(datasetIds); if (datasets.isEmpty()) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } - return new ResponseEntity<>(datasetMapper.datasetToDatasetDTO(datasets), HttpStatus.OK); + + List dtos = new ArrayList<>(); + for(Dataset dataset : datasets){ + if (dataset instanceof MrDataset) { + dtos.add(mrDatasetMapper.datasetToDatasetAndProcessingsDTO((MrDataset) dataset)); + } else if (dataset instanceof EegDataset) { + dtos.add(eegDatasetMapper.datasetToDatasetAndProcessingsDTO((EegDataset) dataset)); + } else { + dtos.add(datasetMapper.datasetToDatasetAndProcessingsDTO(dataset)); + } + } + + return new ResponseEntity<>(dtos, HttpStatus.OK); } @Override @@ -237,7 +237,17 @@ public ResponseEntity> findDatasetsByAcquisitionId(@Parameter(n return new ResponseEntity<>(datasetMapper.datasetToDatasetDTO(datasets), HttpStatus.OK); } } - + + @Override + public ResponseEntity> findDatasetsByExaminationId(Long examinationId) { + List datasets = datasetService.findByExaminationId(examinationId); + if (datasets.isEmpty()) { + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } else { + return new ResponseEntity<>(datasetMapper.datasetToDatasetDTO(datasets), HttpStatus.OK); + } + } + @Override public ResponseEntity> findDatasetsByStudycardId(@Parameter(name = "id of the studycard", required = true) @PathVariable("studycardId") Long studycardId) { List datasets = datasetService.findByStudycard(studycardId); @@ -339,10 +349,11 @@ public void massiveDownloadByDatasetIds( throw new RestServiceException( new ErrorModel(HttpStatus.FORBIDDEN.value(), "Please use a valid sets of dataset IDs.")); } + int size = datasetIds.size(); - if (datasetIds.size() > DATASET_LIMIT) { + if (size > DATASET_LIMIT) { throw new RestServiceException( - new ErrorModel(HttpStatus.FORBIDDEN.value(), "You can't download more than " + DATASET_LIMIT + " datasets.")); + new ErrorModel(HttpStatus.FORBIDDEN.value(), "This selection includes " + size + " datasets. You can't download more than " + DATASET_LIMIT + " datasets.")); } // STEP 1: Retrieve all datasets all in one with only the one we can see @@ -360,14 +371,15 @@ public void massiveDownloadByStudyId( // STEP 0: Check data integrity if (studyId == null) { throw new RestServiceException( - new ErrorModel(HttpStatus.FORBIDDEN.value(), "Please use a valid study ID.")); + new ErrorModel(HttpStatus.FORBIDDEN.value(), "Please use a valid study id.")); } // STEP 1: Retrieve all datasets all in one with only the one we can see List datasets = datasetService.findByStudyId(studyId); + int size = datasets.size(); - if (datasets.size() > DATASET_LIMIT) { + if (size > DATASET_LIMIT) { throw new RestServiceException( - new ErrorModel(HttpStatus.FORBIDDEN.value(), "This study has more than " + DATASET_LIMIT + " datasets, that is the limit. Please download them from solr search." )); + new ErrorModel(HttpStatus.FORBIDDEN.value(), "This study has " + size + " datasets. You can't download more than " + DATASET_LIMIT + " datasets." )); } datasetDownloaderService.massiveDownload(format, datasets, response, false); @@ -382,20 +394,41 @@ public void massiveDownloadByExaminationId( // STEP 0: Check data integrity if (examinationId == null) { throw new RestServiceException( - new ErrorModel(HttpStatus.FORBIDDEN.value(), "Please use a valid examination ID.")); + new ErrorModel(HttpStatus.FORBIDDEN.value(), "Please use a valid examination id.")); } // STEP 1: Retrieve all datasets all in one List datasets = datasetService.findByExaminationId(examinationId); - if (datasets.size() > DATASET_LIMIT) { + int size = datasets.size(); + + if (size > DATASET_LIMIT) { throw new RestServiceException( - new ErrorModel(HttpStatus.FORBIDDEN.value(), "You can't download more than " + DATASET_LIMIT + " datasets.")); + new ErrorModel(HttpStatus.FORBIDDEN.value(), "This examination has " + size + " datasets. You can't download more than " + DATASET_LIMIT + " datasets.")); } datasetDownloaderService.massiveDownload(format, datasets, response, true); } - /** + @Override + public void massiveDownloadByAcquisitionId(Long acquisitionId, String format, HttpServletResponse response) throws RestServiceException, EntityNotFoundException, IOException { + // STEP 0: Check data integrity + if (acquisitionId == null) { + throw new RestServiceException( + new ErrorModel(HttpStatus.FORBIDDEN.value(), "Please use a valid acquisition id.")); + } + // STEP 1: Retrieve all datasets all in one + List datasets = datasetService.findByAcquisition(acquisitionId); + int size = datasets.size(); + + if (size > DATASET_LIMIT) { + throw new RestServiceException( + new ErrorModel(HttpStatus.FORBIDDEN.value(), "This acquisition has " + size + " datasets. You can't download more than " + DATASET_LIMIT + " datasets.")); + } + + datasetDownloaderService.massiveDownload(format, datasets, response, true); + } + + /** * Zip a single file * * @param sourceFile diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/dto/mapper/DatasetMapper.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/dto/mapper/DatasetMapper.java index 33140ae2d2..356ca9f241 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/dto/mapper/DatasetMapper.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/dto/mapper/DatasetMapper.java @@ -24,6 +24,7 @@ import org.shanoir.ng.dataset.dto.DatasetDTO; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.datasetacquisition.dto.mapper.DatasetAcquisitionMapper; +import org.shanoir.ng.processing.dto.mapper.DatasetProcessingMapper; import org.shanoir.ng.shared.core.model.IdName; import org.shanoir.ng.shared.paging.PageImpl; import org.springframework.data.domain.Page; @@ -34,7 +35,7 @@ * @author msimon * */ -@Mapper(componentModel = "spring", uses = { DatasetMetadataMapper.class, DatasetProcessingMapper.class, DatasetAcquisitionMapper.class }) +@Mapper(componentModel = "spring", uses = { DatasetMetadataMapper.class, DatasetProcessingMapper.class, DatasetAcquisitionMapper.class }) @DecoratedWith(DatasetDecorator.class) public interface DatasetMapper { @@ -68,7 +69,7 @@ public interface DatasetMapper { DatasetAndProcessingsDTO datasetToDatasetAndProcessingsDTO(Dataset dataset); /** - * Map a @Dataset to a @DatasetDTO. + * Map a @Dataset list to a @DatasetDTO list. * * @param datasets * dataset. @@ -77,6 +78,7 @@ public interface DatasetMapper { @IterableMapping(qualifiedByName = "standard") List datasetToDatasetDTO(List datasets); + /** * Map a @Dataset to a @DatasetDTO. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/BidsDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/BidsDataset.java index 850a67febc..79c887cb70 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/BidsDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/BidsDataset.java @@ -1,7 +1,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; @Entity diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CalibrationDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CalibrationDataset.java index a3e3da8d69..e062794d75 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CalibrationDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CalibrationDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CtDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CtDataset.java index 69f68ab210..f35407f51d 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CtDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/CtDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/EegDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/EegDataset.java index b34a86f73f..1447fd8bec 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/EegDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/EegDataset.java @@ -14,18 +14,17 @@ package org.shanoir.ng.dataset.modality; -import java.util.List; - import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.OneToMany; - import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.eeg.model.Channel; import org.shanoir.ng.eeg.model.Event; +import java.util.List; + /** * EEG dataset. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/GenericDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/GenericDataset.java index 70f6f8b79f..9f6d9687be 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/GenericDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/GenericDataset.java @@ -1,7 +1,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; @Entity diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeasurementDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeasurementDataset.java index 57df32fc7f..70af02b803 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeasurementDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeasurementDataset.java @@ -1,7 +1,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; @Entity diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MegDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MegDataset.java index f1644d6dc3..d88e2f5c1b 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MegDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MegDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeshDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeshDataset.java index cc62af45d2..8320ac134a 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeshDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MeshDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDataset.java index be2b500428..564690d385 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDataset.java @@ -14,24 +14,14 @@ package org.shanoir.ng.dataset.modality; +import jakarta.persistence.*; +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.shared.model.*; + import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; -import jakarta.persistence.Transient; - -import org.shanoir.ng.dataset.model.Dataset; -import org.shanoir.ng.shared.model.DiffusionGradient; -import org.shanoir.ng.shared.model.EchoTime; -import org.shanoir.ng.shared.model.FlipAngle; -import org.shanoir.ng.shared.model.InversionTime; -import org.shanoir.ng.shared.model.RepetitionTime; - /** * MR dataset. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDatasetMetadata.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDatasetMetadata.java index 74417c9a7a..614069fdf4 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDatasetMetadata.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/MrDatasetMetadata.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.shared.core.model.AbstractEntity; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/ParameterQuantificationDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/ParameterQuantificationDataset.java index a0a1d8cc9e..7dd4b97a20 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/ParameterQuantificationDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/ParameterQuantificationDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/PetDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/PetDataset.java index c34e7bfbd7..25c0f5ba6e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/PetDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/PetDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/RegistrationDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/RegistrationDataset.java index 6ce395a3f8..e5c22b49fe 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/RegistrationDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/RegistrationDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SegmentationDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SegmentationDataset.java index a227a4e850..ddb3b64187 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SegmentationDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SegmentationDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SpectDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SpectDataset.java index f595b99756..fd6a3eb2d7 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SpectDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/SpectDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/StatisticalDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/StatisticalDataset.java index 9285a78169..6a5b833bbf 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/StatisticalDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/StatisticalDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/TemplateDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/TemplateDataset.java index d5b3c381f0..1f3664e560 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/TemplateDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/modality/TemplateDataset.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.modality; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/Dataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/Dataset.java index 38a1102437..cbec47e808 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/Dataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/Dataset.java @@ -14,49 +14,22 @@ package org.shanoir.ng.dataset.model; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; -import jakarta.persistence.Transient; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.As; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import jakarta.persistence.*; import org.apache.commons.lang3.StringUtils; -import org.shanoir.ng.dataset.modality.BidsDataset; -import org.shanoir.ng.dataset.modality.CalibrationDataset; -import org.shanoir.ng.dataset.modality.CtDataset; -import org.shanoir.ng.dataset.modality.EegDataset; -import org.shanoir.ng.dataset.modality.GenericDataset; -import org.shanoir.ng.dataset.modality.MeasurementDataset; -import org.shanoir.ng.dataset.modality.MegDataset; -import org.shanoir.ng.dataset.modality.MeshDataset; -import org.shanoir.ng.dataset.modality.MrDataset; -import org.shanoir.ng.dataset.modality.ParameterQuantificationDataset; -import org.shanoir.ng.dataset.modality.PetDataset; -import org.shanoir.ng.dataset.modality.RegistrationDataset; -import org.shanoir.ng.dataset.modality.SegmentationDataset; -import org.shanoir.ng.dataset.modality.SpectDataset; -import org.shanoir.ng.dataset.modality.StatisticalDataset; -import org.shanoir.ng.dataset.modality.TemplateDataset; +import org.shanoir.ng.dataset.modality.*; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.processing.model.DatasetProcessing; import org.shanoir.ng.shared.core.model.AbstractEntity; import org.shanoir.ng.shared.dateTime.LocalDateAnnotations; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeInfo.As; -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; /** * Dataset. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetExpression.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetExpression.java index c73aa5c75c..f31533b0de 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetExpression.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetExpression.java @@ -14,23 +14,16 @@ package org.shanoir.ng.dataset.model; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; -import jakarta.persistence.Transient; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.datasetfile.DatasetFile; import org.shanoir.ng.processing.model.DatasetProcessingType; import org.shanoir.ng.shared.core.model.AbstractEntity; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + /** * Dataset expression. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetMetadata.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetMetadata.java index eeac1bd880..6c36d83cdd 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetMetadata.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/DatasetMetadata.java @@ -15,7 +15,6 @@ package org.shanoir.ng.dataset.model; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.modality.ProcessedDatasetType; import org.shanoir.ng.shared.core.model.AbstractEntity; diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/GetPathResponse.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/GetPathResponse.java index 4dc02365ad..34281b2b52 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/GetPathResponse.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/GetPathResponse.java @@ -1,9 +1,9 @@ package org.shanoir.ng.dataset.model.carmin; -import java.util.Objects; - import org.springframework.validation.annotation.Validated; +import java.util.Objects; + /** * GetPathResponse */ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/Path.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/Path.java index 7e894b43ef..ff07526123 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/Path.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/Path.java @@ -1,9 +1,9 @@ package org.shanoir.ng.dataset.model.carmin; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; import org.springframework.validation.annotation.Validated; -import jakarta.validation.constraints.NotNull; import java.util.Objects; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/UploadData.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/UploadData.java index 71a4cd5e3f..002dca09de 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/UploadData.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/model/carmin/UploadData.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; +import jakarta.validation.constraints.NotNull; import org.springframework.validation.annotation.Validated; -import jakarta.validation.constraints.NotNull; import java.util.Objects; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepository.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepository.java index abbfd9599c..2e009dc41e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepository.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepository.java @@ -14,8 +14,6 @@ package org.shanoir.ng.dataset.repository; -import java.util.List; - import org.shanoir.ng.dataset.model.Dataset; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -24,6 +22,8 @@ import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; +import java.util.List; + public interface DatasetRepository extends PagingAndSortingRepository, CrudRepository, DatasetRepositoryCustom { Page findByDatasetAcquisitionExaminationStudy_IdIn(Iterable studyIds, Pageable pageable); diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepositoryImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepositoryImpl.java index 0e683aea25..bbca7ef57d 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepositoryImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/repository/DatasetRepositoryImpl.java @@ -1,14 +1,13 @@ package org.shanoir.ng.dataset.repository; -import java.util.List; - import jakarta.persistence.EntityManager; import jakarta.persistence.ParameterMode; import jakarta.persistence.PersistenceContext; import jakarta.persistence.StoredProcedureQuery; - import org.springframework.stereotype.Component; +import java.util.List; + @Component public class DatasetRepositoryImpl implements DatasetRepositoryCustom { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/security/DatasetSecurityService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/security/DatasetSecurityService.java index 2b08516899..3c4a35b827 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/security/DatasetSecurityService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/security/DatasetSecurityService.java @@ -14,16 +14,6 @@ package org.shanoir.ng.dataset.security; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - import org.shanoir.ng.dataset.dto.DatasetDTO; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.dataset.repository.DatasetRepository; @@ -53,6 +43,10 @@ import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; +import java.math.BigInteger; +import java.util.*; +import java.util.stream.Collectors; + @Service public class DatasetSecurityService { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetDownloaderServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetDownloaderServiceImpl.java index 3d04c3ea42..b4ff5e5d8c 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetDownloaderServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetDownloaderServiceImpl.java @@ -1,18 +1,6 @@ package org.shanoir.ng.dataset.service; -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.io.FileUtils; import org.joda.time.DateTime; import org.shanoir.ng.dataset.modality.EegDataset; @@ -41,7 +29,14 @@ import org.springframework.stereotype.Service; import org.springframework.util.StreamUtils; -import jakarta.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; @Service public class DatasetDownloaderServiceImpl { @@ -95,11 +90,7 @@ public void downloadDatasetById(Long datasetId, Long converterId, String format, Map> filesByAcquisitionId = new HashMap<>(); - String subjectName = "unknownSubject"; - Optional subjectOpt = subjectRepository.findById(dataset.getSubjectId()); - if (subjectOpt.isPresent()) { - subjectName = subjectOpt.get().getName(); - } + String subjectName = getSubjectName(dataset); String datasetName = subjectName + "_" + dataset.getId() + "_" + dataset.getName(); if (dataset.getUpdatedMetadata() != null && dataset.getUpdatedMetadata().getComment() != null) { @@ -204,7 +195,7 @@ public void downloadDatasetById(Long datasetId, Long converterId, String format, } } - public void massiveDownload(String format, List datasets, HttpServletResponse response, boolean withInputFile) throws EntityNotFoundException, RestServiceException, IOException { + public void massiveDownload(String format, List datasets, HttpServletResponse response, boolean withManifest) throws EntityNotFoundException, RestServiceException, IOException { // STEP 3: Get the data // Check rights on at least one of the datasets and filter the datasetIds list @@ -237,7 +228,7 @@ public void massiveDownload(String format, List datasets, HttpServletRe continue; } // Create a new folder organized by subject / examination - String subjectName = subjectRepository.findById(dataset.getSubjectId()).orElse(null).getName(); + String subjectName = getSubjectName(dataset); if (subjectName.contains(File.separator)) { subjectName = subjectName.replaceAll(File.separator, "_"); } @@ -274,7 +265,7 @@ public void massiveDownload(String format, List datasets, HttpServletRe List files = downloader.downloadDicomFilesForURLsAsZip(pathURLs, zipOutputStream, subjectName, dataset, datasetFilePath); datasetFiles.addAll(files); - if(withInputFile){ + if(withManifest){ filesByAcquisitionId.putIfAbsent(dataset.getDatasetAcquisition().getId(), new ArrayList<>()); filesByAcquisitionId.get(dataset.getDatasetAcquisition().getId()).addAll(datasetFiles); } @@ -346,4 +337,15 @@ public void massiveDownload(String format, List datasets, HttpServletRe } } + private String getSubjectName(Dataset dataset) { + String subjectName = "unknownSubject"; + if(dataset.getSubjectId() != null){ + Optional subjectOpt = subjectRepository.findById(dataset.getSubjectId()); + if (subjectOpt.isPresent()) { + subjectName = subjectOpt.get().getName(); + } + } + return subjectName; + } + } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetService.java index da89647e18..3f17093c5b 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetService.java @@ -14,12 +14,8 @@ package org.shanoir.ng.dataset.service; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import org.shanoir.ng.dataset.dto.VolumeByFormatDTO; import org.apache.solr.client.solrj.SolrServerException; +import org.shanoir.ng.dataset.dto.VolumeByFormatDTO; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.shared.exception.EntityNotFoundException; import org.shanoir.ng.shared.exception.ShanoirException; @@ -28,6 +24,10 @@ import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PreAuthorize; +import java.io.IOException; +import java.util.List; +import java.util.Map; + /** * Dataset service. * @@ -93,7 +93,7 @@ public interface DatasetService { */ @PreAuthorize("hasRole('ADMIN') or (hasRole('EXPERT') and @datasetSecurityService.hasUpdateRightOnDataset(#dataset, 'CAN_ADMINISTRATE'))") Dataset update(Dataset dataset) throws EntityNotFoundException; - + /** * Find every dataset * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetServiceImpl.java index 31b97f5893..7586f512f4 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/service/DatasetServiceImpl.java @@ -14,19 +14,12 @@ package org.shanoir.ng.dataset.service; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.transaction.Transactional; import org.apache.commons.io.FileUtils; -import org.shanoir.ng.dataset.dto.VolumeByFormatDTO; import org.apache.solr.client.solrj.SolrServerException; +import org.shanoir.ng.dataset.dto.VolumeByFormatDTO; import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.dataset.model.DatasetExpression; @@ -54,9 +47,15 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.util.UriUtils; -import jakarta.persistence.EntityManager; -import jakarta.persistence.PersistenceContext; -import jakarta.transaction.Transactional; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * Dataset service implementation. @@ -167,7 +166,7 @@ public Dataset update(final Dataset dataset) throws EntityNotFoundException { if (datasetDb == null) { throw new EntityNotFoundException(Dataset.class, dataset.getId()); } - updateDatasetValues(datasetDb, dataset); + this.updateDatasetValues(datasetDb, dataset); Dataset ds = repository.save(datasetDb); shanoirEventService.publishEvent(new ShanoirEvent(ShanoirEventType.UPDATE_DATASET_EVENT, ds.getId().toString(), KeycloakUtil.getTokenUserId(), "", ShanoirEvent.SUCCESS, datasetDb.getStudyId())); return ds; @@ -184,11 +183,7 @@ public Dataset update(final Dataset dataset) throws EntityNotFoundException { private Dataset updateDatasetValues(final Dataset datasetDb, final Dataset dataset) { datasetDb.setCreationDate(dataset.getCreationDate()); datasetDb.setId(dataset.getId()); - //datasetDb.setOriginMetadata(dataset.getOriginMetadata()); datasetDb.setProcessings(dataset.getProcessings()); - //datasetDb.setReferencedDatasetForSuperimposition(dataset.getReferencedDatasetForSuperimposition()); - //datasetDb.setReferencedDatasetForSuperimpositionChildrenList(dataset.getReferencedDatasetForSuperimpositionChildrenList()); - //datasetDb.setStudyId(dataset.getStudyId()); datasetDb.setSubjectId(dataset.getSubjectId()); if (dataset.getOriginMetadata().getId().equals(dataset.getUpdatedMetadata().getId())) { // Force creation of a new dataset metadata diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApi.java index f9cc7da876..720ba1e879 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApi.java @@ -14,13 +14,15 @@ package org.shanoir.ng.datasetacquisition.controler; -import java.io.IOException; -import java.util.List; - +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 jakarta.validation.Valid; import org.shanoir.ng.datasetacquisition.dto.DatasetAcquisitionDTO; import org.shanoir.ng.datasetacquisition.dto.DatasetAcquisitionDatasetsDTO; import org.shanoir.ng.datasetacquisition.dto.ExaminationDatasetAcquisitionDTO; -import org.shanoir.ng.importer.dto.EegImportJob; import org.shanoir.ng.importer.dto.ImportJob; import org.shanoir.ng.shared.exception.RestServiceException; import org.springframework.data.domain.Page; @@ -29,18 +31,9 @@ import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.*; -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 jakarta.validation.Valid; +import java.util.List; @Tag(name = "datasetacquisition", description = "the datasetacquisition API") public interface DatasetAcquisitionApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApiController.java index fbb9ce2852..e559748a68 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/controler/DatasetAcquisitionApiController.java @@ -14,12 +14,11 @@ package org.shanoir.ng.datasetacquisition.controler; -import java.io.IOException; -import java.util.Comparator; -import java.util.List; - -import org.shanoir.ng.utils.SecurityContextUtil; - +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.Valid; import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.datasetacquisition.dto.DatasetAcquisitionDTO; import org.shanoir.ng.datasetacquisition.dto.DatasetAcquisitionDatasetsDTO; @@ -35,12 +34,9 @@ import org.shanoir.ng.importer.service.ImporterService; import org.shanoir.ng.shared.configuration.RabbitMQConfiguration; import org.shanoir.ng.shared.error.FieldErrorMap; -import org.shanoir.ng.shared.exception.EntityNotFoundException; -import org.shanoir.ng.shared.exception.ErrorDetails; -import org.shanoir.ng.shared.exception.ErrorModel; -import org.shanoir.ng.shared.exception.RestServiceException; -import org.shanoir.ng.shared.exception.ShanoirException; +import org.shanoir.ng.shared.exception.*; import org.shanoir.ng.utils.KeycloakUtil; +import org.shanoir.ng.utils.SecurityContextUtil; import org.shanoir.ng.utils.usermock.WithMockKeycloakUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,12 +55,9 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.validation.Valid; +import java.io.IOException; +import java.util.Comparator; +import java.util.List; @Controller public class DatasetAcquisitionApiController implements DatasetAcquisitionApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/DatasetAcquisition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/DatasetAcquisition.java index dbbeb4f77c..4d1885987d 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/DatasetAcquisition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/DatasetAcquisition.java @@ -14,20 +14,14 @@ package org.shanoir.ng.datasetacquisition.model; -import java.time.LocalDate; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; -import jakarta.persistence.Transient; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.As; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.datasetacquisition.model.bids.BidsDatasetAcquisition; import org.shanoir.ng.datasetacquisition.model.ct.CtDatasetAcquisition; @@ -40,12 +34,8 @@ import org.shanoir.ng.shared.dateTime.LocalDateAnnotations; import org.shanoir.ng.studycard.model.StudyCard; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonSubTypes.Type; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeInfo.As; -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import java.time.LocalDate; +import java.util.List; /** * Dataset acquisition. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/GenericDatasetAcquisition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/GenericDatasetAcquisition.java index 7a101c1316..36299fdf9c 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/GenericDatasetAcquisition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/GenericDatasetAcquisition.java @@ -1,8 +1,7 @@ package org.shanoir.ng.datasetacquisition.model; -import jakarta.persistence.Entity; - import com.fasterxml.jackson.annotation.JsonTypeName; +import jakarta.persistence.Entity; @Entity @JsonTypeName("Generic") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/bids/BidsDatasetAcquisition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/bids/BidsDatasetAcquisition.java index 8f6d005d62..0faeea8fff 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/bids/BidsDatasetAcquisition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/bids/BidsDatasetAcquisition.java @@ -1,11 +1,9 @@ package org.shanoir.ng.datasetacquisition.model.bids; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.Entity; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; -import com.fasterxml.jackson.annotation.JsonTypeName; - @Entity @JsonTypeName("BIDS") public class BidsDatasetAcquisition extends DatasetAcquisition { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtDatasetAcquisition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtDatasetAcquisition.java index 6fa0f7aaf4..37df0b4441 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtDatasetAcquisition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtDatasetAcquisition.java @@ -14,14 +14,12 @@ package org.shanoir.ng.datasetacquisition.model.ct; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.OneToOne; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * CT dataset acquisition. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtProtocol.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtProtocol.java index ff34b03de8..029b36b7a9 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtProtocol.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/ct/CtProtocol.java @@ -14,14 +14,12 @@ package org.shanoir.ng.datasetacquisition.model.ct; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.OneToOne; - import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * CT protocol. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/eeg/EegDatasetAcquisition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/eeg/EegDatasetAcquisition.java index 85553b7690..0759aec611 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/eeg/EegDatasetAcquisition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/eeg/EegDatasetAcquisition.java @@ -1,11 +1,9 @@ package org.shanoir.ng.datasetacquisition.model.eeg; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.Entity; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * Dataset acquisition for EEG. * @author JCome diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrDatasetAcquisition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrDatasetAcquisition.java index 447df30de0..d9182a0eef 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrDatasetAcquisition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrDatasetAcquisition.java @@ -14,14 +14,12 @@ package org.shanoir.ng.datasetacquisition.model.mr; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.OneToOne; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * MR dataset acquisition. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocol.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocol.java index 7b0528fa40..8b3e92a7a7 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocol.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocol.java @@ -14,18 +14,12 @@ package org.shanoir.ng.datasetacquisition.model.mr; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; import org.shanoir.ng.shared.core.model.AbstractEntity; import org.shanoir.ng.shared.model.DiffusionGradient; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.List; /** * MR protocol. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolMetadata.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolMetadata.java index eaf90ea88f..eb0c04b6d2 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolMetadata.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolMetadata.java @@ -14,19 +14,12 @@ package org.shanoir.ng.datasetacquisition.model.mr; +import jakarta.persistence.*; +import org.shanoir.ng.shared.core.model.AbstractEntity; + import java.util.ArrayList; import java.util.List; -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.DiscriminatorType; -import jakarta.persistence.DiscriminatorValue; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; - -import org.shanoir.ng.shared.core.model.AbstractEntity; - /** * MR protocol. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolSCMetadata.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolSCMetadata.java index 446e8911ba..995fbac3e1 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolSCMetadata.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/mr/MrProtocolSCMetadata.java @@ -16,7 +16,6 @@ import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.modality.BidsDataType; @Entity diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetDatasetAcquisition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetDatasetAcquisition.java index c3f6d9acb6..1afa42f463 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetDatasetAcquisition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetDatasetAcquisition.java @@ -14,14 +14,12 @@ package org.shanoir.ng.datasetacquisition.model.pet; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.OneToOne; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * PET dataset acquisition. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetProtocol.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetProtocol.java index 9b080e6eaa..6df48c939b 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetProtocol.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/model/pet/PetProtocol.java @@ -14,15 +14,13 @@ package org.shanoir.ng.datasetacquisition.model.pet; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.OneToOne; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * PET protocol. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepository.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepository.java index 36674247ed..9715df004a 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepository.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepository.java @@ -14,14 +14,14 @@ package org.shanoir.ng.datasetacquisition.repository; -import java.util.List; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; +import java.util.List; + /** * Repository for dataset acquisition. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryCustom.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryCustom.java index 5a57a825eb..cffcfa18fc 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryCustom.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryCustom.java @@ -1,12 +1,12 @@ package org.shanoir.ng.datasetacquisition.repository; -import java.util.List; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.util.Pair; +import java.util.List; + public interface DatasetAcquisitionRepositoryCustom { Page findPageByStudyCenterOrStudyIdIn(Iterable> studyCenterIds, Iterable studyIds, Pageable pageable); diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryImpl.java index dc5dbc6381..4ba46f3b7d 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/repository/DatasetAcquisitionRepositoryImpl.java @@ -1,7 +1,8 @@ package org.shanoir.ng.datasetacquisition.repository; -import java.util.List; - +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.persistence.Query; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.shared.paging.PageImpl; import org.springframework.data.domain.Page; @@ -10,9 +11,7 @@ import org.springframework.data.util.Pair; import org.springframework.stereotype.Component; -import jakarta.persistence.EntityManager; -import jakarta.persistence.PersistenceContext; -import jakarta.persistence.Query; +import java.util.List; @Component public class DatasetAcquisitionRepositoryImpl implements DatasetAcquisitionRepositoryCustom { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionService.java index deb5bfe80d..1250553bfd 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionService.java @@ -14,10 +14,6 @@ package org.shanoir.ng.datasetacquisition.service; -import java.io.IOException; -import java.util.Collection; -import java.util.List; - import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.shared.exception.EntityNotFoundException; @@ -27,6 +23,10 @@ import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PreAuthorize; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + public interface DatasetAcquisitionService { @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT', 'USER')") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionServiceImpl.java index 852c7cdbde..0615fb77fe 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/service/DatasetAcquisitionServiceImpl.java @@ -14,17 +14,6 @@ package org.shanoir.ng.datasetacquisition.service; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.StreamSupport; - import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.dataset.service.DatasetService; @@ -46,6 +35,11 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + @Service public class DatasetAcquisitionServiceImpl implements DatasetAcquisitionService { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheck.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheck.java index 618430d9e1..0cfa573b86 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheck.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheck.java @@ -14,14 +14,14 @@ package org.shanoir.ng.datasetacquisition.validation; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import jakarta.validation.Constraint; -import jakarta.validation.Payload; - /** * Annotation checking if datasets of an acquisition have same modality type * than the acquisition. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheckValidator.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheckValidator.java index 7c472aef6e..c3c1ed1922 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheckValidator.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetacquisition/validation/DatasetsModalityTypeCheckValidator.java @@ -16,7 +16,6 @@ import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; - import org.shanoir.ng.dataset.modality.CtDataset; import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.dataset.modality.PetDataset; diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetfile/DatasetFile.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetfile/DatasetFile.java index f40e25ad96..139af17a6b 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetfile/DatasetFile.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/datasetfile/DatasetFile.java @@ -14,12 +14,7 @@ package org.shanoir.ng.datasetfile; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Transient; - +import jakarta.persistence.*; import org.shanoir.ng.dataset.model.DatasetExpression; import org.shanoir.ng.shared.core.model.AbstractEntity; diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMJsonApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMJsonApi.java index 8f19ac61ad..31432fd040 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMJsonApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMJsonApi.java @@ -14,20 +14,17 @@ package org.shanoir.ng.dicom.web; +import io.swagger.v3.oas.annotations.Operation; +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.dicom.web.dto.StudiesDTO; -import org.shanoir.ng.dicom.web.dto.StudyDTO; -import org.shanoir.ng.shared.exception.ErrorModel; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PostAuthorize; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - /** * This API interface returns a DICOMJson as described in * https://v3-docs.ohif.org/configuration/datasources/dicom-json/ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApi.java index b3ff311973..67f463e349 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApi.java @@ -1,28 +1,20 @@ package org.shanoir.ng.dicom.web; -import java.util.Map; - -import jakarta.servlet.http.HttpServletRequest; - -import org.shanoir.ng.shared.exception.ErrorModel; -import org.shanoir.ng.shared.exception.RestServiceException; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; - -import io.swagger.v3.oas.annotations.tags.Tag; 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 jakarta.servlet.http.HttpServletRequest; +import org.shanoir.ng.shared.exception.RestServiceException; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; /** * This implements the DICOMWeb REST-API exposed by Shanoir-NG. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApiController.java index 3840ab6c1b..654469b943 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/DICOMWebApiController.java @@ -1,10 +1,10 @@ package org.shanoir.ng.dicom.web; -import java.util.Iterator; -import java.util.Map; - +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.servlet.http.HttpServletRequest; - import org.apache.solr.common.StringUtils; import org.shanoir.ng.dicom.web.service.DICOMWebService; import org.shanoir.ng.examination.model.Examination; @@ -20,10 +20,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.Iterator; +import java.util.Map; @Controller public class DICOMWebApiController implements DICOMWebApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StowRSMultipartRelatedRequestFilter.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StowRSMultipartRelatedRequestFilter.java index cdf36371e9..04c4fb07e0 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StowRSMultipartRelatedRequestFilter.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StowRSMultipartRelatedRequestFilter.java @@ -1,8 +1,5 @@ package org.shanoir.ng.dicom.web; -import java.io.ByteArrayInputStream; -import java.io.IOException; - import jakarta.mail.BodyPart; import jakarta.mail.internet.MimeMultipart; import jakarta.mail.util.ByteArrayDataSource; @@ -11,7 +8,6 @@ import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletRequest; - import org.shanoir.ng.importer.service.DicomSRImporterService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +17,9 @@ import org.springframework.stereotype.Component; import org.springframework.web.filter.GenericFilterBean; +import java.io.ByteArrayInputStream; +import java.io.IOException; + /** * The StowRSMultipartRelatedRequestFilter handles a POST request of * content type "multipart/related", as send by the OHIF-viewer according diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StudyInstanceUIDHandler.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StudyInstanceUIDHandler.java index f747c23762..8eda8ba9e0 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StudyInstanceUIDHandler.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/StudyInstanceUIDHandler.java @@ -1,10 +1,8 @@ package org.shanoir.ng.dicom.web; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ArrayNode; +import jakarta.annotation.PostConstruct; import org.shanoir.ng.anonymization.uid.generation.UIDGeneration; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.dataset.model.DatasetExpression; @@ -22,10 +20,10 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; - -import jakarta.annotation.PostConstruct; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * The StudyInstanceUIDHandler component manages the translation between diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/service/DICOMWebService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/service/DICOMWebService.java index e3c32874ea..c05f2f121c 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/service/DICOMWebService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dicom/web/service/DICOMWebService.java @@ -1,21 +1,10 @@ package org.shanoir.ng.dicom.web.service; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - +import jakarta.annotation.PostConstruct; import org.apache.hc.client5.http.classic.methods.HttpDelete; import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.classic.methods.HttpPost; -import org.apache.hc.client5.http.entity.mime.ContentBody; -import org.apache.hc.client5.http.entity.mime.InputStreamBody; -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder; -import org.apache.hc.client5.http.entity.mime.MultipartPart; -import org.apache.hc.client5.http.entity.mime.MultipartPartBuilder; +import org.apache.hc.client5.http.entity.mime.*; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.client5.http.impl.classic.HttpClients; @@ -34,7 +23,9 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Component; -import jakarta.annotation.PostConstruct; +import java.io.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * This class handles all calls to the shanoir backup pacs using DICOMWeb. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/download/WADODownloaderService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/download/WADODownloaderService.java index c4c8d12132..2bd6599527 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/download/WADODownloaderService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/download/WADODownloaderService.java @@ -14,29 +14,11 @@ package org.shanoir.ng.download; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.StringReader; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -import javax.json.Json; -import javax.json.stream.JsonParser; - +import jakarta.annotation.PostConstruct; +import jakarta.mail.BodyPart; +import jakarta.mail.MessagingException; +import jakarta.mail.internet.MimeMultipart; +import jakarta.mail.util.ByteArrayDataSource; import org.dcm4che3.data.Attributes; import org.dcm4che3.json.JSONReader; import org.json.JSONException; @@ -50,21 +32,29 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.stereotype.Service; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; -import jakarta.annotation.PostConstruct; -import jakarta.mail.BodyPart; -import jakarta.mail.MessagingException; -import jakarta.mail.internet.MimeMultipart; -import jakarta.mail.util.ByteArrayDataSource; +import javax.json.Json; +import javax.json.stream.JsonParser; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; /** * This class is used to download files on using WADO URLs: diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Channel.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Channel.java index 29135c50d7..a037fdf605 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Channel.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Channel.java @@ -1,16 +1,14 @@ package org.shanoir.ng.eeg.model; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; - import org.shanoir.ng.dataset.modality.EegDataset; import org.shanoir.ng.shared.hateoas.HalEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - /** * A channel is a single analog-to-digital converter in the recording system that regularly samples the value of a transducer, * which results in the signal being represented as a time series in the digitized data diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Event.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Event.java index 156a66a838..7cf2718b22 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Event.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/eeg/model/Event.java @@ -1,17 +1,15 @@ package org.shanoir.ng.eeg.model; -import java.util.Date; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; - import org.shanoir.ng.dataset.modality.EegDataset; import org.shanoir.ng.shared.hateoas.HalEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Date; /** * Event linked to an EEG dataset. Event happening during the acquisition of an EEG. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApi.java index de609d1227..fd5fc5a0c9 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApi.java @@ -14,16 +14,15 @@ package org.shanoir.ng.examination.controler; -import java.io.IOException; -import java.util.List; - +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 jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; - import org.shanoir.ng.examination.dto.ExaminationDTO; import org.shanoir.ng.examination.dto.SubjectExaminationDTO; -import org.shanoir.ng.examination.model.Examination; -import org.shanoir.ng.shared.exception.ErrorModel; import org.shanoir.ng.shared.exception.RestServiceException; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -34,11 +33,8 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import io.swagger.v3.oas.annotations.tags.Tag; -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 java.io.IOException; +import java.util.List; @Tag(name = "examination") @RequestMapping("/examinations") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApiController.java index d9fbbeb657..7c8bc32a96 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/controler/ExaminationApiController.java @@ -14,15 +14,10 @@ package org.shanoir.ng.examination.controler; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; - +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; @@ -35,11 +30,7 @@ import org.shanoir.ng.shared.event.ShanoirEvent; import org.shanoir.ng.shared.event.ShanoirEventService; import org.shanoir.ng.shared.event.ShanoirEventType; -import org.shanoir.ng.shared.exception.EntityNotFoundException; -import org.shanoir.ng.shared.exception.ErrorDetails; -import org.shanoir.ng.shared.exception.ErrorModel; -import org.shanoir.ng.shared.exception.RestServiceException; -import org.shanoir.ng.shared.exception.ShanoirException; +import org.shanoir.ng.shared.exception.*; import org.shanoir.ng.shared.model.Subject; import org.shanoir.ng.shared.repository.CenterRepository; import org.shanoir.ng.shared.repository.SubjectRepository; @@ -57,10 +48,14 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile; -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; @Controller public class ExaminationApiController implements ExaminationApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/CodedVariable.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/CodedVariable.java index 1242266aaf..5f66f6f6a6 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/CodedVariable.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/CodedVariable.java @@ -1,19 +1,11 @@ package org.shanoir.ng.examination.model; +import jakarta.persistence.*; +import org.shanoir.ng.score.ScaleItem; + import java.util.ArrayList; import java.util.List; -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; -import jakarta.persistence.PrimaryKeyJoinColumn; -import jakarta.persistence.Table; - -import org.shanoir.ng.score.ScaleItem; - /** * The Class NumericalVariable. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Examination.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Examination.java index 551d7cd0d7..8a4e3230c8 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Examination.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Examination.java @@ -14,11 +14,10 @@ package org.shanoir.ng.examination.model; -import java.sql.Types; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.List; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.JdbcTypeCode; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; @@ -28,20 +27,10 @@ import org.shanoir.ng.shared.model.Study; import org.shanoir.ng.shared.model.Subject; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.CollectionTable; -import jakarta.persistence.Column; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; -import jakarta.persistence.PostLoad; -import jakarta.validation.constraints.NotNull; +import java.sql.Types; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; /** * Examination. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Instrument.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Instrument.java index 6df74ee562..a1e2d33a03 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Instrument.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/Instrument.java @@ -14,24 +14,14 @@ package org.shanoir.ng.examination.model; -import java.util.ArrayList; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.CollectionTable; -import jakarta.persistence.Column; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.shared.core.model.AbstractEntity; import org.shanoir.ng.shared.validation.Unique; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.ArrayList; +import java.util.List; /** * Instrument. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentBasedAssessment.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentBasedAssessment.java index feb046289e..64161a6c66 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentBasedAssessment.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentBasedAssessment.java @@ -14,17 +14,11 @@ package org.shanoir.ng.examination.model; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.List; /** * Instrument based assessment. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentVariable.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentVariable.java index fe9f3c234b..33c819efc4 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentVariable.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/InstrumentVariable.java @@ -14,21 +14,12 @@ package org.shanoir.ng.examination.model; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.List; /** * Instrument variable. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/ScientificArticle.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/ScientificArticle.java index 3b817955a4..6775a129c2 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/ScientificArticle.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/ScientificArticle.java @@ -16,7 +16,6 @@ import jakarta.persistence.Entity; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.shared.core.model.AbstractEntity; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/VariableAssessment.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/VariableAssessment.java index 861904f784..a083f187db 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/VariableAssessment.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/model/VariableAssessment.java @@ -14,19 +14,12 @@ package org.shanoir.ng.examination.model; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToMany; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.persistence.*; import org.shanoir.ng.score.Score; import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; +import java.util.List; /** * Variable assessment. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepository.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepository.java index 17463e687f..02690a5e03 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepository.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepository.java @@ -14,14 +14,14 @@ package org.shanoir.ng.examination.repository; -import java.util.List; - import org.shanoir.ng.examination.model.Examination; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.PagingAndSortingRepository; +import java.util.List; + /** * Repository for examination. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryCustom.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryCustom.java index ce26ee6bfd..f59150a956 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryCustom.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryCustom.java @@ -1,12 +1,12 @@ package org.shanoir.ng.examination.repository; -import java.util.List; - import org.shanoir.ng.examination.model.Examination; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.util.Pair; +import java.util.List; + public interface ExaminationRepositoryCustom { Page findPageByStudyCenterOrStudyIdIn(Iterable> studyCenterIds, Iterable studyIds, Pageable pageable, Boolean preclinical); diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryImpl.java index fcecbcc78e..f21e63a35b 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/repository/ExaminationRepositoryImpl.java @@ -1,7 +1,8 @@ package org.shanoir.ng.examination.repository; -import java.util.List; - +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; +import jakarta.persistence.Query; import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.shared.paging.PageImpl; import org.slf4j.Logger; @@ -12,9 +13,7 @@ import org.springframework.data.util.Pair; import org.springframework.stereotype.Component; -import jakarta.persistence.EntityManager; -import jakarta.persistence.PersistenceContext; -import jakarta.persistence.Query; +import java.util.List; @Component public class ExaminationRepositoryImpl implements ExaminationRepositoryCustom { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationService.java index abc6db6606..d11fecddd8 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationService.java @@ -14,10 +14,6 @@ package org.shanoir.ng.examination.service; -import java.io.File; -import java.io.IOException; -import java.util.List; - import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.shared.exception.EntityNotFoundException; @@ -28,6 +24,10 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.multipart.MultipartFile; +import java.io.File; +import java.io.IOException; +import java.util.List; + /** * Examination service. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationServiceImpl.java index 1c7b623f46..aa931e1f26 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/examination/service/ExaminationServiceImpl.java @@ -14,16 +14,6 @@ package org.shanoir.ng.examination.service; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; - import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.solr.client.solrj.SolrServerException; @@ -53,6 +43,12 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; + /** * Examination service implementation. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/BidsImporterService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/BidsImporterService.java index 4bb9dcd051..e5ce883dd8 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/BidsImporterService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/BidsImporterService.java @@ -270,9 +270,9 @@ private void importDataset(ImportJob importJob, BidsDataType bidsDataType, Datas event.setStatus(ShanoirEvent.SUCCESS); - event.setMessage(importJob.getStudyName() + " (n°" + importJob.getStudyId() + ")" - +" : Successfully created datasets for subject " + importJob.getSubjectName() - + " in examination " + examination.getId()); + event.setMessage("[" + importJob.getStudyName() + " (n°" + importJob.getStudyId() + ")]" + +" Successfully created datasets for subject [" + importJob.getSubjectName() + + "] in examination [" + examination.getId() + "]"); event.setProgress(1f); eventService.publishEvent(event); } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/DicomSRImporterService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/DicomSRImporterService.java index 48437a1940..8fa5f7825c 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/DicomSRImporterService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/DicomSRImporterService.java @@ -1,18 +1,5 @@ package org.shanoir.ng.importer.service; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - import org.apache.solr.client.solrj.SolrServerException; import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Sequence; @@ -21,12 +8,7 @@ import org.dcm4che3.io.DicomInputStream; import org.dcm4che3.io.DicomOutputStream; import org.shanoir.ng.dataset.modality.MeasurementDataset; -import org.shanoir.ng.dataset.model.CardinalityOfRelatedSubjects; -import org.shanoir.ng.dataset.model.Dataset; -import org.shanoir.ng.dataset.model.DatasetExpression; -import org.shanoir.ng.dataset.model.DatasetExpressionFormat; -import org.shanoir.ng.dataset.model.DatasetMetadata; -import org.shanoir.ng.dataset.model.DatasetModalityType; +import org.shanoir.ng.dataset.model.*; import org.shanoir.ng.dataset.service.DatasetService; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.datasetacquisition.model.ct.CtDatasetAcquisition; @@ -47,6 +29,19 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + /** * This class imports the measurements of the ohif-viewer, that are * send as DICOM SR Structured Report. It modifies the by the OHIF diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/EegImporterService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/EegImporterService.java index e843a34b39..e13e2fa4cb 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/EegImporterService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/EegImporterService.java @@ -192,9 +192,9 @@ public void createEegDataset(final EegImportJob importJob) throws IOException { event.setProgress(1f); event.setStatus(ShanoirEvent.SUCCESS); // This message is important for email service - event.setMessage(importJob.getStudyName() + " (n°" + importJob.getStudyId() + ")" - +" : Successfully created datasets for subject " + importJob.getSubjectName() - + " in examination " + examination.getId()); + event.setMessage("[" + importJob.getStudyName() + " (n°" + importJob.getStudyId() + ")]" + +" Successfully created datasets for subject [" + importJob.getSubjectName() + + "] in examination [" + examination.getId() + "]"); eventService.publishEvent(event); // Send mail diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/ImporterService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/ImporterService.java index 035541b751..93db909824 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/ImporterService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/importer/service/ImporterService.java @@ -14,38 +14,10 @@ package org.shanoir.ng.importer.service; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.dcm4che3.data.Attributes; -import org.shanoir.ng.dataset.modality.CalibrationDataset; -import org.shanoir.ng.dataset.modality.CtDataset; -import org.shanoir.ng.dataset.modality.EegDataset; -import org.shanoir.ng.dataset.modality.MegDataset; -import org.shanoir.ng.dataset.modality.MeshDataset; -import org.shanoir.ng.dataset.modality.MrDataset; -import org.shanoir.ng.dataset.modality.ParameterQuantificationDataset; -import org.shanoir.ng.dataset.modality.PetDataset; -import org.shanoir.ng.dataset.modality.RegistrationDataset; -import org.shanoir.ng.dataset.modality.SegmentationDataset; -import org.shanoir.ng.dataset.modality.SpectDataset; -import org.shanoir.ng.dataset.modality.StatisticalDataset; -import org.shanoir.ng.dataset.modality.TemplateDataset; +import org.shanoir.ng.dataset.modality.*; import org.shanoir.ng.dataset.model.Dataset; -import org.shanoir.ng.dataset.model.DatasetExpression; -import org.shanoir.ng.dataset.model.DatasetExpressionFormat; -import org.shanoir.ng.dataset.model.DatasetMetadata; -import org.shanoir.ng.dataset.model.DatasetModalityType; +import org.shanoir.ng.dataset.model.*; import org.shanoir.ng.dataset.service.DatasetService; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.datasetacquisition.service.DatasetAcquisitionService; @@ -54,11 +26,7 @@ import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.examination.repository.ExaminationRepository; import org.shanoir.ng.examination.service.ExaminationService; -import org.shanoir.ng.importer.dto.ImportJob; -import org.shanoir.ng.importer.dto.Patient; -import org.shanoir.ng.importer.dto.ProcessedDatasetImportJob; -import org.shanoir.ng.importer.dto.Serie; -import org.shanoir.ng.importer.dto.Study; +import org.shanoir.ng.importer.dto.*; import org.shanoir.ng.processing.model.DatasetProcessing; import org.shanoir.ng.shared.event.ShanoirEvent; import org.shanoir.ng.shared.event.ShanoirEventService; @@ -82,6 +50,15 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.time.LocalDate; +import java.util.*; + @Service @Scope("prototype") public class ImporterService { @@ -178,9 +155,9 @@ public void createAllDatasetAcquisition(ImportJob importJob, Long userId) throws event.setProgress(1f); event.setStatus(ShanoirEvent.SUCCESS); - event.setMessage(importJob.getStudyName() + " (n°" + importJob.getStudyId() + ")" - +" : Successfully created datasets for subject " + importJob.getSubjectName() - + " in examination " + examination.getId()); + event.setMessage("[" + importJob.getStudyName() + " (n°" + importJob.getStudyId() + ")]" + +" Successfully created datasets for subject [" + importJob.getSubjectName() + + "] in examination [" + examination.getId() + "]"); eventService.publishEvent(event); // Manage archive @@ -530,9 +507,10 @@ public Dataset createProcessedDataset(final ProcessedDatasetImportJob importJob) dataset = datasetService.create(dataset); event.setStatus(ShanoirEvent.SUCCESS); - event.setMessage(importJob.getStudyName() + "(" + importJob.getStudyId() + ")" - +": Successfully created processed dataset for subject " + importJob.getSubjectName() + " in dataset " - + dataset.getId()); + + event.setMessage("[" + importJob.getStudyName() + " (n°" + importJob.getStudyId() + ")] " + + "Successfully created processed dataset [" + dataset.getId() + "] " + + "for subject [" + importJob.getSubjectName() + "]"); event.setProgress(1f); eventService.publishEvent(event); diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApi.java index 0386f0d6de..f10901e075 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApi.java @@ -1,31 +1,21 @@ package org.shanoir.ng.processing.carmin.controller; -import java.util.List; - +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 jakarta.validation.Valid; - -import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; -import org.shanoir.ng.processing.dto.DatasetProcessingDTO; +import org.shanoir.ng.processing.dto.CarminDatasetProcessingDTO; import org.shanoir.ng.shared.exception.EntityNotFoundException; -import org.shanoir.ng.shared.exception.ErrorModel; import org.shanoir.ng.shared.exception.RestServiceException; import org.shanoir.ng.shared.exception.SecurityException; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.*; -import io.swagger.v3.oas.annotations.tags.Tag; -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 java.util.List; @Tag(name = "carminDatasetProcessing") @RequestMapping("/carminDatasetProcessing") @@ -41,10 +31,26 @@ public interface CarminDatasetProcessingApi { @PostMapping(value = "", produces = { "application/json" }, consumes = { "application/json" }) @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT')") - ResponseEntity saveNewCarminDatasetProcessing( - @Parameter(name = "carmin dataset processing to create", required = true) @Valid @RequestBody CarminDatasetProcessing carminDatasetProcessing, + ResponseEntity saveNewCarminDatasetProcessing( + @Parameter(name = "carmin dataset processing to create", required = true) @Valid @RequestBody CarminDatasetProcessingDTO carminDatasetProcessing, + @Parameter(name = "start monitoring job once created") @RequestParam(value = "start", required = false, defaultValue="false") boolean start, BindingResult result) throws RestServiceException, EntityNotFoundException, SecurityException; + @Operation(summary = "", description = "Updates a dataset processing") + @ApiResponses(value = { @ApiResponse(responseCode = "204", description = "dataset processing updated"), + @ApiResponse(responseCode = "401", description = "unauthorized"), + @ApiResponse(responseCode = "403", description = "forbidden"), + @ApiResponse(responseCode = "422", description = "bad parameters"), + @ApiResponse(responseCode = "500", description = "unexpected error") }) + @PutMapping(value = "/{datasetProcessingId}", produces = { "application/json" }, consumes = { + "application/json" }) + @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT')") + ResponseEntity updateCarminDatasetProcessing( + @Parameter(name = "carmin dataset processing to update", required = true) @Valid @RequestBody CarminDatasetProcessingDTO carminDatasetProcessing, + @Parameter(name = "start monitoring job once updated") @RequestParam(value = "start", required = false, defaultValue="false") boolean start, + BindingResult result) + throws RestServiceException, SecurityException; + @Operation(summary = "", description = "If exists, returns the carmin dataset processing corresponding to the given id") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "found dataset processing"), @@ -54,21 +60,9 @@ ResponseEntity saveNewCarminDatasetProcessing( @ApiResponse(responseCode = "500", description = "unexpected error") }) @GetMapping(value = "/{datasetProcessingId}", produces = { "application/json" }) @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT', 'USER')") - ResponseEntity findCarminDatasetProcessingById( + ResponseEntity findCarminDatasetProcessingById( @Parameter(name = "id of the carmin dataset processing", required = true) @PathVariable("datasetProcessingId") Long datasetProcessingId); - @Operation(summary = "", description = "If exists, returns the carmin dataset processing corresponding to the given execution identifier with carmin new fields") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "found dataset processing"), - @ApiResponse(responseCode = "401", description = "unauthorized"), - @ApiResponse(responseCode = "403", description = "forbidden"), - @ApiResponse(responseCode = "404", description = "no dataset processing found"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) - @GetMapping(value = "", produces = { "application/json" }) - @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT', 'USER')") - ResponseEntity findCarminDatasetProcessingByIdentifier( - @Parameter(name = "identifier of the execution", required = true) @RequestParam("identifier") String identifier); - @Operation(summary = "", description = "If exists, returns the dataset processing corresponding to the given id with carmin new fields") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "found dataset processing"), @@ -76,36 +70,8 @@ ResponseEntity findCarminDatasetProcessingByIdentifier( @ApiResponse(responseCode = "403", description = "forbidden"), @ApiResponse(responseCode = "404", description = "no dataset processing found"), @ApiResponse(responseCode = "500", description = "unexpected error") }) - @GetMapping(value = "carminDatasetProcessings", produces = { "application/json" }) + @GetMapping(value = "all", produces = { "application/json" }) @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT', 'USER')") - ResponseEntity> findCarminDatasetProcessings(); - - @Operation(summary = "", description = "Updates a dataset processing") - @ApiResponses(value = { @ApiResponse(responseCode = "204", description = "dataset processing updated"), - @ApiResponse(responseCode = "401", description = "unauthorized"), - @ApiResponse(responseCode = "403", description = "forbidden"), - @ApiResponse(responseCode = "422", description = "bad parameters"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) - @PutMapping(value = "/{datasetProcessingId}", produces = { "application/json" }, consumes = { - "application/json" }) - @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT')") - ResponseEntity updateCarminDatasetProcessing( - @Parameter(name = "id of the dataset processing", required = true) @PathVariable("datasetProcessingId") Long datasetProcessingId, - @Parameter(name = "carmin dataset processing to update", required = true) @Valid @RequestBody CarminDatasetProcessing carminDatasetProcessing, - BindingResult result) - throws RestServiceException; - - @Operation(summary = "", description = "Returns all the carmin dataset processings with given study and subject") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "found carmin dataset processings"), - @ApiResponse(responseCode = "204", description = "no dataset processing found"), - @ApiResponse(responseCode = "401", description = "unauthorized"), - @ApiResponse(responseCode = "403", description = "forbidden"), - @ApiResponse(responseCode = "500", description = "unexpected error") }) - @GetMapping(value = "/study/{studyId}/subject/{subjectId}", produces = { "application/json" }) - @PreAuthorize("hasRole('ADMIN') or (hasAnyRole('EXPERT', 'USER') and @datasetSecurityService.hasRightOnStudy(#studyId, 'CAN_SEE_ALL'))") - ResponseEntity> findCarminDatasetProcessingsByStudyIdAndSubjectId( - @Parameter(name = "id of the study", required = true) @PathVariable("studyId") Long studyId, - @Parameter(name = "id of the subject", required = true) @PathVariable("subjectId") Long subjectId); + ResponseEntity> getAllCarminDatasetProcessings(); } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApiController.java index f7507ea28a..a0bcec3fdb 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/controller/CarminDatasetProcessingApiController.java @@ -1,22 +1,17 @@ package org.shanoir.ng.processing.carmin.controller; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - +import io.swagger.v3.oas.annotations.Parameter; import jakarta.validation.Valid; - import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; import org.shanoir.ng.processing.carmin.schedule.ExecutionStatusMonitorService; -import org.shanoir.ng.processing.carmin.security.CarminDatasetProcessingSecurityService; import org.shanoir.ng.processing.carmin.service.CarminDatasetProcessingService; +import org.shanoir.ng.processing.dto.CarminDatasetProcessingDTO; +import org.shanoir.ng.processing.dto.ParameterResourcesDTO; +import org.shanoir.ng.processing.dto.mapper.CarminDatasetProcessingMapper; import org.shanoir.ng.shared.error.FieldErrorMap; -import org.shanoir.ng.shared.exception.EntityNotFoundException; -import org.shanoir.ng.shared.exception.ErrorDetails; -import org.shanoir.ng.shared.exception.ErrorModel; -import org.shanoir.ng.shared.exception.RestServiceException; import org.shanoir.ng.shared.exception.SecurityException; +import org.shanoir.ng.shared.exception.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -27,7 +22,9 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; -import io.swagger.v3.oas.annotations.Parameter; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; /** * @author KhalilKes @@ -42,62 +39,57 @@ public class CarminDatasetProcessingApiController implements CarminDatasetProces @Autowired private ExecutionStatusMonitorService executionStatusMonitorService; + @Autowired + private CarminDatasetProcessingMapper mapper; + @Override - public ResponseEntity saveNewCarminDatasetProcessing( - @Valid @RequestBody CarminDatasetProcessing carminDatasetProcessing, BindingResult result) + public ResponseEntity saveNewCarminDatasetProcessing( + @Valid @RequestBody CarminDatasetProcessingDTO dto, boolean start, BindingResult result) throws RestServiceException, EntityNotFoundException, SecurityException { /* Validation */ validate(result); - - /** - * run monitoring job - */ /* Save dataset processing in db. */ - final CarminDatasetProcessing createdDatasetProcessing = carminDatasetProcessingService - .createCarminDatasetProcessing(carminDatasetProcessing); - - executionStatusMonitorService.startJob(carminDatasetProcessing.getIdentifier()); - - return new ResponseEntity<>(createdDatasetProcessing, HttpStatus.OK); - } + final CarminDatasetProcessing createdProcessing = carminDatasetProcessingService + .createCarminDatasetProcessing(mapper.carminDatasetProcessingDTOToCarminDatasetProcessing(dto)); - @Override - public ResponseEntity findCarminDatasetProcessingById(Long datasetProcessingId) { - final Optional carminDatasetProcessing = carminDatasetProcessingService.findById(datasetProcessingId); - if (!carminDatasetProcessing.isPresent()) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - // Avoid infinite loop error -> We should be using datasetDTO here in a general matter. - for (Dataset dataset : carminDatasetProcessing.get().getInputDatasets()) { - dataset.setDatasetAcquisition(null); - } - return new ResponseEntity<>(carminDatasetProcessing.get(), HttpStatus.OK); - } - - @Override - public ResponseEntity findCarminDatasetProcessingByIdentifier( - @Parameter(name = "id of the dataset processing", required = true) @RequestParam("identifier") String identifier) { + List parametersDatasets = carminDatasetProcessingService.createProcessingResources(createdProcessing, dto.getParametersResources()); - final Optional carminDatasetProcessing = carminDatasetProcessingService.findByIdentifier(identifier); - if (!carminDatasetProcessing.isPresent()) { - return new ResponseEntity<>(HttpStatus.NOT_FOUND); + if (start) { + if (createdProcessing.getIdentifier() == null || createdProcessing.getIdentifier().isEmpty()) { + throw new RestServiceException( + new ErrorModel(HttpStatus.BAD_REQUEST.value(), "Monitoring job has been set to start but processing identifier is null or empty.", null)); + } + executionStatusMonitorService.startMonitoringJob(createdProcessing.getIdentifier()); } - return new ResponseEntity<>(carminDatasetProcessing.get(), HttpStatus.OK); + CarminDatasetProcessingDTO createdDTO = mapper.carminDatasetProcessingToCarminDatasetProcessingDTO(createdProcessing); + createdDTO.setParametersResources(parametersDatasets); + + return new ResponseEntity<>(createdDTO, HttpStatus.OK); } + @Override public ResponseEntity updateCarminDatasetProcessing( - @Parameter(name = "id of the dataset processing", required = true) @PathVariable("datasetProcessingId") Long datasetProcessingId, - @Parameter(name = "dataset processing to update", required = true) @Valid @RequestBody CarminDatasetProcessing carminDatasetProcessing, - final BindingResult result) throws RestServiceException { + @Parameter(name = "dataset processing to update", required = true) @Valid @RequestBody CarminDatasetProcessingDTO dto, + boolean start, + final BindingResult result) throws RestServiceException, SecurityException { validate(result); try { - carminDatasetProcessingService.updateCarminDatasetProcessing(carminDatasetProcessing); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); + CarminDatasetProcessing updatedProcessing = carminDatasetProcessingService.updateCarminDatasetProcessing(mapper.carminDatasetProcessingDTOToCarminDatasetProcessing(dto)); + + if (start) { + if (updatedProcessing.getIdentifier() == null || updatedProcessing.getIdentifier().isEmpty()) { + throw new RestServiceException( + new ErrorModel(HttpStatus.BAD_REQUEST.value(), "Monitoring job has been set to start but processing identifier is null or empty.", null)); + } + executionStatusMonitorService.startMonitoringJob(updatedProcessing.getIdentifier()); + } + + return new ResponseEntity<>(HttpStatus.OK); } catch (EntityNotFoundException e) { return new ResponseEntity<>(HttpStatus.NOT_FOUND); @@ -105,31 +97,21 @@ public ResponseEntity updateCarminDatasetProcessing( } @Override - public ResponseEntity> findCarminDatasetProcessings() { - final List carminDatasetProcessings = carminDatasetProcessingService.findAllAllowed(); - if (carminDatasetProcessings.isEmpty()) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - return new ResponseEntity<>(carminDatasetProcessings, HttpStatus.OK); + public ResponseEntity findCarminDatasetProcessingById(Long datasetProcessingId) { + final Optional processing = carminDatasetProcessingService.findById(datasetProcessingId); + if (processing.isEmpty()) { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + return new ResponseEntity<>(mapper.carminDatasetProcessingToCarminDatasetProcessingDTO(processing.get()), HttpStatus.OK); } @Override - public ResponseEntity> findCarminDatasetProcessingsByStudyIdAndSubjectId( - @Parameter(name = "id of the study", required = true) @PathVariable("studyId") Long studyId, - @Parameter(name = "id of the subject", required = true) @PathVariable("subjectId") Long subjectId) { - List carminDatasetProcessings = carminDatasetProcessingService.findAll(); - if (carminDatasetProcessings.isEmpty()) { + public ResponseEntity> getAllCarminDatasetProcessings() { + final List processings = carminDatasetProcessingService.findAllAllowed(); + if (processings.isEmpty()) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } - carminDatasetProcessings = carminDatasetProcessings.stream().filter(processing -> { - return !CollectionUtils.isEmpty(processing.getInputDatasets()) - && processing.getInputDatasets().get(0).getStudyId().equals(studyId) - && processing.getInputDatasets().get(0).getSubjectId().equals(subjectId); - }).collect(Collectors.toList()); - if (carminDatasetProcessings.isEmpty()) { - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - return new ResponseEntity<>(carminDatasetProcessings, HttpStatus.OK); + return new ResponseEntity<>(mapper.carminDatasetProcessingsToCarminDatasetProcessingDTOs(processings), HttpStatus.OK); } private void validate(BindingResult result) throws RestServiceException { @@ -141,5 +123,5 @@ private void validate(BindingResult result) throws RestServiceException { } } - + } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/model/CarminDatasetProcessing.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/model/CarminDatasetProcessing.java index 4848143b70..52ae21d5a1 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/model/CarminDatasetProcessing.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/model/CarminDatasetProcessing.java @@ -3,7 +3,6 @@ import jakarta.persistence.Entity; import jakarta.persistence.Inheritance; import jakarta.persistence.InheritanceType; - import org.shanoir.ng.processing.model.DatasetProcessing; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/model/ProcessingResource.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/model/ProcessingResource.java new file mode 100644 index 0000000000..017a53e811 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/model/ProcessingResource.java @@ -0,0 +1,57 @@ +package org.shanoir.ng.processing.carmin.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.processing.model.DatasetProcessing; +import org.shanoir.ng.shared.core.model.AbstractEntity; + +@Entity +public class ProcessingResource extends AbstractEntity { + + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "processing_id") + private DatasetProcessing processing; + + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "dataset_id") + private Dataset dataset; + + @NotNull + private String resourceId; + + public ProcessingResource() {} + + public ProcessingResource(CarminDatasetProcessing processing, Dataset dataset, String resourceId) { + this.processing = processing; + this.dataset = dataset; + this.resourceId = resourceId; + } + + public DatasetProcessing getProcessing() { + return processing; + } + + public void setProcessing(DatasetProcessing processing) { + this.processing = processing; + } + + public Dataset getDataset() { + return dataset; + } + + public void setDataset(Dataset dataset) { + this.dataset = dataset; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OFSEPSeqIdProcessing.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OFSEPSeqIdProcessing.java new file mode 100644 index 0000000000..df41c10d55 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OFSEPSeqIdProcessing.java @@ -0,0 +1,342 @@ +package org.shanoir.ng.processing.carmin.output; + +import org.apache.commons.io.IOUtils; +import org.apache.solr.client.solrj.SolrServerException; +import org.dcm4che3.data.Attributes; +import org.dcm4che3.data.Tag; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.dataset.repository.DatasetRepository; +import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; +import org.shanoir.ng.datasetacquisition.model.mr.MrDatasetAcquisition; +import org.shanoir.ng.datasetacquisition.service.DatasetAcquisitionService; +import org.shanoir.ng.download.WADODownloaderService; +import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.property.model.DatasetProperty; +import org.shanoir.ng.property.service.DatasetPropertyService; +import org.shanoir.ng.shared.exception.CheckedIllegalClassException; +import org.shanoir.ng.shared.exception.EntityNotFoundException; +import org.shanoir.ng.shared.exception.PacsException; +import org.shanoir.ng.solr.service.SolrService; +import org.shanoir.ng.studycard.model.field.DatasetAcquisitionMetadataField; +import org.shanoir.ng.studycard.model.field.DatasetMetadataField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class OFSEPSeqIdProcessing extends OutputProcessing { + + private static final Logger LOG = LoggerFactory.getLogger(OFSEPSeqIdProcessing.class); + + public static final String PIPELINE_OUTPUT = "output.json"; + private static final String[] SERIE_PROPERTIES = { + "coil", + "type", + "protocolValidityStatus", + "name", + "numberOfDirections" + }; + + private static final String[] VOLUME_PROPERTIES = { + "acquisitionDate", + "contrastAgent", + "contrastAgentAlgo", + "contrastAgentAlgoConfidence", + "contrastAgentDICOM", + "organ", + "organAlgo", + "organAlgoConfidence", + "organDICOM", + "type", + "sequence", + "extraType", + "derivedSequence", + "name", + "contrast", + "bValue", + "sliceThickness", + "spacings", + "spacingBetweenSlices", + "numberOfSlices", + "dimension", + "dimensions", + "axis" + + }; + public static final String TYPE = "type"; + public static final String SERIES = "series"; + public static final String ID = "id"; + public static final String VOLUMES = "volumes"; + public static final String ORIENTATION = "orientation"; + + @Autowired + private DatasetRepository datasetRepository; + + @Autowired + private DatasetAcquisitionService acquisitionService; + + @Autowired + private WADODownloaderService wadoDownloaderService; + + @Autowired + private DatasetPropertyService datasetPropertyService; + + @Autowired + private SolrService solrService; + + + @Override + public boolean canProcess(CarminDatasetProcessing processing) throws OutputProcessingException { + if(processing.getPipelineIdentifier() == null || processing.getPipelineIdentifier().isEmpty()){ + throw new OutputProcessingException("Pipeline identifier is not set for processing [" + processing.getName() + "]", null); + } + return processing.getPipelineIdentifier().startsWith("ofsep_sequences_identification"); + } + + @Override + public void manageTarGzResult(List resultFiles, File parentFolder, CarminDatasetProcessing processing) throws OutputProcessingException { + + for(File file : resultFiles){ + if (!file.getName().equals(PIPELINE_OUTPUT)) { + continue; + } + + if (file.length() == 0) { + throw new OutputProcessingException("Result file [" + file.getAbsolutePath() + "] is present but empty.", null); + } + + try (InputStream is = new FileInputStream(file)) { + JSONObject json = new JSONObject(IOUtils.toString(is, StandardCharsets.UTF_8)); + JSONArray series = json.getJSONArray(SERIES); + + if(series.length() < 1){ + LOG.warn("Series list is empty in result file [{}].", file.getAbsolutePath()); + return; + } + + this.processSeries(series, processing); + + }catch (Exception e) { + throw new OutputProcessingException("An error occured while extracting result from result archive.", e); + } + + return; + } + throw new OutputProcessingException("Expected result file [" + parentFolder.getAbsolutePath() + "/" + PIPELINE_OUTPUT + "] is not present.", null); + } + + /** + * Process all series / acquisitions found in output JSON + * + * @param series JSONArray + * @param processing CarminDatasetProcessing + * @throws JSONException + * @throws PacsException + * @throws EntityNotFoundException + */ + public void processSeries(JSONArray series, CarminDatasetProcessing processing) throws JSONException, PacsException, EntityNotFoundException, CheckedIllegalClassException, SolrServerException, IOException { + + for (int i = 0; i < series.length(); i++) { + + JSONObject serie = series.getJSONObject(i); + Long serieId = serie.getLong(ID); + + + List datasets = processing.getInputDatasets().stream() + .filter(ds -> ds.getDatasetAcquisition() != null + && ds.getDatasetAcquisition().getId().equals(serieId)) + .collect(Collectors.toList()); + + if(datasets.isEmpty()){ + LOG.error("No dataset found for serie/acquisition [" + serieId + "]"); + continue; + } + + for(Dataset ds : datasets){ + + JSONObject vol = this.getMatchingVolume(ds, serie); + + if(vol == null){ + LOG.error("No volume from serie [{}] could be match with dataset [{}].", serieId, ds.getId()); + continue; + } + + try { + this.updateDataset(serie, ds, vol); + } catch (CheckedIllegalClassException | EntityNotFoundException | SolrServerException | IOException e) { + LOG.error("Error while updating dataset [{}]", ds.getId(), e); + throw e; + } + + List properties = this.getDatasetPropertiesFromVolume(ds, vol, processing); + datasetPropertyService.createAll(properties); + + } + } + } + + /** + * Update dataset from pipeline output serie & volume + * + * @param serie JSONObject + * @param ds Dataset + * @param vol JSONObject + * @throws JSONException + * @throws EntityNotFoundException + */ + public void updateDataset(JSONObject serie, Dataset ds, JSONObject vol) throws JSONException, EntityNotFoundException, CheckedIllegalClassException, SolrServerException, IOException { + + DatasetMetadataField.NAME.update(ds, vol.getString(TYPE)); + datasetRepository.save(ds); + + if(ds.getDatasetAcquisition() instanceof MrDatasetAcquisition){ + DatasetAcquisition acq = ds.getDatasetAcquisition(); + DatasetAcquisitionMetadataField.MR_SEQUENCE_NAME.update(acq, serie.getString(TYPE)); + acquisitionService.update(acq); + } + + solrService.updateDatasets(Arrays.asList(ds.getId())); + + } + + + /** + * Create dataset properties from pipeline output volume + * + * @param ds Dataset + * @param volume JSONObject + * @return + */ + private List getDatasetPropertiesFromVolume(Dataset ds, JSONObject volume, CarminDatasetProcessing processing) throws JSONException { + List properties = new ArrayList<>(); + + for(String name : SERIE_PROPERTIES){ + + if(!volume.has(name)){ + continue; + } + + DatasetProperty property = new DatasetProperty(); + property.setDataset(ds); + property.setName("serie." + name); + property.setValue(volume.getString(name)); + property.setProcessing(processing); + properties.add(property); + } + + for(String name : VOLUME_PROPERTIES){ + + if(!volume.has(name)){ + continue; + } + + DatasetProperty property = new DatasetProperty(); + property.setDataset(ds); + property.setName("volume." + name); + property.setValue(volume.getString(name)); + property.setProcessing(processing); + properties.add(property); + } + + return properties; + + } + + + /** + * Return JSON volume matching Shanoir dataset + * Match is made by orientation DICOM property + * + * @param dataset Dataset + * @param serie JSONObject + * + * @return JSONObject + * @throws JSONException + */ + public JSONObject getMatchingVolume(Dataset dataset, JSONObject serie) throws JSONException, PacsException { + + if(serie.isNull(VOLUMES)){ + LOG.error("Volumes set is null in result file for serie [{}]", serie.getLong(ID)); + return null; + } + + JSONArray volumes = serie.getJSONArray(VOLUMES); + + Attributes attributes = wadoDownloaderService.getDicomAttributesForDataset(dataset); + + double[] dsOrientation = attributes.getDoubles(Tag.ImageOrientationPatient); + + for (int i = 0 ; i < volumes.length(); i++) { + + JSONObject volume = volumes.getJSONObject(i); + + if(volume.isNull(ORIENTATION)){ + LOG.error("Orientation is null in result file for volume [{}]", volume.getString(ID)); + continue; + } + + JSONArray volOrientation = volume.getJSONArray(ORIENTATION); + + if(dsOrientation == null || dsOrientation.length == 0){ + LOG.error("ImageOrientationPatient DICOM property is empty for dataset [{}]", dataset.getId()); + continue; + } + + if(volOrientation == null || volOrientation.length() == 0){ + LOG.error("Orientation is empty in result file for volume [{}]", volume.getString(ID)); + continue; + } + + if(this.areOrientationsEquals(dsOrientation, volOrientation)){ + return volume; + } + + } + + return null; + + } + + /** + * Check if the two arrays are equals + * + * @param dsOrientation double[] + * @param volOrientation JSONArray + * @return boolean + * @throws JSONException + */ + public boolean areOrientationsEquals(double[] dsOrientation, JSONArray volOrientation) throws JSONException { + + if(dsOrientation == null || dsOrientation.length == 0 || volOrientation == null || volOrientation.length() == 0){ + return false; + } + + if(dsOrientation.length != volOrientation.length()){ + return false; + } + + for (int i = 0 ; i < dsOrientation.length; i++) { + if(dsOrientation[i] != volOrientation.getDouble(i)){ + return false; + } + } + + return true; + + } + +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessing.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessing.java index de521f338c..9410113d2c 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessing.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessing.java @@ -1,9 +1,10 @@ package org.shanoir.ng.processing.carmin.output; -import java.io.File; - import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import java.io.File; +import java.util.List; + /** * This class defines the default class to be implemented for output processing. * @author jcome @@ -11,12 +12,22 @@ */ public abstract class OutputProcessing { + /** + * Return true if the implementation can process the result of the given processing + * + * @param processing CarminDatasetProcessing + * @return + */ + public abstract boolean canProcess(CarminDatasetProcessing processing) throws OutputProcessingException; + /** * This methods manages the single result of a Carmin dataset processing - * @param resultFile the result file as tar.gz of the processing + * + * @param resultFiles the result file as tar.gz of the processing * @param parentFolder the temporary arent folder in which we are currently working - * @param processing the corresponding dataset processing. + * @param processing the corresponding dataset processing. */ - public abstract void manageTarGzResult(File resultFile, File parentFolder, CarminDatasetProcessing processing); + + public abstract void manageTarGzResult(List resultFiles, File parentFolder, CarminDatasetProcessing processing) throws OutputProcessingException; } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessingException.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessingException.java new file mode 100644 index 0000000000..f4c249ba91 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessingException.java @@ -0,0 +1,8 @@ +package org.shanoir.ng.processing.carmin.output; + +public class OutputProcessingException extends Exception{ + + public OutputProcessingException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessingService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessingService.java new file mode 100644 index 0000000000..0f0a742caa --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/OutputProcessingService.java @@ -0,0 +1,143 @@ +package org.shanoir.ng.processing.carmin.output; + +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOUtils; +import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.processing.service.DatasetProcessingService; +import org.shanoir.ng.shared.exception.EntityNotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@Service +public class OutputProcessingService { + + private static final Logger LOG = LoggerFactory.getLogger(OutputProcessingService.class); + + @Value("${vip.upload-folder}") + private String importDir; + + @Autowired + private List outputProcessings; + @Autowired + private DatasetProcessingService datasetProcessingService; + + + /** + * + * Process the result of the given processing + * + * @param processing + * @throws OutputProcessingException + */ + public void process(CarminDatasetProcessing processing) throws OutputProcessingException, EntityNotFoundException { + + final File userImportDir = new File( + this.importDir + File.separator + + processing.getResultsLocation()); + + for (File archive : this.getArchivesToProcess(userImportDir)) { + + File cacheFolder = new File(userImportDir.getAbsolutePath() + File.separator + FilenameUtils.getBaseName(archive.getName())); + + List outputFiles = this.extractTarIntoCache(archive, cacheFolder); + + for (OutputProcessing outputProcessing : outputProcessings) { + if (outputProcessing.canProcess(processing)) { + LOG.info("Processing result file [{}] with [{}] output processing", archive.getAbsolutePath(), outputProcessing.getClass().getSimpleName()); + outputProcessing.manageTarGzResult(outputFiles, userImportDir, processing); + } + } + + this.deleteCache(cacheFolder); + } + // Remove processed datasets from current Carmin processing + processing.setInputDatasets(Collections.emptyList()); + datasetProcessingService.update(processing); + } + + private List getArchivesToProcess(File userImportDir) throws OutputProcessingException { + + LOG.info("Processing result in import directory [{}]...", userImportDir.getAbsolutePath()); + + final PathMatcher matcher = userImportDir.toPath().getFileSystem() + .getPathMatcher("glob:**/*.{tgz,tar.gz}"); + + try (Stream stream = Files.list(userImportDir.toPath())) { + + return stream.filter(matcher::matches).map(Path::toFile).collect(Collectors.toList()); + + } catch (IOException e) { + throw new OutputProcessingException("I/O error while listing files in import directory", e); + } + + } + + private List extractTarIntoCache(File archive, File cacheFolder) throws OutputProcessingException { + + List outputFiles = new ArrayList<>(); + + try (TarArchiveInputStream fin = new TarArchiveInputStream( + new GzipCompressorInputStream(new FileInputStream(archive)))) { + TarArchiveEntry entry; + + if (!cacheFolder.exists()) { + cacheFolder.mkdirs(); + } + + while ((entry = fin.getNextTarEntry()) != null) { + + String parsedEntry = entry.getName(); + + if (entry.isDirectory()) { + continue; + } + + File currentFile = new File(cacheFolder, Paths.get(parsedEntry).getFileName().toString()); + IOUtils.copy(fin, Files.newOutputStream(currentFile.toPath())); + + outputFiles.add(currentFile); + + } + + } catch (IOException e) { + throw new OutputProcessingException("I/O error while extracting files from result archive [" + archive.getAbsolutePath() + "]", e); + } + + if(outputFiles.isEmpty()) { + throw new OutputProcessingException("No processable file found in result archive [" + archive.getAbsolutePath() + "]", null); + } + + return outputFiles; + + } + + private void deleteCache(File cacheFolder) { + try { + FileUtils.deleteDirectory(cacheFolder); + } catch (IOException e) { + LOG.error("I/O error while deleting cache dir [{}]", cacheFolder.getAbsolutePath()); + } + } + +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/DefaultOutputProcessing.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/ProcessedDatasetProcessing.java similarity index 65% rename from shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/DefaultOutputProcessing.java rename to shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/ProcessedDatasetProcessing.java index f635ffec87..1367f6552c 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/DefaultOutputProcessing.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/output/ProcessedDatasetProcessing.java @@ -1,22 +1,6 @@ package org.shanoir.ng.processing.carmin.output; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.function.Predicate; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; -import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; +import jakarta.ws.rs.NotFoundException; import org.apache.commons.io.IOUtils; import org.json.JSONArray; import org.json.JSONException; @@ -28,10 +12,10 @@ import org.shanoir.ng.importer.dto.ProcessedDatasetImportJob; import org.shanoir.ng.importer.service.ImporterService; import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.processing.carmin.service.ProcessingResourceService; import org.shanoir.ng.processing.model.DatasetProcessing; import org.shanoir.ng.processing.service.DatasetProcessingService; import org.shanoir.ng.shared.exception.EntityNotFoundException; -import org.shanoir.ng.shared.exception.ShanoirException; import org.shanoir.ng.shared.model.Study; import org.shanoir.ng.shared.model.Subject; import org.shanoir.ng.shared.repository.StudyRepository; @@ -42,18 +26,23 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import jakarta.ws.rs.NotFoundException; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.function.Predicate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; @Service -public class DefaultOutputProcessing extends OutputProcessing { +public class ProcessedDatasetProcessing extends OutputProcessing { - public static final String JSON_INFILE = "infile"; @Value("${vip.result-file-name}") private String resultFileName; - @Value("${vip.file-formats}") - private String[] listOfNiftiExt; - @Autowired private ImporterService importerService; @@ -69,78 +58,65 @@ public class DefaultOutputProcessing extends OutputProcessing { @Autowired private DatasetService datasetService; - private static final Logger LOG = LoggerFactory.getLogger(DefaultOutputProcessing.class); + @Autowired + private ProcessingResourceService processingResourceService; - @Override - public void manageTarGzResult(File in, File parent, CarminDatasetProcessing processing) { + private static final Logger LOG = LoggerFactory.getLogger(ProcessedDatasetProcessing.class); - LOG.info("Processing result file [{}]...", in.getAbsolutePath()); - try (TarArchiveInputStream fin = new TarArchiveInputStream( - new GzipCompressorInputStream(new FileInputStream(in)))) { - TarArchiveEntry entry; + @Override + public boolean canProcess(CarminDatasetProcessing processing) { + return true; + } - File cacheFolder = new File(parent.getAbsolutePath() + File.separator + "cache"); + @Override + public void manageTarGzResult(List resultFiles, File parent, CarminDatasetProcessing processing) throws OutputProcessingException { - if (!cacheFolder.exists()) { - cacheFolder.mkdirs(); - } + try { List outputFiles = new ArrayList<>(); - File resultJson = null; - // first, find "result.json" file - while ((entry = fin.getNextTarEntry()) != null) { - - String parsedEntry = entry.getName(); - - if (entry.isDirectory()) { - continue; - } - - File currentFile = new File(cacheFolder, Paths.get(parsedEntry).getFileName().toString()); - IOUtils.copy(fin, Files.newOutputStream(currentFile.toPath())); - - if (parsedEntry.endsWith(this.resultFileName)) { - resultJson = currentFile; + for(File file : resultFiles){ + if (file.getAbsolutePath().endsWith("/" + this.resultFileName)) { + resultJson = file; } else { // For all other files that are not a result.json or a folder, create a processed dataset and a dataset processing - outputFiles.add(currentFile); - LOG.info("Output file [{}] found in archive.", parsedEntry); + outputFiles.add(file); + LOG.info("Output file [{}] found in archive.", file.getAbsolutePath()); } } - List inputDatasets = this.getInputDatasets(resultJson, in.getName()); + List inputDatasets = this.getInputDatasets(resultJson, parent.getName()); if(inputDatasets.isEmpty()) { - throw new Exception("No input datasets found."); + throw new OutputProcessingException("No input datasets found.", null); } if(outputFiles.isEmpty()){ - throw new Exception("No processable file found in Tar result."); + throw new OutputProcessingException("No processable file found in Tar result.", null); } this.createProcessedDatasets(outputFiles, processing, inputDatasets); - this.deleteCacheDir(Paths.get(cacheFolder.getAbsolutePath())); - } catch (Exception e) { - LOG.error("An error occured while extracting result from result archive.", e); - importerService.createFailedJob(in.getPath()); + importerService.createFailedJob(parent.getPath()); + throw new OutputProcessingException("An error occured while extracting result from result archive.", e); } } private List getInputDatasets(File resultJson, String tarName) throws IOException, JSONException { - List datasetIds = new ArrayList<>(); + HashSet datasetIds = new HashSet<>(); List candidates = new ArrayList<>(); candidates.add(tarName); if (resultJson == null) { LOG.info("No result JSON found in archive."); + } else if (resultJson.length() == 0) { + LOG.warn("Result JSON [{}] is present but empty.", resultJson.getAbsolutePath()); } else { LOG.info("Processing result JSON [{}]...", resultJson.getName()); @@ -152,39 +128,40 @@ private List getInputDatasets(File resultJson, String tarName) throws I Iterator keys = json.keys(); while (keys.hasNext()) { String key = keys.next(); - Object value = json.get(key); - if (value instanceof JSONArray) { - // case "["id+XXX+filename.nii", "YYY+filename.nii", ...]" - JSONArray array = (JSONArray) value; + JSONArray array = json.optJSONArray(key); + if (array != null) { + // case "["resource_id+XXX+filename.nii", "resource_id+YYY+filename.nii", ...]" for (int i = 0; i < array.length(); i++) { - candidates.add(array.getString(i)); + String value = array.optString(i); + if(value != null){ + candidates.add(array.getString(i)); + } } } else { - // Case "id+XXX+filename.nii" - candidates.add((String) value); + String value = json.optString(key); + if(value != null){ + // Case "resource_id+XXX+filename.nii" + candidates.add(value); + } } } } for (String name : candidates) { - Long id = this.getDatasetIdFromFilename(name); - - if (id != null && !datasetIds.contains(id)) { - datasetIds.add(id); - } + datasetIds.addAll(this.getDatasetIdsFromFilename(name)); } - return datasetService.findByIdIn(datasetIds); + return datasetService.findByIdIn(new ArrayList<>(datasetIds)); } - private Long getDatasetIdFromFilename(String name){ - // "id+[dataset id]+whatever.nii" - Pattern p = Pattern.compile("id\\+(\\d+)\\+.*"); - Matcher m = p.matcher(name); - if (m.matches()) { - return Long.valueOf(m.group(1)); + public List getDatasetIdsFromFilename(String name){ + // "resource_id+[processing resource id]+whatever.nii" + Matcher matcher = Pattern.compile("resource_id\\+(.+)\\+.*").matcher(name); + if (matcher.matches()) { + return this.processingResourceService.findDatasetIdsByResourceId(matcher.group(1)); } - return null; + + return new ArrayList<>(); } /** @@ -194,7 +171,7 @@ private Long getDatasetIdFromFilename(String name){ * @throws EntityNotFoundException * @throws IOException */ - private void createProcessedDatasets(List processedFiles, CarminDatasetProcessing carminDatasetProcessing, List inputDatasets) throws EntityNotFoundException, IOException, Exception { + private void createProcessedDatasets(List processedFiles, CarminDatasetProcessing carminDatasetProcessing, List inputDatasets) throws Exception { // Create dataset processing DatasetProcessing processing = this.createProcessing(carminDatasetProcessing, inputDatasets); @@ -212,7 +189,7 @@ private void createProcessedDatasets(List processedFiles, CarminDatasetPro processedDataset.setProcessedDatasetType(ProcessedDatasetType.RECONSTRUCTEDDATASET); processedDataset.setStudyId(carminDatasetProcessing.getStudyId()); processedDataset.setStudyName(study.getName()); - processedDataset.setProcessedDatasetName(getNameWithoutExtension(file.getName())); + processedDataset.setProcessedDatasetName(carminDatasetProcessing.getName()); if(inputDatasets.size() != 0) { @@ -243,10 +220,6 @@ private void createProcessedDatasets(List processedFiles, CarminDatasetPro datasetProcessingService.update(processing); - // Remove datasets from current Carmin processing - carminDatasetProcessing.setInputDatasets(Collections.emptyList()); - datasetProcessingService.update(carminDatasetProcessing); - } private DatasetProcessing createProcessing(CarminDatasetProcessing carminDatasetProcessing, List inputDatasets) { @@ -261,17 +234,6 @@ private DatasetProcessing createProcessing(CarminDatasetProcessing carminDataset return processing; } - private void deleteCacheDir(Path directory) { - try { - Files.walk(directory) - .sorted(Comparator.reverseOrder()) - .map(Path::toFile) - .forEach(File::delete); - } catch (IOException e) { - LOG.error("I/O error while deleting cache dir [{}]", directory.toString()); - } - } - private String getNameWithoutExtension(String file) { int dotIndex = file.indexOf('.'); return (dotIndex == -1) ? file : file.substring(0, dotIndex); diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/repository/CarminDatasetProcessingRepository.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/repository/CarminDatasetProcessingRepository.java index f00f4343a6..fac31ba0bc 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/repository/CarminDatasetProcessingRepository.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/repository/CarminDatasetProcessingRepository.java @@ -1,11 +1,15 @@ package org.shanoir.ng.processing.carmin.repository; +import java.util.List; import java.util.Optional; import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.processing.carmin.model.ExecutionStatus; import org.springframework.data.repository.CrudRepository; public interface CarminDatasetProcessingRepository extends CrudRepository { public Optional findByIdentifier(String identifier); + + List findByStatus(ExecutionStatus status); } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/repository/ProcessingResourceRepository.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/repository/ProcessingResourceRepository.java new file mode 100644 index 0000000000..24789aae93 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/repository/ProcessingResourceRepository.java @@ -0,0 +1,15 @@ +package org.shanoir.ng.processing.carmin.repository; + +import org.shanoir.ng.processing.carmin.model.ProcessingResource; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface ProcessingResourceRepository extends CrudRepository { + + @Query(value = "SELECT dataset.id FROM ProcessingResource WHERE resourceId = :resourceId") + List findDatasetIdsByResourceId(String resourceId); +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitor.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitor.java index c40f2c8a1a..9a3acedb2e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitor.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitor.java @@ -1,22 +1,13 @@ package org.shanoir.ng.processing.carmin.schedule; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.PathMatcher; -import java.time.LocalDate; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Stream; - -import org.apache.commons.lang3.StringUtils; +import com.fasterxml.jackson.databind.ObjectMapper; import org.keycloak.representations.AccessTokenResponse; import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; import org.shanoir.ng.processing.carmin.model.Execution; import org.shanoir.ng.processing.carmin.model.ExecutionStatus; -import org.shanoir.ng.processing.carmin.output.DefaultOutputProcessing; import org.shanoir.ng.processing.carmin.output.OutputProcessing; +import org.shanoir.ng.processing.carmin.output.OutputProcessingException; +import org.shanoir.ng.processing.carmin.output.OutputProcessingService; import org.shanoir.ng.processing.carmin.service.CarminDatasetProcessingService; import org.shanoir.ng.shared.event.ShanoirEvent; import org.shanoir.ng.shared.event.ShanoirEventService; @@ -29,11 +20,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; +import org.springframework.http.*; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -41,9 +28,7 @@ import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; -import com.fasterxml.jackson.databind.ObjectMapper; - -import jakarta.annotation.PostConstruct; +import java.time.LocalDate; /** * CRON job to request VIP api and create processedDataset * @@ -52,8 +37,6 @@ @Service public class ExecutionStatusMonitor implements ExecutionStatusMonitorService { - private static final String DEFAULT_OUTPUT = "default"; - @Value("${vip.uri}") private String VIP_URI; @@ -76,29 +59,22 @@ public class ExecutionStatusMonitor implements ExecutionStatusMonitorService { private KeycloakServiceAccountUtils keycloakServiceAccountUtils; @Autowired - private ObjectMapper mapper; + private ShanoirEventService eventService; @Autowired - private DefaultOutputProcessing defaultOutputProcessing; - - @Autowired - private ShanoirEventService eventService; - - // Map of output methods to execute. - private static Map outputProcessingMap; - - @PostConstruct - public void Initialize() { - // Init output map - Map aMap = new HashMap<>(); - aMap.put(DEFAULT_OUTPUT, defaultOutputProcessing); - outputProcessingMap = Collections.unmodifiableMap(aMap); - } + private OutputProcessingService outputProcessingService; + /** + * Async job that monitor the state of the VIP execution and process its outcome + * + * @param identifier unique id of the VIP execution + * @throws EntityNotFoundException + * @throws SecurityException + */ @Async @Override @Transactional - public void startJob(String identifier) throws EntityNotFoundException, SecurityException { + public void startMonitoringJob(String identifier) throws EntityNotFoundException, SecurityException { int attempts = 1; this.identifier = identifier; @@ -114,9 +90,9 @@ public void startJob(String identifier) throws EntityNotFoundException, Security .findByIdentifier(this.identifier) .orElseThrow(() -> new EntityNotFoundException( "Processing [" + this.identifier + "] not found")); + processing.setProcessingDate(LocalDate.now()); - String execLabel = "VIP Execution [" + processing.getName() + "]"; - + String execLabel = this.getExecLabel(processing); ShanoirEvent event = new ShanoirEvent( ShanoirEventType.IMPORT_DATASET_EVENT, @@ -127,138 +103,125 @@ public void startJob(String identifier) throws EntityNotFoundException, Security 0.5f); eventService.publishEvent(event); - processing.setProcessingDate(LocalDate.now()); while (!stop.get()) { - // init headers with the active access token - HttpHeaders headers = new HttpHeaders(); - headers.set("Authorization", "Bearer " + token); - HttpEntity entity = new HttpEntity(headers); - - // check how many times the loop tried to get the execution's info without success (only UNAUTHORIZED error) - if(attempts >= 3){ - String msg = "Failed to get execution details from VIP in " + attempts + " attempts"; - LOG.error(msg); - LOG.error("Stopping the thread..."); - stop.set(true); - this.setJobInError(event, execLabel + " : " + msg); - break; - } - - try { - ResponseEntity executionResponseEntity = restTemplate.exchange(uri, HttpMethod.GET, entity, Execution.class); - Execution execution = executionResponseEntity.getBody(); - // init attempts due to successful response - attempts = 1; - switch (execution.getStatus()) { - case FINISHED: - - processing.setStatus(ExecutionStatus.FINISHED); - - this.carminDatasetProcessingService.updateCarminDatasetProcessing(processing); + try{ - LOG.info("{} status is [{}]", execLabel, ExecutionStatus.FINISHED.getRestLabel()); - event.setMessage(execLabel + " : Finished. Processing imported results..."); - eventService.publishEvent(event); + Execution execution = this.getExecutionFromVIP(token, attempts, restTemplate, uri); - // untar the .tgz files - final File userImportDir = new File( - this.importDir + File.separator + - processing.getResultsLocation()); + if(execution == null){ + token = this.refreshServiceAccountAccessToken(); + attempts++; + continue; + } - LOG.info("Processing result in import directory [{}]...", userImportDir.getAbsolutePath()); + attempts = 1; - final PathMatcher matcher = userImportDir.toPath().getFileSystem() - .getPathMatcher("glob:**/*.{tgz,tar.gz}"); - String outputProcessingKey = StringUtils.isEmpty(processing.getOutputProcessing()) ? DEFAULT_OUTPUT : processing.getOutputProcessing(); + switch (execution.getStatus()) { + case FINISHED: + this.processFinishedJob(processing, event); + break; - processing.setProcessingDate(LocalDate.now()); + case UNKOWN: + case EXECUTION_FAILED: + case KILLED: - try (Stream stream = Files.list(userImportDir.toPath())) { + this.processKilledJob(processing, event, execution); + break; - stream.filter(matcher::matches) - .forEach(zipFile -> { - outputProcessingMap.get(outputProcessingKey).manageTarGzResult(zipFile.toFile(), userImportDir.getAbsoluteFile(), processing); - }); + case RUNNING: + try{ + Thread.sleep(sleepTime); // sleep/stop a thread for 20 seconds + } catch (InterruptedException e) { + throw new OutputProcessingException("Thread exception", e); + } + break; + default: + stop.set(true); + break; + } - } catch (IOException e) { + }catch (OutputProcessingException e){ + LOG.error(e.getMessage(), e.getCause()); + this.setJobInError(event, execLabel + " : " + e.getMessage()); + LOG.warn("Stopping thread..."); + stop.set(true); + } + } + } - String msg = "I/O error while listing files in import directory"; - LOG.error(msg, e); - this.setJobInError(event, execLabel + " : " + msg); + private String getExecLabel(CarminDatasetProcessing processing) { + return "VIP Execution [" + processing.getName() + "]"; + } - stop.set(true); - break; - } + public void processKilledJob(CarminDatasetProcessing processing, ShanoirEvent event, Execution execution) throws EntityNotFoundException { - LOG.info("Execution status updated, stopping job..."); + String execLabel = this.getExecLabel(processing); - stop.set(true); + LOG.warn("{} status is [{}]", execLabel, execution.getStatus().getRestLabel()); - event.setMessage(execLabel + " : Finished"); - event.setStatus(ShanoirEvent.SUCCESS); - event.setProgress(1f); - eventService.publishEvent(event); + processing.setStatus(execution.getStatus()); + this.carminDatasetProcessingService.updateCarminDatasetProcessing(processing); - break; + LOG.info("Execution status updated, stopping job..."); - case UNKOWN: - case EXECUTION_FAILED: - case KILLED: + stop.set(true); - LOG.warn("{} status is [{}]", execLabel, execution.getStatus().getRestLabel()); + this.setJobInError(event, execLabel + " : " + execution.getStatus().getRestLabel() + + (execution.getErrorCode() != null ? " (Error code : " + execution.getErrorCode() + ")" : "")); + } - processing.setStatus(execution.getStatus()); - this.carminDatasetProcessingService.updateCarminDatasetProcessing(processing); + public void processFinishedJob(CarminDatasetProcessing processing, ShanoirEvent event) throws EntityNotFoundException, OutputProcessingException { - LOG.info("Execution status updated, stopping job..."); + String execLabel = this.getExecLabel(processing); + processing.setStatus(ExecutionStatus.FINISHED); + processing.setProcessingDate(LocalDate.now()); - stop.set(true); + this.carminDatasetProcessingService.updateCarminDatasetProcessing(processing); - this.setJobInError(event, execLabel + " : " + execution.getStatus().getRestLabel() - + (execution.getErrorCode() != null ? " (Error code : " + execution.getErrorCode() + ")" : "")); + LOG.info("{} status is [{}]", execLabel, ExecutionStatus.FINISHED.getRestLabel()); + event.setMessage(execLabel + " : Finished. Processing imported results..."); + eventService.publishEvent(event); - break; + this.outputProcessingService.process(processing); - case RUNNING: - Thread.sleep(sleepTime); // sleep/stop a thread for 20 seconds - break; - default: - stop.set(true); - break; - } - } catch (HttpStatusCodeException e) { - // in case of an error with response payload - if (e.getStatusCode() == HttpStatus.UNAUTHORIZED) { - LOG.info("Unauthorized : refreshing token... ({} attempts)", attempts); - token = this.refreshServiceAccountAccessToken(); - // inc attempts. - attempts++; - } else { + LOG.info("Execution status updated, stopping job..."); - String msg = "Failed to get execution details from VIP in " + attempts + " attempts"; - LOG.error(msg , e); - this.setJobInError(event, execLabel + " : " + msg); + stop.set(true); - stop.set(true); - } - } catch (RestClientException e) { - // in case of an error with no response payload - String msg = "No response payload in execution infos from VIP"; - LOG.error(msg, e); - this.setJobInError(event, execLabel + " : " + msg); + event.setMessage(execLabel + " : Finished"); + event.setStatus(ShanoirEvent.SUCCESS); + event.setProgress(1f); + eventService.publishEvent(event); + } - stop.set(true); - } catch (InterruptedException e) { + private Execution getExecutionFromVIP(String token, int attempts, RestTemplate restTemplate, String uri) throws OutputProcessingException { - String msg = "Thread exception"; - LOG.error(msg, e); - this.setJobInError(event, execLabel + " : " + msg); + // check how many times the loop tried to get the execution's info without success (only UNAUTHORIZED error) + if(attempts >= 3){ + throw new OutputProcessingException("Failed to get execution details from VIP in " + attempts + " attempts", null); + } - stop.set(true); + // init headers with the active access token + HttpHeaders headers = new HttpHeaders(); + headers.set("Authorization", "Bearer " + token); + HttpEntity entity = new HttpEntity(headers); + + try { + ResponseEntity executionResponseEntity = restTemplate.exchange(uri, HttpMethod.GET, entity, Execution.class); + return executionResponseEntity.getBody(); + } catch (HttpStatusCodeException e) { + // in case of an error with response payload + if (e.getStatusCode() == HttpStatus.UNAUTHORIZED) { + LOG.info("Unauthorized : refreshing token... ({} attempts)", attempts); + return null; + } else { + throw new OutputProcessingException("Failed to get execution details from VIP in " + attempts + " attempts", e); } + } catch (RestClientException e) { + throw new OutputProcessingException("No response payload in execution infos from VIP", e); } } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitorService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitorService.java index d47eb90c77..874d03717a 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitorService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/schedule/ExecutionStatusMonitorService.java @@ -5,5 +5,5 @@ public interface ExecutionStatusMonitorService { - void startJob(String identifier) throws EntityNotFoundException, SecurityException; + void startMonitoringJob(String identifier) throws EntityNotFoundException, SecurityException; } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingService.java index 9aaf6f8e34..f32e4a3efb 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingService.java @@ -1,27 +1,28 @@ package org.shanoir.ng.processing.carmin.service; -import java.util.List; -import java.util.Optional; - import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.processing.dto.ParameterResourcesDTO; import org.shanoir.ng.shared.exception.EntityNotFoundException; import org.shanoir.ng.shared.exception.MicroServiceCommunicationException; import org.springframework.security.access.prepost.PreAuthorize; +import java.util.List; +import java.util.Optional; + public interface CarminDatasetProcessingService { /** - * Find entity by its id. + * Find entity by its id. * * @param id id * @return an entity or null. */ @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT', 'USER')") Optional findById(Long id); - + /** * Get all entities. - * + * * @return a list of manufacturers. */ @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT', 'USER')") @@ -42,20 +43,20 @@ public interface CarminDatasetProcessingService { * @param entity the entity to update. * @return updated entity. * @throws EntityNotFoundException - * @throws MicroServiceCommunicationException + * @throws MicroServiceCommunicationException */ @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT')") CarminDatasetProcessing update(CarminDatasetProcessing entity) throws EntityNotFoundException; - + /** * Delete an entity. - * + * * @param id the entity id to be deleted. * @throws EntityNotFoundException if the entity cannot be found. */ @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT')") void deleteById(Long id) throws EntityNotFoundException; - + /** * save a CarminDatasetProcessing * @@ -74,4 +75,7 @@ public interface CarminDatasetProcessingService { @PreAuthorize("hasAnyRole('ADMIN', 'EXPERT')") CarminDatasetProcessing updateCarminDatasetProcessing(CarminDatasetProcessing carminDatasetProcessing) throws EntityNotFoundException; + List findAllRunning(); + + List createProcessingResources(CarminDatasetProcessing createdProcessing, List parameterDatasets); } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingServiceImpl.java index a73ff668b0..2be725dec7 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/CarminDatasetProcessingServiceImpl.java @@ -1,103 +1,184 @@ package org.shanoir.ng.processing.carmin.service; -import java.util.List; -import java.util.Optional; - +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.dataset.service.DatasetService; import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.processing.carmin.model.ExecutionStatus; import org.shanoir.ng.processing.carmin.repository.CarminDatasetProcessingRepository; import org.shanoir.ng.processing.carmin.security.CarminDatasetProcessingSecurityService; +import org.shanoir.ng.processing.dto.ParameterResourcesDTO; import org.shanoir.ng.shared.exception.EntityNotFoundException; import org.shanoir.ng.utils.Utils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.*; + /** * @author KhalilKes */ @Service public class CarminDatasetProcessingServiceImpl implements CarminDatasetProcessingService { - @Autowired - private CarminDatasetProcessingRepository repository; - - @Autowired - private CarminDatasetProcessingSecurityService carminDatasetProcessingSecurityService; - - private final String RIGHT_STR = "CAN_SEE_ALL"; - - protected CarminDatasetProcessing updateValues(CarminDatasetProcessing from, CarminDatasetProcessing to) { - to.setIdentifier(from.getIdentifier()); - to.setStatus(from.getStatus()); - to.setName(from.getName()); - to.setPipelineIdentifier(from.getPipelineIdentifier()); - to.setStartDate(from.getStartDate()); - to.setEndDate(from.getEndDate()); - to.setTimeout(from.getTimeout()); - to.setResultsLocation(from.getResultsLocation()); - to.setDatasetProcessingType(from.getDatasetProcessingType()); - to.setComment(from.getComment()); - to.setInputDatasets(from.getInputDatasets()); - to.setOutputDatasets(from.getOutputDatasets()); - to.setProcessingDate(from.getProcessingDate()); - to.setStudyId(from.getStudyId()); - return to; - } - - @Override - public CarminDatasetProcessing createCarminDatasetProcessing( - final CarminDatasetProcessing carminDatasetProcessing) { - CarminDatasetProcessing savedEntity = repository.save(carminDatasetProcessing); - return savedEntity; - } - - @Override - public Optional findByIdentifier(String identifier) { - return repository.findByIdentifier(identifier); - } - - @Override - public List findAllAllowed() { - return carminDatasetProcessingSecurityService.filterCarminDatasetList(findAll(), RIGHT_STR); - } - - @Override - public CarminDatasetProcessing updateCarminDatasetProcessing(final CarminDatasetProcessing carminDatasetProcessing) - throws EntityNotFoundException { - final Optional entityDbOpt = repository - .findById(carminDatasetProcessing.getId()); - final CarminDatasetProcessing entityDb = entityDbOpt.orElseThrow( - () -> new EntityNotFoundException(carminDatasetProcessing.getClass(), carminDatasetProcessing.getId())); - - updateValues(carminDatasetProcessing, (CarminDatasetProcessing) entityDb); - return (CarminDatasetProcessing) repository.save(entityDb); - - } - - public Optional findById(final Long id) { - return repository.findById(id); - } - - public List findAll() { - return Utils.toList(repository.findAll()); - } - - public CarminDatasetProcessing create(final CarminDatasetProcessing entity) { - CarminDatasetProcessing savedEntity = repository.save(entity); - return savedEntity; - } - - public CarminDatasetProcessing update(final CarminDatasetProcessing entity) throws EntityNotFoundException { - final Optional entityDbOpt = repository.findById(entity.getId()); - final CarminDatasetProcessing entityDb = entityDbOpt.orElseThrow( - () -> new EntityNotFoundException(entity.getClass(), entity.getId())); - updateValues(entity, entityDb); - return repository.save(entityDb); - } - - public void deleteById(final Long id) throws EntityNotFoundException { - final Optional entity = repository.findById(id); - entity.orElseThrow(() -> new EntityNotFoundException("Cannot find entity with id = " + id)); - repository.deleteById(id); - } + @Autowired + private CarminDatasetProcessingRepository repository; + + @Autowired + private ProcessingResourceService processingResourceService; + + @Autowired + private DatasetService datasetService; + + @Autowired + private CarminDatasetProcessingSecurityService carminDatasetProcessingSecurityService; + + private final String RIGHT_STR = "CAN_SEE_ALL"; + + private CarminDatasetProcessing updateValues(CarminDatasetProcessing from, CarminDatasetProcessing to) { + to.setIdentifier(from.getIdentifier()); + to.setStatus(from.getStatus()); + to.setName(from.getName()); + to.setPipelineIdentifier(from.getPipelineIdentifier()); + to.setStartDate(from.getStartDate()); + to.setEndDate(from.getEndDate()); + to.setTimeout(from.getTimeout()); + to.setResultsLocation(from.getResultsLocation()); + + to.setDatasetProcessingType(from.getDatasetProcessingType()); + to.setComment(from.getComment()); + to.setInputDatasets(from.getInputDatasets()); + to.setOutputDatasets(from.getOutputDatasets()); + to.setProcessingDate(from.getProcessingDate()); + to.setStudyId(from.getStudyId()); + + return to; + } + + @Override + public Optional findById(Long id) { + return repository.findById(id); + } + + @Override + public List findAll() { + return Utils.toList(repository.findAll()); + } + + @Override + public CarminDatasetProcessing create(CarminDatasetProcessing entity) { + return repository.save(entity); + } + + @Override + public CarminDatasetProcessing update(CarminDatasetProcessing entity) throws EntityNotFoundException { + final CarminDatasetProcessing processing = repository.findById(entity.getId()).orElse(null); + if (processing == null) throw new EntityNotFoundException(CarminDatasetProcessing.class, entity.getId()); + return repository.save(processing); + } + + @Override + public void deleteById(Long id) throws EntityNotFoundException { + repository.deleteById(id); + } + + @Override + public CarminDatasetProcessing createCarminDatasetProcessing( + final CarminDatasetProcessing carminDatasetProcessing) { + CarminDatasetProcessing savedEntity = repository.save(carminDatasetProcessing); + return savedEntity; + } + + @Override + public Optional findByIdentifier(String identifier) { + return repository.findByIdentifier(identifier); + } + + @Override + public List findAllAllowed() { + return carminDatasetProcessingSecurityService.filterCarminDatasetList(findAll(), RIGHT_STR); + } + + @Override + public CarminDatasetProcessing updateCarminDatasetProcessing(final CarminDatasetProcessing carminDatasetProcessing) + throws EntityNotFoundException { + final Optional entityDbOpt = repository + .findById(carminDatasetProcessing.getId()); + final CarminDatasetProcessing entityDb = entityDbOpt.orElseThrow( + () -> new EntityNotFoundException(carminDatasetProcessing.getClass(), + carminDatasetProcessing.getId())); + + this.updateValues(carminDatasetProcessing, entityDb); + return repository.save(entityDb); + + } + + @Override + public List findAllRunning() { + return repository.findByStatus(ExecutionStatus.RUNNING); + } + + @Override + public List createProcessingResources(CarminDatasetProcessing processing, List parameterDatasets) { + + if(parameterDatasets == null || parameterDatasets.isEmpty()){ + return new ArrayList<>(); + } + + for (ParameterResourcesDTO dto : parameterDatasets) { + + dto.setResourceIds(new ArrayList<>()); + + HashMap> datasetsByEntityId = new HashMap<>(); + for (Long id : dto.getDatasetIds()) { + Dataset ds = datasetService.findById(id); + + Long entityId = null; + switch (dto.getGroupBy()) { + case ACQUISITION: + if (ds.getDatasetAcquisition() != null) { + entityId = ds.getDatasetAcquisition().getId(); + } + break; + case EXAMINATION: + if (ds.getDatasetAcquisition() != null + && ds.getDatasetAcquisition().getExamination() != null) { + entityId = ds.getDatasetAcquisition().getExamination().getId(); + } + break; + case STUDY: + if (ds.getDatasetAcquisition() != null + && ds.getDatasetAcquisition().getExamination() != null + && ds.getDatasetAcquisition().getExamination().getStudy() != null) { + entityId = ds.getDatasetAcquisition().getExamination().getStudy().getId(); + } + break; + case SUBJECT: + if (ds.getSubjectId() != null) { + entityId = ds.getSubjectId(); + } + break; + case DATASET: + entityId = ds.getId(); + break; + } + + if(entityId != null) { + datasetsByEntityId.putIfAbsent(entityId, new ArrayList<>()); + datasetsByEntityId.get(entityId).add(ds); + } + + } + + for(Map.Entry> entry : datasetsByEntityId.entrySet()) { + String resourceId = processingResourceService.create(processing, entry.getValue()); + dto.getResourceIds().add(resourceId); + } + + } + + return parameterDatasets; + + + } } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/ProcessingResourceService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/ProcessingResourceService.java new file mode 100644 index 0000000000..c35f345c4c --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/ProcessingResourceService.java @@ -0,0 +1,16 @@ +package org.shanoir.ng.processing.carmin.service; + +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; + +import java.util.List; + +public interface ProcessingResourceService { + + List findDatasetsByResourceId(String resourceId); + + + List findDatasetIdsByResourceId(String resourceId); + + String create(CarminDatasetProcessing processing, List datasets); +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/ProcessingResourceServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/ProcessingResourceServiceImpl.java new file mode 100644 index 0000000000..a7f9006f20 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/carmin/service/ProcessingResourceServiceImpl.java @@ -0,0 +1,44 @@ +package org.shanoir.ng.processing.carmin.service; + +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.dataset.service.DatasetService; +import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.processing.carmin.model.ProcessingResource; +import org.shanoir.ng.processing.carmin.repository.ProcessingResourceRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Service +public class ProcessingResourceServiceImpl implements ProcessingResourceService { + + @Autowired + public ProcessingResourceRepository repository; + @Autowired + public DatasetService datasetService; + + @Override + public List findDatasetsByResourceId(String resourceId) { + List ids = repository.findDatasetIdsByResourceId(resourceId); + return datasetService.findByIdIn(ids); + } + + @Override + public List findDatasetIdsByResourceId(String resourceId) { + return repository.findDatasetIdsByResourceId(resourceId); + } + + @Override + public String create(CarminDatasetProcessing processing, List datasets) { + List processingResources = new ArrayList<>(); + String resourceId = UUID.randomUUID().toString(); + for(Dataset dataset : datasets){ + processingResources.add(new ProcessingResource(processing, dataset, resourceId)); + } + repository.saveAll(processingResources); + return resourceId; + } +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApi.java index e177bdfed8..c51c9bf3f3 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApi.java @@ -14,30 +14,22 @@ package org.shanoir.ng.processing.controler; -import java.util.List; - +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 jakarta.validation.Valid; - import org.shanoir.ng.dataset.dto.DatasetDTO; import org.shanoir.ng.processing.dto.DatasetProcessingDTO; import org.shanoir.ng.processing.model.DatasetProcessing; -import org.shanoir.ng.shared.exception.ErrorModel; import org.shanoir.ng.shared.exception.RestServiceException; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import io.swagger.v3.oas.annotations.tags.Tag; -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 org.springframework.web.bind.annotation.*; + +import java.util.List; @Tag(name = "datasetProcessing") @RequestMapping("/datasetProcessing") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApiController.java index 4088cbaac4..d5d6ac23bf 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/controler/DatasetProcessingApiController.java @@ -14,15 +14,13 @@ package org.shanoir.ng.processing.controler; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.Valid; import org.shanoir.ng.dataset.dto.DatasetDTO; import org.shanoir.ng.dataset.dto.mapper.DatasetMapper; -import org.shanoir.ng.dataset.dto.mapper.DatasetProcessingMapper; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.processing.dto.DatasetProcessingDTO; +import org.shanoir.ng.processing.dto.mapper.DatasetProcessingMapper; import org.shanoir.ng.processing.model.DatasetProcessing; import org.shanoir.ng.processing.service.DatasetProcessingService; import org.shanoir.ng.shared.error.FieldErrorMap; @@ -39,8 +37,9 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.validation.Valid; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; @Controller public class DatasetProcessingApiController implements DatasetProcessingApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/CarminDatasetProcessingDTO.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/CarminDatasetProcessingDTO.java new file mode 100644 index 0000000000..5e01354d77 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/CarminDatasetProcessingDTO.java @@ -0,0 +1,96 @@ +package org.shanoir.ng.processing.dto; + +import org.shanoir.ng.processing.carmin.model.ExecutionStatus; + +import java.util.List; + +public class CarminDatasetProcessingDTO extends DatasetProcessingDTO { + + private String identifier; + + private String name; + + private String pipelineIdentifier; + + private int timeout; + + private String outputProcessing; + + /** + * the status of the execution + */ + private ExecutionStatus status; + + private String resultsLocation; + + private Long startDate; + + private Long endDate; + + private List parametersResources; + + + public String getIdentifier() { + return identifier; + } + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getPipelineIdentifier() { + return pipelineIdentifier; + } + public void setPipelineIdentifier(String pipelineIdentifier) { + this.pipelineIdentifier = pipelineIdentifier; + } + public int getTimeout() { + return timeout; + } + public void setTimeout(int timeout) { + this.timeout = timeout; + } + public ExecutionStatus getStatus() { + return status; + } + public void setStatus(ExecutionStatus status) { + this.status = status; + } + + public String getResultsLocation() { + return resultsLocation; + } + public void setResultsLocation(String resultsLocation) { + this.resultsLocation = resultsLocation; + } + public Long getStartDate() { + return startDate; + } + public void setStartDate(Long startDate) { + this.startDate = startDate; + } + public Long getEndDate() { + return endDate; + } + public void setEndDate(Long endDate) { + this.endDate = endDate; + } + public String getOutputProcessing() { + return outputProcessing; + } + public void setOutputProcessing(String outputProcessing) { + this.outputProcessing = outputProcessing; + } + + public List getParametersResources() { + return parametersResources; + } + + public void setParametersResources(List parametersResources) { + this.parametersResources = parametersResources; + } +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/GroupByEnum.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/GroupByEnum.java new file mode 100644 index 0000000000..ea338d5359 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/GroupByEnum.java @@ -0,0 +1,5 @@ +package org.shanoir.ng.processing.dto; + +public enum GroupByEnum { + DATASET, ACQUISITION, EXAMINATION, STUDY, SUBJECT +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/ParameterResourcesDTO.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/ParameterResourcesDTO.java new file mode 100644 index 0000000000..f74652565c --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/ParameterResourcesDTO.java @@ -0,0 +1,43 @@ +package org.shanoir.ng.processing.dto; + +import java.util.List; + +public class ParameterResourcesDTO { + + private String parameter; + private List resourceIds; + private GroupByEnum groupBy; + List datasetIds; + + public String getParameter() { + return parameter; + } + + public void setParameter(String parameter) { + this.parameter = parameter; + } + + public GroupByEnum getGroupBy() { + return groupBy; + } + + public void setGroupBy(GroupByEnum groupBy) { + this.groupBy = groupBy; + } + + public List getDatasetIds() { + return datasetIds; + } + + public void setDatasetIds(List datasetIds) { + this.datasetIds = datasetIds; + } + + public List getResourceIds() { + return resourceIds; + } + + public void setResourceIds(List resourceIds) { + this.resourceIds = resourceIds; + } +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/mapper/CarminDatasetProcessingMapper.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/mapper/CarminDatasetProcessingMapper.java new file mode 100644 index 0000000000..e5b6d96184 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/mapper/CarminDatasetProcessingMapper.java @@ -0,0 +1,68 @@ +/** + * Shanoir NG - Import, manage and share neuroimaging data + * Copyright (C) 2009-2019 Inria - https://www.inria.fr/ + * Contact us on https://project.inria.fr/shanoir/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html + */ + +package org.shanoir.ng.processing.dto.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.MapperConfig; +import org.mapstruct.Mapping; +import org.mapstruct.ObjectFactory; +import org.shanoir.ng.dataset.dto.DatasetDTO; +import org.shanoir.ng.dataset.dto.mapper.DatasetMapper; +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.dataset.service.DatasetUtils; +import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.processing.dto.CarminDatasetProcessingDTO; +import org.shanoir.ng.processing.dto.DatasetProcessingDTO; +import org.shanoir.ng.processing.model.DatasetProcessing; + +import java.util.List; + +@Mapper(componentModel = "spring", uses = { DatasetProcessingMapper.class, DatasetMapper.class }) +public interface CarminDatasetProcessingMapper { + + /** + * Map a @CarminDatasetProcessing to a @CarminDatasetProcessingDTO. + * + * @param processing + * dataset. + * @return dataset DTO. + */ + @Mapping(target = "parametersResources", ignore = true) + CarminDatasetProcessingDTO carminDatasetProcessingToCarminDatasetProcessingDTO(CarminDatasetProcessing processing); + + /** + * Map list of @CarminDatasetProcessing to list of @CarminDatasetProcessingDTO. + * + * @param datasetProcessings processings + * list of dataset processings. + * @return list of dataset processings DTO. + */ + List carminDatasetProcessingsToCarminDatasetProcessingDTOs(List datasetProcessings); + + /** + * Map @CarminDatasetProcessingDTO to @CarminDatasetProcessing + * + * @param dto + * @return + */ + CarminDatasetProcessing carminDatasetProcessingDTOToCarminDatasetProcessing(CarminDatasetProcessingDTO dto); + + @ObjectFactory + default Dataset createDataset(DatasetDTO dto) { + return DatasetUtils.buildDatasetFromType(dto.getType()); + } + + +} diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/dto/mapper/DatasetProcessingMapper.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/mapper/DatasetProcessingMapper.java similarity index 89% rename from shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/dto/mapper/DatasetProcessingMapper.java rename to shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/mapper/DatasetProcessingMapper.java index 69f596d9b9..2ee21d850e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/dataset/dto/mapper/DatasetProcessingMapper.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/dto/mapper/DatasetProcessingMapper.java @@ -12,11 +12,12 @@ * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ -package org.shanoir.ng.dataset.dto.mapper; +package org.shanoir.ng.processing.dto.mapper; import java.util.List; import org.mapstruct.Mapper; +import org.shanoir.ng.dataset.dto.mapper.DatasetMapper; import org.shanoir.ng.processing.model.DatasetProcessing; import org.shanoir.ng.processing.dto.DatasetProcessingDTO; @@ -26,7 +27,7 @@ public interface DatasetProcessingMapper { /** * Map a @DatasetMetadata to a @DatasetMetadataDTO. * - * @param datasets + * @param processing * dataset. * @return dataset DTO. */ @@ -35,7 +36,7 @@ public interface DatasetProcessingMapper { /** * Map list of @DatasetProcessing to list of @DatasetProcessingDTO. * - * @param dataset processings + * @param datasetProcessings processings * list of dataset processings. * @return list of dataset processings DTO. */ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/model/DatasetProcessing.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/model/DatasetProcessing.java index 3522590775..5675bd451d 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/model/DatasetProcessing.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/model/DatasetProcessing.java @@ -14,22 +14,16 @@ package org.shanoir.ng.processing.model; -import java.util.ArrayList; -import java.time.LocalDate; -import java.util.List; - -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.OneToMany; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.shared.core.model.AbstractEntity; import org.shanoir.ng.shared.dateTime.LocalDateAnnotations; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + /** * Dataset Processing. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/service/DatasetProcessingServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/service/DatasetProcessingServiceImpl.java index 77f6b89575..cdcb10511e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/service/DatasetProcessingServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/processing/service/DatasetProcessingServiceImpl.java @@ -14,9 +14,6 @@ package org.shanoir.ng.processing.service; -import java.util.List; -import java.util.Optional; - import org.shanoir.ng.processing.model.DatasetProcessing; import org.shanoir.ng.processing.repository.DatasetProcessingRepository; import org.shanoir.ng.shared.exception.EntityNotFoundException; @@ -24,6 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Optional; + /** * center service implementation. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/model/DatasetProperty.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/model/DatasetProperty.java new file mode 100644 index 0000000000..93925704a3 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/model/DatasetProperty.java @@ -0,0 +1,58 @@ +package org.shanoir.ng.property.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.processing.model.DatasetProcessing; +import org.shanoir.ng.shared.core.model.AbstractEntity; + +@Entity +public class DatasetProperty extends AbstractEntity { + + private static final long serialVersionUID = 7602484872590225134L; + + @ManyToOne + @JoinColumn(name = "dataset_id") + private Dataset dataset; + + @ManyToOne + @JoinColumn(name = "dataset_processing_id") + private DatasetProcessing processing; + + private String name; + + private String value; + + public Dataset getDataset() { + return dataset; + } + + public void setDataset(Dataset dataset) { + this.dataset = dataset; + } + + public DatasetProcessing getProcessing() { + return processing; + } + + public void setProcessing(DatasetProcessing processing) { + this.processing = processing; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/repository/DatasetPropertyRepository.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/repository/DatasetPropertyRepository.java new file mode 100644 index 0000000000..f2d17342ac --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/repository/DatasetPropertyRepository.java @@ -0,0 +1,10 @@ +package org.shanoir.ng.property.repository; + +import org.shanoir.ng.property.model.DatasetProperty; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface DatasetPropertyRepository extends CrudRepository { + +} \ No newline at end of file diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/service/DatasetPropertyService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/service/DatasetPropertyService.java new file mode 100644 index 0000000000..74ff816736 --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/service/DatasetPropertyService.java @@ -0,0 +1,11 @@ + +package org.shanoir.ng.property.service; + +import org.shanoir.ng.property.model.DatasetProperty; + +import java.util.List; + +public interface DatasetPropertyService { + + List createAll(List properties); +} \ No newline at end of file diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/service/DatasetPropertyServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/service/DatasetPropertyServiceImpl.java new file mode 100644 index 0000000000..79da42034d --- /dev/null +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/property/service/DatasetPropertyServiceImpl.java @@ -0,0 +1,20 @@ +package org.shanoir.ng.property.service; + +import org.shanoir.ng.property.model.DatasetProperty; +import org.shanoir.ng.property.repository.DatasetPropertyRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class DatasetPropertyServiceImpl implements DatasetPropertyService { + + @Autowired + private DatasetPropertyRepository repository; + @Override + public List createAll(List properties) { + repository.saveAll(properties); + return properties; + } +} \ No newline at end of file diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/CodedScore.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/CodedScore.java index 286e500d61..049851f819 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/CodedScore.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/CodedScore.java @@ -1,11 +1,6 @@ package org.shanoir.ng.score; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.PrimaryKeyJoinColumn; -import jakarta.persistence.Table; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/NumericalScore.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/NumericalScore.java index 3f35ba5d0a..50f74bac55 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/NumericalScore.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/NumericalScore.java @@ -1,11 +1,6 @@ package org.shanoir.ng.score; -import jakarta.persistence.Entity; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.PrimaryKeyJoinColumn; -import jakarta.persistence.Table; - +import jakarta.persistence.*; import org.shanoir.ng.examination.model.ScientificArticle; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/ScaleItem.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/ScaleItem.java index 931ec6ff01..0df98d68c3 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/ScaleItem.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/ScaleItem.java @@ -1,18 +1,16 @@ package org.shanoir.ng.score; -import java.sql.Types; - -import org.hibernate.annotations.JdbcTypeCode; -import org.shanoir.ng.examination.model.CodedVariable; -import org.shanoir.ng.shared.core.model.AbstractEntity; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; - import jakarta.persistence.Entity; import jakarta.persistence.FetchType; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import org.hibernate.annotations.JdbcTypeCode; +import org.shanoir.ng.examination.model.CodedVariable; +import org.shanoir.ng.shared.core.model.AbstractEntity; + +import java.sql.Types; /** * The Class ScaleItem. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/Score.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/Score.java index 3544c507c4..dbfd2b961e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/Score.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/score/Score.java @@ -14,21 +14,13 @@ package org.shanoir.ng.score; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.PostLoad; - +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.persistence.*; import org.shanoir.ng.examination.model.VariableAssessment; import org.shanoir.ng.shared.hateoas.HalEntity; import org.shanoir.ng.shared.hateoas.Links; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - /** * Score. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Center.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Center.java index b50f1c2e47..ce5d666e10 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Center.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Center.java @@ -16,7 +16,6 @@ import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; - import org.shanoir.ng.shared.core.model.IdName; /** diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/DiffusionGradient.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/DiffusionGradient.java index c40a1ca910..2401a5d9cc 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/DiffusionGradient.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/DiffusionGradient.java @@ -14,17 +14,15 @@ package org.shanoir.ng.shared.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.datasetacquisition.model.mr.MrProtocol; import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * This class represents a diffusion gradient. It is used in the MR protocol to * list and rank all the diffusion gradients of the acquisition. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/EchoTime.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/EchoTime.java index cfb3633bf9..41556b03fc 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/EchoTime.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/EchoTime.java @@ -14,20 +14,17 @@ package org.shanoir.ng.shared.model; -import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Transient; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.examination.model.UnitOfMeasure; import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * This class represents an echo time. It is used in the MR protocol to list and * rank all the echo times of the acquisition. @@ -64,10 +61,6 @@ public class EchoTime extends AbstractEntity { @NotNull private Double echoTimeValue; - @Transient - @JsonInclude - private UnitOfMeasure unit = UnitOfMeasure.MS; - /** * @return the echoNumber */ @@ -125,11 +118,4 @@ public int hashCode() { return hash; } - public UnitOfMeasure getUnit() { - return unit; - } - - public void setUnit(UnitOfMeasure unit) { - this.unit = unit; - } } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/FlipAngle.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/FlipAngle.java index 0f49371762..e38c620bb2 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/FlipAngle.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/FlipAngle.java @@ -14,19 +14,16 @@ package org.shanoir.ng.shared.model; -import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Transient; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.examination.model.UnitOfMeasure; import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * This class represents a flip angle. It is used in the MR protocol to list and * rank all the flip angles of the acquisition. @@ -55,10 +52,6 @@ public class FlipAngle extends AbstractEntity { @NotNull private String flipAngleValue; - @Transient - @JsonInclude - private UnitOfMeasure unit = UnitOfMeasure.DEGREES; - /** * @return the flipAngleValue */ @@ -81,12 +74,5 @@ public MrDataset getMrDataset() { public void setMrDataset(MrDataset mrDataset) { this.mrDataset = mrDataset; } - - public UnitOfMeasure getUnit() { - return unit; - } - - public void setUnit(UnitOfMeasure unit) { - this.unit = unit; - } + } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/InversionTime.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/InversionTime.java index 8df63a94f8..7e1ccdec1d 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/InversionTime.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/InversionTime.java @@ -14,19 +14,16 @@ package org.shanoir.ng.shared.model; -import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Transient; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.examination.model.UnitOfMeasure; import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * This class represents an inversion time. It is used in the MR protocol to * list and rank all the inversion times of the acquisition. @@ -55,10 +52,6 @@ public class InversionTime extends AbstractEntity { @NotNull private Double inversionTimeValue; - @Transient - @JsonInclude - private UnitOfMeasure unit = UnitOfMeasure.MS; - /** * @return the inversionTimeValue */ @@ -81,12 +74,5 @@ public MrDataset getMrDataset() { public void setMrDataset(MrDataset mrDataset) { this.mrDataset = mrDataset; } - - public UnitOfMeasure getUnit() { - return unit; - } - - public void setUnit(UnitOfMeasure unit) { - this.unit = unit; - } + } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/RepetitionTime.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/RepetitionTime.java index e452fa11e7..8ab4f48c03 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/RepetitionTime.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/RepetitionTime.java @@ -14,19 +14,16 @@ package org.shanoir.ng.shared.model; -import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Entity; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Transient; import jakarta.validation.constraints.NotNull; - import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.examination.model.UnitOfMeasure; import org.shanoir.ng.shared.core.model.AbstractEntity; -import com.fasterxml.jackson.annotation.JsonIgnore; - /** * This class represents an repetition time. It is used in the MR protocol to * list and rank all the repetition times of the acquisition. @@ -56,10 +53,6 @@ public class RepetitionTime extends AbstractEntity { @NotNull private Double repetitionTimeValue; - @Transient - @JsonInclude - private UnitOfMeasure unit = UnitOfMeasure.MS; - /** * @return the repetitionTimeValue */ @@ -78,11 +71,4 @@ public void setMrDataset(MrDataset mrDataset) { this.mrDataset = mrDataset; } - public UnitOfMeasure getUnit() { - return unit; - } - - public void setUnit(UnitOfMeasure unit) { - this.unit = unit; - } } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Study.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Study.java index b9b3caae9c..aece41b6b5 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Study.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Study.java @@ -13,25 +13,13 @@ */ package org.shanoir.ng.shared.model; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.ManyToMany; -import jakarta.persistence.OneToMany; -import jakarta.persistence.Table; - -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.*; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.shared.core.model.IdName; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; /** * @author yyao diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Subject.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Subject.java index 8c94ef8b17..b13ffcba1f 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Subject.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Subject.java @@ -13,18 +13,11 @@ */ package org.shanoir.ng.shared.model; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; -import jakarta.persistence.Table; - +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import jakarta.persistence.*; import org.shanoir.ng.shared.core.model.IdName; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.util.List; /** * @author yyao diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/SubjectStudy.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/SubjectStudy.java index 0b73148ce7..83ed48a60f 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/SubjectStudy.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/SubjectStudy.java @@ -1,9 +1,5 @@ package org.shanoir.ng.shared.model; -import java.util.List; - -import org.shanoir.ng.shared.quality.QualityTag; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import org.shanoir.ng.shared.subjectstudy.SubjectType; @@ -17,6 +13,9 @@ import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; import jakarta.validation.constraints.NotNull; +import org.shanoir.ng.shared.quality.QualityTag; + +import java.util.List; @Entity @Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "study_id", "subject_id" }, name = "study_subject_idx") }) diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Tag.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Tag.java index 295ee6e894..f06c449328 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Tag.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/model/Tag.java @@ -1,12 +1,11 @@ package org.shanoir.ng.shared.model; +import com.fasterxml.jackson.annotation.JsonIgnore; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import com.fasterxml.jackson.annotation.JsonIgnore; - @Entity public class Tag { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/service/SecurityService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/service/SecurityService.java index 260cb49534..a79c6f126a 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/service/SecurityService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/shared/service/SecurityService.java @@ -14,9 +14,6 @@ package org.shanoir.ng.shared.service; -import java.util.List; -import java.util.Set; - import org.shanoir.ng.shared.security.rights.StudyUserRight; import org.shanoir.ng.study.rights.StudyUser; import org.shanoir.ng.study.rights.StudyUserRightsRepository; @@ -27,6 +24,9 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.util.List; +import java.util.Set; + @Service public class SecurityService { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApi.java index 2715f8f1bb..9fc136d84e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApi.java @@ -19,9 +19,12 @@ */ package org.shanoir.ng.solr.controler; -import java.io.IOException; -import java.util.List; - +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 jakarta.validation.Valid; import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.shared.exception.RestServiceException; import org.shanoir.ng.solr.model.ShanoirSolrDocument; @@ -35,12 +38,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -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 jakarta.validation.Valid; +import java.io.IOException; +import java.util.List; /** * @author yyao diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApiController.java index 2e702a6dba..8ecdd70507 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/controler/SolrApiController.java @@ -19,11 +19,8 @@ */ package org.shanoir.ng.solr.controler; -import java.io.IOException; -import java.util.List; - +import io.swagger.v3.oas.annotations.Parameter; import jakarta.validation.Valid; - import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.shared.exception.RestServiceException; import org.shanoir.ng.solr.model.ShanoirSolrDocument; @@ -38,7 +35,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; -import io.swagger.v3.oas.annotations.Parameter; +import java.io.IOException; +import java.util.List; /** * @author yyao diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirMetadata.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirMetadata.java index 5d324ae03b..b0a1403fb3 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirMetadata.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirMetadata.java @@ -19,18 +19,13 @@ */ package org.shanoir.ng.solr.model; -import java.time.LocalDate; - -import jakarta.persistence.ColumnResult; -import jakarta.persistence.ConstructorResult; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import jakarta.persistence.SqlResultSetMapping; - +import jakarta.persistence.*; import org.shanoir.ng.dataset.modality.MrDatasetNature; import org.shanoir.ng.dataset.model.DatasetModalityType; import org.shanoir.ng.shared.dateTime.LocalDateAnnotations; +import java.time.LocalDate; + /** * @author yyao * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrDocument.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrDocument.java index 8a6202e502..16b67b52bc 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrDocument.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrDocument.java @@ -19,13 +19,13 @@ */ package org.shanoir.ng.solr.model; -import java.util.Date; -import java.util.List; - import org.apache.solr.client.solrj.beans.Field; import org.shanoir.ng.shared.subjectstudy.SubjectType; import org.springframework.data.annotation.Id; +import java.util.Date; +import java.util.List; + /** * @author yyao * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrQuery.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrQuery.java index 128b1bae58..d40daf46f9 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrQuery.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/model/ShanoirSolrQuery.java @@ -14,16 +14,15 @@ package org.shanoir.ng.solr.model; +import org.shanoir.ng.shared.paging.FacetPageable; +import org.shanoir.ng.utils.Range; + import java.time.LocalDate; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; -import org.shanoir.ng.shared.paging.FacetPageable; -import org.shanoir.ng.shared.subjectstudy.SubjectType; -import org.shanoir.ng.utils.Range; - /** * @author yyao * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/repository/ShanoirMetadataRepositoryImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/repository/ShanoirMetadataRepositoryImpl.java index 2075885f27..0c237eaa76 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/repository/ShanoirMetadataRepositoryImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/repository/ShanoirMetadataRepositoryImpl.java @@ -19,21 +19,20 @@ */ package org.shanoir.ng.solr.repository; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; import jakarta.persistence.Query; - import org.shanoir.ng.solr.model.ShanoirMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + /** * @author yyao * @author mkain diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrService.java index df9d1b9e43..eae5c42f24 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrService.java @@ -19,9 +19,6 @@ */ package org.shanoir.ng.solr.service; -import java.io.IOException; -import java.util.List; - import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.shared.exception.RestServiceException; import org.shanoir.ng.solr.model.ShanoirSolrDocument; @@ -31,6 +28,9 @@ import org.springframework.data.solr.core.query.result.SolrResultPage; import org.springframework.security.access.prepost.PreAuthorize; +import java.io.IOException; +import java.util.List; + /** * @author yyao * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrServiceImpl.java index 67e9ecfc7a..70e18df95a 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/service/SolrServiceImpl.java @@ -19,16 +19,6 @@ */ package org.shanoir.ng.solr.service; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.shared.dateTime.DateTimeUtils; import org.shanoir.ng.shared.exception.RestServiceException; @@ -40,6 +30,7 @@ import org.shanoir.ng.shared.repository.SubjectStudyRepository; import org.shanoir.ng.shared.security.rights.StudyUserRight; import org.shanoir.ng.shared.subjectstudy.SubjectType; + import org.shanoir.ng.solr.model.ShanoirMetadata; import org.shanoir.ng.solr.model.ShanoirSolrDocument; import org.shanoir.ng.solr.model.ShanoirSolrQuery; @@ -62,6 +53,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; + /** * @author yyao * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapper.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapper.java index 00aea1b51c..40518cc8de 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapper.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapper.java @@ -19,11 +19,6 @@ */ package org.shanoir.ng.solr.solrj; -import java.io.IOException; -import java.util.Collection; -import java.util.List; -import java.util.Map; - import org.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.shared.exception.RestServiceException; import org.shanoir.ng.solr.model.ShanoirSolrDocument; @@ -34,6 +29,11 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.solr.repository.Facet; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Map; + /** * @author yyao * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java index 16cc79b420..cea8cd7543 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/solr/solrj/SolrJWrapperImpl.java @@ -3,18 +3,6 @@ */ package org.shanoir.ng.solr.solrj; -import java.io.IOException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.stream.Collectors; - import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery.ORDER; @@ -51,6 +39,13 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import java.io.IOException; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.stream.Collectors; + /** * @author yyao * @@ -171,6 +166,20 @@ public SolrResultPage findByStudyIdInAndFacetCriteria(Map findByDatasetIdIn(Collection datasetIds, Pageable pageable) throws RestServiceException { final SolrQuery query = new SolrQuery(); filterByDatasetIds(datasetIds, query); + /* add sorting */ + if (pageable.getSort() != null) { + for (Sort.Order order : pageable.getSort()) { + query.addSort(order.getProperty(), order.getDirection().equals(Direction.ASC) ? ORDER.asc : ORDER.desc); + } + } + /* add paging */ + query.setRows(pageable.getPageSize()); + query.setStart(pageable.getPageNumber() * pageable.getPageSize()); + + /* results with all the columns */ + for (String fieldStr : DOCUMENT_FACET_LIST) { + query.addField(fieldStr); + } QueryResponse response = querySolrServer(query); return buildShanoirSolrPage(response, pageable, null); } diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApi.java index c8f153fd95..fb369e0d70 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApi.java @@ -14,8 +14,11 @@ package org.shanoir.ng.studycard.controler; -import java.util.List; - +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.MicroServiceCommunicationException; import org.shanoir.ng.shared.exception.RestServiceException; import org.shanoir.ng.studycard.dto.QualityCardResult; @@ -29,11 +32,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import io.swagger.v3.oas.annotations.tags.Tag; -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 java.util.List; @Tag(name = "qualitycards", description = "the qualitycard API") @RequestMapping("/qualitycards") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApiController.java index c175084a32..12e29726c2 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/QualityCardApiController.java @@ -14,14 +14,9 @@ package org.shanoir.ng.studycard.controler; -import java.util.List; - +import io.swagger.v3.oas.annotations.Parameter; import org.shanoir.ng.shared.error.FieldErrorMap; -import org.shanoir.ng.shared.exception.EntityNotFoundException; -import org.shanoir.ng.shared.exception.ErrorDetails; -import org.shanoir.ng.shared.exception.ErrorModel; -import org.shanoir.ng.shared.exception.MicroServiceCommunicationException; -import org.shanoir.ng.shared.exception.RestServiceException; +import org.shanoir.ng.shared.exception.*; import org.shanoir.ng.studycard.dto.QualityCardResult; import org.shanoir.ng.studycard.model.QualityCard; import org.shanoir.ng.studycard.service.CardsProcessingService; @@ -37,7 +32,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import io.swagger.v3.oas.annotations.Parameter; +import java.util.List; @Controller public class QualityCardApiController implements QualityCardApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApi.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApi.java index 62c533be3d..69504d1507 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApi.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApi.java @@ -14,9 +14,11 @@ package org.shanoir.ng.studycard.controler; -import java.io.IOException; -import java.util.List; - +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.apache.solr.client.solrj.SolrServerException; import org.shanoir.ng.shared.core.model.IdList; import org.shanoir.ng.shared.exception.PacsException; @@ -33,11 +35,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -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 java.io.IOException; +import java.util.List; @Tag(name = "studycards", description = "the studyCard API") @RequestMapping("/studycards") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApiController.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApiController.java index d80ccd25d3..8468434bb3 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApiController.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/controler/StudyCardApiController.java @@ -14,11 +14,7 @@ package org.shanoir.ng.studycard.controler; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - +import io.swagger.v3.oas.annotations.Parameter; import org.apache.solr.client.solrj.SolrServerException; import org.dcm4che3.data.Tag; import org.shanoir.ng.dataset.model.Dataset; @@ -26,12 +22,7 @@ import org.shanoir.ng.datasetacquisition.service.DatasetAcquisitionService; import org.shanoir.ng.shared.core.model.IdList; import org.shanoir.ng.shared.error.FieldErrorMap; -import org.shanoir.ng.shared.exception.EntityNotFoundException; -import org.shanoir.ng.shared.exception.ErrorDetails; -import org.shanoir.ng.shared.exception.ErrorModel; -import org.shanoir.ng.shared.exception.MicroServiceCommunicationException; -import org.shanoir.ng.shared.exception.PacsException; -import org.shanoir.ng.shared.exception.RestServiceException; +import org.shanoir.ng.shared.exception.*; import org.shanoir.ng.solr.service.SolrService; import org.shanoir.ng.studycard.dto.DicomTag; import org.shanoir.ng.studycard.model.StudyCard; @@ -49,7 +40,10 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; -import io.swagger.v3.oas.annotations.Parameter; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; @Controller public class StudyCardApiController implements StudyCardApi { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/QualityCard.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/QualityCard.java index 0dbac17a83..78e87da779 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/QualityCard.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/QualityCard.java @@ -14,17 +14,9 @@ package org.shanoir.ng.studycard.model; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.OneToMany; -import jakarta.persistence.PostLoad; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; - import org.dcm4che3.data.Attributes; import org.hibernate.annotations.GenericGenerator; import org.hibernate.validator.constraints.NotBlank; @@ -35,7 +27,7 @@ import org.shanoir.ng.studycard.dto.QualityCardResult; import org.shanoir.ng.studycard.model.rule.QualityExaminationRule; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.List; /** * Study card. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/StudyCard.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/StudyCard.java index eaf2667d7d..19e81267a4 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/StudyCard.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/StudyCard.java @@ -14,8 +14,8 @@ package org.shanoir.ng.studycard.model; -import java.util.List; - +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import jakarta.persistence.*; import org.dcm4che3.data.Attributes; import org.hibernate.annotations.GenericGenerator; import org.hibernate.validator.constraints.NotBlank; @@ -28,16 +28,7 @@ import org.shanoir.ng.studycard.model.rule.DatasetRule; import org.shanoir.ng.studycard.model.rule.StudyCardRule; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.OneToMany; -import jakarta.persistence.PostLoad; -import jakarta.persistence.Table; +import java.util.List; /** * Study card. diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAcquisitionAssignment.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAcquisitionAssignment.java index 099ac4aa1c..6bdfe44e71 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAcquisitionAssignment.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAcquisitionAssignment.java @@ -14,9 +14,10 @@ package org.shanoir.ng.studycard.model.assignment; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.shared.exception.CheckedIllegalClassException; import org.shanoir.ng.studycard.model.field.DatasetAcquisitionMetadataField; @@ -24,9 +25,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - @Entity @DiscriminatorValue("DatasetAcquisition") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAssignment.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAssignment.java index f7f315a4ee..ea8ea57742 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAssignment.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/DatasetAssignment.java @@ -14,9 +14,10 @@ package org.shanoir.ng.studycard.model.assignment; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.shared.exception.CheckedIllegalClassException; import org.shanoir.ng.studycard.model.field.DatasetMetadataField; @@ -24,9 +25,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; - @Entity @DiscriminatorValue("Dataset") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/StudyCardAssignment.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/StudyCardAssignment.java index 76e9ee301a..050f00b8e7 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/StudyCardAssignment.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/assignment/StudyCardAssignment.java @@ -14,20 +14,14 @@ package org.shanoir.ng.studycard.model.assignment; -import org.hibernate.annotations.GenericGenerator; -import org.shanoir.ng.shared.core.model.AbstractEntity; - import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo.As; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; - -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.DiscriminatorType; -import jakarta.persistence.Entity; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; +import org.hibernate.annotations.GenericGenerator; +import org.shanoir.ng.shared.core.model.AbstractEntity; @Entity diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnAcq.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnAcq.java index 9ddd408187..6a83d2888d 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnAcq.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnAcq.java @@ -14,9 +14,9 @@ package org.shanoir.ng.studycard.model.condition; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.shared.exception.CheckedIllegalClassException; import org.shanoir.ng.studycard.model.field.DatasetAcquisitionMetadataField; @@ -24,8 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * Condition valid for the given DatasetAcquisition if the acquisition metadata fulfill the condition */ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnDatasets.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnDatasets.java index 3ca47a4dfc..42cc06d9dd 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnDatasets.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/AcqMetadataCondOnDatasets.java @@ -14,11 +14,9 @@ package org.shanoir.ng.studycard.model.condition; -import java.util.List; - +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.shared.exception.CheckedIllegalClassException; import org.shanoir.ng.studycard.model.field.DatasetMetadataField; @@ -26,7 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.List; /** * Condition valid for the given DatasetAcquisition if every of it's Datasets metadata fulfill the condition diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/DatasetMetadataCondOnDataset.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/DatasetMetadataCondOnDataset.java index a04a3960ac..4022dde233 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/DatasetMetadataCondOnDataset.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/DatasetMetadataCondOnDataset.java @@ -14,9 +14,9 @@ package org.shanoir.ng.studycard.model.condition; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.shared.exception.CheckedIllegalClassException; import org.shanoir.ng.studycard.model.field.DatasetMetadataField; @@ -24,8 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * Condition valid for the given DatasetAcquisition if every of it's Datasets metadata fulfill the condition */ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnAcq.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnAcq.java index 744e97f2e9..b37bcd38ea 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnAcq.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnAcq.java @@ -14,11 +14,9 @@ package org.shanoir.ng.studycard.model.condition; -import java.util.List; - +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.apache.commons.lang3.StringUtils; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.shared.exception.CheckedIllegalClassException; @@ -27,7 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.List; /** * Condition valid for the given DatasetAcquisition if every of it's Datasets metadata fulfill the condition diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnDatasets.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnDatasets.java index 09088f4280..e9dd8990b2 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnDatasets.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/ExamMetadataCondOnDatasets.java @@ -14,11 +14,9 @@ package org.shanoir.ng.studycard.model.condition; -import java.util.List; - +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.apache.commons.lang3.StringUtils; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; @@ -28,7 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.List; /** * Condition valid for the given DatasetAcquisition if every of it's Datasets metadata fulfill the condition diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardCondition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardCondition.java index 20f007e4fd..c35d6e0414 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardCondition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardCondition.java @@ -14,17 +14,12 @@ package org.shanoir.ng.studycard.model.condition; -import java.util.List; - -import jakarta.persistence.Column; -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.DiscriminatorType; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.As; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; - import org.hibernate.annotations.Check; import org.hibernate.annotations.GenericGenerator; import org.shanoir.ng.shared.core.model.AbstractEntity; @@ -32,10 +27,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeInfo.As; -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import java.util.List; @Entity @Check(constraints = "(dicomTag IS NOT NULL AND shanoirField IS NULL) OR (dicomTag IS NULL AND shanoirField IS NOT NULL)") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardDICOMCondition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardDICOMCondition.java index c1258a142a..74bf8d4ecc 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardDICOMCondition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardDICOMCondition.java @@ -14,14 +14,9 @@ package org.shanoir.ng.studycard.model.condition; -import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.apache.commons.lang3.StringUtils; import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Keyword; @@ -31,7 +26,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.annotation.JsonTypeName; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; @Entity @DiscriminatorValue("StudyCardDICOMCondition") diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardMetadataCondition.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardMetadataCondition.java index ecb03e6b5d..3333470532 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardMetadataCondition.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/condition/StudyCardMetadataCondition.java @@ -15,7 +15,6 @@ package org.shanoir.ng.studycard.model.condition; import jakarta.persistence.Entity; - import org.shanoir.ng.studycard.model.field.MetadataFieldInterface; @Entity diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/field/DatasetAcquisitionMetadataField.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/field/DatasetAcquisitionMetadataField.java index fe78c3404f..25e59112a7 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/field/DatasetAcquisitionMetadataField.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/field/DatasetAcquisitionMetadataField.java @@ -15,19 +15,12 @@ package org.shanoir.ng.studycard.model.field; +import com.fasterxml.jackson.annotation.JsonTypeName; import org.shanoir.ng.dataset.modality.BidsDataType; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; -import org.shanoir.ng.datasetacquisition.model.mr.AcquisitionContrast; -import org.shanoir.ng.datasetacquisition.model.mr.ContrastAgentUsed; -import org.shanoir.ng.datasetacquisition.model.mr.MrDatasetAcquisition; -import org.shanoir.ng.datasetacquisition.model.mr.MrProtocol; -import org.shanoir.ng.datasetacquisition.model.mr.MrProtocolSCMetadata; -import org.shanoir.ng.datasetacquisition.model.mr.MrSequenceApplication; -import org.shanoir.ng.datasetacquisition.model.mr.MrSequencePhysics; +import org.shanoir.ng.datasetacquisition.model.mr.*; import org.shanoir.ng.shared.exception.CheckedIllegalClassException; -import com.fasterxml.jackson.annotation.JsonTypeName; - @JsonTypeName("DatasetAcquisitionMetadataField") public enum DatasetAcquisitionMetadataField implements MetadataFieldInterface { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetAcquisitionRule.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetAcquisitionRule.java index b5bcaecacc..e9629b3ef2 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetAcquisitionRule.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetAcquisitionRule.java @@ -14,9 +14,9 @@ package org.shanoir.ng.studycard.model.rule; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.dcm4che3.data.Attributes; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; @@ -28,8 +28,6 @@ import org.shanoir.ng.studycard.model.condition.StudyCardCondition; import org.shanoir.ng.studycard.model.condition.StudyCardDICOMCondition; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * A rule that applies to a {@link DatasetAcquisition} */ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetRule.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetRule.java index a3ddacd622..9c757ffdf3 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetRule.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/DatasetRule.java @@ -14,9 +14,9 @@ package org.shanoir.ng.studycard.model.rule; +import com.fasterxml.jackson.annotation.JsonTypeName; import jakarta.persistence.DiscriminatorValue; import jakarta.persistence.Entity; - import org.dcm4che3.data.Attributes; import org.shanoir.ng.dataset.model.Dataset; import org.shanoir.ng.studycard.model.assignment.DatasetAssignment; @@ -25,8 +25,6 @@ import org.shanoir.ng.studycard.model.condition.StudyCardCondition; import org.shanoir.ng.studycard.model.condition.StudyCardDICOMCondition; -import com.fasterxml.jackson.annotation.JsonTypeName; - /** * A rule that applies to a {@link Dataset} */ diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/QualityExaminationRule.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/QualityExaminationRule.java index 5cc8242600..4a42f4cb1e 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/QualityExaminationRule.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/QualityExaminationRule.java @@ -14,24 +14,10 @@ package org.shanoir.ng.studycard.model.rule; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.OneToMany; - +import jakarta.persistence.*; import org.apache.commons.lang3.StringUtils; import org.dcm4che3.data.Attributes; import org.hibernate.annotations.GenericGenerator; -import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; -import org.shanoir.ng.datasetacquisition.model.mr.MrDatasetAcquisition; import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.shared.core.model.AbstractEntity; import org.shanoir.ng.shared.model.SubjectStudy; @@ -46,6 +32,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + @Entity @GenericGenerator(name = "IdOrGenerate", strategy = "org.shanoir.ng.shared.model.UseIdOrGenerate") public class QualityExaminationRule extends AbstractEntity { diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/StudyCardRule.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/StudyCardRule.java index 08fe7fb6e7..048a0d2131 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/StudyCardRule.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/model/rule/StudyCardRule.java @@ -14,29 +14,18 @@ package org.shanoir.ng.studycard.model.rule; -import java.util.List; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.DiscriminatorColumn; -import jakarta.persistence.DiscriminatorType; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.JoinTable; -import jakarta.persistence.OneToMany; - +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.As; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import jakarta.persistence.*; import org.dcm4che3.data.Attributes; import org.hibernate.annotations.GenericGenerator; import org.shanoir.ng.shared.core.model.AbstractEntity; import org.shanoir.ng.studycard.model.assignment.StudyCardAssignment; import org.shanoir.ng.studycard.model.condition.StudyCardCondition; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeInfo.As; -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; +import java.util.List; @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/CardService.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/CardService.java index b234f26808..69d529fdd1 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/CardService.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/CardService.java @@ -14,13 +14,11 @@ package org.shanoir.ng.studycard.service; -import java.util.List; - import org.shanoir.ng.shared.exception.EntityNotFoundException; import org.shanoir.ng.shared.exception.MicroServiceCommunicationException; import org.shanoir.ng.studycard.model.Card; -import org.springframework.security.access.prepost.PostAuthorize; -import org.springframework.security.access.prepost.PreAuthorize; + +import java.util.List; // MK: had to move down all sec annotations (Pre-/PostAuthorize) to -ServiceImpls as Spring Sec throws a duplicate // annotation exception, because of 2 interface hierarchy, that is not well managed by Spring Sec, so I could not diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/QualityCardServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/QualityCardServiceImpl.java index fce19a09e7..4db2e942b7 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/QualityCardServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/QualityCardServiceImpl.java @@ -14,9 +14,6 @@ package org.shanoir.ng.studycard.service; -import java.util.ArrayList; -import java.util.List; - import org.shanoir.ng.shared.exception.EntityNotFoundException; import org.shanoir.ng.shared.exception.MicroServiceCommunicationException; import org.shanoir.ng.studycard.model.QualityCard; @@ -28,6 +25,9 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; + /** * Study Card service implementation. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/StudyCardServiceImpl.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/StudyCardServiceImpl.java index 7c361d0da6..50af32c274 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/StudyCardServiceImpl.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/studycard/service/StudyCardServiceImpl.java @@ -14,9 +14,6 @@ package org.shanoir.ng.studycard.service; -import java.util.ArrayList; -import java.util.List; - import org.shanoir.ng.shared.exception.EntityNotFoundException; import org.shanoir.ng.shared.exception.MicroServiceCommunicationException; import org.shanoir.ng.studycard.model.StudyCard; @@ -28,6 +25,9 @@ import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; +import java.util.ArrayList; +import java.util.List; + /** * Study Card service implementation. * diff --git a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/utils/DatasetFileUtils.java b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/utils/DatasetFileUtils.java index cc65cd6d76..b42fddd539 100644 --- a/shanoir-ng-datasets/src/main/java/org/shanoir/ng/utils/DatasetFileUtils.java +++ b/shanoir-ng-datasets/src/main/java/org/shanoir/ng/utils/DatasetFileUtils.java @@ -1,17 +1,9 @@ package org.shanoir.ng.utils; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.mail.MessagingException; import org.apache.commons.io.FilenameUtils; import org.shanoir.ng.dataset.dto.InputDTO; import org.shanoir.ng.dataset.modality.EegDataset; @@ -23,11 +15,17 @@ import org.springframework.util.StreamUtils; import org.springframework.web.util.UriUtils; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; - -import jakarta.mail.MessagingException; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; public class DatasetFileUtils { diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/bids/service/BidsDeserializerTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/bids/service/BidsDeserializerTest.java index abff68668f..422fc727f7 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/bids/service/BidsDeserializerTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/bids/service/BidsDeserializerTest.java @@ -1,11 +1,5 @@ package org.shanoir.ng.bids.service; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.io.File; -import java.io.IOException; - import org.apache.commons.io.Charsets; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; @@ -15,6 +9,12 @@ import org.shanoir.ng.bids.model.BidsFile; import org.shanoir.ng.bids.model.BidsFolder; +import java.io.File; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * Test class for deserializer. * @author fli diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiControllerTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiControllerTest.java index d51d95c754..35fa270516 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiControllerTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiControllerTest.java @@ -14,18 +14,7 @@ package org.shanoir.ng.dataset; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doNothing; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.solr.client.solrj.SolrServerException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -68,7 +57,17 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; /** * Unit tests for dataset controller. diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiSecurityTest.java index e3ae8f62a5..81e4ae34cb 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetApiSecurityTest.java @@ -15,17 +15,6 @@ package org.shanoir.ng.dataset; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -63,6 +52,13 @@ import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; + /** * DatasetAPI security test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetDownloaderServiceTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetDownloaderServiceTest.java index 1f3fee1260..9f71c1c3fc 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetDownloaderServiceTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetDownloaderServiceTest.java @@ -1,18 +1,6 @@ package org.shanoir.ng.dataset; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.times; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.SolrServerException; import org.junit.jupiter.api.BeforeEach; @@ -57,7 +45,18 @@ import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.test.context.ActiveProfiles; -import jakarta.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.times; @SpringBootTest @ActiveProfiles("test") diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetMapperTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetMapperTest.java index cdba9d0415..8334b226d6 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetMapperTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetMapperTest.java @@ -14,11 +14,6 @@ package org.shanoir.ng.dataset; -import java.text.ParseException; -import java.time.LocalDate; -import java.util.Arrays; -import java.util.List; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.shanoir.ng.dataset.dto.DatasetDTO; @@ -33,6 +28,11 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; +import java.text.ParseException; +import java.time.LocalDate; +import java.util.Arrays; +import java.util.List; + /** * Dataset mapper test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetRepositoryTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetRepositoryTest.java index f5928deec5..3a8b5c739d 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetRepositoryTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetRepositoryTest.java @@ -14,13 +14,6 @@ package org.shanoir.ng.dataset; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.Arrays; -import java.util.List; - import org.junit.jupiter.api.Test; import org.shanoir.ng.dataset.modality.MrDataset; import org.shanoir.ng.dataset.modality.MrQualityProcedureType; @@ -35,6 +28,11 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.context.ActiveProfiles; +import java.util.Arrays; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; + /** * Tests for repository 'dataset'. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetServiceSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetServiceSecurityTest.java index 9cd1ca5e52..8eda78e8ae 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetServiceSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dataset/DatasetServiceSecurityTest.java @@ -14,17 +14,6 @@ package org.shanoir.ng.dataset; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.shanoir.ng.dataset.modality.MrDataset; @@ -56,6 +45,13 @@ import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.test.context.ActiveProfiles; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; + /** * User security service test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiControllerTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiControllerTest.java index ca132db2ca..410ba74d51 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiControllerTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiControllerTest.java @@ -1,7 +1,7 @@ package org.shanoir.ng.datasetacquisition; -import java.util.Collections; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -24,8 +24,7 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import java.util.Collections; @WebMvcTest(controllers = DatasetAcquisitionApiController.class) diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiSecurityTest.java index 74fb7067eb..fc52a7aa44 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionApiSecurityTest.java @@ -14,19 +14,6 @@ package org.shanoir.ng.datasetacquisition; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import org.springframework.data.util.Pair; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -58,11 +45,19 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.util.Pair; import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.test.context.ActiveProfiles; import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; + /** * User security service test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionMapperTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionMapperTest.java index d7c0cb4cfd..2ac46bcdbd 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionMapperTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionMapperTest.java @@ -14,10 +14,6 @@ package org.shanoir.ng.datasetacquisition; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.shanoir.ng.datasetacquisition.dto.ExaminationDatasetAcquisitionDTO; @@ -32,6 +28,10 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + /** * Dataset acquisition mapper test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionRepositoryTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionRepositoryTest.java index 3e0f1feaae..e2b38acaad 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionRepositoryTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionRepositoryTest.java @@ -14,15 +14,6 @@ package org.shanoir.ng.datasetacquisition; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.springframework.data.util.Pair; import org.junit.jupiter.api.Test; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.datasetacquisition.repository.DatasetAcquisitionRepository; @@ -36,8 +27,17 @@ import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.domain.Sort.Order; +import org.springframework.data.util.Pair; import org.springframework.test.context.ActiveProfiles; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Tests for repository 'examination'. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionServiceSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionServiceSecurityTest.java index c3aa1e5902..7e34e98688 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionServiceSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/DatasetAcquisitionServiceSecurityTest.java @@ -14,21 +14,6 @@ package org.shanoir.ng.datasetacquisition; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import org.springframework.data.util.Pair; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.mockito.internal.util.collections.Sets; @@ -58,9 +43,19 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.util.Pair; import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.test.context.ActiveProfiles; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; + /** * User security service test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/EegImporterServiceTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/EegImporterServiceTest.java index 2a81288405..704d5b17e5 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/EegImporterServiceTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/EegImporterServiceTest.java @@ -1,23 +1,8 @@ package org.shanoir.ng.datasetacquisition.service; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; - -import java.io.IOException; -import java.time.LocalDate; -import java.util.Collections; -import java.util.List; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; +import org.mockito.*; import org.shanoir.ng.dataset.modality.EegDataset; import org.shanoir.ng.dataset.modality.EegDatasetDTO; import org.shanoir.ng.dataset.model.DatasetExpressionFormat; @@ -37,6 +22,15 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; +import java.io.IOException; +import java.time.LocalDate; +import java.util.Collections; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.verify; + @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class EegImporterServiceTest { diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/ImporterServiceTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/ImporterServiceTest.java index d07c87648f..c94d093105 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/ImporterServiceTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/datasetacquisition/service/ImporterServiceTest.java @@ -1,29 +1,9 @@ package org.shanoir.ng.datasetacquisition.service; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - import org.dcm4che3.data.Attributes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; +import org.mockito.*; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.datasetacquisition.model.mr.MrDatasetAcquisition; import org.shanoir.ng.datasetacquisition.repository.DatasetAcquisitionRepository; @@ -31,13 +11,7 @@ import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.examination.repository.ExaminationRepository; import org.shanoir.ng.examination.service.ExaminationService; -import org.shanoir.ng.importer.dto.Dataset; -import org.shanoir.ng.importer.dto.DatasetFile; -import org.shanoir.ng.importer.dto.ExpressionFormat; -import org.shanoir.ng.importer.dto.ImportJob; -import org.shanoir.ng.importer.dto.Patient; -import org.shanoir.ng.importer.dto.Serie; -import org.shanoir.ng.importer.dto.Study; +import org.shanoir.ng.importer.dto.*; import org.shanoir.ng.importer.service.DatasetAcquisitionContext; import org.shanoir.ng.importer.service.DicomPersisterService; import org.shanoir.ng.importer.service.ImporterService; @@ -52,6 +26,19 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; +import java.io.IOException; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @@ -164,7 +151,7 @@ public void createAllDatasetAcquisition() throws Exception { assertTrue(task.getStatus() == 1); // NOTE: This test is important as we use the message to send an mail to study admin further. // PLEASE do not change sucess message OR change it accordingly in emailServiceImpl. - assertEquals("studyName (n°1) : Successfully created datasets for subject subjectName in examination 2", task.getMessage()); + assertEquals("[studyName (n°1)] Successfully created datasets for subject [subjectName] in examination [2]", task.getMessage()); // THEN datasets are created // Check what we save at the end diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/DICOMJsonApiControllerTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/DICOMJsonApiControllerTest.java index 29b348d764..8d9f8e1ee5 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/DICOMJsonApiControllerTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/DICOMJsonApiControllerTest.java @@ -14,13 +14,8 @@ package org.shanoir.ng.dicom.web; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doNothing; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.IOException; -import java.util.Arrays; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.apache.solr.client.solrj.SolrServerException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -45,8 +40,12 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import java.io.IOException; +import java.util.Arrays; + +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @WebMvcTest(controllers = DICOMJsonApiController.class) diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/ExaminationToStudyDTOMapperTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/ExaminationToStudyDTOMapperTest.java index 4f74aac5d2..d36fda2b77 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/ExaminationToStudyDTOMapperTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/dicom/web/ExaminationToStudyDTOMapperTest.java @@ -14,10 +14,6 @@ package org.shanoir.ng.dicom.web; -import java.text.ParseException; -import java.time.LocalDate; -import java.util.ArrayList; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.shanoir.ng.dicom.web.dto.StudyDTO; @@ -29,6 +25,10 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; +import java.text.ParseException; +import java.time.LocalDate; +import java.util.ArrayList; + @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiControllerTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiControllerTest.java index 7ff467559a..cf8b839fb3 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiControllerTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiControllerTest.java @@ -14,19 +14,7 @@ package org.shanoir.ng.examination; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doNothing; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Arrays; - +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.SolrServerException; import org.junit.jupiter.api.BeforeEach; @@ -68,7 +56,15 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import org.springframework.web.multipart.MultipartFile; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Arrays; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; /** * Unit tests for examination controller. diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiSecurityTest.java index da1721b21d..89a1001492 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationApiSecurityTest.java @@ -14,19 +14,6 @@ package org.shanoir.ng.examination; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -59,6 +46,14 @@ import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; +import java.time.LocalDate; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; + /** * User security service test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationMapperTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationMapperTest.java index a207255b86..6b032bf031 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationMapperTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationMapperTest.java @@ -14,9 +14,6 @@ package org.shanoir.ng.examination; -import java.util.Arrays; -import java.util.List; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.shanoir.ng.examination.dto.ExaminationDTO; @@ -29,6 +26,9 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; +import java.util.Arrays; +import java.util.List; + /** * Examination mapper test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationRepositoryTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationRepositoryTest.java index 1784ea07f0..faab599e7f 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationRepositoryTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationRepositoryTest.java @@ -14,11 +14,6 @@ package org.shanoir.ng.examination; -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Iterator; -import java.util.List; - import org.junit.jupiter.api.Test; import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.examination.repository.ExaminationRepository; @@ -27,6 +22,11 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.test.context.ActiveProfiles; +import java.util.Iterator; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + /** * Tests for repository 'examination'. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceSecurityTest.java index 785735d08c..065e15e614 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceSecurityTest.java @@ -14,23 +14,10 @@ package org.shanoir.ng.examination; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import org.springframework.data.util.Pair; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import org.mockito.internal.util.collections.Sets; import org.shanoir.ng.examination.model.Examination; import org.shanoir.ng.examination.repository.ExaminationRepository; import org.shanoir.ng.examination.service.ExaminationService; @@ -51,11 +38,18 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.util.Pair; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.test.context.ActiveProfiles; -import org.mockito.internal.util.collections.Sets; +import java.time.LocalDate; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; /** * User security service test. diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceTest.java index dafca8d66d..22204e8819 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/examination/ExaminationServiceTest.java @@ -14,11 +14,6 @@ package org.shanoir.ng.examination; -import static org.mockito.BDDMockito.given; - -import java.io.IOException; -import java.util.Optional; - import org.apache.solr.client.solrj.SolrServerException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -42,6 +37,11 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; +import java.io.IOException; +import java.util.Optional; + +import static org.mockito.BDDMockito.given; + /** * Examination service test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/controller/BidsApiControllerTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/controller/BidsApiControllerTest.java index d293aa3b26..9cba1d0d90 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/controller/BidsApiControllerTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/controller/BidsApiControllerTest.java @@ -1,7 +1,5 @@ package org.shanoir.ng.exporter.controller; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.shanoir.ng.bids.BidsDeserializer; @@ -18,6 +16,8 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + /** * Test for BidsApiController class * @author fli diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/service/BidsServiceTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/service/BidsServiceTest.java index 22b559ee42..31c9da77f5 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/service/BidsServiceTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/exporter/service/BidsServiceTest.java @@ -1,15 +1,6 @@ package org.shanoir.ng.exporter.service; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.BDDMockito.given; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -37,7 +28,15 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.util.ReflectionTestUtils; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.BDDMockito.given; /** * Test class for BIDS service class. diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/importer/strategies/protocol/MrProtocolStrategyTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/importer/strategies/protocol/MrProtocolStrategyTest.java index 7ef8a9b978..9169d30776 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/importer/strategies/protocol/MrProtocolStrategyTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/importer/strategies/protocol/MrProtocolStrategyTest.java @@ -1,16 +1,5 @@ package org.shanoir.ng.importer.strategies.protocol; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.SortedSet; -import java.util.TreeSet; - import org.dcm4che3.data.Attributes; import org.dcm4che3.data.Tag; import org.dcm4che3.data.UID; @@ -26,6 +15,11 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.*; + /** * Tests the implementation of MrProtocolStrategy. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/processing/carmin/output/OFSEPSeqIdProcessingTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/processing/carmin/output/OFSEPSeqIdProcessingTest.java new file mode 100644 index 0000000000..1a4732da6c --- /dev/null +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/processing/carmin/output/OFSEPSeqIdProcessingTest.java @@ -0,0 +1,109 @@ +package org.shanoir.ng.processing.carmin.output; + + +import org.dcm4che3.data.Attributes; +import org.dcm4che3.data.Tag; +import org.dcm4che3.data.VR; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.shanoir.ng.dataset.modality.MrDataset; +import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.download.WADODownloaderService; +import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.shanoir.ng.shared.exception.PacsException; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.BDDMockito.given; + +@SpringBootTest +@ActiveProfiles("test") +public class OFSEPSeqIdProcessingTest { + + @Mock + private WADODownloaderService wadoDownloaderService; + + @InjectMocks + private OFSEPSeqIdProcessing outputProcessing; + + @Test + public void canProcessTest() throws OutputProcessingException { + CarminDatasetProcessing processing = new CarminDatasetProcessing(); + processing.setPipelineIdentifier("ofsep_sequences_identification/0.1"); + assertTrue(outputProcessing.canProcess(processing)); + processing.setPipelineIdentifier("ofsep_sequences_identification/1.0"); + assertTrue(outputProcessing.canProcess(processing)); + processing.setPipelineIdentifier("ct-tiqua/2.2"); + assertFalse(outputProcessing.canProcess(processing)); + } + + @Test + public void areArraysEqualsTest() throws JSONException { + + assertTrue(outputProcessing.areOrientationsEquals(this.getDsOrientation(), this.getMatchingVolumeOrientation())); + + assertFalse(outputProcessing.areOrientationsEquals(this.getDsOrientation(), this.getNonMatchingVolumeOrientation())); + + } + + @Test + public void getMatchingVolumeTest() throws JSONException, PacsException { + + Dataset ds = new MrDataset(); + ds.setId(1L); + + Attributes attr = new Attributes(); + attr.setDouble(Tag.ImageOrientationPatient, VR.DS, this.getDsOrientation()); + + given(wadoDownloaderService.getDicomAttributesForDataset(Mockito.any(Dataset.class))).willReturn(attr); + + + JSONObject vol1 = new JSONObject() + .put("orientation", this.getMatchingVolumeOrientation()) + .put("id", "volume_1"); + + JSONObject vol2 = new JSONObject() + .put("orientation", this.getMatchingVolumeOrientation()) + .put("id", "volume_2"); + + JSONObject serie = new JSONObject() + .put("id", 1L) + .put("volumes", new JSONArray().put(vol1).put(vol2)); + + JSONObject volume = outputProcessing.getMatchingVolume(ds, serie); + + assertEquals("volume_1", volume.get("id")); + + + } + + private double[] getDsOrientation(){ + return new double[]{1.0,0.0,6.12303176911e-17,6.12303176911e-17,0.0,-1.0}; + } + + private JSONArray getMatchingVolumeOrientation() throws JSONException { + return new JSONArray() + .put(1.0) + .put(0.0) + .put(6.12303176911e-17) + .put(6.12303176911e-17) + .put(0.0) + .put(-1.0); + } + + private JSONArray getNonMatchingVolumeOrientation() throws JSONException { + return new JSONArray() + .put(-0.0331592650151) + .put(-0.0331592650151) + .put(-6.8217453e-010) + .put(-0.0156900742116) + .put(-0.0005205582762) + .put(-0.9998767677021); + } +} \ No newline at end of file diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/processing/carmin/output/ProcessedDatasetProcessingTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/processing/carmin/output/ProcessedDatasetProcessingTest.java new file mode 100644 index 0000000000..498d974bff --- /dev/null +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/processing/carmin/output/ProcessedDatasetProcessingTest.java @@ -0,0 +1,28 @@ +package org.shanoir.ng.processing.carmin.output; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.shanoir.ng.processing.carmin.model.CarminDatasetProcessing; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +@SpringBootTest +@ActiveProfiles("test") +public class ProcessedDatasetProcessingTest { + + @InjectMocks + private ProcessedDatasetProcessing outputProcessing; + + @Test + public void canProcessTest() { + CarminDatasetProcessing processing = new CarminDatasetProcessing(); + processing.setPipelineIdentifier("ofsep_sequences_identification/0.1"); + Assertions.assertTrue(outputProcessing.canProcess(processing)); + processing.setPipelineIdentifier("ofsep_sequences_identification/1.0"); + Assertions.assertTrue(outputProcessing.canProcess(processing)); + processing.setPipelineIdentifier("ct-tiqua/2.2"); + Assertions.assertTrue(outputProcessing.canProcess(processing)); + } + +} diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiControllerTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiControllerTest.java index 93d8f6eb81..6949ac2c9e 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiControllerTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiControllerTest.java @@ -14,13 +14,8 @@ package org.shanoir.ng.studycard; -import static org.mockito.BDDMockito.given; -import static org.mockito.Mockito.doNothing; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.ArrayList; -import java.util.Arrays; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -49,8 +44,12 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import java.util.ArrayList; +import java.util.Arrays; + +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doNothing; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; /** * Unit tests for study card controller. diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiSecurityTest.java index e35c00cf4d..8bcd5e6980 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardApiSecurityTest.java @@ -14,23 +14,11 @@ package org.shanoir.ng.studycard; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; - import jakarta.transaction.Transactional; - -import org.springframework.data.util.Pair; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import org.mockito.internal.util.collections.Sets; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.datasetacquisition.repository.DatasetAcquisitionRepository; import org.shanoir.ng.datasetacquisition.service.DatasetAcquisitionService; @@ -57,10 +45,15 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.data.util.Pair; import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.test.context.ActiveProfiles; -import org.mockito.internal.util.collections.Sets; +import java.util.*; + +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; /** * User security service test. diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardRepositoryTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardRepositoryTest.java index c63e15c67d..a76d607a43 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardRepositoryTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardRepositoryTest.java @@ -14,13 +14,6 @@ package org.shanoir.ng.studycard; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - import org.junit.jupiter.api.Test; import org.shanoir.ng.studycard.model.StudyCard; import org.shanoir.ng.studycard.repository.StudyCardRepository; @@ -28,6 +21,13 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * Tests for repository 'StudyCard'. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardSecurityTest.java index a1ca04e183..45c6efd517 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardSecurityTest.java @@ -14,14 +14,6 @@ package org.shanoir.ng.studycard; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.util.HashSet; -import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -41,6 +33,14 @@ import org.springframework.validation.BeanPropertyBindingResult; import org.springframework.validation.BindingResult; +import java.util.HashSet; +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; + /** * User security service test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceSecurityTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceSecurityTest.java index 5421bfb07a..4714a2da06 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceSecurityTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceSecurityTest.java @@ -14,15 +14,6 @@ package org.shanoir.ng.studycard; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.BDDMockito.given; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; -import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -41,6 +32,15 @@ import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ActiveProfiles; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.BDDMockito.given; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessAuthorized; +import static org.shanoir.ng.utils.assertion.AssertUtils.assertAccessDenied; + /** * StudyCard service security test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceTest.java index ff86b2fbbf..b509e2f093 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studycard/StudyCardServiceTest.java @@ -14,12 +14,6 @@ package org.shanoir.ng.studycard; -import static org.mockito.BDDMockito.given; - -import java.util.Arrays; -import java.util.List; -import java.util.Optional; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,6 +29,12 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.mockito.BDDMockito.given; + /** * Study card service test. * diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studyuser/StudyUserProcessCommandTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studyuser/StudyUserProcessCommandTest.java index 83c8095570..a04a7066b6 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studyuser/StudyUserProcessCommandTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/studyuser/StudyUserProcessCommandTest.java @@ -14,11 +14,6 @@ package org.shanoir.ng.studyuser; -import static org.mockito.BDDMockito.given; - -import java.util.ArrayList; -import java.util.List; - import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.shanoir.ng.shared.security.rights.StudyUserRight; @@ -32,6 +27,11 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; +import java.util.ArrayList; +import java.util.List; + +import static org.mockito.BDDMockito.given; + @SpringBootTest @ActiveProfiles("test") diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/tasks/ShanoirEventServiceTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/tasks/ShanoirEventServiceTest.java index 363130592d..f9c8c9e098 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/tasks/ShanoirEventServiceTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/tasks/ShanoirEventServiceTest.java @@ -1,8 +1,5 @@ package org.shanoir.ng.tasks; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; @@ -14,6 +11,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test class for AsyncTaskService. * Testing if the task is well sent to users MS everytime diff --git a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/utils/DatasetFileUtilsTest.java b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/utils/DatasetFileUtilsTest.java index 19b07f2656..f340b09ad5 100644 --- a/shanoir-ng-datasets/src/test/java/org/shanoir/ng/utils/DatasetFileUtilsTest.java +++ b/shanoir-ng-datasets/src/test/java/org/shanoir/ng/utils/DatasetFileUtilsTest.java @@ -1,8 +1,8 @@ package org.shanoir.ng.utils; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.springframework.test.context.ActiveProfiles; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -17,9 +17,7 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; -import org.springframework.test.context.ActiveProfiles; +import static org.junit.jupiter.api.Assertions.*; @ActiveProfiles("test") public class DatasetFileUtilsTest { diff --git a/shanoir-ng-front/src/app/async-tasks/task.model.ts b/shanoir-ng-front/src/app/async-tasks/task.model.ts index 7d6044c94c..35640b82b0 100644 --- a/shanoir-ng-front/src/app/async-tasks/task.model.ts +++ b/shanoir-ng-front/src/app/async-tasks/task.model.ts @@ -2,12 +2,12 @@ * Shanoir NG - Import, manage and share neuroimaging data * Copyright (C) 2009-2019 Inria - https://www.inria.fr/ * Contact us on https://project.inria.fr/shanoir/ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ @@ -66,12 +66,12 @@ export class Task extends Entity { private buildRoute(): string { if (this.eventType === 'importDataset.event' && this.status != -1) { - if (this.message.lastIndexOf('in examination ') != -1) { - return '/examination/details/' + this.message.slice(this.message.lastIndexOf('in examination ') + ('in examination '.length)); - } else if (this.message.lastIndexOf('for examination ') != -1) { - return '/examination/details/' + this.message.slice(this.message.lastIndexOf('for examination ') + ('for examination '.length)); - } else if (this.message.indexOf('in dataset') != -1) { - return '/dataset/details/' + this.message.slice(this.message.lastIndexOf('in dataset ') + ('in dataset '.length)); + if (this.message.lastIndexOf('examination [') != -1) { + let substring = this.message.match(/examination \[\d+\]/g)[0]; + return '/examination/details/' + substring.slice(substring.lastIndexOf("[") + 1, substring.lastIndexOf("]")); + } else if (this.message.indexOf('dataset [') != -1) { + let substring = this.message.match(/dataset \[\d+\]/g)[0]; + return '/dataset/details/' + substring.slice(substring.lastIndexOf("[") + 1, substring.lastIndexOf("]")); } else if (this.message.indexOf('VIP Execution') != -1) { return '/dataset-processing/details/' + this.objectId } diff --git a/shanoir-ng-front/src/app/carmin/carmin-dataset-processings/carmin-dataset-processings.component.ts b/shanoir-ng-front/src/app/carmin/carmin-dataset-processings/carmin-dataset-processings.component.ts index 683594f4dc..23514b7576 100644 --- a/shanoir-ng-front/src/app/carmin/carmin-dataset-processings/carmin-dataset-processings.component.ts +++ b/shanoir-ng-front/src/app/carmin/carmin-dataset-processings/carmin-dataset-processings.component.ts @@ -6,7 +6,7 @@ import { BrowserPaging } from 'src/app/shared/components/table/browser-paging.mo import { Page, Pageable } from 'src/app/shared/components/table/pageable.model'; import { TableComponent } from 'src/app/shared/components/table/table.component'; import { ColumnDefinition } from '../../shared/components/table/column.definition.type'; -import { CarminDatasetProcessing } from '../models/CarminDatasetProcessing'; +import { CarminDatasetProcessing } from '../models/carmin-dataset-processing.model'; import { CarminDatasetProcessingService } from '../shared/carmin-dataset-processing.service'; @Component({ diff --git a/shanoir-ng-front/src/app/carmin/models/CarminDatasetProcessing.ts b/shanoir-ng-front/src/app/carmin/models/carmin-dataset-processing.model.ts similarity index 63% rename from shanoir-ng-front/src/app/carmin/models/CarminDatasetProcessing.ts rename to shanoir-ng-front/src/app/carmin/models/carmin-dataset-processing.model.ts index 812807e7d3..7974f8b60c 100644 --- a/shanoir-ng-front/src/app/carmin/models/CarminDatasetProcessing.ts +++ b/shanoir-ng-front/src/app/carmin/models/carmin-dataset-processing.model.ts @@ -2,18 +2,19 @@ * Shanoir NG - Import, manage and share neuroimaging data * Copyright (C) 2009-2019 Inria - https://www.inria.fr/ * Contact us on https://project.inria.fr/shanoir/ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ import { DatasetProcessing } from "src/app/datasets/shared/dataset-processing.model"; import { StatusEnum } from "./execution"; +import {ParameterResourcesDto} from "./parameter-resources.dto"; export class CarminDatasetProcessing extends DatasetProcessing { @@ -27,27 +28,5 @@ export class CarminDatasetProcessing extends DatasetProcessing { startDate?: number; endDate?: number; outputProcessing?: string; - - constructor( - identifier?: string, - name?: string, - pipelineIdentifier?: string, - resultsLocation?: string, - status?: StatusEnum, - timeout?: number, - startDate?: number, - endDate?: number, - ) { - super(); - this.identifier = identifier; - this.name = name; - this.pipelineIdentifier = pipelineIdentifier; - this.resultsLocation = resultsLocation; - this.status = status; - this.timeout = timeout; - this.startDate = startDate; - this.endDate = endDate - - } - + parametersResources: ParameterResourcesDto[]; } diff --git a/shanoir-ng-front/src/app/carmin/models/groupby.enum.ts b/shanoir-ng-front/src/app/carmin/models/groupby.enum.ts new file mode 100644 index 0000000000..750c9183e6 --- /dev/null +++ b/shanoir-ng-front/src/app/carmin/models/groupby.enum.ts @@ -0,0 +1,5 @@ +export enum GroupByEnum { + + DATASET = 'DATASET', ACQUISITION = 'ACQUISITION', EXAMINATION = 'EXAMINATION', STUDY = 'STUDY', SUBJECT = 'SUBJECT' + +} diff --git a/shanoir-ng-front/src/app/carmin/models/parameter-resources.dto.ts b/shanoir-ng-front/src/app/carmin/models/parameter-resources.dto.ts new file mode 100644 index 0000000000..de13e27f72 --- /dev/null +++ b/shanoir-ng-front/src/app/carmin/models/parameter-resources.dto.ts @@ -0,0 +1,10 @@ +import {GroupByEnum} from "./groupby.enum"; + +export class ParameterResourcesDto { + + parameter: string; + resourceIds : string[]; + groupBy: GroupByEnum; + datasetIds : number[]; + +} diff --git a/shanoir-ng-front/src/app/carmin/shared/carmin-dataset-processing.service.ts b/shanoir-ng-front/src/app/carmin/shared/carmin-dataset-processing.service.ts index 8fcdadc3f0..f657d47445 100644 --- a/shanoir-ng-front/src/app/carmin/shared/carmin-dataset-processing.service.ts +++ b/shanoir-ng-front/src/app/carmin/shared/carmin-dataset-processing.service.ts @@ -2,19 +2,19 @@ * Shanoir NG - Import, manage and share neuroimaging data * Copyright (C) 2009-2022 Inria - https://www.inria.fr/ * Contact us on https://project.inria.fr/shanoir/ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ import { APP_ID, Injectable } from "@angular/core"; import { HttpClient } from "@angular/common/http"; -import { CarminDatasetProcessing } from "../models/CarminDatasetProcessing"; +import { CarminDatasetProcessing } from "../models/carmin-dataset-processing.model"; import * as AppUtils from "../../utils/app.utils"; import { Observable } from "rxjs"; import { EntityService } from "src/app/shared/components/entity/entity.abstract.service"; @@ -25,19 +25,23 @@ export class CarminDatasetProcessingService extends EntityService{ - return this.httpClient.get(`${this.API_URL}/carminDatasetProcessings`); + return this.httpClient.get(`${this.API_URL}/all`); } public getCarminDatasetProcessing(id: number): Observable{ return this.httpClient.get(`${this.API_URL}/${id}`) } + public updateAndStart(processing: CarminDatasetProcessing){ + return this.http.put(this.API_URL + '/' + processing.id + '?start=true', this.stringify(processing)) + .toPromise(); + } + } - \ No newline at end of file diff --git a/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.html b/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.html index 5f6a1a6a0c..1091242475 100644 --- a/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.html +++ b/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.html @@ -155,7 +155,17 @@

Create dataset acquisition

(delete) = "delete()" (cancel)="goToView()" (back)="goBack()" - > + > + + + + +
+ +
+ + + diff --git a/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.ts b/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.ts index 6ddd3c9ba9..c5bcdee7cc 100644 --- a/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.ts +++ b/shanoir-ng-front/src/app/dataset-acquisitions/dataset-acquisition/dataset-acquisition.component.ts @@ -2,16 +2,16 @@ * Shanoir NG - Import, manage and share neuroimaging data * Copyright (C) 2009-2019 Inria - https://www.inria.fr/ * Contact us on https://project.inria.fr/shanoir/ - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ -import { Component } from '@angular/core'; +import {Component, ViewChild} from '@angular/core'; import { UntypedFormGroup, Validators } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; @@ -25,7 +25,11 @@ import { DatasetAcquisitionService } from '../shared/dataset-acquisition.service import { MrDatasetAcquisition } from '../modality/mr/mr-dataset-acquisition.model'; import { AcquisitionEquipmentPipe } from '../../acquisition-equipments/shared/acquisition-equipment.pipe'; import { EntityService } from 'src/app/shared/components/entity/entity.abstract.service'; -import { DatasetAcquisitionNode } from '../../tree/tree.model'; +import {DatasetAcquisitionNode, ExaminationNode} from '../../tree/tree.model'; +import {DatasetService} from "../../datasets/shared/dataset.service"; +import {LoadingBarComponent} from "../../shared/components/loading-bar/loading-bar.component"; +import {StudyUserRight} from "../../studies/shared/study-user-right.enum"; +import {StudyRightsService} from "../../studies/shared/study-rights.service"; @Component({ @@ -35,15 +39,24 @@ import { DatasetAcquisitionNode } from '../../tree/tree.model'; }) export class DatasetAcquisitionComponent extends EntityComponent { + @ViewChild('progressBar') progressBar: LoadingBarComponent; + public studyCards: StudyCard[]; public acquisitionEquipments: AcquisitionEquipment[]; acquisitionNode: DatasetAcquisition | DatasetAcquisitionNode; - + hasDownloadRight: boolean = false; + noDatasets: boolean = false; + hasEEG: boolean = false; + hasDicom: boolean = false; + hasBids: boolean = false; + constructor( private route: ActivatedRoute, + private datasetService: DatasetService, private datasetAcquisitionService: DatasetAcquisitionService, private studyCardService: StudyCardService, private acqEqService: AcquisitionEquipmentService, + private studyRightsService: StudyRightsService, public acqEqPipe: AcquisitionEquipmentPipe) { super(route, 'dataset-acquisition'); } @@ -51,19 +64,42 @@ export class DatasetAcquisitionComponent extends EntityComponent { return this.datasetAcquisitionService; } - + get datasetAcquisition(): DatasetAcquisition { return this.entity; } - set datasetAcquisition(datasetAcquisition: DatasetAcquisition) { + set datasetAcquisition(datasetAcquisition: DatasetAcquisition) { this.acquisitionNode = this.breadcrumbsService.currentStep.data.datasetAcquisitionNode ? this.breadcrumbsService.currentStep.data.datasetAcquisitionNode : datasetAcquisition; - this.entity = datasetAcquisition; + this.entity = datasetAcquisition; } initView(): Promise { return this.datasetAcquisitionService.get(this.id).then(dsAcq => { this.datasetAcquisition = dsAcq; + this.datasetService.getByAcquisitionId(dsAcq.id).then(datasets => { + dsAcq.datasets = datasets; + this.datasetAcquisition.datasets.forEach(ds => { + this.noDatasets = false; + if (ds.type == 'Eeg') { + this.hasEEG = true; + } else if (ds.type == 'BIDS') { + this.hasBids = true; + } else { + this.hasDicom = true; + } + }); + }) + + if (this.keycloakService.isUserAdmin()) { + this.hasDownloadRight = true; + return; + } else { + return this.studyRightsService.getMyRightsForStudy(dsAcq.examination.study.id).then(rights => { + this.hasDownloadRight = rights.includes(StudyUserRight.CAN_DOWNLOAD); + }); + } + }); } - + initEdit(): Promise { this.studyCardService.getAll().then(scs => this.studyCards = scs); this.acqEqService.getAll().then(aes => this.acquisitionEquipments = aes); @@ -88,10 +124,15 @@ export class DatasetAcquisitionComponent extends EntityComponent { return this.keycloakService.isUserAdminOrExpert(); // TODO } @@ -100,4 +141,4 @@ export class DatasetAcquisitionComponent extends EntityComponent - +
+ +
+ + + + diff --git a/shanoir-ng-front/src/app/dataset-acquisitions/tree/dataset-acquisition-node.component.ts b/shanoir-ng-front/src/app/dataset-acquisitions/tree/dataset-acquisition-node.component.ts index a602e36e2b..5fd4e3c935 100644 --- a/shanoir-ng-front/src/app/dataset-acquisitions/tree/dataset-acquisition-node.component.ts +++ b/shanoir-ng-front/src/app/dataset-acquisitions/tree/dataset-acquisition-node.component.ts @@ -11,7 +11,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html */ -import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; +import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild} from '@angular/core'; import { Router } from '@angular/router'; import { DatasetProcessing } from '../../datasets/shared/dataset-processing.model'; import { Dataset } from '../../datasets/shared/dataset.model'; @@ -21,6 +21,8 @@ import { DatasetProcessingType } from '../../enum/dataset-processing-type.enum'; import { DatasetAcquisitionNode, DatasetNode, ProcessingNode, UNLOADED } from '../../tree/tree.model'; import { DatasetAcquisition } from '../shared/dataset-acquisition.model'; import {DatasetAcquisitionService} from "../shared/dataset-acquisition.service"; +import {LoadingBarComponent} from "../../shared/components/loading-bar/loading-bar.component"; +import {ConsoleService} from "../../shared/console/console.service"; @@ -32,6 +34,7 @@ import {DatasetAcquisitionService} from "../shared/dataset-acquisition.service"; export class DatasetAcquisitionNodeComponent implements OnChanges { + @ViewChild('progressBar') progressBar: LoadingBarComponent; @Input() input: DatasetAcquisitionNode | DatasetAcquisition; @Output() selectedChange: EventEmitter = new EventEmitter(); node: DatasetAcquisitionNode; @@ -40,20 +43,31 @@ export class DatasetAcquisitionNodeComponent implements OnChanges { @Input() hasBox: boolean = false; detailsPath: string = '/dataset-acquisition/details/'; @Output() onAcquisitionDelete: EventEmitter = new EventEmitter(); + datasetIds: number[] = []; + hasEEG: boolean = false; + hasDicom: boolean = false; + downloading = false; + hasBids: boolean = false; constructor( private router: Router, private datasetService: DatasetService, - private datasetAcquisitionService: DatasetAcquisitionService) { + private datasetAcquisitionService: DatasetAcquisitionService, + private consoleService: ConsoleService) { } ngOnChanges(changes: SimpleChanges): void { if (changes['input']) { if (this.input instanceof DatasetAcquisitionNode) { this.node = this.input; + if(this.node.datasets != "UNLOADED"){ + this.setDatasetIds(this.node.datasets); + } + } else { - let label: string = 'Dataset Acquisition n° ' + this.input.id; + let label: string = 'Dataset Acquisition n°' + this.input.id; this.node = new DatasetAcquisitionNode(this.input.id, label, UNLOADED,false); + this.loadDatasets(); } } } @@ -67,10 +81,27 @@ export class DatasetAcquisitionNodeComponent implements OnChanges { if (this.node.datasets == UNLOADED) { this.datasetService.getByAcquisitionId(this.node.id).then(datasets => { this.node.datasets = datasets.map(ds => this.mapDatasetNode(ds, false)).sort(); + this.setDatasetIds(this.node.datasets); }); } } + setDatasetIds(nodes: DatasetNode[]){ + if(!nodes){ + return; + } + nodes.forEach(node => { + this.datasetIds.push(node.id); + if (node.type == 'Eeg') { + this.hasEEG = true; + } else if (node.type == 'BIDS') { + this.hasBids = true; + } else { + this.hasDicom = true; + } + }); + } + private mapDatasetNode(dataset: Dataset, processed: boolean): DatasetNode { return new DatasetNode( dataset.id, @@ -104,4 +135,26 @@ export class DatasetAcquisitionNodeComponent implements OnChanges { onDatasetDelete(index: number) { (this.node.datasets as DatasetNode[]).splice(index, 1) ; } + + download(format: string) { + if (this.downloading) { + return; + } + this.downloading = true; + if (this.datasetIds && this.datasetIds.length == 0) return; + let datasetIdsReady: Promise; + + if (!this.datasetIds || this.datasetIds.length == 0) { + this.consoleService.log('warn', 'Sorry, no dataset for acquisition n°' + this.node?.id); + this.downloading = false; + return; + } else { + datasetIdsReady = Promise.resolve(); + } + + datasetIdsReady.then(() => { + this.datasetService.downloadDatasets(this.datasetIds, format, this.progressBar); + this.downloading = false; + }); + } } diff --git a/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.html b/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.html index 28739b0236..49d080fae1 100644 --- a/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.html +++ b/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.html @@ -138,7 +138,7 @@

-
  • +
  • Output datasets Datasets resulting from this dataset processing. diff --git a/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.ts b/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.ts index a4084d748c..7671f240c1 100644 --- a/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.ts +++ b/shanoir-ng-front/src/app/datasets/dataset-processing/dataset-processing.component.ts @@ -31,7 +31,7 @@ import { FilterablePageable, Page } from '../../shared/components/table/pageable import { TableComponent } from '../../shared/components/table/table.component'; import { ColumnDefinition } from '../../shared/components/table/column.definition.type'; import { CarminDatasetProcessingService } from 'src/app/carmin/shared/carmin-dataset-processing.service'; -import { CarminDatasetProcessing } from 'src/app/carmin/models/CarminDatasetProcessing'; +import { CarminDatasetProcessing } from 'src/app/carmin/models/carmin-dataset-processing.model'; import { SuperPromise } from '../../utils/super-promise'; import {CarminClientService} from "../../carmin/shared/carmin-client.service"; import {HttpResponse} from "@angular/common/http"; diff --git a/shanoir-ng-front/src/app/datasets/shared/dataset.service.ts b/shanoir-ng-front/src/app/datasets/shared/dataset.service.ts index f6b8f71871..e85f72d3e3 100644 --- a/shanoir-ng-front/src/app/datasets/shared/dataset.service.ts +++ b/shanoir-ng-front/src/app/datasets/shared/dataset.service.ts @@ -70,12 +70,20 @@ export class DatasetService extends EntityService implements OnDestroy .then(dtos => this.datasetDTOService.toEntityList(dtos)); } + + + getByExaminationId(examinationId: number) { + return this.http.get(AppUtils.BACKEND_API_DATASET_URL + '/examination/' + examinationId) + .toPromise() + .then(dtos => this.datasetDTOService.toEntityList(dtos)); + } + getByStudycardId(studycardId: number): Promise { return this.http.get(AppUtils.BACKEND_API_DATASET_URL + '/studycard/' + studycardId) .toPromise() .then(dtos => this.datasetDTOService.toEntityList(dtos)); } - + getByStudyId(studyId: number): Promise { return this.http.get(AppUtils.BACKEND_API_DATASET_URL + '/study/' + studyId) .toPromise() @@ -100,6 +108,7 @@ export class DatasetService extends EntityService implements OnDestroy .then(dtos => this.datasetDTOService.toEntityList(Array.from(dtos))); } + progressBarFunc(event: HttpEvent, progressBar: LoadingBarComponent): void { switch (event.type) { case HttpEventType.Sent: @@ -170,6 +179,23 @@ export class DatasetService extends EntityService implements OnDestroy ); } + public downloadDatasetsByAcquisition(acquisitionId: number, format: string, progressBar: LoadingBarComponent) { + let params = new HttpParams().set("acquisitionId", '' + acquisitionId).set("format", format); + this.subscribtions.push( + this.http.get( + AppUtils.BACKEND_API_DATASET_URL + '/massiveDownloadByAcquisition',{ + reportProgress: true, + observe: 'events', + responseType: 'blob', + params: params + }).subscribe((event: HttpEvent) => this.progressBarFunc(event, progressBar), + error => { + this.errorService. handleError(error); + progressBar.progress = 0; + }) + ); + } + downloadStatistics(studyNameInRegExp: string, studyNameOutRegExp: string, subjectNameInRegExp: string, subjectNameOutRegExp: string) { let params = new HttpParams().set("studyNameInRegExp", studyNameInRegExp) .set("studyNameOutRegExp", studyNameOutRegExp) @@ -271,4 +297,5 @@ export class DatasetService extends EntityService implements OnDestroy subscribtion.unsubscribe(); } } + } diff --git a/shanoir-ng-front/src/app/examinations/examination/examination.component.html b/shanoir-ng-front/src/app/examinations/examination/examination.component.html index 0b340a88d8..0da85e9088 100644 --- a/shanoir-ng-front/src/app/examinations/examination/examination.component.html +++ b/shanoir-ng-front/src/app/examinations/examination/examination.component.html @@ -181,7 +181,8 @@

    - + +
    diff --git a/shanoir-ng-front/src/app/examinations/tree/examination-node.component.ts b/shanoir-ng-front/src/app/examinations/tree/examination-node.component.ts index 3eb1b3597a..0149548079 100644 --- a/shanoir-ng-front/src/app/examinations/tree/examination-node.component.ts +++ b/shanoir-ng-front/src/app/examinations/tree/examination-node.component.ts @@ -64,7 +64,9 @@ export class ExaminationNodeComponent implements OnChanges { if (changes['input']) { if (this.input instanceof ExaminationNode) { this.node = this.input; - if (this.input.datasetAcquisitions != 'UNLOADED') this.fetchDatasetIds(this.input.datasetAcquisitions); + if (this.input.datasetAcquisitions != 'UNLOADED') { + this.fetchDatasetIds(this.input.datasetAcquisitions); + } } else { this.node = new ExaminationNode( this.input.id, @@ -111,26 +113,27 @@ export class ExaminationNodeComponent implements OnChanges { } fetchDatasetIds(datasetAcquisitions: DatasetAcquisitionNode[]) { - let datasetIds: number[] = []; - if (datasetAcquisitions) { - datasetAcquisitions.forEach(dsAcq => { - if (dsAcq.datasets == 'UNLOADED') { - datasetIds = undefined; // abort - return; - } else { - dsAcq.datasets.forEach(ds => { - datasetIds.push(ds.id); - if (ds.type === 'Eeg') { - this.hasEEG = true; - } else if (ds.type === 'BIDS') { - this.hasBids = true; - } else { - this.hasDicom = true; - } - }); - } - }); + if (!datasetAcquisitions) { + return; } + let datasetIds: number[] = []; + datasetAcquisitions.forEach(dsAcq => { + if (dsAcq.datasets == 'UNLOADED') { + datasetIds = undefined; // abort + return; + } else { + dsAcq.datasets.forEach(ds => { + datasetIds.push(ds.id); + if (ds.type === 'Eeg') { + this.hasEEG = true; + } else if (ds.type === 'BIDS') { + this.hasBids = true; + } else { + this.hasDicom = true; + } + }); + } + }); this.datasetIds = datasetIds; } diff --git a/shanoir-ng-front/src/app/import/bids/bids-upload.component.html b/shanoir-ng-front/src/app/import/bids/bids-upload.component.html index 681365fc3e..529a52a3b0 100644 --- a/shanoir-ng-front/src/app/import/bids/bids-upload.component.html +++ b/shanoir-ng-front/src/app/import/bids/bids-upload.component.html @@ -72,6 +72,7 @@ +