28 #include "../core/DSCopy.h"
29 #include "../core/Utils.h"
34 #include <terralib/dataaccess/datasource/DataSourceCatalogLoader.h>
38 std::string errorMessage;
55 m_dsOrigin->open(
"connection_string="+conn);
57 else if(dstype ==
"GDAL")
60 m_dsOrigin->open(
"URI="+conn);
62 else if(dstype ==
"POSTGIS")
65 m_dsOrigin->open(conn);
69 errorMessage =
"There is not a implementation for this Data Source Type yet!";
75 errorMessage =
"Data Source invalid!";
81 catch(std::exception& e)
83 errorMessage =
"Error ocurred: " + std::string(e.what());
88 errorMessage =
"Error ocurred: unexpected!";
95 std::string port, std::string dsname, std::string user, std::string pw, std::string& errorMessage)
98 if(dstype ==
"POSTGIS")
100 std::string connStr =
"host=" + host;
101 connStr +=
"&port=" + port;
102 connStr +=
"&dbname=" + dsname;
103 connStr +=
"&user=" + user;
104 connStr +=
"&password=" + pw;
110 m_dsOrigin->open(connStr);
114 errorMessage =
"Data Source invalid!";
121 catch(std::exception& e)
123 errorMessage =
"Error ocurred: " + std::string(e.what());
128 errorMessage =
"Error ocurred: unexpected!";
134 errorMessage =
"There is not a implementation for this Data Source Type yet!";
147 m_dsDestination->open(
"connection_string="+conn);
149 else if(dstype ==
"GDAL")
152 m_dsDestination->open(
"URI="+conn);
154 else if(dstype ==
"POSTGIS")
157 m_dsDestination->open(conn);
161 errorMessage =
"There is not a implementation for this Data Source Type yet!";
167 errorMessage =
"Data Source invalid!";
173 catch(std::exception& e)
175 errorMessage =
"Error ocurred: " + std::string(e.what());
180 errorMessage =
"Error ocurred: unexpected!";
187 std::string port, std::string dsname, std::string user, std::string pw, std::string& errorMessage)
190 if(dstype ==
"POSTGIS")
192 std::string connStr =
"host=" + host;
193 connStr +=
"&port=" + port;
194 connStr +=
"&dbname=" + dsname;
195 connStr +=
"&user=" + user;
196 connStr +=
"&password=" + pw;
202 m_dsDestination->open(connStr);
206 errorMessage =
"Data Source invalid!";
213 catch(std::exception& e)
215 errorMessage =
"Error ocurred: " + std::string(e.what());
220 errorMessage =
"Error ocurred: unexpected!";
226 errorMessage =
"There is not a implementation for this Data Source Type yet!";
233 std::vector<std::string> dictionary;
235 te::da::DataSourceFactory::dictionary_type::const_iterator it = te::da::DataSourceFactory::getDictionary().begin();
237 while(it != te::da::DataSourceFactory::getDictionary().end())
239 if(it->first !=
"MEM")
241 dictionary.push_back(it->first.c_str());
252 std::vector<std::string*> dataSetsNames;
256 te::da::DataSourceCatalogLoader* catalogLoader = transactor->getCatalogLoader();
258 catalogLoader->getDataSets(dataSetsNames);
260 return dataSetsNames;
265 m_datasets = datasets;
270 std::vector<std::string*> datasetsP;
271 for(
size_t i = 0; i < m_datasets.size(); i++)
272 datasetsP.push_back(&m_datasets[i]);
278 return ds.
copy(m_dsOrigin, m_dsDestination, datasetsP, errorMessage);
281 catch(std::exception& e)
283 errorMessage =
"Error ocurred: " + std::string(e.what());
288 errorMessage =
"Error ocurred: unexpected!";
static std::auto_ptr< DataSource > make(const std::string &dsType)
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
A factory for data sources.
Data Source Copy GUI Controller.