/// <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> /// Removes the given ontology attribute from the attributes of this /// </summary> public RDFOntologyFact RemoveOntologyAttribute(RDFOntologyProperty attrProperty, RDFOntologyFact attrValue) { if (attrProperty != null && attrValue != null) { var attr = new RDFOntologyAttribute(attrProperty, attrValue); if (this.OntologyAttributes.ContainsKey(attr.AttributeID)) { this.OntologyAttributes.Remove(attr.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 given ontology attribute to the attributes of this /// </summary> public RDFOntologyFact AddOntologyAttribute(RDFOntologyProperty attrProperty, RDFOntologyFact attrValue) { if (attrProperty != null && attrValue != null) { //Attributes can only be assigned to resource ontology facts if (this.IsObjectFact()) { //Maintain disjointness between property model and reserved RDF/RDFS/OWL vocabularies if ( (!attrProperty.ToString().StartsWith(RDFVocabulary.RDF.BASE_URI.ToString(), StringComparison.Ordinal)) && (!attrProperty.ToString().StartsWith(RDFVocabulary.RDFS.BASE_URI.ToString(), StringComparison.Ordinal)) && (!attrProperty.ToString().StartsWith(RDFVocabulary.OWL.BASE_URI.ToString(), StringComparison.Ordinal)) ) { //Check consistence of property type against range fact type if( (attrProperty.IsObjectProperty() && attrValue.IsObjectFact()) || (attrProperty.IsDatatypeProperty() && attrValue.IsLiteralFact())) { var attr = new RDFOntologyAttribute(attrProperty, attrValue); if (!this.OntologyAttributes.ContainsKey(attr.AttributeID)) { this.OntologyAttributes.Add(attr.AttributeID, attr); } } } } } return this; }