Example #1
0
        /**
         * TODO: this seems to not work properly needs testing
         *
         * @param jclass
         * @param inherit Include inherited classes
         * @return
         * @throws JEVisException
         */

        public List <JEVisObject> GetChildren(JEVisClass jclass, bool inherit)
        {
            List <JEVisObject> filterList = new List <JEVisObject>();

            foreach (JEVisObject obj in GetChildren())
            {
                try
                {
                    JEVisClass oClass = obj.GetJEVisClass();
                    if (oClass != null && oClass.Equals(jclass))
                    {
                        filterList.Add(obj);
                    }
                    else if (oClass != null)
                    {
                        HashSet <JEVisClass> inheritanceClasses = GetInheritanceClasses(new HashSet <JEVisClass>(), oClass);
                        foreach (JEVisClass curClass in inheritanceClasses)
                        {
                            if (curClass.Equals(jclass))
                            {
                                filterList.Add(obj);
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
            }
            logger.Debug(string.Format("[{0}] getChildren: \n{1}\n", GetId(), filterList));

            return(filterList);
        }
 public JEVisClass GetOtherClass(JEVisClass jclass)
 {
     if (GetStart().Equals(jclass))
     {
         return(GetEnd());
     }
     else
     {
         return(GetStart());
     }
 }
Example #3
0
 public int CompareTo(JEVisClass o)
 {
     try
     {
         return GetName().CompareTo(o.GetName());
     }
     catch (JEVisException ex)
     {
         return 1;
     }
 }
Example #4
0
        public JEVisObject BuildObject(String name, JEVisClass jevisClass)
        {
            logger.Debug(string.Format("buildObject: {0} {1}", name, jevisClass.GetName()));
            JsonObject newJson = new JsonObject();

            newJson.SetName(name);
            newJson.SetJEVisClass(jevisClass.GetName());
            newJson.SetParent(GetId());


            return(new JEVisObjectWS(this.ds, newJson));
        }
Example #5
0
 public bool IsAllowedUnder(JEVisClass jevisClass)
 {
     List<JEVisClass> valid = GetValidParents();
     foreach (JEVisClass pClass in valid)
     {
         if (pClass.GetName().Equals(jevisClass.GetName()))
         {
             return true;
         }
     }
     return false;
 }
Example #6
0
        public JEVisClassRelationship BuildRelationship(JEVisClass jclass, int type, int direction)
        {
            JEVisClassRelationship rel;
            if (direction == JEVisConstants.Direction.FORWARD)
            {//this to otherClass
                rel = ds.buildClassRelationship(this.GetName(), jclass.GetName(), type);
            }
            else
            {
                rel = ds.buildClassRelationship(jclass.GetName(), this.GetName(), type);
            }

            return rel;
        }
Example #7
0
 private HashSet <JEVisClass> GetInheritanceClasses(HashSet <JEVisClass> hashSet, JEVisClass obj)
 {
     try
     {
         JEVisClass inheritance = obj.GetInheritance();
         if (inheritance == null)
         {
             return(hashSet);
         }
         else
         {
             hashSet.Add(inheritance);
             return(GetInheritanceClasses(hashSet, inheritance));
         }
     }
     catch (JEVisException ex)
     {
         logger.Error(ex);
     }
     return(hashSet);
 }
Example #8
0
        override public bool Equals(Object o)
        {
            try
            {
                /**
                 * cast needs to be removed
                 */

                if (o.GetType() is JEVisClass)
                {
                    JEVisClass obj = (JEVisClass)o;
                    if (obj.GetName().Equals(GetName()))
                    {
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Info("error, cannot compare objects");
                return false;
            }
            return false;
        }