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); }
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); }
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; }
/// <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; }
/// <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 LoadTextOrigen(ONContext onContext, AeronaveOid oid) { ONSqlSelect lOnSql = new ONSqlSelect(); lOnSql.CreateAlias(CtesBD.TBL_AERONAVE, null, "Aeronave"); lOnSql.AddSelect(CtesBD.FLD_AERONAVE_ORIGEN); 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; }
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; }
public static string RetrieveInstances(ONSqlSelect onSql, ONDisplaySet displaySet, ONPath onPath, ONContext onContext) { string lAlias = onSql.CreateAlias(CtesBD.TBL_NAVENODRIZA, onPath, "NaveNodriza"); ONDisplaySet lSourceDS = null; if(displaySet != null) { lSourceDS = new ONDisplaySet(displaySet); displaySet.Clear(); } if (displaySet == null) onSql.AddSelect(lAlias + "." + CtesBD.FLD_NAVENODRIZA_ID_NAVENODRIZA + ", " + lAlias + "." + CtesBD.FLD_NAVENODRIZA_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_NAVENODRIZA_FUM + ", " + lAlias + "." + CtesBD.FLD_NAVENODRIZA_NOMBRE_NAVENODRIZA); else { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_NAVENODRIZA_ID_NAVENODRIZA)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_NAVENODRIZA_ID_NAVENODRIZA); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_NAVENODRIZA_ESTADOOBJ)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_NAVENODRIZA_ESTADOOBJ); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_NAVENODRIZA_FUM)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_NAVENODRIZA_FUM); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_NAVENODRIZA_NOMBRE_NAVENODRIZA)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_NAVENODRIZA_NOMBRE_NAVENODRIZA); } // 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 = NaveNodrizaInstance.GetTargetClass(onContext, typeof(NaveNodrizaInstance), new ONPath(lDisplaySetItem.Path)); onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(NaveNodrizaInstance), new ONPath(lDisplaySetItem.Path))); } } } return (lAlias); }
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; }
/// <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, PasajeroOid oid) { ONSqlSelect lOnSql = new ONSqlSelect(); lOnSql.CreateAlias(CtesBD.TBL_PASAJERO, null, "Pasajero"); lOnSql.AddSelect(CtesBD.FLD_PASAJERO_NOMBRE); FixInstance(lOnSql, null, null, oid); // Create Data Component PasajeroData lData = new PasajeroData(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_REVISIONPASAJERO, onPath, "RevisionPasajero"); ONDisplaySet lSourceDS = null; if(displaySet != null) { lSourceDS = new ONDisplaySet(displaySet); displaySet.Clear(); } if (displaySet == null) onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_ID_REVISIONPASAJERO + ", " + lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_FK_REVISION_1 + ", " + lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_FK_PASAJEROAERO_1 + ", " + lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_ESTADOOBJ + ", " + lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_FUM); else { displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_REVISIONPASAJERO_ID_REVISIONPASAJERO)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_ID_REVISIONPASAJERO); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_REVISIONPASAJERO_FK_REVISION_1)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_FK_REVISION_1); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_REVISIONPASAJERO_FK_PASAJEROAERO_1)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_FK_PASAJEROAERO_1); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_REVISIONPASAJERO_ESTADOOBJ)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_ESTADOOBJ); displaySet.Add(new ONDisplaySetItem(CtesBD.FLD_REVISIONPASAJERO_FUM)); onSql.AddSelect(lAlias + "." + CtesBD.FLD_REVISIONPASAJERO_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 = RevisionPasajeroInstance.GetTargetClass(onContext, typeof(RevisionPasajeroInstance), new ONPath(lDisplaySetItem.Path)); onSql.AddSelect(AddPath(onSql, JoinType.LeftJoin, lFacetName, new ONPath(lPath), onPath, "", false) + "." + ONInstance.GetFieldNameOfAttribute(typeof(RevisionPasajeroInstance), new ONPath(lDisplaySetItem.Path))); } } } return (lAlias); }