TsManagerDataSource.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 TsManagerDataSource.h
22 
23  \brief A static class for managing the resources used by DataSource test suit.
24  */
25 
26 #ifndef __TERRALIB_UNITTEST_DATAACCESS_INTERNAL_MANAGERDATASOURCE_H
27 #define __TERRALIB_UNITTEST_DATAACCESS_INTERNAL_MANAGERDATASOURCE_H
28 
29 // TerraLib forward declarations
32 
33 #include <terralib/geometry_fw.h>
34 //#include <terralib/postgis_fw.h>
35 
36 #include <terralib/datatype.h>
37 
38 // STL
39 #include <string>
40 #include <vector>
41 
42 /*!
43  \class TsManagerDataSource
44 
45  \brief A static class for managing the resources used by DataSource test suit.
46  */
48 {
49  public:
50  /*!
51  \brief It will initialize the resources used by Test Suit:
52  TsDataSource, TsDataSet, TsDataSetTypePersistence, TsTransactor etc
53  \param driver_name A json file name from where to read values used by tests.
54 
55  This will avoid openning/closing database for each test case.
56  */
57  static void initialize(const std::string driver_name);
58 
59  /*!
60  \brief It will finalize the resources used in Teste Suit:
61  TsDataSource, TsDataSet, TsDataSetTypePersistence, TsTransactor...
62  */
63  static void finalize();
64 
65  /*!
66  \brief Converts a vector of vector of doubles - representing the envelopes of layers
67  into a vector of te::gm::Envelope
68 
69  \param vectd A vector of vector of doubles std::vector<std::vector<double>>.
70  \param vecte The vector of Envelope to output the values.
71  */
72  static void ConvertVectorToEnvelope(std::vector<std::vector<double> >& vectd, std::vector<te::gm::Envelope>& vecte);
73 
74  /*!
75  \brief Converts a vector of vector of 3 doubles - representing points (SRID,X,Y) into a vector of te::gm::Envelope
76 
77  \param vectd A vector of vector of doubles std::vector<std::vector<double>>.
78  \param vectp The vector of Points with SRID,X,Y to output the values.
79  */
80  static void ConvertVectorToPoints( std::vector< std::vector<double> >& vectd, std::vector<te::gm::Point>& vectp);
81 
82  /*!
83  \brief Converts a vector of vector of 3 doubles - representing points (SRID,X,Y) into a vector of te::gm::LinearRings
84 
85  \param vectd A vector of vector of values representing points std::vector<std::vector<double>>.
86  \param vectp The vector of Points with SRID,X,Y to output the values.
87  */
88  static void ConvertVectorToLinearRing(std::vector<std::vector<double> >& vectd, te::gm::LinearRing& lr);
89 
90  /*!
91  \brief Converts a string into a string (Enum) property type
92 
93  \param s String represententing a property type.
94  \param t A string property type.
95  */
96  static void ConvertToPropType(std::string s, te::dt::StringType &t);
97 
98  /*!
99  \brief Converts a string into a number (Enum) representing a property type
100 
101  \param s String represententing a property type.
102  \param t A number (int) representing a property type.
103  */
104  static void ConvertToPropType(std::string s, int &t);
105 
106  /*!
107  \brief It will set vectors of pairs of values based in some vector already known.
108 
109  */
110  static void setPairsValues();
111 
112 // The sm_* will be initialized here and the setUp of PostGIS driver will use them to run all test suite
114  //static std::auto_ptr<te::da::DataSource> sm_datasource;
116  static std::string sm_dsType;
117  static std::map<std::string, std::string> sm_connInfo;
118  static std::map<std::string, std::string> sm_connInfoExist;
119 
120  static std::map<std::string, std::string> sm_connInfoNewDs;
121  static std::map<std::string, std::string> sm_connInfoDropDs;
122  static std::string sm_connStr;
123 
124 // The next statics will be used to compose the vector of pairs below
125  static std::vector<std::string> sm_vecDtNames;
126  static std::vector<te::gm::Envelope> sm_vecEnvelops;
127  static std::vector<te::gm::Envelope> sm_recEnvelops;
128  static std::vector<size_t> sm_dtSize;
129  static std::vector<size_t> sm_dtRecSize;
130 
131 // Vector of pairs to be used in Test Cases
132  static std::vector<std::pair<std::string, te::gm::Envelope> > sm_vecDtNamesAndEnvelops;
133  static std::vector<std::pair<std::string, te::gm::Envelope> > sm_vecNamesAndRecs;
134  static std::vector<std::pair<std::string, size_t> > sm_vecNamesSizes;
135  static std::vector<std::pair<std::string, size_t> > sm_vecNamesSizesRec;
136 
137 // The next vectors will be used to test the existence of pk, uk, fk, idx, Cc, seq
138  static std::vector<std::string> sm_vecPkNames;
139  static std::vector<std::string> sm_vecUkNames;
140  static std::vector<std::string> sm_vecIdxNames;
141  static std::vector<std::string> sm_vecFkNames;
142  static std::vector<std::string> sm_vecSeqNames;
143  static std::vector<std::string> sm_vecCcNames;
144 
145 // Geometries to be used in getDataSet API�s
151 
152  static size_t sm_nroDataSets;
153 
154 // Defining specific variables to test DataSetTypePersistence
155 
158 
159  static std::string sm_ccName;
161  static std::string sm_NameAttr1;
162  static std::string sm_Attr1;
163  static std::string sm_NameAttr2;
164  static std::string sm_NameAttr3;
165  static std::string sm_NameAttr4;
166  static std::string sm_NameAttr5;
167  static std::string sm_NameAttr6;
168  static std::string sm_NameAttr7;
169  static std::string sm_NameAttr8;
170 
171  static std::string sm_Attr6Pk;
172  static std::string sm_Attr6Fk;
173 
174  static std::string sm_Attr3e4Uk;
175  static std::string sm_Attr5idx;
176  static std::string sm_Attr2idx;
177  static std::string sm_Attr7_seq;
178 
179 // DataSetType names used in persistence
180  static std::string sm_newDataSetType;
181  static std::string sm_newCapabilitiesDt;
182  static std::string sm_newDataSetType2;
183  static std::string sm_newDataSetType3;
184  static std::string sm_dtcloned;
185 
186  static std::string sm_oldNameProp;
187  static std::string sm_newNameProp;
188 
190 };
191 #endif // __TERRALIB_UNITTEST_DATAACCESS_INTERNAL_MANAGERDATASOURCE_H
192 
static te::gm::Polygon * sm_pol
This file contains include headers for the Data Type module of TerraLib.
StringType
The subtype of string property.
static std::vector< std::pair< std::string, size_t > > sm_vecNamesSizes
static std::string sm_newDataSetType3
static te::gm::Envelope sm_box
static te::da::DataSourceCapabilities sm_capabilit
static std::map< std::string, std::string > sm_connInfoNewDs
static te::gm::LinearRing * sm_linearRing
static std::string sm_Attr1
static std::map< std::string, std::string > sm_connInfoExist
static std::string sm_Attr2idx
static std::string sm_newDataSetType
static std::string sm_Attr6Fk
A class that models the description of a dataset.
Definition: DataSetType.h:72
static std::string sm_NameAttr1
static std::string sm_connStr
Forward declarations for the dataset module.
static te::da::DataSetType * sm_newdt3
static te::da::DataSource * sm_datasource
static std::string sm_Attr3e4Uk
static std::vector< size_t > sm_dtSize
static std::string sm_oldNameProp
static std::string sm_NameAttr7
static std::map< std::string, std::string > sm_connInfoDropDs
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
A class that describes a check constraint.
static te::da::ForeignKey * sm_fk
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
static std::string sm_NameAttr2
Forward declarations for the DataSource module.
static std::string sm_newDataSetType2
static void setPairsValues()
It will set vectors of pairs of values based in some vector already known.
A static class for managing the resources used by DataSource test suit.
static std::string sm_NameAttr6
static std::string sm_Attr5idx
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
static std::vector< std::pair< std::string, size_t > > sm_vecNamesSizesRec
static te::da::CheckConstraint * sm_cc
A point with x and y coordinate values.
Definition: Point.h:50
static void initialize(const std::string driver_name)
It will initialize the resources used by Test Suit: TsDataSource, TsDataSet, TsDataSetTypePersistence...
An Envelope defines a 2D rectangular region.
static size_t sm_nroDataSets
This file contains forward declarations for the Vector Geometry model of TerraLib.
static void ConvertVectorToEnvelope(std::vector< std::vector< double > > &vectd, std::vector< te::gm::Envelope > &vecte)
Converts a vector of vector of doubles - representing the envelopes of layers into a vector of te::gm...
static std::vector< size_t > sm_dtRecSize
static te::gm::Point sm_pt
static std::vector< std::string > sm_vecDtNames
static void ConvertVectorToPoints(std::vector< std::vector< double > > &vectd, std::vector< te::gm::Point > &vectp)
Converts a vector of vector of 3 doubles - representing points (SRID,X,Y) into a vector of te::gm::En...
static void finalize()
It will finalize the resources used in Teste Suit: TsDataSource, TsDataSet, TsDataSetTypePersistence...
static std::string sm_NameAttr3
static te::gm::Geometry * sm_geom
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
static std::vector< std::string > sm_vecIdxNames
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
static std::vector< std::string > sm_vecSeqNames
static std::map< std::string, std::string > sm_connInfo
static std::vector< te::gm::Envelope > sm_recEnvelops
static std::vector< std::pair< std::string, te::gm::Envelope > > sm_vecNamesAndRecs
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
static std::vector< std::pair< std::string, te::gm::Envelope > > sm_vecDtNamesAndEnvelops
static std::string sm_Attr6Pk
static std::string sm_Attr7_seq
static std::vector< te::gm::Envelope > sm_vecEnvelops
static std::string sm_NameAttr5
static std::string sm_NameAttr8
static te::da::DataSetType * sm_newdt
static std::string sm_newCapabilitiesDt
static std::string sm_newNameProp
static std::string sm_ccName
static std::vector< std::string > sm_vecPkNames
static std::string sm_dtcloned
static std::vector< std::string > sm_vecCcNames
static std::vector< std::string > sm_vecFkNames
static void ConvertToPropType(std::string s, te::dt::StringType &t)
Converts a string into a string (Enum) property type.
static void ConvertVectorToLinearRing(std::vector< std::vector< double > > &vectd, te::gm::LinearRing &lr)
Converts a vector of vector of 3 doubles - representing points (SRID,X,Y) into a vector of te::gm::Li...
static std::string sm_dsType
static std::string sm_NameAttr4
static std::vector< std::string > sm_vecUkNames