diff --git a/docker-compose/database/db-changes/datasets/0055_add_sortingindex_solr.sql b/docker-compose/database/db-changes/datasets/0055_add_sortingindex_solr.sql new file mode 100644 index 0000000000..85cbb540cb --- /dev/null +++ b/docker-compose/database/db-changes/datasets/0055_add_sortingindex_solr.sql @@ -0,0 +1 @@ +ALTER TABLE shanoir_metadata ADD COLUMN sorting_index int(11); \ No newline at end of file diff --git a/docker-compose/solr/core/schema.xml b/docker-compose/solr/core/schema.xml index cfba744a3e..3369bdc4d0 100644 --- a/docker-compose/solr/core/schema.xml +++ b/docker-compose/solr/core/schema.xml @@ -461,6 +461,7 @@ + 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 67b7aea1b4..a958a7a8af 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 @@ -44,7 +44,7 @@ @ColumnResult(name="sliceThickness", type = Double.class), @ColumnResult(name="pixelBandwidth", type = Double.class), @ColumnResult(name="magneticFieldStrength", type = Double.class), @ColumnResult(name="processed", type = Boolean.class), @ColumnResult(name="importDate", type = LocalDate.class), - @ColumnResult(name="username", type = String.class) + @ColumnResult(name="username", type = String.class), @ColumnResult(name="sortingIndex", type = Integer.class) }) }) @@ -93,6 +93,8 @@ public class ShanoirMetadata { private Long subjectId; + private Integer sortingIndex; + private boolean processed; @LocalDateAnnotations @@ -107,7 +109,7 @@ public ShanoirMetadata () { public ShanoirMetadata (Long datasetId, String datasetName, Integer datasetType, Integer datasetNature, LocalDate datasetCreationDate, Long examinationId, String examinationComment, LocalDate examinationDate, String acquisitionEquipmentName, String subjectName, Integer subjectType, Long subjectId, String studyName, Long studyId, String centerName, Long centerId, Double sliceThickness, - Double pixelBandwidth, Double magneticFieldStrength, boolean processed, LocalDate importDate, String username) { + Double pixelBandwidth, Double magneticFieldStrength, boolean processed, LocalDate importDate, String username, Integer sortingIndex) { this.datasetId = datasetId; this.datasetName = datasetName; this.datasetType = datasetType; @@ -120,6 +122,7 @@ public ShanoirMetadata (Long datasetId, String datasetName, Integer datasetType, this.subjectName = subjectName; this.subjectType = subjectType; this.subjectId = subjectId; + this.sortingIndex = sortingIndex; this.studyName = studyName; this.studyId = studyId; this.centerName = centerName; @@ -358,6 +361,14 @@ public void setSubjectId(Long subjectId) { this.subjectId = subjectId; } + public Integer getSortingIndex() { + return sortingIndex; + } + + public void setSortingIndex(Integer sortingIndex) { + this.sortingIndex = sortingIndex; + } + public Long getCenterId() { return centerId; } 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 d630f88083..445a453649 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 @@ -75,6 +75,9 @@ public class ShanoirSolrDocument { @Field private Long subjectId; + @Field + private Integer sortingIndex; + @Field private String studyName; @@ -114,7 +117,7 @@ public ShanoirSolrDocument () { public ShanoirSolrDocument (String id, Long datasetId, String datasetName, String datasetType, String datasetNature, Date datasetCreationDate, Long examinationId, String examinationComment, Date examinationDate, String acquisitionEquipmentName, String subjectName, String subjectType, Long subjectId, String studyName, Long studyId, String centerName, Long centerId, Double sliceThickness, - Double pixelBandwidth, Double magneticFieldStrength, boolean processed, Date importDate, String username) { + Double pixelBandwidth, Double magneticFieldStrength, boolean processed, Date importDate, String username, Integer sortingIndex) { this.id = id; this.datasetId = datasetId; this.datasetName = datasetName; @@ -128,6 +131,7 @@ public ShanoirSolrDocument (String id, Long datasetId, String datasetName, Strin this.subjectName = subjectName; this.subjectType = subjectType; this.subjectId = subjectId; + this.sortingIndex = sortingIndex; this.studyName = studyName; this.studyId = studyId; this.centerName = centerName; @@ -360,6 +364,14 @@ public void setSubjectId(Long subjectId) { this.subjectId = subjectId; } + public Integer getSortingIndex() { + return sortingIndex; + } + + public void setSortingIndex(Integer sortingIndex) { + this.sortingIndex = sortingIndex; + } + public Long getCenterId() { return centerId; } 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 58ed3ae54c..e22acc8891 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 @@ -39,6 +39,8 @@ public class ShanoirSolrQuery { private Collection subjectId; + private Collection sortingIndex; + private Collection examinationId; private Collection examinationComment; @@ -336,6 +338,14 @@ public void setSubjectId(Collection subjectId) { this.subjectId = subjectId; } + public Collection getSortingIndex() { + return sortingIndex; + } + + public void setSortingIndex(Collection sortingIndex) { + this.sortingIndex = sortingIndex; + } + public Collection getCenterId() { return centerId; } 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 01f3eb5a19..236344d72d 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 @@ -52,7 +52,8 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "ae.name as acquisitionEquipmentName, " + "su.name as subjectName, " + "sust.subject_type as subjectType, " + - "su.id as subjectId, st.name as studyName, " + + "su.id as subjectId, " + + "st.name as studyName, " + "e.study_id as studyId, " + "c.name as centerName, " + "c.id as centerId, mrp.slice_thickness as sliceThickness, " + @@ -60,6 +61,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "mrp.magnetic_field_strength as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset_acquisition da on da.id = d.dataset_acquisition_id" @@ -91,6 +93,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset_acquisition da on da.id = d.dataset_acquisition_id" @@ -112,7 +115,8 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "ae.name as acquisitionEquipmentName, " + "su.name as subjectName, " + "sust.subject_type as subjectType, " + - "su.id as subjectId, st.name as studyName, " + + "su.id as subjectId, " + + "st.name as studyName, " + "e.study_id as studyId, " + "c.name as centerName, c.id as centerId, " + "null as sliceThickness, " + @@ -120,6 +124,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset_acquisition da on da.id = d.dataset_acquisition_id" @@ -151,6 +156,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset_acquisition da on da.id = d.dataset_acquisition_id" @@ -172,7 +178,8 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "ae.name as acquisitionEquipmentName, " + "su.name as subjectName, " + "sust.subject_type as subjectType, " + - "su.id as subjectId, st.name as studyName, " + + "su.id as subjectId, " + + "st.name as studyName, " + "e.study_id as studyId, " + "c.name as centerName, c.id as centerId, " + "null as sliceThickness, " + @@ -180,6 +187,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset_acquisition da on da.id = d.dataset_acquisition_id" @@ -211,6 +219,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset_acquisition da on da.id = d.dataset_acquisition_id" @@ -242,6 +251,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "proc.processing_date as importDate, " + "proc.username as username, " + + "null as sortingIndex, " + "1 as processed" + " FROM dataset d" + " LEFT JOIN dataset_processing proc ON proc.id = d.dataset_processing_id" @@ -271,6 +281,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset refd ON refd.id = d.referenced_dataset_for_superimposition_id" @@ -297,12 +308,13 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "st.name as studyName, " + "e.study_id as studyId, " + "c.name as centerName, " + - "c.id as centerId, " - + "null as sliceThickness, " + + "c.id as centerId, " + + "null as sliceThickness, " + "null as pixelBandwidth, " + "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset refd ON refd.id = d.referenced_dataset_for_superimposition_id" @@ -335,6 +347,7 @@ public class ShanoirMetadataRepositoryImpl implements ShanoirMetadataRepositoryC "null as magneticFieldStrength, " + "da.import_date as importDate, " + "da.username as username, " + + "da.sorting_index as sortingIndex, " + "0 as processed" + " FROM dataset d" + " LEFT JOIN dataset_acquisition da on da.id = d.dataset_acquisition_id" 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 ab3d99f7ce..30304cb1a2 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 @@ -207,9 +207,10 @@ private ShanoirSolrDocument getShanoirSolrDocument(ShanoirMetadata shanoirMetada return new ShanoirSolrDocument(String.valueOf(shanoirMetadata.getDatasetId()), shanoirMetadata.getDatasetId(), shanoirMetadata.getDatasetName(), shanoirMetadata.getDatasetType(), shanoirMetadata.getDatasetNature(), DateTimeUtils.localDateToDate(shanoirMetadata.getDatasetCreationDate()), shanoirMetadata.getExaminationId(), shanoirMetadata.getExaminationComment(), DateTimeUtils.localDateToDate(shanoirMetadata.getExaminationDate()), shanoirMetadata.getAcquisitionEquipmentName(), - shanoirMetadata.getSubjectName(), SubjectType.getType(shanoirMetadata.getSubjectType()) != null ? SubjectType.getType(shanoirMetadata.getSubjectType()).name() : null, shanoirMetadata.getSubjectId(), shanoirMetadata.getStudyName(), shanoirMetadata.getStudyId(), shanoirMetadata.getCenterName(), + shanoirMetadata.getSubjectName(), SubjectType.getType(shanoirMetadata.getSubjectType()) != null ? SubjectType.getType(shanoirMetadata.getSubjectType()).name() : null, shanoirMetadata.getSubjectId(), + shanoirMetadata.getStudyName(), shanoirMetadata.getStudyId(), shanoirMetadata.getCenterName(), shanoirMetadata.getCenterId(), shanoirMetadata.getSliceThickness(), shanoirMetadata.getPixelBandwidth(), shanoirMetadata.getMagneticFieldStrength(), - shanoirMetadata.isProcessed(), DateTimeUtils.localDateToDate(shanoirMetadata.getImportDate()), shanoirMetadata.getUsername()); + shanoirMetadata.isProcessed(), DateTimeUtils.localDateToDate(shanoirMetadata.getImportDate()), shanoirMetadata.getUsername(), shanoirMetadata.getSortingIndex()); } @Transactional @@ -249,7 +250,7 @@ private Pageable prepareTextFields(Pageable pageable) { || order.getProperty().equals("datasetName") || order.getProperty().equals("datasetNature") || order.getProperty().equals("datasetType") || order.getProperty().equals("examinationComment") || order.getProperty().equals("tags") || order.getProperty().equals("subjectType") || order.getProperty().equals("acquisitionEquipmentName") - || order.getProperty().equals("processed") + || order.getProperty().equals("processed") || order.getProperty().equals("sortingIndex") ) { pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), order.getDirection(), order.getProperty()); 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 10dda38ffb..8c2289c731 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 @@ -67,6 +67,7 @@ public class SolrJWrapperImpl implements SolrJWrapper { private static final String ACQUISITION_EQUIPMENT_FACET = "acquisitionEquipmentName"; private static final String SUBJECT_NAME_FACET = "subjectName"; private static final String SUBJECT_ID_FACET = "subjectId"; + private static final String SORTING_INDEX_FACET = "sortingIndex"; private static final String SUBJECT_TYPE_FACET = "subjectType"; private static final String STUDY_NAME_FACET = "studyName"; private static final String STUDY_ID_FACET = "studyId"; @@ -96,6 +97,7 @@ public class SolrJWrapperImpl implements SolrJWrapper { CENTER_NAME_FACET, STUDY_ID_FACET, SUBJECT_ID_FACET, + SORTING_INDEX_FACET, SUBJECT_TYPE_FACET, CENTER_ID_FACET, SLICE_THICKNESS_FACET, @@ -406,6 +408,7 @@ private SolrResultPage buildShanoirSolrPage(QueryResponse r solrDoc.setAcquisitionEquipmentName((String) document.getFirstValue("acquisitionEquipmentName")); solrDoc.setSubjectName((String) document.getFirstValue("subjectName")); solrDoc.setSubjectId((Long) document.getFirstValue("subjectId")); + solrDoc.setSortingIndex( (Integer) document.getFirstValue("sortingIndex")); if (document.getFieldValues("tags") != null) { solrDoc.setTags(document.getFieldValues("tags").stream() .map(object -> Objects.toString(object, null)) diff --git a/shanoir-ng-front/src/app/solr/solr.document.model.ts b/shanoir-ng-front/src/app/solr/solr.document.model.ts index 1b8cf5448a..c35ef752da 100644 --- a/shanoir-ng-front/src/app/solr/solr.document.model.ts +++ b/shanoir-ng-front/src/app/solr/solr.document.model.ts @@ -32,6 +32,8 @@ export class SolrDocument { subjectType: string; acquisitionEquipmentName: string; subjectId: string; + + sortingIndex: number; studyName: string; studyId: string; id: number; // only for the table component.. @@ -44,6 +46,7 @@ export class SolrRequest { studyId: string[]; subjectName: string[]; subjectId: string[]; + sortingIndex: number[]; subjectType: string[]; acquisitionEquipmentName: string[]; examinationId: string[]; diff --git a/shanoir-ng-front/src/app/solr/solr.search.component.ts b/shanoir-ng-front/src/app/solr/solr.search.component.ts index 4f023ca365..60ee20e94d 100644 --- a/shanoir-ng-front/src/app/solr/solr.search.component.ts +++ b/shanoir-ng-front/src/app/solr/solr.search.component.ts @@ -461,6 +461,7 @@ export class SolrSearchComponent implements AfterViewChecked, AfterContentInit { {headerName: "Type", field: "datasetType"}, {headerName: "Nature", field: "datasetNature"}, {headerName: "Series date", field: "datasetCreationDate", type: "date", hidden: true}, + {headerName: "Sorting index", field: "sortingIndex"}, {headerName: "Study", field: "studyName", route: function(item) { return item.studyId ? '/study/details/' + item.studyId : null; diff --git a/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts b/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts index eaee95a055..39e4d24d28 100644 --- a/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts +++ b/shanoir-ng-front/src/app/solr/text-search/solr.text-search.component.ts @@ -35,7 +35,7 @@ export class SolrTextSearchComponent implements ControlValueAccessor { showInfo: boolean = false; searchText: string = ""; - searchKeyWords: string[] = ["centerName", "datasetCreationDate", "studyName", "subjectName", "subjectType", "acquisitionEquipmentName", "datasetId", "datasetName", "datasetNature", "datasetType", "processed", "examinationComment", "examinationDate", "importDate", "tags", "magneticFieldStrength", "pixelBandwidth", "sliceThickness", "studyId"]; + searchKeyWords: string[] = ["centerName", "datasetCreationDate", "studyName", "subjectName", "subjectType", "acquisitionEquipmentName", "datasetId", "datasetName", "datasetNature", "datasetType", "processed", "examinationComment", "examinationDate", "importDate", "tags", "magneticFieldStrength", "pixelBandwidth", "sliceThickness", "studyId", "sortingIndex"]; @Output() onChange: EventEmitter = new EventEmitter(); @Output() onType: EventEmitter = new EventEmitter(); @Output() expertModeChange: EventEmitter = new EventEmitter();