27 #include "../../common/Translator.h"
28 #include "../../geometry/Envelope.h"
29 #include "../dataset/ObjectIdSet.h"
30 #include "../query/DataSetName.h"
31 #include "../query/Field.h"
32 #include "../query/Fields.h"
33 #include "../query/From.h"
34 #include "../query/FromItem.h"
35 #include "../query/Select.h"
36 #include "../query/Where.h"
64 std::auto_ptr<DataSourceTransactor> t = getTransactor();
65 return t->getDataSet(name, travType,
false, accessPolicy);
69 const std::string& propertyName,
75 std::auto_ptr<DataSourceTransactor> t = getTransactor();
76 return t->getDataSet(name, propertyName, e, r, travType,
false, accessPolicy);
80 const std::string& propertyName,
86 std::auto_ptr<DataSourceTransactor> t = getTransactor();
87 return t->getDataSet(name, propertyName, g, r, travType,
false, accessPolicy);
95 std::auto_ptr<DataSourceTransactor> t = getTransactor();
96 return t->getDataSet(name, oids, travType,
false, accessPolicy);
102 std::auto_ptr<DataSourceTransactor> t = getTransactor();
103 return t->query(q, travType,
false,accessPolicy);
109 std::auto_ptr<DataSourceTransactor> t = getTransactor();
110 return t->query(query, travType,
false,accessPolicy);
115 std::auto_ptr<DataSourceTransactor> t = getTransactor();
116 return t->execute(command);
121 std::auto_ptr<DataSourceTransactor> t = getTransactor();
122 return t->execute(command);
127 std::auto_ptr<DataSourceTransactor> t = getTransactor();
128 return t->escape(value);
133 std::auto_ptr<DataSourceTransactor> t = getTransactor();
134 return t->isDataSetNameValid(datasetName);
139 std::auto_ptr<DataSourceTransactor> t = getTransactor();
140 return t->isPropertyNameValid(propertyName);
145 std::auto_ptr<DataSourceTransactor> t = getTransactor();
146 return t->getDataSetNames();
151 std::auto_ptr<DataSourceTransactor> t = getTransactor();
152 return t->getNumberOfDataSets();
157 std::auto_ptr<DataSourceTransactor> t = getTransactor();
158 return t->getDataSetType(name);
163 std::auto_ptr<DataSourceTransactor> t = getTransactor();
164 return t->getProperties(datasetName);
169 std::auto_ptr<DataSourceTransactor> t = getTransactor();
170 return t->getPropertyNames(datasetName);
175 std::auto_ptr<DataSourceTransactor> t = getTransactor();
176 return t->getNumberOfProperties(datasetName);
181 std::auto_ptr<DataSourceTransactor> t = getTransactor();
182 return t->propertyExists(datasetName, name);
187 std::auto_ptr<DataSourceTransactor> t = getTransactor();
188 return t->getProperty(datasetName, name);
193 std::auto_ptr<DataSourceTransactor> t = getTransactor();
194 return t->getProperty(datasetName, propertyPos);
199 std::auto_ptr<DataSourceTransactor> t = getTransactor();
200 return t->addProperty(datasetName, p);
205 std::auto_ptr<DataSourceTransactor> t = getTransactor();
206 return t->dropProperty(datasetName, name);
210 const std::string& propertyName,
211 const std::string& newPropertyName)
213 std::auto_ptr<DataSourceTransactor> t = getTransactor();
214 return t->renameProperty(datasetName, propertyName, newPropertyName);
219 std::auto_ptr<DataSourceTransactor> t = getTransactor();
220 return t->getPrimaryKey(datasetName);
225 std::auto_ptr<DataSourceTransactor> t = getTransactor();
226 return t->primaryKeyExists(datasetName, name);
231 std::auto_ptr<DataSourceTransactor> t = getTransactor();
232 return t->addPrimaryKey(datasetName, pk);
237 std::auto_ptr<DataSourceTransactor> t = getTransactor();
238 return t->dropPrimaryKey(datasetName);
243 std::auto_ptr<DataSourceTransactor> t = getTransactor();
244 return t->getForeignKey(datasetName, name);
249 std::auto_ptr<DataSourceTransactor> t = getTransactor();
250 return t->getForeignKeyNames(datasetName);
255 std::auto_ptr<DataSourceTransactor> t = getTransactor();
256 return t->foreignKeyExists(datasetName, name);
261 std::auto_ptr<DataSourceTransactor> t = getTransactor();
262 return t->addForeignKey(datasetName, fk);
267 std::auto_ptr<DataSourceTransactor> t = getTransactor();
268 return t->dropForeignKey(datasetName, fkName);
272 const std::string& name)
274 std::auto_ptr<DataSourceTransactor> t = getTransactor();
275 return t->getUniqueKey(datasetName, name);
280 std::auto_ptr<DataSourceTransactor> t = getTransactor();
281 return t->getUniqueKeyNames(datasetName);
286 std::auto_ptr<DataSourceTransactor> t = getTransactor();
287 return t->uniqueKeyExists(datasetName, name);
292 std::auto_ptr<DataSourceTransactor> t = getTransactor();
293 return t->addUniqueKey(datasetName, uk);
298 std::auto_ptr<DataSourceTransactor> t = getTransactor();
299 return t->dropUniqueKey(datasetName, name);
303 const std::string& name)
305 std::auto_ptr<DataSourceTransactor> t = getTransactor();
306 return t->getCheckConstraint(datasetName, name);
311 std::auto_ptr<DataSourceTransactor> t = getTransactor();
312 return t->getCheckConstraintNames(datasetName);
317 std::auto_ptr<DataSourceTransactor> t = getTransactor();
318 return t->checkConstraintExists(datasetName, name);
323 std::auto_ptr<DataSourceTransactor> t = getTransactor();
324 return t->addCheckConstraint(datasetName, cc);
329 std::auto_ptr<DataSourceTransactor> t = getTransactor();
330 return t->dropCheckConstraint(datasetName, name);
335 std::auto_ptr<DataSourceTransactor> t = getTransactor();
336 return t->getIndex(datasetName, name);
341 std::auto_ptr<DataSourceTransactor> t = getTransactor();
342 return t->getIndexNames(datasetName);
347 std::auto_ptr<DataSourceTransactor> t = getTransactor();
348 return t->indexExists(datasetName, name);
352 const std::map<std::string, std::string>& options)
354 std::auto_ptr<DataSourceTransactor> t = getTransactor();
355 return t->addIndex(datasetName, idx, options);
360 std::auto_ptr<DataSourceTransactor> t = getTransactor();
361 return t->dropIndex(datasetName, idxName);
366 std::auto_ptr<DataSourceTransactor> t = getTransactor();
367 return t->getSequence(name);
372 std::auto_ptr<DataSourceTransactor> t = getTransactor();
373 return t->getSequenceNames();
378 std::auto_ptr<DataSourceTransactor> t = getTransactor();
379 return t->sequenceExists(name);
384 std::auto_ptr<DataSourceTransactor> t = getTransactor();
385 return t->addSequence(sequence);
390 std::auto_ptr<DataSourceTransactor> t = getTransactor();
391 return t->dropSequence(name);
396 std::auto_ptr<DataSourceTransactor> t = getTransactor();
397 return t->getExtent(datasetName, propertyName);
402 std::auto_ptr<DataSourceTransactor> t = getTransactor();
403 return t->getExtent(datasetName, propertyPos);
408 std::auto_ptr<DataSourceTransactor> t = getTransactor();
409 return t->getNumberOfItems(datasetName);
414 std::auto_ptr<DataSourceTransactor> t = getTransactor();
415 return t->hasDataSets();
420 std::auto_ptr<DataSourceTransactor> t = getTransactor();
421 return t->dataSetExists(name);
426 std::auto_ptr<DataSourceTransactor> t = getTransactor();
427 return t->createDataSet(dt, options);
431 const std::string& cloneName,
432 const std::map<std::string, std::string>& options)
434 std::auto_ptr<DataSourceTransactor> t = getTransactor();
435 return t->cloneDataSet(name, cloneName, options);
440 std::auto_ptr<DataSourceTransactor> t = getTransactor();
441 return t->dropDataSet(name);
446 std::auto_ptr<DataSourceTransactor> t = getTransactor();
447 return t->renameDataSet(name, newName);
452 const std::map<std::string, std::string>& options,
455 std::auto_ptr<DataSourceTransactor> t = getTransactor();
456 return t->add(datasetName, d, options, limit);
461 std::auto_ptr<DataSourceTransactor> t = getTransactor();
462 return t->remove(datasetName);
467 const std::vector<std::size_t>& properties,
469 const std::map<std::string, std::string>& options,
472 std::auto_ptr<DataSourceTransactor> t = getTransactor();
473 return t->update(datasetName, dataset, properties, oids, options, limit);
481 throw Exception(
TR_DATAACCESS(
"Could not find the appropriate factory to create a data source instance!"));
493 throw Exception(
TR_DATAACCESS(
"Could not find the appropriate factory to create a data source instance!"));
503 throw Exception(
TR_DATAACCESS(
"Could not find the appropriate factory in order to create a data source instance!"));
505 return ds->exists(dsInfo);
513 throw Exception(
TR_DATAACCESS(
"Could not find the appropriate factory to create a data source instance!"));
515 return ds->getDataSourceNames(dsInfo);
523 throw Exception(
TR_DATAACCESS(
"Could not find the appropriate factory to create a data source instance!"));
525 return ds->getEncodings(dsInfo);
static std::vector< std::string > getDataSourceNames(const std::string &dsType, const std::map< std::string, std::string > &info)
It returns the data source names available in the driver.
virtual void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
static std::auto_ptr< DataSource > create(const std::string &dsType, const std::map< std::string, std::string > &dsInfo)
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 execute(const Query &command)
It executes the specified command using a generic query representation.
virtual void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
It describes an index associated to a DataSetType.
A factory for data sources.
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.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
virtual bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
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 boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
static bool exists(const std::string &dsType, const std::map< std::string, std::string > &dsInfo)
It checks if the data source exists with the connection information and the driver type...
virtual void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
void setId(const std::string &id)
It sets the data source identification.
A Select models a query to be used when retrieving data from a DataSource.
virtual ~DataSource()
Virtual destructor.
virtual std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
virtual std::auto_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.
virtual void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the given dataset.
virtual void dropSequence(const std::string &name)
It removes the sequence from the data source.
It describes a primary key (pk) constraint.
virtual bool isDataSetNameValid(const std::string &datasetName)
It checks if the given dataset name is valid.
virtual void addPrimaryKey(const std::string &datasetName, PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
static void drop(const std::string &dsType, const std::map< std::string, std::string > &dsInfo)
It removes a data source identified by its connection information and the driver type.
static std::auto_ptr< DataSource > make(const std::string &dsType)
It describes a sequence (a number generator).
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
virtual std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
virtual std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
SpatialRelation
Spatial relations between geometric objects.
It models a foreign key constraint for a DataSetType.
virtual void addSequence(Sequence *sequence)
It adds a new sequence in the data source.
virtual std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
AccessPolicy
Supported data access policies (can be used as bitfield).
DataSource()
Default constructor that can be called by subclasses.
virtual void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
virtual std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
static std::vector< std::string > getEncodings(const std::string &dsType, const std::map< std::string, std::string > &info)
It gets the encoding names of the data source.
virtual void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
virtual void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
virtual std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
virtual void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
A Query is independent from the data source language/dialect.
virtual void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
virtual void addForeignKey(const std::string &datasetName, ForeignKey *fk)
It adds a foreign key constraint to a dataset.
virtual void addCheckConstraint(const std::string &datasetName, CheckConstraint *cc)
It adds a check constraint to the dataset.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
virtual bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
It describes a unique key (uk) constraint.
virtual std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
virtual bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
virtual std::auto_ptr< Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
virtual std::auto_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...
TraverseType
A dataset can be traversed in two ways:
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.
#define TR_DATAACCESS(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
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 void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
A class that models the description of a 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 std::auto_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::auto_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
virtual void addUniqueKey(const std::string &datasetName, UniqueKey *uk)
It adds a unique key constraint to the dataset.
It models a property definition.
virtual std::auto_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 std::auto_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...
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::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
virtual std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
virtual void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
virtual std::auto_ptr< ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
A class that describes a check constraint.
An Envelope defines a 2D rectangular region.
It represents the system catalog of a DataSource.
virtual std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
virtual bool hasDataSets()
It checks if the data source has any dataset.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
virtual std::auto_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.
A dataset is the unit of information manipulated by the data access module of TerraLib.
virtual std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
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 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 addIndex(const std::string &datasetName, Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
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.