WFSConnector.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/plugins/datasource/wfs/WFSConnector.cpp
22 
23  \brief OGC Web Feature Service (WFS) connector implementation for the Qt data source widget.
24 */
25 
26 // TerraLib
27 #include "../../../../dataaccess/datasource/DataSource.h"
28 #include "../../../../dataaccess/datasource/DataSourceInfoManager.h"
29 #include "../../../../dataaccess/datasource/DataSourceManager.h"
30 #include "WFSConnector.h"
31 #include "WFSConnectorDialog.h"
32 
33 // Boost
34 #include <boost/uuid/random_generator.hpp>
35 #include <boost/uuid/uuid_io.hpp>
36 #include <boost/filesystem.hpp>
37 
38 // Qt
39 #include <QFileDialog>
40 #include <QMessageBox>
41 
43  : te::qt::widgets::AbstractDataSourceConnector(parent, f)
44 {
45 }
46 
48 
49 void te::qt::plugins::wfs::WFSConnector::connect(std::list<te::da::DataSourceInfoPtr>& datasources)
50 {
51  std::unique_ptr<WFSConnectorDialog> cdialog(new WFSConnectorDialog(static_cast<QWidget*>(parent())));
52 
53  cdialog->exec();
54 
55  te::da::DataSourceInfoPtr ds = cdialog->getDataSource();
56 
57  if(ds.get() != nullptr)
58  {
60  datasources.push_back(ds);
61 
62  te::da::DataSourcePtr driver = cdialog->getDriver();
64  }
65 }
66 
68  std::list<te::da::DataSourceInfoPtr>& /*datasources*/)
69 {
70  QMessageBox::information(this,tr("TerraLib Qt Components"), tr("The WFS data access driver not support creation operation."));
71 }
72 
73 void te::qt::plugins::wfs::WFSConnector::update(std::list<te::da::DataSourceInfoPtr>& datasources)
74 {
75  for(std::list<te::da::DataSourceInfoPtr>::iterator it = datasources.begin(); it != datasources.end(); ++it)
76  {
77  if(it->get() == nullptr)
78  continue;
79 
80  std::unique_ptr<WFSConnectorDialog> cdialog(new WFSConnectorDialog(static_cast<QWidget*>(parent())));
81 
82  cdialog->set(*it);
83 
84  int retval = cdialog->exec();
85 
86  if(retval == QDialog::Rejected)
87  continue;
88 
89  // Don't forget to replace the driver
90  te::da::DataSourcePtr driver = cdialog->getDriver();
91 
92  if(driver.get() != nullptr)
93  {
94  if(te::da::DataSourceManager::getInstance().find(driver->getId()) != nullptr)
95  te::da::DataSourceManager::getInstance().detach(driver->getId());
96 
98  }
99  }
100 }
101 
102 void te::qt::plugins::wfs::WFSConnector::remove(std::list<te::da::DataSourceInfoPtr>& datasources)
103 {
104  for(std::list<te::da::DataSourceInfoPtr>::iterator it = datasources.begin(); it != datasources.end(); ++it)
105  {
106  if(it->get() == nullptr)
107  continue;
108 
109  // First remove driver
111 
112  if(rds.get())
113  {
115  rds.reset();
116  }
117 
118  // Then remove data source
119  te::da::DataSourceInfoManager::getInstance().remove((*it)->getId());
120  }
121 }
122 
boost::shared_ptr< DataSource > DataSourcePtr
void update(std::list< te::da::DataSourceInfoPtr > &datasources)
OGC Web Feature Service (WFS) connector implementation for the Qt data source widget.
static te::dt::Date ds(2010, 01, 01)
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
URI C++ Library.
Definition: Attributes.h:37
WFSConnector(QWidget *parent=0, Qt::WindowFlags f=0)
A dialog window for showing the WFS connector widget.
A dialog window for showing the WFS connector widget.
void remove(std::list< te::da::DataSourceInfoPtr > &datasources)
void create(std::list< te::da::DataSourceInfoPtr > &datasources)
void connect(std::list< te::da::DataSourceInfoPtr > &datasources)
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr