Пример #1
0
 /// <summary>
 /// Adds the "ontologyFact -> rdf:type -> ontologyClass" relation to the data.
 /// </summary>
 public RDFOntologyData AddClassTypeRelation(RDFOntologyFact ontologyFact, RDFOntologyClass ontologyClass)
 {
     if (ontologyFact != null && ontologyClass != null)
     {
         //Enforce preliminary check on usage of BASE classes
         if (!RDFOntologyChecker.CheckReservedClass(ontologyClass))
         {
             //Enforce taxonomy checks before adding the ClassType relation
             if (RDFOntologyChecker.CheckClassTypeCompatibility(ontologyClass))
             {
                 this.Relations.ClassType.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFVocabulary.RDF.TYPE.ToRDFOntologyObjectProperty(), ontologyClass));
             }
             else
             {
                 //Raise warning event to inform the user: ClassType relation cannot be added to the data because only plain classes can be explicitly assigned as class types of facts
                 RDFSemanticsEvents.RaiseSemanticsWarning(String.Format("ClassType relation between fact '{0}' and class '{1}' cannot be added to the data because only plain classes can be explicitly assigned as class types of facts.", ontologyFact, ontologyClass));
             }
         }
         else
         {
             //Raise warning event to inform the user: ClassType relation cannot be added to the data because usage of BASE reserved classes compromises the taxonomy consistency
             RDFSemanticsEvents.RaiseSemanticsWarning(String.Format("ClassType relation between fact '{0}' and class '{1}' cannot be added to the data because because usage of BASE reserved classes compromises the taxonomy consistency.", ontologyFact, ontologyClass));
         }
     }
     return(this);
 }
Пример #2
0
 /// <summary>
 /// Checks if the given class can be assigned as classtype of facts
 /// </summary>
 internal static Boolean CheckClassTypeCompatibility(RDFOntologyClass ontologyClass)
 {
     return(!ontologyClass.IsRestrictionClass() &&
            !ontologyClass.IsCompositeClass() &&
            !ontologyClass.IsEnumerateClass() &&
            !ontologyClass.IsDataRangeClass());
 }
Пример #3
0
 /// <summary>
 /// Sets the range of this ontology property to the given ontology class
 /// </summary>
 public RDFOntologyProperty SetRange(RDFOntologyClass rangeClass)
 {
     if (!this.IsAnnotationProperty())
     {
         this.Range = rangeClass;
     }
     return(this);
 }
Пример #4
0
 /// <summary>
 /// Sets the domain of this ontology property to the given ontology class
 /// </summary>
 public RDFOntologyProperty SetDomain(RDFOntologyClass domainClass)
 {
     if (!this.IsAnnotationProperty())
     {
         this.Domain = domainClass;
     }
     return(this);
 }
Пример #5
0
 /// <summary>
 /// Removes the "ontologyFact -> rdf:type -> ontologyClass" relation from the data
 /// </summary>
 public RDFOntologyData RemoveClassTypeRelation(RDFOntologyFact ontologyFact, RDFOntologyClass ontologyClass)
 {
     if (ontologyFact != null && ontologyClass != null)
     {
         this.Relations.ClassType.RemoveEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFVocabulary.RDF.TYPE.ToRDFOntologyObjectProperty(), ontologyClass));
     }
     return(this);
 }
Пример #6
0
 /// <summary>
 /// Checks if the given aclass can be set disjointwith the given bclass
 /// </summary>
 internal static Boolean CheckDisjointWithCompatibility(RDFOntologyClassModel classModel,
                                                        RDFOntologyClass aClass,
                                                        RDFOntologyClass bClass)
 {
     return(!classModel.CheckIsSubClassOf(aClass, bClass) &&
            !classModel.CheckIsSuperClassOf(aClass, bClass) &&
            !classModel.CheckIsEquivalentClassOf(aClass, bClass));
 }
Пример #7
0
 /// <summary>
 /// Checks if the given childclass can be set subclassof the given motherclass
 /// </summary>
 internal static Boolean CheckSubClassOfCompatibility(RDFOntologyClassModel classModel,
                                                      RDFOntologyClass childClass,
                                                      RDFOntologyClass motherClass)
 {
     return(!classModel.CheckIsSubClassOf(motherClass, childClass) &&
            !classModel.CheckIsEquivalentClassOf(motherClass, childClass) &&
            !classModel.CheckIsDisjointClassWith(motherClass, childClass));
 }
