33 #include <terralib/dataaccess/datasource/DataSourceCatalogLoader.h>
34 #include <terralib/dataaccess/dataset/DataSetPersistence.h>
42 std::string dsConnStrDestination, std::vector<std::string*> datasets, std::string& errorMessage)
46 dsOrigin->
open(dsConnStrOrigin);
50 errorMessage =
"Could not get a connection with the origin DataSource.";
55 dsDestination->
open(dsConnStrDestination);
57 if(dsDestination == 0)
59 errorMessage =
"Could not get a connection with the destination DataSource.";
63 if(!copyDataSets(dsOrigin, dsDestination, datasets, errorMessage))
74 return copyDataSets(dsOrigin, dsDestination, datasets, errorMessage);
81 te::da::DataSourceCatalogLoader* cOrigin = tOrigin->getCatalogLoader();
82 cOrigin->loadCatalog();
86 std::vector<std::string*> datasetsNames;
87 cOrigin->getDataSets(datasetsNames);
88 datasets = datasetsNames;
92 te::da::DataSetPersistence* pDestination = tDestination->getDataSetPersistence();
94 for(
unsigned int i = 0; i < datasets.size(); i++)
100 pDestination->create(datasettype, dataSet);
103 std::cout <<
"Copy executed successfully!" << std::endl << std::endl;
104 std::cout <<
"-------------------------" << std::endl;
106 if(dsDestination->
getType() ==
"MEM")
108 std::vector<std::string*> datasets;
109 dsDestination->
getTransactor()->getCatalogLoader()->getDataSets(datasets);
111 std::cout << std::endl <<
"In-memory data sets:" << std::endl << std::endl;
112 for(std::size_t i = 0; i < datasets.size(); i++)
113 std::cout <<
" " << *datasets[i] << std::endl;
A factory for data sources.
static bool loadModules(std::string &errorMessage)
Load Terralib modules.
Terralib Raster Manager Tool Utils.
virtual std::auto_ptr< DataSourceTransactor > getTransactor()=0
It returns an object that can execute transactions in the context of a data source.
static std::auto_ptr< DataSource > make(const std::string &dsType)
virtual std::auto_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. A connected dataset, after its creation through the data source transactor, continues to depend on the connection given by its associated data source. Differently, a disconnected dataset, after its creation, no more depends of the connection given by the data source, and it continues to live after the connection has been released to the data source.
bool copyDataSets(te::da::DataSource *dsOrigin, te::da::DataSource *dsDestination, std::vector< std::string * > datasets, std::string &errorMessage)
Copy a list of Data Sets.
virtual std::string getType() const =0
It returns the data source type name (in UPPER CASE). Ex: POSTGIS, SQLITE, WFS, WMS, or MYSQL.
virtual std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)=0
It gets information about the given dataset.
virtual void open()=0
It opens the data source and makes it ready for using.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
A class that models the description of a dataset.
bool copy(std::string dsTypeOrigin, std::string dsConnStrOrigin, std::string dsTypeDestination, std::string dsConnStrDestination, std::vector< std::string * > datasets, std::string &errorMessage)
Copy.
An utility class to provide methods to copy a Data Source.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...
A dataset is the unit of information manipulated by the data access module of TerraLib.
bool init(std::string &errorMessage)
Init the application.
A DataSourceTransactor can be viewed as a connection to the data source for reading/writing things in...