Exemplo n.º 1
0
        /// <summary>
        /// Obtains by reflection the name of an attribute in the database
        /// </summary>
        /// <param name="typeInstance">Type of the class</param>
        /// <param name="attributeInDisplay">Attribute to be checked</param>
        public static string GetFieldNameOfAttribute(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.FieldName);
                }
            }

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

            if (lRoleAttribute != null)
            {
                if (attributeInDisplay.Count == 0)
                {
                    return("");
                }
                else
                {
                    return(GetFieldNameOfAttribute(ONContext.GetType_Instance(lRoleAttribute.Domain), attributeInDisplay));
                }
            }
            return("");
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </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 ONOrderCriteriaItem(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type)
 {
     OnPath    = onPath;
     Facet     = facet;
     Attribute = attribute;
     Type      = type;
 }
Exemplo n.º 3
0
        private static string PasajeroAeronaveRoleAddSql(ONSqlSelect onSql, JoinType joinType, string facet, ONPath onPath, ONPath processedPath, string role, bool force, bool isLinkedTo)
        {
            ONPath lOnPath = new ONPath(processedPath);

            lOnPath += role;

            //Source table
            string lAliasProcessed = onSql.GetAlias("Aeronave", processedPath, isLinkedTo);

            if (lAliasProcessed == "")
            {
                force           = false;
                lAliasProcessed = onSql.CreateAlias(joinType, lAliasProcessed, CtesBD.TBL_AERONAVE, processedPath, "Aeronave", force, isLinkedTo);
            }

            //Target table
            string lAlias = onSql.GetAlias("PasajeroAeronave", lOnPath, isLinkedTo);

            if (lAlias == "")
            {
                force  = false;
                lAlias = onSql.CreateAlias(joinType, lAliasProcessed, CtesBD.TBL_PASAJEROAERONAVE, lOnPath, "PasajeroAeronave", force, isLinkedTo);
                onSql.AddAliasWhere(lAlias, lAliasProcessed + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + "=" + lAlias + "." + CtesBD.FLD_PASAJEROAERONAVE_FK_AERONAVE_1);
            }
            //Target path
            if ((((object)onPath == null) || (onPath.Count == 0)) && (string.Compare("PasajeroAeronave", facet, true) == 0) && (!force))
            {
                return(lAlias);
            }

            return(PasajeroAeronaveData.AddPath(onSql, joinType, facet, onPath, lOnPath, "", force, isLinkedTo));
        }
 /// <summary>
 /// Constructor
 /// </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 ONOrderCriteriaItem(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type)
 {
     OnPath = onPath;
     Facet = facet;
     Attribute = attribute;
     Type = type;
 }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public ONOrderCriteriaItem(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type, string domainArgument)
 {
     OnPath         = onPath;
     Facet          = facet;
     Attribute      = attribute;
     Type           = type;
     DomainArgument = domainArgument;
 }
 public ONOrderCriteriaItem(ONPath onPath, string facet, string attribute, OrderByTypeEnumerator type, string domainArgument)
 {
     OnPath = onPath;
     Facet = facet;
     Attribute = attribute;
     Type = type;
     DomainArgument = domainArgument;
 }
Exemplo n.º 8
0
        ///<summary> This method adds the order criteria to the SQL statement </summary>
        ///<param name = "onSql"> This parameter represents the SQL component </param>
        ///<param name = "comparer"> This parameter has all the information refering to the order criteria to add to SQL statement</param>
        /// <param name="startRowOid">This parameter has the OID necessary to start the search</param>
        /// <param name="blockSize">This parameter represents the number of instances to be returned</param>
        protected override void AddOrderCriteria(ONSqlSelect onSql, ONOrderCriteria comparer, ONOid startRowOid, int blockSize, ONPath initialPath)
        {
            //Initilizate StartRow
            AeronaveInstance lInstance = null;

            if (startRowOid != null)
            {
                lInstance     = new AeronaveInstance(OnContext);
                lInstance.Oid = startRowOid as AeronaveOid;
            }

            //Default OrderCriteria
            if (comparer == null)
            {
                string lAlias = onSql.GetAlias("Aeronave", initialPath);
                if (lInstance != null)
                {
                    onSql.AddOrderBy(lAlias, CtesBD.FLD_AERONAVE_ID_AERONAVE, OrderByTypeEnumerator.Asc, lInstance.Oid.Id_AeronaveAttr);
                }
                else
                {
                    onSql.AddOrderBy(lAlias, CtesBD.FLD_AERONAVE_ID_AERONAVE, OrderByTypeEnumerator.Asc, null);
                }
                return;
            }

            //Add OrderCriteria
            bool lUseStartRow = (!comparer.InMemory);

            foreach (ONOrderCriteriaItem lOrderCriteriaItem in comparer.OrderCriteriaSqlItem)
            {
                ONPath lPath = new ONPath(lOrderCriteriaItem.OnPath);
                if ((lInstance != null) && (lUseStartRow))
                {
                    ONSimpleType lAttrStartRow = null;

                    if (lPath.Path == "")
                    {
                        lAttrStartRow = lInstance[lOrderCriteriaItem.Attribute] as ONSimpleType;
                    }
                    else
                    {
                        ONCollection lCollection = (lInstance[lPath.Path] as ONCollection);
                        if ((lCollection != null) && (lCollection.Count > 0))
                        {
                            lAttrStartRow = lCollection[0][lOrderCriteriaItem.Attribute] as ONSimpleType;
                        }
                    }
                    onSql.AddOrderBy(AeronaveData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, lAttrStartRow);
                    lUseStartRow = (lAttrStartRow != null);
                }
                else
                {
                    onSql.AddOrderBy(AeronaveData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, null);
                }
            }
            return;
        }
