/// <summary> /// Adds the "aFact -> owl:differentFrom -> bFact" relation to the data /// </summary> public RDFOntologyData AddDifferentFromRelation(RDFOntologyFact aFact, RDFOntologyFact bFact) { if (aFact != null && bFact != null && !aFact.Equals(bFact)) { //Enforce taxonomy checks before adding the differentFrom relation if (!RDFBASEOntologyReasoningHelper.IsSameFactAs(aFact, bFact, this)) { this.Relations.DifferentFrom.AddEntry(new RDFOntologyTaxonomyEntry(aFact, RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.DIFFERENT_FROM.ToString()), bFact)); this.Relations.DifferentFrom.AddEntry(new RDFOntologyTaxonomyEntry(bFact, RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.DIFFERENT_FROM.ToString()), aFact).SetInference(RDFSemanticsEnums.RDFOntologyInferenceType.API)); } else { //Raise warning event to inform the user: DifferentFrom relation cannot be added to the data because it violates the taxonomy consistency RDFSemanticsEvents.RaiseSemanticsWarning(String.Format("DifferentFrom relation between fact '{0}' and fact '{1}' cannot be added to the data because it violates the taxonomy consistency.", aFact, bFact)); } } return(this); }
/// <summary> /// Adds the "aFact -> objectProperty -> bFact" relation to the data /// </summary> public RDFOntologyData AddAssertionRelation(RDFOntologyFact aFact, RDFOntologyObjectProperty objectProperty, RDFOntologyFact bFact) { if (aFact != null && objectProperty != null && bFact != null) { //Enforce taxonomy checks before adding the assertion //Even if legal, we don't permit creation of transitive cycles!! if (!RDFBASEOntologyReasoningHelper.IsTransitiveAssertionOf(bFact, objectProperty, aFact, this)) { this.Relations.Assertions.AddEntry(new RDFOntologyTaxonomyEntry(aFact, objectProperty, bFact)); } else { //Raise warning event to inform the user: Assertion relation cannot be added to the data because it violates the taxonomy transitive consistency RDFSemanticsEvents.RaiseSemanticsWarning(String.Format("Assertion relation between fact '{0}' and fact '{1}' with transitive property '{2}' cannot be added to the data because it would violate the taxonomy consistency (transitive cycle detected).", aFact, bFact, objectProperty)); } } return(this); }