Search in sources :

Example 1 with SortaServiceResponse

use of org.molgenis.ontology.sorta.request.SortaServiceResponse in project molgenis by molgenis.

the class SortaController method findMatchingOntologyTerms.

@PostMapping("/match/entity")
@ResponseBody
public SortaServiceResponse findMatchingOntologyTerms(@RequestBody Map<String, Object> request) {
    // TODO: less obfuscated request object, let Spring do the matching
    if (request.containsKey("sortaJobExecutionId") && !isEmpty(request.get("sortaJobExecutionId").toString()) && request.containsKey(IDENTIFIER) && !isEmpty(request.get(IDENTIFIER).toString())) {
        String sortaJobExecutionId = request.get("sortaJobExecutionId").toString();
        SortaJobExecution sortaJobExecution = findSortaJobExecution(sortaJobExecutionId);
        if (sortaJobExecution == null)
            return new SortaServiceResponse("sortaJobExecutionId is invalid!");
        String inputTermIdentifier = request.get(IDENTIFIER).toString();
        Entity inputEntity = dataService.findOneById(sortaJobExecution.getSourceEntityName(), inputTermIdentifier);
        if (inputEntity == null)
            return new SortaServiceResponse("inputTerm identifier is invalid!");
        return new SortaServiceResponse(inputEntity, sortaService.findOntologyTermEntities(sortaJobExecution.getOntologyIri(), inputEntity));
    }
    return new SortaServiceResponse("Please check that sortaJobExecutionId and identifier keys exist in input and have nonempty value!");
}
Also used : DynamicEntity(org.molgenis.data.support.DynamicEntity) SortaServiceResponse(org.molgenis.ontology.sorta.request.SortaServiceResponse) SortaJobExecution(org.molgenis.ontology.sorta.job.SortaJobExecution)

Aggregations

DynamicEntity (org.molgenis.data.support.DynamicEntity)1 SortaJobExecution (org.molgenis.ontology.sorta.job.SortaJobExecution)1 SortaServiceResponse (org.molgenis.ontology.sorta.request.SortaServiceResponse)1