Пример #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="onPath">Role path to be treated</param>
 public ONPath(ONPath onPath)
 {
     if ((onPath as object) == null)
         Roles = new List<string>();
     else
         Roles = new List<string>(onPath.Roles);
 }
Пример #2
0
        public object this[ONPath onPath]
        {
            get
            {
                if ((onPath == null) || (onPath.Count == 0))
                    return this;

                string lRol = onPath.RemoveHead();
                PropertyInfo lProperty = null;

                // Last unique role (like attributes)
                if (onPath.Count == 0)
                {
                    lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>");
                    if (lProperty != null)
                        return (lProperty.GetValue(this, null));
                }

                // Roles
                lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>");
                if (lProperty != null)
                {
                    if (onPath.Count == 0)
                        return (lProperty.GetValue(this, null));
                    else
                        return (lProperty.GetValue(this, null) as ONQuery)[onPath];
                }

                return null;
            }
        }
Пример #3
0
        public static ONPath operator+(ONPath obj1, ONPath obj2)
        {
            ONPath lPath = new ONPath(obj1);

            lPath.Roles.AddRange(obj2.Roles);

            return(lPath);
        }
Пример #4
0
        public void AddSqlAttribute(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type, string domainArgument)
        {
            foreach (ONOrderCriteriaItem lOCItem in OrderCriteriaSqlItem)
                if ((lOCItem.OnPath == onPath) && (lOCItem.Attribute == attribute))
                    return;

            OrderCriteriaSqlItem.Add(new ONOrderCriteriaItem(onPath, facet, attribute, type, domainArgument));
        }
Пример #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="onPath">Role path to be treated</param>
 public ONPath(ONPath onPath)
 {
     if ((onPath as object) == null)
     {
         Roles = new List <string>();
     }
     else
     {
         Roles = new List <string>(onPath.Roles);
     }
 }
Пример #6
0
        public static ONPath operator+(ONPath obj1, string obj2)
        {
            ONPath lPath = new ONPath(obj1);

            char[]   lDelimiter = { '.' };
            string[] lRoles     = obj2.Split(lDelimiter);
            foreach (string lRol in lRoles)
            {
                lPath.Roles.Add(lRol);
            }

            return(lPath);
        }
Пример #7
0
        /// <summary>
        /// Checks if the attributes of a determinate class are visible according to the agent connected
        /// </summary>
        /// <param name="typeInstance">Type fo the class to check the visibility</param>
        /// <param name="attributeVisibility">Attribute to be checked, it is not owned to the class that is being checked</param>
        /// <param name="onContext">Request context </param>
        public static bool IsVisibleInv(Type typeInstance, ONPath attributeVisibility, ONContext onContext)
        {
            if (attributeVisibility.Count == 0)
                return true;

            ONPath lAttributeVisibility = new ONPath(attributeVisibility);
            string lRol = lAttributeVisibility.RemoveHead();

            // Attributes
            if (lAttributeVisibility.Count == 0)
            {
                ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute;
                if (lAttributeAttribute != null)
                    return (lAttributeAttribute.IsVisible(onContext));
            }

            // Roles
            ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute;
            if (lRoleAttribute != null)
            {
                Type lTypeInstanceInv = ONContext.GetType_Instance(lRoleAttribute.Domain);
                return (IsVisible(lTypeInstanceInv, lRoleAttribute.RoleInv, onContext) && IsVisibleInv(lTypeInstanceInv, lAttributeVisibility, onContext));
            }

            return false;
        }
Пример #8
0
 public static bool HasHorizontalVisibility(Type typeInstance, string rolePath, StringCollection activeAgentFacets)
 {
     ONPath lRolePath = new ONPath(rolePath);
     return HasHorizontalVisibility(typeInstance, lRolePath, activeAgentFacets);
 }
Пример #9
0
        public static ONPath operator +(ONPath obj1, ONPath obj2)
        {
            ONPath lPath = new ONPath(obj1);
            lPath.Roles.AddRange(obj2.Roles);

            return lPath;
        }
Пример #10
0
        public static bool HasHorizontalVisibility(Type typeInstance, ONPath rolePath, StringCollection activeAgentFacets)
        {
            ONPath lRolePath = new ONPath(rolePath);
            string lRol = lRolePath.RemoveHead();

            // Attributes
            if (lRolePath.Count == 0)
            {
                ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute;
                if (lAttributeAttribute != null)
                    return false;
            }

            ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute;
            if (lRoleAttribute != null)
            {
                if(lRoleAttribute.HasHorizontalVisibility(activeAgentFacets))
                    return true;

                if (lRolePath.Count == 0)
                    return false;
                else
                    return (HasHorizontalVisibility(ONContext.GetType_Instance(lRoleAttribute.Domain), lRolePath, activeAgentFacets));
            }

            return false;
        }
Пример #11
0
        /// <summary>
        /// Obtains the data type of an atribute. It is used to construcut the response message XML 
        /// </summary>
        /// <param name="typeInstance">Type fo the class to check the visibility</param>
        /// <param name="attributeInDisplay">Attribute to be checked, it is not owned to the class that is being checked</param>
        public static string GetTypeOfAttribute(Type typeInstance, ONPath attributeInDisplay)
        {
            string lRol = attributeInDisplay.RemoveHead();

            // Attributes
            if (attributeInDisplay.Count == 0)
            {
                ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute;
                if (lAttributeAttribute != null)
                    return (lAttributeAttribute.Type);
            }

            // Roles
            ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute;
            if (lRoleAttribute != null)
            {
                if (attributeInDisplay.Count == 0)
                    return "";
                else
                    return GetTypeOfAttribute(ONContext.GetType_Instance(lRoleAttribute.Domain), attributeInDisplay);
            }
            return "";
        }
Пример #12
0
        public static ONPath operator +(ONPath obj1, string obj2)
        {
            ONPath lPath = new ONPath(obj1);

            char[] lDelimiter = {'.'};
            string[] lRoles = obj2.Split(lDelimiter);
            foreach (string lRol in lRoles)
                lPath.Roles.Add(lRol);

            return lPath;
        }
Пример #13
0
 public static string InversePath(Type typeInstance, ONPath rolePath)
 {
     ONPath lRolePath = new ONPath(rolePath);
     string lRol = lRolePath.RemoveHead();
     ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute;
     if (lRoleAttribute != null)
     {
         if (lRolePath.Count == 0)
             return (lRoleAttribute.RoleInv);
         else
             return ((InversePath(ONContext.GetType_Instance(lRoleAttribute.Domain), lRolePath)) + "." + (lRoleAttribute.RoleInv));
     }
     return "";
 }
Пример #14
0
 public virtual string InhGetTargetClassName(ONPath onPath)
 {
     if ((onPath == null) || (onPath.Count == 0))
         return ClassName;
     else
         return "";
 }
Пример #15
0
        /// <summary>
        /// Obtains by reflection if an attribute is optimized
        /// </summary>
        /// <param name="typeInstance">Type of the class</param>
        /// <param name="attributeInDisplay">Attribute to be checked</param>
        public static bool IsOptimized(Type typeInstance, ONPath path)
        {
            if (path == null)
                return true;

            if (path.Count == 0)
                return true;

            ONPath lPath = new ONPath(path);
            string lRol = lPath.RemoveHead();

            // Attributes
            if (lPath.Count == 0)
            {
                ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute;
                if (lAttributeAttribute != null)
                    return (lAttributeAttribute.IsOptimized);
            }

            // Roles
            ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute;
            if (lRoleAttribute != null)
            {
                if (lPath.Count == 0)
                    return (!lRoleAttribute.IsLegacy);
                else if (!lRoleAttribute.IsLegacy)
                    return IsOptimized(ONContext.GetType_Instance(lRoleAttribute.Domain), lPath);
            }

            return false;
        }
Пример #16
0
 //, ONOid agentOid)
 public static bool IsLocal(Type typeInstance, string rolePath)
 {
     ONPath lRolePath = new ONPath(rolePath);
     return IsLocal(typeInstance, lRolePath);
 }
Пример #17
0
        public static bool IsLocal(Type typeInstance, ONPath rolePath)
        {
            if (rolePath.Count == 0)
                return true;

            ONPath lRolePath = new ONPath(rolePath);
            string lRol = lRolePath.RemoveHead();

            // Attributes
            if (lRolePath.Count == 0)
            {
                ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>") as ONAttributeAttribute;
                if (lAttributeAttribute != null)
                    return (!lAttributeAttribute.IsLegacy);
            }

            ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>") as ONRoleAttribute;
            if (lRoleAttribute != null)
            {
                if (lRolePath.Count == 0)
                    return (!lRoleAttribute.IsLegacy);
                else
                    return ((!lRoleAttribute.IsLegacy) && (IsLocal(ONContext.GetType_Instance(lRoleAttribute.Domain), lRolePath)));
            }

            return false;
        }
