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

Merge dev into stable #804

Merged
merged 35 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f0da38d
Renamed base_uri to baseUri and ensured it is an array.
henrietteharmse Oct 4, 2024
8814713
Definition is now using DefinedFields and is of type array.
henrietteharmse Oct 7, 2024
837a4ce
DefinedBy is now using DefinedFields.
henrietteharmse Oct 7, 2024
3dff062
AppearsIn is now using DefinedFields.
henrietteharmse Oct 7, 2024
57b4561
DirectAncestor is now using DefinedFields and is an array.
henrietteharmse Oct 7, 2024
d3dba46
DirectParent is now using DefinedFields and is an array.
henrietteharmse Oct 7, 2024
3e60d05
ImportsFrom and exportsTo are now using DefinedFields.
henrietteharmse Oct 8, 2024
ff9b824
Renamed hasPreferredRoots to preferredRoot. Is now using DefinedField…
henrietteharmse Oct 8, 2024
5379b2c
hierarchicalParent and hierarchicalAncestor are now arrays and Define…
henrietteharmse Oct 21, 2024
e5ecfbf
Label is now an array and a DefinedField.
henrietteharmse Oct 22, 2024
98578da
Language is now an array and a DefinedField.
henrietteharmse Oct 22, 2024
270b92b
relatedTo and relatedFrom are now arrays and DefinedFields. Cleaned u…
henrietteharmse Oct 24, 2024
c89233e
synonym is now an array and DefinedField.
henrietteharmse Oct 24, 2024
6d5949e
Merge branch 'dev' of github.com:EBISPOT/ols4 into v2-api-inconsisten…
henrietteharmse Oct 24, 2024
1b0a67d
Merged with dev.
henrietteharmse Oct 24, 2024
be73bab
Improved error message.
henrietteharmse Oct 25, 2024
a1e956d
Fixed type issues.
henrietteharmse Oct 28, 2024
1621775
Added fobi.
henrietteharmse Oct 28, 2024
f5c8976
Update cardinality handling
haideriqbal Oct 28, 2024
b2f8b1f
Update HRA and CCF ontology information
bherr2 Oct 29, 2024
05b6297
Update handling of data properties and oneOf
haideriqbal Nov 4, 2024
3783d98
Merge pull request #780 from bherr2/patch-1
jamesamcl Nov 4, 2024
3e2c9de
Added BaseUri test.
henrietteharmse Nov 5, 2024
987d91f
Merged again with dev
henrietteharmse Nov 5, 2024
7fdbe90
Fixed definedBy issue and made oio available locally.
henrietteharmse Nov 6, 2024
d028624
Fixed baseUri issue.
henrietteharmse Nov 6, 2024
b90e5fb
TESTCASES updated
henrietteharmse Nov 8, 2024
a80c979
Updated README wrt testing.
henrietteharmse Nov 8, 2024
cdc3842
API TESTS updated
henrietteharmse Nov 8, 2024
893de15
Update exact synonym on frontend
haideriqbal Nov 11, 2024
3d7c3eb
Update synonym display on frontend
haideriqbal Nov 11, 2024
7d22f87
Simplify code logic
haideriqbal Nov 11, 2024
b85e4c1
Merge pull request #796 from EBISPOT/fix-exact-synonym-issue
haideriqbal Nov 12, 2024
da4c9f8
Merge pull request #778 from EBISPOT/fix-cardinality-issue
haideriqbal Nov 12, 2024
27a4cbf
Merge pull request #795 from EBISPOT/v2-api-inconsistencies-arrays-ap…
henrietteharmse Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ new expected output:

git add -A testcases_expected_output

8. Commit the updates to testcases to a branch with suffix `-testcases`.
8. Commit the updates to testcases to a branch with suffix `-testcases` and message "TESTCASES updated".
9. Now continue with API testing.

### Testing API
Expand Down Expand Up @@ -440,7 +440,7 @@ the old `testcases_expected_output_api` and replace with new expected output:

git add -A testcases_expected_output_api

16. Commit the API tests to a branch with suffix `-api-tests`.
16. Commit the API tests to a branch with suffix `-api-tests` and message "API-TESTS updated".

17. You can stop the OLS4 backend with "Ctrl-C", and Solr and Neo4J with:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.List;
import java.util.stream.Collectors;

import static uk.ac.ebi.ols.shared.DefinedFields.*;

