Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jusa3 committed Sep 12, 2023
2 parents 286c2e8 + c483a16 commit d5c53c3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 21 deletions.
18 changes: 18 additions & 0 deletions backend/restapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def api_ols():

return obj

# deprecated
@app.route('/api/ols/term', methods=["GET"])
def api_ols_term():
q = request.args.get('iri', type=str)
Expand Down Expand Up @@ -449,5 +450,22 @@ def remove_all_annotations():

return projectId

@app.route('/api/maelstrom-domain', methods=["GET"])
def get_is_Maelstrom_domain():
iri = request.args.get('iri', type=str)
ontology = request.args.get('ontology', type=str)
iri_encoded = quote(quote(iri, safe='~()*!\''), safe='~()*!\'')
url = (ols + 'ontologies/maelstrom/terms/' + iri_encoded + "/parents")

if ontology == "maelstrom":
response_parent = requests.get(url).json()
if response_parent["_embedded"]["terms"][0]["label"] == "Thing":
return jsonify("True")
else:
return jsonify("False")
else:
return jsonify("False")



return app
1 change: 1 addition & 0 deletions backend/restapi/services/filter_search_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def filter_class(obj):
del obj['response']['docs'][i]
return obj

# deprecated
def filter_maelstrom_domains(obj):
if obj:
if len(obj['response']['docs']) != 0:
Expand Down
58 changes: 37 additions & 21 deletions frontend/src/components/annotations/ConceptSearch.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
import { useQuery, useQueryClient } from "react-query";
import {
EuiCallOut,
EuiCard,
EuiFieldSearch,
EuiFlexGroup,
EuiFlexItem,
EuiLoadingSpinner,
EuiPanel,
EuiSpacer,
EuiText,
EuiToolTip,
} from "@elastic/eui";
import React, { useEffect, useState } from "react";
import { OLSConceptIF } from "../../api";
import { EuiButton, EuiCard, EuiFlexGroup, EuiFlexItem, EuiPanel, EuiSpacer, EuiText, EuiToolTip, } from "@elastic/eui";
import React, { useState } from "react";
import { AutocompleteWidget, MetadataWidget } from "@nfdi4health/semlookp-widgets";
import CustomEuiTable from './CustomEuiTable'
import { Question } from '../../pages/AnnotationPage'
import { useParams } from 'react-router-dom'

Expand All @@ -38,14 +25,38 @@ interface SelectedEntity {

export default (props: ConceptSearchProps) => {
const { ontologyList = "" } = useParams();
const [selectedEntity, setSelectedEntity] = useState<SelectedEntity>({iri: "", label: "", ontology_name:"", entityType: ""})

const queryClient = useQueryClient();
const [selectedEntity, setSelectedEntity] = useState<SelectedEntity>({
iri: "",
label: "",
ontology_name: "",
entityType: ""
})
const [isMaelstromDomain, setIsMaelstromDomain] = useState<boolean>(false)

const onInputChange = (e: any) => {
setSelectedEntity(e);
setSelectedEntity(
{
iri: e.iri,
label: e.label,
ontology_name: e.ontology_name,
entityType: e.type
});
};

const {
isSuccess,
data: maelstromDomainInfo
} = useQuery({
queryKey: ["maelstromDomainInfo", selectedEntity.iri],
queryFn: () => {
return fetch(
`/api/maelstrom-domain?iri=${selectedEntity.iri}&ontology=${selectedEntity.ontology_name}`
).then((result) => result.json()
.then((result) => setIsMaelstromDomain(result == "False" ? false : true)))
},
enabled: selectedEntity.iri != ""
});

return (
<div>
<EuiFlexGroup>
Expand Down Expand Up @@ -78,6 +89,11 @@ export default (props: ConceptSearchProps) => {
hasShortSelectedLabel={true}
/>
<EuiSpacer/>
{isSuccess && selectedEntity.iri != "" &&
<EuiButton
isDisabled={isMaelstromDomain}
onClick={() => props.addAnnotation(selectedEntity)}
>Add Annotation</EuiButton>}

</EuiPanel>
</EuiFlexItem>
Expand All @@ -94,8 +110,8 @@ export default (props: ConceptSearchProps) => {
<MetadataWidget
iri={selectedEntity.iri}
api={"https://semanticlookup.zbmed.de/ols/api/"}
entityType={selectedEntity.entityType}
ontologyId={ontologyList.split(',')[0]}
entityType={selectedEntity.entityType == "class" ? "term" : selectedEntity.entityType}
ontologyId={selectedEntity.ontology_name}
/>
</EuiCard>
)}
Expand Down

0 comments on commit d5c53c3

Please sign in to comment.