}
s.setResultsTable(h);
}
}
String rn = null;
Criteria c = null;
String n = null;
String tt = null;
Hashtable<String, String> rns = new Hashtable<String, String>();
//Vector vm = new EZArrayList(sqps.keys());
//vm.add(sqp.getTable());
//(jincludealllist + " ****jincludealllist**** " + r + ":" + h);
for (int ct = 0;ct < jincludealllist.size();ct++)
{
c = (Criteria)jincludealllist.elementAt(ct);
if (!c.getCompareOperator().equals("="))
throw JGException.get("operator_not_supported_for_joins",c.getCompareOperator() + " Operator not supported for joins");
n = c.getName();
tt = findTable(n);
//(sqp.getTable() + ":" + n + " ****jincludealllist 2 **** " + tt);
//realm_user1:realm_username ****jincludealllist 2 **** realm_userrole1
//realm_user1:role.realm_username ****jincludealllist 2 **** role
if (tt == null)
throw JGException.get("table_not_found_for_join_criteria",n + " Table not found for join criteria");
if (!sqp.getTable().equals(tt) && sqps.get(tt) == null)
throw JGException.get("invalid_table_for_join_criteria",n + " Invalid Table for join criteria " + tt);
if (sqp.getTable().equals(tt)){
rn = n;
//vm.remove(tt);
//continue;
}
else{
rns.put(tt,n);
//vm.remove(tt);
if (sqp.getTableInfo().getColumnInfo(sqp.getRealColName(n)) == null)
{
String t = (String)sqp.getAliases().get(sqp.getTable());
if (t != null)
{
sqp.setTable(t);
//("DID YO WOK RELAN " + t + ":" + n + ":" + sqp.getRealColName(n) + ":" + sqp.getTableInfo() + ":" + sqp.getTableInfo().getColumnInfo(sqp.getRealColName(n)) + ":" + sqp);
}
}
if (sqp.getTableInfo().getColumnInfo(sqp.getRealColName(n)) != null)
{
rn = n;
//vm.remove(sqp.getTable());
}
//continue;
}
n = c.getValueString();
tt = findTable(n);
if (tt == null)
throw JGException.get("table_not_found_for_join_criteria",n + " Table not found for join criteria");
if (!sqp.getTable().equals(tt) && sqps.get(tt) == null)
throw JGException.get("invalid_table_for_join_criteria",n + " Invalid Table for join criteria " + tt);
//(sqp.getTable() + ":" + tt + " THE RELAN NAME " + rn + ":" + n);
//realm_user1:role THE RELAN NAME realm_username:role.realm_username
//realm_user1:realm_user1 THE RELAN NAME role.realm_username:user.realm_username
if (sqp.getTable().equals(tt)){
//vm.remove(tt);
rn = n;
//continue;
}
else{
//vm.remove(tt);
rns.put(tt,n);
if (sqp.getTableInfo().getColumnInfo(sqp.getRealColName(n)) != null)
{
rn = n;
//vm.remove(sqp.getTable());
}
}
}
if (rn == null)
{
en = rns.keys();
while (en.hasMoreElements()){
tt = en.nextElement().toString();
n = rns.get(tt);
if (sqp.getTableInfo().getColumnInfo(sqp.getRealColName(n)) != null)
{
rn = n;
//vm.remove(sqp.getTable());
break;
}
}
}
if (rn == null)
throw JGException.get("missing_main_join_dependency",sqp.getTable() + " Missing main join dependency ");
int type = sqp.getTableInfo().getColumnInfo(sqp.getRealColName(rn)).getColumnType();
if (rns.size() > sqps.size())
throw JGException.get("missing_join_dependencies",n + " Missing join dependencies " + rns + ":" + rns.size() + "!=" + sqps.size());
//else
// //(n + " FOUND dependencies " + rns + ":" + rns.size() + "==" + sqps.size());
en = rns.keys();
while (en.hasMoreElements()){
tt = en.nextElement().toString();
n = rns.get(tt);
s = (SQLParser)sqps.get(tt);
//("DID YO WOK " + tt + ":" + n + ":" + s.getRealColName(n) + ":" + s.getTableInfo() + ":" + s.getTableInfo().getColumnInfo(s.getRealColName(n)) + ":" + s);
if (s.getTableInfo().getColumnInfo(s.getRealColName(n)) == null)
{
String t = (String)s.getAliases().get(s.getTable());
if (t != null)
{
s.setTable(t);
}
//("DID YO WOK @ FORCE " + tt + ":" + n + ":" + s.getRealColName(n) + ":" + s.getTableInfo() + ":" + s.getTableInfo().getColumnInfo(s.getRealColName(n)) + ":" + s);
}
if (s.getTableInfo().getColumnInfo(s.getRealColName(n)).getColumnType() != type)
throw JGException.get("incompatible_join_criteria",n + " Incompatible join criteria " + tt);
}
//Hashtable (String rn,Hashtable h,int typ,Object v)
Vector vr = new Vector();
NameValuePairs row = null;
h = null;
String n2 = null;
String tt2 = null;
Vector joined = new Vector();
Vector j1 = null;
Vector j2 = null;
EZArrayList nvr = new EZArrayList();
Vector vt = null;
Object val = null;
NameValuePairs ref = null;
for (int ct = 0;ct < jincludealllist.size();ct++)
{
c = (Criteria)jincludealllist.elementAt(ct);
n = c.getName();
tt = findTable(n);
//("************TT1 " + tt);
if (sqp.getTableInfo().getColumnInfo(sqp.getRealColName(n)) != null)
tt = sqp.getTable();
//("************TT2 " + tt);
n2 = c.getValueString();
tt2 = findTable(n2);
if (sqp.getTableInfo().getColumnInfo(sqp.getRealColName(n2)) != null && !tt.equals(sqp.getTable()))
tt2 = sqp.getTable();
//role.realm_username Cannot join the same table realm_user1:realm_user1
if (tt.equals(tt2))