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" 48 m_uri(
te::core::URI(connInfo))
80 return t->getDataSet(name, travType,
isConnected(), accessPolicy);
84 const std::string& propertyName,
91 return t->getDataSet(name, propertyName, e, r, travType,
isConnected(), accessPolicy);
95 const std::string& propertyName,
102 return t->getDataSet(name, propertyName, g, r, travType,
isConnected(), accessPolicy);
111 return t->getDataSet(name, oids, travType,
isConnected(), accessPolicy);
118 return t->query(q, travType,
false,accessPolicy);
125 return t->query(query, travType,
false,accessPolicy);
131 return t->execute(command);
137 return t->execute(command);
143 return t->escape(value);
149 return t->isDataSetNameValid(datasetName);
155 return t->isPropertyNameValid(propertyName);
161 return t->getDataSetNames();
167 return t->getNumberOfDataSets();
173 return t->getDataSetType(name);
179 return t->getCapabilities(name);
185 return t->getProperties(datasetName);
191 return t->getPropertyNames(datasetName);
197 return t->getNumberOfProperties(datasetName);
203 return t->propertyExists(datasetName, name);
209 return t->getProperty(datasetName, name);
215 return t->getProperty(datasetName, propertyPos);
221 return t->addProperty(datasetName, p);
227 return t->dropProperty(datasetName, name);
231 const std::string& propertyName,
232 const std::string& newPropertyName)
235 return t->renameProperty(datasetName, propertyName, newPropertyName);
241 return t->changePropertyDefinition(datasetName, propName, newProp);
246 assert(propsNames.size() == newProps.size());
248 for(std::size_t i = 0; i < propsNames.size(); ++i)
255 return t->getPrimaryKey(datasetName);
261 return t->primaryKeyExists(datasetName, name);
267 return t->addPrimaryKey(datasetName, pk);
273 return t->dropPrimaryKey(datasetName);
279 return t->getForeignKey(datasetName, name);
285 return t->getForeignKeyNames(datasetName);
291 return t->foreignKeyExists(datasetName, name);
297 return t->addForeignKey(datasetName, fk);
303 return t->dropForeignKey(datasetName, fkName);
307 const std::string& name)
310 return t->getUniqueKey(datasetName, name);
316 return t->getUniqueKeyNames(datasetName);
322 return t->uniqueKeyExists(datasetName, name);
328 return t->addUniqueKey(datasetName, uk);
334 return t->dropUniqueKey(datasetName, name);
338 const std::string& name)
341 return t->getCheckConstraint(datasetName, name);
347 return t->getCheckConstraintNames(datasetName);
353 return t->checkConstraintExists(datasetName, name);
359 return t->addCheckConstraint(datasetName, cc);
365 return t->dropCheckConstraint(datasetName, name);
371 return t->getIndex(datasetName, name);
377 return t->getIndexNames(datasetName);
383 return t->indexExists(datasetName, name);
387 const std::map<std::string, std::string>& options)
390 return t->addIndex(datasetName, idx, options);
396 return t->dropIndex(datasetName, idxName);
402 return t->getSequence(name);
408 return t->getSequenceNames();
414 return t->sequenceExists(name);
420 return t->addSequence(sequence);
426 return t->dropSequence(name);
432 return t->getExtent(datasetName, propertyName);
438 return t->getExtent(datasetName, propertyPos);
444 return t->getNumberOfItems(datasetName);
450 return t->hasDataSets();
456 return t->dataSetExists(name);
462 return t->createDataSet(dt, options);
466 const std::string& cloneName,
467 const std::map<std::string, std::string>& options)
470 return t->cloneDataSet(name, cloneName, options);
476 return t->dropDataSet(name);
482 return t->renameDataSet(name, newName);
487 const std::map<std::string, std::string>& options,
491 return t->add(datasetName, d, options, limit);
497 return t->remove(datasetName, oids);
502 const std::vector<std::size_t>& properties,
504 const std::map<std::string, std::string>& options,
508 return t->update(datasetName, dataset, properties, oids, options, limit);
512 const std::vector<size_t>& ids)
515 return t->update(datasetName, dataset, properties, ids);
532 if(ds.get() ==
nullptr)
533 throw Exception(
TE_TR(
"Could not find the appropriate factory to create a data source instance!"));
535 ds->create(connInfo);
544 if(ds.get() ==
nullptr)
545 throw Exception(
TE_TR(
"Could not find the appropriate factory to create a data source instance!"));
554 if(ds.get() ==
nullptr)
555 throw Exception(
TE_TR(
"Could not find the appropriate factory in order to create a data source instance!"));
557 return ds->exists(connInfo);
564 if(ds.get() ==
nullptr)
565 throw Exception(
TE_TR(
"Could not find the appropriate factory to create a data source instance!"));
567 return ds->getDataSourceNames(connInfo);
582 return t->getGeometryTypeName(type);
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.
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.
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.
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.
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...
virtual void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the given dataset.
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.
It models a foreign key constraint for a DataSetType.
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.
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.
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).
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.
DataSource(const std::string &connInfo)
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.
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.
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.