Files
iTop/test/core/OQLParserTest.php
Pierre Goiffon d8e2a1cc7c Merge branch 'support/2.7' into develop
# Conflicts:
#	README.md
#	composer.json
#	composer.lock
#	core/cmdbsource.class.inc.php
#	core/dbobject.class.php
#	datamodels/2.x/combodo-db-tools/db_analyzer.class.inc.php
#	datamodels/2.x/combodo-db-tools/dbtools.php
#	datamodels/2.x/combodo-db-tools/dictionaries/zh_cn.dict.combodo-db-tools.php
#	datamodels/2.x/itop-attachments/dictionaries/zh_cn.dict.itop-attachments.php
#	datamodels/2.x/itop-core-update/dictionaries/zh_cn.dict.itop-core-update.php
#	dictionaries/zh_cn.dictionary.itop.core.php
#	dictionaries/zh_cn.dictionary.itop.ui.php
#	lib/composer/InstalledVersions.php
#	lib/composer/autoload_classmap.php
#	lib/composer/autoload_static.php
#	lib/composer/installed.php
#	lib/composer/platform_check.php
#	pages/ajax.render.php
#	pages/csvimport.php
#	setup/ajax.dataloader.php
#	setup/index.php
#	setup/setuputils.class.inc.php
#	test/application/UtilsTest.php
2021-06-14 16:19:56 +02:00

