Example #1
0
        private static NeuronQuery ExtractQuery(dynamic query)
        {
            var nq = new NeuronQuery();

            nq.TagContains          = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.TagContains));
            nq.TagContainsNot       = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.TagContainsNot));
            nq.Id                   = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.Id));
            nq.IdNot                = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.IdNot));
            nq.Postsynaptic         = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.Postsynaptic));
            nq.PostsynapticNot      = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.PostsynapticNot));
            nq.Presynaptic          = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.Presynaptic));
            nq.PresynapticNot       = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.PresynapticNot));
            nq.RegionId             = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.RegionId));
            nq.RegionIdNot          = GraphModule.GetQueryArrayOrDefault(query, nameof(NeuronQuery.RegionIdNot));
            nq.RelativeValues       = GraphModule.GetNullableEnumValue <RelativeValues>("relative", query);
            nq.PageSize             = GraphModule.GetNullableIntValue("pagesize", query);
            nq.Page                 = GraphModule.GetNullableIntValue("page", query);
            nq.NeuronActiveValues   = GraphModule.GetNullableEnumValue <ActiveValues>("nactive", query);
            nq.TerminalActiveValues = GraphModule.GetNullableEnumValue <ActiveValues>("tactive", query);
            nq.SortBy               = GraphModule.GetNullableEnumValue <SortByValue>("sortby", query);
            nq.SortOrder            = GraphModule.GetNullableEnumValue <SortOrderValue>("sortorder", query);
            return(nq);
        }
Example #2
0
        public GraphModule(INeuronQueryService neuronQueryService, ITerminalQueryService terminalQueryService) : base("/cortex/graph")
        {
            this.Get("/neurons", async(parameters) =>
            {
                return(await GraphModule.ProcessRequest(async() =>
                {
                    var nv = await neuronQueryService.GetNeurons(GraphModule.ExtractQuery(this.Request.Query));
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                        ));
            }
                     );

            this.Get("/neurons/{neuronid:guid}", async(parameters) =>
            {
                return(await GraphModule.ProcessRequest(async() =>
                {
                    var nv = await neuronQueryService.GetNeuronById(
                        parameters.neuronid,
                        GraphModule.ExtractQuery(this.Request.Query)
                        );
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                        ));
            }
                     );

            this.Get("/neurons/{centralid:guid}/relatives", async(parameters) =>
            {
                return(await GraphModule.ProcessRequest(async() =>
                {
                    var nv = await neuronQueryService.GetNeurons(
                        parameters.centralid,
                        GraphModule.ExtractQuery(this.Request.Query)
                        );

                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                        ));
            }
                     );

            this.Get("/neurons/{centralid:guid}/relatives/{neuronid:guid}", async(parameters) =>
            {
                return(await GraphModule.ProcessRequest(async() =>
                {
                    var nv = await neuronQueryService.GetNeuronById(
                        parameters.neuronid,
                        parameters.centralid,
                        GraphModule.ExtractQuery(this.Request.Query)
                        );
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                        ));
            }
                     );

            this.Get("/terminals/{terminalid:guid}", async(parameters) =>
            {
                return(await GraphModule.ProcessRequest(async() =>
                {
                    var nv = await terminalQueryService.GetTerminalById(
                        parameters.terminalid,
                        GraphModule.ExtractQuery(this.Request.Query)
                        );
                    return new TextResponse(JsonConvert.SerializeObject(nv));
                }
                                                        ));
            }
                     );
        }