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/wms/Transactor.h
22 
23  \brief Implementation of the transactor for the WMS driver.
24 */
25 
26 #ifndef __TERRALIB_WMS_INTERNAL_TRANSACTOR_H
27 #define __TERRALIB_WMS_INTERNAL_TRANSACTOR_H
28 
29 // TerraLib
30 #include "../dataaccess/datasource/DataSourceTransactor.h"
31 #include "WMSLayerInfo.h"
32 #include "Config.h"
33 
34 // STL
35 #include <map>
36 #include <memory>
37 #include <string>
38 
39 namespace te
40 {
41  namespace wms
42  {
43  /*!
44  \class Transactor
45 
46  \brief Implementation of the transactor for the WMS driver.
47  */
49  {
50  public:
51 
52  Transactor(const std::string& uri,
53  const std::map<std::string, WMSLayerInfo>& layersInfo);
54 
55  ~Transactor();
56 
57  te::da::DataSource* getDataSource() const;
58 
59  void begin();
60 
61  void commit();
62 
63  void rollBack();
64 
65  bool isInTransaction() const;
66 
67  std::auto_ptr<te::da::DataSet> getDataSet(const std::string& name,
69  bool connected = false,
70  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
71 
72  std::auto_ptr<te::da::DataSet> getDataSet(const std::string& name,
73  const std::string& propertyName,
74  const te::gm::Envelope* e,
77  bool connected = false,
78  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
79 
80  std::auto_ptr<te::da::DataSet> getDataSet(const std::string& name,
81  const std::string& propertyName,
82  const te::gm::Geometry* g,
85  bool connected = false,
86  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
87 
88  std::auto_ptr<te::da::DataSet> getDataSet(const std::string& name,
89  const te::da::ObjectIdSet* oids,
91  bool connected = false,
92  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
93 
94  std::auto_ptr<te::da::DataSet> query(const te::da::Select& q,
96  bool connected = false,
97  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
98 
99  std::auto_ptr<te::da::DataSet> query(const std::string& query,
101  bool connected = false,
102  const te::common::AccessPolicy accessPolicy = te::common::RAccess);
103 
104  void execute(const te::da::Query& command);
105 
106  void execute(const std::string& command);
107 
108  std::auto_ptr<te::da::PreparedQuery> getPrepared(const std::string& qName = std::string(""));
109 
110  std::auto_ptr<te::da::BatchExecutor> getBatchExecutor();
111 
112  void cancel();
113 
114  boost::int64_t getLastGeneratedId();
115 
116  std::string escape(const std::string& value);
117 
118  bool isDataSetNameValid(const std::string& datasetName);
119 
120  bool isPropertyNameValid(const std::string& propertyName);
121 
122  std::vector<std::string> getDataSetNames();
123 
124  std::size_t getNumberOfDataSets();
125 
126  std::auto_ptr<te::da::DataSetType> getDataSetType(const std::string& name);
127 
128  boost::ptr_vector<te::dt::Property> getProperties(const std::string& datasetName);
129 
130  std::auto_ptr<te::dt::Property> getProperty(const std::string& datasetName, const std::string& name);
131 
132  std::auto_ptr<te::dt::Property> getProperty(const std::string& datasetName, std::size_t propertyPos);
133 
134  std::vector<std::string> getPropertyNames(const std::string& datasetName);
135 
136  std::size_t getNumberOfProperties(const std::string& datasetName);
137 
138  bool propertyExists(const std::string& datasetName, const std::string& name);
139 
140  void addProperty(const std::string& datasetName , te::dt::Property* p);
141 
142  void dropProperty(const std::string& datasetName, const std::string& name);
143 
144  void renameProperty(const std::string& datasetName , const std::string& propertyName, const std::string& newPropertyName);
145 
146  std::auto_ptr<te::da::PrimaryKey> getPrimaryKey(const std::string& datasetName);
147 
148  bool primaryKeyExists(const std::string& datasetName, const std::string& name);
149 
150  void addPrimaryKey(const std::string& datasetName, te::da::PrimaryKey* pk);
151 
152  void dropPrimaryKey(const std::string& datasetName);
153 
154  std::auto_ptr<te::da::ForeignKey> getForeignKey(const std::string& datasetName, const std::string& name);
155 
156  std::vector<std::string> getForeignKeyNames(const std::string& datasetName);
157 
158  bool foreignKeyExists(const std::string& datasetName , const std::string& name);
159 
160  void addForeignKey(const std::string& datasetName, te::da::ForeignKey* fk);
161 
162  void dropForeignKey(const std::string& datasetName , const std::string& fkName);
163 
164  std::auto_ptr<te::da::UniqueKey> getUniqueKey(const std::string& datasetName, const std::string& name);
165 
166  std::vector<std::string> getUniqueKeyNames(const std::string& datasetName);
167 
168  bool uniqueKeyExists(const std::string& datasetName, const std::string& name);
169 
170  void addUniqueKey(const std::string& datasetName, te::da::UniqueKey* uk);
171 
172  void dropUniqueKey(const std::string& datasetName, const std::string& name);
173 
174  std::auto_ptr<te::da::CheckConstraint> getCheckConstraint(const std::string& datasetName, const std::string& name);
175 
176  std::vector<std::string> getCheckConstraintNames(const std::string& datasetName);
177 
178  bool checkConstraintExists(const std::string& datasetName, const std::string& name);
179 
180  void addCheckConstraint(const std::string& datasetName, te::da::CheckConstraint* cc);
181 
182  void dropCheckConstraint(const std::string& datasetName, const std::string& name);
183 
184  std::auto_ptr<te::da::Index> getIndex(const std::string& datasetName, const std::string& name);
185 
186  std::vector<std::string> getIndexNames(const std::string& datasetName);
187 
188  bool indexExists(const std::string& datasetName, const std::string& name);
189 
190  void addIndex(const std::string& datasetName, te::da::Index* idx, const std::map<std::string, std::string>& options);
191 
192  void dropIndex(const std::string& datasetName, const std::string& idxName);
193 
194  std::auto_ptr<te::da::Sequence> getSequence(const std::string& name);
195 
196  std::vector<std::string> getSequenceNames();
197 
198  bool sequenceExists(const std::string& name);
199 
200  void addSequence(te::da::Sequence* sequence);
201 
202  void dropSequence(const std::string& name);
203 
204  std::auto_ptr<te::gm::Envelope> getExtent(const std::string& datasetName,
205  const std::string& propertyName);
206 
207  std::auto_ptr<te::gm::Envelope> getExtent(const std::string& datasetName,
208  std::size_t propertyPos);
209 
210  std::size_t getNumberOfItems(const std::string& datasetName);
211 
212  bool hasDataSets();
213 
214  bool dataSetExists(const std::string& name);
215 
216  void createDataSet(te::da::DataSetType* dt,
217  const std::map<std::string, std::string>& options);
218 
219  void cloneDataSet(const std::string& name,
220  const std::string& cloneName,
221  const std::map<std::string, std::string>& options);
222 
223  void dropDataSet(const std::string& name);
224 
225  void renameDataSet(const std::string& name,
226  const std::string& newName);
227 
228  void add(const std::string& datasetName,
229  te::da::DataSet* d,
230  const std::map<std::string, std::string>& options,
231  std::size_t limit = 0);
232 
233  void remove(const std::string& datasetName, const te::da::ObjectIdSet* oids = 0);
234 
235  void update(const std::string& datasetName,
236  te::da::DataSet* dataset,
237  const std::vector<std::size_t>& properties,
238  const te::da::ObjectIdSet* oids,
239  const std::map<std::string, std::string>& options,
240  std::size_t limit = 0);
241 
242  void optimize(const std::map<std::string, std::string>& opInfo);
243 
244  te::common::CharEncoding getEncoding();
245 
246  private:
247 
248  std::string m_uri;
249  std::map<std::string, WMSLayerInfo> m_layersInfo;
250  };
251 
252  } // end namespace wms
253 } // end namespace te
254 
255 #endif // __TERRALIB_WMS_INTERNAL_TRANSACTOR_H
Implementation of the transactor for the WMS driver.
Definition: Transactor.h:48
#define TEWMSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:132
Informations about WMS Layers.
std::map< std::string, WMSLayerInfo > m_layersInfo
Definition: Transactor.h:249
CharEncoding
Supported charsets (character encoding).
std::string m_uri
Definition: Transactor.h:248
A class that models the description of a dataset.
Definition: DataSetType.h:72
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:127
It describes a sequence (a number generator).
Definition: Sequence.h:56
A class that describes a check constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
It models a property definition.
Definition: Property.h:59
Configuration flags for the TerraLib WMS module.
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
URI C++ Library.
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
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...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
A Query is independent from the data source language/dialect.
Definition: Query.h:46
It describes an index associated to a DataSetType.
Definition: Index.h:54