querybuildercontext.class.inc.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. // Copyright (C) 2010-2012 Combodo SARL
  3. //
  4. // This file is part of iTop.
  5. //
  6. // iTop is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU Affero General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // iTop is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU Affero General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU Affero General Public License
  17. // along with iTop. If not, see <http://www.gnu.org/licenses/>
  18. /**
  19. * Associated with the metamodel -> MakeQuery/MakeQuerySingleTable
  20. *
  21. * @copyright Copyright (C) 2010-2012 Combodo SARL
  22. * @license http://opensource.org/licenses/AGPL-3.0
  23. */
  24. class QueryBuilderContext
  25. {
  26. protected $m_oRootFilter;
  27. protected $m_aClassAliases;
  28. protected $m_aTableAliases;
  29. protected $m_aModifierProperties;
  30. public $m_oQBExpressions;
  31. public function __construct($oFilter, $aModifierProperties, $aGroupByExpr = null)
  32. {
  33. $this->m_oRootFilter = $oFilter;
  34. $this->m_oQBExpressions = new QueryBuilderExpressions($oFilter, $aGroupByExpr);
  35. $this->m_aClassAliases = $oFilter->GetJoinedClasses();
  36. $this->m_aTableAliases = array();
  37. $this->m_aModifierProperties = $aModifierProperties;
  38. }
  39. public function GetRootFilter()
  40. {
  41. return $this->m_oRootFilter;
  42. }
  43. public function GenerateTableAlias($sNewName, $sRealName)
  44. {
  45. return MetaModel::GenerateUniqueAlias($this->m_aTableAliases, $sNewName, $sRealName);
  46. }
  47. public function GenerateClassAlias($sNewName, $sRealName)
  48. {
  49. return MetaModel::GenerateUniqueAlias($this->m_aClassAliases, $sNewName, $sRealName);
  50. }
  51. public function GetModifierProperties($sPluginClass)
  52. {
  53. if (array_key_exists($sPluginClass, $this->m_aModifierProperties))
  54. {
  55. return $this->m_aModifierProperties[$sPluginClass];
  56. }
  57. else
  58. {
  59. return array();
  60. }
  61. }
  62. }
  63. ?>