private List <POCO.OntologyTermMatchResults> GetSummaryFromDatabase(string ontologyUri) { DataFactory.DataConfig datacfg = Utils.GetDataConfig(); POCO.OntologyAssigned oassigned = new POCO.OntologyAssigned(); oassigned.RowKey = ontologyUri; List <POCO.OntologyTermMatchResults> matchsummaries = new List <POCO.OntologyTermMatchResults>(); matchsummaries = DataFactory.Ontology.GetOntologyMatchSummary(Utils.GetDataConfig(), oassigned); return(matchsummaries); }
public IActionResult AssignToSystem([FromHeader] string system, List <string> ontologys) { _logger.LogInformation("CPAPI: AssignOntologyToSystem"); List <POCO.OntologyAssigned> newOnts = new List <POCO.OntologyAssigned>(); // Validate the params if (string.IsNullOrEmpty(system)) { return(StatusCode((int)System.Net.HttpStatusCode.BadRequest)); } if (ontologys == null || ontologys.Count == 0) { return(StatusCode((int)System.Net.HttpStatusCode.BadRequest)); } // Assign each record authority to the system foreach (string ra in ontologys) { // Create a new OntologyAssigned entry POCO.OntologyAssigned ontAssigned = new POCO.OntologyAssigned(); ontAssigned.PartitionKey = Utils.CleanTableKey(system); ontAssigned.RowKey = Utils.CleanTableKey(ra); POCO.OntologyAssigned addedOntology = AssignToSystem(ontAssigned); newOnts.Add(addedOntology); } // Check if any adds succeeded if (newOnts.Count > 0) { // Return the added system entity ObjectResult result = new ObjectResult(newOnts); return(result); } else { return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError)); } }
private POCO.OntologyAssigned AssignToSystem(POCO.OntologyAssigned ontAssigned) { bool isAddedOk = false; // Execute the insert operation. //log.Verbose("Executing table operation"); try { // Call the Add datafactory method DataFactory.DataConfig datacfg = Utils.GetDataConfig(); DataFactory.Ontology.AssignToSystem(datacfg, ontAssigned); } catch (Exception aex) { _logger.LogError("ERR exception: " + aex.Message); } isAddedOk = true; return(ontAssigned); }
public static int AssignToSystem(DataConfig providerConfig, POCO.OntologyAssigned ontAssigned) { int numRows = 0; // Check if this exists already // TODO //List<POCO.RecordAuthorityFilter> rafilts = GetSystemAssignedOntology(providerConfig, ontAssigned); //if (rafilts.Count > 0) //{ // return numRows; //} switch (providerConfig.ProviderType) { case "azure.tableservice": AzureOntologyAssigned az = new AzureOntologyAssigned(ontAssigned); CloudTable table = Utils.GetCloudTable(providerConfig, AzureTableNames.SystemsAssignedOntology); TableOperation operation = TableOperation.InsertOrMerge(az); Task tUpdate = table.ExecuteAsync(operation); tUpdate.Wait(); //TODO return the inserted record id/timestamp return(numRows); case "internal.mongodb": IMongoCollection <MongoOntologyAssigned> collection = Utils.GetMongoCollection <MongoOntologyAssigned>(providerConfig, MongoTableNames.SystemsAssignedOntology); MongoOntologyAssigned mongoObject = Utils.ConvertType <MongoOntologyAssigned>(ontAssigned); collection.InsertOne(mongoObject); return(numRows); default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } return(numRows); }
public static List <POCO.OntologyTerm> GetOntologyTerms(DataConfig providerConfig, POCO.OntologyAssigned ontologyAssigned) { return(GetOntologyTerms(providerConfig, ontologyAssigned.RowKey)); }
public static List <POCO.OntologyTermMatchResults> GetOntologyMatchSummary(DataConfig providerConfig, POCO.OntologyAssigned ontologyAssigned) { // Get the ontology terms for this ontology List <POCO.OntologyTerm> oTerms = DataFactory.Ontology.GetOntologyTerms(providerConfig, ontologyAssigned); // Convert the ontology terms into match results List <POCO.OntologyTermMatchResults> results = new List <POCO.OntologyTermMatchResults>(); foreach (POCO.OntologyTerm term in oTerms) { // Create a matching result object POCO.OntologyTermMatchResults result = new POCO.OntologyTermMatchResults(); result.PartitionKey = term.PartitionKey; result.RowKey = term.RowKey; result.Term = term.Term; result.ParentTerm = term.ParentTerm; results.Add(result); } // Get all the ontology term matches for this ontology List <POCO.OntologyTermMatch> termMatches = DataFactory.Ontology.GetOntologyTermMatches(providerConfig, ontologyAssigned.RowKey); foreach (POCO.OntologyTermMatch match in termMatches) { // Find the Term Match Result for this Term Match POCO.OntologyTermMatchResults matchedResult = results.Find(r => r.PartitionKey == match.PartitionKey && r.RowKey == match.TermRowKey); if (matchedResult != null) { matchedResult.NumRecordAssociationMatches++; } } //TODO use Linq to select all the parent nodes instead // Walk the ontology tree and sum child counts to parent counts for (int i = 0; i < results.Count; i++) { POCO.OntologyTermMatchResults result = results[i]; // Find a parent ontology term (which has no ParentTerm = OntologyUri (PartitionKey)) if (result.ParentTerm == result.PartitionKey) { // Recursively sum the child terms up to its parent SumOntologySummary(ref result, ref results); } } return(results); }
public static bool AddOntologyMatchStatus(DataConfig providerConfig, POCO.RecordToRecordAssociation recassoc, POCO.OntologyAssigned ont, string matchStatus) { bool isSaved = false; POCO.OntologyMatchStatus ontstat = new OntologyMatchStatus(); ontstat.PartitionKey = ont.RowKey; ontstat.RowKey = recassoc.RowKey; ontstat.BatchStatus = matchStatus; switch (providerConfig.ProviderType) { case "azure.tableservice": List <TableOperation> ops = new List <TableOperation>(); CloudTable table = Utils.GetCloudTable(providerConfig, AzureTableNames.OntologyMatchStatus); AzureOntologyMatchStatus az = new AzureOntologyMatchStatus(ontstat); TableOperation operation = TableOperation.InsertOrReplace(az); Task tUpdate = table.ExecuteAsync(operation); tUpdate.Wait(); break; case "internal.mongodb": IMongoCollection <MongoOntologyMatchStatus> collection = Utils.GetMongoCollection <MongoOntologyMatchStatus>(providerConfig, MongoTableNames.OntologyMatchStatus); MongoOntologyMatchStatus mongoObject = Utils.ConvertType <MongoOntologyMatchStatus>(ontstat); collection.InsertOne(mongoObject); break; default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } isSaved = true; return(isSaved); }