Skip to content

Commit

Permalink
api updates for schema changes and some ui tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesamcl committed Jun 9, 2024
1 parent 6fa2411 commit d32700a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 17 deletions.
6 changes: 5 additions & 1 deletion grebi_api/src/main/java/uk/ac/ebi/grebi/GrebiApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void main(String[] args) throws ParseException, org.apache.commons
ctx.result("{}");

var q = new GrebiSolrQuery();
q.addFilter("grebi:nodeId", List.of(ctx.pathParam("nodeId")), SearchType.WHOLE_FIELD);
q.addFilter("grebi__nodeId", List.of(ctx.pathParam("nodeId")), SearchType.WHOLE_FIELD);

var res = solr.getFirstNode(q);

Expand All @@ -67,7 +67,11 @@ public static void main(String[] args) throws ParseException, org.apache.commons
q.setSearchText(ctx.queryParam("q"));
q.setExactMatch(false);
q.addSearchField("id", 1000, SearchType.WHOLE_FIELD);
q.addSearchField("grebi__synonym", 900, SearchType.WHOLE_FIELD);
q.addSearchField("id", 500, SearchType.CASE_INSENSITIVE_TOKENS);
q.addSearchField("grebi__synonym", 450, SearchType.CASE_INSENSITIVE_TOKENS);
q.addSearchField("grebi__description", 400, SearchType.WHOLE_FIELD);
q.addSearchField("grebi__description", 250, SearchType.CASE_INSENSITIVE_TOKENS);
q.addSearchField("_text_", 1, SearchType.CASE_INSENSITIVE_TOKENS);
for(var param : ctx.queryParamMap().entrySet()) {
if(param.getKey().equals("q") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public Map<String, Map<String,JsonElement>> resolve(Collection<String> ids) {
HttpPost request = new HttpPost(resolverHost + "/resolve");
request.setEntity(new StringEntity(gson.toJson(ids), ContentType.APPLICATION_JSON));

// System.out.println("calling resolver at " + resolverHost + "/resolve" + " with " + gson.toJson(ids));

try {
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
Expand All @@ -51,6 +53,7 @@ public Map<String, Map<String,JsonElement>> resolve(Collection<String> ids) {
System.out.println("Resolved " + ids.size() + " ids in " + timer.stop().toString());

String json = EntityUtils.toString(entity);
// System.out.println("response was " + json);
return gson.fromJson(json, Map.class);
} else {
// Handle empty response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Map<String,JsonElement> getFirstNode(GrebiSolrQuery query) {

private GrebiFacetedResultsPage<Map<String,JsonElement>> resolveNodeIds(GrebiFacetedResultsPage<SolrDocument> solrDocs) {

List<String> ids = solrDocs.map(doc -> doc.getFieldValue("grebi:nodeId").toString()).toList();
List<String> ids = solrDocs.map(doc -> doc.getFieldValue("grebi__nodeId").toString()).toList();

Map<String,Map<String,JsonElement>> idToEntity = resolver.resolve(ids);

Expand All @@ -48,14 +48,14 @@ private GrebiFacetedResultsPage<Map<String,JsonElement>> resolveNodeIds(GrebiFac

private Map<String,JsonElement> resolveNodeId(SolrDocument solrDoc) {

Map<String,Map<String,JsonElement>> idToEntity = resolver.resolve(List.of(solrDoc.getFieldValue("grebi:nodeId").toString()));
Map<String,Map<String,JsonElement>> idToEntity = resolver.resolve(List.of(solrDoc.getFieldValue("grebi__nodeId").toString()));

return idToEntity.values().iterator().next();
}

private GrebiFacetedResultsPage<Map<String,JsonElement>> resolveEdgeIds(GrebiFacetedResultsPage<SolrDocument> solrDocs) {

List<String> ids = solrDocs.map(doc -> doc.getFieldValue("grebi:edgeId").toString()).toList();
List<String> ids = solrDocs.map(doc -> doc.getFieldValue("grebi__edgeId").toString()).toList();

Map<String, Map<String,JsonElement>> idToEntity = resolver.resolve(ids);

Expand All @@ -67,7 +67,7 @@ private GrebiFacetedResultsPage<Map<String,JsonElement>> resolveEdgeIds(GrebiFac

private Map<String,JsonElement> resolveEdgeId(SolrDocument solrDoc) {

Map<String,Map<String,JsonElement>> idToEntity = resolver.resolve(List.of(solrDoc.getFieldValue("grebi:edgeId").toString()));
Map<String,Map<String,JsonElement>> idToEntity = resolver.resolve(List.of(solrDoc.getFieldValue("grebi__edgeId").toString()));

return idToEntity.values().iterator().next();
}
Expand Down
10 changes: 5 additions & 5 deletions grebi_ui/src/components/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,18 @@ export default function SearchBox({
to={linkUrl}
>
<div className="flex justify-between">
<div className="truncate flex-auto" title={name}>
{name}
</div>
<div className="truncate flex-initial ml-2 text-right">
{ type &&
<span
className="mr-2 bg-link-default px-3 py-1 rounded-lg text-sm text-white uppercase"
className="bg-link-default px-3 py-1 rounded-lg text-sm text-white uppercase"
title={type}
>
{type}
</span>
}
<div className="truncate flex-auto" title={name}>
{name}
</div>
<div className="truncate flex-initial ml-2 text-right">
<DatasourceTags dss={entry.getDatasources()} />
{/* <span
className="bg-orange-default px-3 py-1 rounded-lg text-sm text-white uppercase"
Expand Down
2 changes: 1 addition & 1 deletion grebi_ui/src/model/PropVal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PropVal {
let ds = src['grebi:datasources']
let value = src['grebi:value']

if(!ds || !value) {
if(ds === undefined || value === undefined) {
throw new Error('missing ds or value in ' + JSON.stringify(src))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export default function PropRowManyDatasourceSets(params:{node:GraphNode,prop:st
if(allSingleValues) {
return (
<Fragment>
<Grid item xs={12} style={{overflow:'hidden'}}>
<Grid item xs={12} style={{overflow:'hidden',padding:'8px'}} className="bg-gradient-to-r from-neutral-light to-white rounded-lg">
<b style={{fontFamily:"'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace"}}>{prop}</b>
</Grid>
{
dsSetsSorted.map(dsSet => {
let values = dsSetToVals.get(dsSet) || []
return <Fragment>
<Grid item xs={12}>
<Grid item xs={12} style={{padding:'8px'}}>
<div className="pl-2">
<DatasourceTags dss={values[0].datasources} />
<PropVals node={node} prop={prop} values={values} />
Expand All @@ -43,7 +43,7 @@ export default function PropRowManyDatasourceSets(params:{node:GraphNode,prop:st
} else {
return (
<Fragment>
<Grid item xs={12} style={{overflow:'hidden'}}>
<Grid item xs={12} style={{overflow:'hidden',padding:'8px'}} className="bg-gradient-to-r from-neutral-light to-white rounded-lg">
<b style={{fontFamily:"'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace"}}>{prop}</b>
</Grid>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function PropRowNoDatasourceLabels(params:{node:GraphNode,prop:st

return (
<Fragment>
<Grid item xs={12} style={{overflow:'hidden'}}>
<Grid item xs={12} style={{overflow:'hidden',padding:'8px'}} className="bg-gradient-to-r from-neutral-light to-white rounded-lg">
<b style={{fontFamily:"'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace"}}>{prop}</b>
</Grid>
<Grid item xs={12}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export default function PropRowOneDatasourceSet(params:{node:GraphNode,prop:stri

return (
<Fragment>
<Grid item xs={12} style={{overflow:'hidden'}}>
<Grid item xs={12} style={{overflow:'hidden',padding:'8px'}} className="bg-gradient-to-r from-neutral-light to-white rounded-lg">
<b style={{fontFamily:"'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace"}}>{prop}</b>
{ datasources.length > 1 && <span>
<DatasourceTags dss={values[0].datasources} />
</span>}
</Grid>
<Grid item xs={12}>
<Grid item xs={12} style={{padding:'8px'}}>
<div className="pl-2">
<PropVals node={node} prop={prop} values={values} />
</div>
Expand Down

0 comments on commit d32700a

Please sign in to comment.