public async Task <ActionResult <Synonym> > PostSynonym(Synonym synonym) { _context.Synonym.Add(synonym); await _context.SaveChangesAsync(); return(CreatedAtAction("GetSynonym", new { id = synonym.Id }, synonym)); }
public void Fill(Database database, string connectionString) { if (database.Options.Ignore.FilterSynonyms) { using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand(GetSQL(), conn)) { conn.Open(); command.CommandTimeout = 0; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { Synonym item = new Synonym(database); item.Id = (int)reader["object_id"]; item.Name = reader["Name"].ToString(); item.Owner = reader["Owner"].ToString(); item.Value = reader["base_object_name"].ToString(); database.Synonyms.Add(item); } } } } } }
public IHttpActionResult Update(int id, Synonym value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { service.Update(id, value); return(StatusCode(HttpStatusCode.NoContent)); } catch (NotSupportedException) { return(BadRequest()); } catch (UnauthorizedAccessException) { return(StatusCode(HttpStatusCode.Forbidden)); } catch (KeyNotFoundException) { return(NotFound()); } }
public async Task <Synonym> Process(Synonym synonym) { var taxon = Taxons.FirstOrDefault(t => t.Kingdom == synonym.Taxon.Kingdom && t.Subkingdom == synonym.Taxon.Subkingdom && t.Infrakingdom == synonym.Taxon.Infrakingdom && t.Phylum == synonym.Taxon.Phylum && t.Subphylum == synonym.Taxon.Subphylum && t.Class == synonym.Taxon.Class && t.Subclass == synonym.Taxon.Subclass && t.Superorder == synonym.Taxon.Superorder && t.Order == synonym.Taxon.Order && t.Family == synonym.Taxon.Family && t.Genus == synonym.Taxon.Genus && t.Species == synonym.Taxon.Species && t.Subspecies == synonym.Taxon.Subspecies && t.Variety == synonym.Taxon.Variety && t.Subvariety == synonym.Taxon.Subvariety && t.Form == synonym.Taxon.Form); if (taxon == null) { taxon = await _taxonService.AddOrUpdateTaxonAsync(synonym.Taxon); Taxons.Add(taxon); } var originResult = Origins.FirstOrDefault(o => o.ParentOrigin.OriginId == Origin.OriginId && o.ExternalId == synonym.Origin.ExternalId && o.AltExternalId == synonym.Origin.AltExternalId); if (originResult == null) { originResult = await _originService.GetOriginAsync(Origin.OriginId, synonym.Origin.ExternalId, synonym.Origin.AltExternalId); Origins.Add(originResult); } if (originResult == null) { originResult = await _originService.AddOrUpdateOriginAsync(synonym.Origin, null); Origins.Add(originResult); } synonym.Origin = originResult; var synonymResult = await _synonymService.GetSynonymAsync(s => s.Name == synonym.Name && s.Rank == synonym.Rank && s.TaxonId == synonym.TaxonId && s.OriginId == originResult.OriginId); if (synonymResult == null) { synonym.Origin = originResult; synonym.Taxon = taxon; synonymResult = await _synonymService.AddOrUpdateSynonymAsync(synonym); } return(synonymResult); }
public bool IsGrammarCorrect() { string[] splittedEntry = entry.Split('.'); if (splittedEntry.Length != 2) { return(false); //throw new Exception("#Incorrect length of attr ref"); } string declarationName = splittedEntry[0]; string attrNameEntry = splittedEntry[1]; Synonym synonym = new Synonym(declarationName); AttrName attrName = new AttrName(attrNameEntry, declarationName, declarations); if (!synonym.IsGrammarCorrect()) { return(false); //throw new Exception("#Incorrect synonym in attr ref: " + synonym.entry); } if (!attrName.IsGrammarCorrect()) { return(false); //throw new Exception("#Incorrect attr name: " + attrName.entry); } refType = attrName.refType; return(true); }
public void setSynonymValues() { Synonyms.Clear(); foreach (var i in SynResult.results) { foreach (var j in i.lexicalEntries) { var synonym = new Synonym(); synonym.Type = j.lexicalCategory; synonym.SynonymItems = ""; foreach (var k in j.entries) { foreach (var l in k.senses) { foreach (var item in l.synonyms) { synonym.SynonymItems += "\n" + item.text; Console.WriteLine(); } } } Synonyms.Add(synonym); } } }
private void CreateExclude() { var supplier = TestSupplier.CreateNaked(this.session); this.session.Transaction.Commit(); this.session.BeginTransaction(); using (var session = sessionFactory.OpenSession()) { var price = session.Load <Price>(supplier.Prices[0].Id); var producerSynonym = new ProducerSynonym { Name = "Тетовый синоним", Price = price, Producer = session.Query <Producer>().First() }; var productSynonym = new Synonym { Name = "Тетовый синоним", Price = price, ProductId = session.Query <CatalogProduct>().First().Id }; var exclude = new Exclude { CatalogProduct = session.Query <CatalogProduct>().First(), Price = price, ProducerSynonym = "Тетовый синоним", OriginalSynonym = productSynonym, }; session.Save(producerSynonym); session.Save(productSynonym); session.Save(exclude); } }
/// <summary> /// /// </summary> /// <param name="synonymAddData"></param> /// <returns></returns> public ActionResult Save(Synonym synonymAddData) { var term = synonymAddData.Term.Trim().ToLower(); var synonyms = synonymAddData.Synonyms.Split(',').ToList(); synonyms.ForEach(s => s.Trim().ToLower()); if (synonyms.Any()) { var mgr = new SolrResources <SearchDocument>(); if (!synonyms.Contains(term)) { synonyms.Add(term); } var s = new Synonym() { Term = synonymAddData.Term, Synonyms = string.Join(",", synonyms), }; mgr.DeleteSynonym("english", s.Term); mgr.AddSynonym("english", s); mgr.ReloadCore(); } return(RedirectToAction("Index", "SynonymsAdmin")); }
private static IEnumerable <Synonym> ParseSynonyms(Response.Synonym[] sources) { foreach (var source in sources) { var synonym = new Synonym { ParagraphLabel = source.Pl }; if (source.Sarefs?.Any() == true) { synonym.SeeInAdditionReference = new List <string>(source.Sarefs); } foreach (var dt in source.Pt) { if (dt[0].TypeLabelOrText == DefiningTextTypes.Text) { synonym.DefiningTexts.Add(new DefiningText(dt[1].TypeLabelOrText)); } else if (dt[0].TypeLabelOrText == DefiningTextTypes.VerbalIllustration) { foreach (var dtc in dt[1].DefiningTextComplexTypes) { synonym.DefiningTexts.Add(VisHelper.Parse(dtc.DefiningText)); } } } yield return(synonym); } }
public void ValidateSynonym_ShouldReturnFalse(string input) { Synonym synonym = new Synonym(input); bool result = synonym.IsGrammarCorrect(); Assert.False(result); }
public ActionResult Add(Synonym synonym, string languageId, string analyzer, string index) { if (!String.IsNullOrWhiteSpace(synonym.From) && !String.IsNullOrWhiteSpace(synonym.To)) { List <Synonym> synonyms = _synonymRepository.GetSynonyms(languageId, index); var fromWords = synonym.From .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Trim()) .ToArray(); if (fromWords.Length > 1) { synonym.MultiWord = true; synonym.From = String.Join(",", fromWords); } else if (!synonym.TwoWay) { synonym.From += "=>" + synonym.From; } synonym.From = synonym.From.ToLower(); synonym.To = synonym.To.ToLower(); synonyms.Add(synonym); _synonymRepository.SetSynonyms(languageId, analyzer, synonyms, index); } return(RedirectToAction("Index", new { index, languageId })); }
public IHttpActionResult Create(Synonym value) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { service.Create(value); return(CreatedAtRoute("Synonyms_Create", new { id = value.Id }, value)); } catch (NotSupportedException) { return(BadRequest()); } catch (UnauthorizedAccessException) { return(StatusCode(HttpStatusCode.Forbidden)); } catch (KeyNotFoundException) { return(NotFound()); } }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult Add() { var synonymMap = new Synonym(); //HttpContext.Current.Application["shellPath"] = EpiHelper.GetShellPath(); return(View("~/modules/MissionSearchEpi/UI/Views/SynonymsAdmin/add.cshtml", synonymMap)); }
public SynonymEntity MapToSynonymEntity(Synonym synonym, Guid diseaseId) { return(new SynonymEntity { DiseaseId = diseaseId, Id = Guid.NewGuid(), Name = GetTrimmedValue(synonym.Name) }); }
public static Search.Models.Synonym AsSearchModel(this Synonym source) => new Search.Models.Synonym { Id = source.Id, Name = source.Name, Rank = source.Rank, Language = source.Language, DateUpdated = source.DateUpdated, Origin = source.Origin?.AsSearchModel() };
private void OnSynonymChosened(Synonym synonym) { var handler = SynonymChosen; if (handler != null) { handler(this, synonym); } }
public SynonymItem(Synonym trs) { TSN = trs.TSN; SciName = trs.SciName; if (string.IsNullOrWhiteSpace(trs.SciName)) { SciName = "---"; } }
public void Create(Synonym value) { using (log.Activity(m => m($"Creating {nameof(Synonym)} by {Thread.CurrentPrincipal?.Identity?.Name}"))) { using (log.Activity(m => m("Authorization"))) { try { security.ValidateCreate(value); } catch (UnauthorizedAccessException) { log.Warn($"Authorization Denied"); throw; } catch (Exception e) { log.Error($"Authorization Error", e); throw; } } var entity = null as Synonym; using (log.Activity(m => m("Create Entity"))) { try { entity = context.Synonyms.Add(value); context.SaveChanges(); } //TODO: KB: Do this on index validation //throw new DuplicateKeyException(value.Name) catch (Exception e) { log.Error($"Update Error", e); throw; } } var newValue = entity.Filter(); using (log.Activity(m => m("Emit Event"))) { try { emitter.OnCreated(newValue); } catch (Exception e) { log.Error($"Emit Event Error", e); throw; } } log.Info(m => m($"Created {nameof(Synonym)}[{entity.Id}] by {Thread.CurrentPrincipal?.Identity?.Name}")); } }
public async Task DropAll() { var synonym = new Synonym(SqlConnection, SqlConnection.Database); await synonym.Create("mySynonym3", "target"); await synonym.DropAll(); await Verifier.Verify(SqlConnection) .SchemaSettings(tables: false); }
public override object GetData() { return(new Collection( Data0.ToString(CultureInfo.InvariantCulture), new Collection(Data1.ToString(CultureInfo.InvariantCulture), Data2.ToString(CultureInfo.InvariantCulture), FileName), "\"" + Name + "\"", Synonym.GetData(), "\"" + Comment + "\"" )); }
public void SomeFunction() { // Just a function to add 2 synonyms to 1 stock. Stock stock = GetStock("General Motors"); Synonym otherName = new Synonym("GM", stock); Add(otherName); ListOfSynonyms.Add(otherName); otherName = new Synonym("Gen. Motors", stock); Add(otherName); }
/// <summary> /// Update the name, external identifier, or language for this synonym. /// Neither the operating company nor the slug may be modified. /// </summary> /// <param name="synonym">An synonym with the updated information</param> /// <returns>A new Synonym object, with the updates in place</returns> /// <exception cref="Terra.ServerException"> /// <list type="bullet"> /// <item> /// <description>If any of the parameters submitted are invalid, returns a status of Not Acceptable.</description> /// </item> /// <item> /// <description>If the existing synonym could not be found on the server, returns a status of Not Found</description> /// </item> /// <item> /// <description>If the local synonym is older than the version on the server, a Precondition Failed status is returned</description> /// </item> /// </list> /// </exception> public Synonym Update(Synonym synonym) { return _client.Request("synonym", Method.PUT). AddParameter("opco", synonym.Opco). AddParameter("name", synonym.Name). AddParameter("slug", synonym.Slug). AddParameter("external", synonym.External). AddParameter("lang", synonym.Language). AddParameter("v", synonym.Version). MakeRequest<Synonym>(); }
public void TermWithSynonymsShouldCreateAsManySynonymsAsInSynonymsArrayPlusItself() { var data = new Synonym { Term = "computer", Synonyms = "laptop,notebook,PC" }; var expectedSynonyms = 4; var actualSynonyms = _synonymsParser.GetAllSynonymObjectsFromSynonym(data).Count(); Assert.AreEqual(expectedSynonyms, actualSynonyms); }
public void FirstSynonymShouldContainAllTheSynonymsSeparatedByComa() { var data = new Synonym { Term = "computer", Synonyms = "laptop,notebook,PC" }; var expectedSynonymsString = "laptop,notebook,PC"; var actualSynonymsData = _synonymsParser.GetAllSynonymObjectsFromSynonym(data).First().Synonyms; Assert.AreEqual(expectedSynonymsString, actualSynonymsData); }
public SynonymTreeNode(Synonym synonym, DatabaseConnection databaseConnection, DatabaseInstance databaseInstance) : base(databaseConnection, databaseInstance) { if (synonym == null) { throw new ArgumentNullException("synonym"); } Synonym = synonym; Text = synonym.DisplayName; this.Override.NodeAppearance.Image = DatabaseExplorerImageList.Instance.ImageList.Images["edit-replace.png"]; }
public async Task Create() { var synonym = new Synonym(SqlConnection, SqlConnection.Database); await synonym.DropAll(); await synonym.Create("mySynonym1", "target"); await Verifier.Verify(SqlConnection) .SchemaSettings(tables: false) .AddScrubber(builder => builder.Replace(SqlConnection.Database, "TargetDb")); }
public OptionAsync <IDatabaseSynonym> GetSynonym(Identifier synonymName, CancellationToken cancellationToken = default) { if (synonymName == null) { throw new ArgumentNullException(nameof(synonymName)); } synonymName = CreateQualifiedIdentifier(synonymName); return(Synonym.TryGetValue(synonymName, out var synonym) ? OptionAsync <IDatabaseSynonym> .Some(synonym) : OptionAsync <IDatabaseSynonym> .None); }
public void Add_LowerCasesInput() { var synonym = new Synonym { From = "A", To = "B" }; _controller.Add(synonym, "", "", ""); Assert.DoesNotContain('A', synonym.From); Assert.DoesNotContain('B', synonym.To); Assert.Contains('a', synonym.From); Assert.Contains('b', synonym.To); }
// Use this for initialization void Start() { if (!runSynonymFinderTest) { return; } Synonym s = new Synonym("brain", DoNothing); Synonym s2 = new Synonym("hate", DoNothing); Synonym s3 = new Synonym("cry", DoNothing); s.PrintWhenReady(); s2.PrintWhenReady(); s3.PrintWhenReady(); }
/// <summary> /// Script a Synonym using SMO /// </summary> /// <param name="objectName">Synonym name</param> /// <param name="schemaName">Schema name</param> /// <returns>String collection of scripts</returns> internal StringCollection GetSynonymScripts(string objectName, string schemaName, ScriptingOptions scriptingOptions = null) { try { Synonym smoObject = string.IsNullOrEmpty(schemaName) ? new Synonym(this.Database, objectName) : new Synonym(this.Database, objectName, schemaName); smoObject.Refresh(); return(smoObject.Script()); } catch (Exception ex) { Logger.Write(LogLevel.Error, "Exception at PeekDefinition GetSynonymScripts : " + ex.Message); return(null); } }
public ActionResult Delete(Synonym synonym, string languageId, string analyzer, string index) { List <Synonym> synonyms = _synonymRepository.GetSynonyms(languageId, index); synonyms.RemoveAll(s => { string synonymFrom = synonym.From + (synonym.TwoWay ? null : "=>" + synonym.From); return(s.From == synonymFrom && s.To == synonym.To && s.TwoWay == synonym.TwoWay); }); _synonymRepository.SetSynonyms(languageId, analyzer, synonyms, index); return(RedirectToAction("Index", new { index, languageId })); }
public void TestCanConstruct() { var synonym = new Synonym(new CultureData(CultureInfo.CurrentCulture), new List<string>()); Assert.IsInstanceOfType(synonym, typeof(LanguageWordList)); }
/// <summary> /// Remove the synonym with from the taxonomy. Note that this doesn't /// delete the synonym, simply removes its association from this /// taxonomy. /// </summary> /// <param name="taxonomy">The taxonomy with which to disassociate the synonym</param> /// <param name="synonym">The synonym for the taxonomy</param> /// <exception cref="Terra.ServerException">Either the taxonomy or the synonym doesn't exist</exception> public void RemoveSynonym(Taxonomy taxonomy, Synonym synonym) { _client.Request("taxonomy/synonym", Method.DELETE). AddParameter("opco", taxonomy.Opco). AddParameter("taxonomy", taxonomy.Slug). AddParameter("slug", synonym.Slug). MakeRequest(); }
/// <summary> /// Completely delete an synonym from Terra. This will remove the synonym /// from every meme it is related to in the operating company. In most /// cases, you'll likely want something along the lines of /// Terra.Service.Categories.RemoveSynonym instead. /// </summary> /// <seealso cref="Terra.Service.Categories.RemoveSynonym"/> /// <seealso cref="Terra.Service.Taxonomies.RemoveSynonym"/> /// <seealso cref="Terra.Service.Properties.RemoveSynonym"/> /// <seealso cref="Terra.Service.Options.RemoveSynonym"/> /// <seealso cref="Terra.Service.Headings.RemoveSynonym"/> /// <seealso cref="Terra.Service.Superheadings.RemoveSynonym"/> /// <param name="synonym">The synonym to delete</param> /// <exception cref="Terra.ServerException">The synonym does not exist</exception> public void Delete(Synonym synonym) { _client.Request("synonym", Method.DELETE). AddParameter("opco", synonym.Opco). AddParameter("slug", synonym.Slug). AddParameter("v", synonym.Version). MakeRequest(); }
/// <summary> /// Remove the synonym with from the property. Note that this doesn't /// delete the synonym, simply removes its association from this /// property. /// </summary> /// <param name="property">The property with which to disassociate the synonym</param> /// <param name="synonym">The synonym for the property</param> /// <exception cref="Terra.ServerException">Either the property or the synonym doesn't exist</exception> public void RemoveSynonym(Property property, Synonym synonym) { _client.Request("property/synonym", Method.DELETE). AddParameter("opco", property.Opco). AddParameter("property", property.Slug). AddParameter("slug", synonym.Slug). MakeRequest(); }
/// <summary> /// Associate an existing synonym with a heading. /// </summary> /// <param name="heading">The heading with which to associate the synonym</param> /// <param name="synonym">The synonym for the heading</param> /// <exception cref="Terra.ServerException">Either the heading or the synonym doesn't exist</exception> public void AddSynonym(Heading heading, Synonym synonym) { _client.Request("heading/synonym", Method.PUT). AddParameter("opco", heading.Opco). AddParameter("heading", heading.Pid). AddParameter("slug", synonym.Slug). MakeRequest(); }
public SynonymValue(string synonymCode) { code = (Synonym)Enum.Parse(typeof(Synonym), synonymCode.ToUpper()); }
/// <summary> /// Remove the synonym with from the superheading. Note that this doesn't /// delete the synonym, simply removes its association from this /// superheading. /// </summary> /// <param name="superheading">The superheading with which to disassociate the synonym</param> /// <param name="synonym">The synonym for the superheading</param> /// <exception cref="Terra.ServerException">Either the superheading or the synonym doesn't exist</exception> public void RemoveSynonym(Superheading superheading, Synonym synonym) { _client.Request("superheading/synonym", Method.DELETE). AddParameter("opco", superheading.Opco). AddParameter("superheading", superheading.Slug). AddParameter("slug", synonym.Slug). MakeRequest(); }
/// <summary> /// Remove the synonym with from the option. Note that this doesn't /// delete the synonym, simply removes its association from this /// option. /// </summary> /// <param name="option">The option with which to disassociate the synonym</param> /// <param name="synonym">The synonym for the option</param> /// <exception cref="Terra.ServerException">Either the option or the synonym doesn't exist</exception> public void RemoveSynonym(Option option, Synonym synonym) { _client.Request("option/synonym", Method.DELETE). AddParameter("opco", option.Opco). AddParameter("option", option.Slug). AddParameter("slug", synonym.Slug). MakeRequest(); }
private void CreateSynonyms() { try { string synString = WebUtility.GetStringParameter("synstring"); Synonym newSyn = new Synonym(); newSyn.Synonyms = synString; WebUtility.WriteAjaxResult(true, "m55", newSyn); } catch (Exception E) { WebUtility.WriteAjaxError(E.Message, E); } }
/// <summary> /// Remove the synonym with from the category. Note that this doesn't /// delete the synonym, simply removes its association from this /// category. /// </summary> /// <param name="category">The category with which to disassociate the synonym</param> /// <param name="synonym">The synonym for the category</param> /// <exception cref="Terra.ServerException">Either the category or the synonym doesn't exist</exception> public void RemoveSynonym(Category category, Synonym synonym) { _client.Request("category/synonym", Method.DELETE). AddParameter("opco", category.Opco). AddParameter("category", category.Slug). AddParameter("slug", synonym.Slug). MakeRequest(); }
private void SaveSynonyms() { string data = WebUtility.GetStringParameter("data", string.Empty); Synonym[] syn = null; try { //syn = (Synonym[])WebUtility.DeserializeAjaxResult(data, typeof(Synonym[])); try { syn = (Synonym[])WebUtility.DeserializeAjaxResult(data, typeof(Synonym[])); } catch (Exception ex) { syn = new Synonym[] { (Synonym)WebUtility.DeserializeAjaxResult(data, typeof(Synonym)) }; } syn = syn == null ? new Synonym[0] : syn; } catch (Exception E) { WebUtility.WriteAjaxError("err_deserialize_json", E); return; } try { synService.SetSynonym(syn); WebUtility.WriteAjaxResult(true, "m55", null); } catch (Exception E) { WebUtility.WriteAjaxError(null, E); } }