90 lines
74 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: Eric
* Date: 31/08/2018
* Time: 17:03
*/
namespace Combodo\iTop\Test\UnitTest\Core;
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
use DBObjectSearch;
use OQLException;
use OqlInterpreter;
use OQLParserException;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class OQLParserTest extends ItopDataTestCase
{
const USE_TRANSACTION = false;
/**
* @group iTopChangeMgt
* @group itopConfigMgmt
* @group itopRequestMgmt
* @dataProvider NestedQueryProvider
*
* @param $sQuery
*
* @throws \OQLException
*/
public function testGoodNestedQueryQueryParser($sQuery)
{
$this->debug($sQuery);
$oDbObjectSearch = DBObjectSearch::FromOQL($sQuery);
$sOql=$oDbObjectSearch->ToOQL();
$this->debug($sOql);
self::assertEquals($sQuery,$sOql);
}
public function NestedQueryProvider()
{
return array(
array("SELECT `U` FROM User AS `U` JOIN Person AS `P` ON `U`.contactid = `P`.id WHERE ((`U`.`status` = 'enabled') AND (`U`.`id` NOT IN (SELECT `U` FROM User AS `U` JOIN Person AS `P` ON `U`.contactid = `P`.id JOIN URP_UserOrg AS `L` ON `L`.userid = `U`.id WHERE ((`U`.`status` = 'enabled') AND (`L`.`allowed_org_id` = `P`.`org_id`)) UNION SELECT `U` FROM User AS `U` WHERE ((`U`.`status` = 'enabled') AND (`U`.`id` NOT IN (SELECT `U` FROM User AS `U` JOIN URP_UserOrg AS `L` ON `L`.userid = `U`.id WHERE (`U`.`status` = 'enabled')))))))"),
array("SELECT `Ur` FROM UserRequest AS `Ur` WHERE (`Ur`.`id` NOT IN (SELECT `Ur` FROM UserRequest AS `Ur` JOIN lnkFunctionalCIToTicket AS `lnk` ON `lnk`.ticket_id = `Ur`.id WHERE 1))"),
array("SELECT `T` FROM Ticket AS `T` WHERE ((`T`.`finalclass` IN ('userrequest', 'change')) AND (`T`.`id` NOT IN (SELECT `Ur` FROM UserRequest AS `Ur` JOIN lnkFunctionalCIToTicket AS `lnk` ON `lnk`.ticket_id = `Ur`.id WHERE 1 UNION SELECT `C` FROM Change AS `C` JOIN lnkFunctionalCIToTicket AS `lnk` ON `lnk`.ticket_id = `C`.id WHERE 1)))"),
array("SELECT `PhysicalDevice` FROM PhysicalDevice AS `PhysicalDevice` WHERE ((`PhysicalDevice`.`status` = 'production') AND (`PhysicalDevice`.`id` NOT IN (SELECT `p` FROM PhysicalDevice AS `p` JOIN lnkFunctionalCIToProviderContract AS `l` ON `l`.functionalci_id = `p`.id WHERE 1)))"),
array('SELECT `UserRequest` FROM UserRequest AS `UserRequest` JOIN Person AS `P` ON `UserRequest`.agent_id = `P`.id JOIN Organization AS `Organization` ON `P`.org_id = `Organization`.id WHERE (`UserRequest`.`org_id` IN (SELECT `Organization` FROM Organization AS `Organization` WHERE (`Organization`.`id` = `UserRequest`.`org_id`)))'),
array('SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (`UserRequest`.`org_id` IN (SELECT `Organization` FROM Organization AS `Organization` WHERE (`Organization`.`id` = `UserRequest`.`org_id`)))'),
array('SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (`UserRequest`.`org_id` IN (SELECT `Organization` FROM Organization AS `Organization` WHERE 1))'),
array('SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (`UserRequest`.`org_id` NOT IN (SELECT `Organization` FROM Organization AS `Organization` WHERE 1))'),
array('SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (`UserRequest`.`org_id` IN (SELECT `Organization` FROM Organization AS `Organization` JOIN Organization AS `Organization1` ON `Organization`.parent_id BELOW `Organization1`.id WHERE (`Organization1`.`id` = \'3\')))'),
array('SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE (`UserRequest`.`org_id` IN (SELECT `Organization` FROM Organization AS `Organization` WHERE (`Organization`.`id` = \'3\')))'),
array("SELECT `L`, `P` FROM Location AS `L` JOIN Person AS `P` ON `P`.location_id = `L`.id WHERE 1"),
array("SELECT `UserRequest` FROM UserRequest AS `UserRequest` WHERE ((`UserRequest`.`agent_id` = :current_contact_id) AND (`UserRequest`.`status` NOT IN ('closed', 'resolved')))"),
array("SELECT `L` FROM Person AS `P` JOIN Location AS `L` ON `P`.location_id = `L`.id WHERE 1"),
);
}
/**
* Bug N°4052 OQL parser limit for huge request
* @throws \OQLException
*/
public function testOQLParserStackSize()
{
// OQL Parser stack size is 1000
$sQuery = "SELECT Organization WHERE 1";
$sQuery .= str_repeat(" UNION SELECT Organization WHERE 1", 497);
//$sExpression = "SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk1`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk1`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk1`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk1`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk1`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk1`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk1`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk1`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk1`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root3`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s1`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s1`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk1`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root4`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s2`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s2`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk1`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s3`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s3`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root5`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t5`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `lnk1` ON `lnk1`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk1`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s4`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s4`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root6`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`Root`.`id` = :current_contact->org_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`l2`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`l2`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`l2`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`l2`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`l2`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`l2`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`l2`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`l2`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`l2`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root3`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s1`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s1` ON `GARE`.service_id = `s1`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s1`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s1`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root3`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`l2`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root4`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s2`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s2` ON `GARE`.service_id = `s2`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s2`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s2`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk5`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`l2`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s3`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s3`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root5`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s3` ON `GARE`.service_id = `s3`.id JOIN lnkOrganizationToService AS `lnk6` ON `lnk6`.service_id = `s3`.id JOIN Team AS `t5` ON `lnk6`.team_id = `t5`.id JOIN Organization AS `Node5` ON `t5`.org_id = `Node5`.id JOIN Organization AS `Root5` ON `Node5`.parent_id BELOW `Root5`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root5`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t5`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`Root5`.`id` = :current_contact->org_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`l2`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id JOIN lnkServiceToTeam AS `lnk2` ON `lnk2`.service_id = `s4`.id JOIN Team AS `t3` ON `lnk2`.team_id = `t3`.id JOIN Organization AS `Node3` ON `t3`.org_id = `Node3`.id JOIN Organization AS `Root3` ON `Node3`.parent_id BELOW `Root3`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root3`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id JOIN lnkServiceToTeam AS `lnk3` ON `lnk3`.service_id = `s4`.id JOIN Team AS `t4` ON `lnk3`.team_id = `t4`.id JOIN Organization AS `Node4` ON `t4`.org_id = `Node4`.id JOIN Organization AS `Root4` ON `Node4`.parent_id BELOW `Root4`.id JOIN lnkOrganizationToPerson AS `lnk5` ON `lnk5`.organization_id = `Root4`.id JOIN lnkPersonToTeam AS `lnk4` ON `lnk4`.team_id = `t4`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk5`.`person_id` = :current_contact_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`Root6`.`id` = :current_contact->org_id)) UNION SELECT `GARE` FROM UserRequest AS `GARE` JOIN Team AS `t` ON `GARE`.team_id = `t`.id JOIN Organization AS `Node` ON `t`.org_id = `Node`.id JOIN Organization AS `Root` ON `Node`.parent_id BELOW `Root`.id JOIN lnkOrganizationToPerson AS `l2` ON `l2`.organization_id = `Root`.id JOIN lnkPersonToTeam AS `l` ON `l`.team_id = `t`.id JOIN Service AS `s4` ON `GARE`.service_id = `s4`.id JOIN lnkOrganizationToService AS `lnk7` ON `lnk7`.service_id = `s4`.id JOIN Team AS `t6` ON `lnk7`.team_id = `t6`.id JOIN Organization AS `Node6` ON `t6`.org_id = `Node6`.id JOIN Organization AS `Root6` ON `Node6`.parent_id BELOW `Root6`.id JOIN lnkOrganizationToPerson AS `lnk9` ON `lnk9`.organization_id = `Root6`.id JOIN lnkPersonToTeam AS `lnk8` ON `lnk8`.team_id = `t6`.id WHERE (((((`l2`.`person_id` = :current_contact_id) AND ((`GARE`.`agent_id` != '') AND (`GARE`.`operational_status` NOT IN ('closed', 'resolved')))) AND (`lnk9`.`person_id` = :current_contact_id)) AND (`GARE`.`finalclass` = 'UserRequest')) AND (`lnk9`.`person_id` = :current_contact_id))";
try {
$oOql = new OqlInterpreter($sQuery);
$oOql->ParseQuery();
}
catch (OQLParserException $e) {
self::fail("OQL Parser stack overflow");
}
catch (OQLException $e) {
self::fail("OQL Parser stack overflow");
}
self::assertTrue(true);
}
}