te::da::DataAccess Class Reference

Class used to centralize and control access to data in terralib. It aims to create a high-level interface for simplifying the concepts defined in the terralib DataAccess module. More...

#include <DataAccess.h>

Inheritance diagram for te::da::DataAccess:
te::dt::AbstractData

Public Member Functions

void beginTransaction ()
 Commits a transaction. More...
 
virtual te::dt::AbstractDataclone () const override
 Begins a transaction. More...
 
void commitTransaction ()
 Rollbacks the transaction. More...
 
void createDataSet (te::da::DataSetType *dataSetType)
 Function used to create a new DataSet into internal datasource. This class will NOT take the ownership of the dataSetType pointer. More...
 
 DataAccess (const te::core::URI &uri, const std::string &dataSourceDriver, const std::string &dataSetName="")
 constructor. More...
 
 DataAccess (const te::da::DataAccess &rhs)
 
 DataAccess (te::da::DataSourcePtr dataSource, const std::string &dataSetName="")
 Constructor. More...
 
 DataAccess (te::da::DataSourcePtr dataSource, const te::da::DataSetType *dataSetType)
 constructor. More...
 
bool dataSetExists () const
 
void execute (const std::string &query)
 Executes the given sql in the current transactor. More...
 
void flush ()
 
te::da::DataSetTypeConvertergetConverter () const
 Get data set type. More...
 
std::unique_ptr< te::da::DataSetgetDataSet () const
 Get dataset using internal information (data source, query, datasetTypeConverter) More...
 
std::unique_ptr< te::da::DataSetgetDataSet (const te::da::Expression *filter) const
 Get dataset using internal information (data source, query, datasetTypeConverter), using the given filter. More...
 
std::string getDataSetName () const
 Get data set name. More...
 
const te::da::DataSetTypegetDataSetType () const
 Get data set type. More...
 
te::da::DataSourcePtr getDataSource () const
 Get the data source associated with this data access. More...
 
std::string getDataSourceConnectionInfo () const
 Get data source connection info. More...
 
std::vector< std::string > getDistinctValues (const std::string &attributeName)
 Function used to get distinct values ir order, from a specific attribute. More...
 
te::da::LiteralgetLiteral (const std::string &attributeName, const std::string &value)
 It creates a Literal Expression based on a attribute type. More...
 
te::gm::Envelope getMBR () const
 Gets the MBR of the data access. More...
 
te::da::SelectgetQuery () const
 Get query object. More...
 
int getSRID () const
 Gets the SRID of the data access. More...
 
std::string getStrQuery () const
 Get query object as string. More...
 
te::da::DataSourceTransactorPtr getTransactor () const
 Sets he transactor to be used. More...
 
virtual int getTypeCode () const override
 It returns the data type code associated to the data value. More...
 
std::unique_ptr< te::da::DataSetquery (const std::string &query)
 
std::unique_ptr< te::da::DataSetquery (const te::da::Select &select)
 Get dataset using internal information (data source, datasetTypeConverter), but using query parameter for data restriction. More...
 
void rollbackTransaction ()
 When handling with files, specially using OGR, the olnly way to ensure the data is writen tis to close dataSource. So this functions encapsulates it. More...
 
void saveDataSet (te::da::DataSet *dataSet, bool enableProgress=true)
 Function used to save data into internal datasource (if a converter was defined, it will be used) More...
 
void setConverter (te::da::DataSetTypeConverter *converter)
 Set data set converter type. More...
 
void setObjectIdSetFilter (const te::da::ObjectIdSet *objectIdSetFilter)
 Gets the current transactor. If no transactor is defined, it creates one. More...
 
void setQuery (te::da::Select *select)
 Set data set restriction. More...
 
void setTransactor (te::da::DataSourceTransactorPtr transactor)
 
virtual std::string toString () const override
 Check if the the dataSet exists. More...
 
virtual ~DataAccess ()
 Default destructor. More...
 

Protected Attributes

std::string m_dataSetName
 Dataset name. More...
 
std::unique_ptr< te::da::Selectm_dataSetQuery
 Filter used to load data with restriction. More...
 
std::unique_ptr< te::da::DataSetTypem_dataSetType
 Data set type. More...
 
std::unique_ptr< te::da::DataSetTypeConverterm_dataSetTypeConverter
 DataSetType Converter. More...
 
te::da::DataSourcePtr m_dataSource
 Data source. More...
 
std::unique_ptr< te::da::ObjectIdSetm_objectIdSetFilter
 A optional filter containg an objectId set. More...
 
te::da::DataSourceTransactorPtr m_transactor
 Transactor. More...
 

Detailed Description

