src/terralib/dataaccess/datasource/DataSource.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/dataaccess/datasource/DataSource.cpp
22 
23  \brief An abstract class for data providers like a DBMS, Web Services or a regular file.
24 */
25 
26 // TerraLib
27 #include "../../core/translator/Translator.h"
28 #include "../../geometry/Envelope.h"
29 #include "../dataset/DataSetCapabilities.h"
30 #include "../dataset/DataSetTypeCapabilities.h"
31 #include "../dataset/ObjectIdSet.h"
32 #include "../query/DataSetName.h"
33 #include "../query/Field.h"
34 #include "../query/Fields.h"
35 #include "../query/From.h"
36 #include "../query/FromItem.h"
37 #include "../query/Select.h"
38 #include "../query/Where.h"
39 #include "DataSource.h"
40 #include "DataSourceCapabilities.h"
41 #include "DataSourceCatalog.h"
42 #include "DataSourceFactory.h"
43 #include "DataSourceTransactor.h"
44 
45 
46 te::da::DataSource::DataSource(const std::string& connInfo) :
47  m_id(""),
48  m_uri(te::core::URI(connInfo))
49 {
50 }
51 
53  : m_id(""),
54  m_uri(uri)
55 {
56 }
57 
59 
60 const std::string& te::da::DataSource::getId() const
61 {
62  return m_id;
63 }
64 
65 void te::da::DataSource::setId(const std::string& id)
66 {
67  m_id = id;
68 }
69 
71 {
72  return m_uri;
73 }
74 
75 std::unique_ptr<te::da::DataSet> te::da::DataSource::getDataSet(const std::string& name,
76  te::common::TraverseType travType,
77  const te::common::AccessPolicy accessPolicy)
78 {
79  std::unique_ptr<DataSourceTransactor> t = getTransactor();
80  return t->getDataSet(name, travType, isConnected(), accessPolicy);
81 }
82 
83 std::unique_ptr<te::da::DataSet> te::da::DataSource::getDataSet(const std::string& name,
84  const std::string& propertyName,
85  const te::gm::Envelope* e,
87  te::common::TraverseType travType,
88  const te::common::AccessPolicy accessPolicy)
89 {
90  std::unique_ptr<DataSourceTransactor> t = getTransactor();
91  return t->getDataSet(name, propertyName, e, r, travType, isConnected(), accessPolicy);
92 }
93 
94 std::unique_ptr<te::da::DataSet> te::da::DataSource::getDataSet(const std::string& name,
95  const std::string& propertyName,
96  const te::gm::Geometry* g,
98  te::common::TraverseType travType,
99  const te::common::AccessPolicy accessPolicy)
100 {
101  std::unique_ptr<DataSourceTransactor> t = getTransactor();
102  return t->getDataSet(name, propertyName, g, r, travType, isConnected(), accessPolicy);
103 }
104 
105 std::unique_ptr<te::da::DataSet> te::da::DataSource::getDataSet(const std::string& name,
106  const te::da::ObjectIdSet* oids,
107  te::common::TraverseType travType,
108  const te::common::AccessPolicy accessPolicy)
109 {
110  std::unique_ptr<DataSourceTransactor> t = getTransactor();
111  return t->getDataSet(name, oids, travType, isConnected(), accessPolicy);
112 }
113 
114 std::unique_ptr<te::da::DataSet> te::da::DataSource::query(const Select& q, te::common::TraverseType travType,
115  const te::common::AccessPolicy accessPolicy)
116 {
117  std::unique_ptr<DataSourceTransactor> t = getTransactor();
118  return t->query(q, travType, false,accessPolicy);
119 }
120 
121 std::unique_ptr<te::da::DataSet> te::da::DataSource::query(const std::string& query, te::common::TraverseType travType,
122  const te::common::AccessPolicy accessPolicy)
123 {
124  std::unique_ptr<DataSourceTransactor> t = getTransactor();
125  return t->query(query, travType, false,accessPolicy);
126 }
127 
128 void te::da::DataSource::execute(const Query& command)
129 {
130  std::unique_ptr<DataSourceTransactor> t = getTransactor();
131  return t->execute(command);
132 }
133 
134 void te::da::DataSource::execute(const std::string& command)
135 {
136  std::unique_ptr<DataSourceTransactor> t = getTransactor();
137  return t->execute(command);
138 }
139 
140 std::string te::da::DataSource::escape(const std::string& value)
141 {
142  std::unique_ptr<DataSourceTransactor> t = getTransactor();
143  return t->escape(value);
144 }
145 
146 bool te::da::DataSource::isDataSetNameValid(const std::string& datasetName)
147 {
148  std::unique_ptr<DataSourceTransactor> t = getTransactor();
149  return t->isDataSetNameValid(datasetName);
150 }
151 
152 bool te::da::DataSource::isPropertyNameValid(const std::string& propertyName)
153 {
154  std::unique_ptr<DataSourceTransactor> t = getTransactor();
155  return t->isPropertyNameValid(propertyName);
156 }
157 
158 std::vector<std::string> te::da::DataSource::getDataSetNames()
159 {
160  std::unique_ptr<DataSourceTransactor> t = getTransactor();
161  return t->getDataSetNames();
162 }
163 
165 {
166  std::unique_ptr<DataSourceTransactor> t = getTransactor();
167  return t->getNumberOfDataSets();
168 }
169 
170 std::unique_ptr<te::da::DataSetType> te::da::DataSource::getDataSetType(const std::string& name)
171 {
172  std::unique_ptr<DataSourceTransactor> t = getTransactor();
173  return t->getDataSetType(name);
174 }
175 
176 std::unique_ptr<te::da::DataSetTypeCapabilities> te::da::DataSource::getCapabilities(const std::string &name)
177 {
178  std::unique_ptr<DataSourceTransactor> t = getTransactor();
179  return t->getCapabilities(name);
180 }
181 
182 boost::ptr_vector<te::dt::Property> te::da::DataSource::getProperties(const std::string& datasetName)
183 {
184  std::unique_ptr<DataSourceTransactor> t = getTransactor();
185  return t->getProperties(datasetName);
186 }
187 
188 std::vector<std::string> te::da::DataSource::getPropertyNames(const std::string& datasetName)
189 {
190  std::unique_ptr<DataSourceTransactor> t = getTransactor();
191  return t->getPropertyNames(datasetName);
192 }
193 
194 std::size_t te::da::DataSource::getNumberOfProperties(const std::string& datasetName)
195 {
196  std::unique_ptr<DataSourceTransactor> t = getTransactor();
197  return t->getNumberOfProperties(datasetName);
198 }
199 
200 bool te::da::DataSource::propertyExists(const std::string& datasetName, const std::string& name)
201 {
202  std::unique_ptr<DataSourceTransactor> t = getTransactor();
203  return t->propertyExists(datasetName, name);
204 }
205 
206 std::unique_ptr<te::dt::Property> te::da::DataSource::getProperty(const std::string& datasetName, const std::string& name)
207 {
208  std::unique_ptr<DataSourceTransactor> t = getTransactor();
209  return t->getProperty(datasetName, name);
210 }
211 
212 std::unique_ptr<te::dt::Property> te::da::DataSource::getProperty(const std::string& datasetName, std::size_t propertyPos)
213 {
214  std::unique_ptr<DataSourceTransactor> t = getTransactor();
215  return t->getProperty(datasetName, propertyPos);
216 }
217 
218 void te::da::DataSource::addProperty(const std::string& datasetName, te::dt::Property* p)
219 {
220  std::unique_ptr<DataSourceTransactor> t = getTransactor();
221  return t->addProperty(datasetName, p);
222 }
223 
224 void te::da::DataSource::dropProperty(const std::string& datasetName, const std::string& name)
225 {
226  std::unique_ptr<DataSourceTransactor> t = getTransactor();
227  return t->dropProperty(datasetName, name);
228 }
229 
230 void te::da::DataSource::renameProperty(const std::string& datasetName,
231  const std::string& propertyName,
232  const std::string& newPropertyName)
233 {
234  std::unique_ptr<DataSourceTransactor> t = getTransactor();
235  return t->renameProperty(datasetName, propertyName, newPropertyName);
236 }
237 
238 void te::da::DataSource::changePropertyDefinition(const std::string& datasetName, const std::string& propName, te::dt::Property* newProp)
239 {
240  std::unique_ptr<DataSourceTransactor> t = getTransactor();
241  return t->changePropertyDefinition(datasetName, propName, newProp);
242 }
243 
244 void te::da::DataSource::changePropertiesDefinitions(const std::string& datasetName, const std::vector<std::string>& propsNames, const std::vector<te::dt::Property*> newProps)
245 {
246  assert(propsNames.size() == newProps.size());
247 
248  for(std::size_t i = 0; i < propsNames.size(); ++i)
249  changePropertyDefinition(datasetName, propsNames[i], newProps[i]);
250 }
251 
252 std::unique_ptr<te::da::PrimaryKey> te::da::DataSource::getPrimaryKey(const std::string& datasetName)
253 {
254  std::unique_ptr<DataSourceTransactor> t = getTransactor();
255  return t->getPrimaryKey(datasetName);
256 }
257 
258 bool te::da::DataSource::primaryKeyExists(const std::string& datasetName, const std::string& name)
259 {
260  std::unique_ptr<DataSourceTransactor> t = getTransactor();
261  return t->primaryKeyExists(datasetName, name);
262 }
263 
264 void te::da::DataSource::addPrimaryKey(const std::string& datasetName, PrimaryKey* pk)
265 {
266  std::unique_ptr<DataSourceTransactor> t = getTransactor();
267  return t->addPrimaryKey(datasetName, pk);
268 }
269 
270 void te::da::DataSource::dropPrimaryKey(const std::string& datasetName)
271 {
272  std::unique_ptr<DataSourceTransactor> t = getTransactor();
273  return t->dropPrimaryKey(datasetName);
274 }
275 
276 std::unique_ptr<te::da::ForeignKey> te::da::DataSource::getForeignKey(const std::string& datasetName, const std::string& name)
277 {
278  std::unique_ptr<DataSourceTransactor> t = getTransactor();
279  return t->getForeignKey(datasetName, name);
280 }
281 
282 std::vector<std::string> te::da::DataSource::getForeignKeyNames(const std::string& datasetName)
283 {
284  std::unique_ptr<DataSourceTransactor> t = getTransactor();
285  return t->getForeignKeyNames(datasetName);
286 }
287 
288 bool te::da::DataSource::foreignKeyExists(const std::string& datasetName, const std::string& name)
289 {
290  std::unique_ptr<DataSourceTransactor> t = getTransactor();
291  return t->foreignKeyExists(datasetName, name);
292 }
293 
294 void te::da::DataSource::addForeignKey(const std::string& datasetName, ForeignKey* fk)
295 {
296  std::unique_ptr<DataSourceTransactor> t = getTransactor();
297  return t->addForeignKey(datasetName, fk);
298 }
299 
300 void te::da::DataSource::dropForeignKey(const std::string& datasetName, const std::string& fkName)
301 {
302  std::unique_ptr<DataSourceTransactor> t = getTransactor();
303  return t->dropForeignKey(datasetName, fkName);
304 }
305 
306 std::unique_ptr<te::da::UniqueKey> te::da::DataSource::getUniqueKey(const std::string& datasetName,
307  const std::string& name)
308 {
309  std::unique_ptr<DataSourceTransactor> t = getTransactor();
310  return t->getUniqueKey(datasetName, name);
311 }
312 
313 std::vector<std::string> te::da::DataSource::getUniqueKeyNames(const std::string& datasetName)
314 {
315  std::unique_ptr<DataSourceTransactor> t = getTransactor();
316  return t->getUniqueKeyNames(datasetName);
317 }
318 
319 bool te::da::DataSource::uniqueKeyExists(const std::string& datasetName, const std::string& name)
320 {
321  std::unique_ptr<DataSourceTransactor> t = getTransactor();
322  return t->uniqueKeyExists(datasetName, name);
323 }
324 
325 void te::da::DataSource::addUniqueKey(const std::string& datasetName, UniqueKey* uk)
326 {
327  std::unique_ptr<DataSourceTransactor> t = getTransactor();
328  return t->addUniqueKey(datasetName, uk);
329 }
330 
331 void te::da::DataSource::dropUniqueKey(const std::string& datasetName, const std::string& name)
332 {
333  std::unique_ptr<DataSourceTransactor> t = getTransactor();
334  return t->dropUniqueKey(datasetName, name);
335 }
336 
337 std::unique_ptr<te::da::CheckConstraint> te::da::DataSource::getCheckConstraint(const std::string& datasetName,
338  const std::string& name)
339 {
340  std::unique_ptr<DataSourceTransactor> t = getTransactor();
341  return t->getCheckConstraint(datasetName, name);
342 }
343 
344 std::vector<std::string> te::da::DataSource::getCheckConstraintNames(const std::string& datasetName)
345 {
346  std::unique_ptr<DataSourceTransactor> t = getTransactor();
347  return t->getCheckConstraintNames(datasetName);
348 }
349 
350 bool te::da::DataSource::checkConstraintExists(const std::string& datasetName, const std::string& name)
351 {
352  std::unique_ptr<DataSourceTransactor> t = getTransactor();
353  return t->checkConstraintExists(datasetName, name);
354 }
355 
356 void te::da::DataSource::addCheckConstraint(const std::string& datasetName, CheckConstraint* cc)
357 {
358  std::unique_ptr<DataSourceTransactor> t = getTransactor();
359  return t->addCheckConstraint(datasetName, cc);
360 }
361 
362 void te::da::DataSource::dropCheckConstraint(const std::string& datasetName, const std::string& name)
363 {
364  std::unique_ptr<DataSourceTransactor> t = getTransactor();
365  return t->dropCheckConstraint(datasetName, name);
366 }
367 
368 std::unique_ptr<te::da::Index> te::da::DataSource::getIndex(const std::string& datasetName, const std::string& name)
369 {
370  std::unique_ptr<DataSourceTransactor> t = getTransactor();
371  return t->getIndex(datasetName, name);
372 }
373 
374 std::vector<std::string> te::da::DataSource::getIndexNames(const std::string& datasetName)
375 {
376  std::unique_ptr<DataSourceTransactor> t = getTransactor();
377  return t->getIndexNames(datasetName);
378 }
379 
380 bool te::da::DataSource::indexExists(const std::string& datasetName, const std::string& name)
381 {
382  std::unique_ptr<DataSourceTransactor> t = getTransactor();
383  return t->indexExists(datasetName, name);
384 }
385 
386 void te::da::DataSource::addIndex(const std::string& datasetName, Index* idx,
387  const std::map<std::string, std::string>& options)
388 {
389  std::unique_ptr<DataSourceTransactor> t = getTransactor();
390  return t->addIndex(datasetName, idx, options);
391 }
392 
393 void te::da::DataSource::dropIndex(const std::string& datasetName, const std::string& idxName)
394 {
395  std::unique_ptr<DataSourceTransactor> t = getTransactor();
396  return t->dropIndex(datasetName, idxName);
397 }
398 
399 std::unique_ptr<te::da::Sequence> te::da::DataSource::getSequence(const std::string& name)
400 {
401  std::unique_ptr<DataSourceTransactor> t = getTransactor();
402  return t->getSequence(name);
403 }
404 
405 std::vector<std::string> te::da::DataSource::getSequenceNames()
406 {
407  std::unique_ptr<DataSourceTransactor> t = getTransactor();
408  return t->getSequenceNames();
409 }
410 
411 bool te::da::DataSource::sequenceExists(const std::string& name)
412 {
413  std::unique_ptr<DataSourceTransactor> t = getTransactor();
414  return t->sequenceExists(name);
415 }
416 
418 {
419  std::unique_ptr<DataSourceTransactor> t = getTransactor();
420  return t->addSequence(sequence);
421 }
422 
423 void te::da::DataSource::dropSequence(const std::string& name)
424 {
425  std::unique_ptr<DataSourceTransactor> t = getTransactor();
426  return t->dropSequence(name);
427 }
428 
429 std::unique_ptr<te::gm::Envelope> te::da::DataSource::getExtent(const std::string& datasetName, const std::string& propertyName)
430 {
431  std::unique_ptr<DataSourceTransactor> t = getTransactor();
432  return t->getExtent(datasetName, propertyName);
433 }
434 
435 std::unique_ptr<te::gm::Envelope> te::da::DataSource::getExtent(const std::string& datasetName, std::size_t propertyPos)
436 {
437  std::unique_ptr<DataSourceTransactor> t = getTransactor();
438  return t->getExtent(datasetName, propertyPos);
439 }
440 
441 std::size_t te::da::DataSource::getNumberOfItems(const std::string& datasetName)
442 {
443  std::unique_ptr<DataSourceTransactor> t = getTransactor();
444  return t->getNumberOfItems(datasetName);
445 }
446 
448 {
449  std::unique_ptr<DataSourceTransactor> t = getTransactor();
450  return t->hasDataSets();
451 }
452 
453 bool te::da::DataSource::dataSetExists(const std::string& name)
454 {
455  std::unique_ptr<DataSourceTransactor> t = getTransactor();
456  return t->dataSetExists(name);
457 }
458 
459 void te::da::DataSource::createDataSet(DataSetType* dt, const std::map<std::string, std::string>& options)
460 {
461  std::unique_ptr<DataSourceTransactor> t = getTransactor();
462  return t->createDataSet(dt, options);
463 }
464 
465 void te::da::DataSource::cloneDataSet(const std::string& name,
466  const std::string& cloneName,
467  const std::map<std::string, std::string>& options)
468 {
469  std::unique_ptr<DataSourceTransactor> t = getTransactor();
470  return t->cloneDataSet(name, cloneName, options);
471 }
472 
473 void te::da::DataSource::dropDataSet(const std::string& name)
474 {
475  std::unique_ptr<DataSourceTransactor> t = getTransactor();
476  return t->dropDataSet(name);
477 }
478 
479 void te::da::DataSource::renameDataSet(const std::string& name, const std::string& newName)
480 {
481  std::unique_ptr<DataSourceTransactor> t = getTransactor();
482  return t->renameDataSet(name, newName);
483 }
484 
485 void te::da::DataSource::add(const std::string& datasetName,
486  DataSet* d,
487  const std::map<std::string, std::string>& options,
488  std::size_t limit)
489 {
490  std::unique_ptr<DataSourceTransactor> t = getTransactor();
491  return t->add(datasetName, d, options, limit);
492 }
493 
494 void te::da::DataSource::remove(const std::string& datasetName, const ObjectIdSet* oids)
495 {
496  std::unique_ptr<DataSourceTransactor> t = getTransactor();
497  return t->remove(datasetName, oids);
498 }
499 
500 void te::da::DataSource::update(const std::string& datasetName,
501  DataSet* dataset,
502  const std::vector<std::size_t>& properties,
503  const ObjectIdSet* oids,
504  const std::map<std::string, std::string>& options,
505  std::size_t limit)
506 {
507  std::unique_ptr<DataSourceTransactor> t = getTransactor();
508  return t->update(datasetName, dataset, properties, oids, options, limit);
509 }
510 
511 void te::da::DataSource::update(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::set<int> >& properties,
512  const std::vector<size_t>& ids)
513 {
514  std::unique_ptr<DataSourceTransactor> t = getTransactor();
515  return t->update(datasetName, dataset, properties, ids);
516 }
517 
519 {
521 }
522 
524 {
525 
526 }
527 
528 std::unique_ptr<te::da::DataSource> te::da::DataSource::create(const std::string& dsType, const std::string& connInfo)
529 {
530  std::unique_ptr<DataSource> ds(DataSourceFactory::make(dsType, connInfo));
531 
532  if(ds.get() == nullptr)
533  throw Exception(TE_TR("Could not find the appropriate factory to create a data source instance!"));
534 
535  ds->create(connInfo);
536 
537  return ds;
538 }
539 
540 void te::da::DataSource::drop(const std::string& dsType, const std::string& connInfo)
541 {
542  std::unique_ptr<DataSource> ds(DataSourceFactory::make(dsType, connInfo));
543 
544  if(ds.get() == nullptr)
545  throw Exception(TE_TR("Could not find the appropriate factory to create a data source instance!"));
546 
547  ds->drop(connInfo);
548 }
549 
550 bool te::da::DataSource::exists(const std::string& dsType, const std::string& connInfo)
551 {
552  std::unique_ptr<DataSource> ds(DataSourceFactory::make(dsType, connInfo));
553 
554  if(ds.get() == nullptr)
555  throw Exception(TE_TR("Could not find the appropriate factory in order to create a data source instance!"));
556 
557  return ds->exists(connInfo);
558 }
559 
560 std::vector<std::string> te::da::DataSource::getDataSourceNames(const std::string& dsType, const std::string& connInfo)
561 {
562  std::unique_ptr<DataSource> ds(DataSourceFactory::make(dsType, connInfo));
563 
564  if(ds.get() == nullptr)
565  throw Exception(TE_TR("Could not find the appropriate factory to create a data source instance!"));
566 
567  return ds->getDataSourceNames(connInfo);
568 }
569 
571 {
573 
575 
576  return dsCap.isConnected();
577 }
578 
580 {
581  std::unique_ptr<DataSourceTransactor> t = getTransactor();
582  return t->getGeometryTypeName(type);
583 }
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.
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.
virtual std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
virtual std::unique_ptr< DataSourceTransactor > getTransactor()=0
It returns the set of parameters used to set up the access channel to the underlying repository...
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.
virtual 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.
virtual boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
virtual void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Base exception class for plugin module.
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 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.
virtual std::unique_ptr< ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
virtual void setEncoding(const te::core::EncodingType &et)
It sets the encodings for the data source.
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.
SpatialRelation
Spatial relations between geometric objects.
It describes a sequence (a number generator).
virtual 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.
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.
virtual ~DataSource()
Virtual destructor.
A class that informs what the dataset implementation of a given data source can perform.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
virtual std::unique_ptr< Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
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.
It models a property definition.
Definition: Property.h:59
virtual te::core::EncodingType getEncoding()
It return the DataSource current encoding.
virtual std::unique_ptr< DataSet > query(const Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. This method always returns a dis...
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.
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.
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
virtual 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.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
virtual void addCheckConstraint(const std::string &datasetName, CheckConstraint *cc)
It adds a check constraint to the dataset.
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.
URI C++ Library.
Definition: Attributes.h:37
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.
A factory for data sources.
void setId(const std::string &id)
It sets the data source identification.
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.
It represents the system catalog of a DataSource.
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 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
virtual std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about 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
std::string m_id
The data source identification.
virtual bool isDataSetNameValid(const std::string &datasetName)
It checks if the given dataset name is valid.
A class for representing an Uniform Resource Identifier (URI).
Definition: URI.h:49
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 std::unique_ptr< DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. This method always returns a disconnected dataset...
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 void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
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.
te::core::URI m_uri
The URI used to describe the datasource connection;.
virtual std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
virtual 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.
virtual std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
virtual std::string getGeometryTypeName(te::gm::GeomType type)
It gets the datasource geometry type name equivalent to terralib.
virtual void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the 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 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.
const std::string & getId() const
An identification value for the data source.
virtual std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
virtual 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.
const DataSetCapabilities & getDataSetCapabilities() const
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.
A class that represents the known capabilities of a specific data source.
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 void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.