Пример #18
0
 /// <summary>
 /// Construction the part of SQL sentence that is Oder By 
 /// </summary>
 /// <param name="onPath">Role path in case that the attribute is from another class</param>
 /// <param name="facet">Name of the class that has the attribute to be fixed in SQL sentence</param>
 /// <param name="attribute">Name of the attribute that is needed to the sort</param>
 /// <param name="type">Direction of the order. Could be ascending o descending</param>
 public void AddSqlAttribute(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type)
 {
     AddSqlAttribute(onPath, facet, attribute, type, "");
 }
Пример #19
0
        public ONSimpleType DisplaysetItemValue(ONPath displaysetItem)
        {
            if ((displaysetItem == null) || (displaysetItem.Count == 0))
                return null;

            ONPath lDisplaysetItem = new ONPath(displaysetItem);
            string lRol = lDisplaysetItem.RemoveHead();
            PropertyInfo lProperty = null;
            MethodInfo lMethod = null;
            string methodName = lRol + "RoleHV";

            // Last unique role (like attributes)
            if (lDisplaysetItem.Count == 0)
            {
                lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>");
                if (lProperty != null)
                    return (lProperty.GetValue(this, null)) as ONSimpleType;
            }

            // Roles
            lMethod = GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
            if (lMethod != null)
            {
                ONCollection lCollection = lMethod.Invoke(this, null) as ONCollection;
                if (lCollection.Count <= 0)
                {
                    return ONSimpleType.Null(ONInstance.GetTypeOfAttribute(GetType(), displaysetItem));
                }

                ONInstance lInstance = lCollection[0];

                return lInstance.DisplaysetItemValue(lDisplaysetItem);
            }

            return null;
        }
Пример #20
0
        public object this[ONPath onPath]
        {
            get
            {
                if ((onPath == null) || (onPath.Count == 0))
                    return this;

                // Search in preloaded related attributes
                if (RelatedValues.ContainsKey(onPath.Path))
                    return RelatedValues[onPath.Path];

                string lRol = onPath.RemoveHead();
                PropertyInfo lProperty = null;

                // Last unique role (like attributes)
                if (onPath.Count == 0)
                {
                    lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONAttributeAttribute), "<Attribute>" + lRol + "</Attribute>");
                    if (lProperty != null)
                        return (lProperty.GetValue(this, null));
                }

                // Roles
                lProperty = ONContext.GetPropertyInfoWithAttribute(GetType(), typeof(ONRoleAttribute), "<Role>" + lRol + "</Role>");
                if (lProperty != null)
                {
                    if (onPath.Count == 0)
                        return (lProperty.GetValue(this, null));
                    else
                        return (lProperty.GetValue(this, null) as ONCollection)[onPath];
                }

                return null;
            }
        }
Пример #21
0
        public static string GetTargetClass(ONContext onContext, Type typeInstance, ONPath path)
        {
            foreach (string lRole in path.Roles)
            {
                // Attributes
                ONAttributeAttribute lAttributeAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONAttributeAttribute), "<Attribute>" + lRole + "</Attribute>") as ONAttributeAttribute;

                if (lAttributeAttribute != null)
                    return (lAttributeAttribute.FacetOfField);

                // Roles
                ONRoleAttribute lRoleAttribute = ONContext.GetAttributeInProperty(typeInstance, typeof(ONRoleAttribute), "<Role>" + lRole + "</Role>") as ONRoleAttribute;

                if (lRoleAttribute != null)
                    typeInstance = ONContext.GetType_Instance(lRoleAttribute.Domain);
                else
                    break;
            }

            if (typeInstance != null)
            {
                object[] lParameters = new object[1];
                lParameters[0] = onContext;

                ONInstance lInstance = Activator.CreateInstance(typeInstance, lParameters) as ONInstance;
                return lInstance.ClassName;
            }
            else
                return "";
        }