public IActionResult GetByFilter([FromQuery] string filter) { string entityAsJson = ""; try { _logger.LogInformation("CPAPI: Get"); // Deserialize the ontology filter OntologyExplorerFilter oFilter = new OntologyExplorerFilter(); if (filter != null && filter.Length > 0) { _logger.LogDebug("Deserializing ontology filter of length: " + filter.Length); oFilter = JsonConvert.DeserializeObject <OntologyExplorerFilter>(filter); } List <DataFactory.Filter> filters = new List <DataFactory.Filter>(); // Check for filters if (oFilter.ontology.Count > 0) { string combinedFilter = ""; foreach (string of in oFilter.ontology) { string cleanFilterPKey = Utils.CleanTableKey(of); DataFactory.Filter pkfilt = new DataFactory.Filter("PartitionKey", of, "eq"); filters.Add(pkfilt); } } List <POCO.OntologyMatchSummary> matchsummaries = new List <POCO.OntologyMatchSummary>(); matchsummaries = DataFactory.Ontology.GetOntologyMatchSummary(Utils.GetDataConfig(), filters); entityAsJson = JsonConvert.SerializeObject(matchsummaries, Formatting.Indented); } catch (Exception ex) { string exceptionMsg = "Ontology GET exception: " + ex.Message; //log.Info("Exception occurred extracting text from uploaded file \r\nError: " + ex.Message); if (ex.InnerException != null) { exceptionMsg = exceptionMsg + "[" + ex.InnerException.Message + "]"; } _logger.LogError(exceptionMsg); return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError)); } ObjectResult result = new ObjectResult(entityAsJson); return(result); }
public IActionResult GetSummaryByFilter([FromQuery] string filter) { string entityAsJson = ""; try { _logger.LogInformation("CPAPI: Get"); // Deserialize the ontology filter OntologyExplorerFilter oFilter = new OntologyExplorerFilter(); if (filter != null && filter.Length > 0) { _logger.LogDebug("Deserializing ontology filter of length: " + filter.Length); oFilter = JsonConvert.DeserializeObject <OntologyExplorerFilter>(filter); } List <DataFactory.Filter> filters = new List <DataFactory.Filter>(); // Check for filters if (oFilter.ontology.Count > 0) { Func <List <POCO.OntologyTermMatchResults> > dataGetter = () => GetSummaryFromDatabase(oFilter.ontology[0]); var matchsummaries = _cacheOntologyExplorer.GetOrAdd(oFilter.ontology[0], dataGetter); // Sort by ParentTerm then by Term matchsummaries.Sort((x, y) => String.Compare(x.ParentTerm + "|" + x.Term, y.ParentTerm + "|" + y.Term)); entityAsJson = JsonConvert.SerializeObject(matchsummaries, Formatting.Indented); } } catch (Exception ex) { string exceptionMsg = "Ontology GET exception: " + ex.Message; //log.Info("Exception occurred extracting text from uploaded file \r\nError: " + ex.Message); if (ex.InnerException != null) { exceptionMsg = exceptionMsg + "[" + ex.InnerException.Message + "]"; } _logger.LogError(exceptionMsg); return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError)); } ObjectResult result = new ObjectResult(entityAsJson); return(result); }