コード例 #1
0
 /// <summary>
 /// Makes the data checks
 /// </summary>
 /// <param name="onSql">Sql to execute</param>
 /// <param name="data">Data componente of the class</param>
 public void FilterInData(ONSqlSelect onSql, ONDBData data)
 {
     foreach (ONFilter lOnFilter in Values)
     {
         lOnFilter.FilterInData(onSql, data);
     }
 }
コード例 #2
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));
        }
コード例 #3
0
        /// <summary>
        /// Retrieve all the instances of a determinate class that fulfil a determinate formula of searching
        /// </summary>
        /// <param name="linkedTo">List to reach the class to retrieve the related instance</param>
        /// <param name="filters">Formula to search concrete instances</param>
        /// <param name="comparer">Order Criteria that must be followed by the query</param>
        /// <param name="startRowOid">OID frontier</param>
        /// <param name="blockSize">Number of instances to be returned</param>
        /// <returns>Instances that check the filter list</returns>
        protected virtual ONCollection SolveQuery(ONLinkedToList linkedTo, ONFilterList onFilterList, ONDisplaySet displaySet, ONOrderCriteria comparer, ONOid startRowOid, int blockSize)
        {
            ONSqlSelect lOnSql = new ONSqlSelect();

            try
            {
                // Create select and first table
                InhRetrieveInstances(lOnSql, displaySet, null, OnContext);

                // Fix related instance
                if (!AddLinkedTo(lOnSql, linkedTo))
                {
                    return(ONContext.GetComponent_Collection(ClassName, OnContext));
                }

                // Add filter formula
                if (onFilterList != null)
                {
                    onFilterList.FilterInData(lOnSql, this);
                }

                // Retrieve query instance number
                int lTotalNumInstances = -1;
                if (OnContext.CalculateQueryInstancesNumber)
                {
                    if ((onFilterList == null) || (!onFilterList.InMemory))
                    {
                        ArrayList lSqlParameters;
                        string    lNumInstancesSqlSentence = ONSqlSelect.GenerateSQLAsCount(lOnSql, out lSqlParameters);
                        lTotalNumInstances = Convert.ToInt32(ExecuteScalar(lNumInstancesSqlSentence, lSqlParameters));
                    }
                    OnContext.CalculateQueryInstancesNumber = false;
                }

                // OrderCriteria
                AddOrderCriteria(lOnSql, comparer, startRowOid, blockSize);

                // Execute
                ONCollection lONCollection = ExecuteSql(lOnSql, onFilterList, displaySet, comparer, startRowOid, blockSize);

                // Set Query instance number
                if (lTotalNumInstances > -1)
                {
                    lONCollection.totalNumInstances = lTotalNumInstances;
                }

                return(lONCollection);
            }
            catch (Exception e)
            {
                string ltraceItem = "Method: SolveQuery, Component: ONDBData";
                if (e is ONSystemException)
                {
                    ONSystemException lException = e as ONSystemException;
                    lException.addTraceInformation(ltraceItem);
                    throw lException;
                }
                throw new ONSystemException(e, ltraceItem);
            }
        }
コード例 #4
0
        /// <summary>
        /// Returns the instance with the Oid
        /// </summary>
        /// <param name="oid">OID to search the instance</param>
        /// <param name="onFilterList">Filters to theck</param>
        /// <returns>The instance searched</returns>
        public override ONInstance Search(ONOid oid, ONFilterList onFilterList, ONDisplaySet displaySet)
        {
            ONSqlSelect lOnSql = new ONSqlSelect();

            // Create select and first table
            InhRetrieveInstances(lOnSql, displaySet, null, OnContext);

            // Fix instance
            InhFixInstance(lOnSql, null, null, oid);

            // Add filter formula
            onFilterList.FilterInData(lOnSql, this);

            // Execute
            ONCollection lCollection = ExecuteSql(lOnSql, onFilterList, displaySet, null, null, 0);

            if (lCollection.Count > 0)
            {
                return(lCollection[0] as ONInstance);
            }
            else
            {
                return(null);
            }
        }
コード例 #5
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;
        }
コード例 #6
0
        public override void FilterInData(ONSqlSelect onSql, ONDBData data)
        {
            if (InLegacy)
            {
                return;
            }

            //Fix Instance
            data.InhFixInstance(onSql, null, null, mOid);
        }
コード例 #7
0
        public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
        {
            string       lAlias    = onSql.CreateAlias(CtesBD.TBL_REVISION, onPath, "Revision");
            ONDisplaySet lSourceDS = null;

            if (displaySet != null)
            {
                lSourceDS = new ONDisplaySet(displaySet);
                displaySet.Clear();
            }
            if (displaySet == null)
            {
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISION_ID_REVISARAERONAVE + ", " + lAlias + "." + CtesBD.FLD_REVISION_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_REVISION_FUM + ", " + lAlias + "." + CtesBD.FLD_REVISION_NOMBREREVISOR + ", " + lAlias + "." + CtesBD.FLD_REVISION_FECHAREVISION + ", " + lAlias + "." + CtesBD.FLD_REVISION_ID_AERONAVE);
            }
            else
            {
                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_REVISION_ID_REVISARAERONAVE));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISION_ID_REVISARAERONAVE);

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

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

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

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

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


            // 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 = RevisionInstance.GetTargetClass(onContext, typeof(RevisionInstance), new ONPath(lDisplaySetItem.Path));
                        onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(RevisionInstance), new ONPath(lDisplaySetItem.Path)));
                    }
                }
            }
            return(lAlias);
        }
