Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the "ontologyFact -> rdfs:isDefinedBy -> ontologyResource" annotation to the data
 /// </summary>
 public RDFOntologyData AddIsDefinedByAnnotation(RDFOntologyFact ontologyFact,
                                                 RDFOntologyResource ontologyResource)
 {
     if (ontologyFact != null && ontologyResource != null)
     {
         this.Annotations.IsDefinedBy.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDFS.IS_DEFINED_BY.ToString()), ontologyResource));
         if (ontologyResource.IsLiteral())
         {
             this.AddLiteral((RDFOntologyLiteral)ontologyResource);
         }
     }
     return(this);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds the given standard annotation to the given ontology fact
        /// </summary>
        public RDFOntologyData AddStandardAnnotation(RDFSemanticsEnums.RDFOntologyStandardAnnotation standardAnnotation,
                                                     RDFOntologyFact ontologyFact,
                                                     RDFOntologyResource annotationValue)
        {
            if (ontologyFact != null && annotationValue != null)
            {
                switch (standardAnnotation)
                {
                //owl:versionInfo
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.VersionInfo:
                    if (annotationValue.IsLiteral())
                    {
                        this.Annotations.VersionInfo.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFVocabulary.OWL.VERSION_INFO.ToRDFOntologyAnnotationProperty(), annotationValue));
                    }
                    else
                    {
                        RDFSemanticsEvents.RaiseSemanticsInfo(String.Format("Cannot annotate ontology fact with owl:versionInfo value '{0}' because it is not an ontology literal", annotationValue));
                    }
                    break;

                //owl:versionIRI
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.VersionIRI:
                    RDFSemanticsEvents.RaiseSemanticsInfo("Cannot annotate ontology fact with owl:versionIRI because it is reserved for ontologies");
                    break;

                //rdfs:comment
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.Comment:
                    if (annotationValue.IsLiteral())
                    {
                        this.Annotations.Comment.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFVocabulary.RDFS.COMMENT.ToRDFOntologyAnnotationProperty(), annotationValue));
                    }
                    else
                    {
                        RDFSemanticsEvents.RaiseSemanticsInfo(String.Format("Cannot annotate ontology fact with rdfs:comment value '{0}' because it is not an ontology literal", annotationValue));
                    }
                    break;

                //rdfs:label
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.Label:
                    if (annotationValue.IsLiteral())
                    {
                        this.Annotations.Label.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFVocabulary.RDFS.LABEL.ToRDFOntologyAnnotationProperty(), annotationValue));
                    }
                    else
                    {
                        RDFSemanticsEvents.RaiseSemanticsInfo(String.Format("Cannot annotate ontology fact with rdfs:label value '{0}' because it is not an ontology literal", annotationValue));
                    }
                    break;

                //rdfs:seeAlso
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.SeeAlso:
                    this.Annotations.SeeAlso.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFVocabulary.RDFS.SEE_ALSO.ToRDFOntologyAnnotationProperty(), annotationValue));
                    break;

                //rdfs:isDefinedBy
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.IsDefinedBy:
                    this.Annotations.IsDefinedBy.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFVocabulary.RDFS.IS_DEFINED_BY.ToRDFOntologyAnnotationProperty(), annotationValue));
                    break;

                //owl:priorVersion
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.PriorVersion:
                    RDFSemanticsEvents.RaiseSemanticsInfo("Cannot annotate ontology fact with owl:priorVersion because it is reserved for ontologies");
                    break;

                //owl:imports
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.Imports:
                    RDFSemanticsEvents.RaiseSemanticsInfo("Cannot annotate ontology fact with owl:imports because it is reserved for ontologies");
                    break;

                //owl:backwardCompatibleWith
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.BackwardCompatibleWith:
                    RDFSemanticsEvents.RaiseSemanticsInfo("Cannot annotate ontology fact with owl:backwardCompatibleWith because it is reserved for ontologies");
                    break;

                //owl:incompatibleWith
                case RDFSemanticsEnums.RDFOntologyStandardAnnotation.IncompatibleWith:
                    RDFSemanticsEvents.RaiseSemanticsInfo("Cannot annotate ontology fact with owl:incompatibleWith because it is reserved for ontologies");
                    break;
                }
            }
            return(this);
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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);
        }