BasicQueries.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20  /*!
21  \file terralin/vp/AbstractDataHandler.h
22 
23  \brief This class represents handler to help reading and writing data from/to a dataSource by dividing it into smaller groups
24  */
25 
26 #ifndef __TERRALIB_VP_INTERNAL_BASICQUERIES_H
27 #define __TERRALIB_VP_INTERNAL_BASICQUERIES_H
28 
29 #include "../Config.h"
30 
31 //Terralib Include Files
32 #include "../query/Fields.h"
33 #include "../query/From.h"
34 
35 #include <memory>
36 #include <string>
37 #include <vector>
38 
39 namespace te
40 {
41  namespace dt
42  {
43  class AbstractData;
44  }
45 
46  namespace gm
47  {
48  class Envelope;
49  }
50 
51  namespace da
52  {
53  class DataSetType;
54  class Expression;
55  class Select;
56  class Where;
57 
59  {
60  BasicQueries() = delete;
61  ~BasicQueries() = delete;
62 
63  public:
64 
65  /*! \brief Helper function to create a query from the given parameters.
66  \param distinct TRUE if distinct clause must be added. FALSE otherwise
67  \param vecColumns A vector containing the columns to be added to the query
68  \param tableName The name of the table to be queried
69  \param vecWhereColumns A vector containing all the columns in the where clause
70  \param vecWhereValues A vector containing all the values in the where clause
71  \return An query resulting from the given parameters
72  */
73  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Select> GetQuery(
74  bool distinct,
75  const std::vector<std::string>& vecColumns,
76  const std::string& tableName,
77  const std::vector<std::string>& vecWhereColumns,
78  const std::vector<te::dt::AbstractData*>& vecWhereValues);
79 
80 
81  /*! \brief Helper function to create a query from the given parameters.
82  \param distinct TRUE if distinct clause must be added. FALSE otherwise
83  \param vecColumns A vector containing the columns to be added to the query
84  \param tableName The name of the table to be queried
85  \return An query resulting from the given parameters
86  */
87  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Select> GetQuery(
88  bool distinct,
89  const std::vector<std::string>& vecColumns,
90  const std::string& tableName);
91 
92 
93  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Fields> GetFields(const te::da::DataSetType* dataSetType);
94  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Fields> GetFields(const std::vector<std::string>& vecColummns);
95  TEDATAACCESSEXPORT static std::unique_ptr<te::da::From> GetFrom(const te::da::DataSetType* dataSetType);
96  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Expression> GetRelationalExpression(const std::string& propertyName, int propertyValue, const std::string& relationalOperator);
97  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Expression> GetRelationalExpression(const std::string& propertyName, const std::string& propertyValue, const std::string& relationalOperator);
98  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Expression> GetIntersectsExpression(const te::da::DataSetType* dataSetType, const te::gm::Envelope& envelope);
99  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Expression> GetInExpression(const std::string& propertyName, const std::vector<int>& vecValues);
100  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Expression> GetInExpression(const std::string& propertyName, const std::vector<std::string>& vecValues);
101 
103 
104  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Where> GetWhereEqualTo(const std::string& propertyName, int propertyValue);
105  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Where> GetWhereEqualTo(const std::string& propertyName, const std::string& propertyValue);
106  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Select> GetSimpleQuery(const te::da::DataSetType* dataSetType);
107  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Select> GetSimpleQueryEqualTo(const te::da::DataSetType* dataSetType, const std::string& propertyName, int propertyValue);
108  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Select> GetSimpleQueryEqualTo(const te::da::DataSetType* dataSetType, const std::string& propertyName, const std::string& propertyValue);
109  TEDATAACCESSEXPORT static std::unique_ptr<te::da::Select> GetSimpleQueryIntersects(const te::da::DataSetType* dataSetType, const te::gm::Envelope& envelope);
110  };
111  }
112 }
113 
114 #endif //__TERRALIB_VP_INTERNAL_BASICQUERIES_H
static TEDATAACCESSEXPORT void AppendExpressionToWhereClause(te::da::Select *select, te::da::Expression *expression)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Select > GetQuery(bool distinct, const std::vector< std::string > &vecColumns, const std::string &tableName)
Helper function to create a query from the given parameters.
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Where > GetWhereEqualTo(const std::string &propertyName, const std::string &propertyValue)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Select > GetQuery(bool distinct, const std::vector< std::string > &vecColumns, const std::string &tableName, const std::vector< std::string > &vecWhereColumns, const std::vector< te::dt::AbstractData * > &vecWhereValues)
Helper function to create a query from the given parameters.
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Select > GetSimpleQueryEqualTo(const te::da::DataSetType *dataSetType, const std::string &propertyName, const std::string &propertyValue)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Select > GetSimpleQuery(const te::da::DataSetType *dataSetType)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Fields > GetFields(const te::da::DataSetType *dataSetType)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Where > GetWhereEqualTo(const std::string &propertyName, int propertyValue)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Expression > GetInExpression(const std::string &propertyName, const std::vector< std::string > &vecValues)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Expression > GetInExpression(const std::string &propertyName, const std::vector< int > &vecValues)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Select > GetSimpleQueryIntersects(const te::da::DataSetType *dataSetType, const te::gm::Envelope &envelope)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Fields > GetFields(const std::vector< std::string > &vecColummns)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Expression > GetRelationalExpression(const std::string &propertyName, const std::string &propertyValue, const std::string &relationalOperator)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Expression > GetRelationalExpression(const std::string &propertyName, int propertyValue, const std::string &relationalOperator)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Expression > GetIntersectsExpression(const te::da::DataSetType *dataSetType, const te::gm::Envelope &envelope)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::Select > GetSimpleQueryEqualTo(const te::da::DataSetType *dataSetType, const std::string &propertyName, int propertyValue)
static TEDATAACCESSEXPORT std::unique_ptr< te::da::From > GetFrom(const te::da::DataSetType *dataSetType)
A class that models the description of a dataset.
Definition: DataSetType.h:73
This is an abstract class that models a query expression.
Definition: Expression.h:48
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:67
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
TerraLib.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:97