コード例 #8
0
        public ONCollection RevisionPasajeroRole(RevisionPasajeroOid oid)
        {
            ONSqlSelect lOnSql = new ONSqlSelect();

            //Create select
            RevisionPasajeroData.AddPath(lOnSql, "Revision", new ONPath("Revision"), null, "");
            RetrieveInstances(lOnSql, null, new ONPath("Revision"), OnContext);

            //Fix related instance
            RevisionPasajeroData.FixInstance(lOnSql, null, null, oid);

            //Execute
            return(ExecuteQuery(lOnSql));
        }
コード例 #9
0
        public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
        {
            string       lAlias    = onSql.CreateAlias(CtesBD.TBL_PASAJERO, onPath, "Pasajero");
            ONDisplaySet lSourceDS = null;

            if (displaySet != null)
            {
                lSourceDS = new ONDisplaySet(displaySet);
                displaySet.Clear();
            }
            if (displaySet == null)
            {
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_PASAJERO_ID_PASAJERO + ", " + lAlias + "." + CtesBD.FLD_PASAJERO_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_PASAJERO_FUM);
            }
            else
            {
                displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_PASAJERO_ID_PASAJERO));
                onSql.AddSelect(lAlias + "." + CtesBD.FLD_PASAJERO_ID_PASAJERO);

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

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

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


            // 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 = PasajeroInstance.GetTargetClass(onContext, typeof(PasajeroInstance), new ONPath(lDisplaySetItem.Path));
                        onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(PasajeroInstance), new ONPath(lDisplaySetItem.Path)));
                    }
                }
            }
            return(lAlias);
        }
コード例 #10
0
        public override void FilterInData(ONSqlSelect onSql, ONDBData data)
        {
            if (InLegacy)
            {
                return;
            }

            data.InhAddPath(onSql, mRelatedOid.ClassName, ONPath, "");

            //Fix Instance
            ONDBData lData = ONContext.GetComponent_Data(mRelatedOid.ClassName, data.OnContext) as ONDBData;

            lData.InhFixInstance(onSql, null, ONPath, mRelatedOid);
        }
コード例 #11
0
        public override void FilterInData(ONSqlSelect onSql, ONDBData data)
        {
            if (IsUnableToFilterInData(data.OnContext))
            {
                return;
            }

            #region Horizontal visibility for agent 'Administrador'
            if (data.OnContext.LeafActiveAgentFacets.Contains("Administrador"))
            {
                // No Horizontal Visibility formula
            }
            #endregion Horizontal visibility for agent 'Administrador'
        }
コード例 #12
0
        public ONCollection PasajeroAeronaveRole(PasajeroAeronaveOid oid)
        {
            ONSqlSelect lOnSql = new ONSqlSelect();

            //Create select
            PasajeroAeronaveData.AddPath(lOnSql, "Aeronave", new ONPath("Aeronave"), null, "");
            RetrieveInstances(lOnSql, null, new ONPath("Aeronave"), OnContext);

            //Fix related instance
            PasajeroAeronaveData.FixInstance(lOnSql, null, null, oid);

            //Execute
            return(ExecuteQuery(lOnSql));
        }
コード例 #13
0
        /// <summary>Load the data retrieved from the Data Base to components of the application</summary>
        /// <param name="onContext">This parameter has the current context</param>
        /// <param name="oid">OID of the instance whose text attribute value is wanted to be loaded</param>
        public static ONText LoadTextNombre(ONContext onContext, AeronaveOid oid)
        {
            ONSqlSelect lOnSql = new ONSqlSelect();

            lOnSql.CreateAlias(CtesBD.TBL_AERONAVE, null, "Aeronave");
            lOnSql.AddSelect(CtesBD.FLD_AERONAVE_NOMBRE);

            FixInstance(lOnSql, null, null, oid);

            // Create Data Component
            AeronaveData lData = new AeronaveData(onContext);

            // Execute query
            ArrayList lSqlParameters;
            ONText    lReturn = new ONText((string)lData.ExecuteScalar(lOnSql.GenerateSQL(out lSqlParameters), lSqlParameters));

            return(lReturn);
        }
コード例 #14
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);
     }
 }
コード例 #15
0
        public ONInstance LocalSearch(ONInstance instance)
        {
            ONSqlSelect onSql = new ONSqlSelect();

            // Create select and first table
            InhRetrieveInstances(onSql, null, null, OnContext);

            // Fix instance
            InhFixInstance(onSql, null, null, instance.Oid);

            // Execute
            ONCollection lCollection = ExecuteQuery(onSql, instance);

            if (lCollection.Count > 0)
            {
                return(lCollection[0]);
            }
            else
            {
                return(null);
            }
        }
