All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "../../../common/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 {
57 }
58 
60 {
61  if(m_ds == 0)
62  {
63  throw Exception(TE_TR("Data Source not defined."));
64  }
65 
66  //load graph metada information
67  loadGraphInfo(id);
68 
69  //load vertex and edges attributes information
70  loadGraphAttrInfo(id);
71 }
72 
74 {
75  if(m_ds == 0)
76  {
77  throw Exception(TE_TR("Data Source not defined."));
78  }
79 
80  if(this->getName().empty())
81  {
82  throw Exception(TE_TR("Graph name not defined."));
83  }
84 
85  if(!isValidGraphName(this->getName()))
86  {
87  throw Exception(TE_TR("Invalid graph name."));
88  }
89 
90  //add graph table entry
91  addGraphTableNewEntry();
92 
93  //add graph attr table entries
94  addGraphAttrTableNewEntry();
95 
96  //create graph table model
97  if(this->getStorageMode() == te::graph::Vertex_List)
98  {
99  createGraphTableVertexModel();
100 
101  if(getEdgePropertySize() != 0)
102  {
103  createEdgeAttrTable();
104  }
105  }
106  else if(this->getStorageMode() == te::graph::Edge_List)
107  {
108  createGraphTableEdgeModel();
109 
110  if(getVertexPropertySize() != 0)
111  {
112  createVertexAttrTable();
113  }
114  }
115 }
116 
118 {
119  if(m_ds == 0)
120  {
121  throw Exception(TE_TR(""));
122  }
123 }
124 
126 {
127  if(getVertexPropertySize() == 0)
128  {
129  createVertexAttrTable();
130  }
131 
133 
134  //get data set
135  std::string tableName = this->getVertexTableName();
136 
137  // add attribute entry in graph attr table
138  saveGraphAttrTableNewEntry(this->getId(), tableName, p->getName(), Globals::sm_tableVertexModelAttrId, te::graph::Vertex_Attr);
139 
140  // add property in vertex table
141  saveProperty(tableName, p);
142 }
143 
145 {
147 
148  std::string propertyName = p->getName();
149 
151 
152  //get data set
153  std::string tableName = this->getVertexTableName();
154 
155  //remove property
156  removeProperty(tableName, propertyName);
157 }
158 
160 {
161  if(this->getStorageMode() == te::graph::Vertex_List)
162  {
163  throw Exception(TE_TR("TO DO."));
164  }
165 
167 
168  //get data set
169  std::string tableName = this->getEdgeTableName();
170 
171  // add attribute entry in graph attr table
172  saveGraphAttrTableNewEntry(this->getId(), tableName, p->getName(), Globals::sm_tableEdgeModelAttrId, te::graph::Edge_Attr);
173 
174  // add property in edge table
175  saveProperty(tableName, p);
176 }
177 
179 {
181 
182  std::string propertyName = p->getName();
183 
185 
186  //get data set
187  std::string tableName = this->getEdgeTableName();
188 
189  //remove property
190  removeProperty(tableName, propertyName);
191 }
192 
194 {
196 
197  //first property: id
199  prop_id->setAutoNumber(true);
200  dt->add(prop_id);
201 
202  //second property: name
204  prop_name->setSize(32);
205  dt->add(prop_name);
206 
207  //third property: type
209  dt->add(prop_type);
210 
211  //fourth property: table name
213  prop_tableName->setSize(32);
214  dt->add(prop_tableName);
215 
216  //fifth property: description
218  prop_desc->setSize(128);
219  dt->add(prop_desc);
220 
221  //define a primary key
222  std::string pkName = Globals::sm_tableGraphName;
223  pkName += "_pk";
224 
225  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
226  pk->add(prop_id);
227 
228  //create index
229  std::string idxName = Globals::sm_tableGraphAttrId;
230  idxName += "_idx";
231  te::da::Index* index = new te::da::Index(idxName, te::da::B_TREE_TYPE, dt);
232  index->add(prop_id);
233 
234  createTable(Globals::sm_tableGraphName, dt);
235 }
236 
238 {
240 
241  //first property: id
243  prop_id->setAutoNumber(true);
244  dt->add(prop_id);
245 
246  //second property: id
248  dt->add(prop_graphId);
249 
250  //third property: table
252  prop_table->setSize(32);
253  dt->add(prop_table);
254 
255  //fourth property: column
257  prop_column->setSize(32);
258  dt->add(prop_column);
259 
260  //fifth property: link name
262  prop_link->setSize(32);
263  dt->add(prop_link);
264 
265  //sixth property: type
267  dt->add(prop_type);
268 
269  //define a primary key
270  std::string pkName = Globals::sm_tableAttributeName;
271  pkName += "_pk";
272 
273  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
274  pk->add(prop_id);
275 
276  //create index
277  std::string idxName = Globals::sm_tableAttributeAttrId;
278  idxName += "_attr_idx";
279  te::da::Index* index = new te::da::Index(idxName, te::da::B_TREE_TYPE, dt);
280  index->add(prop_id);
281 
282  createTable(Globals::sm_tableAttributeName, dt);
283 }
284 
286 {
287  throw Exception(TE_TR("TO DO."));
288 }
289 
291 {
292  std::string tableName = this->getName() + Globals::sm_tableEdgeModelSufixName;
293 
294  te::da::DataSetType* dt = new te::da::DataSetType(tableName);
295 
296  //first property: id
298  prop_edgeId->setAutoNumber(true);
299  dt->add(prop_edgeId);
300 
301  //second property: id
303  dt->add(prop_vFrom);
304 
305  //third property: id
307  dt->add(prop_vTo);
308 
309  //add edge properties
310  te::gm::GeometryProperty* geomProp = 0;
311 
312  if(getEdgePropertySize() != 0)
313  {
314  for(int i = 0; i < getEdgePropertySize(); ++i)
315  {
316  te::dt::Property* p = getEdgeProperty(i)->clone();
317  p->setParent(0);
318 
319  dt->add(p);
320 
321  if(p->getType() == te::dt::GEOMETRY_TYPE)
322  {
323  geomProp = (te::gm::GeometryProperty*)p;
324  }
325  }
326  }
327 
328  //define a primary key
329  std::string pkName = tableName;
330  pkName += "_pk";
331 
332  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
333  pk->add(prop_edgeId);
334 
335  //create index
336  std::string idxEdge = tableName;
337  idxEdge += "_edge_idx";
338  te::da::Index* indexEdge = new te::da::Index(idxEdge, te::da::B_TREE_TYPE, dt);
339  indexEdge->add(prop_edgeId);
340 
341  std::string idxVFrom = tableName;
342  idxVFrom += "_vfrom_idx";
343  te::da::Index* indexVFrom = new te::da::Index(idxVFrom, te::da::B_TREE_TYPE, dt);
344  indexVFrom->add(prop_vFrom);
345 
346  std::string idxVTo = tableName;
347  idxVTo += "_vto_idx";
348  te::da::Index* indexVTo = new te::da::Index(idxVTo, te::da::B_TREE_TYPE, dt);
349  indexVTo->add(prop_vTo);
350 
351  //create spatial index
352  if(geomProp)
353  {
354  std::string idxSpatial = tableName;
355  idxSpatial += "_spatial_idx";
356  te::da::Index* idx = new te::da::Index(idxSpatial, te::da::R_TREE_TYPE, dt);
357  idx->add((te::dt::Property*)geomProp);
358  }
359 
360  createTable(tableName, dt);
361 }
362 
364 {
365  std::string tableName = this->getName() + Globals::sm_tableVertexAttributeModelSufixName;
366 
367  te::da::DataSetType* dt = new te::da::DataSetType(tableName);
368 
369  //first property: id
371  prop_Id->setAutoNumber(true);
372  dt->add(prop_Id);
373 
374  te::gm::GeometryProperty* geomProp = 0;
375 
376  if(getVertexPropertySize() != 0)
377  {
378  for(int i = 0; i < getVertexPropertySize(); ++i)
379  {
380  te::dt::Property* p = getVertexProperty(i)->clone();
381  p->setParent(0);
382 
383  dt->add(p);
384 
385  if(p->getType() == te::dt::GEOMETRY_TYPE)
386  {
387  geomProp = (te::gm::GeometryProperty*)p;
388  }
389  }
390  }
391 
392  //define a primary key
393  std::string pkName = tableName;
394  pkName += "_pk";
395  te::da::PrimaryKey* pk = new te::da::PrimaryKey(pkName, dt);
396  pk->add(prop_Id);
397 
398  //create index
399  std::string idxName = tableName;
400  idxName += "_idx";
401  te::da::Index* index = new te::da::Index(idxName, te::da::B_TREE_TYPE, dt);
402  index->add(prop_Id);
403 
404  //create spatial index
405  if(geomProp)
406  {
407  std::string idxSpatial = tableName;
408  idxSpatial += "_spatial_idx";
409  te::da::Index* idx = new te::da::Index(idxSpatial, te::da::R_TREE_TYPE, dt);
410  idx->add((te::dt::Property*)geomProp);
411  }
412 
413  createTable(tableName, dt);
414 }
415 
417 {
418  throw Exception(TE_TR("TO DO."));
419 }
420 
422 {
423  if(m_ds->dataSetExists(tableName))
424  {
425  delete dt;
426  return;
427  }
428 
429  std::map<std::string, std::string> options;
430 
431  m_ds->createDataSet(dt, options);
432 }
433 
435 {
436  return true;
437 }
438 
440 {
441  //create the graph metadata table model
442  createGraphMetadataTable();
443 
444  //get dataset type
445  std::auto_ptr<te::da::DataSetType> dsType(m_ds->getDataSetType(Globals::sm_tableGraphName));
446 
447  std::auto_ptr<te::mem::DataSet> dsMem(new te::mem::DataSet(dsType.get()));
448 
449  //create new item
450  te::mem::DataSetItem* dsItem = new te::mem::DataSetItem(dsMem.get());
451 
452  dsItem->setString(1, this->getName());
453  dsItem->setInt32(2, (int)this->getStorageMode());
454 
455  if(this->getStorageMode() == te::graph::Edge_List)
456  {
457  dsItem->setString(3, this->getEdgeTableName());
458  }
459  else if(this->getStorageMode() == te::graph::Vertex_List)
460  {
461  dsItem->setString(3, this->getVertexTableName());
462  }
463 
464  dsItem->setString(4, this->getDescription());
465 
466  dsMem->add(dsItem);
467 
468  //add item
469  std::map<std::string, std::string> options;
470 
471  dsMem->moveBeforeFirst();
472 
473  m_ds->add(Globals::sm_tableGraphName, dsMem.get(), options);
474 
475  //clear
476  dsMem->clear();
477 
478  //update graph id
479  updateGraphId();
480 }
481 
483 {
484  createGraphAttributesTable();
485 
486  //add edge attributes
487  if(getEdgePropertySize() != 0)
488  {
489  std::string tableName = this->getEdgeTableName();
490 
491  for(int i = 0; i < getEdgePropertySize(); ++i)
492  {
493  saveGraphAttrTableNewEntry(this->getId(), tableName, getEdgeProperty(i)->getName(), Globals::sm_tableEdgeModelAttrId, te::graph::Edge_Attr);
494  }
495  }
496 
497  //add vertex attributes
498  if(getVertexPropertySize() != 0)
499  {
500  std::string tableName = this->getVertexTableName();
501 
502  for(int i = 0; i < getVertexPropertySize(); ++i)
503  {
504  saveGraphAttrTableNewEntry(this->getId(), tableName, getVertexProperty(i)->getName(), Globals::sm_tableVertexModelAttrId, te::graph::Vertex_Attr);
505  }
506  }
507 }
508 
509 void te::graph::DataSourceGraphMetadata::saveGraphAttrTableNewEntry(int graphId, std::string tableName, std::string attrName, std::string linkColumn, te::graph::GraphAttrType type)
510 {
511  //get dataset type
512  std::auto_ptr<te::da::DataSetType> dsType(m_ds->getDataSetType(Globals::sm_tableAttributeName));
513 
514  std::auto_ptr<te::mem::DataSet> dsMem(new te::mem::DataSet(dsType.get()));
515 
516  //create datase item
517  te::mem::DataSetItem* dsItem = new te::mem::DataSetItem(dsMem.get());
518 
519  dsItem->setInt32(0, graphId);
520  dsItem->setString(1, tableName);
521  dsItem->setString(2, te::common::Convert2LCase(attrName));
522  dsItem->setString(3, te::common::Convert2LCase(linkColumn));
523  dsItem->setInt32(4, type);
524 
525  //add item
526  std::map<std::string, std::string> options;
527 
528  m_ds->add(Globals::sm_tableAttributeName, dsMem.get(), options);
529 
530  //clear
531  dsMem->clear();
532 }
533 
535 {
536  //get dataset type
537  std::auto_ptr<te::da::DataSetType> dsType(m_ds->getDataSetType(tableName));
538 
539  //add property
540  m_ds->addProperty(tableName, p);
541 
542  //if property is a geometry property
543  if(p->getType() == te::dt::GEOMETRY_TYPE)
544  {
545  //create index
546  std::string idxSpatial = tableName;
547  idxSpatial += "_spatial_idx";
548  te::da::Index* idx = new te::da::Index(idxSpatial, te::da::R_TREE_TYPE, dsType.get());
549  idx->add(p);
550 
551  //add index
552  std::map<std::string, std::string> options;
553 
554  m_ds->addIndex(tableName, idx, options);
555  }
556 }
557 
558 void te::graph::DataSourceGraphMetadata::removeProperty(std::string tableName, std::string propertyName)
559 {
560  m_ds->dropProperty(tableName, propertyName);
561 }
562 
564 {
565  //load graph info
566  te::da::Field* f = new te::da::Field("*");
567  te::da::Fields* fields = new te::da::Fields;
568  fields->push_back(f);
569 
571  te::da::From* from = new te::da::From;
572  from->push_back(t);
573 
575 
577 
578  te::da::Where* filter = new te::da::Where(equal);
579 
580  te::da::Select select(fields, from, filter);
581 
582  //get dataset result
583  std::auto_ptr<te::da::DataSet> dataset = m_ds->query(select);
584 
585  if(dataset->moveNext())
586  {
587  m_id = dataset->getInt32(Globals::sm_tableGraphAttrId);
588  m_name = dataset->getString(Globals::sm_tableGraphAttrName);
589  m_description = dataset->getString(Globals::sm_tableGraphAttrDesc);
590 
591  int type = dataset->getInt32(Globals::sm_tableGraphAttrType);
592  if(type == te::graph::Edge_List)
593  {
594  m_mode = te::graph::Edge_List;
595  }
596  else if(type == te::graph::Vertex_List)
597  {
598  m_mode =te::graph::Vertex_List;
599  }
600  }
601 }
602 
604 {
605  //load attributes
606  te::da::Field* f = new te::da::Field("*");
607  te::da::Fields* fields = new te::da::Fields;
608  fields->push_back(f);
609 
611  te::da::From* from = new te::da::From;
612  from->push_back(t);
613 
615 
617 
618  te::da::Where* filter = new te::da::Where(equal);
619 
620  te::da::Select select(fields, from, filter);
621 
622  //get dataset result
623  std::auto_ptr<te::da::DataSet> dataset = m_ds->query(select);
624 
625  while(dataset->moveNext())
626  {
627  int type = dataset->getInt32(Globals::sm_tableAttributeAttrType);
628 
629  std::string tableName = dataset->getString(Globals::sm_tableAttributeAttrTable);
630  std::string columnName = dataset->getString(Globals::sm_tableAttributeAttrColumn);
631 
632  if(type == 0) // vertex attribute
633  {
634  loadVertexAttr(tableName, columnName);
635  }
636  else if(type == 1) // edge attribute
637  {
638  loadEdgeAttr(tableName, columnName);
639  }
640  }
641 }
642 
643 void te::graph::DataSourceGraphMetadata::loadVertexAttr(std::string tableName, std::string columnName)
644 {
645  //get property
646  std::auto_ptr<te::dt::Property> p = m_ds->getProperty(tableName, columnName);
647 
648  te::dt::Property* myProp = p.release();
649 
651 }
652 
653 void te::graph::DataSourceGraphMetadata::loadEdgeAttr(std::string tableName, std::string columnName)
654 {
655  //get property
656  std::auto_ptr<te::dt::Property> p = m_ds->getProperty(tableName, columnName);
657 
658  te::dt::Property* myProp = p.release();
659 
661 }
662 
664 {
666  te::da::Fields* fields = new te::da::Fields;
667  fields->push_back(f);
668 
670  te::da::From* from = new te::da::From;
671  from->push_back(t);
672 
673  te::da::LiteralString* l = new te::da::LiteralString(this->getName());
674 
676 
677  te::da::Where* filter = new te::da::Where(equal);
678 
679  te::da::Select select(fields, from, filter);
680 
681  std::auto_ptr<te::da::DataSet> dataset = m_ds->query(select);
682 
683  if(dataset->moveNext())
684  {
685  int id = dataset->getInt32(Globals::sm_tableGraphAttrId);
686 
687  m_id = id;
688  }
689 }
690 
691 /*
692  GRAPH PACKAGE - DATABASE MODEL
693 
694 -- create graph metadata table
695 
696 CREATE TABLE te_graph (
697  graph_id serial NOT NULL,
698  graph_name VARCHAR NULL,
699  graph_type INTEGER NULL,
700  graph_table_name VARCHAR NULL,
701  graph_description VARCHAR NULL,
702  PRIMARY KEY(graph_id)
703 );
704 
705 -- create graph attributes
706 
707 CREATE TABLE te_graph_attr (
708  attr_id serial NOT NULL,
709  graph_id INTEGER NOT NULL,
710  attr_table VARCHAR NULL,
711  attr_column VARCHAR NULL,
712  attr_link_column VARCHAR NULL,
713  attribute_type INTEGER NULL,
714  PRIMARY KEY(attr_id)
715 );
716 
717 
718 -- create graph table model edge list
719 
720 CREATE TABLE graph_model_edge (
721  edge_id serial NOT NULL,
722  vertex_from INT NULL,
723  vertex_to INT NULL,
724  PRIMARY KEY(edge_id)
725 );
726 
727 -- create graph table model vertex list
728 
729 CREATE TABLE graph_model_vertex (
730  vertex_id serial NOT NULL,
731  edges_in bytea NULL,
732  edges_out bytea NULL,
733  PRIMARY KEY(vertex_id)
734 );
735 
736 -- create vertex table properties
737 
738 CREATE TABLE graph_vertex_properties (
739  vertex_id serial NOT NULL,
740  geometry bytea NULL,
741  PRIMARY KEY(vertex_id)
742 );
743 
744 -- create edge table properties
745 
746 CREATE TABLE graph_edge_properties (
747  edge_id serial NOT NULL,
748  geometry bytea NULL,
749  PRIMARY KEY(edge_id)
750 );
751 
752 -- create graph algorithms table
753 
754 CREATE TABLE te_graph_algorithms (
755  algol_id serial NOT NULL,
756  name VARCHAR NULL,
757  description VARCHAR NULL,
758  PRIMARY KEY(algol_id)
759 );
760 
761 -- create graph algorithms params table
762 
763 CREATE TABLE te_graph_algorithms_params (
764  algol_id serial NOT NULL,
765  parameter_number serial NOT NULL,
766  parameter_name VARCHAR NULL,
767  parameter_description VARCHAR NULL,
768  PRIMARY KEY(algol_id, parameter_number)
769 );
770 
771 -- create the table with relation between graphs and algorithms
772 
773 CREATE TABLE graph_algorithm (
774  graph_id INTEGER NOT NULL,
775  algol_id INTEGER NOT NULL,
776  parameter_number INTEGER NOT NULL,
777  attribute_id INTEGER NOT NULL,
778  attribute_value VARCHAR NULL,
779  PRIMARY KEY(graph_id, algol_id, parameter_number, attribute_id)
780 );
781 */
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.
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...
Definition: Field.h:50
static const std::string sm_tableVertexModelAttrId
Attribute id.
Definition: Globals.h:97
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.
Definition: Globals.h:82
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:197
A class that models the name of any property of an object.
Definition: PropertyName.h:50
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
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.
virtual Property * clone() const =0
It returns a clone of the object.
void save()
Function used to save the graph information.
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.
void add(te::dt::Property *p)
It adds the property to the list of properties of the index.
Definition: Index.h:197
static const std::string sm_tableGraphAttrName
Attribute Name.
Definition: Globals.h:76
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
static const std::string sm_tableGraphName
Database Model Table Graph Name.
Definition: Globals.h:74
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.
Definition: Globals.h:83
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.
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...
Definition: DataSet.h:65
static const std::string sm_tableGraphAttrType
Attribute Type.
Definition: Globals.h:77
static const std::string sm_tableEdgeModelAttrId
Attribute Id.
Definition: Globals.h:91
void createVertexAttrTable()
Used when edge_model is selected and vertex objects has attributes associated.
static const std::string sm_tableAttributeAttrColumn
Attribute Column.
Definition: Globals.h:85
static const std::string sm_tableGraphAttrTableName
Attribute Table Name.
Definition: Globals.h:78
static const std::string sm_tableGraphAttrId
Attribute Id.
Definition: Globals.h:75
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
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.
Definition: Globals.h:86
static const std::string sm_tableGraphAttrDesc
Attribute Description.
Definition: Globals.h:79
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 getType() const
It returns the property data type.
Definition: Property.h:161
void add(Constraint *c)
It adds a new constraint.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
Definition: DataSetItem.h:56
void loadEdgeAttr(std::string tableName, std::string columnName)
Load the edge attributes.
static const std::string sm_tableAttributeName
Database Model Table Attribute Name.
Definition: Globals.h:81
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
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.
Definition: Globals.h:92
bool isValidGraphName(std::string graphName)
Verify if a graph name is valid.
static const std::string sm_tableVertexAttributeModelSufixName
Database Model Vertex Attribute Model Table Name.
Definition: Globals.h:96
void addGraphAttrTableNewEntry()
Add a new graph attributes metadata information into the SGBD.
static const std::string sm_tableEdgeModelAttrVTo
Attribute Vertex To.
Definition: Globals.h:93
static const std::string sm_tableAttributeAttrTable
Attribute Table.
Definition: Globals.h:84
static const std::string sm_tableEdgeModelSufixName
Database Model Edge Model Table Name.
Definition: Globals.h:89
void createGraphMetadataTable()
Function used to create the graph metadata tables in a SGBD.
It describes an index associated to a DataSetType.
Definition: Index.h:54
virtual void addEdgeProperty(te::dt::Property *p)
Add a new property associated to the edge element.
GraphAttrType
Definition: Enums.h:61
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.
Definition: Globals.h:87
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