Class used to centralize and control access to data in terralib. It aims to create a high-level interface for simplifying the concepts defined in the terralib DataAccess module.

Definition at line 76 of file DataAccess.h.

Constructor & Destructor Documentation

◆ DataAccess() [1/4]

te::da::DataAccess::DataAccess ( const te::core::URI uri,
const std::string &  dataSourceDriver,
const std::string &  dataSetName = "" 
)

constructor.

Parameters
uriThe URI used to describe the datasource connection.
dataSourceDriverThe data source type name (example: POSTGIS, ORACLE, SQLITE).
dataSetNameThe dataset name (not needed to inform if DataAccess will be used to create a new Dataset)
Exceptions
ExceptionAn exception can be thrown, if the data source cannot be created or opened and dataset not found.
Note
A data source will be created without id information

◆ DataAccess() [2/4]

te::da::DataAccess::DataAccess ( te::da::DataSourcePtr  dataSource,
const std::string &  dataSetName = "" 
)

Constructor.

Parameters
dataSourceThe data source pointer.
dataSetNameThe dataset name (not needed to inform if DataAccess will be used to create a new Dataset)
Exceptions
ExceptionAn exception can be thrown, if the data source cannot be opened or dataset not found.
Note
This class will take the ownership of data source pointer

◆ DataAccess() [3/4]

te::da::DataAccess::DataAccess ( te::da::DataSourcePtr  dataSource,
const te::da::DataSetType dataSetType 
)

constructor.

Parameters
dataSourceThe data source pointer.
dataSetTypeThe dataset type
Exceptions
ExceptionAn exception can be thrown, if the data source cannot be opened or dataset not found.
Note
This class will take the ownership of data source pointer, but will clone the received dataSetType Copy constructor

◆ DataAccess() [4/4]

te::da::DataAccess::DataAccess ( const te::da::DataAccess rhs)

◆ ~DataAccess()

virtual te::da::DataAccess::~DataAccess ( )
virtual

Default destructor.

Member Function Documentation

◆ beginTransaction()

void te::da::DataAccess::beginTransaction ( )

Commits a transaction.

◆ clone()

virtual te::dt::AbstractData* te::da::DataAccess::clone ( ) const
overridevirtual

Begins a transaction.

Implements te::dt::AbstractData.

◆ commitTransaction()

void te::da::DataAccess::commitTransaction ( )

Rollbacks the transaction.

◆ createDataSet()

void te::da::DataAccess::createDataSet ( te::da::DataSetType dataSetType)

Function used to create a new DataSet into internal datasource. This class will NOT take the ownership of the dataSetType pointer.

Parameters
dataSetPointer to a data set type to be created

◆ dataSetExists()

bool te::da::DataAccess::dataSetExists ( ) const

◆ execute()

void te::da::DataAccess::execute ( const std::string &  query)

Executes the given sql in the current transactor.

◆ flush()

void te::da::DataAccess::flush ( )

◆ getConverter()

te::da::DataSetTypeConverter* te::da::DataAccess::getConverter ( ) const

Get data set type.

Returns
Pointer to the datasettype
Note
The caller of this method will NOT take the ownership of the given pointer

◆ getDataSet() [1/2]

std::unique_ptr<te::da::DataSet> te::da::DataAccess::getDataSet ( ) const

Get dataset using internal information (data source, query, datasetTypeConverter)

Returns
DataSet object

◆ getDataSet() [2/2]

std::unique_ptr<te::da::DataSet> te::da::DataAccess::getDataSet ( const te::da::Expression filter) const

Get dataset using internal information (data source, query, datasetTypeConverter), using the given filter.

Returns
DataSet object

◆ getDataSetName()

std::string te::da::DataAccess::getDataSetName ( ) const

Get data set name.

Returns
String with the new data set name

◆ getDataSetType()

const te::da::DataSetType* te::da::DataAccess::getDataSetType ( ) const

Get data set type.

Returns
Pointer to the datasettype
Note
The caller of this method will NOT take the ownership of the given pointer

◆ getDataSource()

te::da::DataSourcePtr te::da::DataAccess::getDataSource ( ) const

Get the data source associated with this data access.

Returns
The data source associated with this data access

◆ getDataSourceConnectionInfo()

std::string te::da::DataAccess::getDataSourceConnectionInfo ( ) const

Get data source connection info.

Returns
String with data source connection info

◆ getDistinctValues()

std::vector<std::string> te::da::DataAccess::getDistinctValues ( const std::string &  attributeName)

Function used to get distinct values ir order, from a specific attribute.

Parameters
attributeNameString with attribute name
Returns
A vector with all distinct values from a attribute in order.

◆ getLiteral()

