Skip to content

Commit

Permalink
Merge pull request #2549 from pierrehenri-dauvergne/shanoir-issue#2539
Browse files Browse the repository at this point in the history
shanoir-issue#2539: use getType instead of instanceof to check modality
  • Loading branch information
michaelkain authored Jan 6, 2025
2 parents ff6761a + 029e923 commit ce01b69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,17 @@ 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); }

@Bean
public static Queue deleteAnimalSubjectQueue() { return new Queue(DELETE_ANIMAL_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);
Expand Down

0 comments on commit ce01b69

Please sign in to comment.