src/terralib/wfs/Transactor.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/wfs/Transactor.cpp
22 
23  \brief Implementation of the transactor for the WFS driver.
24 */
25 
26 // TerraLib
27 #include "../core/translator/Translator.h"
28 #include "../dataaccess/utils/Utils.h"
29 #include "../datatype/Property.h"
30 #include "../geometry/Envelope.h"
31 #include "../geometry/Geometry.h"
32 #include "../geometry/GeometryProperty.h"
33 #include "../ogr/DataSet.h"
34 #include "../ogr/SQLVisitor.h"
35 #include "../ogr/Utils.h"
36 #include "DataSource.h"
37 #include "Exception.h"
38 #include "Transactor.h"
39 #include "Utils.h"
40 
41 // OGR
42 #include <ogrsf_frmts.h>
43 
44 // STL
45 #include <vector>
46 
48 {
49 }
50 
52 
54 {
55  return m_ds;
56 }
57 
58 std::unique_ptr<te::da::DataSet> te::wfs::Transactor::getDataSet(const std::string& name,
59  te::common::TraverseType /*travType*/,
60  bool /*connected*/,
61  const te::common::AccessPolicy /*accessPolicy*/)
62 {
63  assert(m_ds->getOGRDataSource());
64 
65  //OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ds->getOGRDataSource()->GetName());
66  GDALDataset* ds = (GDALDataset*)GDALOpenEx(m_ds->getOGRDataSource()->GetDescription(), GDAL_OF_READONLY, nullptr, nullptr, nullptr);
67 
68  std::string sql = "SELECT FID, * FROM \"" + name + "\"";
69  OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), nullptr, nullptr);
70 
71  if(layer == nullptr)
72  throw Exception(TE_TR("The informed data set could not be found in the data source!"));
73 
74  //char** fields = new char*[1];
75  //fields[0] = "OGR_GEOMETRY";
76 
77  //layer->SetIgnoredFields((const char**) fields);
78 
79  return std::unique_ptr<te::da::DataSet>(new te::ogr::DataSet(ds, layer));
80 }
81 
82 std::unique_ptr<te::da::DataSet> te::wfs::Transactor::getDataSet(
83  const std::string& name, const std::string& /*propertyName*/,
84  const te::gm::Envelope* /*e*/, te::gm::SpatialRelation /*r*/,
85  te::common::TraverseType /*travType*/, bool /*connected*/,
86  const te::common::AccessPolicy /*accessPolicy*/)
87 {
88  assert(m_ds->getOGRDataSource());
89 
90  //OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ds->getOGRDataSource()->GetName());
91  GDALDataset* ds = (GDALDataset*)GDALOpenEx(m_ds->getOGRDataSource()->GetDescription(), GDAL_OF_READONLY, nullptr, nullptr, nullptr);
92 
93  std::string sql = "SELECT FID, * FROM \"" + name + "\"";
94  OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), nullptr, nullptr);
95 
96  if(layer == nullptr)
97  throw Exception(TE_TR("The informed data set could not be found in the data source!"));
98 
99 // layer->SetSpatialFilterRect(e->m_llx, e->m_lly, e->m_urx, e->m_ury);
100 
101  return std::unique_ptr<te::da::DataSet>(new te::ogr::DataSet(ds, layer));
102 }
103 
104 std::unique_ptr<te::da::DataSet> te::wfs::Transactor::getDataSet(const std::string& name,
105  const std::string& /*propertyName*/,
106  const te::gm::Geometry* g,
108  te::common::TraverseType /*travType*/,
109  bool /*connected*/,
110  const te::common::AccessPolicy /*accessPolicy*/)
111 {
112  assert(m_ds->getOGRDataSource());
113 
114  //OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ds->getOGRDataSource()->GetName());
115  GDALDataset* ds = (GDALDataset*)GDALOpenEx(m_ds->getOGRDataSource()->GetDescription(), GDAL_OF_READONLY, nullptr, nullptr, nullptr);
116 
117  std::string sql = "SELECT FID, * FROM \"" + name + "\"";
118  OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), nullptr, nullptr);
119 
120  if(layer == nullptr)
121  throw Exception(TE_TR("The informed data set could not be found in the data source!"));
122 
123  OGRGeometry* ogrg = te::ogr::Convert2OGR(g);
124 
125  layer->SetSpatialFilter(ogrg);
126 
127  OGRGeometryFactory::destroyGeometry(ogrg);
128 
129  return std::unique_ptr<te::da::DataSet>(new te::ogr::DataSet(ds, layer));
130 }
131 
132 std::unique_ptr<te::da::DataSet> te::wfs::Transactor::query(const te::da::Select& q,
133  te::common::TraverseType /*travType*/,
134  bool /*connected*/,
135  const te::common::AccessPolicy /*accessPolicy*/)
136 {
137  assert(m_ds->getOGRDataSource());
138 
139  //OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ds->getOGRDataSource()->GetName());
140  GDALDataset* ds = (GDALDataset*)GDALOpenEx(m_ds->getOGRDataSource()->GetDescription(), GDAL_OF_READONLY, nullptr, nullptr, nullptr);
141 
142  std::string sql;
143 
144  te::ogr::SQLVisitor visitor(*m_ds->getDialect(), sql);
145 
146  q.accept(visitor);
147 
148  sql = te::ogr::RemoveSpatialSql(sql);
149 
150  OGRLayer* layer = ds->ExecuteSQL(sql.c_str(), nullptr, nullptr);
151 
152  if(layer == nullptr)
153  throw Exception(TE_TR("The informed data set could not be found in the data source!"));
154 
155  te::gm::Envelope* e = visitor.getMBR();
156 
157  if(e != nullptr)
158  layer->SetSpatialFilterRect(e->m_llx, e->m_lly, e->m_urx, e->m_ury);
159 
160  return std::unique_ptr<te::da::DataSet>(new te::ogr::DataSet(ds, layer));
161 }
162 
163 std::unique_ptr<te::da::DataSet> te::wfs::Transactor::query(const std::string& query,
164  te::common::TraverseType /*travType*/,
165  bool /*connected*/,
166  const te::common::AccessPolicy /*accessPolicy*/)
167 {
168  assert(m_ds->getOGRDataSource());
169 
170  //OGRDataSource* ds = OGRSFDriverRegistrar::Open(m_ds->getOGRDataSource()->GetName());
171  GDALDataset* ds = (GDALDataset*)GDALOpenEx(m_ds->getOGRDataSource()->GetDescription(), GDAL_OF_READONLY, nullptr, nullptr, nullptr);
172 
173  OGRLayer* layer = ds->ExecuteSQL(query.c_str(), nullptr, nullptr);
174 
175  if(layer == nullptr)
176  throw Exception(TE_TR("The informed data set could not be found in the data source!"));
177 
178  return std::unique_ptr<te::da::DataSet>(new te::ogr::DataSet(ds, layer));
179 }
180 
181 std::vector<std::string> te::wfs::Transactor::getDataSetNames()
182 {
183  std::vector<std::string> names;
184 
185  if(!m_ds->getOGRDataSource())
186  return names;
187 
188  for(int i = 0; i < m_ds->getOGRDataSource()->GetLayerCount(); ++i)
189  names.push_back(m_ds->getOGRDataSource()->GetLayer(i)->GetName());
190 
191  return names;
192 }
193 
195 {
196  if(!m_ds->getOGRDataSource())
197  return 0;
198 
199  return m_ds->getOGRDataSource()->GetLayerCount();
200 }
201 
202 std::unique_ptr<te::da::DataSetType> te::wfs::Transactor::getDataSetType(const std::string& name)
203 {
204  assert(m_ds->getOGRDataSource());
205 
206  std::string sql("SELECT FID, * FROM \"");
207  sql += name + "\"";
208 
209  OGRLayer* layer = m_ds->getOGRDataSource()->ExecuteSQL(sql.c_str(), nullptr, nullptr);
210 
211  if(layer == nullptr)
212  throw Exception(TE_TR("Could not retrieve the informed data set!"));
213 
214  std::unique_ptr<te::da::DataSetType> type(te::ogr::Convert2TerraLib(layer->GetLayerDefn()));
215  type->setName(name);
216 
217  const char* colIdName = layer->GetFIDColumn();
218 
219  if(colIdName == nullptr || colIdName[0] == '\0')
220  colIdName = "FID";
221 
222  int pos = layer->GetLayerDefn()->GetFieldIndex(colIdName);
223  if(pos >= 0)
224  {
225  te::da::PrimaryKey* pk = new te::da::PrimaryKey(colIdName, type.get());
226  pk->add(type->getProperty(pos));
227  }
228 
229  int srs = te::ogr::Convert2TerraLibProjection(layer->GetSpatialRef());
230 
232 
233  if(gp != nullptr)
234  gp->setSRID(srs);
235 
236  m_ds->getOGRDataSource()->ReleaseResultSet(layer);
237 
238  return type;
239 }
240 
241 boost::ptr_vector<te::dt::Property> te::wfs::Transactor::getProperties(const std::string& datasetName)
242 {
243  boost::ptr_vector<te::dt::Property> properties;
244 
245  std::unique_ptr<te::da::DataSetType> type = getDataSetType(datasetName);
246 
247  const std::vector<te::dt::Property*>& props = type->getProperties();
248  for(std::size_t i = 0; i < props.size(); ++i)
249  properties.push_back(props[i]->clone());
250 
251  return properties;
252 }
253 
254 std::unique_ptr<te::dt::Property> te::wfs::Transactor::getProperty(const std::string& datasetName, const std::string& name)
255 {
256  assert(m_ds->getOGRDataSource());
257 
258  std::string sql("SELECT FID, * FROM \"");
259  sql += datasetName + "\"";
260 
261  OGRLayer* layer = m_ds->getOGRDataSource()->ExecuteSQL(sql.c_str(), nullptr, nullptr);
262 
263  if(layer == nullptr)
264  throw Exception(TE_TR("Could not retrieve the informed data set!"));
265 
266  int propertyPos = layer->GetLayerDefn()->GetFieldIndex(name.c_str());
267 
268  m_ds->getOGRDataSource()->ReleaseResultSet(layer);
269 
270  return getProperty(datasetName, static_cast<std::size_t>(propertyPos));
271 }
272 
273 std::unique_ptr<te::dt::Property> te::wfs::Transactor::getProperty(const std::string& datasetName, std::size_t propertyPos)
274 {
275  assert(m_ds->getOGRDataSource());
276 
277  std::string sql("SELECT FID, * FROM \"");
278  sql += datasetName + "\"";
279 
280  OGRLayer* layer = m_ds->getOGRDataSource()->ExecuteSQL(sql.c_str(), nullptr, nullptr);
281 
282  if(layer == nullptr)
283  throw Exception(TE_TR("Could not retrieve the informed data set!"));
284 
285  OGRFeatureDefn* def = layer->GetLayerDefn();
286  OGRFieldDefn* fdef = def->GetFieldDefn(static_cast<int>(propertyPos));
287 
288  std::unique_ptr<te::dt::Property> prop;
289  if(fdef != nullptr)
290  prop.reset(te::ogr::Convert2TerraLib(fdef));
291 
292  m_ds->getOGRDataSource()->ReleaseResultSet(layer);
293 
294  return prop;
295 }
296 
297 std::vector<std::string> te::wfs::Transactor::getPropertyNames(const std::string& datasetName)
298 {
299  assert(m_ds->getOGRDataSource());
300 
301  std::string sql("SELECT FID, * FROM \"");
302  sql += datasetName + "\"";
303 
304  OGRLayer* layer = m_ds->getOGRDataSource()->ExecuteSQL(sql.c_str(), nullptr, nullptr);
305 
306  if(layer == nullptr)
307  throw Exception(TE_TR("Could not retrieve the informed data set!"));
308 
309  std::vector<std::string> propertyNames;
310 
311  OGRFeatureDefn* def = layer->GetLayerDefn();
312 
313  for(int i = 0; i < def->GetFieldCount(); ++i)
314  propertyNames.push_back(def->GetFieldDefn(i)->GetNameRef());
315 
316  m_ds->getOGRDataSource()->ReleaseResultSet(layer);
317 
318  return propertyNames;
319 }
320 
321 std::size_t te::wfs::Transactor::getNumberOfProperties(const std::string& datasetName)
322 {
323  return getPropertyNames(datasetName).size();
324 }
325 
326 bool te::wfs::Transactor::propertyExists(const std::string& datasetName, const std::string& name)
327 {
328  std::vector<std::string> propertyNames = getPropertyNames(datasetName);
329 
330  for(std::size_t i = 0; i < propertyNames.size(); ++i)
331  if(propertyNames[i] == name)
332  return true;
333 
334  return false;
335 }
336 
337 std::unique_ptr<te::gm::Envelope> te::wfs::Transactor::getExtent(const std::string& datasetName,
338  const std::string& propertyName)
339 {
340  assert(m_ds->getOGRDataSource());
341 
342  std::string sql("SELECT ");
343  sql += propertyName + " FROM \"";
344  sql += datasetName + "\"";
345 
346  OGRLayer* layer = m_ds->getOGRDataSource()->ExecuteSQL(sql.c_str(), nullptr, nullptr);
347 
348  if(layer == nullptr)
349  throw Exception(TE_TR("Could not retrieve the informed data set!"));
350 
351  std::unique_ptr<OGREnvelope> ogrEnv(new OGREnvelope);
352 
353  if(layer->GetExtent(ogrEnv.get()) != OGRERR_NONE)
354  {
355  m_ds->getOGRDataSource()->ReleaseResultSet(layer);
356  throw Exception(TE_TR("Error when attempting to get the extent!"));
357  }
358 
359  std::unique_ptr<te::gm::Envelope> teEnv(te::ogr::Convert2TerraLib(ogrEnv.get()));
360 
361  m_ds->getOGRDataSource()->ReleaseResultSet(layer);
362 
363  return teEnv;
364 }
365 
366 std::unique_ptr<te::gm::Envelope> te::wfs::Transactor::getExtent(const std::string& datasetName,
367  std::size_t /*propertyPos*/)
368 {
369  return getExtent(datasetName, "OGR_GEOMETRY");
370 }
371 
372 std::size_t te::wfs::Transactor::getNumberOfItems(const std::string& datasetName)
373 {
374  assert(m_ds->getOGRDataSource());
375 
376  OGRLayer* layer = m_ds->getOGRDataSource()->GetLayerByName(datasetName.c_str());
377 
378  if(layer == nullptr)
379  throw Exception(TE_TR("Could not retrieve the informed data set!"));
380 
381  return layer->GetFeatureCount();
382 }
383 
385 {
386  if(!m_ds->getOGRDataSource())
387  return false;
388 
389  return (m_ds->getOGRDataSource()->GetLayerCount() > 0);
390 }
391 
392 bool te::wfs::Transactor::dataSetExists(const std::string& name)
393 {
394  if(!m_ds->getOGRDataSource())
395  return false;
396 
397  return (m_ds->getOGRDataSource()->GetLayerByName(name.c_str()) != nullptr);
398 }
399 
400 /** NOT SUPPORTED METHODS */
401 //@{
402 
404 {
405  throw Exception(TE_TR("The method begin() is not supported by the WFS driver!"));
406 }
407 
409 {
410  throw Exception(TE_TR("The method commit() is not supported by the WFS driver!"));
411 }
412 
414 {
415  throw Exception(TE_TR("The method rollBack() is not supported by the WFS driver!"));
416 }
417 
419 {
420  throw Exception(TE_TR("The method isInTransaction() is not supported by the WFS driver!"));
421 }
422 
424 {
425  throw Exception(TE_TR("The method execute() is not supported by the WFS driver!"));
426 }
427 
428 void te::wfs::Transactor::execute(const std::string& /*command*/)
429 {
430  throw Exception(TE_TR("The method execute() is not supported by the WFS driver!"));
431 }
432 
433 std::unique_ptr<te::da::PreparedQuery> te::wfs::Transactor::getPrepared(const std::string& /*qName*/)
434 {
435  throw Exception(TE_TR("The method getPrepared() is not supported by the WFS driver!"));
436 }
437 
438 std::unique_ptr<te::da::BatchExecutor> te::wfs::Transactor::getBatchExecutor()
439 {
440  throw Exception(TE_TR("The method getBatchExecutor() is not supported by the WFS driver!"));
441 }
442 
444 {
445  throw Exception(TE_TR("The method cancel() is not supported by the WFS driver!"));
446 }
447 
449 {
450  throw Exception(TE_TR("The method getLastGeneratedId() is not supported by the WFS driver!"));
451 }
452 
453 std::string te::wfs::Transactor::escape(const std::string& /*value*/)
454 {
455  throw Exception(TE_TR("The method escape() is not supported by the WFS driver!"));
456 }
457 
458 bool te::wfs::Transactor::isDataSetNameValid(const std::string& /*datasetName*/)
459 {
460  throw Exception(TE_TR("The method isDataSetNameValid() is not supported by the WFS driver!"));
461 }
462 
463 bool te::wfs::Transactor::isPropertyNameValid(const std::string& /*propertyName*/)
464 {
465  throw Exception(TE_TR("The method isPropertyNameValid() is not supported by the WFS driver!"));
466 }
467 
468 void te::wfs::Transactor::addProperty(const std::string& /*datasetName*/, te::dt::Property* /*p*/)
469 {
470  throw Exception(TE_TR("The method addProperty() is not supported by the WFS driver!"));
471 }
472 
473 void te::wfs::Transactor::dropProperty(const std::string& /*datasetName*/, const std::string& /*name*/)
474 {
475  throw Exception(TE_TR("The method dropProperty() is not supported by the WFS driver!"));
476 }
477 
478 void te::wfs::Transactor::renameProperty(const std::string& /*datasetName*/, const std::string& /*propertyName*/, const std::string& /*newPropertyName*/)
479 {
480  throw Exception(TE_TR("The method renameProperty() is not supported by the WFS driver!"));
481 }
482 
483 std::unique_ptr<te::da::PrimaryKey> te::wfs::Transactor::getPrimaryKey(const std::string& /*datasetName*/)
484 {
485  throw Exception(TE_TR("The method getPrimaryKey() is not supported by the WFS driver!"));
486 }
487 
488 bool te::wfs::Transactor::primaryKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
489 {
490  throw Exception(TE_TR("The method primaryKeyExists() is not supported by the WFS driver!"));
491 }
492 
493 void te::wfs::Transactor::addPrimaryKey(const std::string& /*datasetName*/, te::da::PrimaryKey* /*pk*/)
494 {
495  throw Exception(TE_TR("The method addPrimaryKey() is not supported by the WFS driver!"));
496 }
497 
498 void te::wfs::Transactor::dropPrimaryKey(const std::string& /*datasetName*/)
499 {
500  throw Exception(TE_TR("The method dropPrimaryKey() is not supported by the WFS driver!"));
501 }
502 
503 std::unique_ptr<te::da::ForeignKey> te::wfs::Transactor::getForeignKey(const std::string& /*datasetName*/, const std::string& /*name*/)
504 {
505  throw Exception(TE_TR("The method getForeignKey() is not supported by the WFS driver!"));
506 }
507 
508 std::vector<std::string> te::wfs::Transactor::getForeignKeyNames(const std::string& /*datasetName*/)
509 {
510  throw Exception(TE_TR("The method getForeignKeyNames() is not supported by the WFS driver!"));
511 }
512 
513 bool te::wfs::Transactor::foreignKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
514 {
515  throw Exception(TE_TR("The method foreignKeyExists() is not supported by the WFS driver!"));
516 }
517 
518 void te::wfs::Transactor::addForeignKey(const std::string& /*datasetName*/, te::da::ForeignKey* /*fk*/)
519 {
520  throw Exception(TE_TR("The method addForeignKey() is not supported by the WFS driver!"));
521 }
522 
523 void te::wfs::Transactor::dropForeignKey(const std::string& /*datasetName*/, const std::string& /*fkName*/)
524 {
525  throw Exception(TE_TR("The method dropForeignKey() is not supported by the WFS driver!"));
526 }
527 
528 std::unique_ptr<te::da::UniqueKey> te::wfs::Transactor::getUniqueKey(const std::string& /*datasetName*/, const std::string& /*name*/)
529 {
530  throw Exception(TE_TR("The method getUniqueKey() is not supported by the WFS driver!"));
531 }
532 
533 std::vector<std::string> te::wfs::Transactor::getUniqueKeyNames(const std::string& /*datasetName*/)
534 {
535  throw Exception(TE_TR("The method getUniqueKeyNames() is not supported by the WFS driver!"));
536 }
537 
538 bool te::wfs::Transactor::uniqueKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
539 {
540  throw Exception(TE_TR("The method uniqueKeyExists() is not supported by the WFS driver!"));
541 }
542 
543 void te::wfs::Transactor::addUniqueKey(const std::string& /*datasetName*/, te::da::UniqueKey* /*uk*/)
544 {
545  throw Exception(TE_TR("The method addUniqueKey() is not supported by the WFS driver!"));
546 }
547 
548 void te::wfs::Transactor::dropUniqueKey(const std::string& /*datasetName*/, const std::string& /*name*/)
549 {
550  throw Exception(TE_TR("The method dropUniqueKey() is not supported by the WFS driver!"));
551 }
552 
553 std::unique_ptr<te::da::CheckConstraint> te::wfs::Transactor::getCheckConstraint(const std::string& /*datasetName*/, const std::string& /*name*/)
554 {
555  throw Exception(TE_TR("The method getCheckConstraint() is not supported by the WFS driver!"));
556 }
557 
558 std::vector<std::string> te::wfs::Transactor::getCheckConstraintNames(const std::string& /*datasetName*/)
559 {
560  throw Exception(TE_TR("The method getCheckConstraintNames() is not supported by the WFS driver!"));
561 }
562 
563 bool te::wfs::Transactor::checkConstraintExists(const std::string& /*datasetName*/, const std::string& /*name*/)
564 {
565  throw Exception(TE_TR("The method checkConstraintExists() is not supported by the WFS driver!"));
566 }
567 
568 void te::wfs::Transactor::addCheckConstraint(const std::string& /*datasetName*/, te::da::CheckConstraint* /*cc*/)
569 {
570  throw Exception(TE_TR("The method addCheckConstraint() is not supported by the WFS driver!"));
571 }
572 
573 void te::wfs::Transactor::dropCheckConstraint(const std::string& /*datasetName*/, const std::string& /*name*/)
574 {
575  throw Exception(TE_TR("The method dropCheckConstraint() is not supported by the WFS driver!"));
576 }
577 
578 std::unique_ptr<te::da::Index> te::wfs::Transactor::getIndex(const std::string& /*datasetName*/, const std::string& /*name*/)
579 {
580  throw Exception(TE_TR("The method getIndex() is not supported by the WFS driver!"));
581 }
582 
583 std::vector<std::string> te::wfs::Transactor::getIndexNames(const std::string& /*datasetName*/)
584 {
585  throw Exception(TE_TR("The method getIndexNames() is not supported by the WFS driver!"));
586 }
587 
588 bool te::wfs::Transactor::indexExists(const std::string& /*datasetName*/, const std::string& /*name*/)
589 {
590  throw Exception(TE_TR("The method indexExists() is not supported by the WFS driver!"));
591 }
592 
593 void te::wfs::Transactor::addIndex(const std::string& /*datasetName*/, te::da::Index* /*idx*/, const std::map<std::string, std::string>& /*options*/)
594 {
595  throw Exception(TE_TR("The method addIndex() is not supported by the WFS driver!"));
596 }
597 
598 void te::wfs::Transactor::dropIndex(const std::string& /*datasetName*/, const std::string& /*idxName*/)
599 {
600  throw Exception(TE_TR("The method dropIndex() is not supported by the WFS driver!"));
601 }
602 
603 std::unique_ptr<te::da::Sequence> te::wfs::Transactor::getSequence(const std::string& /*name*/)
604 {
605  throw Exception(TE_TR("The method getSequence() is not supported by the WFS driver!"));
606 }
607 
608 std::vector<std::string> te::wfs::Transactor::getSequenceNames()
609 {
610  throw Exception(TE_TR("The method getSequenceNames() is not supported by the WFS driver!"));
611 }
612 
613 bool te::wfs::Transactor::sequenceExists(const std::string& /*name*/)
614 {
615  throw Exception(TE_TR("The method sequenceExists() is not supported by the WFS driver!"));
616 }
617 
619 {
620  throw Exception(TE_TR("The method addSequence() is not supported by the WFS driver!"));
621 }
622 
623 void te::wfs::Transactor::dropSequence(const std::string& /*name*/)
624 {
625  throw Exception(TE_TR("The method dropSequence() is not supported by the WFS driver!"));
626 }
627 
629  const std::map<std::string, std::string>& /*options*/)
630 {
631  throw Exception(TE_TR("The method createDataSet() is not supported by the WFS driver!"));
632 }
633 
634 void te::wfs::Transactor::cloneDataSet(const std::string& /*name*/,
635  const std::string& /*cloneName*/,
636  const std::map<std::string, std::string>& /*options*/)
637 {
638  throw Exception(TE_TR("The method cloneDataSet() is not supported by the WFS driver!"));
639 }
640 
641 void te::wfs::Transactor::dropDataSet(const std::string& /*name*/)
642 {
643  throw Exception(TE_TR("The method dropDataSet() is not supported by the WFS driver!"));
644 }
645 
646 void te::wfs::Transactor::renameDataSet(const std::string& /*name*/,
647  const std::string& /*newName*/)
648 {
649  throw Exception(TE_TR("The method renameDataSet() is not supported by the WFS driver!"));
650 }
651 
652 void te::wfs::Transactor::add(const std::string& /*datasetName*/,
653  te::da::DataSet* /*d*/,
654  const std::map<std::string, std::string>& /*options*/,
655  std::size_t /*limit*/,
656  bool /*enableProgress*/)
657 {
658  throw Exception(TE_TR("The method add() is not supported by the WFS driver!"));
659 }
660 
661 void te::wfs::Transactor::remove(const std::string& /*datasetName*/, const te::da::ObjectIdSet* /*oids*/)
662 {
663  throw Exception(TE_TR("The method remove() is not supported by the WFS driver!"));
664 }
665 
666 void te::wfs::Transactor::update(const std::string& /*datasetName*/,
667  te::da::DataSet* /*dataset*/,
668  const std::vector<std::size_t>& /*properties*/,
669  const te::da::ObjectIdSet* /*oids*/,
670  const std::map<std::string, std::string>& /*options*/,
671  std::size_t /*limit*/)
672 {
673  throw Exception(TE_TR("The method update() is not supported by the WFS driver!"));
674 }
675 
676 void te::wfs::Transactor::optimize(const std::map<std::string, std::string>& /*opInfo*/)
677 {
678  throw Exception(TE_TR("The method optimize() is not supported by the WFS driver!"));
679 }
680 //@}
std::unique_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name)
It gets the unique key in the dataset with the given name.
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
Geometric property.
const te::da::SQLDialect * getDialect() const
It returns the data source SQL dialect, if there is one.
void add(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0, bool enableProgress=true)
It adds data items to the dataset in the data source.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
Definition: PrimaryKey.h:123
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
void createDataSet(te::da::DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
TEOGREXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
std::unique_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
bool foreignKeyExists(const std::string &datasetName, const std::string &name)
It checks if a foreign key with the given name exists in the data source.
Implementation of the data source for the WFS driver.
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
Base exception class for plugin module.
A class that models the description of a dataset.
Definition: DataSetType.h:72
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
An exception class for the TerraLib WFS module.
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
std::unique_ptr< te::da::PreparedQuery > getPrepared(const std::string &qName=std::string(""))
It creates a prepared query object that may be used for query commands (select, insert, update and delete) that are used repeatedly.
std::unique_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name)
It gets the check constraint of the dataset with the given name.
std::unique_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
double m_urx
Upper right corner x-coordinate.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
SpatialRelation
Spatial relations between geometric objects.
It describes a sequence (a number generator).
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
static te::dt::Date ds(2010, 01, 01)
void update(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)
It updates the contents of a dataset for the set of data items.
A class that describes a check constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
TEOGREXPORT std::string RemoveSpatialSql(const std::string &sql)
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
It models a property definition.
Definition: Property.h:59
std::unique_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
void optimize(const std::map< std::string, std::string > &opInfo)
For some data access drivers, this method will perform some operations to optimize the data storage...
Implementation of the data source for the WFS driver.
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
double m_llx
Lower left corner x-coordinate.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
bool hasDataSets()
It checks if the data source has any dataset.
void cancel()
It requests that the data source stop the processing of the current command.
An Envelope defines a 2D rectangular region.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
std::unique_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName)
It retrieves the bounding rectangle of the spatial property for the given dataset.
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
TEOGREXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
void DataSet()
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
void cloneDataSet(const std::string &name, const std::string &cloneName, const std::map< std::string, std::string > &options)
It clones the dataset in the data source.
void begin()
NOT SUPPORTED METHODS.
Utility functions for the data access module.
std::unique_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
double m_lly
Lower left corner y-coordinate.
std::unique_ptr< te::da::DataSet > query(const te::da::Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. A dataset can be connected or di...
A dataset is the unit of information manipulated by the data access module of TerraLib.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
double m_ury
Upper right corner y-coordinate.
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
bool checkConstraintExists(const std::string &datasetName, const std::string &name)
It checks if a check-constraint with the given name exists in the data source.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
void addIndex(const std::string &datasetName, te::da::Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
Implementation of the transactor for the WFS driver.
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
void dropSequence(const std::string &name)
It removes the sequence from the data source.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
A Query is independent from the data source language/dialect.
Definition: Query.h:46
It describes an index associated to a DataSetType.
std::unique_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
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.
std::unique_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
TEOGREXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection.
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
void commit()
It commits the transaction.
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.