27 #include "../../../../common/Translator.h"
28 #include "../../../../dataaccess/datasource/DataSource.h"
29 #include "../../../../dataaccess/datasource/DataSourceFactory.h"
30 #include "../../../../dataaccess/datasource/DataSourceInfo.h"
31 #include "../../../../dataaccess/datasource/DataSourceManager.h"
32 #include "../../../widgets/Exception.h"
34 #include "ui_WCSConnectorDialogForm.h"
37 #include <boost/algorithm/string/case_conv.hpp>
38 #include <boost/uuid/random_generator.hpp>
39 #include <boost/uuid/uuid_io.hpp>
40 #include <boost/lexical_cast.hpp>
43 #include <QMessageBox>
47 m_ui(new Ui::WCSConnectorDialogForm)
76 if(m_datasource.get() != 0)
78 const std::map<std::string, std::string>& connInfo = m_datasource->getConnInfo();
80 std::map<std::string, std::string>::const_iterator it = connInfo.find(
"URI");
81 if(it != connInfo.end())
82 m_ui->m_serverLineEdit->setText(QString::fromStdString(it->second));
84 m_ui->m_datasourceTitleLineEdit->setText(QString::fromStdString(m_datasource->getTitle()));
86 m_ui->m_datasourceDescriptionTextEdit->setText(QString::fromStdString(m_datasource->getDescription()));
96 throw te::qt::widgets::Exception(
TE_TR(
"Sorry! No data access driver loaded for WCS data sources!"));
99 std::map<std::string, std::string> dsInfo;
100 getConnectionInfo(dsInfo);
104 ds->setConnectionInfo(dsInfo);
106 m_driver.reset(ds.release());
108 if(m_driver.get() == 0)
109 throw te::qt::widgets::Exception(
TE_TR(
"Could not open WCS data source due to an unknown error!"));
111 QString title = m_ui->m_datasourceTitleLineEdit->text().trimmed();
114 title = m_ui->m_serverLineEdit->text().trimmed();
116 if(m_datasource.get() == 0)
121 m_datasource->setConnInfo(dsInfo);
123 boost::uuids::basic_random_generator<boost::mt19937> gen;
124 boost::uuids::uuid u = gen();
125 std::string dsId = boost::uuids::to_string(u);
127 m_datasource->setId(dsId);
128 m_driver->setId(dsId);
129 m_datasource->setTitle(title.toStdString());
130 m_datasource->setDescription(m_ui->m_datasourceDescriptionTextEdit->toPlainText().trimmed().toStdString());
131 m_datasource->setAccessDriver(
"WCS");
132 m_datasource->setType(
"WCS");
136 m_driver->setId(m_datasource->getId());
137 m_datasource->setConnInfo(dsInfo);
138 m_datasource->setTitle(title.toStdString());
139 m_datasource->setDescription(m_ui->m_datasourceDescriptionTextEdit->toPlainText().trimmed().toStdString());
142 catch(
const std::exception& e)
144 QMessageBox::warning(
this,
145 tr(
"TerraLib Qt Components"),
151 QMessageBox::warning(
this,
152 tr(
"TerraLib Qt Components"),
153 tr(
"Unknown error while opening WCS data source!"));
166 throw te::qt::widgets::Exception(
TE_TR(
"Sorry! No data access driver loaded for WCS data sources!"));
169 std::map<std::string, std::string> dsInfo;
170 getConnectionInfo(dsInfo);
176 throw te::qt::widgets::Exception(
TE_TR(
"Could not open WCS server!"));
178 ds->setConnectionInfo(dsInfo);
181 QMessageBox::information(
this,
182 tr(
"TerraLib Qt Components"),
183 tr(
"Data source is ok!"));
187 catch(
const std::exception& e)
189 QMessageBox::warning(
this,
190 tr(
"TerraLib Qt Components"),
195 QMessageBox::warning(
this,
196 tr(
"TerraLib Qt Components"),
197 tr(
"Unknown error while testing WCS data source!"));
203 QMessageBox::warning(
this,
204 tr(
"TerraLib Qt Components"),
205 tr(
"Not implemented yet!\nWe will provide it soon!"));
213 QString url = m_ui->m_serverLineEdit->text().trimmed();
215 throw te::qt::widgets::Exception(
TE_TR(
"Please define the server address first!"));
217 connInfo[
"URI"] = url.toStdString();
void openPushButtonPressed()
static bool find(const std::string &dsType)
boost::shared_ptr< DataSource > DataSourcePtr
void set(const te::da::DataSourceInfoPtr &ds)
#define TE_TR(message)
It marks a string in order to get translated.
A dialog window for showing the WCS connector widget.
WCSConnectorDialog(QWidget *parent=0, Qt::WindowFlags f=0)
const te::da::DataSourcePtr & getDriver() const
void testPushButtonPressed()
std::auto_ptr< Ui::WCSConnectorDialogForm > m_ui
static std::auto_ptr< DataSource > make(const std::string &dsType)
const te::da::DataSourceInfoPtr & getDataSource() const
void getConnectionInfo(std::map< std::string, std::string > &connInfo) const
A class that represents a data source component.
void helpPushButtonPressed()
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr