|
From: <sv...@de...> - 2005-06-17 22:25:04
|
Author: pcamacho
Date: 2005-06-17 18:25:04 -0400 (Fri, 17 Jun 2005)
New Revision: 1353
Modified:
humano2/trunk/core/db/absComplex.cs
humano2/trunk/core/db/mssql/mssqlComplex.cs
humano2/trunk/core/db/pgsql/pgsqlComplex.cs
humano2/trunk/web/portal/site/showView.aspx.cs
Log:
FIX: patch for showview to display the columns of type pertinence like th=
is attFrom.attTo . This is due to a bug in=20
viewtools.
Modified: humano2/trunk/core/db/absComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/absComplex.cs 2005-06-17 20:50:45 UTC (rev 1352=
)
+++ humano2/trunk/core/db/absComplex.cs 2005-06-17 22:25:04 UTC (rev 1353=
)
@@ -373,16 +373,26 @@
abstract public string [] GetParamsView(int id);
=20
/// <summary>
- /// Get the params (where, orderby etc...) of a report
+ /// Get the params (where, orderby etc...) of a report
/// </summary>
/// <param name=3D"id">id of report</param>
/// <returns>params of the report</returns>
abstract public string [] GetParamsReport(int id);
=20
+ ///<summary>
+ /// Get the user name of an attribute
+ ///</summary>
+ abstract public string GetUserAttName(int idAtt);
=20
///<summary>
+ /// Get the sys name of an attribute
+ ///</summary>
+ abstract public string GetSysAttName(int idAtt);
+ =20
+ =20
+ ///<summary>
/// Returns the name of the basic attribute (numeric, textline..=
.) father of an attribute passed in param =20
- ///</summary>
+ ///</summary>
/// <param name=3D"classId">The classId of an attribute</param>
/// <returns>the sys name of basic attribute</returns>
=20
Modified: humano2/trunk/core/db/mssql/mssqlComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-06-17 20:50:45 UTC (=
rev 1352)
+++ humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-06-17 22:25:04 UTC (=
rev 1353)
@@ -1175,6 +1175,39 @@
}
return res;
}
+ =20
+ =20
+ override public string GetUserAttName(int idAtt)
+ {
+ string req =3D "select \"attName\" from attribute where \"id=
_entity\" =3D '" + idAtt +"'";
+ string res =3D "";
+ DataTable dt =3D doSelect(req);
+ try
+ {
+ res =3D Convert.ToString(dt.Rows[0]["attName"]);
+ }
+ catch
+ {
+ Logger.Log("Problem trying to get the user name of att "=
+ idAtt, LogLevel.Trace);
+ }
+ return res;
+ }
+ =20
+ override public string GetSysAttName(int idAtt)
+ {
+ string req =3D "select \"sysAttName\" from attribute where \=
"id_entity\" =3D '" + idAtt +"'";
+ string res =3D "";
+ DataTable dt =3D doSelect(req);
+ try
+ {
+ res =3D Convert.ToString(dt.Rows[0]["sysAttName"]);
+ }
+ catch
+ {
+ Logger.Log("Problem trying to get the sys name of att " =
+ idAtt, LogLevel.Trace);
+ }
+ return res;
+ }
=20
override public string GetBasicAttributeSysName(int classId)
{
Modified: humano2/trunk/core/db/pgsql/pgsqlComplex.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-06-17 20:50:45 UTC (=
rev 1352)
+++ humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-06-17 22:25:04 UTC (=
rev 1353)
@@ -658,7 +658,7 @@
return convertAttrib(idEntity, names, "attName", "sysAttName");
}
=20
- ///<summary>Converts the 'sysAttName' to the 'attName' o=
f a class</summary>
+ ///<summary>Converts the 'sysAttName' to the 'attName' of a clas=
s</summary>
override public string[] convertAttribSysNameToName(int idEntity, stri=
ng[] names)
{
return convertAttrib(idEntity, names, "sysAttName", "attName");
@@ -935,7 +935,7 @@
}
=20
/// <summary>
- /// Converts a system attribute name into a user attribute name
+ /// Converts a system attribute name into a user attribute name
/// </summary>
/// <param name=3D"sysAttName">system name for attribute </param=
>
/// <returns>user attribute name</returns>
@@ -955,8 +955,40 @@
return res;
}
=20
+ override public string GetUserAttName(int idAtt)
+ {
+ string req =3D "select \"attName\" from attribute where \"id=
_entity\" =3D '" + idAtt +"'";
+ string res =3D "";
+ DataTable dt =3D doSelect(req);
+ try
+ {
+ res =3D Convert.ToString(dt.Rows[0]["attName"]);
+ }
+ catch
+ {
+ Logger.Log("Problem trying to get the user name of att "=
+ idAtt, LogLevel.Trace);
+ }
+ return res;
+ }
+ =20
+ override public string GetSysAttName(int idAtt)
+ {
+ string req =3D "select \"sysAttName\" from attribute where \=
"id_entity\" =3D '" + idAtt +"'";
+ string res =3D "";
+ DataTable dt =3D doSelect(req);
+ try
+ {
+ res =3D Convert.ToString(dt.Rows[0]["sysAttName"]);
+ }
+ catch
+ {
+ Logger.Log("Problem trying to get the sys name of att " =
+ idAtt, LogLevel.Trace);
+ }
+ return res;
+ }
+ =20
/// <summary>
- /// Tells if an attribute is primary=20
+ /// Tells if an attribute is primary=20
/// </summary>
/// <param name=3D"sysAttName">system name for attribute </param=
>
/// <returns>true if attribute is primary</returns>
Modified: humano2/trunk/web/portal/site/showView.aspx.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- humano2/trunk/web/portal/site/showView.aspx.cs 2005-06-17 20:50:45 UT=
C (rev 1352)
+++ humano2/trunk/web/portal/site/showView.aspx.cs 2005-06-17 22:25:04 UT=
C (rev 1353)
@@ -129,6 +129,7 @@
Logger.Log("Before ExecViewFromDataTabe. iniClass=3D " + Con=
vert.ToString(iniClass),LogLevel.Trace);
=20
DataTable viewRes =3D dbAdapter.ExecViewFromDataTable(iniCla=
ss, viewTable, idEntity, orderArr, currPage, 1);
+ viewRes =3D bigPatchForViewTools(viewRes,viewTable,iniClass,=
idEntity); //Only a big patch, see comment of the function....
=20
int pageCount=3D dbAdapter.NumberOfPagesInPagedView;
if (pageCount > 1)
@@ -146,6 +147,7 @@
foreach(DataRow row in viewRes.Rows)=20
{
row["instanceUrl"] =3D Html.genAbsoluteUrl("/portal/site=
/instance.aspx?id_entity=3D" + row[0]);
+ Logger.Log("instanceUrl=3D " + row["instanceUrl"],LogLev=
el.Trace);
}
=20
xmlString =3D "<instances>";
@@ -190,7 +192,7 @@
xmlSearch +=3D "</searchFields>";
xmlString +=3D xmlSearch;
xmlString +=3D "</instances>";
- =20
+ Logger.Log("idEntity:" + idEntity,LogLevel.Trace);
=20
//Add the header
xmlString =3D "<?xml version=3D\"1.0\" encoding=3D\"UTF-8\=
"?>"
@@ -205,7 +207,7 @@
DataTable dtParam =3D this.makeDataTableInViewTools();
DataRow dr =3D dtParam.NewRow();
=20
- dr["columna"] =3D getAttributeListForClass(iniClass);
+ dr["columns"] =3D getAttributeListForClass(iniClass);
//Logger.Log("search: list of attributes =3D " + dr["columna"],LogLev=
el.Trace);
=20
//Explicacion de los filtros...
@@ -276,11 +278,12 @@
}
return filter;
}
+ =20
private DataTable makeDataTableInViewTools()
{
DataTable dt1 =3D new DataTable();
DataColumn dc1;
- dc1 =3D new DataColumn("columna",typeof(string));
+ dc1 =3D new DataColumn("columns",typeof(string));
dt1.Columns.Add(dc1);
dc1 =3D new DataColumn("filtros",typeof(string));
dt1.Columns.Add(dc1);
@@ -325,10 +328,10 @@
continue; =20
}
xmlString +=3D"<attribute>"; =20
- =20
+ =20
//Get the real user column name that corresponds to system column na=
me
- string userColName =3D complex.ConvertSysAttNameToUserAttName(colNam=
e);
- int userColD =3D complex.ConvertSysAttNameToIdAttName(colName);
+ string userColName =3D buildCompleteUserAttName(colName);//complex.C=
onvertSysAttNameToUserAttName(colName);
+ string userColD =3D colName; //complex.ConvertSysAttNameToIdAttName(=
colName);
=20
xmlString +=3D "<value>"
+ userColName
@@ -344,19 +347,22 @@
private string xml_getContentTable(DataTable viewRes, int idEntity,str=
ing IdRead,absComplex complex)
{
string xmlString =3D "";
-
+ Logger.Log("xml_getContentTable",LogLevel.Trace);
foreach(DataRow row in viewRes.Rows)
{
xmlString +=3D "<instance>";
foreach( DataColumn col in row.Table.Columns )
{
+ Logger.Log("col.ColumnName: " + col.ColumnName,LogLe=
vel.Trace); =20
+ =20
if(col.ColumnName =3D=3D "instanceUrl") //Computes t=
he url for update and show.
{
string baseUrl =3D row["instanceUrl"] +=20
"&display=3DreadXslt.aspx&iniClass=3D" +=20
- iniClass + "&idView=3D" + idEntity +=20
- "&idView=3D" + idEntity + "&action=3D";
- xmlString +=3D xml_getUrl(baseUrl); =20
+ iniClass + "&idView=3D" + idEntity + "&action=3D";
+ xmlString +=3D xml_getUrl(baseUrl);=20
+ Logger.Log("baseUrl=3D " + baseUrl,LogLevel.Trac=
e);
+ Logger.Log("[[idEntity]]=3D " + idEntity,LogLeve=
l.Trace);
}
else if(col.ColumnName =3D=3D "id_entity")
{=20
@@ -397,12 +403,33 @@
}
private string xml_getEntity(DataRow row,DataColumn col,absComplex com=
plex,string IdRead)
{
- string xmlString =3D "";
+ Logger.Log("xml_getEntity: ", LogLevel.Trace);
+ =20
+ string xmlString =3D "";
xmlString +=3D "<value>"
+ "<text>" + row[col] + "</text>";
//Now check if the attribute is Primary
- xmlString +=3D "<isPrimary>";
- if(complex.IsPrimary(col.ColumnName))
+ string auxcolname =3D col.ColumnName;
+ bool isNumeric =3D!( (auxcolname =3D=3D "id_entity")=20
+ || (auxcolname.StartsWith("id_entity"))=
=20
+ || (auxcolname=3D=3D"row"));
+ string sysAttName=3D"";
+ =20
+ if(isNumeric)
+ {
+ string [] idAttArr =3D auxcolname.Split("^".ToCharArray(=
));
+ Logger.Log("idAttArr[0]:" + idAttArr[0],LogLevel.Trace);
+ sysAttName =3D complex.GetSysAttName(Convert.ToInt32(idA=
ttArr[0]));
+ }
+ else
+ {
+ sysAttName =3D auxcolname;
+ }
+ =20
+ Logger.Log("sysAttName:" + sysAttName,LogLevel.Trace);
+ =20
+ xmlString +=3D "<isPrimary>";
+ if(complex.IsPrimary(sysAttName))
{
xmlString +=3D "true";
}
@@ -414,7 +441,7 @@
xmlString +=3D "<show>0</show>";
xmlString +=3D "<isSelfLookup>";
=20
- if(complex.IsSelfLookUp(col.ColumnName))
+ if(complex.IsSelfLookUp(sysAttName))
{
xmlString +=3D "true";
}
@@ -433,32 +460,65 @@
{
string auxcolname;
string xmlString =3D "";
-
+ =20
auxcolname =3D col.ColumnName;
=20
xmlString +=3D "<value>"
+ "<text>" + row[col] + "</text>";
//Now check if the attribute is Primary
- xmlString +=3D "<isPrimary>";
- if(complex.IsPrimary(col.ColumnName))
- {
- xmlString +=3D "true";
- }
- else
- {
- xmlString +=3D "false";
- }
- xmlString +=3D "</isPrimary>";
=20
- xmlString +=3D "<isSelfLookup>";
- if(complex.IsSelfLookUp(col.ColumnName))
- {
- xmlString +=3D "true";
- }else{
- xmlString +=3D "false";
- }
- xmlString +=3D "</isSelfLookup>";
- =20
+ bool isNumeric =3D!( (auxcolname =3D=3D "id_entity")=20
+ || (auxcolname.StartsWith("id_entity"))=
=20
+ || (auxcolname=3D=3D"row"));
+ string sysAttName=3D"";
+ =20
+ if(isNumeric)
+ {
+ string [] idAttArr =3D auxcolname.Split("^".ToCharArray(=
));
+ Logger.Log("idAttArr[0]:" + idAttArr[0],LogLevel.Trace);
+ //sysAttName =3D complex.GetSysAttName(Convert.ToInt32(i=
dAttArr[0]));
+ //Take the first if there's no destination of the second=
if there's a destination
+ if(idAttArr.Length =3D=3D 2)
+ {
+ sysAttName =3D complex.GetSysAttName(Convert.ToInt32=
(idAttArr[1])); //Take the second part
+ }
+ else
+ {
+ sysAttName =3D complex.GetSysAttName(Convert.ToInt32=
(idAttArr[0]));
+ }
+ }
+ else //Don't change anything
+ {
+ sysAttName =3D auxcolname;
+ }
+ =20
+ xmlString +=3D "<isPrimary>";
+ =20
+ if(complex.IsPrimary(sysAttName))
+ {
+ xmlString +=3D "true";
+ }
+ else
+ {
+ xmlString +=3D "false";
+ }
+
+ xmlString +=3D "</isPrimary>";
+
+ xmlString +=3D "<isSelfLookup>";
+ if(complex.IsSelfLookUp(sysAttName))
+ {
+ Logger.Log("IsSelfLookUp!!",LogLevel.Trace);
+ xmlString +=3D "true";
+ }
+ else
+ {
+ Logger.Log("NOT IsSelfLookUp",LogLevel.Trace);
+ xmlString +=3D "false";
+ }
+ xmlString +=3D "</isSelfLookup>";
+ =20
+ =20
if(auxcolname.StartsWith("id_entity"))
{
xmlString +=3D "<show>0</show>";
@@ -531,5 +591,115 @@
rblSeparador.Visible=3Dfalse;
}
}
- }
+ =20
+ ////////////////////////////////////////////////////////////////=
////////////////////////////////////////// =20
+ ///UGLY PATCH !! FIXME SOON!!! FIXME SOON!!! //////////////////=
////////////////////////////////////////// =20
+ //BECAREFUL: This is only a patch that should be removed once Vi=
ewTools will be repaired: ///
+ // ViewTools can not display two columns that are pertinences to=
the same class. The columns displayed ///
+ // are the same, because Viewtools only take the first pertinenc=
e. In this case we have to get back ///
+ // the column corresponding to the attributes in the parameters =
passed to generate viewtools, and then ///
+ // get the real name of column and the good value to display... =
Well I understand myself Ithink... ///
+ // Hopefully ViewTools will be fixed soon... =
///
+ ////////////////////////////////////////////////////////////////=
//////////////////////////////////////////
+ ///<summary>Takes a datatable generated with viewtools and patch=
es it</summary>
+ ///<param name=3D"viewRes">The datatable generated by viewtools.=
Will be patched</param>
+ ///<param name=3D"viewTable">The parameters passed to viewtools =
(columns, filter, order etc...)</param>
+ ///<returns>The new really good patched datatable :)</returns>
+ private DataTable bigPatchForViewTools(DataTable viewRes, DataTa=
ble viewTable, int iniClass, int idEntity)
+ {
+ DataTable patchedTable =3D new DataTable(); //Will contain=
the good result
+ =20
+ ///builds the array with the columns to display
+ string columns =3D Convert.ToString(viewTable.Rows[0]["colum=
ns"]);
+ string [] columnsList =3D columns.Split(",".ToCharArray());
+ int indexColumns =3D 0; =20
+ Logger.Log("columns: " + columns, LogLevel.Trace);
+ =20
+ //First change the columns
+ foreach(DataColumn col in viewRes.Columns)=20
+ {
+ Logger.Log("indexColumns=3D" + indexColumns,LogLevel.Trace);
+ string colName =3D col.ColumnName;
+ Logger.Log("colName: " + colName,LogLevel.Trace);
+ string newPatchedColName =3D "";
+ =09
+ =20
+ if((colName.StartsWith("id_entity")=20
+ || (colName=3D=3D"id_entity")
+ || (colName=3D=3D"row"))
+ ) //the list of columns passed to viewTools does not=
have the idEntities...
+ {
+ newPatchedColName =3D colName; //Don't change anythi=
ng
+ if(colName=3D=3D"id_entity") //The first column must=
be always 0
+ {
+ indexColumns++; =20
+ }
+ }
+ else
+ {
+ newPatchedColName =3D columnsList[indexColumns]; =
//Put the attId, to be able then to get easily the name
+ indexColumns++;
+ }
+ DataColumn newPatchedCol =3D new DataColumn(newPatchedCo=
lName);
+ patchedTable.Columns.Add(newPatchedCol);
+ }
+ =20
+ //Now change the lines with good values
+ =20
+ for(int i=3D0;i<viewRes.Rows.Count;i++)
+ {
+ DataRow myRow =3D patchedTable.NewRow(); //Create the li=
ne once
+ //Fill the row
+ for(int j =3D 0; j< viewRes.Columns.Count; j++)
+ {
+ myRow[j] =3D Convert.ToString(viewRes.Rows[i][j]);
+ Console.Write(myRow[j] + " ");
+ }
+ patchedTable.Rows.Add(myRow); =20
+ Console.Write("\n");
+ }
+ return patchedTable;
+ } =20
+ =20
+ /*
+ private string buildPertinenceColumn(DataTable viewTable, string=
col, int iniClass, int idEntity)
+ {
+ viewTable["columns"] =3D "0" + col;
+ =20
+ adapter dbAdapter =3D userCred.CoreAdapter;
+ DataTable res =3D dbAdapter.ExecViewFromDataTable(iniClass, =
viewTable, idEntity, "", 0, 1);
+ }
+ */
+ =20
+ /////////////////////////////////////////////////////////////////=
//////////////////////////////////=20
+ ///////////////////////////////////// END OF UGLY PATCH /////////=
//////////////////////////////////
+ /////////////////////////////////////////////////////////////////=
//////////////////////////////////
+ =20
+ ///<summary>
+ //Builds the complete user attribute name, that means. If an att=
ribute is not a pertinence, display=20
+ ///the user att name for att, else returns fromUserAttName.toUse=
rAttName.
+ ///</summary>
+ private string buildCompleteUserAttName(string idAtt)
+ {
+ absCrud crud =3D Factory.Crud();
+ absComplex complex =3D crud.GetCore().Complex;
+ =20
+ string [] fromToAttArr =3D idAtt.Split("^".ToCharArray());
+ string fullUserAttName =3D "";
+ if(fromToAttArr.Length =3D=3D 2)
+ {
+ string fromAtt =3D fromToAttArr[0];
+ string toAtt =3D fromToAttArr[1];
+ string fromUserAttName =3D complex.GetUserAttName(Conver=
t.ToInt32(fromAtt));
+ string toUserAttName =3D complex.GetUserAttName(Convert.=
ToInt32(toAtt)); =20
+ fullUserAttName =3D fromUserAttName + "." + toUserAttNam=
e;
+ }
+ else
+ {
+ fullUserAttName =3D complex.GetUserAttName(Convert.ToInt3=
2(idAtt)); =20
+ }
+ =20
+ return fullUserAttName;
+ }
+ } =20
}
|