Files
iTop/tests/php-unit-tests/unitary-tests/core/OQLParserTest.php
Molkobain d177ee4a7f Merge remote-tracking branch 'origin/support/2.7' into support/3.0
# Conflicts:
#	tests/manual-visual-tests/Backoffice/RenderAllUiBlocks.php
#	tests/php-unit-tests/ItopDataTestCase.php
#	tests/php-unit-tests/ItopTestCase.php
#	tests/php-unit-tests/integration-tests/dictionaries-test/fr.dictionary.itop.core.KO.wrong_php
#	tests/php-unit-tests/integration-tests/dictionaries-test/fr.dictionary.itop.core.OK.php
#	tests/php-unit-tests/integration-tests/iTopModulesPhpVersionChecklistTest.php
#	tests/php-unit-tests/integration-tests/iTopXmlVersionChecklistTest.php
#	tests/php-unit-tests/phpunit.xml.dist
#	tests/php-unit-tests/unitary-tests/application/SCSSCompilationTest.php
#	tests/php-unit-tests/unitary-tests/application/Session/SessionTest.php
#	tests/php-unit-tests/unitary-tests/application/ThemeHandlerTest.php
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/DO_NOT_CHANGE.css-variables.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/DO_NOT_CHANGE.light-grey.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/README.md
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/_included_file3.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/cross_reference1.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/cross_reference2.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/feature1/_feature1.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/included_file1.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/included_scss/included_file2.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/included_scss/included_file4.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/multi_imports.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/shortcut.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/shortcut2.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/simple_import.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/simple_import2.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/typography.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/css/ui-lightness/DO_NOT_CHANGE.jqueryui.scss
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_1c94c4_256x240.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_222222_256x240.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_E87C1E_256x240.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_F26522_256x240.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_ffd27a_256x240.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/css/ui-lightness/images/ui-icons_ffffff_256x240.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/ac-background.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/actions_right.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/bg.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/breadcrumb-separator.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/calendar.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/delete.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/desc.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/error.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-closed-555.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-closed-fff.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-open-555.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/eye-open-fff.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/full-screen.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/green-header.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/green-square.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/indicator.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/info-mini.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/minus.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/ok.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/orange-header.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/plus.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/red-header.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/truncated.png
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-collapsable-last.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-collapsable.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-expandable-last.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-expandable.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-item-last.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/testimages/images/tv-item.gif
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main.css
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_imagemodified.css
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_importmodified.css
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_stylesheet.css
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_testcompilethemes.css
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/main_varchanged.css
#	tests/php-unit-tests/unitary-tests/application/theme-handler/expected/themes/basque-red/theme-parameters.json
#	tests/php-unit-tests/unitary-tests/application/theme-handler/getimages/expected-getimages.json
#	tests/php-unit-tests/unitary-tests/application/theme-handler/getimages/test-getimages.scss
#	tests/php-unit-tests/unitary-tests/core/ActionEmailTest.php
#	tests/php-unit-tests/unitary-tests/core/AttributeDefTest.inc.php
#	tests/php-unit-tests/unitary-tests/core/AttributeURLDefaultPattern.php
#	tests/php-unit-tests/unitary-tests/core/AttributeURLTest.php
#	tests/php-unit-tests/unitary-tests/core/BulkChangeTest.inc.php
#	tests/php-unit-tests/unitary-tests/core/CSVParserTest.php
#	tests/php-unit-tests/unitary-tests/core/DBObjectTest.php
#	tests/php-unit-tests/unitary-tests/core/DBSearchAddConditionPointingTo.php
#	tests/php-unit-tests/unitary-tests/core/ExpressionEvaluateTest.php
#	tests/php-unit-tests/unitary-tests/core/GetSelectFilterTest.php
#	tests/php-unit-tests/unitary-tests/core/InlineImageTest.php
#	tests/php-unit-tests/unitary-tests/core/Log/ExceptionLogTest.php
#	tests/php-unit-tests/unitary-tests/core/Log/ExceptionLogTest/Exceptions.php
#	tests/php-unit-tests/unitary-tests/core/Log/LogAPITest.php
#	tests/php-unit-tests/unitary-tests/core/Log/LogFileNameBuilderTest.php
#	tests/php-unit-tests/unitary-tests/core/LogAPITest.php
#	tests/php-unit-tests/unitary-tests/core/LogFileNameBuilderTest.php
#	tests/php-unit-tests/unitary-tests/core/MetaModelTest.php
#	tests/php-unit-tests/unitary-tests/core/OQLTest.php
#	tests/php-unit-tests/unitary-tests/core/UniquenessConstraintTest.php
#	tests/php-unit-tests/unitary-tests/core/XMLDataLoaderTest.php
#	tests/php-unit-tests/unitary-tests/core/dictApcuTest.php
#	tests/php-unit-tests/unitary-tests/core/dictTest.php
#	tests/php-unit-tests/unitary-tests/core/ormCaseLogTest.php
#	tests/php-unit-tests/unitary-tests/core/ormPasswordTest.php
#	tests/php-unit-tests/unitary-tests/core/ormStyleTest.php
#	tests/php-unit-tests/unitary-tests/setup/MFCompilerTest.php
#	tests/php-unit-tests/unitary-tests/setup/SubMFCompiler.php
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/1.7_to_1.6.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/1.7_to_1.6.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.6_to_1.7_2.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.6_to_1.7_2.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6_2.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_1.6_2.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_3.0.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/1.7_to_3.0.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.0_to_1.7.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/3.0_to_1.7.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/Bug_4569.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/Convert-samples/Bug_4569.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_deleted.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_deleted.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_in-definition.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_in-definition.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_not-in-definition.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_deleted_to_not-in-definition.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_deleted.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_deleted.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_in-definition.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_in-definition.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_not-in-definition.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_in-definition_to_not-in-definition.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_deleted.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_deleted.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_in-definition.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_in-definition.input.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_not-in-definition.expected.xml
#	tests/php-unit-tests/unitary-tests/setup/iTopDesignFormat/MoveNode-samples/from_not-in-definition_to_not-in-definition.input.xml
#	tests/php-unit-tests/unitary-tests/setup/ressources/datamodels/datamodel-branding.xml
#	tests/php-unit-tests/unitary-tests/sources/application/Helper/WebResourcesHelperTest.php
#	tests/php-unit-tests/unitary-tests/sources/application/status/StatusIncTest.php
#	tests/php-unit-tests/unitary-tests/sources/application/status/status.php
#	tests/php-unit-tests/unitary-tests/synchro/DataSynchroTest.php
2023-01-10 15:27:44 +01:00

91 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
* @group specificOrgInSampleData
* @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);
}
}