26#ifndef __TERRALIB_DATAACCESS_INTERNAL_DATASOURCETRANSACTOR_H
27#define __TERRALIB_DATAACCESS_INTERNAL_DATASOURCETRANSACTOR_H
30#include "../../common/Enums.h"
31#include "../../geometry/Enums.h"
32#include "../dataset/CheckConstraint.h"
33#include "../dataset/DataSetType.h"
34#include "../dataset/DataSet.h"
35#include "../dataset/ForeignKey.h"
36#include "../dataset/Index.h"
37#include "../dataset/PrimaryKey.h"
38#include "../dataset/Sequence.h"
39#include "../dataset/UniqueKey.h"
52#include <boost/ptr_container/ptr_vector.hpp>
53#include <boost/cstdint.hpp>
54#include <boost/noncopyable.hpp>
55#include <boost/shared_ptr.hpp>
61 namespace dt {
class Property; }
62 namespace gm {
class Envelope;
class Geometry; }
67 class DataSetTypeCapabilities;
167 virtual std::unique_ptr<DataSet>
getDataSet(
const std::string& name,
169 bool connected =
false,
198 virtual std::unique_ptr<DataSet>
getDataSet(
const std::string& name,
199 const std::string& propertyName,
203 bool connected =
false,
232 virtual std::unique_ptr<DataSet>
getDataSet(
const std::string& name,
233 const std::string& propertyName,
237 bool connected =
false,
260 std::unique_ptr<te::da::DataSet>
getDataSet(
const std::string& name,
263 bool connected =
false,
292 bool connected =
false,
318 virtual std::unique_ptr<DataSet>
query(
const std::string& query,
320 bool connected =
false,
350 virtual void execute(
const std::string& command) = 0;
366 virtual std::unique_ptr<PreparedQuery>
getPrepared(
const std::string& qName = std::string(
"")) = 0;
410 virtual std::string
escape(
const std::string& value) = 0;
486 virtual std::unique_ptr<te::da::DataSetType>
getDataSetType(
const std::string& name) = 0;
497 virtual std::unique_ptr<te::da::DataSetTypeCapabilities>
getCapabilities(
const std::string& name);
510 virtual boost::ptr_vector<te::dt::Property>
getProperties(
const std::string& datasetName) = 0;
524 virtual std::unique_ptr<te::dt::Property>
getProperty(
const std::string& datasetName,
const std::string& name) = 0;
538 virtual std::unique_ptr<te::dt::Property>
getProperty(
const std::string& datasetName, std::size_t propertyPos) = 0;
581 virtual bool propertyExists(
const std::string& datasetName,
const std::string& name) = 0;
606 virtual void dropProperty(
const std::string& datasetName,
const std::string& name) = 0;
620 const std::string& propertyName,
621 const std::string& newPropertyName) = 0;
636 virtual std::unique_ptr<te::da::PrimaryKey>
getPrimaryKey(
const std::string& datasetName) = 0;
650 virtual bool primaryKeyExists(
const std::string& datasetName,
const std::string& name) = 0;
688 virtual std::unique_ptr<ForeignKey>
getForeignKey(
const std::string& datasetName,
const std::string& name) = 0;
713 virtual bool foreignKeyExists(
const std::string& datasetName,
const std::string& name) = 0;
738 virtual void dropForeignKey(
const std::string& datasetName,
const std::string& fkName) = 0;
752 virtual std::unique_ptr<te::da::UniqueKey>
getUniqueKey(
const std::string& datasetName,
const std::string& name) = 0;
779 virtual bool uniqueKeyExists(
const std::string& datasetName,
const std::string& name) = 0;
804 virtual void dropUniqueKey(
const std::string& datasetName,
const std::string& name) = 0;
818 virtual std::unique_ptr<te::da::CheckConstraint>
getCheckConstraint(
const std::string& datasetName,
const std::string& name) = 0;
884 virtual std::unique_ptr<te::da::Index>
getIndex(
const std::string& datasetName,
const std::string& name) = 0;
897 virtual std::vector<std::string>
getIndexNames(
const std::string& datasetName) = 0;
911 virtual bool indexExists(
const std::string& datasetName,
const std::string& name) = 0;
926 const std::map<std::string, std::string>& options) = 0;
938 virtual void dropIndex(
const std::string& datasetName,
const std::string& idxName) = 0;
951 virtual std::unique_ptr<Sequence>
getSequence(
const std::string& name) = 0;
1013 virtual std::unique_ptr<te::gm::Envelope>
getExtent(
const std::string& datasetName,
1014 const std::string& propertyName) = 0;
1028 virtual std::unique_ptr<te::gm::Envelope>
getExtent(
const std::string& datasetName,
1029 std::size_t propertyPos) = 0;
1120 const std::string& cloneName,
1121 const std::map<std::string, std::string>& options) = 0;
1144 virtual void renameDataSet(
const std::string& name,
const std::string& newName) = 0;
1169 virtual void add(
const std::string& datasetName,
1171 const std::map<std::string, std::string>& options,
1172 std::size_t limit = 0,
1173 bool enableProgress =
true) = 0;
1208 virtual void update(
const std::string& datasetName,
1210 const std::vector<std::size_t>& properties,
1212 const std::map<std::string, std::string>& options,
1213 std::size_t limit = 0) = 0;
1227 virtual void update(
const std::string& datasetName,
1229 const std::vector< std::set<int> >& properties,
1230 const std::vector<size_t>& ids);
1247 virtual void optimize(
const std::map<std::string, std::string>& opInfo) = 0;
A class that models an object that submits commands in batch to the data source.
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 DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
virtual void addForeignKey(const std::string &datasetName, ForeignKey *fk)=0
It adds a foreign key constraint to a dataset.
virtual void addPrimaryKey(const std::string &datasetName, PrimaryKey *pk)=0
It adds a primary key constraint to the dataset schema.
virtual std::vector< std::string > getSequenceNames()=0
It gets the sequence names available in the data source.
virtual std::string getGeometryTypeName(te::gm::GeomType type)
It gets the datasource geometry type name equivalent to terralib.
virtual void cloneDataSet(const std::string &name, const std::string &cloneName, const std::map< std::string, std::string > &options)=0
It clones the dataset in the data source.
virtual void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)=0
It renames a property of the given dataset.
virtual DataSource * getDataSource() const =0
It returns the parent data source of the transactor.
virtual void cancel()=0
It requests that the data source stop the processing of the current command.
virtual void optimize(const std::map< std::string, std::string > &opInfo)=0
For some data access drivers, this method will perform some operations to optimize the data storage.
virtual std::unique_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName)=0
It retrieves the bounding rectangle of the spatial property for the given dataset.
virtual boost::int64_t getLastGeneratedId()=0
It returns the last id generated by an insertion command.
virtual std::unique_ptr< DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)=0
It gets the dataset identified by the given name. A dataset can be connected or disconnected....
virtual void addSequence(Sequence *sequence)=0
It creates a new sequence in the data source.
virtual void addIndex(const std::string &datasetName, Index *idx, const std::map< std::string, std::string > &options)=0
It adds an index to the dataset.
virtual void execute(const Query &command)=0
It executes the specified command using a generic query representation.
virtual std::size_t getNumberOfDataSets()=0
It retrieves the number of data sets available in the data source.
virtual void execute(const std::string &command)=0
It executes the specifed command in the data source native language.
virtual void addUniqueKey(const std::string &datasetName, UniqueKey *uk)=0
It adds a unique key constraint to the dataset.
virtual std::unique_ptr< ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)=0
It retrieves the foreign key from the given dataset.
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, const ObjectIdSet *oids, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name using the set of objects identification....
virtual void addProperty(const std::string &datasetName, te::dt::Property *p)=0
It adds a new property to the dataset schema.
virtual std::unique_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)=0
It gets the index with the given name from the dataset.
virtual bool foreignKeyExists(const std::string &datasetName, const std::string &name)=0
It checks if a foreign key with the given name exists in the data source.
virtual void update(const std::string &datasetName, DataSet *dataset, const std::vector< std::size_t > &properties, const ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)=0
It updates the contents of a dataset for the set of data items.
virtual void dropUniqueKey(const std::string &datasetName, const std::string &name)=0
It removes the unique key constraint from the dataset.
virtual std::unique_ptr< te::dt::Property > getProperty(const std::string &datasetName, std::size_t propertyPos)=0
It retrieves the property lying in the given position from the dataset.
virtual std::unique_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)=0
It retrieves the property with the given name from the dataset.
virtual bool checkConstraintExists(const std::string &datasetName, const std::string &name)=0
It checks if a check-constraint with the given name exists in the data source.
virtual void dropForeignKey(const std::string &datasetName, const std::string &fkName)=0
It removes the foreign key constraint from the dataset schema.
virtual void add(const std::string &datasetName, DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0, bool enableProgress=true)=0
It adds data items to the dataset in the data source.
virtual void commit()=0
It commits the transaction.
virtual std::vector< std::string > getIndexNames(const std::string &datasetName)=0
It gets the index names of 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, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)=0
It gets the dataset identified by the given name using a spatial filter over the specified property....
virtual std::string escape(const std::string &value)=0
It escapes a string for using in commands and queries.
virtual std::unique_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name)=0
It gets the unique key in the dataset with the given name.
virtual std::size_t getNumberOfItems(const std::string &datasetName)=0
It retrieves the number of items of the given dataset.
virtual std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)=0
It retrieves the primary key of the dataset.
virtual bool propertyExists(const std::string &datasetName, const std::string &name)=0
It checks if a property with the given name exists in the dataset.
virtual boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)=0
It retrieves the properties of the dataset.
virtual void dropPrimaryKey(const std::string &datasetName)=0
It removes the primary key constraint from the dataset schema.
DataSourceTransactor()
Default constructor that can be called by subclasses.
virtual std::unique_ptr< DataSet > query(const Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)=0
It executes a query that may return some data using a generic query. A dataset can be connected or di...
virtual std::unique_ptr< BatchExecutor > getBatchExecutor()=0
It creates a batch command executor.
virtual void begin()=0
It starts a new transaction.
virtual std::vector< std::string > getForeignKeyNames(const std::string &datasetName)=0
It gets the foreign key names of the given dataset.
virtual ~DataSourceTransactor()
Virtual destructor.
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, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)=0
It gets the dataset identified by the given name using a spatial filter over the given geometric prop...
virtual bool sequenceExists(const std::string &name)=0
It checks if a sequence with the given name exists in the data source.
virtual void dropProperty(const std::string &datasetName, const std::string &name)=0
It removes a property from the given dataset.
virtual std::unique_ptr< DataSet > query(const std::string &query, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)=0
It executes a query that may return some data using the data source native language....
virtual void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
virtual void dropDataSet(const std::string &name)=0
It removes the dataset schema from the data source.
virtual bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
virtual bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
virtual void addCheckConstraint(const std::string &datasetName, CheckConstraint *cc)=0
It adds a check constraint to the dataset.
virtual std::vector< std::string > getPropertyNames(const std::string &datasetName)=0
It gets the property names of the given dataset.
virtual bool uniqueKeyExists(const std::string &datasetName, const std::string &name)=0
It checks if a unique key with the given name exists in the dataset.
virtual void renameDataSet(const std::string &name, const std::string &newName)=0
It renames a dataset.
virtual std::size_t getNumberOfProperties(const std::string &datasetName)=0
It gets the number of properties of the given dataset.
virtual void dropSequence(const std::string &name)=0
It removes the sequence from the data source.
virtual std::unique_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name)=0
It gets the check constraint of the dataset with the given name.
virtual std::unique_ptr< te::da::DataSetTypeCapabilities > getCapabilities(const std::string &name)
It gets capabilities about a data set.
virtual bool dataSetExists(const std::string &name)=0
It checks if a dataset with the given name exists in the data source.
virtual void dropCheckConstraint(const std::string &datasetName, const std::string &name)=0
It removes the check constraint from the dataset.
virtual std::unique_ptr< Sequence > getSequence(const std::string &name)=0
It gets the sequence with the given name in the data source.
virtual std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)=0
It gets information about the given dataset.
virtual std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)=0
It gets the check constraint names of the given dataset.
virtual std::vector< std::string > getDataSetNames()=0
It It gets the dataset names available in the data source.
virtual bool hasDataSets()=0
It checks if the data source has any dataset.
virtual void dropIndex(const std::string &datasetName, const std::string &idxName)=0
It removes the index from the dataset schema.
virtual void rollBack()=0
It aborts the transaction. Any changes will be rolled-back.
virtual void remove(const std::string &datasetName, const ObjectIdSet *oids=0)=0
It removes all the informed items from the dataset.
virtual bool isInTransaction() const =0
It returns true if a transaction is in progress, otherwise, it returns false.
virtual bool primaryKeyExists(const std::string &datasetName, const std::string &name)=0
It checks if a primary key exists in the dataset.
virtual void createDataSet(DataSetType *dt, const std::map< std::string, std::string > &options)=0
It creates the dataset schema definition in the target data source.
virtual bool indexExists(const std::string &datasetName, const std::string &name)=0
It checks if an index with the given name exists in the dataset.
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::vector< std::string > getUniqueKeyNames(const std::string &datasetName)=0
It gets the unique key names of the given dataset.
virtual std::unique_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, std::size_t propertyPos)=0
It retrieves the bounding rectangle for the spatial property lying in the given position in the datas...
virtual std::unique_ptr< PreparedQuery > getPrepared(const std::string &qName=std::string(""))=0
It creates a prepared query object that may be used for query commands (select, insert,...
An abstract class for data providers like a DBMS, Web Services or a regular file.
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.
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).
boost::shared_ptr< DataSourceTransactor > DataSourceTransactorPtr
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
SpatialRelation
Spatial relations between geometric objects.
A class that implements a prepared query for PostgreSQL data access driver.
#define TEDATAACCESSEXPORT
You can use this macro in order to export/import classes and functions from this module.