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"
63 throw Exception(
TE_TR(
"Data Source not defined."));
70 loadGraphAttrInfo(
id);
77 throw Exception(
TE_TR(
"Data Source not defined."));
80 if(this->getName().empty())
82 throw Exception(
TE_TR(
"Graph name not defined."));
85 if(!isValidGraphName(this->getName()))
87 throw Exception(
TE_TR(
"Invalid graph name."));
91 addGraphTableNewEntry();
94 addGraphAttrTableNewEntry();
99 createGraphTableVertexModel();
101 if(getEdgePropertySize() != 0)
103 createEdgeAttrTable();
108 createGraphTableEdgeModel();
110 if(getVertexPropertySize() != 0)
112 createVertexAttrTable();
121 throw Exception(
TE_TR(
""));
127 if(getVertexPropertySize() == 0)
129 createVertexAttrTable();
135 std::string tableName = this->getVertexTableName();
141 saveProperty(tableName, p);
148 std::string propertyName = p->
getName();
153 std::string tableName = this->getVertexTableName();
156 removeProperty(tableName, propertyName);
163 throw Exception(
TE_TR(
"TO DO."));
169 std::string tableName = this->getEdgeTableName();
175 saveProperty(tableName, p);
182 std::string propertyName = p->
getName();
187 std::string tableName = this->getEdgeTableName();
190 removeProperty(tableName, propertyName);
214 dt->
add(prop_tableName);
248 dt->
add(prop_graphId);
258 dt->
add(prop_column);
278 idxName +=
"_attr_idx";
287 throw Exception(
TE_TR(
"TO DO."));
299 dt->
add(prop_edgeId);
312 if(getEdgePropertySize() != 0)
314 for(
int i = 0; i < getEdgePropertySize(); ++i)
329 std::string pkName = tableName;
333 pk->
add(prop_edgeId);
336 std::string idxEdge = tableName;
337 idxEdge +=
"_edge_idx";
339 indexEdge->
add(prop_edgeId);
341 std::string idxVFrom = tableName;
342 idxVFrom +=
"_vfrom_idx";
344 indexVFrom->
add(prop_vFrom);
346 std::string idxVTo = tableName;
347 idxVTo +=
"_vto_idx";
349 indexVTo->
add(prop_vTo);
354 std::string idxSpatial = tableName;
355 idxSpatial +=
"_spatial_idx";
360 createTable(tableName, dt);
376 if(getVertexPropertySize() != 0)
378 for(
int i = 0; i < getVertexPropertySize(); ++i)
393 std::string pkName = tableName;
399 std::string idxName = tableName;
407 std::string idxSpatial = tableName;
408 idxSpatial +=
"_spatial_idx";
413 createTable(tableName, dt);
418 throw Exception(
TE_TR(
"TO DO."));
423 if(m_ds->dataSetExists(tableName))
429 std::map<std::string, std::string> options;
431 m_ds->createDataSet(dt, options);
442 createGraphMetadataTable();
453 dsItem->
setInt32(2, (
int)this->getStorageMode());
457 dsItem->
setString(3, this->getEdgeTableName());
461 dsItem->
setString(3, this->getVertexTableName());
464 dsItem->
setString(4, this->getDescription());
469 std::map<std::string, std::string> options;
471 dsMem->moveBeforeFirst();
484 createGraphAttributesTable();
487 if(getEdgePropertySize() != 0)
489 std::string tableName = this->getEdgeTableName();
491 for(
int i = 0; i < getEdgePropertySize(); ++i)
498 if(getVertexPropertySize() != 0)
500 std::string tableName = this->getVertexTableName();
502 for(
int i = 0; i < getVertexPropertySize(); ++i)
526 std::map<std::string, std::string> options;
537 std::auto_ptr<te::da::DataSetType> dsType(m_ds->getDataSetType(tableName));
540 m_ds->addProperty(tableName, p);
546 std::string idxSpatial = tableName;
547 idxSpatial +=
"_spatial_idx";
552 std::map<std::string, std::string> options;
554 m_ds->addIndex(tableName, idx, options);
560 m_ds->dropProperty(tableName, propertyName);
568 fields->push_back(f);
583 std::auto_ptr<te::da::DataSet> dataset = m_ds->query(select);
585 if(dataset->moveNext())
608 fields->push_back(f);
623 std::auto_ptr<te::da::DataSet> dataset = m_ds->query(select);
625 while(dataset->moveNext())
634 loadVertexAttr(tableName, columnName);
638 loadEdgeAttr(tableName, columnName);
646 std::auto_ptr<te::dt::Property> p = m_ds->getProperty(tableName, columnName);
656 std::auto_ptr<te::dt::Property> p = m_ds->getProperty(tableName, columnName);
667 fields->push_back(f);
681 std::auto_ptr<te::da::DataSet> dataset = m_ds->query(select);
683 if(dataset->moveNext())
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
An abstract class that models a source of data in a query.
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.
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.
std::string Convert2LCase(const std::string &value)
It converts a string to lower case.
A class that models the name of any property of an object.
A class that models the description of a dataset.
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 Property * clone() const =0
It returns a clone of the object.
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.
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.
static const std::string sm_tableGraphName
Database Model Table Graph Name.
It models a property definition.
static const std::string sm_tableAttributeAttrGraphId
Attribute Graph Id.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
static const std::string sm_tableGraphAttrType
Attribute Type.
static const std::string sm_tableEdgeModelAttrId
Attribute Id.
static const std::string sm_tableAttributeAttrColumn
Attribute Column.
static const std::string sm_tableGraphAttrTableName
Attribute Table Name.
static const std::string sm_tableGraphAttrId
Attribute Id.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
A class that can be used to model a filter expression that can be applied to a query.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
static const std::string sm_tableAttributeAttrLink
Attribute Link.
static const std::string sm_tableGraphAttrDesc
Attribute Description.
A Select models a query to be used when retrieving data from a DataSource.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
int getType() const
It returns the property data type.
void add(Constraint *c)
It adds a new constraint.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
static const std::string sm_tableAttributeName
Database Model Table Attribute Name.
It describes a primary key (pk) constraint.
It models the comparison operator.
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.
static const std::string sm_tableVertexAttributeModelSufixName
Database Model Vertex Attribute Model Table Name.
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.
It describes an index associated to a DataSetType.
This class models a string Literal value.
static const std::string sm_tableAttributeAttrType
Attribute Type.
const std::string & getName() const
It returns the property name.
void setParent(Property *p)
It associate this property to the informed parent.