public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext) { string lAlias = onSql.CreateAlias(CtesBD.TBL_ADMINISTRADOR, onPath, "Administrador"); ONDisplaySet lSourceDS = null; if (displaySet != null) { lSourceDS = new ONDisplaySet(displaySet); displaySet.Clear(); } if (displaySet == null) { onSql.AddSelect(lAlias + "." + CtesBD.FLD_ADMINISTRADOR_ID_ADMINISTRADOR + ", " + lAlias + "." + CtesBD.FLD_ADMINISTRADOR_PASSWORD + ", " + lAlias + "." + CtesBD.FLD_ADMINISTRADOR_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_ADMINISTRADOR_FUM); } else { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_ADMINISTRADOR_ID_ADMINISTRADOR)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_ADMINISTRADOR_ID_ADMINISTRADOR); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_ADMINISTRADOR_PASSWORD)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_ADMINISTRADOR_PASSWORD); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_ADMINISTRADOR_ESTADOOBJ)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_ADMINISTRADOR_ESTADOOBJ); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_ADMINISTRADOR_FUM)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_ADMINISTRADOR_FUM); } // 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 = AdministradorInstance.GetTargetClass(onContext, typeof(AdministradorInstance), new ONPath(lDisplaySetItem.Path)); onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(AdministradorInstance), new ONPath(lDisplaySetItem.Path))); } } } return(lAlias); }
/// <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); }
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); }
/// <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); }