Transactor.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 terralib/postgis/Transactor.h
22 
23  \brief A Transactor can be viewed as a connection to the data source for reading/writing things into it.
24 */
25 
26 #ifndef __TERRALIB_POSTGIS_INTERNAL_TRANSACTOR_H
27 #define __TERRALIB_POSTGIS_INTERNAL_TRANSACTOR_H
28 
29 // TerraLib
30 #include "../dataaccess/datasource/DataSourceTransactor.h"
31 #include "Config.h"
32 #include "DataSource.h"
33 
34 // STL
35 #include <memory>
36 #include <map>
37 #include <string>
38 
39 namespace te
40 {
41 // Forward declarations
42  namespace dt { class Property; }
43  namespace gm { class Envelope; class Geometry; }
44 
45  namespace pgis
46  {
47  // Forward declarations
48  class BatchExecutor;
49  class DataSet;
50  class Connection;
51  class ObjectIdSet;
52  class PreparedQuery;
53  class Query;
54  class ScopedConnection;
55 
56  /*!
57  \class Transactor
58 
59  \brief The transactor class for the PostGIS driver.
60 
61  \sa te::da::DataSourceTransactor, DataSource
62  */
64  {
65  public:
66 
67  /*!
68  \brief Constructor.
69 
70  \param ds The PostGIS data source associated to this transactor.
71  \param conn An available connection that will be released when the transactor is deleted
72  */
73  Transactor(DataSource* ds, const int& connectionId = -1);
74 
75  /*! \brief The destructor will automatically release the connection to the pool. */
77 
79 
80  /*!
81  \brief It returns the underlying connection.
82 
83  \return The underlying connection.
84 
85  \note PostGIS driver extended method.
86  */
87  Connection* getConnection(const int& id = -1) const;
88 
89  /*!
90  \brief It returns the underlying connection ID.
91 
92  \return The underlying connection ID.
93 
94  \note PostGIS driver extended method.
95  */
96  int getConnectionID() const;
97 
98  void begin();
99 
100  void commit();
101 
102  void rollBack();
103 
104  bool isInTransaction() const;
105 
106  std::unique_ptr<te::da::DataSet> getDataSet(const std::string& name,
108  bool isConnected = false,
109  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
110 
111  std::unique_ptr<te::da::DataSet> getDataSet(const std::string& name,
112  const std::string& propertyName,
113  const te::gm::Envelope* e,
116  bool isConnected = false,
117  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
118 
119  std::unique_ptr<te::da::DataSet> getDataSet(const std::string& name,
120  const std::string& propertyName,
121  const te::gm::Geometry* g,
124  bool isConnected = false,
125  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
126 
127  std::unique_ptr<te::da::DataSet> query(const te::da::Select& q,
129  bool connected = false,
130  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
131 
132 
133  std::unique_ptr<te::da::DataSet> query(const std::string& query,
135  bool connected = false,
136  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
137 
138  void execute(const te::da::Query& command);
139 
140  void execute(const std::string& command);
141 
142  std::unique_ptr<te::da::PreparedQuery> getPrepared(const std::string& qName = std::string(""));
143 
144  std::unique_ptr<te::da::BatchExecutor> getBatchExecutor();
145 
146  void cancel();
147 
148  boost::int64_t getLastGeneratedId();
149 
150  std::string escape(const std::string& value);
151 
152  std::vector<std::string> getDataSetNames();
153 
154  std::size_t getNumberOfDataSets();
155 
156  std::unique_ptr<te::da::DataSetType> getDataSetType(const std::string& name);
157 
158  boost::ptr_vector<te::dt::Property> getProperties(const std::string& datasetName);
159 
160  std::unique_ptr<te::dt::Property> getProperty(const std::string& datasetName, const std::string& name);
161 
162  std::unique_ptr<te::dt::Property> getProperty(const std::string& datasetName, std::size_t propertyPos);
163 
164  std::vector<std::string> getPropertyNames(const std::string& datasetName);
165 
166  std::size_t getNumberOfProperties(const std::string& datasetName);
167 
168  bool propertyExists(const std::string& datasetName, const std::string& name);
169 
170  void addProperty(const std::string& datasetName, te::dt::Property* p);
171 
172  void dropProperty(const std::string& datasetName, const std::string& name);
173 
174  void renameProperty(const std::string& datasetName,
175  const std::string& propertyName,
176  const std::string& newPropertyName);
177 
178 
179  void changePropertyDefinition(const std::string& datasetName, const std::string& propName, te::dt::Property* newProp);
180 
182 
183 
184  std::unique_ptr<te::da::PrimaryKey> getPrimaryKey(const std::string& datasetName);
185 
186  bool primaryKeyExists(const std::string& datasetName, const std::string& name);
187 
188  void addPrimaryKey(const std::string& datasetName, te::da::PrimaryKey* pk);
189 
190  void dropPrimaryKey(const std::string& datasetName);
191 
192  std::unique_ptr<te::da::ForeignKey> getForeignKey(const std::string& datasetName, const std::string& name);
193 
194  std::vector<std::string> getForeignKeyNames(const std::string& datasetName);
195 
196  bool foreignKeyExists(const std::string& datasetName, const std::string& name);
197 
198  void addForeignKey(const std::string& datasetName, te::da::ForeignKey* fk);
199 
200  void dropForeignKey(const std::string& datasetName, const std::string& fkName);
201 
202  std::unique_ptr<te::da::UniqueKey> getUniqueKey(const std::string& datasetName, const std::string& name);
203 
204  std::vector<std::string> getUniqueKeyNames(const std::string& datasetName);
205 
206  bool uniqueKeyExists(const std::string& datasetName, const std::string& name);
207 
208  void addUniqueKey(const std::string& datasetName, te::da::UniqueKey* uk);
209 
210  void dropUniqueKey(const std::string& datasetName, const std::string& name);
211 
212  std::unique_ptr<te::da::CheckConstraint> getCheckConstraint(const std::string& datasetName, const std::string& name);
213 
214  std::vector<std::string> getCheckConstraintNames(const std::string& datasetName);
215 
216  bool checkConstraintExists(const std::string& datasetName, const std::string& name);
217 
218  void addCheckConstraint(const std::string& datasetName, te::da::CheckConstraint* cc);
219 
220  void dropCheckConstraint(const std::string& datasetName, const std::string& name);
221 
222  std::unique_ptr<te::da::Index> getIndex(const std::string& datasetName, const std::string& name);
223 
224  std::vector<std::string> getIndexNames(const std::string& datasetName);
225 
226  bool indexExists(const std::string& datasetName, const std::string& name);
227 
228  void addIndex(const std::string& datasetName, te::da::Index* idx,
229  const std::map<std::string, std::string>& options);
230 
231  void dropIndex(const std::string& datasetName, const std::string& idxName);
232 
233  std::unique_ptr<te::da::Sequence> getSequence(const std::string& name);
234 
235  std::vector<std::string> getSequenceNames();
236 
237  bool sequenceExists(const std::string& name);
238 
239  void addSequence(te::da::Sequence* sequence);
240 
241  void dropSequence(const std::string& name);
242 
243  std::unique_ptr<te::gm::Envelope> getExtent(const std::string& datasetName,
244  const std::string& propertyName);
245 
246  std::unique_ptr<te::gm::Envelope> getExtent(const std::string& datasetName,
247  std::size_t propertyPos);
248 
249  std::size_t getNumberOfItems(const std::string& datasetName);
250 
251  bool hasDataSets();
252 
253  bool dataSetExists(const std::string& name);
254 
255  void createDataSet(te::da::DataSetType* dt, const std::map<std::string, std::string>& options);
256 
257  void cloneDataSet(const std::string& name,
258  const std::string& cloneName,
259  const std::map<std::string, std::string>& options);
260 
261  void dropDataSet(const std::string& name);
262 
263  void renameDataSet(const std::string& name, const std::string& newName);
264 
265  void add(const std::string& datasetName,
266  te::da::DataSet* d,
267  const std::map<std::string, std::string>& options,
268  std::size_t limit = 0,
269  bool enableProgress = true);
270 
271  void remove(const std::string& datasetName, const te::da::ObjectIdSet* oids = 0);
272 
273  void update(const std::string& datasetName,
274  te::da::DataSet* dataset,
275  const std::vector<std::size_t>& properties,
276  const te::da::ObjectIdSet* oids,
277  const std::map<std::string, std::string>& options,
278  std::size_t limit = 0);
279 
280  void update(const std::string& datasetName,
281  te::da::DataSet* dataset,
282  const std::vector< std::set<int> >& properties,
283  const std::vector<size_t>& ids);
284 
285  void optimize(const std::map<std::string, std::string>& opInfo);
286 
287  /*!
288  \brief It will check in the database catalog the number that identifies the PostGIS Geometry type.
289 
290  \return The oid of the geometry type or 0 if it is not found.
291 
292  \exception Exception It may throws an exception.
293 
294  \note PostGIS driver extended method.
295  */
296  unsigned int getGeomTypeId();
297 
298  /*!
299  \brief It will check in the database catalog the number that identifies the PostGIS Raster type.
300 
301  \return The oid of the raster type or 0 if it is not found.
302 
303  \exception Exception It may throws an exception.
304 
305  \note PostGIS driver extended method.
306  */
307  unsigned int getRasterTypeId();
308 
309  /*!
310  \brief It retrieves some information about the database such as the default schema used when no one is provided.
311 
312  \param currentSchema A reference to output the current schema.
313 
314  \exception Exception It throws an exception if it was not possible to query the database.
315 
316  \note PostGIS driver extended method.
317  */
318  void getDatabaseInfo(std::string& currentSchema);
319 
320  /*!
321  \brief It loads information about a given geometry column.
322 
323  \param datasetName The name of the dataset containing the geometric property.
324  \param gp The geometric columns to load its information.
325 
326  \exception It throws an exception if it can not load the information.
327  */
328  void getGeometryInfo(const std::string& datasetName, te::gm::GeometryProperty* gp);
329 
330  /*!
331  \brief It loads information about a given raster column.
332 
333  \param datasetName The name of the dataset containing the geometric property.
334  \param rp The raster column to load its information.
335 
336  \exception It throws an exception if it can not load the information.
337  */
338  void getRasterInfo(const std::string& datasetName, te::rst::RasterProperty* rp);
339 
340  /*!
341  \brief It gets the full name of the given name including the schema name.
342 
343  \param name The dataset name.
344 
345  \return The dataset full name.
346  */
347  std::string getFullName(const std::string& name);
348 
349  protected:
350 
351  /*!
352  \brief It looks for the dataset id in the PostgreSQL system.
353 
354  \param datasetName Dataset name. If it has no schema prefix name, it will look the dataset id in the default schema.
355 
356  \exception Exception It throws an exception, if it was not possible to get the dataset id.
357 
358  \note PostGIS driver extended method.
359  */
360  unsigned int getDataSetId(const std::string& datasetName);
361 
362  /*!
363  \brief It looks for a dataset name with the given id in the PostgreSQL.
364 
365  \param id The dataset id.
366 
367  \return The dataset name.
368 
369  \exception Exception It throws an exception if it was not possible to retrieve the information.
370 
371  \note PostGIS driver extended method.
372  */
373  std::string getDataSetName(unsigned int id);
374 
375  /*!
376  \brief It gets the information about the given dataset.
377 
378  \param datasetName The dataset name.
379 
380  \return The information about the given dataset.
381 
382  \note Internally, a record set will be generated containing the following fields:
383  <ul>
384  <li>0 (int2): attribute number in the table (a.attnum), remember that attribute number is 1 based</li>
385  <li>1 (name): attribute name (a.attname)</li>
386  <li>2 (Oid): attribute type oid (t.oid)</li>
387  <li>3 (bool): 't' if attribute is NOT NULL, otherwise, its value is 'f' (a.attnotnull)</li>
388  <li>4 (text): type modifier information, like precision and scale (format_type(a.atttypid, a.atttypmod))</li>
389  <li>5 (bool): 't' if attribute is has a default value, otherwise, its value is 'f' (a.atthasdef)</li>
390  <li>6 (text): attribute default value if field number 5 is true (pg_get_expr(d.adbin, d.adrelid))</li>
391  <li>7 (int4): Number of dimensions, if the column is an array type; otherwise 0 (a.attndims)</li>
392  </ul>
393 
394  \exception Exception It throws an exception if it was not possible to get the information needed.
395 
396  \note PostGIS driver extended method.
397  */
398  std::unique_ptr<te::da::DataSet> getPropertiesInfo(const std::string& datasetName);
399 
400  /*!
401  \brief It sets the property id from the PostgreSQL system.
402 
403  \param p The property whose oid will be set from PostgreSQL system tables.
404 
405  \exception Exception It throws an exception if it was not possible to set the oid information.
406 
407  \note PostGIS driver extended method.
408  */
410 
411  /*!
412  \brief It retrieves a property with the given id from the given dataset.
413 
414  \param pid The property id.
415  \param datasetName The dataset name.
416 
417  \return The property with the given id from the dataset.
418 
419  \note PostGIS driver extended method.
420  */
421  std::unique_ptr<te::dt::Property> getProperty(unsigned int pid, const std::string& datasetName);
422 
423  /*!
424  \brief It gets the dataset containing information about one of the constraints(primary, foreign or
425  unique keys, or the check constraints) of the given dataset. If the constraint type
426  is not specified, it gets all the constraints of the given dataset.
427 
428  \param datasetName The dataset name.
429  \param conType The type of constraint to be retrieved. If this value is '\0' all the types are retrieved.
430 
431  \return A recordset with the following fields:
432  <ul>
433  <li>0 (Oid): constraint oid (c.oid)</li>
434  <li>1 (name): constraint schema name (n.nspname)</li>
435  <li>2 (name): constraint name (c.conname)</li>
436  <li>3 (char): constraint type (c.contype), one of the following values: 'c', 'f', 'p', 'u'</li>
437  <li>4 (Oid): the referenced table (c.confrelid)</li>
438  <li>5 (char): OnUpdate action (c.confupdtype)</li>
439  <li>6 (char): OnDeletion action (c.confdeltype)</li>
440  <li>7 (char): ??? (c.confmatchtype)</li>
441  <li>8 (int2[]): array of attribute numbers (c.conkey), the list of keys in a foreign key, primary key or unique key</li>
442  <li>9 (int2[]): array of attribute numbers in the referenced table (c.confkey)</li>
443  <li>10 (text): constraint expression (pg_get_constraintdef(c.oid))</li>
444  </ul>
445 
446  \return The dataset containing information about the constraints of the given dataset.
447  */
448  std::unique_ptr<te::da::DataSet> getConstraints(const std::string& datasetName, char conType = '\0');
449 
450  /*!
451  \brief It gets the information about all the dataset constraints(primary, foreign and
452  unique keys, and the check constraints) and loads it on the given dataset schema.
453 
454  \param dt The dataset schema.
455  */
457 
458  /*!
459  \brief It gets all the indexes of the given dataset and adds them to the dummy schema.
460 
461  \param dt The dataset schema.
462 
463  \return The dataset indexes.
464  */
466 
467  /*!
468  \brief It gets information about all the sequences in the datasource.
469 
470  \exception It throws an exception if the sequences cannot be loaded.
471 
472  \return The list of sequences in the data source.
473 
474  \note Not thread-safe!
475  \note PostGIS driver extended method.
476  */
477  std::vector<te::da::Sequence*> getSequences();
478 
479  private:
480 
481  DataSource* m_ds; //!< The PostGIS data source associated to this transactor.
482  int m_connectionId; //!< The connection id used by this transactor.
483  const int m_fetchSize; //!< The size of cursor fetch.
484  bool m_getConstraints; //!< Flag that defines if the method getConstraints must be called.
485  int m_transactionCount; //!< Counter used to control the number of begin transaction called.
486  };
487 
488  typedef boost::shared_ptr<Transactor> TransactorPtr;
489 
490  } // end namespace da
491 } // end namespace te
492 
493 #endif // __TERRALIB_POSTGIS_INTERNAL_TRANSACTOR_H
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::da::CheckConstraint
A class that describes a check constraint.
Definition: CheckConstraint.h:47
te::pgis::Transactor::getProperty
std::unique_ptr< te::dt::Property > getProperty(unsigned int pid, const std::string &datasetName)
It retrieves a property with the given id from the given dataset.
te::pgis::Transactor::getLastGeneratedId
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
te::pgis::Transactor::dropUniqueKey
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
te::pgis::Transactor::addIndex
void addIndex(const std::string &datasetName, te::da::Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::pgis::Transactor::hasDataSets
bool hasDataSets()
It checks if the data source has any dataset.
te::pgis::Transactor::getPropertyNames
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
te::pgis::Transactor::dropPrimaryKey
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
te::pgis::Transactor::escape
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
te::pgis::Transactor::addForeignKey
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
te::pgis::Transactor::getDatabaseInfo
void getDatabaseInfo(std::string &currentSchema)
It retrieves some information about the database such as the default schema used when no one is provi...
te::pgis::Transactor::checkConstraintExists
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.
te::pgis::Transactor::update
void update(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=0)
It updates the contents of a dataset for the set of data items.
te::pgis::Transactor::getConnection
Connection * getConnection(const int &id=-1) const
It returns the underlying connection.
te::gm::GeometryProperty
Geometric property.
Definition: GeometryProperty.h:52
te::pgis::Transactor::getPropertiesInfo
std::unique_ptr< te::da::DataSet > getPropertiesInfo(const std::string &datasetName)
It gets the information about the given dataset.
te::pgis::Transactor::renameProperty
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
te::common::RAccess
@ RAccess
Definition: Enums.h:43
te::pgis::Transactor::getForeignKey
std::unique_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
te::pgis::Transactor::cloneDataSet
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.
te::pgis::Transactor::m_getConstraints
bool m_getConstraints
Flag that defines if the method getConstraints must be called.
Definition: Transactor.h:484
te::pgis::Transactor::m_transactionCount
int m_transactionCount
Counter used to control the number of begin transaction called.
Definition: Transactor.h:485
te::pgis::Transactor::getDataSet
std::unique_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=te::common::FORWARDONLY, bool isConnected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name using a spatial filter over the specified property....
te::pgis::Transactor::getUniqueKey
std::unique_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name)
It gets the unique key in the dataset with the given name.
DataSource.h
Data Source for WS OGC WMS.
te::pgis::Transactor::getProperty
std::unique_ptr< te::dt::Property > getProperty(const std::string &datasetName, std::size_t propertyPos)
It retrieves the property lying in the given position from the dataset.
te::pgis::Transactor::sequenceExists
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
te::pgis::Transactor::getRasterInfo
void getRasterInfo(const std::string &datasetName, te::rst::RasterProperty *rp)
It loads information about a given raster column.
te::pgis::Transactor::getConstraints
std::unique_ptr< te::da::DataSet > getConstraints(const std::string &datasetName, char conType='\0')
It gets the dataset containing information about one of the constraints(primary, foreign or unique ke...
te::pgis::Transactor::getGeometryTypeName
std::string getGeometryTypeName(te::gm::GeomType type)
It gets the datasource geometry type name equivalent to terralib.
te::pgis::Transactor::add
void add(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0, bool enableProgress=true)
It adds data items to the dataset in the data source.
te::pgis::Transactor::remove
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
te::da::Query
A Query is independent from the data source language/dialect.
Definition: Query.h:47
te::pgis::Transactor::renameDataSet
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
te::pgis::Transactor::getFullName
std::string getFullName(const std::string &name)
It gets the full name of the given name including the schema name.
te::pgis::Transactor
The transactor class for the PostGIS driver.
Definition: Transactor.h:64
te::common::TraverseType
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:54
te::da::Index
It describes an index associated to a DataSetType.
Definition: Index.h:53
te::pgis::Transactor::addProperty
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
te::pgis::Transactor::getDataSetType
std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
te::pgis::Transactor::addPrimaryKey
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
te::pgis::Transactor::addUniqueKey
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
te::pgis::Transactor::getCheckConstraint
std::unique_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name)
It gets the check constraint of the dataset with the given name.
te::pgis::Transactor::execute
void execute(const std::string &command)
It executes the specifed command in the data source native language.
te::pgis::Transactor::getIndexNames
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
te::pgis::Transactor::getGeomTypeId
unsigned int getGeomTypeId()
It will check in the database catalog the number that identifies the PostGIS Geometry type.
te::pgis::Transactor::dropDataSet
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
te::pgis::Transactor::getGeometryInfo
void getGeometryInfo(const std::string &datasetName, te::gm::GeometryProperty *gp)
It loads information about a given geometry column.
te::pgis::Transactor::dropProperty
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
te::pgis::Transactor::getRasterTypeId
unsigned int getRasterTypeId()
It will check in the database catalog the number that identifies the PostGIS Raster type.
te::pgis::Transactor::execute
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
te::pgis::Transactor::commit
void commit()
It commits the transaction.
te::pgis::Transactor::foreignKeyExists
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.
te::pgis::Transactor::getProperty
std::unique_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
te::pgis::Transactor::getCheckConstraintNames
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
te::rst::RasterProperty
Raster property.
Definition: RasterProperty.h:59
te::pgis::Transactor::begin
void begin()
It starts a new transaction.
te::pgis::Connection
A class that implements a connection to a PostgreSQL database.
Definition: Connection.h:69
te::pgis::Transactor::isInTransaction
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
te::pgis::Transactor::cancel
void cancel()
It requests that the data source stop the processing of the current command.
te::pgis::Transactor::getConstraints
void getConstraints(te::da::DataSetType *dt)
It gets the information about all the dataset constraints(primary, foreign and unique keys,...
te::pgis::DataSource
The PostGIS driver.
Definition: DataSource.h:55
te::pgis::Transactor::m_ds
DataSource * m_ds
The PostGIS data source associated to this transactor.
Definition: Transactor.h:481
te::pgis::Transactor::getSequences
std::vector< te::da::Sequence * > getSequences()
It gets information about all the sequences in the datasource.
te::pgis::Transactor::getDataSetId
unsigned int getDataSetId(const std::string &datasetName)
It looks for the dataset id in the PostgreSQL system.
te::pgis::Transactor::changePropertyDefinition
void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
te::pgis::Transactor::m_fetchSize
const int m_fetchSize
The size of cursor fetch.
Definition: Transactor.h:483
te::pgis::Transactor::getNumberOfProperties
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
te::da::DataSourceTransactor
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
Definition: DataSourceTransactor.h:89
te::pgis::Transactor::primaryKeyExists
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
te::pgis::Transactor::dropCheckConstraint
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
te::pgis::Transactor::getDataSource
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
TEPGISEXPORT
#define TEPGISEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:195
te::pgis::Transactor::optimize
void optimize(const std::map< std::string, std::string > &opInfo)
For some data access drivers, this method will perform some operations to optimize the data storage.
te::da::ForeignKey
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:49
te::gm::SpatialRelation
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:128
te::pgis::Transactor::getProperties
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
te::pgis::Transactor::getExtent
std::unique_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName)
It retrieves the bounding rectangle of the spatial property for the given dataset.
te::pgis::Transactor::query
std::unique_ptr< te::da::DataSet > query(const te::da::Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. A dataset can be connected or di...
te::pgis::Transactor::getPrepared
std::unique_ptr< te::da::PreparedQuery > getPrepared(const std::string &qName=std::string(""))
It creates a prepared query object that may be used for query commands (select, insert,...
te::pgis::Transactor::getNumberOfDataSets
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
te::pgis::Transactor::uniqueKeyExists
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
te::pgis::Transactor::createDataSet
void createDataSet(te::da::DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
te::pgis::Transactor::getUniqueKeyNames
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
te::pgis::Transactor::propertyExists
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
te::pgis::TransactorPtr
boost::shared_ptr< Transactor > TransactorPtr
Definition: Transactor.h:488
te::pgis::Transactor::getExtent
std::unique_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, std::size_t propertyPos)
It retrieves the bounding rectangle for the spatial property lying in the given position in the datas...
te::pgis::Transactor::dropIndex
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
te::pgis::Transactor::getDataSetNames
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
te::pgis::Transactor::dropSequence
void dropSequence(const std::string &name)
It removes the sequence from the data source.
te::pgis::Transactor::getDataSet
std::unique_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=te::common::FORWARDONLY, bool isConnected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name using a spatial filter over the given geometric prop...
te::pgis::Transactor::getPropertyId
void getPropertyId(te::dt::Property *p)
It sets the property id from the PostgreSQL system.
te::da::Select
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:67
te::pgis::Transactor::rollBack
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
te::da::UniqueKey
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:50
te::pgis::Transactor::getDataSetName
std::string getDataSetName(unsigned int id)
It looks for a dataset name with the given id in the PostgreSQL.
te::pgis::Transactor::addCheckConstraint
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
te::pgis::Transactor::getIndex
std::unique_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
te::pgis::Transactor::getBatchExecutor
std::unique_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
te::da::DataSource
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
te::pgis::Transactor::getConnectionID
int getConnectionID() const
It returns the underlying connection ID.
te::pgis::Transactor::addSequence
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
te::dt::Property
It models a property definition.
Definition: Property.h:60
te::da::DataSet
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:114
te::da::Sequence
It describes a sequence (a number generator).
Definition: Sequence.h:57
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::pgis::Transactor::dropForeignKey
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
te::da::PrimaryKey
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:49
te::pgis::Transactor::getSequenceNames
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
te::pgis::Transactor::indexExists
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
te::pgis::Transactor::Transactor
Transactor(DataSource *ds, const int &connectionId=-1)
Constructor.
te::pgis::Transactor::getDataSet
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, bool isConnected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. A dataset can be connected or disconnected....
te::da::DataSetType
A class that models the description of a dataset.
Definition: DataSetType.h:73
te::pgis::Transactor::~Transactor
~Transactor()
The destructor will automatically release the connection to the pool.
te::pgis::Transactor::m_connectionId
int m_connectionId
The connection id used by this transactor.
Definition: Transactor.h:482
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::pgis::Transactor::getSequence
std::unique_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
te::pgis::Transactor::getNumberOfItems
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
te::gm::GeomType
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:42
te::pgis::Transactor::update
void update(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::set< int > > &properties, const std::vector< size_t > &ids)
It updates the contents of a dataset.
te::pgis::Transactor::getIndexes
void getIndexes(te::da::DataSetType *dt)
It gets all the indexes of the given dataset and adds them to the dummy schema.
te::pgis::Transactor::getForeignKeyNames
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
te::common::AccessPolicy
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:41
te::pgis::Transactor::getPrimaryKey
std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
te::pgis::Transactor::dataSetExists
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
te::da::ObjectIdSet
This class represents a set of unique ids created in the same context. i.e. from the same data set.
Definition: ObjectIdSet.h:56
te::common::FORWARDONLY
@ FORWARDONLY
Definition: Enums.h:55
te::pgis::Transactor::query
std::unique_ptr< te::da::DataSet > query(const std::string &query, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using the data source native language....