Exemplo n.º 9
0
 public ONOid this[ONPath path]
 {
     get
     {
         return mLinkedToList[path];
     }
     set
     {
         mLinkedToList.Add(path, value);
     }
 }
Exemplo n.º 10
0
 public ONOid this [ONPath path]
 {
     get
     {
         return(mLinkedToList[path]);
     }
     set
     {
         mLinkedToList.Add(path, value);
     }
 }
Exemplo n.º 11
0
        public QueryByRelatedFilter(string className, ONPath onPath, ONOid relatedOid)
            : base(className, "QueryByRelated")
        {
            ONPath = onPath;
              mRelatedOid = relatedOid;

              Type lDataType = ONContext.GetType_Data(ClassName);
              InMemory = false;
              InData = !lDataType.IsSubclassOf(typeof(ONLVData));
              InLegacy = lDataType.IsSubclassOf(typeof(ONLVData));
        }
Exemplo n.º 12
0
 public virtual string InhGetTargetClassName(ONPath onPath)
 {
     if ((onPath == null) || (onPath.Count == 0))
     {
         return(ClassName);
     }
     else
     {
         return("");
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Constructor for LeftJoin sentences
        /// </summary>
        /// <param name="joinType">Type of join</param>
        /// <param name="fatherAlias">Father alias</param>
        /// <param name="alias">Alias name</param>
        /// <param name="table">Table name</param>
        /// <param name="onPath">Sql to solve</param>
        public ONSqlAlias(JoinType joinType, ONSqlAlias fatherAlias, string alias, string table, ONPath onPath, string facet)
        {
            JoiningType = joinType;
            Alias = alias;
            Table = table;
            OnPath = onPath;
            Facet = facet;
            FatherAlias = fatherAlias;

            if (FatherAlias != null)
                FatherAlias.ChildAlias.Add(this);
        }
Exemplo n.º 14
0
        public QueryByRelatedFilter(string className, ONPath onPath, ONOid relatedOid)
            : base(className, "QueryByRelated")
        {
            ONPath      = onPath;
            mRelatedOid = relatedOid;

            Type lDataType = ONContext.GetType_Data(ClassName);

            InMemory = false;
            InData   = !lDataType.IsSubclassOf(typeof(ONLVData));
            InLegacy = lDataType.IsSubclassOf(typeof(ONLVData));
        }
Exemplo n.º 15
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));
        }
Exemplo n.º 16
0
        public static string GetTargetClassName(ONPath onPath)
        {
            ONPath lOnPath = new ONPath(onPath);

            if (lOnPath.Count == 0)
            {
                return("Administrador");
            }

            string lRol = lOnPath.RemoveHead();

            return("");
        }
