示例#1
0
        public List <OntologyProperty> GetInheritedProperies(OntologyClass oClass)
        {
            List <OntologyProperty> retval = new List <OntologyProperty>();
            Dictionary <String, OntologyProperty> tempRetval = new Dictionary <string, OntologyProperty>();

            // get the full list
            // walk up the parent chain and add all the properties we need.
            List <String> fullParentList = null;

            fullParentList = this.GetSuperclassNames(oClass.GetNameString(false), fullParentList);
            fullParentList.Add(oClass.GetNameString(false));

            // go through the superclass list and gather all the properties.
            foreach (String scn in fullParentList)
            {
                // add each property from the superclass
                foreach (OntologyProperty currProp in this.classHash[scn].GetProperties())
                {
                    tempRetval.Add(currProp.GetNameStr(), currProp);
                }
            }

            // assemble into a single list with no repeated values
            Object[] keys = tempRetval.Keys.ToArray();
            Array.Sort(keys);

            foreach (Object propKey in keys)
            {
                retval.Add(tempRetval[(String)propKey]);
            }

            return(retval);
        }
示例#2
0
        public void AddClass(OntologyClass oClass)
        {
            String classNameStr = oClass.GetNameString(false);          // get the full name of the class and do not strip the uri info

            this.connHash.Clear();

            this.classHash.Add(classNameStr, oClass);
            // store info on the related subclasses
            List <String> superClassNames = oClass.GetParentNameStrings(false); // get the parents. there may be several.

            // spin through the list and find the ones that need to be added
            foreach (String scn in superClassNames)
            {
                if (!(this.subclassHash.ContainsKey(scn)))
                {   // this superclass was not previously added.
                    List <OntologyClass> scList = new List <OntologyClass>();
                    scList.Add(oClass);
                    this.subclassHash.Add(scn, scList);
                }
                else
                {   // just add this one
                    this.subclassHash[scn].Add(oClass);
                }
            }
        }
示例#3
0
        /*  returns true/false indicating whether the classCompared is a subclass of the classComparedTo */
        public Boolean ClassIsA(OntologyClass classCompared, OntologyClass classComparedTo)
        {
            Boolean retval = false;

            // is the ClassCompared an ClassComparedTo? check recursively....
            if (classCompared == null || classComparedTo == null)    /* do nothing */
            {
            }
            else
            {
                // get all of the needed parents
                List <OntologyClass> allParents = this.GetClassParents(classCompared);
                allParents.Add(classCompared);

                foreach (OntologyClass currentAncestor in allParents)
                {
                    if (currentAncestor.GetNameString(false).ToLower().Equals(classComparedTo.GetNameString(false).ToLower()))
                    {
                        retval = true;
                        break;
                    }
                }
            }
            return(retval);
        }
示例#4
0
        public List <OntologyProperty> GetDescendantPropeties(OntologyClass oClass)
        {
            List <OntologyProperty> retval = new List <OntologyProperty>();
            Dictionary <String, OntologyProperty> tempRetval = new Dictionary <string, OntologyProperty>();

            // get the full list...
            // walk up the parent chain and add all the properties
            List <String> fullChildList = null;

            fullChildList = this.GetSubclassNames(oClass.GetNameString(false), fullChildList);

            // go through the subclass list and gather all the properties
            foreach (String scn in fullChildList)
            {   // add each property from the child class
                foreach (OntologyProperty currProp in this.classHash[scn].GetProperties())
                {
                    tempRetval.Add(currProp.GetNameStr(), currProp);
                }
            }
            // assemble into a single list without repeated values
            foreach (String propKey in tempRetval.Keys)
            {
                retval.Add(tempRetval[propKey]);
            }
            // send it out
            return(retval);
        }