27 #include "../common/Exception.h"
28 #include "../common/Translator.h"
29 #include "../dataaccess/datasource/DataSourceTransactor.h"
30 #include "../dataaccess/query/SQLDialect.h"
31 #include "../datatype/StringProperty.h"
45 #include <boost/filesystem.hpp>
46 #include <boost/format.hpp>
47 #include <boost/lexical_cast.hpp>
78 m_connInfo = connInfo;
95 loadGeometryColumnsCache(conn->getConn());
128 return m_geomColumns;
132 const std::string& geomColName)
134 boost::lock_guard<boost::mutex> lock(m_mtx);
136 m_geomColumns[datasetName] = geomColName;
140 const std::string& colName)
const
142 boost::lock_guard<boost::mutex> lock(m_mtx);
144 std::map<std::string, std::string>::const_iterator it = m_geomColumns.find(datasetName);
146 if(it != m_geomColumns.end())
147 return it->second == colName;
159 ADOX::_CatalogPtr pCatalog = 0;
161 pCatalog.CreateInstance(__uuidof(ADOX::Catalog));
165 pCatalog->Create(connInfo.c_str());
172 std::map<std::string, std::string>::const_iterator it = dsInfo.find(
"CREATE_OGC_METADATA_TABLES");
173 std::map<std::string, std::string>::const_iterator it_end = dsInfo.end();
175 if(it != it_end && it->second ==
"TRUE")
188 std::map<std::string, std::string> op;
190 createDataSet(geomColsDt, op);
201 std::map<std::string, std::string> info = dsInfo;
203 boost::filesystem::path path(info[
"DB_NAME"]);
205 if(boost::filesystem::remove(path) ==
false)
211 std::map<std::string, std::string> info = dsInfo;
213 boost::filesystem::path path(info[
"DB_NAME"]);
215 return boost::filesystem::exists(path);
220 return std::vector<std::string>();
225 return std::vector<te::common::CharEncoding>();
230 boost::lock_guard<boost::mutex> lock(m_mtx);
232 m_geomColumns.clear();
234 _RecordsetPtr recordset;
236 TESTHR(recordset.CreateInstance(__uuidof(Recordset)));
238 std::string query =
"SELECT * FROM geometry_columns";
242 recordset->Open(query.c_str(), _variant_t((IDispatch *)adoConn), adOpenDynamic, adLockReadOnly, adCmdText);
244 while(!recordset->EndOfFile)
246 std::string tablename = (LPCSTR)(_bstr_t)recordset->GetFields()->GetItem(
"f_table_name")->GetValue();
248 std::string columnName = (LPCSTR)(_bstr_t)recordset->GetFields()->GetItem(
"f_geometry_column")->GetValue();
250 m_geomColumns[tablename] = columnName;
252 recordset->MoveNext();
The transactor class for the Microsoft Access driver.
static te::da::DataSourceCapabilities * sm_capabilities
The query dialect supported by ADO driver.
#define ADO_DRIVER_IDENTIFIER
The ADO driver identifier string.
const te::da::DataSourceCapabilities & getCapabilities() const
It returns the known capabilities of the data source.
void drop(const std::map< std::string, std::string > &dsInfo)
It removes the data source with the connection information from a driver.
An atomic property like an integer or double.
bool isValid() const
It checks if the data source is valid (available for using).
A class that models the description of a dataset.
void close()
It closes the data source and clears all the resources used by its internal communication channel...
bool exists(const std::map< std::string, std::string > &dsInfo)
Check the existence of a data source in a driver.
It represents the SQL query dialect accepted by a given data source.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
bool isOpened() const
It returns true if the data source is opened, otherwise it returns false.
std::string MakeConnectionStr(const std::map< std::string, std::string > &dsInfo)
Create a connection string based on a map.
#define TE_TR(message)
It marks a string in order to get translated.
std::vector< te::common::CharEncoding > getEncodings(const std::map< std::string, std::string > &dsInfo)
It gets the encodings for the data source.
A class that implements a connection to a ADO database.
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
static te::da::SQLDialect * sm_queryDialect
The query dialect supported by ADO driver.
void registerGeometryColumn(const std::string &datasetName, const std::string &geomColName)
std::auto_ptr< te::da::DataSourceTransactor > getTransactor()
It returns an object that can execute transactions in the context of a data source.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
const std::map< std::string, std::string > & getGeomColumns() const
void create(const std::map< std::string, std::string > &dsInfo)
It creates a new data source.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
~DataSource()
Virtual destructor.
Implementation of the data source class for the ADO driver.
DataSourceTransactor class implementation for Microsoft Access driver.
void add(Constraint *c)
It adds a new constraint.
bool isGeometryColumn(const std::string &datasetName, const std::string &colName) const
std::string getType() const
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
Utility functions for ADO.
A class that implements a connection to a ADO database.
void setConnectionInfo(const std::map< std::string, std::string > &connInfo)
It sets the connection information to be used when connecting to the data source. ...
void loadGeometryColumnsCache(_ConnectionPtr &adoConn)
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 > getDataSourceNames(const std::map< std::string, std::string > &dsInfo)
It gets the data source names available in a driver.
An static class with global definitions.
void open()
It opens the data source and makes it ready for using.