From aafd1785630807a9cb13a4687867966c2714d32c Mon Sep 17 00:00:00 2001 From: pierrehenri-dauvergne Date: Tue, 17 Dec 2024 11:31:43 +0100 Subject: [PATCH 1/2] shanoir-issue#2539: use getType instead of instanceof to check modality --- .../DatasetsModalityTypeCheckValidator.java | 12 +++++------- .../shared/configuration/RabbitMQConfiguration.java | 10 +++++++--- 2 files changed, 12 insertions(+), 10 deletions(-) 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 c3c1ed1922..140f8b06af 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,10 +16,8 @@ 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; import org.shanoir.ng.dataset.model.Dataset; +import org.shanoir.ng.dataset.model.DatasetType; import org.shanoir.ng.datasetacquisition.model.DatasetAcquisition; import org.shanoir.ng.datasetacquisition.model.ct.CtDatasetAcquisition; import org.shanoir.ng.datasetacquisition.model.mr.MrDatasetAcquisition; @@ -42,22 +40,22 @@ public void initialize(final DatasetsModalityTypeCheck constraintAnnotation) { @Override public boolean isValid(final DatasetAcquisition datasetAcquisition, final ConstraintValidatorContext context) { - if (datasetAcquisition.getDatasets() != null && !datasetAcquisition.getDatasets().isEmpty()) { + if (datasetAcquisition.getDatasets() != null && !datasetAcquisition.getDatasets().isEmpty()) { if (datasetAcquisition instanceof MrDatasetAcquisition) { for (Dataset dataset : datasetAcquisition.getDatasets()) { - if (!(dataset instanceof MrDataset)) { + if (!(dataset.getType().equals(DatasetType.Mr))) { return false; } } } else if (datasetAcquisition instanceof PetDatasetAcquisition) { for (Dataset dataset : datasetAcquisition.getDatasets()) { - if (!(dataset instanceof PetDataset)) { + if (!(dataset.getType().equals(DatasetType.Pet))) { return false; } } } else if (datasetAcquisition instanceof CtDatasetAcquisition) { for (Dataset dataset : datasetAcquisition.getDatasets()) { - if (!(dataset instanceof CtDataset)) { + if (!(dataset.getType().equals(DatasetType.Ct))) { return false; } } diff --git a/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java b/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java index 2727e20310..1fdd1d21b8 100644 --- a/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java +++ b/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java @@ -312,10 +312,14 @@ public static Queue subjectStudyQueue() { public static Queue studiesSubjectStudyStudyCardTagQueue() { return new Queue(STUDIES_SUBJECT_STUDY_STUDY_CARD_TAG, true); } - + @Bean - public static Queue deleteSubjectQueue() { return new Queue(DELETE_SUBJECT_QUEUE, true); } - + public static Queue deleteSubjectQueue() { + return new Queue(DELETE_SUBJECT_QUEUE, true); } + @Bean + public static Queue deleteAnimalSubjectQueue() { + return new Queue(DELETE_ANIMAL_SUBJECT_QUEUE, true); } + @Bean public static Queue importerQueue() { return new Queue(IMPORTER_QUEUE_DATASET, true); From 029e92303a37bd0113487c1bfcf93fac60669f01 Mon Sep 17 00:00:00 2001 From: michaelkain Date: Mon, 6 Jan 2025 10:16:42 +0100 Subject: [PATCH 2/2] Update RabbitMQConfiguration.java --- .../ng/shared/configuration/RabbitMQConfiguration.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java b/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java index 159044ec8d..44b4ae88cf 100644 --- a/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java +++ b/shanoir-ng-ms-common/src/main/java/org/shanoir/ng/shared/configuration/RabbitMQConfiguration.java @@ -316,12 +316,12 @@ public static Queue studiesSubjectStudyStudyCardTagQueue() { @Bean public static Queue deleteSubjectQueue() { return new Queue(DELETE_SUBJECT_QUEUE, true); - } + } - @Bean + @Bean public static Queue deleteAnimalSubjectQueue() { return new Queue(DELETE_ANIMAL_SUBJECT_QUEUE, true); - } + } @Bean public static Queue importerQueue() {