21 #include "../common/Translator.h"
30 #include <terralib4/kernel/TeDatabase.h>
31 #include <terralib4/kernel/TeDatabaseFactory.h>
32 #include <terralib4/kernel/TeDatabaseFactoryParams.h>
33 #include <terralib4/kernel/TeDBConnectionsPool.h>
34 #include <terralib4/kernel/TeDefines.h>
35 #include <terralib4/kernel/TeTheme.h>
36 #include <terralib4/utils/TeUpdateDBVersion.h>
67 std::auto_ptr<te::da::DataSourceTransactor> t(
new Transactor(
this, m_db));
75 std::string dbInfo = m_dbInfo.at(
"T4_DRIVER");
76 std::string auxDbName = m_dbInfo.at(
"T4_DB_NAME");
77 std::string hostName =
"";
78 std::string userName =
"";
79 std::string password =
"";
83 m_db = TeDBConnectionsPool::instance().getDatabase(dbInfo, auxDbName, hostName, userName,
84 password, portNumber);
86 if(!m_db->isConnected())
88 if(!m_db->connect(hostName, userName, password, auxDbName, portNumber))
89 throw te::da::Exception(
TE_TR(
"Could not connect to informed database!"));
93 if(needUpdateDB(m_db, DBver))
95 std::string dbVersion = TeDBVERSION;
97 if(isLowerVersion(dbVersion, DBver))
101 throw te::da::Exception(
TE_TR(
"Cannot connect to database because the version of Terraview is lower than the version of the database!"));
106 throw te::da::Exception(
TE_TR(
"The database must be converted to the model ") + dbVersion +
"! \n");
109 m_db->loadLayerSet();
110 m_db->loadViewSet(m_db->user());
131 return sm_capabilities;
141 throw Exception(
TE_TR(
"This driver is read-only!"));
146 throw Exception(
TE_TR(
"This driver is read-only!"));
151 std::vector<string> dbnames = getDataSourceNames(dsInfo);
153 return std::find(dbnames.begin(), dbnames.end(), dsInfo.at(
"T4_DB_NAME")) != dbnames.end();
160 std::auto_ptr<TeDatabase> db(TeDatabaseFactory::make(*params.get()));
162 std::vector<std::string> dbnames;
164 db->showDatabases(params->host_, params->user_, params->password_, dbnames, params->port_);
171 std::vector<te::common::CharEncoding> result;
184 std::vector<std::string> layers;
186 std::auto_ptr<te::da::DataSourceTransactor> t = getTransactor();
196 std::vector<std::string> tables;
198 std::auto_ptr<te::da::DataSourceTransactor> t = getTransactor();
208 std::vector<std::string> rasters;
210 std::auto_ptr<te::da::DataSourceTransactor> t = getTransactor();
220 std::vector<::terralib4::ThemeInfo> themes;
222 std::auto_ptr<te::da::DataSourceTransactor> t = getTransactor();
232 TeTheme* tl4Theme = 0;
234 std::auto_ptr<te::da::DataSourceTransactor> t = getTransactor();
244 std::auto_ptr<te::da::DataSourceTransactor> t = getTransactor();
std::vector< std::string > getTL4Rasters()
void create(const std::map< std::string, std::string > &dsInfo)
It creates a new data source.
void open()
It opens the data source and makes it ready for using.
DataSourceTransactor implementation for TerraLib 4.x API.
void drop(const std::map< std::string, std::string > &dsInfo)
It removes the data source with the connection information from a driver.
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
std::vector< std::string > getTL4Rasters()
It represents the SQL query dialect accepted by a given data source.
Implements the DataSource class for the TerraLib 4.x Data Access Driver.
static te::da::DataSourceCapabilities sm_capabilities
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
std::vector< std::string > getDataSourceNames(const std::map< std::string, std::string > &dsInfo)
It gets the data source names available in a driver.
#define TE_TR(message)
It marks a string in order to get translated.
std::vector< std::string > getTL4Tables()
Configuration flags for the TerraLib 4 driver.
bool isValid() const
It checks if the data source is valid (available for using).
The basic information about a Terralib 4.x Theme.
std::auto_ptr< TeDatabaseFactoryParams > Convert2T4DatabaseParams(const std::map< std::string, std::string > &dsInfo)
It converts a data source information to a TerraLib 4.x database params.
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
TeTheme * getTL4Theme(const ::terralib4::ThemeInfo &theme)
TeDatabase * getTerralib4Db()
std::auto_ptr< te::da::DataSourceTransactor > getTransactor()
It returns an object that can execute transactions in the context of a data source.
const std::map< std::string, std::string > & getConnectionInfo() const
It returns the set of parameters used to set up the access channel to the underlying repository...
std::vector< std::string > getTL4Tables()
std::vector< te::common::CharEncoding > getEncodings(const std::map< std::string, std::string > &dsInfo)
It gets the encodings for the data source.
std::vector<::terralib4::ThemeInfo > getTL4Themes()
static te::da::SQLDialect * sm_dialect
int getLayerSRID(const std::string &layerName)
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
int getLayerSRID(const std::string &layerName)
TeTheme * getTL4Theme(const ::terralib4::ThemeInfo &theme)
void close()
It closes the data source and clears all the resources used by its internal communication channel...
void setConnectionInfo(const std::map< std::string, std::string > &connInfo)
It sets the connection information to be used when connecting to the data source. ...
bool exists(const std::map< std::string, std::string > &dsInfo)
Check the existence of a data source in a driver.
std::vector< std::string > getTL4Layers()
#define TERRALIB4_DRIVER_IDENTIFIER
The Terralib 4 driver identifier string.
Utilitary functions for dealing with TerraLib 5 and 4.x conversion.
~DataSource()
Virtual destructor.
std::vector<::terralib4::ThemeInfo > getTL4Themes()
std::vector< std::string > getTL4Layers()