26#ifndef __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCE_H
27#define __TERRALIB_DATAACCESS_DATASOURCE_INTERNAL_DATASOURCE_H
30#include "../../common/Enums.h"
31#include "../../core/uri/URI.h"
32#include "../../geometry/Enums.h"
33#include "../dataset/CheckConstraint.h"
34#include "../dataset/DataSet.h"
35#include "../dataset/DataSetType.h"
36#include "../dataset/ForeignKey.h"
37#include "../dataset/Index.h"
38#include "../dataset/PrimaryKey.h"
39#include "../dataset/Sequence.h"
40#include "../dataset/UniqueKey.h"
51#include <boost/ptr_container/ptr_vector.hpp>
52#include <boost/cstdint.hpp>
53#include <boost/noncopyable.hpp>
54#include <boost/shared_ptr.hpp>
71 class DataSetTypeCapabilities;
72 class DataSourceCapabilities;
73 class DataSourceTransactor;
78 class CheckConstraint;
310 virtual std::unique_ptr<DataSet>
getDataSet(
const std::string& name,
337 virtual std::unique_ptr<DataSet>
getDataSet(
const std::string& name,
338 const std::string& propertyName,
361 virtual std::unique_ptr<DataSet>
getDataSet(
const std::string& name,
362 const std::string& propertyName,
387 std::unique_ptr<te::da::DataSet>
getDataSet(
const std::string& name,
437 virtual std::unique_ptr<DataSet>
query(
const std::string& query,
466 virtual void execute(
const std::string& command);
482 virtual std::string
escape(
const std::string& value);
557 virtual std::unique_ptr<te::da::DataSetType>
getDataSetType(
const std::string& name);
566 std::unique_ptr<te::da::DataSetTypeCapabilities>
getCapabilities(
const std::string& name);
579 virtual boost::ptr_vector<te::dt::Property>
getProperties(
const std::string& datasetName);
593 virtual std::unique_ptr<te::dt::Property>
getProperty(
const std::string& datasetName,
const std::string& name);
607 virtual std::unique_ptr<te::dt::Property>
getProperty(
const std::string& datasetName, std::size_t propertyPos);
650 virtual bool propertyExists(
const std::string& datasetName,
const std::string& name);
675 virtual void dropProperty(
const std::string& datasetName,
const std::string& name);
689 const std::string& propertyName,
690 const std::string& newPropertyName);
694 virtual void changePropertiesDefinitions(
const std::string& datasetName,
const std::vector<std::string>& propsNames,
const std::vector<te::dt::Property*> newProps);
707 virtual std::unique_ptr<te::da::PrimaryKey>
getPrimaryKey(
const std::string& datasetName);
759 virtual std::unique_ptr<ForeignKey>
getForeignKey(
const std::string& datasetName,
const std::string& name);
809 virtual void dropForeignKey(
const std::string& datasetName,
const std::string& fkName);
823 virtual std::unique_ptr<te::da::UniqueKey>
getUniqueKey(
const std::string& datasetName,
const std::string& name);
850 virtual bool uniqueKeyExists(
const std::string& datasetName,
const std::string& name);
875 virtual void dropUniqueKey(
const std::string& datasetName,
const std::string& name);
889 virtual std::unique_ptr<te::da::CheckConstraint>
getCheckConstraint(
const std::string& datasetName,
const std::string& name);
955 virtual std::unique_ptr<te::da::Index>
getIndex(
const std::string& datasetName,
const std::string& name);
968 virtual std::vector<std::string>
getIndexNames(
const std::string& datasetName);
982 virtual bool indexExists(
const std::string& datasetName,
const std::string& name);
997 const std::map<std::string, std::string>& options);
1009 virtual void dropIndex(
const std::string& datasetName,
const std::string& idxName);
1022 virtual std::unique_ptr<Sequence>
getSequence(
const std::string& name);
1084 virtual std::unique_ptr<te::gm::Envelope>
getExtent(
const std::string& datasetName,
1085 const std::string& propertyName);
1099 virtual std::unique_ptr<te::gm::Envelope>
getExtent(
const std::string& datasetName, std::size_t propertyPos);
1190 const std::string& cloneName,
1191 const std::map<std::string, std::string>& options);
1214 virtual void renameDataSet(
const std::string& name,
const std::string& newName);
1238 virtual void add(
const std::string& datasetName,
1240 const std::map<std::string, std::string>& options,
1241 std::size_t limit = 0);
1276 virtual void update(
const std::string& datasetName,
1278 const std::vector<std::size_t>& properties,
1280 const std::map<std::string, std::string>& options,
1281 std::size_t limit = 0);
1295 virtual void update(
const std::string& datasetName,
1297 const std::vector< std::set<int> >& properties,
1298 const std::vector<size_t>& ids);
1336 static std::unique_ptr<DataSource>
create(
const std::string& dsType,
const std::string& connInfo);
1352 static void drop(
const std::string& dsType,
const std::string& connInfo);
1366 static bool exists(
const std::string& dsType,
const std::string& connInfo);
1380 static std::vector<std::string>
getDataSourceNames(
const std::string& dsType,
const std::string& connInfo);
1400 virtual void create(
const std::string& connInfo) = 0;
1411 virtual void drop(
const std::string& connInfo) = 0;
1424 virtual bool exists(
const std::string& connInfo) = 0;
A class to store the proxy information that must be used to access data located in URIs.
A class that describes a check constraint.
A class that models the description of a dataset.
A dataset is the unit of information manipulated by the data access module of TerraLib.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
An abstract class for data providers like a DBMS, Web Services or a regular file.
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, const te::da::ObjectIdSet *oids, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name using the identification of the objects....
virtual void setEncoding(const te::core::EncodingType &et)
It sets the encodings for the data source.
virtual void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
virtual void create(const std::string &connInfo)=0
It creates a new data source.
virtual void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
DataSource(const std::string &connInfo)
virtual void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
virtual boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
virtual void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
virtual std::string getGeometryTypeName(te::gm::GeomType type)
It gets the datasource geometry type name equivalent to terralib.
virtual void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
virtual bool hasDataSets()
It checks if the data source has any 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 std::unique_ptr< DataSourceTransactor > getTransactor()=0
It returns the set of parameters used to set up the access channel to the underlying repository.
virtual void execute(const Query &command)
It executes the specified command using a generic query representation.
virtual void update(const std::string &datasetName, DataSet *dataset, const std::vector< std::set< int > > &properties, const std::vector< size_t > &ids)
It updates the contents of a dataset.
virtual std::unique_ptr< Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
virtual bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
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 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...
virtual bool isDataSetNameValid(const std::string &datasetName)
It checks if the given dataset name is valid.
virtual bool isValid() const =0
It checks if the data source is valid (available for using).
virtual std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
virtual void addUniqueKey(const std::string &datasetName, UniqueKey *uk)
It adds a unique key constraint to the dataset.
virtual ~DataSource()
Virtual destructor.
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::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
DataSource(const te::core::URI &uri)
Default constructor that can be called by subclasses.
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 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 void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
virtual te::core::EncodingType getEncoding()
It return the DataSource current encoding.
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.
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 bool isOpened() const =0
It returns true if the data source is opened, otherwise it returns false.
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 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 sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
virtual 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...
virtual void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the 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.
virtual void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
const te::core::URI & getConnectionInfo() const
An Uniform Resource Identifier used to describe the datasource connection.
virtual void drop(const std::string &connInfo)=0
It removes the data source with the connection information from a driver.
virtual bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
virtual void addSequence(Sequence *sequence)
It adds a new sequence in the data source.
virtual void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
virtual std::string getType() const =0
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS,...
te::core::URI m_uri
The URI used to describe the datasource connection;.
virtual std::unique_ptr< ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
virtual 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.
std::string m_id
The data source identification.
virtual std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
virtual void dropSequence(const std::string &name)
It removes the sequence from the data source.
virtual void changePropertiesDefinitions(const std::string &datasetName, const std::vector< std::string > &propsNames, const std::vector< te::dt::Property * > newProps)
virtual void close()=0
It closes the data source and clears all the resources used by its internal communication channel.
virtual bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
const std::string & getId() const
An identification value for the data source.
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 std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
virtual void addCheckConstraint(const std::string &datasetName, CheckConstraint *cc)
It adds a check constraint to the dataset.
virtual bool exists(const std::string &connInfo)=0
Check the existence of a data source in a driver.
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.
virtual void execute(const std::string &command)
It executes the specified command in the data source native language.
virtual void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
std::unique_ptr< te::da::DataSetTypeCapabilities > getCapabilities(const std::string &name)
It gets capabilities about a data set.
virtual std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
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.
virtual std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
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::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 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.
virtual std::unique_ptr< 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, 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...
virtual std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
virtual std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given 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.
static std::unique_ptr< DataSource > create(const std::string &dsType, const std::string &connInfo)
It creates a new repository for a data source.
virtual void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the given dataset.
virtual std::unique_ptr< 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, 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....
virtual std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
virtual void addPrimaryKey(const std::string &datasetName, PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
virtual std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
virtual std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
virtual std::vector< std::string > getSequenceNames()
It gets the sequence names available in 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.
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.
virtual void addForeignKey(const std::string &datasetName, ForeignKey *fk)
It adds a foreign key constraint to a 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 std::vector< std::string > getDataSourceNames(const std::string &connInfo)=0
It gets the data source names available in a driver.
virtual void open()=0
It opens the data source and makes it ready for using.
virtual std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
virtual std::unique_ptr< DataSet > query(const std::string &query, 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 the data source native language....
void setId(const std::string &id)
It sets the data source identification.
virtual const SQLDialect * getDialect() const =0
It returns the data source SQL dialect, if there is one.
It models a foreign key constraint for a DataSetType.
It describes an index associated to a DataSetType.
This class represents a set of unique ids created in the same context. i.e. from the same data set.
It describes a primary key (pk) constraint.
A Query is independent from the data source language/dialect.
It represents the SQL query dialect accepted by a given data source.
A Select models a query to be used when retrieving data from a DataSource.
It describes a sequence (a number generator).
It describes a unique key (uk) constraint.
It models a property definition.
An Envelope defines a 2D rectangular region.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
TraverseType
A dataset can be traversed in two ways:
AccessPolicy
Supported data access policies (can be used as bitfield).
EncodingType
Supported character encodings.
boost::shared_ptr< DataSource > DataSourcePtr
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
SpatialRelation
Spatial relations between geometric objects.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.