30 #include "../../../dataaccess/dataset/DataSet.h"
31 #include "../../../dataaccess/dataset/DataSetType.h"
32 #include "../../../dataaccess/datasource/DataSource.h"
33 #include "../../../dataaccess/datasource/DataSourceCapabilities.h"
34 #include "../../../dataaccess/datasource/DataSourceManager.h"
35 #include "../../../dataaccess/query/QueryCapabilities.h"
36 #include "../../../dataaccess/query/Select.h"
37 #include "../../../dataaccess/utils/Utils.h"
38 #include "../../../geometry/GeometryProperty.h"
39 #include "../../../maptools/QueryLayer.h"
40 #include "../../../se/Utils.h"
41 #include "../../widgets/help/HelpPushButton.h"
42 #include "../datasource/selector/DataSourceSelectorWizardPage.h"
43 #include "../datasource/selector/DataSourceSelectorWidget.h"
44 #include "../utils/DoubleListWidget.h"
59 #include <QMessageBox>
63 #include <boost/uuid/random_generator.hpp>
64 #include <boost/uuid/uuid_io.hpp>
73 this->setWizardStyle(QWizard::ModernStyle);
75 this->setWindowTitle(tr(
"Query Layer Builder"));
77 this->setOption(QWizard::HaveHelpButton,
true);
78 this->setOption(QWizard::HelpButtonOnRight,
false);
82 this->setButton(QWizard::HelpButton, helpButton);
96 if(currentPage() == m_dataSourcePage.get())
98 std::list<te::da::DataSourceInfoPtr> list = m_dataSourcePage->getSelectorWidget()->getSelecteds();
108 if(!dataSource->isOpened())
111 setDataSource(dataSource);
113 return m_dataSourcePage->isComplete();
115 else if(currentPage() == m_dataSetPage.get())
120 std::vector<std::pair<std::string, std::string> > vec;
121 m_dataSetPage->getWidget()->getDataSetNames(vec);
122 m_whereClausePage->getWidget()->setFromItems(vec);
124 return m_dataSetPage->isComplete();
126 else if(currentPage() == m_fieldPage.get())
128 return m_fieldPage->isComplete();
130 else if(currentPage() == m_whereClausePage.get())
132 return m_whereClausePage->isComplete();
134 else if(currentPage() == m_groupByPage.get())
136 return m_groupByPage->isComplete();
138 else if(currentPage() == m_orderByPage.get())
140 return m_orderByPage->isComplete();
142 else if(currentPage() == m_layerAttrPage.get())
144 bool res = m_layerAttrPage->isComplete();
147 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Layer name not defined."));
161 m_whereClausePage->getWidget()->setDataSource(m_ds);
165 getQueryCapabilities();
170 if(m_whereClausePage.get())
171 m_whereClausePage->getWidget()->setLayerList(layerList);
180 te::da::From* from = m_dataSetPage->getWidget()->getFrom();
183 te::da::Where* w = m_whereClausePage->getWidget()->getWhere();
199 static boost::uuids::basic_random_generator<boost::mt19937> gen;
200 boost::uuids::uuid u = gen();
201 std::string
id = boost::uuids::to_string(u);
203 std::string title = m_layerAttrPage->getLayerName();
208 layer->setDataSourceId(m_ds->getId());
209 layer->setRendererType(
"QUERY_LAYER_RENDERER");
211 layer->computeExtent();
214 std::auto_ptr<const te::map::LayerSchema> schema(layer->getSchema());
234 addPage(m_dataSourcePage.get());
235 addPage(m_dataSetPage.get());
236 addPage(m_fieldPage.get());
237 addPage(m_whereClausePage.get());
238 addPage(m_groupByPage.get());
239 addPage(m_orderByPage.get());
240 addPage(m_layerAttrPage.get());
245 std::string dsId = m_ds->getId();
247 std::vector<std::string> datasetNames;
251 m_dataSetPage->getWidget()->setDataSetNames(datasetNames);
257 std::vector<std::string> datasetNames = m_ds->getDataSetNames();
259 std::vector<std::pair<std::string, std::string> > dataSetSelecteds;
261 m_dataSetPage->getWidget()->getDataSetNames(dataSetSelecteds);
263 std::vector<std::string> inputProperties;
264 std::vector<std::string> geomProperties;
269 for(
size_t t = 0; t < dataSetSelecteds.size(); ++t)
272 std::string alias = dataSetSelecteds[t].second;
275 std::string dataSetName = dataSetSelecteds[t].first;
278 std::auto_ptr<te::da::DataSetType> dsType(0);
280 for(
unsigned int i = 0; i < datasetNames.size(); ++i)
282 if(datasetNames[i] == dataSetName)
283 dsType = m_ds->getDataSetType(datasetNames[i]);
288 for(
size_t i = 0; i < dsType->size(); ++i)
290 std::string propName = dsType->getProperty(i)->getName();
291 std::string fullName = alias +
"." + propName;
300 geomProperties.push_back(fullName);
303 inputProperties.push_back(fullName);
309 m_fieldPage->getWidget()->setInputValues(inputProperties);
310 m_fieldPage->getWidget()->clearOutputValues();
311 m_fieldPage->getWidget()->setFixedOutputValues(geomProperties,
"geometry");
312 m_groupByPage->getWidget()->setInputValues(inputProperties);
313 m_whereClausePage->getWidget()->setAttributeList(inputProperties);
314 m_whereClausePage->getWidget()->setGeomAttributeList(geomProperties, srid);
315 m_orderByPage->getWidget()->setAttributeList(inputProperties);
325 std::vector<std::string> vecOperators;
327 std::set<std::string>::iterator it;
334 vecOperators.push_back(*it);
344 vecOperators.push_back(*it);
349 m_whereClausePage->getWidget()->setOperatorsList(vecOperators);
352 std::vector<std::string> vecSpatialOperators;
358 vecSpatialOperators.push_back(*it);
363 m_whereClausePage->getWidget()->setSpatialOperatorsList(vecSpatialOperators);
366 std::vector<std::string> vecConnectors;
372 vecConnectors.push_back(*it);
377 m_whereClausePage->getWidget()->setConnectorsList(vecConnectors);
const std::set< std::string > & getComparsionOperators() const
This class is a wizard page with the DoubleListWidget component, used to create the FIELD object of a...
This file has the WhereClauseWizardPage class.
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
boost::shared_ptr< DataSource > DataSourcePtr
A Qt dialog that allows users to create query builder based on TerraLib query framework.
This class is a wizard page with the WhereClauseWidget component.
This file has the FieldsWizardPage class.
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
const std::set< std::string > & getArithmeticOperators() const
A layer resulting from a query.
This file has the OrderByWizardPage class.
const QueryCapabilities & getQueryCapabilities() const
TESEEXPORT Style * CreateFeatureTypeStyle(const te::gm::GeomType &geomType)
Try creates an appropriate feature type style based on given geometry type.
const std::set< std::string > & getLogicalOperators() const
This file has the GroupByWizardPage class.
A class that informs the query support of a given data source.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
static DataSourceManager & getInstance()
It returns a reference to the singleton instance.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
A class that can be used to model a filter expression that can be applied to a query.
const Fields * getFields() const
It returns the list of output expressions used to form the result set.
TEDATAACCESSEXPORT void GetDataSetNames(std::vector< std::string > &datasetNames, const std::string &datasourceId)
A Select models a query to be used when retrieving data from a DataSource.
const std::set< std::string > & getSpatialTopologicOperators() const
This class is used to define the layer attributes information.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
boost::intrusive_ptr< QueryLayer > QueryLayerPtr
This class is a wizard page with the DoubleListWidget component, used to create the GROUPBY object of...
This class is a wizard page with the DataSetWidget component.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
This file has the DataSetWizardPage class.
This file has the LayerAttributesWizardPage class.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr