From dbb05faa2039d9c28957ec8f927c1b92573515bf Mon Sep 17 00:00:00 2001 From: kfilippopolitis Date: Tue, 12 Dec 2023 13:57:34 +0200 Subject: [PATCH] Refactor project structure from Package by Layer to Package by Feature --- .../AlgorithmService.java | 5 +- .../AlgorithmSpecificationDTO.java | 323 +++++++++--------- .../AlgorithmsAPI.java | 6 +- .../Exareme2AlgorithmRequestDTO.java | 4 +- .../Exareme2AlgorithmSpecificationDTO.java | 2 +- .../algorithm/Exareme2AlgorithmsSpecs.java | 15 + .../ExperimentAPI.java | 8 +- .../DAOs => experiment}/ExperimentDAO.java | 3 +- .../DTOs => experiment}/ExperimentDTO.java | 4 +- .../ExperimentExecutionDTO.java | 2 +- .../ExperimentRepository.java | 8 +- .../ExperimentService.java | 15 +- .../ExperimentSpecifications.java | 3 +- .../DTOs => experiment}/ExperimentsDTO.java | 2 +- ...Exareme2PathologyCommonDataElementDTO.java | 2 +- .../PathologiesAPI.java | 6 +- .../DTOs => pathology}/PathologyDTO.java | 34 +- .../PathologyMetadataDTO.java | 2 +- .../PathologyService.java | 5 +- .../{controllers => user}/ActiveUserAPI.java | 4 +- .../{services => user}/ActiveUserService.java | 5 +- .../mip/{models/DAOs => user}/UserDAO.java | 3 +- .../mip/{models/DTOs => user}/UserDTO.java | 5 +- .../UserRepository.java | 3 +- src/main/java/hbp/mip/utils/ClaimUtils.java | 2 +- .../mip/utils/ControllerExceptionHandler.java | 1 + .../mip/utils/Exareme2AlgorithmsSpecs.java | 21 -- 27 files changed, 230 insertions(+), 263 deletions(-) rename src/main/java/hbp/mip/{services => algorithm}/AlgorithmService.java (95%) rename src/main/java/hbp/mip/{models/DTOs => algorithm}/AlgorithmSpecificationDTO.java (96%) rename src/main/java/hbp/mip/{controllers => algorithm}/AlgorithmsAPI.java (88%) rename src/main/java/hbp/mip/{models/DTOs/exareme2 => algorithm}/Exareme2AlgorithmRequestDTO.java (98%) rename src/main/java/hbp/mip/{models/DTOs/exareme2 => algorithm}/Exareme2AlgorithmSpecificationDTO.java (98%) create mode 100644 src/main/java/hbp/mip/algorithm/Exareme2AlgorithmsSpecs.java rename src/main/java/hbp/mip/{controllers => experiment}/ExperimentAPI.java (96%) rename src/main/java/hbp/mip/{models/DAOs => experiment}/ExperimentDAO.java (97%) rename src/main/java/hbp/mip/{models/DTOs => experiment}/ExperimentDTO.java (95%) rename src/main/java/hbp/mip/{models/DTOs => experiment}/ExperimentExecutionDTO.java (95%) rename src/main/java/hbp/mip/{repositories => experiment}/ExperimentRepository.java (92%) rename src/main/java/hbp/mip/{services => experiment}/ExperimentService.java (98%) rename src/main/java/hbp/mip/{repositories => experiment}/ExperimentSpecifications.java (98%) rename src/main/java/hbp/mip/{models/DTOs => experiment}/ExperimentsDTO.java (86%) rename src/main/java/hbp/mip/{models/DTOs/exareme2 => pathology}/Exareme2PathologyCommonDataElementDTO.java (89%) rename src/main/java/hbp/mip/{controllers => pathology}/PathologiesAPI.java (90%) rename src/main/java/hbp/mip/{models/DTOs => pathology}/PathologyDTO.java (87%) rename src/main/java/hbp/mip/{models/DTOs => pathology}/PathologyMetadataDTO.java (97%) rename src/main/java/hbp/mip/{services => pathology}/PathologyService.java (97%) rename src/main/java/hbp/mip/{controllers => user}/ActiveUserAPI.java (92%) rename src/main/java/hbp/mip/{services => user}/ActiveUserService.java (95%) rename src/main/java/hbp/mip/{models/DAOs => user}/UserDAO.java (94%) rename src/main/java/hbp/mip/{models/DTOs => user}/UserDTO.java (84%) rename src/main/java/hbp/mip/{repositories => user}/UserRepository.java (80%) delete mode 100644 src/main/java/hbp/mip/utils/Exareme2AlgorithmsSpecs.java diff --git a/src/main/java/hbp/mip/services/AlgorithmService.java b/src/main/java/hbp/mip/algorithm/AlgorithmService.java similarity index 95% rename from src/main/java/hbp/mip/services/AlgorithmService.java rename to src/main/java/hbp/mip/algorithm/AlgorithmService.java index 2c922f7e..0e5a570b 100644 --- a/src/main/java/hbp/mip/services/AlgorithmService.java +++ b/src/main/java/hbp/mip/algorithm/AlgorithmService.java @@ -1,11 +1,8 @@ -package hbp.mip.services; +package hbp.mip.algorithm; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; -import hbp.mip.models.DTOs.AlgorithmSpecificationDTO; -import hbp.mip.models.DTOs.exareme2.Exareme2AlgorithmSpecificationDTO; import hbp.mip.utils.CustomResourceLoader; -import hbp.mip.utils.Exareme2AlgorithmsSpecs; import hbp.mip.utils.HTTPUtil; import hbp.mip.utils.Logger; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/hbp/mip/models/DTOs/AlgorithmSpecificationDTO.java b/src/main/java/hbp/mip/algorithm/AlgorithmSpecificationDTO.java similarity index 96% rename from src/main/java/hbp/mip/models/DTOs/AlgorithmSpecificationDTO.java rename to src/main/java/hbp/mip/algorithm/AlgorithmSpecificationDTO.java index c69acd46..0c3c006b 100644 --- a/src/main/java/hbp/mip/models/DTOs/AlgorithmSpecificationDTO.java +++ b/src/main/java/hbp/mip/algorithm/AlgorithmSpecificationDTO.java @@ -1,162 +1,161 @@ -package hbp.mip.models.DTOs; - -import hbp.mip.models.DTOs.exareme2.Exareme2AlgorithmSpecificationDTO; -import hbp.mip.utils.Exceptions.InternalServerError; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - - -public record AlgorithmSpecificationDTO( - String name, - String label, - String desc, - List parameters, - List preprocessing -){ - public record TransformerSpecificationDTO(String name, String label, String desc, - List parameters) { - public TransformerSpecificationDTO(Exareme2AlgorithmSpecificationDTO.Exareme2TransformerSpecificationDTO transformerDTO) { - this( - transformerDTO.name(), - transformerDTO.label(), - transformerDTO.desc(), - getAlgorithmParameterSpecifications(transformerDTO.parameters()) - ); - } - - private static List getAlgorithmParameterSpecifications( - Map exareme2Parameters - ) { - List parameters = new ArrayList<>(); - exareme2Parameters.forEach((name, parameterDTO) - -> parameters.add(new AlgorithmParameterSpecificationDTO(name, parameterDTO))); - return parameters; - } - - } - - public record AlgorithmParameterSpecificationDTO( - String name, - String label, - String desc, - String type, - String columnValuesSQLType, - String columnValuesIsCategorical, - String defaultValue, - String valueType, - String valueNotBlank, - String valueMultiple, - String valueMin, - String valueMax, - List valueEnumerations - ) { - public AlgorithmParameterSpecificationDTO(String name, Exareme2AlgorithmSpecificationDTO.Exareme2AlgorithmParameterSpecificationDTO parameter) { - this( - name, - parameter.label(), - parameter.desc(), - "other", - "", - "", - parameter.default_value(), - parameter.types().get(0), - parameter.notblank(), - parameter.multiple(), - parameter.min(), - parameter.max(), - parameter.enums() != null ? parameter.enums().source() : null - ); - } - - public AlgorithmParameterSpecificationDTO(String name, Exareme2AlgorithmSpecificationDTO.Exareme2AlgorithmInputDataDetailSpecificationDTO inputDataDetail) { - this( - name, - inputDataDetail.label(), - inputDataDetail.desc(), - getParameterType(name), - getParameterColumnValuesSQLType(name, inputDataDetail.types()), - getParameterColumnValuesIsCategorical(name, inputDataDetail.stattypes()), - "", - getParameterValueType(name, inputDataDetail.types()), - inputDataDetail.notblank(), - inputDataDetail.multiple(), - "", - "", - null - ); - } - - private static String getParameterType(String inputDataDetailName){ - if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { - return inputDataDetailName; - } - return "column"; - } - - private static String getParameterValueType(String inputDataDetailName, List types){ - if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { - return types.get(0); - } - return ""; - } - - private static String getParameterColumnValuesSQLType(String inputDataDetailName, List types){ - if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { - return ""; - } - return String.join(", ", types); - } - - private static String getParameterColumnValuesIsCategorical(String inputDataDetailName, List stattypes){ - if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { - return ""; - } - - if (stattypes.contains("nominal") && stattypes.contains("numerical")) { - return ""; - } else if (stattypes.contains("nominal")) { - return "true"; - } else if (stattypes.contains("numerical")) { - return "false"; - } else { - throw new InternalServerError("Invalid stattypes: " + stattypes); - } - } - } - - public AlgorithmSpecificationDTO(Exareme2AlgorithmSpecificationDTO exareme2Algorithm){ - this( - exareme2Algorithm.name(), - exareme2Algorithm.label(), - exareme2Algorithm.desc(), - getAlgorithmParameters(exareme2Algorithm), - getTransformers(exareme2Algorithm.preprocessing()) - ); - } - - private static List getAlgorithmParameters(Exareme2AlgorithmSpecificationDTO exareme2Algorithm){ - List parameters = new ArrayList<>(); - if (exareme2Algorithm.inputdata().y() != null) { - parameters.add(new AlgorithmParameterSpecificationDTO("y", exareme2Algorithm.inputdata().y())); - } - if (exareme2Algorithm.inputdata().x() != null) { - parameters.add(new AlgorithmParameterSpecificationDTO("x", exareme2Algorithm.inputdata().x())); - } - parameters.add(new AlgorithmParameterSpecificationDTO("pathology", exareme2Algorithm.inputdata().data_model())); - parameters.add(new AlgorithmParameterSpecificationDTO("dataset", exareme2Algorithm.inputdata().datasets())); - parameters.add(new AlgorithmParameterSpecificationDTO("filter", exareme2Algorithm.inputdata().filter())); - exareme2Algorithm.parameters().forEach((name, parameterDTO) - -> parameters.add(new AlgorithmParameterSpecificationDTO(name, parameterDTO))); - return parameters; - } - - private static List getTransformers(List exareme2Transformers){ - List preprocessing = new ArrayList<>(); - exareme2Transformers.forEach(exareme2TransformerSpecificationDTO - -> preprocessing.add(new TransformerSpecificationDTO(exareme2TransformerSpecificationDTO))); - return preprocessing; - } - -} +package hbp.mip.algorithm; + +import hbp.mip.utils.Exceptions.InternalServerError; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + + +public record AlgorithmSpecificationDTO( + String name, + String label, + String desc, + List parameters, + List preprocessing +){ + public record TransformerSpecificationDTO(String name, String label, String desc, + List parameters) { + public TransformerSpecificationDTO(Exareme2AlgorithmSpecificationDTO.Exareme2TransformerSpecificationDTO transformerDTO) { + this( + transformerDTO.name(), + transformerDTO.label(), + transformerDTO.desc(), + getAlgorithmParameterSpecifications(transformerDTO.parameters()) + ); + } + + private static List getAlgorithmParameterSpecifications( + Map exareme2Parameters + ) { + List parameters = new ArrayList<>(); + exareme2Parameters.forEach((name, parameterDTO) + -> parameters.add(new AlgorithmParameterSpecificationDTO(name, parameterDTO))); + return parameters; + } + + } + + public record AlgorithmParameterSpecificationDTO( + String name, + String label, + String desc, + String type, + String columnValuesSQLType, + String columnValuesIsCategorical, + String defaultValue, + String valueType, + String valueNotBlank, + String valueMultiple, + String valueMin, + String valueMax, + List valueEnumerations + ) { + public AlgorithmParameterSpecificationDTO(String name, Exareme2AlgorithmSpecificationDTO.Exareme2AlgorithmParameterSpecificationDTO parameter) { + this( + name, + parameter.label(), + parameter.desc(), + "other", + "", + "", + parameter.default_value(), + parameter.types().get(0), + parameter.notblank(), + parameter.multiple(), + parameter.min(), + parameter.max(), + parameter.enums() != null ? parameter.enums().source() : null + ); + } + + public AlgorithmParameterSpecificationDTO(String name, Exareme2AlgorithmSpecificationDTO.Exareme2AlgorithmInputDataDetailSpecificationDTO inputDataDetail) { + this( + name, + inputDataDetail.label(), + inputDataDetail.desc(), + getParameterType(name), + getParameterColumnValuesSQLType(name, inputDataDetail.types()), + getParameterColumnValuesIsCategorical(name, inputDataDetail.stattypes()), + "", + getParameterValueType(name, inputDataDetail.types()), + inputDataDetail.notblank(), + inputDataDetail.multiple(), + "", + "", + null + ); + } + + private static String getParameterType(String inputDataDetailName){ + if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { + return inputDataDetailName; + } + return "column"; + } + + private static String getParameterValueType(String inputDataDetailName, List types){ + if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { + return types.get(0); + } + return ""; + } + + private static String getParameterColumnValuesSQLType(String inputDataDetailName, List types){ + if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { + return ""; + } + return String.join(", ", types); + } + + private static String getParameterColumnValuesIsCategorical(String inputDataDetailName, List stattypes){ + if (inputDataDetailName.equals("dataset") || inputDataDetailName.equals("filter") || inputDataDetailName.equals("pathology")) { + return ""; + } + + if (stattypes.contains("nominal") && stattypes.contains("numerical")) { + return ""; + } else if (stattypes.contains("nominal")) { + return "true"; + } else if (stattypes.contains("numerical")) { + return "false"; + } else { + throw new InternalServerError("Invalid stattypes: " + stattypes); + } + } + } + + public AlgorithmSpecificationDTO(Exareme2AlgorithmSpecificationDTO exareme2Algorithm){ + this( + exareme2Algorithm.name(), + exareme2Algorithm.label(), + exareme2Algorithm.desc(), + getAlgorithmParameters(exareme2Algorithm), + getTransformers(exareme2Algorithm.preprocessing()) + ); + } + + private static List getAlgorithmParameters(Exareme2AlgorithmSpecificationDTO exareme2Algorithm){ + List parameters = new ArrayList<>(); + if (exareme2Algorithm.inputdata().y() != null) { + parameters.add(new AlgorithmParameterSpecificationDTO("y", exareme2Algorithm.inputdata().y())); + } + if (exareme2Algorithm.inputdata().x() != null) { + parameters.add(new AlgorithmParameterSpecificationDTO("x", exareme2Algorithm.inputdata().x())); + } + parameters.add(new AlgorithmParameterSpecificationDTO("pathology", exareme2Algorithm.inputdata().data_model())); + parameters.add(new AlgorithmParameterSpecificationDTO("dataset", exareme2Algorithm.inputdata().datasets())); + parameters.add(new AlgorithmParameterSpecificationDTO("filter", exareme2Algorithm.inputdata().filter())); + exareme2Algorithm.parameters().forEach((name, parameterDTO) + -> parameters.add(new AlgorithmParameterSpecificationDTO(name, parameterDTO))); + return parameters; + } + + private static List getTransformers(List exareme2Transformers){ + List preprocessing = new ArrayList<>(); + exareme2Transformers.forEach(exareme2TransformerSpecificationDTO + -> preprocessing.add(new TransformerSpecificationDTO(exareme2TransformerSpecificationDTO))); + return preprocessing; + } + +} diff --git a/src/main/java/hbp/mip/controllers/AlgorithmsAPI.java b/src/main/java/hbp/mip/algorithm/AlgorithmsAPI.java similarity index 88% rename from src/main/java/hbp/mip/controllers/AlgorithmsAPI.java rename to src/main/java/hbp/mip/algorithm/AlgorithmsAPI.java index ef65fc7c..0570a025 100644 --- a/src/main/java/hbp/mip/controllers/AlgorithmsAPI.java +++ b/src/main/java/hbp/mip/algorithm/AlgorithmsAPI.java @@ -1,8 +1,6 @@ -package hbp.mip.controllers; +package hbp.mip.algorithm; -import hbp.mip.models.DTOs.AlgorithmSpecificationDTO; -import hbp.mip.services.ActiveUserService; -import hbp.mip.services.AlgorithmService; +import hbp.mip.user.ActiveUserService; import hbp.mip.utils.Logger; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; diff --git a/src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmRequestDTO.java b/src/main/java/hbp/mip/algorithm/Exareme2AlgorithmRequestDTO.java similarity index 98% rename from src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmRequestDTO.java rename to src/main/java/hbp/mip/algorithm/Exareme2AlgorithmRequestDTO.java index 311f4074..dea08fb7 100644 --- a/src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmRequestDTO.java +++ b/src/main/java/hbp/mip/algorithm/Exareme2AlgorithmRequestDTO.java @@ -1,7 +1,7 @@ -package hbp.mip.models.DTOs.exareme2; +package hbp.mip.algorithm; import com.google.gson.JsonSyntaxException; -import hbp.mip.models.DTOs.ExperimentExecutionDTO; +import hbp.mip.experiment.ExperimentExecutionDTO; import hbp.mip.utils.Exceptions.InternalServerError; import hbp.mip.utils.JsonConverters; diff --git a/src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmSpecificationDTO.java b/src/main/java/hbp/mip/algorithm/Exareme2AlgorithmSpecificationDTO.java similarity index 98% rename from src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmSpecificationDTO.java rename to src/main/java/hbp/mip/algorithm/Exareme2AlgorithmSpecificationDTO.java index 4196bb99..93708e3a 100644 --- a/src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2AlgorithmSpecificationDTO.java +++ b/src/main/java/hbp/mip/algorithm/Exareme2AlgorithmSpecificationDTO.java @@ -1,4 +1,4 @@ -package hbp.mip.models.DTOs.exareme2; +package hbp.mip.algorithm; import com.google.gson.annotations.SerializedName; diff --git a/src/main/java/hbp/mip/algorithm/Exareme2AlgorithmsSpecs.java b/src/main/java/hbp/mip/algorithm/Exareme2AlgorithmsSpecs.java new file mode 100644 index 00000000..5dd7eb1d --- /dev/null +++ b/src/main/java/hbp/mip/algorithm/Exareme2AlgorithmsSpecs.java @@ -0,0 +1,15 @@ +package hbp.mip.algorithm; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +@Getter +@Setter +@Component +public class Exareme2AlgorithmsSpecs { + private List algorithms = new ArrayList<>(); +} diff --git a/src/main/java/hbp/mip/controllers/ExperimentAPI.java b/src/main/java/hbp/mip/experiment/ExperimentAPI.java similarity index 96% rename from src/main/java/hbp/mip/controllers/ExperimentAPI.java rename to src/main/java/hbp/mip/experiment/ExperimentAPI.java index a63e0fc0..2a0e52b5 100644 --- a/src/main/java/hbp/mip/controllers/ExperimentAPI.java +++ b/src/main/java/hbp/mip/experiment/ExperimentAPI.java @@ -1,11 +1,7 @@ -package hbp.mip.controllers; +package hbp.mip.experiment; -import hbp.mip.models.DTOs.ExperimentDTO; -import hbp.mip.models.DTOs.ExperimentExecutionDTO; -import hbp.mip.models.DTOs.ExperimentsDTO; -import hbp.mip.services.ActiveUserService; -import hbp.mip.services.ExperimentService; +import hbp.mip.user.ActiveUserService; import hbp.mip.utils.JsonConverters; import hbp.mip.utils.Logger; import org.springframework.http.HttpStatus; diff --git a/src/main/java/hbp/mip/models/DAOs/ExperimentDAO.java b/src/main/java/hbp/mip/experiment/ExperimentDAO.java similarity index 97% rename from src/main/java/hbp/mip/models/DAOs/ExperimentDAO.java rename to src/main/java/hbp/mip/experiment/ExperimentDAO.java index 0c87adbc..2e464a8b 100644 --- a/src/main/java/hbp/mip/models/DAOs/ExperimentDAO.java +++ b/src/main/java/hbp/mip/experiment/ExperimentDAO.java @@ -1,7 +1,8 @@ -package hbp.mip.models.DAOs; +package hbp.mip.experiment; import com.google.gson.Gson; import com.google.gson.annotations.Expose; +import hbp.mip.user.UserDAO; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/hbp/mip/models/DTOs/ExperimentDTO.java b/src/main/java/hbp/mip/experiment/ExperimentDTO.java similarity index 95% rename from src/main/java/hbp/mip/models/DTOs/ExperimentDTO.java rename to src/main/java/hbp/mip/experiment/ExperimentDTO.java index 2fcb55c1..013e2967 100644 --- a/src/main/java/hbp/mip/models/DTOs/ExperimentDTO.java +++ b/src/main/java/hbp/mip/experiment/ExperimentDTO.java @@ -1,6 +1,6 @@ -package hbp.mip.models.DTOs; +package hbp.mip.experiment; -import hbp.mip.models.DAOs.ExperimentDAO; +import hbp.mip.user.UserDTO; import hbp.mip.utils.JsonConverters; import java.util.ArrayList; diff --git a/src/main/java/hbp/mip/models/DTOs/ExperimentExecutionDTO.java b/src/main/java/hbp/mip/experiment/ExperimentExecutionDTO.java similarity index 95% rename from src/main/java/hbp/mip/models/DTOs/ExperimentExecutionDTO.java rename to src/main/java/hbp/mip/experiment/ExperimentExecutionDTO.java index 82f555ee..340525d8 100644 --- a/src/main/java/hbp/mip/models/DTOs/ExperimentExecutionDTO.java +++ b/src/main/java/hbp/mip/experiment/ExperimentExecutionDTO.java @@ -1,4 +1,4 @@ -package hbp.mip.models.DTOs; +package hbp.mip.experiment; import java.util.List; diff --git a/src/main/java/hbp/mip/repositories/ExperimentRepository.java b/src/main/java/hbp/mip/experiment/ExperimentRepository.java similarity index 92% rename from src/main/java/hbp/mip/repositories/ExperimentRepository.java rename to src/main/java/hbp/mip/experiment/ExperimentRepository.java index 445b4131..ec2fa54e 100644 --- a/src/main/java/hbp/mip/repositories/ExperimentRepository.java +++ b/src/main/java/hbp/mip/experiment/ExperimentRepository.java @@ -1,9 +1,7 @@ -package hbp.mip.repositories; +package hbp.mip.experiment; -import hbp.mip.models.DAOs.ExperimentDAO; -import hbp.mip.models.DAOs.UserDAO; -import hbp.mip.models.DTOs.ExperimentExecutionDTO; -import hbp.mip.models.DTOs.UserDTO; +import hbp.mip.user.UserDAO; +import hbp.mip.user.UserDTO; import hbp.mip.utils.Exceptions.BadRequestException; import hbp.mip.utils.Exceptions.ExperimentNotFoundException; import hbp.mip.utils.JsonConverters; diff --git a/src/main/java/hbp/mip/services/ExperimentService.java b/src/main/java/hbp/mip/experiment/ExperimentService.java similarity index 98% rename from src/main/java/hbp/mip/services/ExperimentService.java rename to src/main/java/hbp/mip/experiment/ExperimentService.java index 2036c60e..17cb7f3b 100644 --- a/src/main/java/hbp/mip/services/ExperimentService.java +++ b/src/main/java/hbp/mip/experiment/ExperimentService.java @@ -1,11 +1,10 @@ -package hbp.mip.services; - -import hbp.mip.models.DAOs.ExperimentDAO; -import hbp.mip.models.DTOs.*; -import hbp.mip.models.DTOs.exareme2.Exareme2AlgorithmRequestDTO; -import hbp.mip.models.DTOs.exareme2.Exareme2AlgorithmSpecificationDTO; -import hbp.mip.repositories.ExperimentRepository; -import hbp.mip.repositories.ExperimentSpecifications; +package hbp.mip.experiment; + +import hbp.mip.algorithm.Exareme2AlgorithmsSpecs; +import hbp.mip.algorithm.Exareme2AlgorithmRequestDTO; +import hbp.mip.algorithm.Exareme2AlgorithmSpecificationDTO; +import hbp.mip.user.ActiveUserService; +import hbp.mip.user.UserDTO; import hbp.mip.utils.*; import hbp.mip.utils.Exceptions.BadRequestException; import hbp.mip.utils.Exceptions.InternalServerError; diff --git a/src/main/java/hbp/mip/repositories/ExperimentSpecifications.java b/src/main/java/hbp/mip/experiment/ExperimentSpecifications.java similarity index 98% rename from src/main/java/hbp/mip/repositories/ExperimentSpecifications.java rename to src/main/java/hbp/mip/experiment/ExperimentSpecifications.java index 5c5d86f1..60ef2dde 100644 --- a/src/main/java/hbp/mip/repositories/ExperimentSpecifications.java +++ b/src/main/java/hbp/mip/experiment/ExperimentSpecifications.java @@ -1,6 +1,5 @@ -package hbp.mip.repositories; +package hbp.mip.experiment; -import hbp.mip.models.DAOs.ExperimentDAO; import hbp.mip.utils.Exceptions.BadRequestException; import jakarta.persistence.criteria.*; import lombok.NonNull; diff --git a/src/main/java/hbp/mip/models/DTOs/ExperimentsDTO.java b/src/main/java/hbp/mip/experiment/ExperimentsDTO.java similarity index 86% rename from src/main/java/hbp/mip/models/DTOs/ExperimentsDTO.java rename to src/main/java/hbp/mip/experiment/ExperimentsDTO.java index ca436a09..a23fbece 100644 --- a/src/main/java/hbp/mip/models/DTOs/ExperimentsDTO.java +++ b/src/main/java/hbp/mip/experiment/ExperimentsDTO.java @@ -1,4 +1,4 @@ -package hbp.mip.models.DTOs; +package hbp.mip.experiment; import java.util.List; diff --git a/src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2PathologyCommonDataElementDTO.java b/src/main/java/hbp/mip/pathology/Exareme2PathologyCommonDataElementDTO.java similarity index 89% rename from src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2PathologyCommonDataElementDTO.java rename to src/main/java/hbp/mip/pathology/Exareme2PathologyCommonDataElementDTO.java index 38faa1fe..df5c853f 100644 --- a/src/main/java/hbp/mip/models/DTOs/exareme2/Exareme2PathologyCommonDataElementDTO.java +++ b/src/main/java/hbp/mip/pathology/Exareme2PathologyCommonDataElementDTO.java @@ -1,4 +1,4 @@ -package hbp.mip.models.DTOs.exareme2; +package hbp.mip.pathology; public record Exareme2PathologyCommonDataElementDTO( diff --git a/src/main/java/hbp/mip/controllers/PathologiesAPI.java b/src/main/java/hbp/mip/pathology/PathologiesAPI.java similarity index 90% rename from src/main/java/hbp/mip/controllers/PathologiesAPI.java rename to src/main/java/hbp/mip/pathology/PathologiesAPI.java index bbcd3465..5282f310 100644 --- a/src/main/java/hbp/mip/controllers/PathologiesAPI.java +++ b/src/main/java/hbp/mip/pathology/PathologiesAPI.java @@ -1,8 +1,6 @@ -package hbp.mip.controllers; +package hbp.mip.pathology; -import hbp.mip.models.DTOs.PathologyDTO; -import hbp.mip.services.ActiveUserService; -import hbp.mip.services.PathologyService; +import hbp.mip.user.ActiveUserService; import hbp.mip.utils.Logger; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; diff --git a/src/main/java/hbp/mip/models/DTOs/PathologyDTO.java b/src/main/java/hbp/mip/pathology/PathologyDTO.java similarity index 87% rename from src/main/java/hbp/mip/models/DTOs/PathologyDTO.java rename to src/main/java/hbp/mip/pathology/PathologyDTO.java index a1364379..0989d2a7 100644 --- a/src/main/java/hbp/mip/models/DTOs/PathologyDTO.java +++ b/src/main/java/hbp/mip/pathology/PathologyDTO.java @@ -1,17 +1,17 @@ -package hbp.mip.models.DTOs; - -import java.util.List; - - -public record PathologyDTO( - String code, - String version, - String label, - Boolean longitudinal, - PathologyMetadataDTO metadataHierarchy, - List datasets -) { - public record EnumerationDTO(String code, String label) { - } -} - +package hbp.mip.pathology; + +import java.util.List; + + +public record PathologyDTO( + String code, + String version, + String label, + Boolean longitudinal, + PathologyMetadataDTO metadataHierarchy, + List datasets +) { + public record EnumerationDTO(String code, String label) { + } +} + diff --git a/src/main/java/hbp/mip/models/DTOs/PathologyMetadataDTO.java b/src/main/java/hbp/mip/pathology/PathologyMetadataDTO.java similarity index 97% rename from src/main/java/hbp/mip/models/DTOs/PathologyMetadataDTO.java rename to src/main/java/hbp/mip/pathology/PathologyMetadataDTO.java index eb795fb2..77ff07fc 100644 --- a/src/main/java/hbp/mip/models/DTOs/PathologyMetadataDTO.java +++ b/src/main/java/hbp/mip/pathology/PathologyMetadataDTO.java @@ -1,4 +1,4 @@ -package hbp.mip.models.DTOs; +package hbp.mip.pathology; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/hbp/mip/services/PathologyService.java b/src/main/java/hbp/mip/pathology/PathologyService.java similarity index 97% rename from src/main/java/hbp/mip/services/PathologyService.java rename to src/main/java/hbp/mip/pathology/PathologyService.java index 5b7a8d75..eb084741 100644 --- a/src/main/java/hbp/mip/services/PathologyService.java +++ b/src/main/java/hbp/mip/pathology/PathologyService.java @@ -1,9 +1,6 @@ -package hbp.mip.services; +package hbp.mip.pathology; import com.google.gson.reflect.TypeToken; -import hbp.mip.models.DTOs.exareme2.Exareme2PathologyCommonDataElementDTO; -import hbp.mip.models.DTOs.PathologyMetadataDTO; -import hbp.mip.models.DTOs.PathologyDTO; import hbp.mip.utils.ClaimUtils; import hbp.mip.utils.Exceptions.InternalServerError; import hbp.mip.utils.HTTPUtil; diff --git a/src/main/java/hbp/mip/controllers/ActiveUserAPI.java b/src/main/java/hbp/mip/user/ActiveUserAPI.java similarity index 92% rename from src/main/java/hbp/mip/controllers/ActiveUserAPI.java rename to src/main/java/hbp/mip/user/ActiveUserAPI.java index 9fb7e8fe..f415d870 100644 --- a/src/main/java/hbp/mip/controllers/ActiveUserAPI.java +++ b/src/main/java/hbp/mip/user/ActiveUserAPI.java @@ -1,7 +1,5 @@ -package hbp.mip.controllers; +package hbp.mip.user; -import hbp.mip.models.DTOs.UserDTO; -import hbp.mip.services.ActiveUserService; import hbp.mip.utils.Logger; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; diff --git a/src/main/java/hbp/mip/services/ActiveUserService.java b/src/main/java/hbp/mip/user/ActiveUserService.java similarity index 95% rename from src/main/java/hbp/mip/services/ActiveUserService.java rename to src/main/java/hbp/mip/user/ActiveUserService.java index 07d0841d..222faca2 100644 --- a/src/main/java/hbp/mip/services/ActiveUserService.java +++ b/src/main/java/hbp/mip/user/ActiveUserService.java @@ -1,8 +1,5 @@ -package hbp.mip.services; +package hbp.mip.user; -import hbp.mip.models.DAOs.UserDAO; -import hbp.mip.models.DTOs.UserDTO; -import hbp.mip.repositories.UserRepository; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; diff --git a/src/main/java/hbp/mip/models/DAOs/UserDAO.java b/src/main/java/hbp/mip/user/UserDAO.java similarity index 94% rename from src/main/java/hbp/mip/models/DAOs/UserDAO.java rename to src/main/java/hbp/mip/user/UserDAO.java index 7e7c845f..d6f0074c 100644 --- a/src/main/java/hbp/mip/models/DAOs/UserDAO.java +++ b/src/main/java/hbp/mip/user/UserDAO.java @@ -1,7 +1,6 @@ -package hbp.mip.models.DAOs; +package hbp.mip.user; import com.google.gson.annotations.Expose; -import hbp.mip.models.DTOs.UserDTO; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; diff --git a/src/main/java/hbp/mip/models/DTOs/UserDTO.java b/src/main/java/hbp/mip/user/UserDTO.java similarity index 84% rename from src/main/java/hbp/mip/models/DTOs/UserDTO.java rename to src/main/java/hbp/mip/user/UserDTO.java index 348e315d..3b68be5c 100644 --- a/src/main/java/hbp/mip/models/DTOs/UserDTO.java +++ b/src/main/java/hbp/mip/user/UserDTO.java @@ -1,7 +1,4 @@ -package hbp.mip.models.DTOs; - -import hbp.mip.models.DAOs.UserDAO; - +package hbp.mip.user; public record UserDTO(String username, String fullname, String email, String subjectId, Boolean agreeNDA){ public UserDTO(UserDAO userDAO){ diff --git a/src/main/java/hbp/mip/repositories/UserRepository.java b/src/main/java/hbp/mip/user/UserRepository.java similarity index 80% rename from src/main/java/hbp/mip/repositories/UserRepository.java rename to src/main/java/hbp/mip/user/UserRepository.java index 505fcbbd..d83ad87e 100644 --- a/src/main/java/hbp/mip/repositories/UserRepository.java +++ b/src/main/java/hbp/mip/user/UserRepository.java @@ -1,6 +1,5 @@ -package hbp.mip.repositories; +package hbp.mip.user; -import hbp.mip.models.DAOs.UserDAO; import org.springframework.data.repository.CrudRepository; import org.springframework.data.rest.core.annotation.RestResource; diff --git a/src/main/java/hbp/mip/utils/ClaimUtils.java b/src/main/java/hbp/mip/utils/ClaimUtils.java index da31ee24..540de596 100644 --- a/src/main/java/hbp/mip/utils/ClaimUtils.java +++ b/src/main/java/hbp/mip/utils/ClaimUtils.java @@ -1,6 +1,6 @@ package hbp.mip.utils; -import hbp.mip.models.DTOs.PathologyDTO; +import hbp.mip.pathology.PathologyDTO; import hbp.mip.utils.Exceptions.UnauthorizedException; import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.Authentication; diff --git a/src/main/java/hbp/mip/utils/ControllerExceptionHandler.java b/src/main/java/hbp/mip/utils/ControllerExceptionHandler.java index 0cd1efa8..b873971a 100644 --- a/src/main/java/hbp/mip/utils/ControllerExceptionHandler.java +++ b/src/main/java/hbp/mip/utils/ControllerExceptionHandler.java @@ -1,5 +1,6 @@ package hbp.mip.utils; +import hbp.mip.utils.Exceptions.ExperimentNotFoundException; import hbp.mip.utils.Exceptions.*; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/hbp/mip/utils/Exareme2AlgorithmsSpecs.java b/src/main/java/hbp/mip/utils/Exareme2AlgorithmsSpecs.java deleted file mode 100644 index 9b87ca25..00000000 --- a/src/main/java/hbp/mip/utils/Exareme2AlgorithmsSpecs.java +++ /dev/null @@ -1,21 +0,0 @@ -package hbp.mip.utils; - -import hbp.mip.models.DTOs.exareme2.Exareme2AlgorithmSpecificationDTO; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -@Component -public class Exareme2AlgorithmsSpecs { - private List algorithms = new ArrayList<>(); - - - public List getAlgorithms() { - return algorithms; - } - - public void setAlgorithms(List algorithms) { - this.algorithms = algorithms; - } -}