Skip to content

Commit

Permalink
start sorting feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cmpich committed Mar 4, 2024
1 parent 5549455 commit 63b9a5d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,23 @@ public JsonResultResponse<GeneDiseaseAnnotationDocument> getDiseaseAnnotationsWi
bool2.should(new MatchQueryBuilder("parentSlimIDs.keyword", diseaseID));

// create histogram of select columns of unfiltered query

addTableFilter(pagination, bool);
LinkedHashMap <String, SortOrder> sortingMap = new LinkedHashMap<>();
sortingMap.put("phylogeneticSortingIndex", SortOrder.ASC);

// Sorting sets for different names of the sorting selection box
Map<String, List<String>> sortingSetMap = new HashMap<>();
sortingSetMap.put("default", List.of("phylogeneticSortingIndex",
"subject.geneSymbol.displayText.keyword"));
sortingSetMap.put("gene", List.of("subject.geneSymbol.displayText.keyword", "phylogeneticSortingIndex"));
sortingSetMap.put("disease", List.of("object.name.keyword", "phylogeneticSortingIndex","subject.geneSymbol.displayText.keyword"));
sortingSetMap.put("species", List.of("subject.taxon.name.keyword", "subject.geneSymbol.displayText.keyword"));

LinkedHashMap<String, SortOrder> sortingMap = new LinkedHashMap<>();

List<String> sortFields = sortingSetMap.get(pagination.getSortBy());
if (sortFields == null) {
sortFields = sortingSetMap.get("default");
}
sortFields.forEach(sortField -> sortingMap.put(sortField, SortOrder.ASC));

SearchResponse searchResponse = getSearchResponse(bool, pagination, sortingMap, debug);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ private List<GeneDiseaseAnnotationDocument> createGeneDiseaseAnnotationViaOrthol
stringListMap.forEach((basedOnGenesList, diseaseAnnotations1) -> {
DiseaseAnnotation diseaseAnnotation = diseaseAnnotations1.get(0);
GeneDiseaseAnnotationDocument gdad = new GeneDiseaseAnnotationDocument();
gdad.setViaOrthologyAnnotation(true);
gdad.setSubject(gene);
gdad.setRelation(associationType);
String generatedRelationString = getGeneratedRelationString(gdad.getRelation().getName(), diseaseAnnotation.getNegated());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<GeneDiseaseAnnotation> getFiltered() {
params.put("internal", false);
params.put("obsolete", false);
//params.put("subject.curie", "MGI:2140175");
// params.put("subject.curie", "HGNC:6893");
//params.put("subject.curie", "HGNC:13625");
// params.put("subject.curie", "HGNC:40");

do {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.alliancegenome.api.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonView;
import lombok.Data;
Expand All @@ -18,4 +20,26 @@ public class GeneDiseaseAnnotationDocument extends DiseaseAnnotationDocument {
public GeneDiseaseAnnotationDocument() {
setCategory("gene_disease_annotation");
}

// 1 true
// 0 false
@JsonIgnore
private boolean isViaOrthologyAnnotation;

@JsonView({View.DiseaseAnnotationAll.class})
@JsonProperty("viaOrthologyOrder")
public int getViaOrthologyOrder() {
return isViaOrthologyAnnotation ? 1 : 0;
}

@JsonView({View.DiseaseAnnotationAll.class})
@JsonProperty("viaOrthologyOrder")
public void setViaOrthologyOrder(int order) {
isViaOrthologyAnnotation = order == 1;
}

@Override
public String toString() {
return subject.getCurie() + " | " + getRelation().getName() + " | " + getObject().getCurie();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ protected void buildSharedSearchableDocumentMappings() throws IOException {
new FieldBuilder(builder, "soTermName", "text").keyword().letterText().build();
new FieldBuilder(builder, "soTermId", "keyword").build();
new FieldBuilder(builder, "species", "text").keyword().synonym().sort().build();

new FieldBuilder(builder, "displayText", "text").keyword().sort().build();

// speciesOrder will generate properly and it will be of type: long

// new FieldBuilder(builder, "stage", "text").keyword().build();
Expand Down

0 comments on commit 63b9a5d

Please sign in to comment.