public async Task <ActionResult <ConceptParentsDTO> > Parents( [FromQuery] HashSet <Guid> idents, [FromServices] ConceptTreeSearcher searcher) { try { var concepts = await searcher.GetAncestryAsync(idents); var dto = new ConceptParentsDTO { Concepts = concepts.Select(c => new ConceptDTO(c)) }; return(Ok(dto)); } catch (ArgumentNullException ane) { log.LogError("Missing argument. Error:{Error}", ane.Message); return(BadRequest()); } catch (Exception ex) { log.LogError("Failed to retrieve parents of Concepts:{Ids}. Error:{Error}", idents, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <ConceptDTO> > Single( Guid ident, [FromServices] ConceptTreeSearcher searcher) { try { var concept = await searcher.GetAsync(ident); if (concept == null) { return(NotFound()); } var dto = new ConceptDTO(concept); return(Ok(dto)); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode)); } catch (Exception ex) { log.LogError("Failed to retrieve Concept:{Id}. Error:{Error}", ident, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <ConceptTreeDTO> > GetTreeTop( [FromServices] ConceptTreeSearcher searcher) { try { var tree = await searcher.GetTreetopAsync(); var dto = new ConceptTreeDTO(tree); return(Ok(dto)); } catch (Exception e) { log.LogError("Failed to retrieve concept treetop. Error:{Error}", e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <IEnumerable <ConceptDTO> > > Children( Guid ident, [FromServices] ConceptTreeSearcher searcher) { try { var children = await searcher.GetChildrenAsync(ident); var dtos = children.Select(c => new ConceptDTO(c)); return(Ok(dtos)); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode)); } catch (Exception ex) { log.LogError("Failed to retrieve children of Concept:{Id}. Error:{Error}", ident, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <IEnumerable <ConceptDTO> > > SearchParents( [FromQuery] string searchTerm, [FromQuery] Guid?rootId, [FromServices] ConceptTreeSearcher searcher) { try { var ancestry = await searcher.GetAncestryBySearchTermAsync(rootId, searchTerm); return(Ok(ancestry.Select(c => new ConceptDTO(c)))); } catch (ArgumentNullException ane) { log.LogError("Missing argument. Error:{Error}", ane.Message); return(BadRequest()); } catch (Exception ex) { log.LogError("Failed to search for concepts by term. Term:{Term} RootId:{RootId} Error:{Error}", searchTerm, rootId, ex.Message); return(StatusCode(StatusCodes.Status500InternalServerError)); } }