ITsDataSource.cpp
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 terralib/itest/dataaccess/ITsDataSource.cpp
22 
23  \brief A integration test suit for the TerraLib Data Access Module.
24 
25  \author Carolina Galvão dos Santos
26  */
27 
28 // TerraLib
30 #include <terralib/common.h>
31 #include <terralib/dataaccess.h>
32 #include <terralib/core/plugin.h>
33 
34 // STL
35 #include <memory>
36 #include <map>
37 #include <string>
38 
39 // GTest and GMock
40 #include <gmock/gmock.h>
41 #include <gtest/gtest.h>
42 
44 {
45  public:
46 
47  /* Mock constructor */
48  MockDataSource() = default;
49 
50  /* Mock destructor */
51  virtual ~MockDataSource() = default;
52 
53  /* Methods that are virtual, with sample declaration: */
54 
55  MOCK_CONST_METHOD0(getType, std::string ());
56  MOCK_CONST_METHOD0(getConnectionInfo, const std::map<std::string, std::string>& ());
57  MOCK_METHOD1(setConnectionInfo, void (const std::map<std::string, std::string>& connInfo));
58  MOCK_METHOD0(open, void ());
59  MOCK_METHOD0(close, void ());
60  MOCK_CONST_METHOD0(isOpened, bool ());
61  MOCK_CONST_METHOD0(isValid, bool ());
64  MOCK_METHOD1(execute, void (const te::da::Query& command));
65  MOCK_METHOD1(execute, void (const std::string& command));
66  MOCK_METHOD1(escape, std::string (const std::string& value));
67  MOCK_METHOD1(isDataSetNameValid, bool (const std::string& datasetName));
68  MOCK_METHOD1(isPropertyNameValid, bool (const std::string& propertyName));
69  MOCK_METHOD0(getDataSetNames, std::vector<std::string> ());
70  MOCK_METHOD0(getNumberOfDataSets, std::size_t ());
71  MOCK_METHOD1(getProperties, boost::ptr_vector<te::dt::Property> (const std::string& datasetName));
72  MOCK_METHOD1(getPropertyNames, std::vector<std::string> (const std::string& datasetName));
73  MOCK_METHOD1(getNumberOfProperties, std::size_t (const std::string& datasetName));
74  MOCK_METHOD2(propertyExists, bool (const std::string& datasetName, const std::string& name));
75  MOCK_METHOD2(addProperty, void (const std::string& datasetName, te::dt::Property* p));
76  MOCK_METHOD2(dropProperty, void (const std::string& datasetName, const std::string& name));
77  MOCK_METHOD3(renameProperty, void (const std::string& datasetName, const std::string& propertyName, const std::string& newPropertyName));
78  MOCK_METHOD3(changePropertyDefinition, void (const std::string& datasetName, const std::string& propName, te::dt::Property* newProp));
79  MOCK_METHOD3(changePropertiesDefinitions, void (const std::string& datasetName, const std::vector<std::string>& propsNames, const std::vector<te::dt::Property*> newProps));
80  MOCK_METHOD2(primaryKeyExists, bool (const std::string& datasetName, const std::string& name));
81  MOCK_METHOD2(addPrimaryKey, void (const std::string& datasetName, te::da::PrimaryKey* pk));
82  MOCK_METHOD1(dropPrimaryKey, void (const std::string& datasetName));
83  MOCK_METHOD1(getForeignKeyNames, std::vector<std::string> (const std::string& datasetName));
84  MOCK_METHOD2(foreignKeyExists, bool (const std::string& datasetName, const std::string& name));
85  MOCK_METHOD2(addForeignKey, void (const std::string& datasetName, te::da::ForeignKey* fk));
86  MOCK_METHOD2(dropForeignKey, void (const std::string& datasetName, const std::string& fkName));
87  MOCK_METHOD1(getUniqueKeyNames, std::vector<std::string> (const std::string& datasetName));
88  MOCK_METHOD2(uniqueKeyExists, bool (const std::string& datasetName, const std::string& name));
89  MOCK_METHOD2(addUniqueKey, void (const std::string& datasetName, te::da::UniqueKey* uk));
90  MOCK_METHOD2(dropUniqueKey, void (const std::string& datasetName, const std::string& name));
91  MOCK_METHOD1(getCheckConstraintNames, std::vector<std::string> (const std::string& datasetName));
92  MOCK_METHOD2(checkConstraintExists, bool (const std::string& datasetName, const std::string& name));
93  MOCK_METHOD2(addCheckConstraint, void (const std::string& datasetName, te::da::CheckConstraint* cc));
94  MOCK_METHOD2(dropCheckConstraint, void (const std::string& datasetName, const std::string& name));
95  MOCK_METHOD1(getIndexNames, std::vector<std::string> (const std::string& datasetName));
96  MOCK_METHOD2(indexExists, bool (const std::string& datasetName, const std::string& name));
97  MOCK_METHOD3(addIndex, void (const std::string& datasetName, te::da::Index* idx, const std::map<std::string, std::string>& options));
98  MOCK_METHOD2(dropIndex, void (const std::string& datasetName, const std::string& idxName));
99  MOCK_METHOD0(getSequenceNames, std::vector<std::string> ());
100  MOCK_METHOD1(sequenceExists, bool (const std::string& name));
101  MOCK_METHOD1(addSequence, void (te::da::Sequence* sequence));
102  MOCK_METHOD1(dropSequence, void (const std::string& name));
103  MOCK_METHOD1(getNumberOfItems, std::size_t (const std::string& datasetName));
104  MOCK_METHOD0(hasDataSets, bool ());
105  MOCK_METHOD1(dataSetExists, bool (const std::string& name));
106  MOCK_METHOD2(createDataSet, void (te::da::DataSetType* dt, const std::map<std::string, std::string>& options));
107  MOCK_METHOD3(cloneDataSet, void (const std::string& name, const std::string& cloneName, const std::map<std::string, std::string>& options));
108  MOCK_METHOD1(dropDataSet, void (const std::string& name));
109  MOCK_METHOD2(renameDataSet, void (const std::string& name, const std::string& newName));
110  MOCK_METHOD4(add, void (const std::string& datasetName, te::da::DataSet* d, const std::map<std::string, std::string>& options, std::size_t limit));
112  MOCK_METHOD2(remove, void (const std::string& datasetName, const te::da::ObjectIdSet* oids));
113  MOCK_METHOD6(update, void (const std::string& datasetName, te::da::DataSet* dataset, const std::vector<std::size_t>& properties, const te::da::ObjectIdSet* oids, const std::map<std::string, std::string>& options, std::size_t limit));
114  MOCK_METHOD4(update, void (const std::string& datasetName, te::da::DataSet* dataset, const std::vector< std::set<int> >& properties, const std::vector<size_t>& ids));
115  MOCK_METHOD1(create, void(const std::map<std::string, std::string>& dsInfo));
116  MOCK_METHOD1(drop, void(const std::map<std::string, std::string>& dsInfo));
117  MOCK_METHOD1(exists, bool(const std::map<std::string, std::string>& dsInfo));
118  MOCK_METHOD1(getDataSourceNames, std::vector<std::string>(const std::map<std::string, std::string>& dsInfo));
119  MOCK_METHOD1(getEncodings, std::vector<te::core::EncodingType>(const std::map<std::string, std::string>& dsInfo));
120 
121  /* Methods that return an auto_ptr, must be override: */
122 
123  MOCK_METHOD0(getTransactorOfMock, te::da::DataSourceTransactor* ());
124  virtual std::auto_ptr<te::da::DataSourceTransactor> getTransactor() override {
125  return std::auto_ptr<te::da::DataSourceTransactor>(getTransactorOfMock());
126  }
127  MOCK_METHOD3(getDataSetOfMock, te::da::DataSet* (const std::string& name, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy));
128  virtual std::auto_ptr<te::da::DataSet> getDataSet(const std::string& name, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override {
129  return std::auto_ptr<te::da::DataSet>(getDataSetOfMock(name, travType, accessPolicy));
130  }
131  MOCK_METHOD6(getDataSetOfMock1, te::da::DataSet* (const std::string& name, const std::string& propertyName, const te::gm::Envelope* e, te::gm::SpatialRelation r, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy));
132  virtual std::auto_ptr<te::da::DataSet> getDataSet(const std::string& name, const std::string& propertyName, const te::gm::Envelope* e, te::gm::SpatialRelation r, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override {
133  return std::auto_ptr<te::da::DataSet>(getDataSetOfMock1(name, propertyName, e, r, travType, accessPolicy));
134  }
135  MOCK_METHOD6(getDataSetOfMock2, te::da::DataSet* (const std::string& name, const std::string& propertyName, const te::gm::Geometry* g, te::gm::SpatialRelation r, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy));
136  virtual std::auto_ptr<te::da::DataSet> getDataSet(const std::string& name, const std::string& propertyName, const te::gm::Geometry* g, te::gm::SpatialRelation r, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override {
137  return std::auto_ptr<te::da::DataSet>(getDataSetOfMock2(name, propertyName, g, r, travType, accessPolicy));
138  }
139  MOCK_METHOD3(queryOfMock, te::da::DataSet* (const te::da::Select& q, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy));
140  virtual std::auto_ptr<te::da::DataSet> query(const te::da::Select& q, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override {
141  return std::auto_ptr<te::da::DataSet>(queryOfMock(q, travType, accessPolicy));
142  }
143  MOCK_METHOD3(queryOfMock1, te::da::DataSet* (const std::string& query, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy));
144  virtual std::auto_ptr<te::da::DataSet> query(const std::string& query, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override {
145  return std::auto_ptr<te::da::DataSet>(queryOfMock1(query, travType, accessPolicy));
146  }
147  MOCK_METHOD1(getDataSetTypeOfMock, te::da::DataSetType* (const std::string& name));
148  virtual std::auto_ptr<te::da::DataSetType> getDataSetType(const std::string& name) override {
149  return std::auto_ptr<te::da::DataSetType>(getDataSetTypeOfMock(name));
150  }
151  MOCK_METHOD2(getPropertyOfMock, te::dt::Property* (const std::string& datasetName, const std::string& name));
152  virtual std::auto_ptr<te::dt::Property> getProperty(const std::string& datasetName, const std::string& name) override {
153  return std::auto_ptr<te::dt::Property>(getPropertyOfMock(datasetName, name));
154  }
155  MOCK_METHOD2(getPropertyOfMock1, te::dt::Property* (const std::string& datasetName, std::size_t propertyPos));
156  virtual std::auto_ptr<te::dt::Property> getProperty(const std::string& datasetName, std::size_t propertyPos) override {
157  return std::auto_ptr<te::dt::Property>(getPropertyOfMock1(datasetName, propertyPos));
158  }
159  MOCK_METHOD1(getPrimaryKeyOfMock, te::da::PrimaryKey* (const std::string& datasetName));
160  virtual std::auto_ptr<te::da::PrimaryKey> getPrimaryKey(const std::string& datasetName) override {
161  return std::auto_ptr<te::da::PrimaryKey> (getPrimaryKeyOfMock(datasetName));
162  }
163  MOCK_METHOD2(getForeignKeyOfMock, te::da::ForeignKey* (const std::string& datasetName, const std::string& name));
164  virtual std::auto_ptr<te::da::ForeignKey> getForeignKey(const std::string& datasetName, const std::string& name) override {
165  return std::auto_ptr<te::da::ForeignKey> (getForeignKeyOfMock(datasetName, name));
166  }
167  MOCK_METHOD2(getUniqueKeyOfMock, te::da::UniqueKey* (const std::string& datasetName, const std::string& name));
168  virtual std::auto_ptr<te::da::UniqueKey> getUniqueKey(const std::string& datasetName, const std::string& name) override {
169  return std::auto_ptr<te::da::UniqueKey> (getUniqueKeyOfMock(datasetName, name));
170  }
171  MOCK_METHOD2(getCheckConstraintOfMock, te::da::CheckConstraint* (const std::string& datasetName, const std::string& name));
172  virtual std::auto_ptr<te::da::CheckConstraint> getCheckConstraint(const std::string& datasetName, const std::string& name) override {
173  return std::auto_ptr<te::da::CheckConstraint> (getCheckConstraintOfMock(datasetName, name));
174  }
175  MOCK_METHOD2(getIndexOfMock, te::da::Index* (const std::string& datasetName, const std::string& name));
176  virtual std::auto_ptr<te::da::Index> getIndex(const std::string& datasetName, const std::string& name) override {
177  return std::auto_ptr<te::da::Index> (getIndexOfMock(datasetName, name));
178  }
179  MOCK_METHOD1(getSequenceOfMock, te::da::Sequence* (const std::string& name));
180  virtual std::auto_ptr<te::da::Sequence> getSequence(const std::string& name) override {
181  return std::auto_ptr<te::da::Sequence> (getSequenceOfMock(name));
182  }
183  MOCK_METHOD2(getExtentOfMock, te::gm::Envelope* (const std::string& datasetName, const std::string& propertyName));
184  virtual std::auto_ptr<te::gm::Envelope> getExtent(const std::string& datasetName, const std::string& propertyName) override {
185  return std::auto_ptr<te::gm::Envelope> (getExtentOfMock(datasetName, propertyName));
186  }
187  MOCK_METHOD2(getExtentOfMock1, te::gm::Envelope* (const std::string& datasetName, std::size_t propertyPos));
188  virtual std::auto_ptr<te::gm::Envelope> getExtent(const std::string& datasetName, std::size_t propertyPos) override {
189  return std::auto_ptr<te::gm::Envelope> (getExtentOfMock1(datasetName, propertyPos));
190  }
191 };
192 
194 {
195  /* Load OGR plugin */
197  std::string plugins_path = te::core::FindInTerraLibPath("share/terralib/plugins");
198  info = te::core::JSONPluginInfoSerializer(plugins_path + "/te.da.ogr.teplg.json");
201 
202  /* Create DataSource */
203  std::unique_ptr <te::da::DataSource> ds = te::da::DataSourceFactory::make("OGR");
204  ds.reset(datasource);
205 
206  std::map<std::string, std::string> connInfo;
207  std::string data_dir = TERRALIB_DATA_DIR;
208  connInfo["URI"] = data_dir + "/DadosEric/Municipios.shp";
209 
210  ds->setConnectionInfo(connInfo); /* Exp.1 */
211 
212  ds->open(); /* Exp.2 */
213 
214  bool isOpened = ds->isOpened(); /* Exp.3 */
215 
216  if(isOpened)
217  {
218  ds->close(); /* Exp.4 */
219 
220  isOpened = ds->isOpened(); /* Exp.5 */
221  }
222 }
223 
224 using ::testing::AtLeast;
225 using ::testing::_;
226 using ::testing::Return;
227 using ::testing::InSequence;
228 
229 TEST(DataSourceTest, CanCreateDataSource) {
230  /* Testing a method that realize a simple sequence
231  * of calls to open and close a DataSource */
232 
233  /* Mock class declaration */
234  std::unique_ptr<MockDataSource> mockDS (new MockDataSource());
235 
236  {
237  InSequence dummy;
238  /* In Sequence means that this expectations
239  * should happen in that order */
240 
241  /* Exp.1 */
242  EXPECT_CALL(*mockDS.get(), setConnectionInfo(_))
243  .Times(AtLeast(1));
244 
245  /* Exp.2 */
246  EXPECT_CALL(*mockDS.get(), open())
247  .Times(AtLeast(1))
248  .WillOnce(Return());
249 
250  /* Exp.3 */
251  EXPECT_CALL(*mockDS.get(), isOpened())
252  .Times(AtLeast(1))
253  .WillOnce(Return(true));
254 
255  /* Exp.4 */
256  EXPECT_CALL(*mockDS.get(), close())
257  .Times(AtLeast(1))
258  .WillOnce(Return());
259 
260  /* Exp.5 */
261  EXPECT_CALL(*mockDS.get(), isOpened())
262  .Times(AtLeast(1))
263  .WillOnce(Return(false));
264  }
265 
266  /* Calls of mock class */
267 
269 
270  CreateDataSource(mockDS.release());
271 
273 }
virtual std::auto_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name) override
It gets the index with the given name from the dataset.
virtual void cloneDataSet(const std::string &name, const std::string &cloneName, const std::map< std::string, std::string > &options)
It clones the dataset in the data source.
virtual std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name) override
It gets information about the given dataset.
virtual bool isValid() const =0
It checks if the data source is valid (available for using).
static std::unique_ptr< DataSource > create(const std::string &dsType, const std::string &connInfo)
It creates a new repository for a data source.
virtual bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
virtual void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
virtual void execute(const Query &command)
It executes the specified command using a generic query representation.
Include files for Core Plugin Library.
virtual std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
MOCK_METHOD2(propertyExists, bool(const std::string &datasetName, const std::string &name))
MOCK_METHOD1(setConnectionInfo, void(const std::map< std::string, std::string > &connInfo))
virtual std::auto_ptr< te::dt::Property > getProperty(const std::string &datasetName, std::size_t propertyPos) override
It retrieves the property lying in the given position from the dataset.
virtual void open()=0
It opens the data source and makes it ready for using.
virtual bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
MOCK_METHOD6(update, void(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit))
virtual std::auto_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, std::size_t propertyPos) override
It retrieves the bounding rectangle for the spatial property lying in the given position in the datas...
virtual boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
MOCK_CONST_METHOD0(getType, std::string())
virtual void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
MOCK_METHOD3(renameProperty, void(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName))
virtual ~MockDataSource()=default
void insert(const PluginInfo &pinfo)
Adds plugin with its plugin information to the list of unloaded plugins.
A class that models the description of a dataset.
Definition: DataSetType.h:72
virtual bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
virtual std::auto_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name) override
It gets the unique key in the dataset with the given name.
virtual bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
virtual void createDataSet(DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
This file is a wrapper around platform specific include files.
virtual std::auto_ptr< te::da::DataSet > query(const te::da::Select &q, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override
It executes a query that may return some data using a generic query. This method always returns a dis...
virtual std::auto_ptr< te::da::Sequence > getSequence(const std::string &name) override
It gets the sequence with the given name in the data source.
It represents the SQL query dialect accepted by a given data source.
Definition: SQLDialect.h:55
virtual void add(const std::string &datasetName, DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0)
It adds data items to the dataset in the data source.
MOCK_METHOD0(open, void())
virtual bool isOpened() const =0
It returns true if the data source is opened, otherwise it returns false.
Basic information about a plugin.
SpatialRelation
Spatial relations between geometric objects.
It describes a sequence (a number generator).
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
virtual void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
static te::dt::Date ds(2010, 01, 01)
static void drop(const std::string &dsType, const std::string &connInfo)
It removes a data source identified by its connection information and the driver type.
A class that describes a check constraint.
virtual void addForeignKey(const std::string &datasetName, ForeignKey *fk)
It adds a foreign key constraint to a dataset.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
virtual void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
virtual void addSequence(Sequence *sequence)
It adds a new sequence in the data source.
void load(const std::string &plugin_name, const bool start=true)
It tries to load the informed plugin.
It models a property definition.
Definition: Property.h:59
void CreateDataSource(te::da::DataSource *datasource)
virtual te::core::EncodingType getEncoding()
It return the DataSource current encoding.
virtual std::string getType() const =0
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
EncodingType
Supported character encodings.
Definition: CharEncoding.h:50
static std::vector< std::string > getDataSourceNames(const std::string &dsType, const std::string &connInfo)
It returns the data source names available in the driver.
virtual void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
virtual void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
std::string name
The plugin name: an internal value used to identify the plugin in the system. Must be a unique value...
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
virtual std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
static PluginManager & instance()
Access the singleton.
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
MockDataSource()=default
virtual void addCheckConstraint(const std::string &datasetName, CheckConstraint *cc)
It adds a check constraint to the dataset.
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
An Envelope defines a 2D rectangular region.
virtual void addUniqueKey(const std::string &datasetName, UniqueKey *uk)
It adds a unique key constraint to the dataset.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
virtual void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the given dataset.
virtual std::auto_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name) override
It gets the check constraint of the dataset with the given name.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
static te::dt::TimeDuration dt(20, 30, 50, 11)
virtual void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
virtual std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
te::gm::Polygon * p
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
virtual std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
TEST(DataSourceTest, CanCreateDataSource)
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
virtual std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
virtual std::auto_ptr< te::da::DataSourceTransactor > getTransactor() override
It returns the set of parameters used to set up the access channel to the underlying repository...
virtual void addPrimaryKey(const std::string &datasetName, PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
virtual std::auto_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName) override
It retrieves the bounding rectangle of the spatial property for the given dataset.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
virtual std::auto_ptr< te::da::DataSet > query(const std::string &query, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override
It executes a query that may return some data using the data source native language. This method always returns a disconnected dataset, that is, a dataset that is no more dependent of the data source that provided the connection for its creation. Therefore, the disconnected dataset continues to live after the connection given by the data source has been released.
virtual bool isDataSetNameValid(const std::string &datasetName)
It checks if the given dataset name is valid.
void initialize()
It initializes the TerraLib Platform.
virtual bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
A dataset is the unit of information manipulated by the data access module of TerraLib.
virtual bool hasDataSets()
It checks if the data source has any dataset.
virtual std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
virtual void dropSequence(const std::string &name)
It removes the sequence from the data source.
virtual bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
virtual std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName) override
It retrieves the primary key of the dataset.
virtual void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
TECOREEXPORT PluginInfo JSONPluginInfoSerializer(const std::string &file_name)
A plugin finder that search for plugins in some special directories defined by compile time macros...
Definition: Serializers.cpp:44
virtual void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
const te::core::URI & getConnectionInfo() const
An Uniform Resource Identifier used to describe the datasource connection.
virtual void close()=0
It closes the data source and clears all the resources used by its internal communication channel...
virtual const SQLDialect * getDialect() const =0
It returns the data source SQL dialect, if there is one.
TECOREEXPORT std::string FindInTerraLibPath(const std::string &path)
Returns the path relative to a directory or file in the context of TerraLib.
virtual std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
virtual void addIndex(const std::string &datasetName, Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
virtual void changePropertiesDefinitions(const std::string &datasetName, const std::vector< std::string > &propsNames, const std::vector< te::dt::Property * > newProps)
virtual std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override
It gets the dataset identified by the given name. This method always returns a disconnected dataset...
virtual std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name) override
It retrieves the foreign key from the given dataset.
This file contains include headers for the TerraLib Common Runtime module.
virtual std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, const std::string &propertyName, const te::gm::Envelope *e, te::gm::SpatialRelation r, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override
It gets the dataset identified by the given name using a spatial filter over the specified property...
virtual bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
static bool exists(const std::string &dsType, const std::string &connInfo)
It checks if the data source exists with the connection information and the driver type...
virtual std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
virtual std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
This file contains include headers for the Data Access module of TerraLib.
virtual std::auto_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name) override
It retrieves the property with the given name from the dataset.
virtual void update(const std::string &datasetName, DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)
It updates the contents of a dataset for the set of data items.
virtual bool checkConstraintExists(const std::string &datasetName, const std::string &name)
It checks if a check-constraint with the given name exists in the data source.
virtual bool foreignKeyExists(const std::string &datasetName, const std::string &name)
It checks if a foreign key with the given name exists in the data source.
virtual std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
A Query is independent from the data source language/dialect.
Definition: Query.h:46
It describes an index associated to a DataSetType.
virtual std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, const std::string &propertyName, const te::gm::Geometry *g, te::gm::SpatialRelation r, te::common::TraverseType travType, const te::common::AccessPolicy accessPolicy) override
It gets the dataset identified by the given name using a spatial filter over the given geometric prop...
MOCK_METHOD4(add, void(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit))
virtual void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.