Exemplo n.º 17
0
        /// <summary>
        /// Search table of the path and facet
        /// </summary>
        /// <param name="facet">Facet name</param>
        /// <param name="onPath">Path to solve</param>
        /// <returns>Table name</returns>
        public string GetTable(string facet, ONPath onPath)
        {
            ONSqlPath  lOnSqlPath  = new ONSqlPath(onPath, facet);
            ONSqlAlias lOnSqlAlias = GetOnSqlAlias(lOnSqlPath);

            // Path no exist
            if (lOnSqlAlias == null)
            {
                return("");
            }

            return(lOnSqlAlias.Table);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Search alias
        /// </summary>
        /// <param name="facet">Facet name</param>
        /// <param name="onPath">Path to solve</param>
        /// <param name="isLinkedTo">The alias belongs to a role in a linked To element</param>
        /// <returns>Alias string</returns>
        public string GetAlias(string facet, ONPath onPath, bool isLinkedTo)
        {
            ONSqlPath  lOnSqlPath  = new ONSqlPath(onPath, facet, isLinkedTo);
            ONSqlAlias lOnSqlAlias = GetOnSqlAlias(lOnSqlPath);

            // Path no exist
            if (lOnSqlAlias == null)
            {
                return("");
            }

            return(lOnSqlAlias.Alias);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Constructor for LeftJoin sentences
        /// </summary>
        /// <param name="joinType">Type of join</param>
        /// <param name="fatherAlias">Father alias</param>
        /// <param name="alias">Alias name</param>
        /// <param name="table">Table name</param>
        /// <param name="onPath">Sql to solve</param>
        public ONSqlAlias(JoinType joinType, ONSqlAlias fatherAlias, string alias, string table, ONPath onPath, string facet)
        {
            JoiningType = joinType;
            Alias       = alias;
            Table       = table;
            OnPath      = onPath;
            Facet       = facet;
            FatherAlias = fatherAlias;

            if (FatherAlias != null)
            {
                FatherAlias.ChildAlias.Add(this);
            }
        }
        /// <summary>This method adds to the SQL statement any path that appears in a formula</summary>
        /// <param name="onSql">This parameter has the current SQL statement</param>
        /// <param name="joinType">This parameter has the type of join</param>
        /// <param name="facet">First class, the beginning of the path</param>
        /// <param name="onPath">Path to add to SQL statement</param>
        /// <param name="processedOnPath">Path pocessed until the call of this method</param>
        /// <param name="initialClass">Domain of the object valued argument, object valued filter variables or AGENT when it should be necessary</param>
        /// <param name="forceLastAlias">Create almost the last alias in the sql</param>
        public static string AddPath(ONSqlSelect onSql, JoinType joinType, string facet, ONPath onPath, ONPath processedOnPath, string initialClass, bool forceLastAlias)
        {
            // initialClass is used for Object-valued arguments, object-valued filter variables, agent instance, ...
            ONPath lProcessedOnPath = new ONPath(processedOnPath);
            ONPath lOnPath = new ONPath(onPath);

            // Calculate processed path
            string lRole = lOnPath.RemoveHead() as string;
            lProcessedOnPath += lRole;

            // Search Path
            if (lOnPath.Count == 0)
            {
                string lAlias = onSql.GetAlias(facet, lProcessedOnPath);
                if ((lAlias != "") && (!forceLastAlias))
                    return (lAlias);
            }
             			// Create path
            if (initialClass == "") // Simple paths
            {
                if (string.Compare(lRole, "NaveNodriza", true) == 0)
                    return NaveNodrizaData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias);
                if (string.Compare(lRole, "Aeronave", true) == 0)
                    return AeronaveData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias);
                if (string.Compare(lRole, "Pasajero", true) == 0)
                    return PasajeroData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias);
                if (string.Compare(lRole, "PasajeroAeronave", true) == 0)
                    return PasajeroAeronaveData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias);
                if (string.Compare(lRole, "Revision", true) == 0)
                    return RevisionData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias);
                if (string.Compare(lRole, "RevisionPasajero", true) == 0)
                    return RevisionPasajeroData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias);
                if (string.Compare(lRole, "Administrador", true) == 0)
                    return AdministradorData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias);
            }

            // Solve path with initialPath
            object[] lParameters = new object[6];
            lParameters[0] = onSql;
            lParameters[1] = facet;
            lParameters[2] = lOnPath;
            lParameters[3] = lProcessedOnPath;
            lParameters[4] = "";
            lParameters[5] = forceLastAlias;

            return ONContext.InvoqueMethod(ONContext.GetType_Data(initialClass), "AddPath", lParameters) as string;
        }
Exemplo n.º 21
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);
            }
        }
Exemplo n.º 22
0
        public static string GetTargetClassName(ONPath onPath)
        {
            ONPath lOnPath = new ONPath(onPath);

            if (lOnPath.Count == 0)
            {
                return("Aeronave");
            }

            string lRol = lOnPath.RemoveHead();

            if (string.Compare(lRol, "PasajeroAeronave", true) == 0)
            {
                return(PasajeroAeronaveData.GetTargetClassName(lOnPath));
            }

            return("");
        }
Exemplo n.º 23
0
 /// <summary>This method adds to the SQL statement the part that fixes the instance</summary>
 /// <param name="onSql">This parameter has the current SQL statement</param>
 /// <param name="onPath">Path to add to SQL statement</param>
 /// <param name="processedOnPath">Path pocessed until the call of this method</param>
 /// <param name="oid">OID to fix the instance in the SQL statement</param>
 /// <param name="isLinkedTo">The alias belongs to a role in a linked To element</param>
 public static void FixInstance(ONSqlSelect onSql, ONPath onPath, ONPath processedOnPath, AeronaveOid oid, bool isLinkedTo)
 {
     if ((onPath != null) && (string.Compare(onPath.Path, "agent", true) == 0))
     {
         if (onSql.GetParameter("agent") == null)
         {
             string lAlias = AddPath(onSql, JoinType.InnerJoin, "Aeronave", onPath, processedOnPath, "Aeronave", false, isLinkedTo);
             onSql.AddWhere(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + " = ?");
             onSql.AddWhereParameter("agent", oid.Id_AeronaveAttr);
         }
     }
     else
     {
         string lAlias = AddPath(onSql, JoinType.InnerJoin, "Aeronave", onPath, processedOnPath, "", false, isLinkedTo);
         onSql.AddWhere(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + " = ?");
         onSql.AddWhereParameter("", oid.Id_AeronaveAttr);
     }
 }
Exemplo n.º 24
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("");
        }
