src/terralib/stmemory/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/stmememory/Transactor.cpp
22 
23  \brief An implementation of DataSourceTransactor class for the ST in-memory driver.
24 */
25 
26 // TerraLib
27 #include "../core/translator/Translator.h"
28 #include "../dataaccess/dataset/DataSetType.h"
29 #include "../dataaccess/dataset/PrimaryKey.h"
30 #include "../datatype/DateTimePeriod.h"
31 #include "DataSet.h"
32 #include "DataSource.h"
33 #include "Transactor.h"
34 #include "Exception.h"
35 
36 
38  m_ds(parent)
39 {
40 }
41 
43 
45 {
46  return m_ds;
47 }
48 
50 {
51  return;
52 }
53 
55 {
56  return;
57 }
58 
60 {
61  return;
62 }
63 
65 {
66  return false;
67 }
68 
69 std::unique_ptr<te::da::DataSet> te::stmem::Transactor::getDataSet(const std::string& name,
70  te::common::TraverseType /*travType*/ ,
71  bool /*connected*/,
73 {
74  //It creates a new DataSet that shares the internal observations.
75  DataSet* ds = new DataSet(*getData(name), false);
76  return std::unique_ptr<te::da::DataSet>(ds);
77 }
78 
79 std::unique_ptr<te::da::DataSet> te::stmem::Transactor::getDataSet(const std::string& name,
80  const std::string& propertyName,
81  const te::gm::Envelope* e,
83  te::common::TraverseType /*travType*/,
84  bool /*connected*/,
86 {
87  te::da::DataSetType* type = getType(name);
88  DataSet* ds = getData(name);
89  if(static_cast<int>(type->getPropertyPosition(propertyName)) != ds->getGeomPropIdx())
90  throw Exception("Not supported by ST In-Memory driver!");
91  return std::unique_ptr<te::da::DataSet>(ds->filter(e, r));
92 }
93 
94 std::unique_ptr<te::da::DataSet> te::stmem::Transactor::getDataSet(const std::string& name,
95  const std::string& propertyName,
96  const te::gm::Geometry* g,
98  te::common::TraverseType /*travType*/,
99  bool /*connected*/,
101 {
102  te::da::DataSetType* type = getType(name);
103  DataSet* ds = getData(name);
104  if(static_cast<int>(type->getPropertyPosition(propertyName)) != ds->getGeomPropIdx())
105  throw Exception("Not supported by ST In-Memory driver!");
106  return std::unique_ptr<te::da::DataSet>(ds->filter(g, r));
107 }
108 
109 std::unique_ptr<te::da::DataSet> te::stmem::Transactor::query(const te::da::Select& /*q*/,
110  te::common::TraverseType /*travType*/, bool /*connected*/,
112 {
113  return std::unique_ptr<te::da::DataSet>();
114 }
115 
116 std::unique_ptr<te::da::DataSet> te::stmem::Transactor::query(const std::string& /*query*/,
117  te::common::TraverseType /*travType*/,
118  bool /*connected*/,
120 {
121  return std::unique_ptr<te::da::DataSet>();
122 }
123 
125 {
126  return;
127 }
128 
129 void te::stmem::Transactor::execute(const std::string& /*command*/)
130 {
131  return;
132 }
133 
134 std::unique_ptr<te::da::PreparedQuery>
135 te::stmem::Transactor::getPrepared(const std::string& /*qName*/)
136 {
137  return std::unique_ptr<te::da::PreparedQuery> ();
138 }
139 
140 std::unique_ptr<te::da::BatchExecutor>
142 {
143  return std::unique_ptr<te::da::BatchExecutor> ();
144 }
145 
147 {
148  return;
149 }
150 
152 {
153  return 0;
154 }
155 
156 std::string te::stmem::Transactor::escape(const std::string& /*value*/)
157 {
158  return "";
159 }
160 
161 bool te::stmem::Transactor::isDataSetNameValid(const std::string& datasetName)
162 {
163  std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(datasetName);
164  if(it==m_ds->m_datasets.end())
165  return true;
166  return false;
167 }
168 
169 bool te::stmem::Transactor::isPropertyNameValid(const std::string& /*propertyName*/)
170 {
171  return true;
172 }
173 
174 std::vector<std::string> te::stmem::Transactor::getDataSetNames()
175 {
176  std::vector<std::string> result;
177  std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.begin();
178  if(it!=m_ds->m_datasets.end())
179  {
180  result.push_back(it->first);
181  ++it;
182  }
183  return result;
184 }
185 
187 {
188  return m_ds->m_datasets.size();
189 }
190 
191 std::unique_ptr<te::da::DataSetType> te::stmem::Transactor::getDataSetType(const std::string& name)
192 {
193  te::da::DataSetType* type = getType(name);
194  return std::unique_ptr<te::da::DataSetType>(static_cast<te::da::DataSetType*>(type->clone()));
195 }
196 
197 boost::ptr_vector<te::dt::Property> te::stmem::Transactor::getProperties(const std::string& datasetName)
198 {
199  boost::ptr_vector<te::dt::Property> properties;
200 
201  te::da::DataSetType* type = getType(datasetName);
202 
203  const std::size_t np = type->size();
204 
205  for(std::size_t i = 0; i != np; ++i)
206  properties.push_back(type->getProperty(i)->clone());
207 
208  return properties;
209 }
210 
211 std::unique_ptr<te::dt::Property>
212 te::stmem::Transactor::getProperty(const std::string& datasetName, const std::string& name)
213 {
214  te::da::DataSetType* type = getType(datasetName);
215 
216  return std::unique_ptr<te::dt::Property>(type->getProperty(name)->clone());
217 }
218 
219 std::unique_ptr<te::dt::Property>
220 te::stmem::Transactor::getProperty(const std::string& datasetName, std::size_t propertyPos)
221 {
222  te::da::DataSetType* type = getType(datasetName);
223 
224  return std::unique_ptr<te::dt::Property>(type->getProperty(propertyPos)->clone());
225 }
226 
227 std::vector<std::string> te::stmem::Transactor::getPropertyNames(const std::string& datasetName)
228 {
229  std::vector<std::string> propertyNames;
230 
231  te::da::DataSetType* type = getType(datasetName);
232 
233  const std::size_t np = type->size();
234 
235  for(std::size_t i = 0; i != np; ++i)
236  propertyNames.push_back(type->getProperty(i)->getName());
237 
238  return propertyNames;
239 }
240 
241 std::size_t te::stmem::Transactor::getNumberOfProperties(const std::string& datasetName)
242 {
243  te::da::DataSetType* type = getType(datasetName);
244 
245  return type->size();
246 }
247 
248 bool te::stmem::Transactor::propertyExists(const std::string& datasetName, const std::string& name)
249 {
250  te::da::DataSetType* type = getType(datasetName);
251 
252  if(type->getProperty(name)!=0)
253  return true;
254 
255  return false;
256 }
257 
258 void te::stmem::Transactor::addProperty(const std::string& /*datasetName*/, te::dt::Property* /*p*/)
259 {
260  return;
261 }
262 
263 void te::stmem::Transactor::dropProperty(const std::string& /*datasetName*/, const std::string& /*name*/)
264 {
265  return;
266 }
267 
268 void te::stmem::Transactor::renameProperty(const std::string& /*datasetName*/,
269  const std::string& /*propertyName*/,
270  const std::string& /*newPropertyName*/)
271 {
272  return;
273 }
274 
275 std::unique_ptr<te::da::PrimaryKey> te::stmem::Transactor::getPrimaryKey(const std::string& datasetName)
276 {
277  te::da::DataSetType* type = getType(datasetName);
278 
279  return std::unique_ptr<te::da::PrimaryKey>(static_cast<te::da::PrimaryKey*>(type->getPrimaryKey()->clone()));
280 }
281 
282 bool te::stmem::Transactor::primaryKeyExists(const std::string& datasetName, const std::string& name)
283 {
284  te::da::DataSetType* type = getType(datasetName);
285  te::da::PrimaryKey* pk = type->getPrimaryKey();
286 
287  if(pk==0)
288  return false;
289 
290  if(pk->getName()==name)
291  return true;
292 
293  return false;
294 }
295 
296 void te::stmem::Transactor::addPrimaryKey(const std::string& datasetName, te::da::PrimaryKey* pk)
297 {
298  te::da::DataSetType* type = getType(datasetName);
299  type->add(pk);
300 }
301 
302 void te::stmem::Transactor::dropPrimaryKey(const std::string& /*datasetName*/)
303 {
304  return;
305 }
306 
307 std::unique_ptr<te::da::ForeignKey>
308 te::stmem::Transactor::getForeignKey(const std::string& /*datasetName*/, const std::string& /*name*/)
309 {
310  return std::unique_ptr<te::da::ForeignKey>();
311 }
312 
313 std::vector<std::string> te::stmem::Transactor::getForeignKeyNames(const std::string& /*datasetName*/)
314 {
315  return std::vector<std::string>();
316 }
317 
318 bool te::stmem::Transactor::foreignKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
319 {
320  return false;
321 }
322 
323 void te::stmem::Transactor::addForeignKey(const std::string& /*datasetName*/, te::da::ForeignKey* /*fk*/)
324 {
325  return;
326 }
327 
328 void te::stmem::Transactor::dropForeignKey(const std::string& /*datasetName*/, const std::string& /*fkName*/)
329 {
330  return;
331 }
332 
333 std::unique_ptr<te::da::UniqueKey> te::stmem::Transactor::getUniqueKey(const std::string& /*datasetName*/, const std::string& /*name*/)
334 {
335  return std::unique_ptr<te::da::UniqueKey>();
336 }
337 
338 std::vector<std::string> te::stmem::Transactor::getUniqueKeyNames(const std::string& /*datasetName*/)
339 {
340  return std::vector<std::string>(0);
341 }
342 
343 bool te::stmem::Transactor::uniqueKeyExists(const std::string& /*datasetName*/, const std::string& /*name*/)
344 {
345  return false;
346 }
347 
348 void te::stmem::Transactor::addUniqueKey(const std::string& /*datasetName*/, te::da::UniqueKey* /*uk*/)
349 {
350  return;
351 }
352 
353 void te::stmem::Transactor::dropUniqueKey(const std::string& /*datasetName*/, const std::string& /*name*/)
354 {
355  return;
356 }
357 
358 std::unique_ptr<te::da::CheckConstraint> te::stmem::Transactor::getCheckConstraint(const std::string& /*datasetName*/, const std::string& /*name*/)
359 {
360  return std::unique_ptr<te::da::CheckConstraint>();
361 }
362 
363 std::vector<std::string> te::stmem::Transactor::getCheckConstraintNames(const std::string& /*datasetName*/)
364 {
365  return std::vector<std::string>();
366 }
367 
368 bool te::stmem::Transactor::checkConstraintExists(const std::string& /*datasetName*/, const std::string& /*name*/)
369 {
370  return false;
371 }
372 
373 void te::stmem::Transactor::addCheckConstraint(const std::string& /*datasetName*/, te::da::CheckConstraint* /*cc*/)
374 {
375  return;
376 }
377 
378 void te::stmem::Transactor::dropCheckConstraint(const std::string& /*datasetName*/, const std::string& /*name*/)
379 {
380  return;
381 }
382 
383 std::unique_ptr<te::da::Index> te::stmem::Transactor::getIndex(const std::string& /*datasetName*/, const std::string& /*name*/)
384 {
385  return std::unique_ptr<te::da::Index>();
386 }
387 
388 std::vector<std::string> te::stmem::Transactor::getIndexNames(const std::string& /*datasetName*/)
389 {
390  return std::vector<std::string>(0);
391 }
392 
393 bool te::stmem::Transactor::indexExists(const std::string& /*datasetName*/, const std::string& /*name*/)
394 {
395  return false;
396 }
397 
398 void te::stmem::Transactor::addIndex(const std::string& /*datasetName*/, te::da::Index* /*idx*/,
399  const std::map<std::string, std::string>& /*options*/)
400 {
401  return;
402 }
403 
404 void te::stmem::Transactor::dropIndex(const std::string& /*datasetName*/, const std::string& /*idxName*/)
405 {
406  return;
407 }
408 
409 std::unique_ptr<te::da::Sequence> te::stmem::Transactor::getSequence(const std::string& /*name*/)
410 {
411  return std::unique_ptr<te::da::Sequence>();
412 }
413 
414 std::vector<std::string> te::stmem::Transactor::getSequenceNames()
415 {
416  return std::vector<std::string>(0);
417 }
418 
419 bool te::stmem::Transactor::sequenceExists(const std::string& /*name*/)
420 {
421  return false;
422 }
423 
425 {
426  return;
427 }
428 
429 void te::stmem::Transactor::dropSequence(const std::string& /*name*/)
430 {
431  return;
432 }
433 
434 std::unique_ptr<te::gm::Envelope> te::stmem::Transactor::getExtent(const std::string& datasetName,
435  const std::string& propertyName)
436 {
437  te::da::DataSetType* type = getType(datasetName);
438  DataSet* ds = getData(datasetName);
439  if(static_cast<int>(type->getPropertyPosition(propertyName)) != ds->getGeomPropIdx())
440  throw Exception("Not supported by ST In-Memory driver!");
441 
442  return std::unique_ptr<te::gm::Envelope>(ds->getExtent(static_cast<size_t>(ds->getGeomPropIdx())));
443 }
444 
445 std::unique_ptr<te::gm::Envelope> te::stmem::Transactor::getExtent(const std::string& datasetName,
446  std::size_t propertyPos)
447 {
448  DataSet* ds = getData(datasetName);
449  if(static_cast<int>(propertyPos) != ds->getGeomPropIdx())
450  throw Exception("Not supported by ST In-Memory driver!");
451 
452  return std::unique_ptr<te::gm::Envelope>(ds->getExtent(static_cast<size_t>(ds->getGeomPropIdx())));
453 }
454 
455 std::size_t te::stmem::Transactor::getNumberOfItems(const std::string& datasetName)
456 {
457  DataSet* ds = getData(datasetName);
458  return ds->size();
459 }
460 
462 {
463  return !m_ds->m_datasets.empty();
464 }
465 
466 bool te::stmem::Transactor::dataSetExists(const std::string& name)
467 {
468  std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(name);
469  if(it== m_ds->m_datasets.end())
470  return false;
471  return true;
472 }
473 
474 void te::stmem::Transactor::createDataSet(te::da::DataSetType* /*dt*/, const std::map<std::string, std::string>& /*options*/)
475 {
476  return;
477 }
478 
479 void te::stmem::Transactor::cloneDataSet(const std::string& /*name*/,
480  const std::string& /*cloneName*/,
481  const std::map<std::string, std::string>& /*options*/)
482 {
483  return;
484 }
485 
486 
487 void te::stmem::Transactor::dropDataSet(const std::string& name)
488 {
489  std::map<std::string, te::da::DataSetType*>::iterator itdt = m_ds->m_schemas.find(name);
490  if(itdt==m_ds->m_schemas.end())
491  throw Exception("There is not a DataSetType with the given name!");
492 
493  std::map<std::string, DataSet*>::iterator itds = m_ds->m_datasets.find(name);
494  if(itds==m_ds->m_datasets.end())
495  throw Exception("There is not a DataSet with the given name!");
496 
497  delete(itdt->second);
498  delete(itds->second);
499  m_ds->m_schemas.erase(itdt);
500  m_ds->m_datasets.erase(itds);
501  return;
502 }
503 
504 void te::stmem::Transactor::renameDataSet(const std::string& name, const std::string& newName)
505 {
506  if(dataSetExists(newName))
507  throw Exception("The is already a DataSet with the new name!");
508 
509  std::map<std::string, te::da::DataSetType*>::iterator itdt = m_ds->m_schemas.find(name);
510  if(itdt==m_ds->m_schemas.end())
511  throw Exception("There is not a DataSetType with the given name!");
512 
513  std::map<std::string, DataSet*>::iterator itds = m_ds->m_datasets.find(name);
514  if(itds==m_ds->m_datasets.end())
515  throw Exception("There is not a DataSet with the given name!");
516 
517  te::da::DataSetType* dt = itdt->second;
518  dt->setName(newName);
519  DataSet* ds = itds->second;
520  //ds->setName(newName); => DataSet does not have name!!
521 
522  //erase without deleting the pointer.
523  m_ds->m_schemas.erase(itdt);
524  m_ds->m_datasets.erase(itds);
525 
526  m_ds->m_schemas.insert(std::pair<std::string, te::da::DataSetType*>(newName,dt));
527  m_ds->m_datasets.insert(std::pair<std::string, DataSet*>(newName,ds));
528 
529  return;
530 }
531 
532 void te::stmem::Transactor::add(const std::string& /*datasetName*/,
533  te::da::DataSet* /*d*/,
534  const std::map<std::string, std::string>& /*options*/,
535  std::size_t /*limit*/,
536  bool /*enableProgress*/)
537 {
538  return;
539 }
540 
541 void te::stmem::Transactor::remove(const std::string& /*datasetName*/, const te::da::ObjectIdSet* /*oids*/)
542 {
543  return;
544 }
545 
546 void te::stmem::Transactor::update( const std::string& /*datasetName*/,
547  te::da::DataSet* /*dataset*/,
548  const std::vector<std::size_t>& /*properties*/,
549  const te::da::ObjectIdSet* /*oids*/,
550  const std::map<std::string, std::string>& /*options*/,
551  std::size_t /*limit*/)
552 {
553  return;
554 }
555 
556 void te::stmem::Transactor::optimize(const std::map<std::string, std::string>& /*opInfo*/)
557 {
558  return;
559 }
560 
561 
563 {
564  return m_ds;
565 }
566 
567 void te::stmem::Transactor::add(const std::string& name, te::da::DataSetType* t, DataSet* d)
568 {
569  if(dataSetExists(name))
570  throw Exception("There is already a DataSet with the new name!");
571 
572  m_ds->m_datasets.insert(std::pair<std::string, DataSet*>(name,d));
573  m_ds->m_schemas.insert(std::pair<std::string, te::da::DataSetType*>(name,t));
574  return;
575 }
576 
577  std::unique_ptr<te::da::DataSet> te::stmem::Transactor::getDataSet(const std::string& name,
579  te::common::TraverseType /*travType*/, bool /*connected*/,
581  {
582  DataSet* ds = getData(name);
583  return std::unique_ptr<te::da::DataSet>(ds->filter(dt, r));
584  }
585 
586  std::unique_ptr<te::da::DataSet> te::stmem::Transactor::getDataSet(const std::string& name,
589  te::common::TraverseType /*travType*/, bool /*connected*/,
591  {
592  DataSet* ds = getData(name);
593  return std::unique_ptr<te::da::DataSet>(ds->filter(g, sr, dt, tr));
594  }
595 
596  std::unique_ptr<te::da::DataSet> te::stmem::Transactor::getDataSet(const std::string& name,
599  te::common::TraverseType /*travType*/, bool /*connected*/,
601  {
602  DataSet* ds = getData(name);
603  return std::unique_ptr<te::da::DataSet>(ds->filter(e, sr, dt, tr));
604  }
605 
606  std::unique_ptr<te::dt::DateTimePeriod>
608  {
609  DataSet* ds = getData(name);
610  return std::unique_ptr<te::dt::DateTimePeriod>(ds->getTemporalExtent());
611  }
612 
613 // Protected Methods
614 te::da::DataSetType* te::stmem::Transactor::getType(const std::string& datasetName)
615 {
616  std::map<std::string, te::da::DataSetType*>::const_iterator it = m_ds->m_schemas.find(datasetName);
617  if(it==m_ds->m_schemas.end())
618  throw Exception("There is not a DataSetType with the given name!");
619  return it->second;
620 }
621 
622 te::stmem::DataSet* te::stmem::Transactor::getData(const std::string& datasetName)
623 {
624  std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(datasetName);
625  if(it==m_ds->m_datasets.end())
626  throw Exception("There is not a DataSet with the given name!");
627  return it->second;
628 }
Property * getProperty(std::size_t i) const
It returns the i-th property.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
std::unique_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
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.
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
~Transactor()
It constructs a Transactor.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
Property * clone() const
It returns a clone of the object.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
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 hasDataSets()
It checks if the data source has any dataset.
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
std::unique_ptr< te::dt::DateTimePeriod > getTemporalExtent() const
It returns the temporal extent of the observations.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
Base exception class for plugin module.
A class that models the description of a dataset.
Definition: DataSetType.h:72
Implements a DataSource that contains In-Memory DataSets indexed by space and time.
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 dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
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.
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.
DataSet * getData(const std::string &datasetName)
It returns the DataSet associated to a given name.
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of 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 > getDataSetNames()
It It gets the dataset names available in the data source.
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
Definition: DataSetType.h:214
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
SpatialRelation
Spatial relations between geometric objects.
It describes a sequence (a number generator).
static te::dt::Date ds(2010, 01, 01)
A class that describes a check constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
DataSource * m_ds
The associated data source.
virtual Property * clone() const =0
It returns a clone of the object.
std::map< std::string, te::da::DataSetType * > m_schemas
The set of dataset schemas.
It models a property definition.
Definition: Property.h:59
void commit()
It commits the transaction.
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
te::da::DataSetType * getType(const std::string &datasetName)
It returns the DataSetType associated to a given name.
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.
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
void begin()
It starts a new transaction.
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
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.
std::unique_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
std::unique_ptr< te::dt::DateTimePeriod > getTemporalExtent(const std::string &name)
It returns the temporal extent associated to a DataSet.
void setName(const std::string &name)
It sets the property name.
Definition: Property.h:137
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
Constraint * clone()
It returns a clone of the object.
An Envelope defines a 2D rectangular region.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
std::unique_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
void DataSet()
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
static te::dt::TimeDuration dt(20, 30, 50, 11)
std::map< std::string, DataSet * > m_datasets
The set of datasets stored in memory.
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
std::unique_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
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 dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
An implementation of DataSourceTransactor class for the ST In-memory driver.
std::unique_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
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.
DataSource * getSTMemDataSource() const
It returns its associated ST In-Memory DataSource.
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
It models a foreign key constraint for a DataSetType.
Definition: ForeignKey.h:50
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
It describes a unique key (uk) constraint.
Definition: UniqueKey.h:53
std::size_t size() const
It returns the number of properties of the CompositeProperty.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
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.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
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.
std::size_t size() const
It returns the collection size, if it is known.
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
Implementation of a in-memory data set that contains spatiotemporal observations indexed by time and ...
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
void add(Constraint *c)
It adds a new constraint.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Transactor(DataSource *parent)
It constructs a Transactor.
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...
void cancel()
It requests that the data source stop the processing of the current command.
Implementation of an in-memory data set that contains spatiotemporal observations indexed by time and...
An exception class for the TerraLib ST memory driver.
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
Implements a DataSource that contains st memory DataSets indexed by space and time.
std::size_t getPropertyPosition(const std::string &name) const
It returns the property position based on its name.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
int getGeomPropIdx() const
It returns the index of the property that contains the observed geometries.
std::unique_ptr< DataSet > filter(const te::gm::Envelope *e, te::gm::SpatialRelation r) const
It returns a new DataSet, based on a given spatial filter.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
virtual const std::string & getName() const
It returns the constraint name.
Definition: Constraint.h:119
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::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
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.
A Query is independent from the data source language/dialect.
Definition: Query.h:46
It describes an index associated to a DataSetType.
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
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...
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.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127