|
From: <sv...@de...> - 2005-06-30 18:35:59
|
Author: pcamacho
Date: 2005-06-30 14:36:00 -0400 (Thu, 30 Jun 2005)
New Revision: 1436
Modified:
humano2/branches/viewtools/components/tests/viewTools.cs
humano2/branches/viewtools/components/viewTools/ViewTools.cs
Log:
FIX/CHANGE: viewtools works with FROM (all columns appear with sql variab=
les).
Modified: humano2/branches/viewtools/components/tests/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/branches/viewtools/components/tests/viewTools.cs 2005-06-29 2=
3:01:46 UTC (rev 1435)
+++ humano2/branches/viewtools/components/tests/viewTools.cs 2005-06-30 1=
8:36:00 UTC (rev 1436)
@@ -80,9 +80,6 @@
vt.Complex =3D complex;
vt.KeyFlag =3D 0;
=20
- //Don't forget to init SQLVars!!!
- =20
- =20
//Simple columns
vt.TestInitSQLVars("10181",""); //Don't forget to init SQLVa=
rs!
string strSelect =3D vt.SQLSelect("10181");
@@ -154,17 +151,20 @@
Assert.IsTrue(strOrder.Trim() =3D=3D "ORDER BY upper(\"d1016=
0cTicket\".\"c10162Title\") asc , upper(\"d10160cTicket\".\"c10162Date\")=
desc".Trim());
}
=20
- //[Test]
+ [Test]
public void SQLFrom()
{
init(); =20
Humano2.Components.ViewTools.ViewTools vt =3D new Humano2.Components.=
ViewTools.ViewTools(10162);
vt.Complex =3D complex;
vt.KeyFlag =3D 0; =20
- string strFrom =3D vt.SQLFrom("0,10181,10208,10231^18,10209"=
,"10187^10179|7|'closed'|0|0");
- Logger.Log("SQLFrom(\"0,10181,10208,10231^18,10209\",\"10187=
^10179|7|'closed'|0|0\");" + strFrom, LogLevel.Trace);
=20
- Assert.IsTrue(strFrom.Trim() =3D=3D "FROM \"d10160cTicket\" =
inner join \"entity\" on \"d10160cTicket\".id_entity =3D \"entity\".id_en=
tity and entity.\"delDate\" is null LEFT JOIN \"user\" ON \"d10160cTick=
et\".\"c10162Assigned to3\" =3D \"user\".id_entity LEFT JOIN entity e1 ON=
\"user\".id_entity =3D e1.id_entity LEFT JOIN \"d10160cTicket Status\" =
ON \"d10160cTicket\".\"c10162Status\" =3D \"d10160cTicket Status\".id_ent=
ity LEFT JOIN entity e2 ON \"d10160cTicket Status\".id_entity =3D e2.id_e=
ntity".Trim());
+ vt.TestInitSQLVars("0,10231^18,10229^18,10187^10179",""); //=
Don't forget to init SQLVars!
+ string strFrom =3D vt.SQLFrom("0,10231^18,10229^18,10187^101=
79","");
+ Logger.Log("SQLFrom(\"0,10231^18,10229^18,10187^10179\",\"\"=
);" + strFrom, LogLevel.Trace);
+ =20
+ Assert.IsTrue(strFrom.Trim() =3D=3D=20
+ "FROM \"d10160cTicket\" inner join \"entity\" on \"d=
10160cTicket\".id_entity =3D \"entity\".id_entity and entity.\"delDate\" =
is null LEFT JOIN \"user\" user0 ON \"d10160cTicket\".\"c10162Assigned =
to3\" =3D user0.id_entity LEFT JOIN entity e1 ON \"user\".id_entity =3D e=
1.id_entity LEFT JOIN \"user\" user1 ON \"d10160cTicket\".\"c10162Reques=
t by1\" =3D user1.id_entity LEFT JOIN \"d10160cTicket Status\" d10160cTic=
ketStatus2 ON \"d10160cTicket\".\"c10162Status\" =3D d10160cTicketStatus2=
.id_entity LEFT JOIN entity e2 ON \"d10160cTicket Status\".id_entity =3D =
e2.id_entity");
}
=20
//[Test]
Modified: humano2/branches/viewtools/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/branches/viewtools/components/viewTools/ViewTools.cs 2005-06-=
29 23:01:46 UTC (rev 1435)
+++ humano2/branches/viewtools/components/viewTools/ViewTools.cs 2005-06-=
30 18:36:00 UTC (rev 1436)
@@ -315,11 +315,11 @@
{
string fullAtt =3D (attributes[i].Split("|".ToCharArray(=
)))[0];
string att =3D fullAtt.Split("^".ToCharArray())[0]; //Re=
move target if pertinence
- //Logger.Log("att: " + att,LogLevel.Trace);
+ Logger.Log("att: " + att,LogLevel.Trace);
bool isPert =3D fullAtt.IndexOf('^') !=3D -1;
if(!list.ContainsKey(fullAtt) && isPert)
{
- //Logger.Log(fullAtt + " added",LogLevel.Trace);
+ Logger.Log(fullAtt + " added",LogLevel.Trace);
string tableId =3D Complex.GetPertinenceClassForAttr=
ibute(att); =20
string tableName =3D (Complex.GetClassSysName(tableI=
d) + index).Replace(" ",""); //Don't forget to remove spaces... This is a=
SQL variable!!
list.Add(fullAtt,tableName);
@@ -449,30 +449,6 @@
}
=20
=20
- ///<summary>
- /// Given a name of table like "Tickets" for example, builds the=
name of sql var for this table
- /// removing the quotes (") and concatenating the number passed =
in param
- /// It is important to remove spaces from the table name to avoi=
d SQL error
- ///</summary>
- ///<param name=3D"number">The number to concatenate</param>
- ///<param name=3D"sqlTableName">The name of table</param>
- ///<returns>[name of table(without quotes)] + number.ToString</r=
eturns>
- /*
- private string getSQLTableVar(string sqlTableName, int number)
- {
- string res =3D "";
- res =3D sqlTableName.Replace("\"","").Replace(" ","") + numb=
er; //remove quotes and spaces
- return res;
- }
- =20
- private string getSQLTableVarWithTableName(string sqlTableName, =
int number)
- {
- string res =3D sqlTableName + " " + getSQLTableVar(sqlTableN=
ame,number); =20
- return res;
- }
- */
- =20
- =20
public string SQLSelect(string param)
{
Logger.Log("<<SQLSelect:>>",LogLevel.Trace);
@@ -499,7 +475,7 @@
string tableAffectedName =3D "";
if(this.SQLVars.ContainsKey(Col.FullAtt))
{
- tableAffectedName =3D Convert.ToString(this.SQLV=
ars.GetByIndex(this.SQLVars.IndexOfKey(Col.FullAtt))); //getSQLTableVar(=
table.TableName,index++);
+ tableAffectedName =3D Convert.ToString(this.SQLV=
ars.GetByIndex(this.SQLVars.IndexOfKey(Col.FullAtt))); =20
}
else
{
@@ -626,9 +602,13 @@
break;
}
=09
- Query.Append(relationType + relation.EndTableName);
+ //Here use SQLVars to build from query
+ string SQLVar =3D Convert.ToString(this.SQLVars.GetB=
yIndex(this.SQLVars.IndexOfKey(relation.IdPK + "^" + relation.IdFK)));
+ Query.Append(relationType + relation.EndTableName + " " + SQLVar);
+ Logger.Log("fromColumnIndex=3D " + relation.IdPK, Lo=
gLevel.Trace);
+ Logger.Log("toColumnIndex=3D " + relation.IdFK, LogL=
evel.Trace);
Query.Append(" ON " + relation.IniTableName + "." + relation.Primar=
yKeyName);
- Query.Append(" =3D " + relation.EndTableName + "." + relation.Forei=
gnKeyName);
+ Query.Append(" =3D " + SQLVar + "." + relation.ForeignKeyName);
=20
if(tableDictionary.IndexOf(relation.EndTableName) =3D=3D -1)
{
@@ -1465,7 +1445,8 @@
=20
private ViewRelation[] GetRelatedTableList(string[] strParams)
{
- ArrayList Relations =3D new ArrayList();
+ Logger.Log("<<GetRelatedTableList>> ", LogLevel.Trace);
+ ArrayList Relations =3D new ArrayList();
string tableNameTo =3D "", tableNameFrom =3D "", columnNameTo =3D "",=
columnNameFrom =3D "";
int toColumnIndex =3D 0, length =3D 0, toTableIndex =3D 0, fromColumn=
Index =3D 0, fromTableIndex =3D 0;
Enums.RelationType rel;
@@ -1475,7 +1456,8 @@
foreach(string index in strParams)
{
flag =3D 0;
- if(!IsNumeric(index))
+ Logger.Log("index=3D " + index, LogLevel.Trace);
+ if(!IsNumeric(index))
{
string[] aux =3D index.Split("|".ToCharArray());
columns =3D aux[0].Split("^".ToCharArray());
@@ -1690,6 +1672,9 @@
=20
int position =3D 0;
int pos =3D -1;
+ =20
+ //Logger.Log("fromColumnIndex=3D " + fromColumnIndex, LogLev=
el.Trace);
+ //Logger.Log("toColumnIndex=3D " + toColumnIndex, LogLevel.T=
race);
=09
if(Relations.Count > 0)
{
@@ -1703,6 +1688,7 @@
}
position++;
}
+ /*
if(pos > -1)
{
Relations.RemoveAt(position);
@@ -1712,6 +1698,8 @@
{
Relations.Add(Relation);
}
+ */
+ Relations.Add(Relation);
}
else
{
|