/**************************************************************************** ** ** https://www.qxorm.com/ ** Copyright (C) 2013 XDL Team (ic-east.com) ** ** This file is part of the QxOrm library ** ** This software is provided 'as-is', without any express or implied ** warranty. In no event will the authors be held liable for any ** damages arising from the use of this software ** ** Commercial Usage ** Licensees holding valid commercial QxOrm licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and XDL Team ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file 'license.gpl3.txt' included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met : http://www.gnu.org/copyleft/gpl.html ** ** If you are unsure which license is appropriate for your use, or ** if you have questions regarding the use of this file, please contact : ** ic-east.com ** ****************************************************************************/ #ifndef _QX_SQL_RELATION_LINKED_H_ #define _QX_SQL_RELATION_LINKED_H_ #ifdef _MSC_VER #pragma once #endif /*! * \file QxSqlRelationLinked.h * \author XDL Team * \ingroup QxDao * \brief Hierarchy of relationships to build SQL query */ #include #include #include #include namespace qx { namespace dao { namespace detail { class IxDao_Helper; } // namespace detail } // namespace dao } // namespace qx namespace qx { class IxClass; /*! * \ingroup QxDao * \brief qx::QxSqlRelationLinked : hierarchy of relationships to build SQL query * * Here is the structure, each real relation has a relation linked associated to build the hierarchy, like this : * \code (, ) ("blog", blog_relation) ("blog", ) ("author", author_relation) ("author", ) ("list_blog", list_blog_relation) ("list_blog", ) (etc...) ("comment", comment_relation) ("comment", ) ("blog_id", blog_id_relation) ("blog_id", ) (etc...) ("category", category_relation) ("category", ) ("list_blog", list_blog_relation) ("list_blog", ) (etc...) * \endcode */ class QX_DLL_EXPORT QxSqlRelationLinked { public: typedef std::shared_ptr type_ptr; typedef std::tuple, long>, QString, bool> type_relation; typedef qx::QxCollection type_lst_relation; typedef QHash type_lst_relation_linked; private: struct QxSqlRelationLinkedImpl; std::unique_ptr m_pImpl; //!< Private implementation idiom public: QxSqlRelationLinked(); QxSqlRelationLinked(bool bRoot); virtual ~QxSqlRelationLinked(); static type_ptr getHierarchy(IxClass *pClass, const QStringList &sRelationX, qx_bool &bOk, qx::dao::detail::IxDao_Helper *pDaoHelper = NULL); void hierarchySelect(QxSqlRelationParams ¶ms); void hierarchyFrom(QxSqlRelationParams ¶ms); void hierarchyJoin(QxSqlRelationParams ¶ms); void hierarchyWhereSoftDelete(QxSqlRelationParams ¶ms); void hierarchyResolveOutput(QxSqlRelationParams ¶ms); QSqlError hierarchyOnBeforeSave(QxSqlRelationParams ¶ms); QSqlError hierarchyOnAfterSave(QxSqlRelationParams ¶ms); void updateOffset(QxSqlRelationParams ¶ms); bool getCartesianProduct() const; long getAllRelationCount() const; long getRelationCount() const; bool existRelation(const QString &sKey) const; type_lst_relation_linked getRelationLinkedX() const; type_lst_relation getRelationX() const; bool isRoot() const; bool checkRootColumns(const QString &s) const; long getRootColumnsCount() const; long getRootColumnsOffset() const; void setRootColumnsOffset(long l); QString getRootCustomAlias() const; protected: bool isValidDaoHelper(QxSqlRelationParams ¶ms) const; }; typedef std::shared_ptr QxSqlRelationLinked_ptr; } // namespace qx #endif // _QX_SQL_RELATION_LINKED_H_