Exemplo n.º 25
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);
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Fix related instance
        /// </summary>
        /// <param name="onSql">Sentence SQL to be executed</param>
        /// <param name="linkedTo">List to reach the class to retrieve the related instance</param>
        protected bool AddLinkedTo(ONSqlSelect onSql, ONLinkedToList linkedTo)
        {
            // Fix related instance
            foreach (KeyValuePair <ONPath, ONOid> lDictionaryEntry in linkedTo)
            {
                ONPath lPath = lDictionaryEntry.Key as ONPath;
                ONOid  lOID  = lDictionaryEntry.Value as ONOid;

                string lAliasRelated = InhAddPath(onSql, lOID.ClassName, lPath, "", true);

                // Check Visibility
                if (!ONInstance.IsVisibleInv(ONContext.GetType_Instance(ClassName), lPath, OnContext))
                {
                    return(false);
                }

                ONDBData lData = ONContext.GetComponent_Data(lOID.ClassName, OnContext) as ONDBData;
                lData.InhFixInstance(onSql, null, lPath, lOID, true);
            }

            return(true);
        }
Exemplo n.º 28
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("");
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Treatment the part of the XML message that has links items
        /// </summary>
        /// <param name="xmlReader">Variable with the message XML to be treated</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        public ONLinkedToList GetLinkedTo(XmlReader xmlReader, double dtdVersion)
        {
            ONLinkedToList lLinkedToList = new ONLinkedToList();

            if (!xmlReader.IsStartElement("LinkedTo"))
            {
                return(lLinkedToList);
            }

            if (xmlReader.IsEmptyElement)
            {
                xmlReader.ReadStartElement("LinkedTo");
                return(lLinkedToList);
            }

            xmlReader.ReadStartElement("LinkedTo");
            while (xmlReader.IsStartElement("Link.Item"))
            {
                ONPath lPath = new ONPath(xmlReader.GetAttribute("Role"));
                xmlReader.ReadStartElement("Link.Item");

                object[] lParam = new object[2];
                lParam[0] = xmlReader;
                lParam[1] = dtdVersion;

                string lClassInstance = xmlReader.GetAttribute("Class");
                ONOid  lInstance      = ONContext.InvoqueMethod(ONContext.GetType_XML(lClassInstance), "XML2ON", lParam) as ONOid;

                lLinkedToList[lPath] = lInstance;

                xmlReader.ReadEndElement();         // Link.Item
            }
            xmlReader.ReadEndElement();             // LinkedTo

            return(lLinkedToList);
        }
Exemplo n.º 30
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);
        }
Exemplo n.º 31
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);
        }
Exemplo n.º 32
0
 private static string AeronaveFacetAddSql(JoinType joinType, ONSqlSelect onSql, ONPath onPath, bool force)
 {
     return AeronaveFacetAddSql(joinType, onSql, onPath, force, false);
 }
Exemplo n.º 33
0
 private static string AeronaveFacetAddSql(ONSqlSelect onSql, ONPath onPath)
 {
     return AeronaveFacetAddSql(JoinType.InnerJoin, onSql, onPath, false, false);
 }
Exemplo n.º 34
0
        ///<summary> This method adds the order criteria to the SQL statement </summary>
        ///<param name = "onSql"> This parameter represents the SQL component </param>
        ///<param name = "comparer"> This parameter has all the information refering to the order criteria to add to SQL statement</param>
        /// <param name="startRowOid">This parameter has the OID necessary to start the search</param>
        /// <param name="blockSize">This parameter represents the number of instances to be returned</param>
        protected override void AddOrderCriteria(ONSqlSelect onSql, ONOrderCriteria comparer, ONOid startRowOid, int blockSize, ONPath initialPath)
        {
            //Initilizate StartRow
            AeronaveInstance lInstance = null;
            if (startRowOid != null)
            {
                lInstance = new AeronaveInstance(OnContext);
                lInstance.Oid = startRowOid as AeronaveOid;
            }

            //Default OrderCriteria
            if (comparer == null)
            {
                string lAlias = onSql.GetAlias("Aeronave", initialPath);
                if (lInstance != null)
                {
                    onSql.AddOrderBy(lAlias, CtesBD.FLD_AERONAVE_ID_AERONAVE, OrderByTypeEnumerator.Asc, lInstance.Oid.Id_AeronaveAttr);
                }
                else
                {
                    onSql.AddOrderBy(lAlias, CtesBD.FLD_AERONAVE_ID_AERONAVE, OrderByTypeEnumerator.Asc, null);
                }
                return;
            }

            //Add OrderCriteria
            bool lUseStartRow = (!comparer.InMemory);
            foreach (ONOrderCriteriaItem lOrderCriteriaItem in comparer.OrderCriteriaSqlItem)
            {
                ONPath lPath = new ONPath(lOrderCriteriaItem.OnPath);
                if((lInstance != null) && (lUseStartRow))
                {
                    ONSimpleType lAttrStartRow = null;

                    if (lPath.Path == "")
                        lAttrStartRow = lInstance[lOrderCriteriaItem.Attribute] as ONSimpleType;
                    else
                    {
                        ONCollection lCollection = (lInstance[lPath.Path] as ONCollection);
                        if((lCollection != null) && (lCollection.Count > 0))
                            lAttrStartRow = lCollection[0][lOrderCriteriaItem.Attribute] as ONSimpleType;
                    }
                    onSql.AddOrderBy(AeronaveData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, lAttrStartRow);
                    lUseStartRow = (lAttrStartRow != null);
                }
                else
                    onSql.AddOrderBy(AeronaveData.AddPath(onSql, JoinType.LeftJoin, lOrderCriteriaItem.Facet, lPath, null, lOrderCriteriaItem.DomainArgument, false), lOrderCriteriaItem.Attribute, lOrderCriteriaItem.Type, null);
            }
            return;
        }
