Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shanoir-issue#2471: add sorting_index to search #2515

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE shanoir_metadata ADD COLUMN sorting_index int(11);
1 change: 1 addition & 0 deletions docker-compose/solr/core/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@
<field name="studyName" type="lowercase"/>
<field name="subjectName" type="lowercase"/>
<field name="subjectId" type="plong"/>
<field name="sortingIndex" type="pint"/>
<field name="subjectType" type="lowercase"/>
<field name="tags" type="strings"/>
<field name="processed" type="boolean" indexed="true" stored="true" required="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

Expand Down Expand Up @@ -93,6 +93,8 @@ public class ShanoirMetadata {

private Long subjectId;

private Integer sortingIndex;

private boolean processed;

@LocalDateAnnotations
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public class ShanoirSolrDocument {
@Field
private Long subjectId;

@Field
private Integer sortingIndex;

@Field
private String studyName;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class ShanoirSolrQuery {

private Collection<Long> subjectId;

private Collection<Integer> sortingIndex;

private Collection<Long> examinationId;

private Collection<String> examinationComment;
Expand Down Expand Up @@ -336,6 +338,14 @@ public void setSubjectId(Collection<Long> subjectId) {
this.subjectId = subjectId;
}

public Collection<Integer> getSortingIndex() {
return sortingIndex;
}

public void setSortingIndex(Collection<Integer> sortingIndex) {
this.sortingIndex = sortingIndex;
}

public Collection<Long> getCenterId() {
return centerId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ 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, " +
"mrp.pixel_bandwidth as pixelBandwidth, " +
"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"
Expand Down Expand Up @@ -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"
Expand All @@ -112,14 +115,16 @@ 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, " +
"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_acquisition da on da.id = d.dataset_acquisition_id"
Expand Down Expand Up @@ -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"
Expand All @@ -172,14 +178,16 @@ 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, " +
"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_acquisition da on da.id = d.dataset_acquisition_id"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -406,6 +408,7 @@ private SolrResultPage<ShanoirSolrDocument> 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))
Expand Down
3 changes: 3 additions & 0 deletions shanoir-ng-front/src/app/solr/solr.document.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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..
Expand All @@ -44,6 +46,7 @@ export class SolrRequest {
studyId: string[];
subjectName: string[];
subjectId: string[];
sortingIndex: number[];
subjectType: string[];
acquisitionEquipmentName: string[];
examinationId: string[];
Expand Down
1 change: 1 addition & 0 deletions shanoir-ng-front/src/app/solr/solr.search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> = new EventEmitter();
@Output() onType: EventEmitter<void> = new EventEmitter();
@Output() expertModeChange: EventEmitter<boolean> = new EventEmitter();
Expand Down