Exemplo n.º 1
0
        public async Task <ActionResult <ConceptTreeDTO> > GetTreeTop([FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var tree = await conceptReader.GetTreetopAsync();

                var dto = new ConceptTreeDTO(tree);
                return(Ok(dto));
            }
            catch (Exception e)
            {
                log.LogError("Could not retrieve ConceptTree. Error:{Error}", e.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult <IEnumerable <ConceptDTO> > > SearchParents(
            [FromQuery] string searchTerm,
            [FromQuery] Guid?rootId,
            [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var terms    = searchTerm.Split(' ');
                var concepts = await conceptReader.GetWithParentsBySearchTermAsync(rootId, terms);

                return(Ok(concepts.Select(c => new ConceptDTO(c))));
            }
            catch (Exception ex)
            {
                log.LogError("Could not search for concepts by term. Term:{Term} RootId:{RootId} Error:{Error}", searchTerm, rootId, ex.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <ConceptParentsDTO> > Parents(
            [FromQuery] HashSet <Guid> idents,
            [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var concepts = await conceptReader.GetWithParentsAsync(idents);

                var dto = new ConceptParentsDTO
                {
                    Concepts = concepts.Select(c => new ConceptDTO(c))
                };

                return(Ok(dto));
            }
            catch (Exception ex)
            {
                log.LogError("Could not retrieve parents of Concepts:{Ids}. Error:{Error}", idents, ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemplo n.º 4
0
        public async Task <ActionResult <ConceptDTO> > Single(Guid ident, [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var concept = await conceptReader.GetAsync(ident);

                if (concept == null)
                {
                    return(NotFound());
                }

                var dto = new ConceptDTO(concept);
                return(Ok(dto));
            }
            catch (LeafDbException le)
            {
                return(StatusCode(le.StatusCode));
            }
            catch (Exception ex)
            {
                log.LogError("Could not retrieve Concept:{Id}. Error:{Error}", ident, ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemplo n.º 5
0
 public ConceptTreeSearcher(IConceptTreeReader reader, ILogger <ConceptTreeSearcher> logger)
 {
     this.reader = reader;
     log         = logger;
 }
Exemplo n.º 6
0
        public async Task <ActionResult <IEnumerable <ConceptDTO> > > Children(Guid ident, [FromServices] IConceptTreeReader conceptReader)
        {
            try
            {
                var children = await conceptReader.GetChildrenAsync(ident);

                var dtos = children.Select(c => new ConceptDTO(c));
                return(Ok(dtos));
            }
            catch (LeafDbException le)
            {
                return(StatusCode(le.StatusCode));
            }
            catch (Exception ex)
            {
                log.LogError("Could not retrieve children of Concept:{Id}. Error:{Error}", ident, ex.ToString());
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }