public async Task <Terminal> Get(Guid guid, Graph.Common.NeuronQuery neuronQuery, CancellationToken cancellationToken = default(CancellationToken)) { Terminal result = null; NeuronRepository.FillWithDefaults(neuronQuery, this.settingsService); using (var db = ArangoDatabase.CreateWithSetting(this.settingsService.DatabaseName)) { AssertionConcern.AssertStateTrue(await Helper.GraphExists(db), Constants.Messages.Error.GraphNotInitialized); var t = await db.DocumentAsync <Terminal>(guid.ToString()); if ( t != null && ( neuronQuery.TerminalActiveValues.Value.HasFlag(Graph.Common.ActiveValues.All) || ( Helper.TryConvert(neuronQuery.TerminalActiveValues.Value, out bool activeValue) && t.Active == activeValue ) ) ) { result = t.CloneExcludeSynapticPrefix(); } } return(result); }
private async Task <Domain.Model.QueryResult> GetAllCore(Guid?centralGuid, NeuronQuery neuronQuery, CancellationToken token = default(CancellationToken)) { Domain.Model.QueryResult result = null; NeuronRepository.FillWithDefaults(neuronQuery, this.settingsService); result = NeuronRepository.GetNeuronResults( centralGuid, null, this.settingsService.DatabaseName, neuronQuery, token ); return(result); }
private async Task <Domain.Model.QueryResult> GetRelativeCore(Guid guid, Guid?centralGuid, NeuronQuery neuronQuery, CancellationToken token = default(CancellationToken)) { Domain.Model.QueryResult result = null; NeuronRepository.FillWithDefaults(neuronQuery, this.settingsService); using (var db = ArangoDatabase.CreateWithSetting(this.settingsService.DatabaseName)) { AssertionConcern.AssertStateTrue(await Helper.GraphExists(db), Constants.Messages.Error.GraphNotInitialized); if (!centralGuid.HasValue) { var n = await db.DocumentAsync <Neuron>(guid.ToString()); if ( n != null && ( neuronQuery.NeuronActiveValues.Value.HasFlag(ActiveValues.All) || ( Helper.TryConvert(neuronQuery.NeuronActiveValues.Value, out bool activeValue) && n.Active == activeValue ) ) ) { var region = n.RegionId != null ? await db.DocumentAsync <Neuron>(n.RegionId) : null; var creationAuthor = (await db.DocumentAsync <Neuron>(n.CreationAuthorId)); var lastModificationAuthor = !string.IsNullOrEmpty(n.LastModificationAuthorId) ? (await db.DocumentAsync <Neuron>(n.LastModificationAuthorId)) : null; var unifiedLastModificationAuthor = !string.IsNullOrEmpty(n.UnifiedLastModificationAuthorId) ? (await db.DocumentAsync <Neuron>(n.UnifiedLastModificationAuthorId)) : null; AssertionConcern.AssertStateTrue(creationAuthor != null, string.Format(Constants.Messages.Error.AuthorNeuronNotFound, n.CreationAuthorId)); result = new Domain.Model.QueryResult() { Count = 1, Neurons = new Domain.Model.NeuronResult[] { new Domain.Model.NeuronResult() { Neuron = n, NeuronCreationAuthorTag = creationAuthor.Tag, NeuronLastModificationAuthorTag = lastModificationAuthor != null ? lastModificationAuthor.Tag : string.Empty, NeuronUnifiedLastModificationAuthorTag = unifiedLastModificationAuthor != null ? unifiedLastModificationAuthor.Tag : string.Empty, NeuronRegionTag = region != null ? region.Tag : string.Empty } } }; } else { result = new Domain.Model.QueryResult() { Count = 0, Neurons = new Domain.Model.NeuronResult[0] } }; } else { result = NeuronRepository.GetNeuronResults(centralGuid.Value, guid, this.settingsService.DatabaseName, neuronQuery, token); } // KEEP: circular references will now be allowed 2018/10/24 // int c = db.Query() // .Traversal<Neuron, Terminal>(EdgePrefix + guid.ToString()) // .Depth(1, 999) // .OutBound() // .Graph(NeuronRepository.GraphName) // .Filter(n => n.Vertex.Id == guid.ToString()) // .Select(g => g.Vertex.Id) // .ToList() // .Count(); } return(result); }