/// <summary>
        /// Enlists the facts which are members of the given non literal-compatible class within the given ontology
        /// (internal-only method for performance purposes, used during validation and reasoning logics)
        /// </summary>
        internal static RDFOntologyData EnlistMembersOfNonLiteralCompatibleClass(RDFOntologyClass ontClass,
                                                                                 RDFOntology ontology)
        {
            var result = new RDFOntologyData();

            if (ontClass != null && ontology != null)
            {
                //Restriction
                if (ontClass.IsRestrictionClass())
                {
                    result = RDFSemanticsUtilities.EnlistMembersOfRestriction((RDFOntologyRestriction)ontClass, ontology);
                }

                //Composite
                else if (ontClass.IsCompositeClass())
                {
                    result = RDFSemanticsUtilities.EnlistMembersOfComposite(ontClass, ontology);
                }

                //Enumerate
                else if (ontClass.IsEnumerateClass())
                {
                    result = RDFSemanticsUtilities.EnlistMembersOfEnumerate((RDFOntologyEnumerateClass)ontClass, ontology);
                }

                //Class
                else
                {
                    result = RDFSemanticsUtilities.EnlistMembersOfClass(ontClass, ontology);
                }
            }
            return(result);
        }
 /// <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>
 /// Adds the "ontologyFact -> rdf:type -> ontologyClass" relation to the data.
 /// </summary>
 public RDFOntologyData AddClassTypeRelation(RDFOntologyFact ontologyFact,
                                             RDFOntologyClass ontologyClass)
 {
     if (ontologyFact != null && ontologyClass != null)
     {
         //Enforce taxonomy checks before adding the classType relation
         //Only plain classes can be explicitly assigned as classtypes of facts
         if (!ontologyClass.IsRestrictionClass() &&
             !ontologyClass.IsCompositeClass() &&
             !ontologyClass.IsEnumerateClass() &&
             !ontologyClass.IsDataRangeClass() &&
             //owl:Nothing cannot be assigned as classtype of facts
             !ontologyClass.Equals(RDFBASEOntology.Instance.Model.ClassModel.SelectClass(RDFVocabulary.OWL.NOTHING.ToString())))
         {
             this.Relations.ClassType.AddEntry(new RDFOntologyTaxonomyEntry(ontologyFact, RDFBASEOntology.Instance.Model.PropertyModel.SelectProperty(RDFVocabulary.RDF.TYPE.ToString()), 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));
         }
     }
     return(this);
 }
        /// <summary>
        /// Enlists the facts which are members of the given class within the given ontology
        /// </summary>
        public static RDFOntologyData EnlistMembersOf(RDFOntologyClass ontClass, RDFOntology ontology) {
            var result      = new RDFOntologyData();
            if (ontClass   != null && ontology != null) {
                
                //Restriction
                if (ontClass.IsRestrictionClass()) {
                    result  = RDFSemanticsUtilities.EnlistMembersOfRestriction((RDFOntologyRestriction)ontClass,  ontology);
                }

                //Enumeration
                else if (ontClass.IsEnumerateClass()) {
                    result  = RDFSemanticsUtilities.EnlistMembersOfEnumerate((RDFOntologyEnumerateClass)ontClass, ontology);
                }

                //DataRange
                else if (ontClass.IsDataRangeClass()) {
                    result  = RDFSemanticsUtilities.EnlistMembersOfDataRange((RDFOntologyDataRangeClass)ontClass, ontology);
                }

                //Composite
                else if (ontClass.IsCompositeClass()) {
                    result  = RDFSemanticsUtilities.EnlistMembersOfComposite(ontClass, ontology);
                }

                //SimpleClass
                else {
                    result  = RDFSemanticsUtilities.EnlistMembersOfClass(ontClass, ontology);
                }

            }
            return result;
        }
        /// <summary>
        /// Adds the given ontology class to the class types of this
        /// </summary>
        public RDFOntologyFact AddClassType(RDFOntologyClass classType) {
            if (classType != null) {

                //Class types can only be assigned to resource ontology facts
                if (this.IsObjectFact()) {

                    //Cannot assign a restriction or a composite/enumerate class as class type of a fact
                    if (!classType.IsCompositeClass() && !classType.IsEnumerateClass() && !classType.IsRestrictionClass()) {
                        if (!this.ClassTypes.ContainsKey(classType.PatternMemberID)) {
                            this.ClassTypes.Add(classType.PatternMemberID, classType);
                        }
                    }

                }                

            }
            return this;
        }