예제 #1
0
        private string?ImplementFromGraphClauseToSelectQuery(string query, Parameters parameters)
        {
            Endpoint?endpointConfig = _endpointService.GetEndpointConfiguration(parameters.RouteParameters.Endpoint);

            if (endpointConfig == null)
            {
                return(null);
            }
            if (!string.IsNullOrEmpty(parameters.RouteParameters.Graph) && endpointConfig.NamedGraphs != null &&
                endpointConfig.NamedGraphs.Count > 0)
            {
                var graph = endpointConfig.NamedGraphs.Where(x => x.GraphName.Equals(parameters.RouteParameters.Graph))
                            .Select(y => y.Uri).FirstOrDefault();
                if (string.IsNullOrEmpty(graph))
                {
                    return(null);
                }
                query = Regex.Replace(query, "where",
                                      $"FROM <{graph}> WHERE",
                                      RegexOptions.IgnoreCase);
                return(query);
            }

            if (!string.IsNullOrEmpty(endpointConfig.DefaultGraph))
            {
                query = Regex.Replace(query, "where", $"FROM <{endpointConfig.DefaultGraph}> WHERE",
                                      RegexOptions.IgnoreCase);
                return(query);
            }

            return(query);
        }
        public IActionResult GetEndpointConfiguration([FromRoute] string endpoint)
        {
            var info = _endpointService.GetEndpointConfiguration(endpoint);

            if (info != null)
            {
                return(Ok(_mapper.Map <Endpoint, EndpointVm>(info)));
            }
            return(NotFound(new CustomErrorVm()
            {
                CustomErrorMessage = "Endpoint does not exist."
            }));
        }