Exemplo n.º 35
0
 public override string InhRetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
 {
     return RetrieveInstances(onSql, displaySet, onPath, onContext);
 }
Exemplo n.º 36
0
 public override string InhGetTargetClassName(ONPath onPath)
 {
     return GetTargetClassName(onPath);
 }
Exemplo n.º 37
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="onPath">Path to solve</param>
 /// <param name="facet">Facet of the path</param>
 /// <param name="islinkedTo">The path is used in a linked to element</param>
 public ONSqlPath(ONPath onPath, string facet, bool islinkedTo)
 {
     OnPath = onPath;
     Facet = facet;
     IslinkedTo = islinkedTo;
 }
Exemplo n.º 38
0
 /// <summary>This method adds to the SQL statement any path that appears in a formula</summary>
 /// <param name="onSql">This parameter has the current SQL statement</param>
 /// <param name="joinType">This parameter has the type of join</param>
 /// <param name="facet">First class, the beginning of the path</param>
 /// <param name="onPath">Path to add to SQL statement</param>
 /// <param name="processedOnPath">Path pocessed until the call of this method</param>
 /// <param name="initialClass">Domain of the object valued argument, object valued filter variables or AGENT when it should be necessary</param>
 /// <param name="forceLastAlias">Create almost the last alias in the sql</param>
 public static string AddPath(ONSqlSelect onSql, JoinType joinType, string facet, ONPath onPath, ONPath processedOnPath, string initialClass, bool forceLastAlias)
 {
     return AddPath(onSql, joinType, facet, onPath, processedOnPath, initialClass, forceLastAlias, false);
 }
Exemplo n.º 39
0
        private static string AeronaveFacetAddSql(JoinType joinType, ONSqlSelect onSql, ONPath onPath, bool force, bool isLinkedTo)
        {
            //Target table
            string lAliasFacet = "";
            string lAlias = onSql.CreateAlias(joinType, "", CtesBD.TBL_AERONAVE, onPath, "Aeronave", false, isLinkedTo);

            // Load facet from 'Aeronave' to 'Aeronave'
            lAliasFacet = onSql.GetAlias("Aeronave", onPath, isLinkedTo);
            if ((lAliasFacet == "") || force)
            {
                if (force)
                    lAliasFacet = onSql.CreateAlias(joinType, "", CtesBD.TBL_AERONAVE, onPath, "Aeronave", force, isLinkedTo);
                else
                    lAliasFacet = onSql.CreateAlias(joinType, lAlias, CtesBD.TBL_AERONAVE, onPath, "Aeronave", force, isLinkedTo);
                onSql.AddAliasWhere(lAliasFacet, lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + " = " + lAliasFacet + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE);
            }
            return lAliasFacet;
        }
Exemplo n.º 40
0
 /// <summary> This method adds the order criteria to the SQL statement </summary>
 /// <param name="onSql"> This parameter represents the SQL component </param>
 /// <param name="comparer"> This parameter has all the information refering to the order criteria to add to SQL statement</param>
 /// <param name="startRowOid">This parameter has the OID necessary to start the search</param>
 /// <param name="blockSize">This parameter represents the number of instances to be returned</param>
 /// <param name="initialPath"> This parameter has the path of the instances reached in a For All</param>
 protected virtual void AddOrderCriteria(ONSqlSelect onSql, ONOrderCriteria comparer, ONOid startRowOid, int blockSize, ONPath initialPath)
 {
 }
Exemplo n.º 41
0
 public override string InhRetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
 {
     return(RetrieveInstances(onSql, displaySet, onPath, onContext));
 }
Exemplo n.º 42
0
 public override string InhGetTargetClassName(ONPath onPath)
 {
     return(GetTargetClassName(onPath));
 }
Exemplo n.º 43
0
 /// <summary>This method adds to the SQL statement the part that fixes the instance</summary>
 /// <param name="onSql">This parameter has the current SQL statement</param>
 /// <param name="onPath">Path to add to SQL statement</param>
 /// <param name="processedOnPath">Path pocessed until the call of this method</param>
 /// <param name="oid">OID to fix the instance in the SQL statement</param>
 /// <param name="isLinkedTo">The alias belongs to a role in a linked To element</param>
 public static void FixInstance(ONSqlSelect onSql, ONPath onPath, ONPath processedOnPath, AeronaveOid oid, bool isLinkedTo)
 {
     if ((onPath != null) && (string.Compare(onPath.Path, "agent", true) == 0))
     {
         if (onSql.GetParameter("agent") == null)
         {
             string lAlias = AddPath(onSql, JoinType.InnerJoin, "Aeronave", onPath, processedOnPath, "Aeronave", false, isLinkedTo);
             onSql.AddWhere(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + " = ?");
             onSql.AddWhereParameter("agent", oid.Id_AeronaveAttr);
         }
     }
     else
     {
         string lAlias = AddPath(onSql, JoinType.InnerJoin, "Aeronave", onPath, processedOnPath, "", false, isLinkedTo);
         onSql.AddWhere(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + " = ?");
         onSql.AddWhereParameter("", oid.Id_AeronaveAttr);
     }
 }
