Ejemplo n.º 1
0
        public bool IsAllowedUnder(JEVisObject otherObject)
        {
            bool classIsAllowedUnderClass = GetJEVisClass().IsAllowedUnder(otherObject.GetJEVisClass());
            bool isDirectory          = this.ds.GetJEVisClass("Directory").getHeirs().contains(this.GetJEVisClass());
            bool isUnique             = GetJEVisClass().IsUnique();
            bool isAlreadyUnderParent = false;

            if (otherObject.GetParents() != null)
            {
                foreach (JEVisObject child in otherObject.GetChildren())
                {
                    try
                    {
                        if (child.GetJEVisClassName().Equals(GetJEVisClassName()))
                        {
                            isAlreadyUnderParent = true;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            /**
             * first check if its allowed to be created under other object class
             */
            if (classIsAllowedUnderClass)
            {
                if (!isUnique)
                {
                    /**
                     * if its not unique its always allowed to be created
                     */
                    return(true);
                }
                else /**
                      *  if it is a directory and its of the same class of its parent its allowed to be created
                      */if (!isAlreadyUnderParent)
                {
                    /**
                     * if it is unique and not already created its allowed to be created
                     */
                    return(true);
                }
                else
                {
                    return(isDirectory && otherObject.GetJEVisClassName().Equals(GetJEVisClassName()));
                }
            }

            return(false);
        }