DataSourceGraphMetadata.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 DataSourceGraphMetadata.cpp
22 
23  \brief Class used to define the graph metadata informations
24  over a SGBD source
25 */
26 
27 // Terralib Includes
28 #include "../../../common/StringUtils.h"
29 #include "../../../core/translator/Translator.h"
30 #include "../../../dataaccess/dataset/DataSetType.h"
31 #include "../../../dataaccess/dataset/ForeignKey.h"
32 #include "../../../dataaccess/dataset/Index.h"
33 #include "../../../dataaccess/dataset/PrimaryKey.h"
34 #include "../../../dataaccess/datasource/DataSource.h"
35 #include "../../../dataaccess/query_h.h"
36 #include "../../../dataaccess/Enums.h"
37 #include "../../../datatype/SimpleProperty.h"
38 #include "../../../datatype/StringProperty.h"
39 #include "../../../geometry/GeometryProperty.h"
40 #include "../../../memory/DataSet.h"
41 #include "../../../memory/DataSetItem.h"
42 #include "../../core/EdgeProperty.h"
43 #include "../../core/VertexProperty.h"
44 #include "../../Config.h"
45 #include "../../Exception.h"
46 #include "../../Globals.h"
48 
49 
51 {
53 }
54 
56 
58 {
59  if(m_ds == nullptr)
60  {
61  throw Exception(TE_TR("Data Source not defined."));
62  }
63 
64  //load graph metada information
65  loadGraphInfo(id);
66 
67  //load vertex and edges attributes information
69 }
70 
72 {
73  if(m_ds == nullptr)
74  {
75  throw Exception(TE_TR("Data Source not defined."));
76  }
77 
78  if(this->getName().empty())
79  {
80  throw Exception(TE_TR("Graph name not defined."));
81  }
82 
83  if(!isValidGraphName(this->getName()))
84  {
85  throw Exception(TE_TR("Invalid graph name."));
86  }
87 
88  //add graph table entry
90 
91  //add graph attr table entries
93 
94  //create graph table model
96  {
98 
99  if(getEdgePropertySize() != 0)
100  {
102  }
103  }
104  else if(this->getStorageMode() == te::graph::Edge_List)
105  {
107 
108  if(getVertexPropertySize() != 0)
109  {
111  }
112  }
113 }
114 
116 {
117  if(m_ds == nullptr)
118  {
119  throw Exception(TE_TR(""));
120  }
121 }
122 
124 {
125  if(getVertexPropertySize() == 0)
126  {
128  }
129 
131 
132  //get data set
133  std::string tableName = this->getVertexTableName();
134 
135  // add attribute entry in graph attr table
137 
138  // add property in vertex table
139  saveProperty(tableName, p);
140 }
141 
143 {
145 
146  std::string propertyName = p->getName();
147 
149 
150  //get data set
151  std::string tableName = this->getVertexTableName();
152 
153  //remove property
154  removeProperty(tableName, propertyName);
155 }
156 
158 {
160  {
161  throw Exception(TE_TR("TO DO."));
162  }
163 
165 
166  //get data set
167  std::string tableName = this->getEdgeTableName();
168 
169  // add attribute entry in graph attr table
171 
172  // add property in edge table
173  saveProperty(tableName, p);
174 }
175 
177 {
179 
180  std::string propertyName = p->getName();
181 
183 
184  //get data set
185  std::string tableName = this->getEdgeTableName();
186 
187  //remove property
188  removeProperty(tableName, propertyName);
189 }
190 
192 {
194 
195  //first property: id
197  prop_id->setAutoNumber(true);
198  dt->add(prop_id);
199 
200  //second property: name
202  prop_name->setSize(32);
203  dt->add(prop_name);
204 
205  //third property: type
207  dt->add(prop_type);
208 
209  //fourth property: table name
211  prop_tableName->setSize(32);
212  dt->add(prop_tableName);
213 
214  //fifth property: description
216  prop_desc->setSize(128);
217  dt->add(prop_desc);
218 
219  //define a primary key
220  std::string pkName = Globals::sm_tableGraphName;
221  pkName += "_pk";
222 
223  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
224  pk->add(prop_id);
225 
226  //create index
227  std::string idxName = Globals::sm_tableGraphAttrId;
228  idxName += "_idx";
229  te::da::Index* index = new te::da::Index(idxName, te::da::B_TREE_TYPE, dt);
230  index->add(prop_id);
231 
233 }
234 
236 {
238 
239  //first property: id
241  prop_id->setAutoNumber(true);
242  dt->add(prop_id);
243 
244  //second property: id
246  dt->add(prop_graphId);
247 
248  //third property: table
250  prop_table->setSize(32);
251  dt->add(prop_table);
252 
253  //fourth property: column
255  prop_column->setSize(32);
256  dt->add(prop_column);
257 
258  //fifth property: link name
260  prop_link->setSize(32);
261  dt->add(prop_link);
262 
263  //sixth property: type
265  dt->add(prop_type);
266 
267  //define a primary key
268  std::string pkName = Globals::sm_tableAttributeName;
269  pkName += "_pk";
270 
271  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
272  pk->add(prop_id);
273 
274  //create index
275  std::string idxName = Globals::sm_tableAttributeAttrId;
276  idxName += "_attr_idx";
277  te::da::Index* index = new te::da::Index(idxName, te::da::B_TREE_TYPE, dt);
278  index->add(prop_id);
279 
281 }
282 
284 {
285  throw Exception(TE_TR("TO DO."));
286 }
287 
289 {
290  std::string tableName = this->getName() + Globals::sm_tableEdgeModelSufixName;
291 
292  te::da::DataSetType* dt = new te::da::DataSetType(tableName);
293 
294  //first property: id
296  prop_edgeId->setAutoNumber(true);
297  dt->add(prop_edgeId);
298 
299  //second property: id
301  dt->add(prop_vFrom);
302 
303  //third property: id
305  dt->add(prop_vTo);
306 
307  //add edge properties
308  te::gm::GeometryProperty* geomProp = nullptr;
309 
310  if(getEdgePropertySize() != 0)
311  {
312  for(int i = 0; i < getEdgePropertySize(); ++i)
313  {
315  p->setParent(nullptr);
316 
317  dt->add(p);
318 
319  if(p->getType() == te::dt::GEOMETRY_TYPE)
320  {
321  geomProp = (te::gm::GeometryProperty*)p;
322  }
323  }
324  }
325 
326  //define a primary key
327  std::string pkName = tableName;
328  pkName += "_pk";
329 
330  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
331  pk->add(prop_edgeId);
332 
333  //create index
334  std::string idxEdge = tableName;
335  idxEdge += "_edge_idx";
336  te::da::Index* indexEdge = new te::da::Index(idxEdge, te::da::B_TREE_TYPE, dt);
337  indexEdge->add(prop_edgeId);
338 
339  std::string idxVFrom = tableName;
340  idxVFrom += "_vfrom_idx";
341  te::da::Index* indexVFrom = new te::da::Index(idxVFrom, te::da::B_TREE_TYPE, dt);
342  indexVFrom->add(prop_vFrom);
343 
344  std::string idxVTo = tableName;
345  idxVTo += "_vto_idx";
346  te::da::Index* indexVTo = new te::da::Index(idxVTo, te::da::B_TREE_TYPE, dt);
347  indexVTo->add(prop_vTo);
348 
349  //create spatial index
350  if(geomProp)
351  {
352  std::string idxSpatial = tableName;
353  idxSpatial += "_spatial_idx";
354  te::da::Index* idx = new te::da::Index(idxSpatial, te::da::R_TREE_TYPE, dt);
355  idx->add((te::dt::Property*)geomProp);
356  }
357 
358  createTable(tableName, dt);
359 }
360 
362 {
363  std::string tableName = this->getName() + Globals::sm_tableVertexAttributeModelSufixName;
364 
365  te::da::DataSetType* dt = new te::da::DataSetType(tableName);
366 
367  //first property: id
369  prop_Id->setAutoNumber(true);
370  dt->add(prop_Id);
371 
372  te::gm::GeometryProperty* geomProp = nullptr;
373 
374  if(getVertexPropertySize() != 0)
375  {
376  for(int i = 0; i < getVertexPropertySize(); ++i)
377  {
379  p->setParent(nullptr);
380 
381  dt->add(p);
382 
383  if(p->getType() == te::dt::GEOMETRY_TYPE)
384  {
385  geomProp = (te::gm::GeometryProperty*)p;
386  }
387  }
388  }
389 
390  //define a primary key
391  std::string pkName = tableName;
392  pkName += "_pk";
393  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
394  pk->add(prop_Id);
395 
396  //create index
397  std::string idxName = tableName;
398  idxName += "_idx";
399  te::da::Index* index = new te::da::Index(idxName, te::da::B_TREE_TYPE, dt);
400  index->add(prop_Id);
401 
402  //create spatial index
403  if(geomProp)
404  {
405  std::string idxSpatial = tableName;
406  idxSpatial += "_spatial_idx";
407  te::da::Index* idx = new te::da::Index(idxSpatial, te::da::R_TREE_TYPE, dt);
408  idx->add((te::dt::Property*)geomProp);
409  }
410 
411  createTable(tableName, dt);
412 }
413 
415 {
416  throw Exception(TE_TR("TO DO."));
417 }
418 
420 {
421  if(m_ds->dataSetExists(tableName))
422  {
423  delete dt;
424  return;
425  }
426 
427  std::map<std::string, std::string> options;
428 
429  m_ds->createDataSet(dt, options);
430 }
431 
433  std::string /*graphName*/)
434 {
435  return true;
436 }
437 
439 {
440  //create the graph metadata table model
442 
443  //get dataset type
444  std::unique_ptr<te::da::DataSetType> dsType(m_ds->getDataSetType(Globals::sm_tableGraphName));
445 
446  std::unique_ptr<te::mem::DataSet> dsMem(new te::mem::DataSet(dsType.get()));
447 
448  //create new item
449  te::mem::DataSetItem* dsItem = new te::mem::DataSetItem(dsMem.get());
450 
451  dsItem->setString(1, this->getName());
452  dsItem->setInt32(2, (int)this->getStorageMode());
453 
454  if(this->getStorageMode() == te::graph::Edge_List)
455  {
456  dsItem->setString(3, this->getEdgeTableName());
457  }
458  else if(this->getStorageMode() == te::graph::Vertex_List)
459  {
460  dsItem->setString(3, this->getVertexTableName());
461  }
462 
463  dsItem->setString(4, this->getDescription());
464 
465  dsMem->add(dsItem);
466 
467  //add item
468  std::map<std::string, std::string> options;
469 
470  dsMem->moveBeforeFirst();
471 
472  m_ds->add(Globals::sm_tableGraphName, dsMem.get(), options);
473 
474  //clear
475  dsMem->clear();
476 
477  //update graph id
478  updateGraphId();
479 }
480 
482 {
484 
485  //add edge attributes
486  if(getEdgePropertySize() != 0)
487  {
488  std::string tableName = this->getEdgeTableName();
489 
490  for(int i = 0; i < getEdgePropertySize(); ++i)
491  {
493  }
494  }
495 
496  //add vertex attributes
497  if(getVertexPropertySize() != 0)
498  {
499  std::string tableName = this->getVertexTableName();
500 
501  for(int i = 0; i < getVertexPropertySize(); ++i)
502  {
504  }
505  }
506 }
507 
508 void te::graph::DataSourceGraphMetadata::saveGraphAttrTableNewEntry(int graphId, std::string tableName, std::string attrName, std::string linkColumn, te::graph::GraphAttrType type)
509 {
510  //get dataset type
511  std::unique_ptr<te::da::DataSetType> dsType(m_ds->getDataSetType(Globals::sm_tableAttributeName));
512 
513  std::unique_ptr<te::mem::DataSet> dsMem(new te::mem::DataSet(dsType.get()));
514 
515  //create datase item
516  te::mem::DataSetItem* dsItem = new te::mem::DataSetItem(dsMem.get());
517 
518  dsItem->setInt32(0, graphId);
519  dsItem->setString(1, tableName);
520  dsItem->setString(2, te::common::Convert2LCase(attrName));
521  dsItem->setString(3, te::common::Convert2LCase(linkColumn));
522  dsItem->setInt32(4, type);
523 
524  //add item
525  std::map<std::string, std::string> options;
526 
527  m_ds->add(Globals::sm_tableAttributeName, dsMem.get(), options);
528 
529  //clear
530  dsMem->clear();
531 }
532 
534 {
535  //get dataset type
536  std::unique_ptr<te::da::DataSetType> dsType(m_ds->getDataSetType(tableName));
537 
538  //add property
539  m_ds->addProperty(tableName, p);
540 
541  //if property is a geometry property
542  if(p->getType() == te::dt::GEOMETRY_TYPE)
543  {
544  //create index
545  std::string idxSpatial = tableName;
546  idxSpatial += "_spatial_idx";
547  te::da::Index* idx = new te::da::Index(idxSpatial, te::da::R_TREE_TYPE, dsType.get());
548  idx->add(p);
549 
550  //add index
551  std::map<std::string, std::string> options;
552 
553  m_ds->addIndex(tableName, idx, options);
554  }
555 }
556 
557 void te::graph::DataSourceGraphMetadata::removeProperty(std::string tableName, std::string propertyName)
558 {
559  m_ds->dropProperty(tableName, propertyName);
560 }
561 
563 {
564  //load graph info
565  te::da::Field* f = new te::da::Field("*");
566  te::da::Fields* fields = new te::da::Fields;
567  fields->push_back(f);
568 
570  te::da::From* from = new te::da::From;
571  from->push_back(t);
572 
574 
576 
577  te::da::Where* filter = new te::da::Where(equal);
578 
579  te::da::Select select(fields, from, filter);
580 
581  //get dataset result
582  std::unique_ptr<te::da::DataSet> dataset = m_ds->query(select);
583 
584  if(dataset->moveNext())
585  {
586  m_id = dataset->getInt32(Globals::sm_tableGraphAttrId);
587  m_name = dataset->getString(Globals::sm_tableGraphAttrName);
588  m_description = dataset->getString(Globals::sm_tableGraphAttrDesc);
589 
590  int type = dataset->getInt32(Globals::sm_tableGraphAttrType);
591  if(type == te::graph::Edge_List)
592  {
594  }
595  else if(type == te::graph::Vertex_List)
596  {
598  }
599  }
600 }
601 
603 {
604  //load attributes
605  te::da::Field* f = new te::da::Field("*");
606  te::da::Fields* fields = new te::da::Fields;
607  fields->push_back(f);
608 
610  te::da::From* from = new te::da::From;
611  from->push_back(t);
612 
614 
616 
617  te::da::Where* filter = new te::da::Where(equal);
618 
619  te::da::Select select(fields, from, filter);
620 
621  //get dataset result
622  std::unique_ptr<te::da::DataSet> dataset = m_ds->query(select);
623 
624  while(dataset->moveNext())
625  {
626  int type = dataset->getInt32(Globals::sm_tableAttributeAttrType);
627 
628  std::string tableName = dataset->getString(Globals::sm_tableAttributeAttrTable);
629  std::string columnName = dataset->getString(Globals::sm_tableAttributeAttrColumn);
630 
631  if(type == 0) // vertex attribute
632  {
633  loadVertexAttr(tableName, columnName);
634  }
635  else if(type == 1) // edge attribute
636  {
637  loadEdgeAttr(tableName, columnName);
638  }
639  }
640 }
641 
642 void te::graph::DataSourceGraphMetadata::loadVertexAttr(std::string tableName, std::string columnName)
643 {
644  //get property
645  std::unique_ptr<te::dt::Property> p = m_ds->getProperty(tableName, columnName);
646 
647  te::dt::Property* myProp = p.release();
648 
650 }
651 
652 void te::graph::DataSourceGraphMetadata::loadEdgeAttr(std::string tableName, std::string columnName)
653 {
654  //get property
655  std::unique_ptr<te::dt::Property> p = m_ds->getProperty(tableName, columnName);
656 
657  te::dt::Property* myProp = p.release();
658 
660 }
661 
663 {
665  te::da::Fields* fields = new te::da::Fields;
666  fields->push_back(f);
667 
669  te::da::From* from = new te::da::From;
670  from->push_back(t);
671 
673 
675 
676  te::da::Where* filter = new te::da::Where(equal);
677 
678  te::da::Select select(fields, from, filter);
679 
680  std::unique_ptr<te::da::DataSet> dataset = m_ds->query(select);
681 
682  if(dataset->moveNext())
683  {
684  int id = dataset->getInt32(Globals::sm_tableGraphAttrId);
685 
686  m_id = id;
687  }
688 }
689 
690 /*
691  GRAPH PACKAGE - DATABASE MODEL
692 
693 -- create graph metadata table
694 
695 CREATE TABLE te_graph (
696  graph_id serial NOT NULL,
697  graph_name VARCHAR NULL,
698  graph_type INTEGER NULL,
699  graph_table_name VARCHAR NULL,
700  graph_description VARCHAR NULL,
701  PRIMARY KEY(graph_id)
702 );
703 
704 -- create graph attributes
705 
706 CREATE TABLE te_graph_attr (
707  attr_id serial NOT NULL,
708  graph_id INTEGER NOT NULL,
709  attr_table VARCHAR NULL,
710  attr_column VARCHAR NULL,
711  attr_link_column VARCHAR NULL,
712  attribute_type INTEGER NULL,
713  PRIMARY KEY(attr_id)
714 );
715 
716 
717 -- create graph table model edge list
718 
719 CREATE TABLE graph_model_edge (
720  edge_id serial NOT NULL,
721  vertex_from INT NULL,
722  vertex_to INT NULL,
723  PRIMARY KEY(edge_id)
724 );
725 
726 -- create graph table model vertex list
727 
728 CREATE TABLE graph_model_vertex (
729  vertex_id serial NOT NULL,
730  edges_in bytea NULL,
731  edges_out bytea NULL,
732  PRIMARY KEY(vertex_id)
733 );
734 
735 -- create vertex table properties
736 
737 CREATE TABLE graph_vertex_properties (
738  vertex_id serial NOT NULL,
739  geometry bytea NULL,
740  PRIMARY KEY(vertex_id)
741 );
742 
743 -- create edge table properties
744 
745 CREATE TABLE graph_edge_properties (
746  edge_id serial NOT NULL,
747  geometry bytea NULL,
748  PRIMARY KEY(edge_id)
749 );
750 
751 -- create graph algorithms table
752 
753 CREATE TABLE te_graph_algorithms (
754  algol_id serial NOT NULL,
755  name VARCHAR NULL,
756  description VARCHAR NULL,
757  PRIMARY KEY(algol_id)
758 );
759 
760 -- create graph algorithms params table
761 
762 CREATE TABLE te_graph_algorithms_params (
763  algol_id serial NOT NULL,
764  parameter_number serial NOT NULL,
765  parameter_name VARCHAR NULL,
766  parameter_description VARCHAR NULL,
767  PRIMARY KEY(algol_id, parameter_number)
768 );
769 
770 -- create the table with relation between graphs and algorithms
771 
772 CREATE TABLE graph_algorithm (
773  graph_id INTEGER NOT NULL,
774  algol_id INTEGER NOT NULL,
775  parameter_number INTEGER NOT NULL,
776  attribute_id INTEGER NOT NULL,
777  attribute_value VARCHAR NULL,
778  PRIMARY KEY(graph_id, algol_id, parameter_number, attribute_id)
779 );
780 */
void createGraphAttributesTable()
Function used to create the graph metadata attributes tables in a SGBD.
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
virtual void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
Geometric property.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
Definition: PrimaryKey.h:123
An abstract class that models a source of data in a query.
Definition: FromItem.h:50
The Field class can be used to model an expression that takes part of the output items of a SELECT...
static const std::string sm_tableVertexModelAttrId
Attribute id.
virtual te::dt::Property * getVertexProperty(int idx)
Get a vertex property given a index.
An atomic property like an integer or double.
static const std::string sm_tableAttributeAttrId
Attribute Id.
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
virtual te::dt::Property * getEdgeProperty(int idx)
Get a edge property given a index.
std::string Convert2LCase(const std::string &value)
It converts a string to lower case.
Definition: StringUtils.h:202
te::da::DataSource * m_ds
Data source attribute, has to be database information.
virtual int getVertexPropertySize()
Used to verify the number of properties associated to vertex elements.
A class that models the name of any property of an object.
Base exception class for plugin module.
void load(int id)
Function used to load the graph information given a graph id.
A class that models the description of a dataset.
Definition: DataSetType.h:72
std::string m_description
Attribute used to describe a graph.
virtual void createDataSet(DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
void setSize(std::size_t s)
It sets the maximum number of characters for a varying string, or the number of characters for a fixe...
virtual void addVertexProperty(te::dt::Property *p)
Add a new property associated to the vertex element.
void saveProperty(std::string tableName, te::dt::Property *p)
Save a property into a table in SGBD.
void save()
Function used to save the graph information.
virtual void add(const std::string &datasetName, DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0)
It adds data items to the dataset in the data source.
void loadGraphAttrInfo(int id)
Function used to load the graph attributes information given a graph id.
void createGraphTableEdgeModel()
Function used to create the edge model scheme of tables.
virtual 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.
void add(te::dt::Property *p)
It adds the property to the list of properties of the index.
static const std::string sm_tableGraphAttrName
Attribute Name.
static te::dt::Date ds(2010, 01, 01)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
virtual Property * clone() const =0
It returns a clone of the object.
static const std::string sm_tableGraphName
Database Model Table Graph Name.
It models a property definition.
Definition: Property.h:59
void addGraphTableNewEntry()
Add a new graph metadata information into the SGBD.
static const std::string sm_tableAttributeAttrGraphId
Attribute Graph Id.
te::graph::GraphStorageMode m_mode
Enum attribute used to defines the storage mode.
virtual void addVertexProperty(te::dt::Property *p)
Add a new property associated to the vertex element.
virtual std::unique_ptr< DataSet > query(const Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. This method always returns a dis...
std::string getName()
It returns the graph name.
void createEdgeAttrTable()
Used when vertex_model is selected and edge objects has attributes associated.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
void loadVertexAttr(std::string tableName, std::string columnName)
Load the vertex attributes.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
static const std::string sm_tableGraphAttrType
Attribute Type.
int m_id
Attribute graph unique identifier.
static const std::string sm_tableEdgeModelAttrId
Attribute Id.
void createVertexAttrTable()
Used when edge_model is selected and vertex objects has attributes associated.
static const std::string sm_tableAttributeAttrColumn
Attribute Column.
static const std::string sm_tableGraphAttrTableName
Attribute Table Name.
std::string getDescription()
It returns the the graph description.
URI C++ Library.
Definition: Attributes.h:37
static te::dt::TimeDuration dt(20, 30, 50, 11)
static const std::string sm_tableGraphAttrId
Attribute Id.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
void createTable(std::string tableName, te::da::DataSetType *dt)
Function used to create a table inside the SGBD.
DataSourceGraphMetadata(te::da::DataSource *ds)
Default constructor.
A class that can be used to model a filter expression that can be applied to a query.
Definition: Where.h:47
te::gm::Polygon * p
void removeProperty(std::string tableName, std::string propertyName)
Remove a property of a table in SGBD.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
virtual void removeVertexProperty(int idx)
Remove a property associated to the vertex element.
Class used to define the graph metadata informations over a SGBD source.
static const std::string sm_tableAttributeAttrLink
Attribute Link.
static const std::string sm_tableGraphAttrDesc
Attribute Description.
virtual std::unique_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
void update()
Function used to update the graph information on a data source.
int getId()
It returns the graph id.
int getType() const
It returns the property data type.
Definition: Property.h:161
void add(Constraint *c)
It adds a new constraint.
virtual bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
void loadEdgeAttr(std::string tableName, std::string columnName)
Load the edge attributes.
static const std::string sm_tableAttributeName
Database Model Table Attribute Name.
std::string getEdgeTableName()
It returns the edge table name that contains the vertex elements in data source.
virtual void removeVertexProperty(int idx)
Remove a property associated to the vertex element.
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
virtual void removeEdgeProperty(int idx)
Remove a property associated to the edge element.
It models the comparison operator.
Definition: EqualTo.h:46
virtual void addIndex(const std::string &datasetName, Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
virtual int getEdgePropertySize()
Used to verify the number of properties associated to edge elements.
std::string getVertexTableName()
It returns the vertex table name that contains the vertex elements in data source.
GraphStorageMode getStorageMode()
It returns the the graph storage mode (defined in Enums file)
void createGraphTableVertexModel()
Function used to create the vertex model scheme of tables.
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property.
static const std::string sm_tableEdgeModelAttrVFrom
Attribute Vertex From.
bool isValidGraphName(std::string graphName)
Verify if a graph name is valid.
~DataSourceGraphMetadata()
Default destructor.
std::string m_name
Attribute name.
static const std::string sm_tableVertexAttributeModelSufixName
Database Model Vertex Attribute Model Table Name.
void addGraphAttrTableNewEntry()
Add a new graph attributes metadata information into the SGBD.
static const std::string sm_tableEdgeModelAttrVTo
Attribute Vertex To.
static const std::string sm_tableAttributeAttrTable
Attribute Table.
static const std::string sm_tableEdgeModelSufixName
Database Model Edge Model Table Name.
void createGraphMetadataTable()
Function used to create the graph metadata tables in a SGBD.
It describes an index associated to a DataSetType.
virtual void addEdgeProperty(te::dt::Property *p)
Add a new property associated to the edge element.
virtual void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
virtual void addEdgeProperty(te::dt::Property *p)
Add a new property associated to the edge element.
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:56
virtual void removeEdgeProperty(int idx)
Remove a property associated to the edge element.
void saveGraphAttrTableNewEntry(int graphId, std::string tableName, std::string attrName, std::string linkColumn, te::graph::GraphAttrType type)
Save each metadata attributes of vertex and eges into SGBD.
This class models a string Literal value.
Definition: LiteralString.h:46
void loadGraphInfo(int id)
Function used to load the graph information given a graph id.
static const std::string sm_tableAttributeAttrType
Attribute Type.
const std::string & getName() const
It returns the property name.
Definition: Property.h:127
void setParent(Property *p)
It associate this property to the informed parent.
Definition: Property.h:177