Exemplo n.º 44
0
        /// <summary>This method adds to the SQL statement any path that appears in a formula</summary>
        /// <param name="onSql">This parameter has the current SQL statement</param>
        /// <param name="joinType">This parameter has the type of join</param>
        /// <param name="facet">First class, the beginning of the path</param>
        /// <param name="onPath">Path to add to SQL statement</param>
        /// <param name="processedOnPath">Path pocessed until the call of this method</param>
        /// <param name="initialClass">Domain of the object valued argument, object valued filter variables or AGENT when it should be necessary</param>
        /// <param name="forceLastAlias">Create almost the last alias in the sql</param>
        /// <param name="isLinkedTo">The alias belongs to a role in a linked To element</param>
        public static string AddPath(ONSqlSelect onSql, JoinType joinType, string facet, ONPath onPath, ONPath processedOnPath, string initialClass, bool forceLastAlias, bool isLinkedTo)
        {
            // initialClass is used for Object-valued arguments, object-valued filter variables, agent instance, ...
            ONPath lProcessedOnPath = new ONPath(processedOnPath);
            ONPath lOnPath = new ONPath(onPath);
            bool lOnPathExist = true;
            object[] lParameters = new object[8];

            if (initialClass != "")
            {
                string lRol = lOnPath.RemoveHead();
                lProcessedOnPath += lRol;
                // Solve path with initialPath
                lParameters[0] = onSql;
                lParameters[1] = joinType;
                lParameters[2] = facet;
                lParameters[3] = lOnPath;
                lParameters[4] = lProcessedOnPath;
                lParameters[5] = "";
                lParameters[6] = forceLastAlias;
                lParameters[7] = isLinkedTo;

                return ONContext.InvoqueMethod(ONContext.GetType_Data(initialClass), "AddPath", lParameters) as string;

            }

            // Search max solved path
            ONPath lMaxSolvedPath = new ONPath(onPath);
            string lMaxSolvedPathDomain = facet;
            while ((lMaxSolvedPath.Count > 0) && (onSql.GetAlias(lMaxSolvedPathDomain, lProcessedOnPath + lMaxSolvedPath, isLinkedTo) == ""))
            {
                lMaxSolvedPath.RemoveTail();
                lMaxSolvedPathDomain = GetTargetClassName(lMaxSolvedPath);
            }
            if (lMaxSolvedPath.Count > 0)
            {
                lProcessedOnPath += lMaxSolvedPath;
                for (int i = 0; i < lMaxSolvedPath.Count; i++)
                    lOnPath.RemoveHead();

                lParameters[0] = onSql;
                lParameters[1] = joinType;
                lParameters[2] = facet;
                lParameters[3] = lOnPath;
                lParameters[4] = lProcessedOnPath;
                lParameters[5] = "";
                lParameters[6] = forceLastAlias;
                lParameters[7] = isLinkedTo;

                return ONContext.InvoqueMethod(ONContext.GetType_Data(lMaxSolvedPathDomain), "AddPath", lParameters) as string;
            }

            // Create inheritance path
            if ((onPath == null) || (onPath.Count == 0))
            {
                if (forceLastAlias)
                    return AeronaveFacetAddSql(joinType, onSql, processedOnPath, forceLastAlias, isLinkedTo);

                if ((processedOnPath == null) || (processedOnPath.Count == 0))
                    return (onSql.CreateAlias(joinType, "", CtesBD.TBL_AERONAVE, null, "Aeronave", false, isLinkedTo));
                else
                    return (onSql.CreateAlias(joinType, "", CtesBD.TBL_AERONAVE, processedOnPath, "Aeronave", false, isLinkedTo));
            }

            // Calculate processed path
            string lRole = lOnPath.RemoveHead() as string;
            lProcessedOnPath += lRole;

            // Search Path
            if (lOnPath.Count == 0)
            {
                string lAlias = onSql.GetAlias(facet, lProcessedOnPath, isLinkedTo);
                if ((lAlias != "") && (!forceLastAlias))
                    return (lAlias);
                else
                    lOnPathExist = false;
            }
            else
            {
                string lTargetClass = GetTargetClassName(new ONPath(lRole));

                // Agent & OV Argument Control
                if ((lTargetClass == "") && (initialClass != ""))
                    lTargetClass = initialClass;

                string lAlias = onSql.GetAlias(lTargetClass, lProcessedOnPath, isLinkedTo);
                if (lAlias == "")
                    lOnPathExist = false;
            }

            // Create path
            if (string.Compare(lRole, "PasajeroAeronave", true) == 0)
            {
                if (lOnPathExist)
                    return PasajeroAeronaveData.AddPath(onSql, joinType, facet, lOnPath, lProcessedOnPath, "", forceLastAlias, isLinkedTo);
                else
                    return PasajeroAeronaveRoleAddSql(onSql, joinType, facet, lOnPath, processedOnPath, lRole, forceLastAlias, isLinkedTo);
            }

            initialClass = "Aeronave";

            // Solve path with initialPath
            lParameters[0] = onSql;
            lParameters[1] = joinType;
            lParameters[2] = facet;
            lParameters[3] = lOnPath;
            lParameters[4] = lProcessedOnPath;
            lParameters[5] = "";
            lParameters[6] = forceLastAlias;
            lParameters[7] = isLinkedTo;

            return ONContext.InvoqueMethod(ONContext.GetType_Data(initialClass), "AddPath", lParameters) as string;
        }