Пример #8
0
 /// <summary>
 /// Default-ctor to build an ontology complement class of the given class and with the given name
 /// </summary>
 public RDFOntologyComplementClass(RDFResource className, RDFOntologyClass complementOf) : base(className)
 {
     if (complementOf != null)
     {
         this.ComplementOf = complementOf;
     }
     else
     {
         throw new RDFSemanticsException("Cannot create RDFOntologyComplementClass because given \"complementOf\" parameter is null.");
     }
 }
Пример #9
0
 /// <summary>
 /// Default-ctor to build an "owl:AllValuesFrom" ontology restriction with the given name on the given property and the given fromClass
 /// </summary>
 public RDFOntologyAllValuesFromRestriction(RDFResource restrictionName,
                                            RDFOntologyProperty onProperty,
                                            RDFOntologyClass fromClass) : base(restrictionName, onProperty)
 {
     if (fromClass != null)
     {
         this.FromClass = fromClass;
     }
     else
     {
         throw new RDFSemanticsException("Cannot create RDFOntologyAllValuesFromRestriction because given \"fromClass\" parameter is null.");
     }
 }
Пример #10
0
 /// <summary>
 /// Builds a class model lens for the given class on the given ontology
 /// </summary>
 public RDFOntologyClassModelLens(RDFOntologyClass ontologyClass, RDFOntology ontology)
 {
     if (ontologyClass != null)
     {
         if (ontology != null)
         {
             this.OntologyClass = ontologyClass;
             this.Ontology      = ontology.UnionWith(RDFBASEOntology.Instance);
         }
         else
         {
             throw new RDFSemanticsException("Cannot create class model lens because given \"ontology\" parameter is null");
         }
     }
     else
     {
         throw new RDFSemanticsException("Cannot create class model lens because given \"ontologyClass\" parameter is null");
     }
 }
        /// <summary>
        /// Default-ctor to build an ontology qualified cardinality restriction with the given name on the given property and given class
        /// </summary>
        public RDFOntologyQualifiedCardinalityRestriction(RDFResource restrictionName,
                                                          RDFOntologyProperty onProperty,
                                                          RDFOntologyClass onClass,
                                                          int minQualifiedCardinality,
                                                          int maxQualifiedCardinality) : base(restrictionName, onProperty)
        {
            //OnClass
            if (onClass != null)
            {
                this.OnClass = onClass;
            }
            else
            {
                throw new RDFSemanticsException("Cannot create RDFOntologyQualifiedCardinalityRestriction because given \"onClass\" parameter is null.");
            }

            //MinQualifiedCardinality
            if (minQualifiedCardinality > 0)
            {
                if (maxQualifiedCardinality > 0)
                {
                    if (minQualifiedCardinality <= maxQualifiedCardinality)
                    {
                        this.MinQualifiedCardinality = minQualifiedCardinality;
                    }
                    else
                    {
                        throw new RDFSemanticsException("Cannot create RDFOntologyQualifiedCardinalityRestriction because given \"minQualifiedCardinality\" parameter (" + minQualifiedCardinality + ") must be less or equal than given \"maxQualifiedCardinality\" parameter (" + maxQualifiedCardinality + ")");
                    }
                }
                else
                {
                    this.MinQualifiedCardinality = minQualifiedCardinality;
                }
            }

            //MaxQualifiedCardinality
            if (maxQualifiedCardinality > 0)
            {
                if (minQualifiedCardinality > 0)
                {
                    if (maxQualifiedCardinality >= minQualifiedCardinality)
                    {
                        this.MaxQualifiedCardinality = maxQualifiedCardinality;
                    }
                    else
                    {
                        throw new RDFSemanticsException("Cannot create RDFOntologyQualifiedCardinalityRestriction because given \"maxQualifiedCardinality\" parameter (" + maxQualifiedCardinality + ") must be greater or equal than given \"minQualifiedCardinality\" parameter (" + minQualifiedCardinality + ")");
                    }
                }
                else
                {
                    this.MaxQualifiedCardinality = maxQualifiedCardinality;
                }
            }

            if (this.MinQualifiedCardinality == 0 && this.MaxQualifiedCardinality == 0)
            {
                throw new RDFSemanticsException("Cannot create RDFOntologyQualifiedCardinalityRestriction because at least one of the given \"minQualifiedCardinality\" and \"maxQualifiedCardinality\" parameters must be greater than 0.");
            }
        }
Пример #12
0
 /// <summary>
 /// Checks if the given class is a reserved BASE ontology class
 /// </summary>
 internal static Boolean CheckReservedClass(RDFOntologyClass ontClass)
 {
     return(RDFBASEOntology.Instance.Model.ClassModel.Classes.ContainsKey(ontClass.PatternMemberID));
 }