private void ProcessGraphValidationResult(CheckGraphResult validationResult, string sentenceId) { foreach (var disconnectedWordId in validationResult.DisconnectedWordIds) { EventAggregator.GetEvent<ValidationExceptionEvent>() .Publish( string.Format( "The word id: {0}, in sentence id: {1}, is not connected to another word.", disconnectedWordId, sentenceId)); } foreach (var cycle in validationResult.Cycles) { EventAggregator.GetEvent<ValidationExceptionEvent>() .Publish( string.Format( "The sentence with id {0} has cycle: {1}", sentenceId, string.Join(",", cycle))); } if (validationResult.DisconnectedWordIds.Any() || validationResult.Cycles.Any()) { EventAggregator.GetEvent<StatusNotificationEvent>() .Publish("Please check warnings in the Output panel."); } }
private void OnCheckIsTreeOnSentence(SentenceWrapper sentenceWrapper) { if (sentenceWrapper == null) { return; } var validationResult = new CheckGraphResult(); // todo no bueno with the app config var appConfig = appConfigMapper.Map(SelectedDocument.Model.GetAttributeByName("configurationFilePath")) .GetAwaiter() .GetResult(); sentenceWrapper.IsTree = GraphOperations.GetGraph(sentenceWrapper.Model, appConfig.Definitions.First(), eventAggregator) .IsTree(validationResult); if (!sentenceWrapper.IsTree) { foreach (var disconnectedWordId in validationResult.DisconnectedWordIds) { eventAggregator.GetEvent<ValidationExceptionEvent>() .Publish( string.Format( "The word id: {0}, in sentence id: {1}, is not connected to another word.", disconnectedWordId, sentenceWrapper.Id.Value)); } foreach (var cycle in validationResult.Cycles) { eventAggregator.GetEvent<ValidationExceptionEvent>() .Publish( string.Format( "The sentence with id {0} has cycle: {1}", sentence.Id.Value, string.Join(",", cycle))); } if (validationResult.DisconnectedWordIds.Any() || validationResult.Cycles.Any()) { eventAggregator.GetEvent<StatusNotificationEvent>() .Publish("Please check warnings in the Output panel."); } } }
private void ProcessPreviousSentence(Sentence sentence) { if ((sentence == null) || (sentence.Words.Count <= 1)) { return; } AddSentenceInternalAttributes(sentence); EventAggregator.GetEvent<StatusNotificationEvent>() .Publish(string.Format("Loaded sentence: {0} {1}", sentence.GetAttributeByName("id"), sentence.GetAttributeByName("content"))); var validationResult = new CheckGraphResult(); sentence.IsTree = GraphOperations.GetGraph(sentence, definition, EventAggregator).IsTree(validationResult); ProcessGraphValidationResult(validationResult, sentence.GetAttributeByName("id")); }
private void ProcessGraphValidationResult(CheckGraphResult validationResult, string sentenceId) { foreach (var disconnectedWordId in validationResult.DisconnectedWordIds) { EventAggregator.GetEvent<ValidationExceptionEvent>() .Publish( string.Format( "The word id: {0}, in sentence id: {1}, is not connected to another word.", disconnectedWordId, sentenceId)); } foreach (var cycle in validationResult.Cycles) { EventAggregator.GetEvent<ValidationExceptionEvent>() .Publish( string.Format("The sentence with id {0} has cycle: {1}", sentenceId, string.Join(",", cycle))); } }