|
From: <sv...@de...> - 2005-05-25 19:46:29
|
Author: pcamacho
Date: 2005-05-25 15:46:20 -0400 (Wed, 25 May 2005)
New Revision: 1147
Modified:
humano2/trunk/components/viewTools/ViewTools.cs
humano2/trunk/core/db/absComplex.cs
humano2/trunk/core/db/absCrud.cs
humano2/trunk/core/db/mssql/mssqlComplex.cs
humano2/trunk/core/db/mssql/mssqlCrud.cs
humano2/trunk/core/db/pgsql/pgsqlComplex.cs
humano2/trunk/core/db/pgsql/pgsqlCrud.cs
Log:
FIX:=20
* the view was crashing when trying to show instances with non basic att=
ributes (like email).
* the function GetBasicAttributeSysName was bugged: it was only returnin=
g "attribute" and not the name of the basic=20
attribute like "textline" or "numeric" etc...
Modified: humano2/trunk/components/viewTools/ViewTools.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/components/viewTools/ViewTools.cs 2005-05-25 19:08:00 U=
TC (rev 1146)
+++ humano2/trunk/components/viewTools/ViewTools.cs 2005-05-25 19:46:20 U=
TC (rev 1147)
@@ -447,7 +447,9 @@
foreach(DisplayOrder var2 in disp)
{
vars.Add(var2.Text + "," + var2.Type);
+ Logger.Log("ViewTools: vars[]=3D" + var2.Text + "," =
+ var2.Type,LogLevel.Trace);
}
+ Logger.Log("ViewTools: call of BuildTempTable",LogLevel.=
Trace);
Query.Append(Complex.BuildTempTable((string[])vars.ToArray(typeof(st=
ring)),ref tableName));
TempTable =3D tableName;
}
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-05-25 19:08:00 UTC (rev 1146=
)
+++ humano2/trunk/core/db/absComplex.cs 2005-05-25 19:46:20 UTC (rev 1147=
)
@@ -344,10 +344,10 @@
abstract public string ConvertSysAttNameToUserAttName(string sys=
AttName);
=20
/// <summary>
- /// Converts a system attribute name into a user attribute name
+ /// Converts a system attribute name into its id
/// </summary>
/// <param name=3D"sysAttName">system name for attribute </param>
- /// <return>user attribute name</returns>
+ /// <return>id of attribute</returns>
abstract public int ConvertSysAttNameToIdAttName(string sysAttName);
=20
/// <summary>
@@ -375,6 +375,13 @@
abstract public string [] GetParamsReport(int id);
=20
=20
+ ///<summary>
+ /// Returns the name of the basic attribute (numeric, textline..=
.) father of an attribute passed in param
+ /// <param name=3D"classId">The classId of an attribute</param>
+ /// <returns>the sys name of basic attribute</returns>
+ ///</summary>
+ abstract public string GetBasicAttributeSysName(int classId);
+ =20
#endregion
=20
public object doScalar(string query)
Modified: humano2/trunk/core/db/absCrud.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/absCrud.cs 2005-05-25 19:08:00 UTC (rev 1146)
+++ humano2/trunk/core/db/absCrud.cs 2005-05-25 19:46:20 UTC (rev 1147)
@@ -58,11 +58,30 @@
=09
virtual public string AttributeTypeMapping(string name)
{
- return attMap[name];
+ string res =3D "";
+ Logger.Log("AttributeTypeMapping. name=3D " + name, LogLevel=
.Trace);
+ if(attMap[name] =3D=3D null) //This is not a basic type
+ {
+ res =3D findSqlTypeForAttribute(attMap,name);
+ }
+ else
+ {
+ res =3D attMap[name]; =20
+ }
+ return res;
}
=09
- #endregion
- =09
+ #endregion
+ =20
+ ///<summary>
+ /// Finds the sql type of a non basic attribute (like textline, =
numeric, currency etc...)
+ ///<param name=3D"attMap">the dictionnary with basic attributes =
/ sql type</param>
+ ///<param name=3D"name">The name of the non basic attribute</par=
am>
+ ///<returns>The type of non basic attribute. If this type is not=
found, an exception is
+ /// raised (because every non basic type should derived from a b=
asic one)</returns>
+ ///</summary>
+ abstract protected string findSqlTypeForAttribute(StringDictiona=
ry attMap, string name);
+ =20
///<summary>Devuelve toda la estructura de una clase.</summary>
///<returns>Devuelve un DataSet con toda la estructura activa de una c=
lase.</returns>
///<param name=3D"idEntity">El ID del objeto que sea leido</param>
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-05-25 19:08:00 UTC (=
rev 1146)
+++ humano2/trunk/core/db/mssql/mssqlComplex.cs 2005-05-25 19:46:20 UTC (=
rev 1147)
@@ -71,7 +71,7 @@
return res;
}
=20
- public override DataTable getColsforView(int classId)
+ public override DataTable getColsforView(int classId)
{
string query =3D @"select top 1 ""id_entity"", ""columns"" from ""vie=
w"" where ""idClassView"" =3D "+classId+" order by id_entity";
return doSelect(query);
@@ -1170,7 +1170,14 @@
Logger.Log("ConvertSysAttName: there is no userAttName for sysAttNam=
e: " + sysAttName,LogLevel.Trace);
}
return res;
- } =20
+ }
+
+ override public string GetBasicAttributeSysName(int classId)
+ {
+ //FIXME: this method must be implemented
+ throw new MetaModelException("Method GetBasicAttributeSysNam=
e must be implemented.");
+ return null; =20
+ }
=20
}
}
Modified: humano2/trunk/core/db/mssql/mssqlCrud.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/mssqlCrud.cs 2005-05-25 19:08:00 UTC (rev=
1146)
+++ humano2/trunk/core/db/mssql/mssqlCrud.cs 2005-05-25 19:46:20 UTC (rev=
1147)
@@ -1471,17 +1471,17 @@
return res;
}
=09
- override protected string genClassSysName(int domainId, string classNa=
me)
+ override protected string genClassSysName(int domainId, string classNa=
me)
{
Boolean exists =3D false;
int loop =3D 0;
string baseSysName =3D String.Format("d{0}{1}", domainId, className);
string sysName =3D baseSysName;
- do
+ do
{
exists =3D false;
int id =3D Convert.ToInt32(conn.doScalar("select * from class where =
sysName =3D'" + sysName + "'"));
- if (id > 0 )
+ if (id > 0 )
{
exists =3D true;
loop +=3D 1;
@@ -1492,17 +1492,17 @@
return sysName;
}
=20
- override protected string genAttSysName(int classId, string attName)
+ override protected string genAttSysName(int classId, string attName)
{
Boolean exists =3D false;
int loop =3D 0;
string baseSysName =3D String.Format("c{0}{1}", classId, attName);
string sysName =3D baseSysName;
- do
+ do
{
exists =3D false;
int id =3D Convert.ToInt32(conn.doScalar("select id_entity from attr=
ibute where sysAttName =3D'" + sysName + "'"));
- if (id > 0 )
+ if (id > 0 )
{
exists =3D true;
loop +=3D 1;
@@ -1746,5 +1746,20 @@
/* + "foreign key id_entity references class (id_entity)" */
conn.doCommand( sqlCommand );
}
+ =20
+ =20
+ ///<summary>
+ /// Finds the sql type of a non basic attribute (like textline, =
numeric, currency etc...)
+ ///<param name=3D"attMap">the dictionnary with basic attributes =
/ sql type</param>
+ ///<param name=3D"name">The name of the non basic attribute</par=
am>
+ ///<returns>The type of non basic attribute. If this type is not=
found, an exception is
+ /// raised (because every non basic type should derived from a b=
asic one)</returns>
+ ///</summary>
+ override protected string findSqlTypeForAttribute(StringDictiona=
ry attMap, string name)
+ {
+ //FIXME: this method has to be implemented...=20
+ throw new MetaModelException("The method findSqlTypeForAttri=
bute is not yet implemented...");
+ return ""; =20
+ }
}
}
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-05-25 19:08:00 UTC (=
rev 1146)
+++ humano2/trunk/core/db/pgsql/pgsqlComplex.cs 2005-05-25 19:46:20 UTC (=
rev 1147)
@@ -371,7 +371,6 @@
where
entity.id_entity =3D " + colId + @" and
entity.class =3D class.id_entity");
-
=20
if(dt.Rows.Count>0)
{=09
@@ -381,7 +380,7 @@
}
else
{
- tName =3D InstanceType(Convert.ToInt32(dt.Rows[0]["id_entity"]));
+ tName =3D GetBasicAttributeSysName(Convert.ToInt32(dt.Rows[0]["id_e=
ntity"]));
}
}
else
@@ -394,6 +393,7 @@
}
dt.Dispose();
return tName;
+ =20
}
=20
///<summary>
@@ -401,11 +401,15 @@
/// <param name=3D"classId">The classId of an attribute</param>
/// <returns>the sys name of basic attribute</returns>
///</summary>
- private string getBasicAttributeSysName(int classId)
+ override public string GetBasicAttributeSysName(int classId)
{
int parentId =3D classId;
+ int oldParentId =3D 0;
+ =20
while(parentId !=3D 5)
{
+ oldParentId =3D parentId;
+ Logger.Log("GetBasicAttributeSysName: parentId=3D " + pa=
rentId, LogLevel.Trace);
string queryParent =3D "select \"parentId\" from class w=
here id_entity=3D" + parentId;
object resParent =3D conn.doScalar(queryParent);
if(resParent =3D=3D null)
@@ -415,7 +419,7 @@
parentId =3D Convert.ToInt32(resParent);
}
//Now I look for the sysName of basic attribute
- string querySysName =3D "select \"sysName\" from class where=
id_entity=3D" + parentId;
+ string querySysName =3D "select \"sysName\" from class where=
id_entity=3D" + oldParentId;
object resSysName =3D conn.doScalar(querySysName);
string sysName =3D resSysName.ToString();
=20
@@ -440,13 +444,24 @@
foreach(string col in args)
{
var =3D col.Split(",".ToCharArray());
+ Logger.Log("BuildTempTable: col[" + loop + "]=3D " + col=
,LogLevel.Trace);
name =3D var[0];
name =3D name.Substring(name.IndexOf(".")+1);
- if ((loop > 0) && (name =3D=3D "id_entity")) name =3D name + loop.To=
String();
+ if ((loop > 0) && (name =3D=3D "id_entity"))=20
+ {
+ name =3D name + loop.ToString();
+ }
//FIXME: This "AttributeTypeMapping" needs to change to support dyna=
mic derived types in view.
- type =3D core.Crud.AttributeTypeMapping(var[2].ToString());
- if (type =3D=3D null) type =3D var[2].ToString();
+ Logger.Log("BuildTempTable: var[2].ToString()=3D " + var[2].ToString=
(),LogLevel.Trace);
+ type =3D core.Crud.AttributeTypeMapping(var[0].ToString(=
)); //var[0] is of the form "d109cVerifAttribs"."c10007Text1" for example
+ =
//The data we need is c10007Text1
+ if (type =3D=3D null)=20
+ {
+ Logger.Log("BuildTempTable: type=3D=3Dnull",LogLevel=
.Trace);
+ type =3D var[2].ToString(); //FIXME ok but it is a b=
ig patch
+ }
table.Append(name + " " + type + ",");
+ Logger.Log("BuildTempTable. name=3D " + name + ", type=3D=
" + type,LogLevel.Trace);
loop++;
}
table.Append("\"row\" Serial);\n");
Modified: humano2/trunk/core/db/pgsql/pgsqlCrud.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/pgsqlCrud.cs 2005-05-25 19:08:00 UTC (rev=
1146)
+++ humano2/trunk/core/db/pgsql/pgsqlCrud.cs 2005-05-25 19:46:20 UTC (rev=
1147)
@@ -1742,5 +1742,45 @@
/* + "foreign key id_entity references class (id_entity)" */
conn.doCommand( sqlCommand );
}
+ =20
+ ///<summary>
+ /// Finds the sql type of a non basic attribute (like textline, =
numeric, currency etc...)
+ ///<param name=3D"attMap">the dictionnary with basic attributes =
/ sql type</param>
+ ///<param name=3D"name">The name of the non basic attribute</par=
am>
+ ///<returns>The type of non basic attribute. If this type is not=
found, an exception is
+ /// raised (because every non basic type should derived from a b=
asic one)</returns>
+ ///</summary>
+ ///FIXME: this function looks could use getBasicAttributeForType
+ override protected string findSqlTypeForAttribute(StringDictiona=
ry attMap, string name)
+ {
+ =20
+ absCrud crud =3D Factory.Crud();
+ absComplex complex =3D crud.GetCore().Complex;
+ Logger.Log("finSqlTypeForAttribute: name=3D " + name,LogLeve=
l.Trace);
+ =20
+ string [] nameSplit =3D name.Split((".").ToCharArray());
+ string aux =3D nameSplit[1]; //The before last element of sp=
lit has got the good data (sysName of attribute)
+ aux =3D aux.Replace("\"",""); //Remove "
+ Logger.Log("findSqlTypeForAttribute: aux =3D " + aux, LogLe=
vel.Trace);
+ =20
+ int id_entity =3D complex.ConvertSysAttNameToIdAttName(aux);
+ =20
+ =20
+ string res;
+ =20
+ if(id_entity =3D=3D -1)
+ {
+ Logger.Log("findSqlTypeForAttribute: id_entity =3D=3D -1=
",LogLevel.Trace);
+ res =3D null;
+ }
+ else
+ { =20
+ int classIdOfAttribute =3D complex.getClassIdofInstance(=
id_entity);=20
+ string basicAttributeSysName =3D complex.GetBasicAttribu=
teSysName(classIdOfAttribute);
+ Logger.Log("findSqlTypeForAttribute: basicAttributeSysNa=
me=3D " + basicAttributeSysName,LogLevel.Trace);
+ res =3DattMap[basicAttributeSysName];
+ }
+ return res;
+ }
}
}
|