public class SolrFieldMapper {

// Maps OLS3 field names to the OLS4 schema
Expand Down Expand Up @@ -36,23 +38,23 @@ public static List<String> mapFieldsList(Collection<String> ols3FieldNames) {
continue;
}

if (legacyFieldName.equals("label")) {
newFields.add(prefix + "label" + suffix);
if (legacyFieldName.equals(LABEL.getText())) {
newFields.add(prefix + LABEL.getText() + suffix);
continue;
}

if (legacyFieldName.equals("synonym")) {
newFields.add(prefix + "synonym" + suffix);
if (legacyFieldName.equals(SYNONYM.getText())) {
newFields.add(prefix + SYNONYM.getText() + suffix);
continue;
}

if (legacyFieldName.equals("definition")) {
newFields.add(prefix + "definition" + suffix);
if (legacyFieldName.equals(DEFINITION.getText())) {
newFields.add(prefix + DEFINITION.getText() + suffix);
continue;
}

if (legacyFieldName.equals("description")) {
newFields.add(prefix + "definition" + suffix);
if (legacyFieldName.equals(DEFINITION.getOls3Text())) {
newFields.add(prefix + DEFINITION.getText() + suffix);
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.web.util.UriUtils;
import uk.ac.ebi.spot.ols.model.v1.V1Related;
import uk.ac.ebi.spot.ols.model.v1.V1Term;
import static uk.ac.ebi.ols.shared.DefinedFields.*;

import java.util.Collection;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void search(
solrQuery.set("defType", "edismax");
solrQuery.setQuery(query.toLowerCase());
// Specify the query fields with boosting
String[] fields = {"label_s^5", "synonym_s^3", "short_form_s^2", "obo_id_s^2", "iri_s", "annotations_trimmed"};
String[] fields = {LABEL.getText()+"_s^5", SYNONYM.getText()+"_s^3", "short_form_s^2", "obo_id_s^2", "iri_s", "annotations_trimmed"};
solrQuery.set("qf", String.join(" ", SolrFieldMapper.mapFieldsList(List.of(fields))));
// Boost exact phrase matches in label and synonym fields
solrQuery.set("pf", "lowercase_label^10 lowercase_synonym^5");
Expand All @@ -142,7 +142,7 @@ public void search(
solrQuery.set("defType", "edismax");
solrQuery.setQuery(query);

String[] fields = {"label^5", "synonym^3", "definition", "short_form^2", "obo_id^2", "iri", "annotations_trimmed"};
String[] fields = {LABEL.getText()+"^5", SYNONYM.getText()+"^3", DEFINITION.getText(), "short_form^2", "obo_id^2", "iri", "annotations_trimmed"};

solrQuery.set("qf", String.join(" ", SolrFieldMapper.mapFieldsList(List.of(fields))));

Expand Down Expand Up @@ -206,9 +206,10 @@ public void search(
.collect(Collectors.joining(" OR "));

if (inclusive) {
solrQuery.addFilterQuery("filter( iri: (" + result + ")) filter(hierarchicalAncestor: (" + result + "))");
solrQuery.addFilterQuery("filter( iri: (" + result + ")) filter(" + HIERARCHICAL_ANCESTOR.getText()+
": (" + result + "))");
} else {
solrQuery.addFilterQuery("hierarchicalAncestor: (" + result + ")");
solrQuery.addFilterQuery(HIERARCHICAL_ANCESTOR.getText() + ": (" + result + ")");
}

}
Expand All @@ -219,9 +220,10 @@ public void search(
.collect(Collectors.joining(" OR "));

if (inclusive) {
solrQuery.addFilterQuery("filter( iri: (" + result + ")) filter(hierarchicalAncestor: (" + result + "))");
solrQuery.addFilterQuery("filter( iri: (" + result + ")) filter("+ HIERARCHICAL_ANCESTOR.getText()+
": (" + result + "))");
} else {
solrQuery.addFilterQuery("hierarchicalAncestor: (" + result + ")");
solrQuery.addFilterQuery(HIERARCHICAL_ANCESTOR.getText()+": (" + result + ")");
}
}

Expand Down Expand Up @@ -281,8 +283,8 @@ public void search(
fieldList.add("id");
fieldList.add("iri");
fieldList.add("ontology_name");
fieldList.add("label");
fieldList.add("description");
fieldList.add(LABEL.getText());
fieldList.add(DEFINITION.getOls3Text());
fieldList.add("short_form");
fieldList.add("obo_id");
fieldList.add("type");
Expand All @@ -292,13 +294,14 @@ public void search(
if (fieldList.contains("id")) outDoc.put("id", JsonHelper.getString(json, "id"));
if (fieldList.contains("iri")) outDoc.put("iri", JsonHelper.getString(json, "iri"));
if (fieldList.contains("ontology_name")) outDoc.put("ontology_name", JsonHelper.getString(json, "ontologyId"));
if (fieldList.contains("label")) {
var label = outDoc.put("label", JsonHelper.getString(json, "label"));
if (fieldList.contains(LABEL.getText())) {
var label = outDoc.put(LABEL.getText(), JsonHelper.getString(json, LABEL.getText()));
if(label!=null) {
outDoc.put("label", label);
outDoc.put(LABEL.getText(), label);
}
}
if (fieldList.contains("description")) outDoc.put("description", JsonHelper.getStrings(json, "definition"));
if (fieldList.contains(DEFINITION.getOls3Text())) outDoc.put(DEFINITION.getOls3Text(),
JsonHelper.getStrings(json, DEFINITION.getText()));
if (fieldList.contains("short_form")) outDoc.put("short_form", JsonHelper.getString(json, "shortForm"));
if (fieldList.contains("obo_id")) outDoc.put("obo_id", JsonHelper.getString(json, "curie"));
if (fieldList.contains(IS_DEFINING_ONTOLOGY.getOls3Text())) outDoc.put(IS_DEFINING_ONTOLOGY.getOls3Text(),
Expand All @@ -307,7 +310,7 @@ public void search(
if (fieldList.contains("type")) {
outDoc.put("type", JsonHelper.getType(json, "type"));
}
if (fieldList.contains("synonym")) outDoc.put("synonym", JsonHelper.getStrings(json, "synonym"));
if (fieldList.contains(SYNONYM.getText())) outDoc.put(SYNONYM.getText(), JsonHelper.getStrings(json, SYNONYM.getText()));
if (fieldList.contains("ontology_prefix")) outDoc.put("ontology_prefix", JsonHelper.getString(json, "ontologyPreferredPrefix"));
if (fieldList.contains("subset")) outDoc.put("subset", JsonHelper.getStrings(json, "http://www.geneontology.org/formats/oboInOwl#inSubset"));
if (fieldList.contains("ontology_iri")) outDoc.put("ontology_iri", JsonHelper.getStrings(json, "ontologyIri").get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void select(
}
solrQuery.setQuery(query);
solrQuery.set("defType", "edismax");
solrQuery.set("qf", "label whitespace_edge_label synonym whitespace_edge_synonym shortForm whitespace_edge_shortForm curie iri");
solrQuery.set("qf", LABEL.getText()+" whitespace_edge_label synonym whitespace_edge_synonym shortForm whitespace_edge_shortForm curie iri");
solrQuery.set("bq", "type:ontology^10.0 " +
IS_DEFINING_ONTOLOGY.getText() +":true^100.0 str_label:\"" + queryLc + "\"^1000 edge_label:\"" +
queryLc + "\"^500 str_synonym:\"" + queryLc + "\" edge_synonym:\"" + queryLc + "\"^100");
Expand Down Expand Up @@ -129,14 +129,14 @@ public void select(
String result = childrenOf.stream()
.map(addQuotes)
.collect(Collectors.joining(" OR "));
solrQuery.addFilterQuery("directAncestor: (" + result + ")");
solrQuery.addFilterQuery(DIRECT_ANCESTOR.getText() + ": (" + result + ")");
}

if (allChildrenOf != null) {
String result = allChildrenOf.stream()
.map(addQuotes)
.collect(Collectors.joining(" OR "));
solrQuery.addFilterQuery("hierarchicalAncestor: (" + result + ")");
solrQuery.addFilterQuery(HIERARCHICAL_ANCESTOR.getText() + ": (" + result + ")");
}

solrQuery.addFilterQuery(IS_OBSOLETE.getText() + ":" + queryObsoletes);
Expand All @@ -146,9 +146,9 @@ public void select(
solrQuery.add("hl.simple.pre", "<b>");
solrQuery.add("hl.simple.post", "</b>");
solrQuery.addHighlightField("whitespace_edge_label");
solrQuery.addHighlightField("label");
solrQuery.addHighlightField(LABEL.getText());
solrQuery.addHighlightField("whitespace_edge_synonym");
solrQuery.addHighlightField("synonym");
solrQuery.addHighlightField(SYNONYM.getText());

logger.debug("select: ()", solrQuery.toQueryString());

Expand All @@ -175,10 +175,10 @@ public void select(
fieldList.add("iri");
fieldList.add("short_form");
fieldList.add("obo_id");
fieldList.add("label");
fieldList.add(LABEL.getText());
fieldList.add("ontology_name");
fieldList.add("ontology_prefix");
fieldList.add("description");
fieldList.add(DEFINITION.getOls3Text());
fieldList.add("type");
}

Expand All @@ -187,8 +187,9 @@ public void select(
if (fieldList.contains("id")) outDoc.put("id", res.get("id").toString().replace('+', ':'));
if (fieldList.contains("iri")) outDoc.put("iri", JsonHelper.getString(json, "iri"));
if (fieldList.contains("ontology_name")) outDoc.put("ontology_name", JsonHelper.getString(json, "ontologyId"));
if (fieldList.contains("label")) outDoc.put("label", JsonHelper.getString(json, "label"));
if (fieldList.contains("description")) outDoc.put("description", JsonHelper.getStrings(json, "definition"));
if (fieldList.contains(LABEL.getText())) outDoc.put(LABEL.getText(), JsonHelper.getString(json, LABEL.getText()));
if (fieldList.contains(DEFINITION.getOls3Text())) outDoc.put(DEFINITION.getOls3Text(),
JsonHelper.getStrings(json, DEFINITION.getText()));
if (fieldList.contains("short_form")) outDoc.put("short_form", JsonHelper.getString(json, "shortForm"));
if (fieldList.contains("obo_id")) outDoc.put("obo_id", JsonHelper.getString(json, "curie"));
if (fieldList.contains(IS_DEFINING_ONTOLOGY.getOls3Text())) outDoc.put(IS_DEFINING_ONTOLOGY.getOls3Text(),
Expand All @@ -197,7 +198,7 @@ public void select(
if (fieldList.contains("type")) {
outDoc.put("type", JsonHelper.getType(json, "type"));
}
if (fieldList.contains("synonym")) outDoc.put("synonym", JsonHelper.getStrings(json, "synonym"));
if (fieldList.contains(SYNONYM.getText())) outDoc.put(SYNONYM.getText(), JsonHelper.getStrings(json, SYNONYM.getText()));
if (fieldList.contains("ontology_prefix")) outDoc.put("ontology_prefix", JsonHelper.getString(json, "ontologyPreferredPrefix"));

docs.add(outDoc);
Expand Down Expand Up @@ -228,9 +229,9 @@ public void select(
Map<String,Object> resHighlight = new LinkedHashMap<>();
for(var fieldName : highlight.keySet()) {
if(fieldName.equals("whitespace_edge_label")) {
resHighlight.put("label_autosuggest", highlight.get(fieldName));
resHighlight.put(LABEL.getText()+"_autosuggest", highlight.get(fieldName));
} else if(fieldName.equals("whitespace_edge_synonym")) {
resHighlight.put("synonym_autosuggest", highlight.get(fieldName));
resHighlight.put(SYNONYM.getText()+"_autosuggest", highlight.get(fieldName));
} else {
resHighlight.put(fieldName, highlight.get(fieldName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.nio.charset.StandardCharsets;
import java.util.*;

import static uk.ac.ebi.ols.shared.DefinedFields.*;

@Tag(name = "Suggest Controller")
@RestController
public class V1SuggestController {
Expand Down Expand Up @@ -55,9 +57,9 @@ public void suggest(

solrQuery.setQuery(query);
solrQuery.set("defType", "edismax");
solrQuery.set("qf", "label^10 edge_label^2 whitespace_edge_label^1");
solrQuery.set("qf", LABEL.getText()+"^10 edge_label^2 whitespace_edge_label^1");
solrQuery.set("wt", "json");
solrQuery.setFields("label");
solrQuery.setFields(LABEL.getText());

solrQuery.setSort("score", SolrQuery.ORDER.desc);

Expand All @@ -73,7 +75,7 @@ public void suggest(
solrQuery.setStart(start);
solrQuery.setRows(rows);
solrQuery.add("group", "true");
solrQuery.add("group.field", "label");
solrQuery.add("group.field", LABEL.getText());
solrQuery.add("group.main", "true");


Expand All @@ -90,7 +92,7 @@ public void suggest(
for(SolrDocument res : qr.getResults()) {
Map<String,Object> outDoc = new HashMap<>();

outDoc.put("autosuggest", res.get("label"));
outDoc.put("autosuggest", res.get(LABEL.getText()));

docs.add(outDoc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void createJsTreeEntries(List<Map<String,Object>> jstree, JsonObject ent
}

jstreeEntry.put("iri", entityIri);
jstreeEntry.put("text", JsonHelper.getString(entity, "label"));
jstreeEntry.put("text", JsonHelper.getString(entity, LABEL.getText()));

Collection<String> childIris = entityIriToChildIris.get(entityIri);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ List<Map<String,Object>> buildJsTree() {
jstreeEntry.put("id", base64Encode(thisEntityJsTreeIdDecoded + ";" + child.getAsJsonObject().get("iri").getAsString()));
jstreeEntry.put("parent", base64Encode(thisEntityJsTreeIdDecoded));
jstreeEntry.put("iri", JsonHelper.getString(child.getAsJsonObject(), "iri"));
jstreeEntry.put("text", JsonHelper.getString(child.getAsJsonObject(), "label"));
jstreeEntry.put("text", JsonHelper.getString(child.getAsJsonObject(), LABEL.getText()));
jstreeEntry.put("state", Map.of("opened", false));
jstreeEntry.put("children",
JsonHelper.getString(child.getAsJsonObject(), HAS_DIRECT_CHILDREN.getText()).equals("true")
|| JsonHelper.getString(child.getAsJsonObject(), "hasHierarchicalChildren").equals("true")
|| JsonHelper.getString(child.getAsJsonObject(), HAS_HIERARCHICAL_CHILDREN.getText()).equals("true")
);

Map<String,Object> attrObj = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import uk.ac.ebi.spot.ols.repository.transforms.RemoveLiteralDatatypesTransform;
import uk.ac.ebi.spot.ols.service.Neo4jClient;

import static uk.ac.ebi.ols.shared.DefinedFields.*;

import java.util.*;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -76,13 +78,13 @@ private Map<String, Object> getGraphForEntity(String iri, String type, String ne
for(String referencedIri : linkedEntities.keySet()) {
JsonObject reference = linkedEntities.getAsJsonObject(referencedIri);
if(!iriToLabel.containsKey(referencedIri))
iriToLabel.put(referencedIri, JsonHelper.getString(reference, "label"));
iriToLabel.put(referencedIri, JsonHelper.getString(reference, LABEL.getText()));
}
}

Map<String, Object> nodeRes = new LinkedHashMap<>();
nodeRes.put("iri", JsonHelper.getString(ontologyNodeObject, "iri"));
nodeRes.put("label", JsonHelper.getString(ontologyNodeObject, "label"));
nodeRes.put(LABEL.getText(), JsonHelper.getString(ontologyNodeObject, LABEL.getText()));
return nodeRes;

}).collect(Collectors.toList());
Expand All @@ -107,7 +109,7 @@ private Map<String, Object> getGraphForEntity(String iri, String type, String ne
if(propertyLabel == null)
propertyLabel = "is a";

edgeRes.put("label", propertyLabel);
edgeRes.put(LABEL.getText(), propertyLabel);
edgeRes.put("uri", uri);

return edgeRes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import uk.ac.ebi.spot.ols.repository.neo4j.OlsNeo4jClient;
import uk.ac.ebi.spot.ols.repository.transforms.LocalizationTransform;

import static uk.ac.ebi.ols.shared.DefinedFields.*;

import java.util.*;
import java.util.stream.Collectors;

Expand All @@ -30,7 +32,7 @@ public List<Map<String,Object>> getJsTreeForIndividual(String iri, String ontolo

private List<Map<String,Object>> getJsTreeForEntity(String iri, String type, String neo4jType, String ontologyId, String lang) {

List<String> parentRelationIRIs = List.of("directParent");
List<String> parentRelationIRIs = List.of(DIRECT_PARENT.getText());

String thisEntityId = ontologyId + "+" + type + "+" + iri;

Expand Down Expand Up @@ -59,7 +61,7 @@ public List<Map<String,Object>> getJsTreeChildrenForIndividual(String individual

private List<Map<String,Object>> getJsTreeChildrenForEntity(String iri, String jstreeId, String type, String neo4jType, String ontologyId, String lang) {

List<String> parentRelationIRIs = List.of("directParent");
List<String> parentRelationIRIs = List.of(DIRECT_PARENT.getText());

String thisEntityId = ontologyId + "+" + type + "+" + iri;

Expand Down
Loading
Loading