From 532cc638daa3eb786d19b3a2ac149d1f8203415b Mon Sep 17 00:00:00 2001 From: Jim Balhoff Date: Mon, 29 Jul 2024 14:17:13 -0400 Subject: [PATCH] Add conforms-to-gpad to model search results. --- .../server/handler/ModelSearchHandler.java | 25 ++++++++++++++++--- .../resources/ModelSearchQueryTemplate.rq | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/minerva-server/src/main/java/org/geneontology/minerva/server/handler/ModelSearchHandler.java b/minerva-server/src/main/java/org/geneontology/minerva/server/handler/ModelSearchHandler.java index 615e0da2..b578a726 100644 --- a/minerva-server/src/main/java/org/geneontology/minerva/server/handler/ModelSearchHandler.java +++ b/minerva-server/src/main/java/org/geneontology/minerva/server/handler/ModelSearchHandler.java @@ -10,6 +10,7 @@ import org.openrdf.repository.RepositoryException; import org.semanticweb.owlapi.model.IRI; +import javax.annotation.Nullable; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.io.IOException; @@ -89,6 +90,8 @@ static public class ModelMeta { private String date; private String title; private String state; + @SerializedName("conforms-to-gpad") + private Boolean conformsToGPAD; private Set contributors; private Set groups; private HashMap> query_match; @@ -96,11 +99,12 @@ static public class ModelMeta { @SerializedName("modified-p") private boolean modified; - public ModelMeta(String id, String date, String title, String state, Set contributors, Set groups, boolean modified) { + public ModelMeta(String id, String date, String title, String state, @Nullable Boolean conformsToGPAD, Set contributors, Set groups, boolean modified) { this.id = id; this.date = date; this.title = title; this.state = state; + this.conformsToGPAD = conformsToGPAD; this.contributors = contributors; this.groups = groups; this.modified = modified; @@ -150,6 +154,15 @@ public void setState(String state) { this.state = state; } + @Nullable + public Boolean getConformsToGPAD() { + return this.conformsToGPAD; + } + + public void setConformsToGPAD(Boolean conforms) { + this.conformsToGPAD = conforms; + } + public Set getContributors() { return contributors; } @@ -454,7 +467,7 @@ public ModelSearchResult search(Set taxa, String group_by_constraint = "GROUP BY ?id"; //default return block //TODO investigate need to add DISTINCT to GROUP_CONCAT here - String return_block = "?id (MIN(?date) AS ?mindate) (MIN(?title) AS ?mintitle) (MIN(?state) AS ?minstate) (GROUP_CONCAT(DISTINCT ?contributor;separator=\";\") AS ?contributors) (GROUP_CONCAT(DISTINCT ?group;separator=\";\") AS ?groups)"; + String return_block = "?id (MIN(?date) AS ?mindate) (MIN(?title) AS ?mintitle) (MIN(?state) AS ?minstate) (MIN(?conformsToGPAD) AS ?minConformsToGPAD) (GROUP_CONCAT(DISTINCT ?contributor;separator=\";\") AS ?contributors) (GROUP_CONCAT(DISTINCT ?group;separator=\";\") AS ?groups)"; if (count != null) { return_block = "(count(distinct ?id) as ?count)"; limit_constraint = ""; @@ -525,6 +538,12 @@ public ModelSearchResult search(Set taxa, if (state_binding != null) { state = state_binding.getValue().stringValue(); } + Binding conformanceBinding = bs.getBinding("minConformsToGPAD"); + Boolean conformance = null; + if (conformanceBinding != null) { + System.out.println("CONFORMANCE: " + conformanceBinding.getValue().stringValue()); + conformance = Boolean.valueOf(conformanceBinding.getValue().stringValue()); + } Binding group_binding = bs.getBinding("groups"); String groups_ = ""; if (group_binding != null) { @@ -539,7 +558,7 @@ public ModelSearchResult search(Set taxa, if (mm == null) { //look up model in in-memory cache to check edit state boolean is_modified = m3.isModelModified(model_iri); - mm = new ModelMeta(model_curie, date, title, state, contributors, groups, is_modified); + mm = new ModelMeta(model_curie, date, title, state, conformance, contributors, groups, is_modified); } //matching for (String ind : ind_return.keySet()) { diff --git a/minerva-server/src/main/resources/ModelSearchQueryTemplate.rq b/minerva-server/src/main/resources/ModelSearchQueryTemplate.rq index 6521f41e..aa48b64e 100644 --- a/minerva-server/src/main/resources/ModelSearchQueryTemplate.rq +++ b/minerva-server/src/main/resources/ModelSearchQueryTemplate.rq @@ -21,6 +21,7 @@ GRAPH ?id { ?contributor ; optional{?id ?group } . optional{?id lego:modelstate ?state } . +optional{?id lego:conforms_to_gpad ?conformsToGPAD}