コード例 #16
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);
        }
コード例 #17
0
        private static string NaveNodrizaFacetAddSql(JoinType joinType, ONSqlSelect onSql, ONPath onPath, bool force, bool isLinkedTo)
        {
            //Target table
            string lAliasFacet = "";
            string lAlias      = onSql.CreateAlias(joinType, "", CtesBD.TBL_NAVENODRIZA, onPath, "NaveNodriza", false, isLinkedTo);

            // Load facet from 'NaveNodriza' to 'NaveNodriza'
            lAliasFacet = onSql.GetAlias("NaveNodriza", onPath, isLinkedTo);
            if ((lAliasFacet == "") || force)
            {
                if (force)
                {
                    lAliasFacet = onSql.CreateAlias(joinType, "", CtesBD.TBL_NAVENODRIZA, onPath, "NaveNodriza", force, isLinkedTo);
                }
                else
                {
                    lAliasFacet = onSql.CreateAlias(joinType, lAlias, CtesBD.TBL_NAVENODRIZA, onPath, "NaveNodriza", force, isLinkedTo);
                }
                onSql.AddAliasWhere(lAliasFacet, lAlias + "." + CtesBD.FLD_NAVENODRIZA_ID_NAVENODRIZA + " = " + lAliasFacet + "." + CtesBD.FLD_NAVENODRIZA_ID_NAVENODRIZA);
            }
            return(lAliasFacet);
        }
コード例 #18
0
        private static string PasajeroFacetAddSql(JoinType joinType, ONSqlSelect onSql, ONPath onPath, bool force, bool isLinkedTo)
        {
            //Target table
            string lAliasFacet = "";
            string lAlias      = onSql.CreateAlias(joinType, "", CtesBD.TBL_PASAJERO, onPath, "Pasajero", false, isLinkedTo);

            // Load facet from 'Pasajero' to 'Pasajero'
            lAliasFacet = onSql.GetAlias("Pasajero", onPath, isLinkedTo);
            if ((lAliasFacet == "") || force)
            {
                if (force)
                {
                    lAliasFacet = onSql.CreateAlias(joinType, "", CtesBD.TBL_PASAJERO, onPath, "Pasajero", force, isLinkedTo);
                }
                else
                {
                    lAliasFacet = onSql.CreateAlias(joinType, lAlias, CtesBD.TBL_PASAJERO, onPath, "Pasajero", force, isLinkedTo);
                }
                onSql.AddAliasWhere(lAliasFacet, lAlias + "." + CtesBD.FLD_PASAJERO_ID_PASAJERO + " = " + lAliasFacet + "." + CtesBD.FLD_PASAJERO_ID_PASAJERO);
            }
            return(lAliasFacet);
        }
コード例 #19
0
        private static string AdministradorFacetAddSql(JoinType joinType, ONSqlSelect onSql, ONPath onPath, bool force, bool isLinkedTo)
        {
            //Target table
            string lAliasFacet = "";
            string lAlias      = onSql.CreateAlias(joinType, "", CtesBD.TBL_ADMINISTRADOR, onPath, "Administrador", false, isLinkedTo);

            // Load facet from 'Administrador' to 'Administrador'
            lAliasFacet = onSql.GetAlias("Administrador", onPath, isLinkedTo);
            if ((lAliasFacet == "") || force)
            {
                if (force)
                {
                    lAliasFacet = onSql.CreateAlias(joinType, "", CtesBD.TBL_ADMINISTRADOR, onPath, "Administrador", force, isLinkedTo);
                }
                else
                {
                    lAliasFacet = onSql.CreateAlias(joinType, lAlias, CtesBD.TBL_ADMINISTRADOR, onPath, "Administrador", force, isLinkedTo);
                }
                onSql.AddAliasWhere(lAliasFacet, lAlias + "." + CtesBD.FLD_ADMINISTRADOR_ID_ADMINISTRADOR + " = " + lAliasFacet + "." + CtesBD.FLD_ADMINISTRADOR_ID_ADMINISTRADOR);
            }
            return(lAliasFacet);
        }
コード例 #20
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);
        }
コード例 #21
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);
        }
コード例 #22
0
 public override string InhRetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext)
 {
     return(RetrieveInstances(onSql, displaySet, onPath, onContext));
 }
コード例 #23
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid, bool isLinkedTo)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid, isLinkedTo);
 }
コード例 #24
0
 public override void InhFixInstance(ONSqlSelect onSql, ONPath onPath, ONPath OnPath, ONOid oid)
 {
     FixInstance(onSql, onPath, OnPath, oid as AeronaveOid);
 }
コード例 #25
0
 private static string AeronaveFacetAddSql(JoinType joinType, ONSqlSelect onSql, ONPath onPath, bool force)
 {
     return(AeronaveFacetAddSql(joinType, onSql, onPath, force, false));
 }
コード例 #26
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);
 }
コード例 #27
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));
 }
コード例 #28
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));
 }
コード例 #29
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));
 }
コード例 #30
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));
 }