Exemplo n.º 45
0
 private static string PasajeroAeronaveRoleAddSql(ONSqlSelect onSql, JoinType joinType, string facet, ONPath onPath, ONPath processedPath, string role, bool force)
 {
     return PasajeroAeronaveRoleAddSql(onSql, joinType, facet, onPath, processedPath, role, force, false);
 }
Exemplo n.º 46
0
 public virtual string InhRetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
 {
     return "";
 }
Exemplo n.º 47
0
        private static string PasajeroAeronaveRoleAddSql(ONSqlSelect onSql, JoinType joinType, string facet, ONPath onPath, ONPath processedPath, string role, bool force, bool isLinkedTo)
        {
            ONPath lOnPath = new ONPath(processedPath);
            lOnPath += role;

            //Source table
            string lAliasProcessed = onSql.GetAlias("Aeronave", processedPath, isLinkedTo);
            if (lAliasProcessed == "")
            {
                force = false;
                lAliasProcessed = onSql.CreateAlias(joinType, lAliasProcessed, CtesBD.TBL_AERONAVE, processedPath, "Aeronave", force, isLinkedTo);
            }

            //Target table
            string lAlias = onSql.GetAlias("PasajeroAeronave", lOnPath, isLinkedTo);
            if (lAlias == "")
            {
                force = false;
                lAlias = onSql.CreateAlias(joinType, lAliasProcessed, CtesBD.TBL_PASAJEROAERONAVE, lOnPath, "PasajeroAeronave", force, isLinkedTo);
                onSql.AddAliasWhere(lAlias, lAliasProcessed + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + "=" + lAlias + "." + CtesBD.FLD_PASAJEROAERONAVE_FK_AERONAVE_1);
            }
            //Target path
            if ((((object) onPath == null) || (onPath.Count == 0)) && (string.Compare("PasajeroAeronave", facet, true) == 0) && (!force))
                return lAlias;

            return PasajeroAeronaveData.AddPath(onSql, joinType, facet, onPath, lOnPath, "", force, isLinkedTo);
        }
Exemplo n.º 48
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid, bool isLinkedTo)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid, isLinkedTo);
 }
Exemplo n.º 49
0
 public override string InhAddPath(ONSqlSelect onSql, string facet, ONPath onPath, string initialClass, bool isLinkedTo)
 {
     return AddPath(onSql, JoinType.InnerJoin, facet, onPath, null, initialClass, false, isLinkedTo);
 }
Exemplo n.º 50
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="onPath">Path to solve</param>
 /// <param name="facet">Facet of the path</param>
 public ONSqlPath(ONPath onPath, string facet)
 {
     OnPath = onPath;
     Facet = facet;
 }
Exemplo n.º 51
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid);
 }
Exemplo n.º 52
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid);
 }
Exemplo n.º 53
0
        public static string GetTargetClassName(ONPath onPath)
        {
            ONPath lOnPath = new ONPath(onPath);

            if (lOnPath.Count == 0)
                return "Aeronave";

            string lRol = lOnPath.RemoveHead();
            if (string.Compare(lRol, "PasajeroAeronave", true) == 0)
                return PasajeroAeronaveData.GetTargetClassName(lOnPath);

            return "";
        }
Exemplo n.º 54
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid, bool isLinkedTo)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid, isLinkedTo);
 }
Exemplo n.º 55
0
        public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
        {
            string       lAlias    = onSql.CreateAlias(CtesBD.TBL_AERONAVE, onPath, "Aeronave");
            ONDisplaySet lSourceDS = null;

            if (displaySet != null)
            {
                lSourceDS = new ONDisplaySet(displaySet);
                displaySet.Clear();
            }
            if (displaySet == null)
            {
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_FUM + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS);
            }
            else
            {
                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ID_AERONAVE));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE);

                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ESTADOOBJ));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ESTADOOBJ);

                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_FUM));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_FUM);

                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS);

                if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_NOMBRE))
                {
                    displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_NOMBRE));
                    onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_NOMBRE);
                }

                if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_ORIGEN))
                {
                    displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ORIGEN));
                    onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ORIGEN);
                }

                if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_DESTINO))
                {
                    displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_DESTINO));
                    onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_DESTINO);
                }
            }


            // Related attributes
            if (displaySet != null)
            {
                foreach (ONDisplaySetItem lDisplaySetItem in lSourceDS)
                {
                    if ((lDisplaySetItem.Path.IndexOf(".") > 0) && (lDisplaySetItem.InData) && (!lDisplaySetItem.HasHV))
                    {
                        displaySet.Add(lDisplaySetItem);

                        string lPath      = lDisplaySetItem.Path.Substring(0, lDisplaySetItem.Path.LastIndexOf("."));
                        string lFacetName = AeronaveInstance.GetTargetClass(onContext, typeof(AeronaveInstance), new ONPath(lDisplaySetItem.Path));
                        onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(AeronaveInstance), new ONPath(lDisplaySetItem.Path)));
                    }
                }
            }
            return(lAlias);
        }
