|
From: <sv...@de...> - 2005-06-30 22:14:59
|
Author: pcamacho
Date: 2005-06-30 18:15:01 -0400 (Thu, 30 Jun 2005)
New Revision: 1438
Modified:
humano2/branches/viewtools/components/tests/viewTools.cs
humano2/branches/viewtools/components/viewTools/ViewTools.cs
Log:
CHANGE: viewtools working with select from and where!! :D
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-30 1=
8:53:44 UTC (rev 1437)
+++ humano2/branches/viewtools/components/tests/viewTools.cs 2005-06-30 2=
2:15:01 UTC (rev 1438)
@@ -21,7 +21,7 @@
namespace Humano2.Components.Test.ViewTools
{
/// <summary>
- /// Summary description for ViewTools.
+ /// All tests work with the template HelpDesk SMB
/// </summary>
[TestFixture]
public class ViewTools
@@ -35,7 +35,7 @@
crud =3D complex.GetCore().Crud; =20
}
=20
- //[Test]
+ [Test]
public void getTableList()
{
init(); =20
@@ -117,7 +117,7 @@
Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT user0.\"email\=
", user1.\"email\" as \"email1\"".Trim());=20
}
=20
- //[Test]
+ [Test]
public void SQLWhere()
{
init(); =20
@@ -126,16 +126,17 @@
vt.Complex =3D complex;
vt.KeyFlag =3D 0;
=20
+ vt.TestInitSQLVars("0,10187","10187^10179|7|'closed'|0|0"); =
//Don't forget to init SQLVars!
+ =20
//Simple conditions
string strWhere =3D vt.SQLWhere("10187^10179|7|'closed'|0|0"=
);
Logger.Log("SQLWhere(\"10187^10179|7|'closed'|0|0\"):" + str=
Where, LogLevel.Trace);
Assert.IsTrue(strWhere.Trim() =3D=3D "WHERE d10160cTicketSta=
tus0.\"c10163Status Name\" ILIKE '%closed%'".Trim());
=20
- =20
//Double conditions
strWhere =3D vt.SQLWhere("10187^10179|7|'closed'|1|0;10181|4=
|'Joli ticket'|0|0");
Logger.Log("SQLWhere(\"10187^10179|7|'closed'|1|0;10181|4|'J=
oli ticket'|0|0\"):" + strWhere, LogLevel.Trace);
- Assert.IsTrue(strWhere.Trim() =3D=3D "WHERE d10160cTicketSta=
tus0.\"c10163Status Name\" ILIKE '%closed%' AND d10160cTicket1.\"c10162Ti=
tle\" =3D 'Joli ticket'".Trim()); =20
+ Assert.IsTrue(strWhere.Trim() =3D=3D "WHERE d10160cTicketSta=
tus0.\"c10163Status Name\" ILIKE '%closed%' AND \"d10160cTicket\".\"c1016=
2Title\" =3D 'Joli ticket'".Trim()); =20
}
=20
//[Test]
@@ -164,7 +165,7 @@
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");
+ "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 user0.id_entity =3D e1.i=
d_entity LEFT JOIN \"user\" user1 ON \"d10160cTicket\".\"c10162Request b=
y1\" =3D user1.id_entity LEFT JOIN \"d10160cTicket Status\" d10160cTicket=
Status2 ON \"d10160cTicket\".\"c10162Status\" =3D d10160cTicketStatus2.id=
_entity LEFT JOIN entity e2 ON d10160cTicketStatus2.id_entity =3D e2.id_e=
ntity");
}
=20
[Test]
@@ -186,12 +187,20 @@
string strQuery =3D vt.GetLastExecutedQuery();
Logger.Log("strQuery=3D " + strQuery,LogLevel.Trace);
Assert.IsTrue(strQuery.Trim() =3D=3D "SELECT \"d10160cTicket=
\".id_entity, user0.\"email\", user1.\"email\" as \"email2\", d10160cTick=
etStatus2.\"c10163Status Name\" FROM \"d10160cTicket\" inner join \"entit=
y\" on \"d10160cTicket\".id_entity =3D \"entity\".id_entity and entity.\"=
delDate\" is null LEFT JOIN \"user\" user0 ON \"d10160cTicket\".\"c1016=
2Assigned to3\" =3D user0.id_entity LEFT JOIN entity e1 ON user0.id_entit=
y =3D e1.id_entity LEFT JOIN \"user\" user1 ON \"d10160cTicket\".\"c1016=
2Request by1\" =3D user1.id_entity LEFT JOIN \"d10160cTicket Status\" d10=
160cTicketStatus2 ON \"d10160cTicket\".\"c10162Status\" =3D d10160cTicket=
Status2.id_entity LEFT JOIN entity e2 ON d10160cTicketStatus2.id_entity =3D=
e2.id_entity WHERE e1.\"delDate\" IS NULL AND e2.\"delDate\" IS NULL".T=
rim());
+ =20
+ //query with where
+ dr["columna"] =3D "0,10231^18,10229^18,10187^10179";
+ dr["filtros"] =3D "10231^18|4|'te...@hu...'|0|0";
+ vt.GetSQLDataTable(dtParam); //Don't get result, only to hav=
e the query
+ strQuery =3D vt.GetLastExecutedQuery();
+ Logger.Log("strQuery=3D " + strQuery,LogLevel.Trace);
+ Assert.IsTrue(strQuery.Trim() =3D=3D "SELECT \"d10160cTicket=
\".id_entity, user0.\"email\", user1.\"email\" as \"email2\", d10160cTick=
etStatus2.\"c10163Status Name\" FROM \"d10160cTicket\" inner join \"entit=
y\" on \"d10160cTicket\".id_entity =3D \"entity\".id_entity and entity.\"=
delDate\" is null LEFT JOIN \"user\" user0 ON \"d10160cTicket\".\"c1016=
2Assigned to3\" =3D user0.id_entity LEFT JOIN entity e1 ON user0.id_entit=
y =3D e1.id_entity LEFT JOIN \"user\" user1 ON \"d10160cTicket\".\"c1016=
2Request by1\" =3D user1.id_entity LEFT JOIN \"d10160cTicket Status\" d10=
160cTicketStatus2 ON \"d10160cTicket\".\"c10162Status\" =3D d10160cTicket=
Status2.id_entity LEFT JOIN entity e2 ON d10160cTicketStatus2.id_entity =3D=
e2.id_entity WHERE e1.\"delDate\" IS NULL AND e2.\"delDate\" IS NULL AN=
D e1.\"delDate\" IS NULL AND e2.\"delDate\" IS NULL and user0.\"email\" =
=3D 'te...@hu...'".Trim());
}
=20
- [Test]
+ //[Test]
public void getSQLVars()
{
- //Logger.Log("<<getSQLVars>>", LogLevel.Trace);
+ //Logger.Log(\"<<getSQLVars>>", LogLevel.Trace);
init(); =20
Humano2.Components.ViewTools.ViewTools vt =3D new Humano2.Components.=
ViewTools.ViewTools(10162);
vt.Complex =3D complex;
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-=
30 18:53:44 UTC (rev 1437)
+++ humano2/branches/viewtools/components/viewTools/ViewTools.cs 2005-06-=
30 22:15:01 UTC (rev 1438)
@@ -1077,12 +1077,22 @@
=20
if(columnIndex !=3D 0)
{
- tableName =3D Complex.TableName(columnIndex);
+ //If pertatt use SQL vars if not simple table name
+ string fullAtt =3D parameters[0];
+ if(fullAtt.IndexOf('^')!=3D-1)
+ {
+ Logger.Log("fullAtt: " + fullAtt,LogLevel.Trace)=
;
+ tableName =3D Convert.ToString(this.SQLVars.GetB=
yIndex(this.SQLVars.IndexOfKey(fullAtt))); =20
+ }
+ else
+ {
+ tableName =3D Complex.TableName(columnIndex);=20
+ }
columnName =3D Complex.ColumnName(columnIndex);
}
else
{
- tableName =3D Complex.TableName(IdClass);
+ tableName =3D Complex.TableName(IdClass); //id_entity attribute ok
columnName =3D "id_entity";
}
=20
@@ -1676,38 +1686,28 @@
=20
//Logger.Log("fromColumnIndex=3D " + fromColumnIndex, LogLev=
el.Trace);
//Logger.Log("toColumnIndex=3D " + toColumnIndex, LogLevel.T=
race);
- =09
- if(Relations.Count > 0)
+ =09
+ //Add the relation if it does not belongs yet to the list of=
relations
+ if(!relationsContains(Relation,Relations))
{
- foreach(ViewRelation vr in Relations)
- {
- pos =3D -1;
- if(vr.IdClassIni =3D=3D Relation.IdClassIni && vr.IdClassFin =3D=3D=
Relation.IdClassFin)
- {
- pos =3D position;
- break;
- }
- position++;
- }
- /*
- if(pos > -1)
- {
- Relations.RemoveAt(position);
- Relations.Insert(position,Relation);
- }
- else
- {
- Relations.Add(Relation);
- }
- */
- Relations.Add(Relation);
- }
- else
- {
Relations.Add(Relation);
}
}
=20
+ private bool relationsContains(ViewRelation rel, ArrayList Relat=
ions)
+ {
+ bool res =3D false;
+ foreach( ViewRelation relation in Relations)
+ {
+ if(relation.IdPK =3D=3D rel.IdPK && relation.IdFK =3D=3D=
rel.IdFK) =20
+ {
+ res=3Dtrue;
+ break;
+ }
+ }
+ return res;
+ }
+ =20
private Enums.RelationType GetRelationType(int ClassFrom, int ClassTo,=
int RelationColumn)
{
string strRatio =3D "";
|