|
From: <sv...@de...> - 2005-06-29 22:12:18
|
Author: pcamacho
Date: 2005-06-29 18:12:11 -0400 (Wed, 29 Jun 2005)
New Revision: 1434
Modified:
humano2/branches/viewtools/components/tests/formulas.cs
humano2/branches/viewtools/components/tests/viewTools.cs
humano2/branches/viewtools/components/tests/xmltools.cs
humano2/branches/viewtools/components/viewTools/ViewTools.cs
humano2/branches/viewtools/core/db/absComplex.cs
humano2/branches/viewtools/core/db/pgsql/pgsqlComplex.cs
Log:
CHANGE: in viewTools build of sorted list that will be used to build the =
right SQL string.
Modified: humano2/branches/viewtools/components/tests/formulas.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/formulas.cs 2005-06-28 20=
:57:49 UTC (rev 1433)
+++ humano2/branches/viewtools/components/tests/formulas.cs 2005-06-29 22=
:12:11 UTC (rev 1434)
@@ -29,7 +29,7 @@
//////
//First test the FunctionH2 class
//
- [Test]
+ //[Test]
public void TestGetFormulas()
{
ProcessFormulas formula =3D new ProcessFormulas();
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-28 2=
0:57:49 UTC (rev 1433)
+++ humano2/branches/viewtools/components/tests/viewTools.cs 2005-06-29 2=
2:12:11 UTC (rev 1434)
@@ -15,6 +15,7 @@
using Humano2.Core;
using Humano2.Core.Db;
using Humano2.Components.ViewTools;
+using System.Collections;
using NUnit.Framework;
=20
namespace Humano2.Components.Test.ViewTools
@@ -34,7 +35,43 @@
crud =3D complex.GetCore().Crud; =20
}
=20
- [Test]
+ //[Test]
+ public void getTableList()
+ {
+ init(); =20
+ Humano2.Components.ViewTools.ViewTools vt =3D new Humano2.Components.=
ViewTools.ViewTools(10162);
+ vt.Complex =3D complex;
+ vt.KeyFlag =3D 0; =20
+ =20
+ ViewTable [] affectedTables =3D vt.TestGetTableList("10181,1=
0229^18,10231^18".Split(",".ToCharArray()));
+ ViewColumns[] affectedColumns;
+ =20
+ foreach(ViewTable table in affectedTables)
+ {
+ affectedColumns =3D table.Columns;
+ Logger.Log("TableName: " + table.TableName, LogLevel.Tra=
ce); =20
+ foreach(ViewColumns Cols in affectedColumns)
+ {
+ Logger.Log("Cols Name: " + Cols.ColumnName, LogLevel=
.Trace); =20
+ }
+ Logger.Log("---", LogLevel.Trace);
+ }
+ =20
+ Logger.Log("affectedTables[0].TableName: " + affectedTables[=
0].TableName, LogLevel.Trace);
+ Assert.IsTrue(affectedTables[0].TableName =3D=3D "\"d10160cT=
icket\"");
+ =20
+ affectedColumns =3D affectedTables[0].Columns;
+ Assert.IsTrue(affectedColumns[0].ColumnName =3D=3D "\"c10162=
Title\"");
+ Logger.Log("affectedColumns[0].ColumnName: " + affectedColum=
ns[0].ColumnName, LogLevel.Trace);
+ =20
+ Assert.IsTrue(affectedTables[1].TableName =3D=3D "\"user\"")=
;
+ affectedColumns =3D affectedTables[1].Columns;
+ Assert.IsTrue(affectedColumns[0].ColumnName =3D=3D "\"email\=
"");
+ Assert.IsTrue(affectedColumns[1].ColumnName =3D=3D "\"email\=
"");
+ }
+ =20
+ =20
+ //[Test]
public void SQLSelect()
{
init(); =20
@@ -46,30 +83,35 @@
//Simple columns
string strSelect =3D vt.SQLSelect("10181");
Logger.Log("SQLSelect(\"10181\"): " + strSelect,LogLevel.Tra=
ce);
- Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT \"d10160cTicke=
t\".\"c10162Title\"".Trim());
+ Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT d10160cTicket0=
.\"c10162Title\"".Trim());
strSelect =3D vt.SQLSelect("0,10181");
Logger.Log("SQLSelect(\"0,10181\"): " + strSelect,LogLevel.T=
race);
- Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT \"d10160cTicke=
t\".id_entity, \"d10160cTicket\".\"c10162Title\"".Trim());
+ Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT d10160cTicket0=
.id_entity, d10160cTicket1.\"c10162Title\"".Trim());
=20
//Pertinence columns
strSelect =3D vt.SQLSelect("10231");
Logger.Log("SQLSelect(\"10231\"): " + strSelect,LogLevel.Tra=
ce);
- Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT \"d10160cTicke=
t\".\"c10162Assigned to3\"".Trim());
+ Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT d10160cTicket0=
.\"c10162Assigned to3\"".Trim());
=20
strSelect =3D vt.SQLSelect("10231^18");
Logger.Log("SQLSelect(\"10231^18\"): " + strSelect,LogLevel.=
Trace);
- Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT \"user\".\"ema=
il\"".Trim());
+ Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT user0.\"email\=
"".Trim());
=20
strSelect =3D vt.SQLSelect("10181,10231^18");
Logger.Log("SQLSelect(\"10181,10231^18\"): " + strSelect,Log=
Level.Trace);
- Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT \"d10160cTicke=
t\".\"c10162Title\", \"user\".\"email\"".Trim());
+ Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT d10160cTicket0=
.\"c10162Title\", user0.\"email\"".Trim());
=20
strSelect =3D vt.SQLSelect("10187^10179");
Logger.Log("SQLSelect(\"10187^10179\"): " + strSelect,LogLev=
el.Trace);
- Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT \"d10160cTicke=
t Status\".\"c10163Status Name\"".Trim());
+ Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT d10160cTicketS=
tatus0.\"c10163Status Name\"".Trim());
+ =20
+ //Double Pertinence on the same class
+ strSelect =3D vt.SQLSelect("10229^18,10231^18");
+ Logger.Log("SQLSelect(\"10229^18,10231^18\"): " + strSelect,=
LogLevel.Trace);
+ Assert.IsTrue(strSelect.Trim() =3D=3D "SELECT user0.\"email\=
", user1.\"email\" as \"email1\"".Trim());=20
}
=20
- [Test]
+ //[Test]
public void SQLWhere()
{
init(); =20
@@ -81,16 +123,16 @@
//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 \"d10160cTicket =
Status\".\"c10163Status Name\" ILIKE '%closed%'".Trim());
+ 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 \"d10160cTicket =
Status\".\"c10163Status Name\" ILIKE '%closed%' AND \"d10160cTicket\".\"c=
10162Title\" =3D 'Joli ticket'".Trim()); =20
+ Assert.IsTrue(strWhere.Trim() =3D=3D "WHERE d10160cTicketSta=
tus0.\"c10163Status Name\" ILIKE '%closed%' AND d10160cTicket1.\"c10162Ti=
tle\" =3D 'Joli ticket'".Trim()); =20
}
=20
- [Test]
+ //[Test]
public void SQLOrderBy()
{
init(); =20
@@ -103,7 +145,7 @@
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
@@ -116,7 +158,7 @@
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());
}
=20
- [Test]
+ //[Test]
public void ParseQuery()
{
init(); =20
@@ -139,6 +181,42 @@
Assert.IsTrue(strQuery.Trim() =3D=3D "SELECT \"d10160cTicket=
\".id_entity, \"d10160cTicket\".\"c10162Title\", \"d10160cTicket\".\"c101=
62Date\", \"user\".\"email\", \"d10160cTicket\".\"c10162Resolution Date\"=
FROM \"d10160cTicket\" inner join \"entity\" on \"d10160cTicket\".id_ent=
ity =3D \"entity\".id_entity and entity.\"delDate\" is null LEFT JOIN \=
"user\" ON \"d10160cTicket\".\"c10162Assigned to3\" =3D \"user\".id_entit=
y LEFT JOIN entity e1 ON \"user\".id_entity =3D e1.id_entity LEFT JOIN \=
"d10160cTicket Status\" ON \"d10160cTicket\".\"c10162Status\" =3D \"d1016=
0cTicket Status\".id_entity LEFT JOIN entity e2 ON \"d10160cTicket Status=
\".id_entity =3D e2.id_entity WHERE e1.\"delDate\" IS NULL AND e2.\"delD=
ate\" IS NULL and \"d10160cTicket Status\".\"c10163Status Name\" ILIKE '=
%closed%' ORDER BY upper(\"user\".\"email\") asc".Trim());
}
=20
+ [Test]
+ public void getSQLVars()
+ {
+ //Logger.Log("<<getSQLVars>>", LogLevel.Trace);
+ init(); =20
+ Humano2.Components.ViewTools.ViewTools vt =3D new Humano2.Components.=
ViewTools.ViewTools(10162);
+ vt.Complex =3D complex;
+ vt.KeyFlag =3D 0; =20
+ string strSelect =3D "0,10181,10208,10213,10231^18";
+ string strWhere =3D "10231^18|4|'to...@em...'|1|0;10229^18=
|7|'lulu'|0|0";
+ =20
+ SortedList SQLVarsList =3D vt.TestGetSQLVars(strSelect,strWh=
ere);
+ =20
+ string tableName0 =3D Convert.ToString(SQLVarsList.GetByInde=
x(SQLVarsList.IndexOfKey("10231^18")));=20
+ string tableName1 =3D Convert.ToString(SQLVarsList.GetByInde=
x(SQLVarsList.IndexOfKey("10229^18")));
+ //Logger.Log("tableName0 =3D " + tableName0,LogLevel.Trace);
+ //Logger.Log("tableName1 =3D " + tableName1,LogLevel.Trace);
+ Assert.IsTrue(tableName0 =3D=3D "user0");
+ Assert.IsTrue(tableName1 =3D=3D "user1");
+ =20
+ strSelect =3D "0,10181,10208,10213,10229^18,10231^18";
+ strWhere =3D "10187^10179|4|'open'|0|0;";
+ =20
+ SQLVarsList =3D vt.TestGetSQLVars(strSelect,strWhere);
+ =20
+ tableName0 =3D Convert.ToString(SQLVarsList.GetByIndex(SQLVa=
rsList.IndexOfKey("10229^18")));=20
+ tableName1 =3D Convert.ToString(SQLVarsList.GetByIndex(SQLVa=
rsList.IndexOfKey("10231^18")));
+ string tableName2 =3D Convert.ToString(SQLVarsList.GetByInde=
x(SQLVarsList.IndexOfKey("10187^10179")));
+ //Logger.Log("tableName0 =3D " + tableName0,LogLevel.Trace);
+ //Logger.Log("tableName1 =3D " + tableName1,LogLevel.Trace);
+ //Logger.Log("tableName2 =3D " + tableName2,LogLevel.Trace);
+ =20
+ Assert.IsTrue(tableName0 =3D=3D "user0");
+ Assert.IsTrue(tableName1 =3D=3D "user1");
+ Assert.IsTrue(tableName2 =3D=3D "d10160cTicketStatus2");
+ }
=20
/// <summary>
/// Funcion que genera un datatable con la forma en que ViewTool=
s lo recibe...
Modified: humano2/branches/viewtools/components/tests/xmltools.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/xmltools.cs 2005-06-28 20=
:57:49 UTC (rev 1433)
+++ humano2/branches/viewtools/components/tests/xmltools.cs 2005-06-29 22=
:12:11 UTC (rev 1434)
@@ -35,7 +35,7 @@
return filereadbuf;
}
=20
- [Test]
+ //[Test]
public void OrderAttributesInDataStructure()
{
//Loads the xml in a string
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-=
28 20:57:49 UTC (rev 1433)
+++ humano2/branches/viewtools/components/viewTools/ViewTools.cs 2005-06-=
29 22:12:11 UTC (rev 1434)
@@ -36,6 +36,7 @@
private string _whereInit =3D "";
private bool _caseSensitive; //To allow doing insensitive case s=
earch
private string query; //To get the query from outside
+ =20
#endregion
=20
#region "CONSTRUCTORES"
@@ -288,6 +289,45 @@
#endregion
=20
#region "METODOS"
+ =20
+ private SortedList getSQLVars(string strSelect, string strWhere)
+ {
+ //Logger.Log("<<getSQLVars>>", LogLevel.Trace);
+ SortedList res =3D new SortedList();
+ =20
+ //Parse strSelect and fill the sortedList
+ string [] strSelectArr =3D strSelect.Split(",".ToCharArray()=
);
+ string [] strWhereArr =3D strWhere.Split(";".ToCharArray());
+ int globalIndex =3D 0;
+ globalIndex =3D fillSortedListWithPertAttributes(res, strSel=
ectArr, 0);
+ fillSortedListWithPertAttributes(res, strWhereArr, globalInd=
ex);
+ return res;
+ }
+ =20
+ ///<summary>With a list of attributes fills a sorted list with (=
att,SQLVar) id the att is a pert att</summary>
+ ///<param name=3D"list">The list to fill</param>
+ ///<param name=3D"attributes">The list of attributes</param>
+ ///<param name=3D"index">The index used to create the name of va=
riables: TableName concatenated to index</param>
+ private int fillSortedListWithPertAttributes(SortedList list, st=
ring [] attributes, int index)
+ {
+ for(int i=3D0; i<attributes.Length;i++)
+ {
+ 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);
+ bool isPert =3D fullAtt.IndexOf('^') !=3D -1;
+ if(!list.ContainsKey(fullAtt) && isPert)
+ {
+ //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);
+ index++;
+ }
+ }
+ return index;
+ }
+ =20
public void ChangeSelect(string strSelect, string strWhere)
{
Select =3D SQLSelect(strSelect);
@@ -379,10 +419,10 @@
Logger.Log("Final Statement was: " + sql, LogLevel.Error); =09
throw ex;
}
- =09
}
=20
- if(find > -1) {
+ if(find > -1)=20
+ {
Complex.doCommand(dropTable);
}
return res;
@@ -407,13 +447,37 @@
return xml;
}
=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
public string SQLSelect(string param)
{
- ViewTable[] affectedTables;
+ Logger.Log("<<SQLSelect:>>",LogLevel.Trace);
+ =20
+ ViewTable[] affectedTables;
StringBuilder Query =3D new StringBuilder();
ViewColumns[] affectedColumns;
Logger.Log("SQLSelect: " + param,LogLevel.Trace);
- affectedTables =3D GetTableList(param.Split(",".ToCharArray(=
)));
+ affectedTables =3D getTableList(param.Split(",".ToCharArray(=
)));
int i =3D 1;
ArrayList values =3D new ArrayList();
DisplayOrder[] disp;
@@ -422,35 +486,33 @@
foreach(ViewTable table in affectedTables)
{
affectedColumns =3D table.Columns;
- =09
+ int index =3D 0;
foreach(ViewColumns Cols in affectedColumns)
{
aux =3D new DisplayOrder();
- if(Cols.Function =3D=3D Enums.AggregateFunctions.nofunc)
- {
- aux.Position =3D Cols.Position;
- aux.Text =3D table.TableName + "." + Cols.ColumnName + ", ";
- aux.Id =3D Cols.ColumnIndex;
- aux.Type =3D Cols.Type;
- }
- else
- {
- switch(Cols.Function)
- {
- case Enums.AggregateFunctions.count:
- aux.Position =3D Cols.Position;
- aux.Text =3D "count(" + table.TableName + "." + Cols.ColumnName =
+ "), ";
- aux.Id =3D Cols.ColumnIndex;
- aux.Type =3D Cols.Type;
- break;
- case Enums.AggregateFunctions.sum:
- aux.Position =3D Cols.Position;
- aux.Text =3D "sum(" + table.TableName + "." + Cols.ColumnName + =
"), ";
- aux.Id =3D Cols.ColumnIndex;
- aux.Type =3D Cols.Type;
- break;
- }
- }
+ string tableAffectedName =3D getSQLTableVar(table.Ta=
bleName,index++);
+ string beginFunction =3D "";
+ string endFunction =3D "";
+ =20
+ switch(Cols.Function)
+ {
+ case Enums.AggregateFunctions.nofunc:
+ beginFunction =3D "";
+ endFunction =3D "";
+ break;
+ case Enums.AggregateFunctions.count:
+ beginFunction =3D "count(";
+ endFunction =3D ")";
+ break;
+ case Enums.AggregateFunctions.sum:
+ beginFunction =3D "sum(";
+ endFunction =3D ")";
+ break;
+ }
+ aux.Text =3D beginFunction + tableAffectedName + end=
Function + "." + Cols.ColumnName + ", ";
+ aux.Position =3D Cols.Position;
+ aux.Id =3D Cols.ColumnIndex;
+ aux.Type =3D Cols.Type;
values.Add(aux);
i++;
}
@@ -476,6 +538,7 @@
int begin =3D var.Text.IndexOf(".")+1;
int end =3D var.Text.IndexOf(",",begin);
string field =3D var.Text.Substring(begin,end - begin);
+ Logger.Log("field: " + field, LogLevel.Trace);
if (selCols.ContainsKey(field))
{
field =3D field.Replace("\"","");
@@ -530,7 +593,7 @@
relations =3D GetRelatedTableList((string[])cols.ToArray(typeof(strin=
g)));
if(relations.Length > 0)
{
- //ViewRelation previousRelation =3D null;=09
+ //ViewRelation previousRelation =3D null;=09
string relationType =3D "";
ArrayList tableDictionary =3D new ArrayList();
int counter =3D 1;
@@ -1029,6 +1092,7 @@
=09
strFilters.Append(tableName + "." + columnName + " ");
int recursionIndex;
+ Logger.Log("parameters[2]: " + parameters[2],LogLevel.Tr=
ace);
recursionIndex =3D parameters[2].IndexOf("{");
=20
if(recursionIndex !=3D -1)
@@ -1201,7 +1265,7 @@
break;
}
=20
- if(parameters[4] =3D=3D "2")
+ if(parameters[4] =3D=3D "2") //FIXME: Should not be =3D=3D"1"??
{
strFilters.Append(") ");
}
@@ -1234,7 +1298,7 @@
return parameter;
}
=20
- private ViewTable[] GetTableList(string[] strParams)
+ private ViewTable[] getTableList(string[] strParams)
{
ArrayList TableNames =3D new ArrayList();
ArrayList Tables =3D new ArrayList();
@@ -1243,11 +1307,11 @@
string tableName;
int columnIndex, tablePosition;
int i =3D 1;
- Logger.Log("GetTableList. Step 1",LogLevel.Trace);
+ //Logger.Log("getTableList. Step 1",LogLevel.Trace);
foreach(string Indice in strParams)
{
- Logger.Log("GetTableList. Loop",LogLevel.Trace);
- Logger.Log("GetTableList. param=3D " + Indice,LogLevel.T=
race);
+ //Logger.Log("getTableList. Loop",LogLevel.Trace);
+ //Logger.Log("getTableList. param=3D " + Indice,LogLevel=
.Trace);
string valor =3D Indice.Split("|".ToCharArray()).GetValu=
e(0).ToString();
if(IsNumeric(valor))
{
@@ -1272,11 +1336,13 @@
Logger.Log("columnIndex=3D" + columnIndex,LogLevel.Trace);
Col =3D new ViewColumns(columnIndex,Complex.ColumnNa=
me(columnIndex));
Col.Type =3D Complex.InstanceType(columnIndex);
+ tableName =3D Complex.TableName(columnIndex);
}
else
{
Col =3D new ViewColumns(0,"id_entity");
Col.Type =3D "int";
+ tableName =3D Complex.TableName(IdClass);
}
=09
try
@@ -1288,17 +1354,7 @@
Col.Function =3D (Enums.AggregateFunctions)0;
}
=20
- if(columnIndex !=3D 0)
- {
- tableName =3D Complex.TableName(columnIndex);
- }
- else
- {
- tableName =3D Complex.TableName(IdClass);
- }
-
tablePosition =3D TableNames.IndexOf(tableName);
- =20
if(tablePosition < 0)
{
Table =3D new ViewTable();
@@ -1311,43 +1367,30 @@
{
Table.TableIndex =3D IdClass;
}
-
- if(IdClass !=3D Table.TableIndex && KeyFlag =3D=3D 1)
- {
- ViewColumns aux =3D new ViewColumns(0,"id_entity");
- aux.Position =3D i;
- aux.Type =3D "int";
- Table.AddColumn(aux);
- i++;
- }
- Col.Position =3D i;
-
Table.PrimaryKeyName =3D "id_entity";
- Table.AddColumn(Col);
Tables.Add(Table);
TableNames.Add(tableName);
}
else
{
Table =3D (ViewTable)Tables[tablePosition];
- // Tables.RemoveAt(tablePosition);
- if(IdClass !=3D Table.TableIndex && KeyFlag =3D=3D 1)
- {
- ViewColumns aux =3D new ViewColumns(0,"id_entity");
- aux.Position =3D i;
- aux.Type =3D "int"; =20
- Table.AddColumn(aux);
- i++;
- }
- Col.Position =3D i;
- Table.AddColumn(Col);
- // Tables.Add(Table);
}
+ =20
+ if(IdClass !=3D Table.TableIndex && KeyFlag =3D=3D 1)
+ {
+ ViewColumns aux =3D new ViewColumns(0,"id_entity");
+ aux.Position =3D i;
+ aux.Type =3D "int"; =20
+ Table.AddColumn(aux);
+ i++;
+ }
+ Table.AddColumn(Col);
+ Col.Position =3D i;
i++;
}
return (ViewTable[])Tables.ToArray(typeof(ViewTable));
}
-
+ =20
private int[] GetParentIndexes(int id_entity)
{
object res =3D null;
@@ -1374,7 +1417,7 @@
StringBuilder Query =3D new StringBuilder();
string iniTable, endTable;
=09
- parentIndexes =3D GetParentIndexes(intIdClass);
+ parentIndexes =3D GetParentIndexes(intIdClass);
=20
for(int i =3D 0; i<=3D parentIndexes.Length - 2;i++)
{
@@ -1383,17 +1426,14 @@
if(previousRelation =3D=3D 0)
{
Query.Append(iniTable + " inner join " + endTable);
- Query.Append(" on " + iniTable + ".id_entity");
- Query.Append(" =3D " + endTable + ".id_entity ");
- previousRelation =3D 1;
}
else
{
Query.Append("inner join" + endTable);
- Query.Append(" on " + iniTable + ".id_entity");
- Query.Append(" =3D " + endTable + ".id_entity ");
- previousRelation =3D 1;
}
+ Query.Append(" on " + iniTable + ".id_entity");
+ Query.Append(" =3D " + endTable + ".id_entity ");
+ previousRelation =3D 1;
}
Query.Append("and entity.\"delDate\" is null ");
return Query.ToString();
@@ -1693,9 +1733,20 @@
}
return res;
}
+ =20
+ ////////////////////////////////////////////////////////////////=
/////////////////////////////////////////////////
+ //These functions are not used in the code. They are only here t=
o be able to test private functions from outside
+ //
+ public ViewTable[] TestGetTableList(string [] strParams)
+ {
+ return getTableList(strParams);
+ }
+ =20
+ public SortedList TestGetSQLVars(string strSelect, string strWhe=
re)
+ {
+ return getSQLVars(strSelect,strWhere); =20
+ }
=20
-
#endregion
-
}
}
Modified: humano2/branches/viewtools/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/branches/viewtools/core/db/absComplex.cs 2005-06-28 20:57:49 =
UTC (rev 1433)
+++ humano2/branches/viewtools/core/db/absComplex.cs 2005-06-29 22:12:11 =
UTC (rev 1434)
@@ -118,6 +118,12 @@
///<returns>Devuele un true si una clase. Si no, false.</returns>
abstract public bool IsClass(int idEntity);
=20
+ ///<sumaray>Returns the sysName of a class given the classId</su=
mmary>
+ ///<param name=3D"classId">The id of the class</param>
+ ///<returns>The sysName of the class</returns>
+ abstract public string GetClassSysName(string classId);
+ =20
+ =20
/// <summary>
/// Resuelve el sysName de una clase con '"' antes y despues del strin=
g.
/// </summary>
@@ -329,14 +335,21 @@
abstract public void finalImport(string [,] attsArr, DataSet dsAtts, s=
tring tableName, int domainId, int classId);
=20
/// <summary>
- /// Get the string id of the pertinence attribute an attribute is relat=
ed to
+ /// Get the string id of the pertinence attribute an attribute is r=
elated to
/// </summary>
/// <param name=3D"attributeId">The attribute for which we want =
the pertinence attribute related to</param>
/// <returns>The attribute of the pertinence attribute or "" if =
attributeId is not a pertinence attribute</returns>
abstract public string GetPertinenceForAttribute(string attribut=
eId);
=20
+ ///<summary>
+ ///Returns the class a pertinence attribute points to
+ ///<summary>
+ ///<param name=3D"attributeId">the pertinence attribute</param>
+ ///<returns>The id_entity of the class pointed by the attribute.=
If the att is not a pert att, returns ""</returns>
+ abstract public string GetPertinenceClassForAttribute(string att=
ributeId);
+ =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>
@@ -395,7 +408,6 @@
///</summary>
/// <param name=3D"classId">The classId of an attribute</param>
/// <returns>the sys name of basic attribute</returns>
-
abstract public string GetBasicAttributeSysName(int classId);
=20
=20
Modified: humano2/branches/viewtools/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/branches/viewtools/core/db/pgsql/pgsqlComplex.cs 2005-06-28 2=
0:57:49 UTC (rev 1433)
+++ humano2/branches/viewtools/core/db/pgsql/pgsqlComplex.cs 2005-06-29 2=
2:12:11 UTC (rev 1434)
@@ -934,6 +934,38 @@
}
}
=20
+ =20
+ override public string GetPertinenceClassForAttribute(string att=
ributeId)
+ {
+ string req =3D "select \"to\" from pertinence where id_entit=
y =3D" + attributeId;
+ DataTable dt =3D doSelect(req);
+ if( (dt =3D=3D null) || (dt.Rows.Count =3D=3D 0))
+ {
+ return ""; =20
+ }
+ else
+ {
+ return Convert.ToString(dt.Rows[0]["to"]); //Get the per=
tinence attribute
+ }
+ }
+ =20
+ =20
+ override public string GetClassSysName(string classId)
+ {
+ string req =3D "select \"sysName\" from class where id_entit=
y=3D" + classId;
+ string res =3D "";
+ DataTable dt =3D doSelect(req);
+ try
+ {
+ res =3D Convert.ToString(dt.Rows[0]["sysName"]);
+ }
+ catch
+ {
+ Logger.Log("GetClassSysName: " + classId + " is not the =
id of a class... :(",LogLevel.Trace);
+ }
+ return res;
+ }
+ =20
/// <summary>
/// Converts a system attribute name into a user attribute name
/// </summary>
|