Exemplo n.º 56
0
        public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
        {
            string lAlias = onSql.CreateAlias(CtesBD.TBL_AERONAVE, onPath, "Aeronave");
            ONDisplaySet lSourceDS = null;
            if(displaySet != null)
            {
                lSourceDS = new ONDisplaySet(displaySet);
                displaySet.Clear();
            }
            if (displaySet == null)
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_FUM + ", " + lAlias + "." + CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS);
            else
            {
                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ID_AERONAVE));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ID_AERONAVE);

                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ESTADOOBJ));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ESTADOOBJ);

                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_FUM));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_FUM);

                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_MAXIMOPASAJEROS);

                if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_NOMBRE))
                {
                    displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_NOMBRE));
                    onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_NOMBRE);
                }

                if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_ORIGEN))
                {
                    displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_ORIGEN));
                    onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_ORIGEN);
                }

                if (lSourceDS.Contains(CtesBD.FLD_AERONAVE_DESTINO))
                {
                    displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_AERONAVE_DESTINO));
                    onSql.AddSelect(lAlias + "." + CtesBD.FLD_AERONAVE_DESTINO);
                }

            }

            // Related attributes
            if (displaySet != null)
            {
                foreach (ONDisplaySetItem lDisplaySetItem in lSourceDS)
                {
                    if((lDisplaySetItem.Path.IndexOf(".") > 0) && (lDisplaySetItem.InData) && (! lDisplaySetItem.HasHV))
                    {
                        displaySet.Add(lDisplaySetItem);

                        string lPath = lDisplaySetItem.Path.Substring(0, lDisplaySetItem.Path.LastIndexOf("."));
                        string lFacetName = AeronaveInstance.GetTargetClass(onContext, typeof(AeronaveInstance), new ONPath(lDisplaySetItem.Path));
                        onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(AeronaveInstance), new ONPath(lDisplaySetItem.Path)));
                    }
                }
            }
            return (lAlias);
        }
Exemplo n.º 57
0
        /// <summary>
        /// Treatment the part of the XML message that has links items
        /// </summary>
        /// <param name="xmlReader">Variable with the message XML to be treated</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        public ONLinkedToList GetLinkedTo(XmlReader xmlReader, double dtdVersion)
        {
            ONLinkedToList lLinkedToList = new ONLinkedToList();

            if (!xmlReader.IsStartElement("LinkedTo"))
                return lLinkedToList;

            if (xmlReader.IsEmptyElement)
            {
                xmlReader.ReadStartElement("LinkedTo");
                return lLinkedToList;
            }

            xmlReader.ReadStartElement("LinkedTo");
            while (xmlReader.IsStartElement("Link.Item"))
            {
                ONPath lPath = new ONPath(xmlReader.GetAttribute("Role"));
                xmlReader.ReadStartElement("Link.Item");

                object[] lParam = new object[2];
                lParam[0] = xmlReader;
                lParam[1] = dtdVersion;

                string lClassInstance = xmlReader.GetAttribute("Class");
                ONOid lInstance = ONContext.InvoqueMethod(ONContext.GetType_XML(lClassInstance), "XML2ON", lParam) as ONOid;

                lLinkedToList[lPath] = lInstance;

                xmlReader.ReadEndElement(); // Link.Item
            }
            xmlReader.ReadEndElement(); // LinkedTo

            return lLinkedToList;
        }
Exemplo n.º 58
0
 /// <summary>This method adds to the SQL statement any path that appears in a formula</summary>
 /// <param name="onSql">This parameter has the current SQL statement</param>
 /// <param name="facet">First class, the beginning of the path</param>
 /// <param name="onPath">Path to add to SQL statement</param>
 /// <param name="processedOnPath">Path pocessed until the call of this method</param>
 /// <param name="initialClass">Domain of the object valued argument, object valued filter variables or AGENT when it should be necessary</param>
 public static string AddPath(ONSqlSelect onSql, string facet, ONPath onPath, ONPath processedOnPath, string initialClass)
 {
     return AddPath(onSql, JoinType.InnerJoin, facet, onPath, processedOnPath, initialClass, false, false);
 }
Exemplo n.º 59
0
 /// <summary>This method adds to the SQL statement the part that fixes the instance</summary>
 /// <param name="onSql">This parameter has the current SQL statement</param>
 /// <param name="onPath">Path to add to SQL statement</param>
 /// <param name="processedOnPath">Path pocessed until the call of this method</param>
 /// <param name="oid">OID to fix the instance in the SQL statement</param>
 public static void FixInstance(ONSqlSelect onSql, ONPath onPath, ONPath processedOnPath, AeronaveOid oid)
 {
     FixInstance(onSql, onPath, processedOnPath, oid, false);
 }
Exemplo n.º 60
0
 public override string InhAddPath( ONSqlSelect onSql, JoinType joinType, string facet, ONPath onPath, string initialClass)
 {
     // initialClass is used for Object-valued arguments, object-valued filter variables, agent instance, ...
     return AddPath(onSql, joinType, facet, onPath, null, initialClass, false);
 }