/// <summary> /// Removes the "ontologyFact -> ontologyAnnotationProperty -> ontologyResource" annotation from the data /// </summary> public RDFOntologyData RemoveCustomAnnotation(RDFOntologyFact ontologyFact, RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyResource ontologyResource) { if (ontologyFact != null && ontologyAnnotationProperty != null && ontologyResource != null) { //owl:versionInfo if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.VERSION_INFO.ToString()))) { if (ontologyResource.IsLiteral()) { this.RemoveVersionInfoAnnotation(ontologyFact, (RDFOntologyLiteral)ontologyResource); } } //rdfs:comment else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.COMMENT.ToString()))) { if (ontologyResource.IsLiteral()) { this.RemoveCommentAnnotation(ontologyFact, (RDFOntologyLiteral)ontologyResource); } } //rdfs:label else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.LABEL.ToString()))) { if (ontologyResource.IsLiteral()) { this.RemoveLabelAnnotation(ontologyFact, (RDFOntologyLiteral)ontologyResource); } } //rdfs:seeAlso else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.SEE_ALSO.ToString()))) { this.RemoveSeeAlsoAnnotation(ontologyFact, ontologyResource); } //rdfs:isDefinedBy else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.IS_DEFINED_BY.ToString()))) { this.RemoveIsDefinedByAnnotation(ontologyFact, ontologyResource); } //custom else { this.Annotations.CustomAnnotations.RemoveEntry(new RDFOntologyTaxonomyEntry(ontologyFact, ontologyAnnotationProperty, ontologyResource)); } } return(this); }
/// <summary> /// Removes the given custom annotation from the given ontology fact /// </summary> public RDFOntologyData RemoveCustomAnnotation(RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyFact ontologyFact, RDFOntologyResource annotationValue) { if (ontologyAnnotationProperty != null && ontologyFact != null && annotationValue != null) { //owl:versionInfo if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.VERSION_INFO.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.VersionInfo, ontologyFact, annotationValue); } //owl:versionIRI else if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.VERSION_IRI.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.VersionIRI, ontologyFact, annotationValue); } //rdfs:comment else if (ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.COMMENT.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.Comment, ontologyFact, annotationValue); } //rdfs:label else if (ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.LABEL.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.Label, ontologyFact, annotationValue); } //rdfs:seeAlso else if (ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.SEE_ALSO.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.SeeAlso, ontologyFact, annotationValue); } //rdfs:isDefinedBy else if (ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.IS_DEFINED_BY.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.IsDefinedBy, ontologyFact, annotationValue); } //owl:imports else if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.IMPORTS.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.Imports, ontologyFact, annotationValue); } //owl:backwardCompatibleWith else if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.BACKWARD_COMPATIBLE_WITH.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.BackwardCompatibleWith, ontologyFact, annotationValue); } //owl:incompatibleWith else if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.INCOMPATIBLE_WITH.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.IncompatibleWith, ontologyFact, annotationValue); } //owl:priorVersion else if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.PRIOR_VERSION.ToRDFOntologyAnnotationProperty())) { this.RemoveStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation.PriorVersion, ontologyFact, annotationValue); } //custom annotation else { this.Annotations.CustomAnnotations.RemoveEntry(new RDFOntologyTaxonomyEntry(ontologyFact, ontologyAnnotationProperty, annotationValue)); } } return(this); }
/// <summary> /// Removes the given custom annotation from this ontology resource /// </summary> public RDFOntologyResource RemoveCustomAnnotation(RDFOntologyAnnotationProperty annotationProperty, RDFOntologyFact annotationFact) { if (annotationProperty != null && annotationFact != null) { //Redirect standard annotation properties to their own methods if (annotationProperty.Equals(RDFVocabulary.OWL.VERSION_INFO)) { return this.RemoveVersionInfo(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.COMMENT)) { return this.RemoveComment(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.LABEL)) { return this.RemoveLabel(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.SEE_ALSO)) { return this.RemoveSeeAlso(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.IS_DEFINED_BY)) { return this.RemoveIsDefinedBy(annotationFact); } var annotAttr = new RDFOntologyAttribute(annotationProperty, annotationFact); if (this.CustomAnnotations.ContainsKey(annotAttr.AttributeID)) { this.CustomAnnotations.Remove(annotAttr.AttributeID); } } return this; }
/// <summary> /// Adds the given custom annotation to this ontology resource /// </summary> public RDFOntologyResource AddCustomAnnotation(RDFOntologyAnnotationProperty annotationProperty, RDFOntologyFact annotationFact) { if (annotationProperty != null && annotationFact != null) { //Redirect standard annotation properties to their own methods if (annotationProperty.Equals(RDFVocabulary.OWL.VERSION_INFO)) { return this.AddVersionInfo(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.COMMENT)) { return this.AddComment(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.LABEL)) { return this.AddLabel(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.SEE_ALSO)) { return this.AddSeeAlso(annotationFact); } if (annotationProperty.Equals(RDFVocabulary.RDFS.IS_DEFINED_BY)) { return this.AddIsDefinedBy(annotationFact); } //Cannot make axioms on annotation properties if (!(this is RDFOntologyProperty && ((RDFOntologyProperty)this).IsAnnotationProperty())) { //Cannot assign attributes to literal ontology facts if (!(this is RDFOntologyFact && ((RDFOntologyFact)this).IsLiteralFact())) { var annotAttr = new RDFOntologyAttribute(annotationProperty, annotationFact); if (!this.CustomAnnotations.ContainsKey(annotAttr.AttributeID)) { this.CustomAnnotations.Add(annotAttr.AttributeID, annotAttr); } } } } return this; }
/// <summary> /// Adds the "ontologyFact -> ontologyAnnotationProperty -> ontologyResource" annotation to the data /// </summary> public RDFOntologyData AddCustomAnnotation(RDFOntologyFact ontologyFact, RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyResource ontologyResource) { if (ontologyFact != null && ontologyAnnotationProperty != null && ontologyResource != null) { //owl:versionInfo if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.VERSION_INFO.ToString()))) { if (ontologyResource.IsLiteral()) { this.AddVersionInfoAnnotation(ontologyFact, (RDFOntologyLiteral)ontologyResource); } } //vs:term_status else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.VS.TERM_STATUS.ToString()))) { //Raise warning event to inform the user: vs:term_status annotation property cannot be used for facts RDFSemanticsEvents.RaiseSemanticsWarning("vs:term_status annotation property cannot be used for facts."); } //rdfs:comment else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.COMMENT.ToString()))) { if (ontologyResource.IsLiteral()) { this.AddCommentAnnotation(ontologyFact, (RDFOntologyLiteral)ontologyResource); } } //rdfs:label else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.LABEL.ToString()))) { if (ontologyResource.IsLiteral()) { this.AddLabelAnnotation(ontologyFact, (RDFOntologyLiteral)ontologyResource); } } //rdfs:seeAlso else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.SEE_ALSO.ToString()))) { this.AddSeeAlsoAnnotation(ontologyFact, ontologyResource); } //rdfs:isDefinedBy else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.IS_DEFINED_BY.ToString()))) { this.AddIsDefinedByAnnotation(ontologyFact, ontologyResource); } //ontology-specific else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.VERSION_IRI.ToString())) || ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.IMPORTS.ToString())) || ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.BACKWARD_COMPATIBLE_WITH.ToString())) || ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.INCOMPATIBLE_WITH.ToString())) || ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.PRIOR_VERSION.ToString()))) { //Raise warning event to inform the user: Ontology-specific annotation properties cannot be used for facts RDFSemanticsEvents.RaiseSemanticsWarning("Ontology-specific annotation properties cannot be used for facts."); } //custom else { this.Annotations.CustomAnnotations.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, ontologyAnnotationProperty, ontologyResource)); if (ontologyResource.IsLiteral()) { this.AddLiteral((RDFOntologyLiteral)ontologyResource); } } } return(this); }
/// <summary> /// Loads the annotation properties from the given graph into the given ontology /// </summary> internal static void LoadAnnotationProperties(RDFGraph ontGraph, RDFOntology ontology, RDFGraph customAnnot) { foreach (var t in customAnnot) { var anProp = new RDFOntologyAnnotationProperty((RDFResource)t.Subject); ontology.Model.PropertyModel.AddProperty(anProp); } }
/// <summary> /// Removes the "ontology -> ontologyAnnotationProperty -> ontologyResource" annotation from the ontology /// </summary> public RDFOntology RemoveCustomAnnotation(RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyResource ontologyResource) { if (ontologyAnnotationProperty != null && ontologyResource != null) { this.Annotations.CustomAnnotations.RemoveEntry(new RDFOntologyTaxonomyEntry(this, ontologyAnnotationProperty, ontologyResource)); } return this; }
/// <summary> /// Adds the "ontology -> ontologyAnnotationProperty -> ontologyResource" annotation to the ontology /// </summary> public RDFOntology AddCustomAnnotation(RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyResource ontologyResource) { if (ontologyAnnotationProperty != null && ontologyResource != null) { if (ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.VERSION_INFO) || ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.COMMENT) || ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.LABEL) || ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.SEE_ALSO) || ontologyAnnotationProperty.Equals(RDFVocabulary.RDFS.IS_DEFINED_BY) || ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.IMPORTS) || ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.BACKWARD_COMPATIBLE_WITH) || ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.INCOMPATIBLE_WITH) || ontologyAnnotationProperty.Equals(RDFVocabulary.OWL.PRIOR_VERSION)) { //Raise warning event to inform the user: Standard RDFS/OWL //annotation properties cannot be used in custom annotations RDFSemanticsEvents.RaiseSemanticsWarning("Standard RDFS/OWL annotation properties cannot be used in custom annotations."); return this; } this.Annotations.CustomAnnotations.AddEntry(new RDFOntologyTaxonomyEntry(this, ontologyAnnotationProperty, ontologyResource)); } return this; }
/// <summary> /// Removes the "ontology -> ontologyAnnotationProperty -> ontologyResource" annotation from the ontology /// </summary> public RDFOntology RemoveCustomAnnotation(RDFOntologyAnnotationProperty ontologyAnnotationProperty, RDFOntologyResource ontologyResource) { if (ontologyAnnotationProperty != null && ontologyResource != null) { //owl:versionInfo if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.VERSION_INFO.ToString()))) { if (ontologyResource.IsLiteral()) { this.RemoveVersionInfoAnnotation((RDFOntologyLiteral)ontologyResource); } } //owl:versionIRI else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.VERSION_IRI.ToString()))) { if (ontologyResource.IsOntology()) { this.RemoveVersionIRIAnnotation((RDFOntology)ontologyResource); } } //rdfs:comment else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.COMMENT.ToString()))) { if (ontologyResource.IsLiteral()) { this.RemoveCommentAnnotation((RDFOntologyLiteral)ontologyResource); } } //rdfs:label else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.LABEL.ToString()))) { if (ontologyResource.IsLiteral()) { this.RemoveLabelAnnotation((RDFOntologyLiteral)ontologyResource); } } //rdfs:seeAlso else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.SEE_ALSO.ToString()))) { this.RemoveSeeAlsoAnnotation(ontologyResource); } //rdfs:isDefinedBy else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.IS_DEFINED_BY.ToString()))) { this.RemoveIsDefinedByAnnotation(ontologyResource); } //owl:imports else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.IMPORTS.ToString()))) { if (ontologyResource.IsOntology()) { this.RemoveImportsAnnotation((RDFOntology)ontologyResource); } } //owl:backwardCompatibleWith else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.BACKWARD_COMPATIBLE_WITH.ToString()))) { if (ontologyResource.IsOntology()) { this.RemoveBackwardCompatibleWithAnnotation((RDFOntology)ontologyResource); } } //owl:incompatibleWith else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.INCOMPATIBLE_WITH.ToString()))) { if (ontologyResource.IsOntology()) { this.RemoveIncompatibleWithAnnotation((RDFOntology)ontologyResource); } } //owl:priorVersion else if (ontologyAnnotationProperty.Equals(RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.OWL.PRIOR_VERSION.ToString()))) { if (ontologyResource.IsOntology()) { this.RemovePriorVersionAnnotation((RDFOntology)ontologyResource); } } //custom else { this.Annotations.CustomAnnotations.RemoveEntry(new RDFOntologyTaxonomyEntry(this, ontologyAnnotationProperty, ontologyResource)); } } return(this); }