te::da::Literal* te::da::DataAccess::getLiteral ( const std::string &  attributeName,
const std::string &  value 
)

It creates a Literal Expression based on a attribute type.

Parameters
attributeNameAttribute name from data set
valueAttribute value used to create the right Literal expression
Returns
Valid pointer if the attribute type is supported and a null pointer in other case

◆ getMBR()

te::gm::Envelope te::da::DataAccess::getMBR ( ) const

Gets the MBR of the data access.

Returns
The MBR of the data access

◆ getQuery()

te::da::Select* te::da::DataAccess::getQuery ( ) const

Get query object.

Returns
Pointer to the query object
Note
The caller of this method will NOT take the ownership of the given pointer

◆ getSRID()

int te::da::DataAccess::getSRID ( ) const

Gets the SRID of the data access.

Returns
The SRID of the data access The the objectId set to be used as a filter

◆ getStrQuery()

std::string te::da::DataAccess::getStrQuery ( ) const

Get query object as string.

Returns
String with the query restriction.

◆ getTransactor()

te::da::DataSourceTransactorPtr te::da::DataAccess::getTransactor ( ) const

Sets he transactor to be used.

◆ getTypeCode()

virtual int te::da::DataAccess::getTypeCode ( ) const
overridevirtual

It returns the data type code associated to the data value.

Returns
The data type code associated to the data value.

Implements te::dt::AbstractData.

◆ query() [1/2]

std::unique_ptr<te::da::DataSet> te::da::DataAccess::query ( const std::string &  query)

◆ query() [2/2]

std::unique_ptr<te::da::DataSet> te::da::DataAccess::query ( const te::da::Select select)

Get dataset using internal information (data source, datasetTypeConverter), but using query parameter for data restriction.

Parameters
selectSelect object that defines the data filter information.
Returns
DataSet object

◆ rollbackTransaction()

void te::da::DataAccess::rollbackTransaction ( )

When handling with files, specially using OGR, the olnly way to ensure the data is writen tis to close dataSource. So this functions encapsulates it.

◆ saveDataSet()

void te::da::DataAccess::saveDataSet ( te::da::DataSet dataSet,
bool  enableProgress = true 
)

Function used to save data into internal datasource (if a converter was defined, it will be used)

Parameters
dataSetPointer to a data set to be saved
Note
DataAccess will take the ownership of dataset and erase the data at end

◆ setConverter()

void te::da::DataAccess::setConverter ( te::da::DataSetTypeConverter converter)

Set data set converter type.

Parameters
converterThe data set type converter pointer
Note
This class will take the ownership of converter pointer

◆ setObjectIdSetFilter()

void te::da::DataAccess::setObjectIdSetFilter ( const te::da::ObjectIdSet objectIdSetFilter)

Gets the current transactor. If no transactor is defined, it creates one.

◆ setQuery()

void te::da::DataAccess::setQuery ( te::da::Select select)

Set data set restriction.

Parameters
selectThe data set query pointer
Note
This class will take the ownership of query pointer

◆ setTransactor()

void te::da::DataAccess::setTransactor ( te::da::DataSourceTransactorPtr  transactor)

◆ toString()

virtual std::string te::da::DataAccess::toString ( ) const
overridevirtual

Check if the the dataSet exists.

Implements te::dt::AbstractData.

Member Data Documentation

◆ m_dataSetName

std::string te::da::DataAccess::m_dataSetName
protected

Dataset name.

Definition at line 313 of file DataAccess.h.

◆ m_dataSetQuery

std::unique_ptr<te::da::Select> te::da::DataAccess::m_dataSetQuery
protected

Filter used to load data with restriction.

Definition at line 312 of file DataAccess.h.

◆ m_dataSetType

std::unique_ptr<te::da::DataSetType> te::da::DataAccess::m_dataSetType
protected

Data set type.

Definition at line 310 of file DataAccess.h.

◆ m_dataSetTypeConverter

std::unique_ptr<te::da::DataSetTypeConverter> te::da::DataAccess::m_dataSetTypeConverter
protected

DataSetType Converter.

Definition at line 311 of file DataAccess.h.

◆ m_dataSource

te::da::DataSourcePtr te::da::DataAccess::m_dataSource
protected

Data source.

Definition at line 308 of file DataAccess.h.

◆ m_objectIdSetFilter

std::unique_ptr<te::da::ObjectIdSet> te::da::DataAccess::m_objectIdSetFilter
protected

A optional filter containg an objectId set.

Definition at line 314 of file DataAccess.h.

◆ m_transactor

te::da::DataSourceTransactorPtr te::da::DataAccess::m_transactor
mutableprotected

Transactor.

Definition at line 309 of file DataAccess.h.


The documentation for this class was generated from the following file: