27 #include "../common/Translator.h"
28 #include "../dataaccess/dataset/DataSetType.h"
29 #include "../dataaccess/dataset/PrimaryKey.h"
30 #include "../datatype/DateTimePeriod.h"
78 return std::auto_ptr<te::da::DataSet>(ds);
82 const std::string& propertyName,
92 throw Exception(
"Not supported by ST In-Memory driver!");
93 return std::auto_ptr<te::da::DataSet>(ds->
filter(e, r));
97 const std::string& propertyName,
107 throw Exception(
"Not supported by ST In-Memory driver!");
108 return std::auto_ptr<te::da::DataSet>(ds->
filter(g, r));
115 return std::auto_ptr<te::da::DataSet>(0);
123 return std::auto_ptr<te::da::DataSet>(0);
136 std::auto_ptr<te::da::PreparedQuery>
139 return std::auto_ptr<te::da::PreparedQuery> (0);
142 std::auto_ptr<te::da::BatchExecutor>
145 return std::auto_ptr<te::da::BatchExecutor> (0);
165 std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(datasetName);
166 if(it==m_ds->m_datasets.end())
178 std::vector<std::string> result;
179 std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.begin();
180 if(it!=m_ds->m_datasets.end())
182 result.push_back(it->first);
190 return m_ds->m_datasets.size();
201 boost::ptr_vector<te::dt::Property> properties;
205 const std::size_t np = type->
size();
207 for(std::size_t i = 0; i != np; ++i)
213 std::auto_ptr<te::dt::Property>
221 std::auto_ptr<te::dt::Property>
226 return std::auto_ptr<te::dt::Property>(type->
getProperty(propertyPos)->
clone());
231 std::vector<std::string> propertyNames;
235 const std::size_t np = type->
size();
237 for(std::size_t i = 0; i != np; ++i)
240 return propertyNames;
309 std::auto_ptr<te::da::ForeignKey>
312 return std::auto_ptr<te::da::ForeignKey>(0);
317 return std::vector<std::string>();
337 return std::auto_ptr<te::da::UniqueKey>(0);
342 return std::vector<std::string>(0);
362 return std::auto_ptr<te::da::CheckConstraint>(0);
367 return std::vector<std::string>(0);
387 return std::auto_ptr<te::da::Index>(0);
392 return std::vector<std::string>(0);
401 const std::map<std::string, std::string>& )
413 return std::auto_ptr<te::da::Sequence>(0);
418 return std::vector<std::string>(0);
437 const std::string& propertyName)
440 DataSet* ds = getData(datasetName);
442 throw Exception(
"Not supported by ST In-Memory driver!");
448 std::size_t propertyPos)
451 DataSet* ds = getData(datasetName);
453 throw Exception(
"Not supported by ST In-Memory driver!");
460 DataSet* ds = getData(datasetName);
466 return !m_ds->m_datasets.empty();
471 std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(name);
472 if(it== m_ds->m_datasets.end())
484 const std::map<std::string, std::string>& )
492 std::map<std::string, te::da::DataSetType*>::iterator itdt = m_ds->m_schemas.find(name);
493 if(itdt==m_ds->m_schemas.end())
494 throw Exception(
"There is not a DataSetType with the given name!");
496 std::map<std::string, DataSet*>::iterator itds = m_ds->m_datasets.find(name);
497 if(itds==m_ds->m_datasets.end())
498 throw Exception(
"There is not a DataSet with the given name!");
500 delete(itdt->second);
501 delete(itds->second);
502 m_ds->m_schemas.erase(itdt);
503 m_ds->m_datasets.erase(itds);
509 if(dataSetExists(newName))
510 throw Exception(
"The is already a DataSet with the new name!");
512 std::map<std::string, te::da::DataSetType*>::iterator itdt = m_ds->m_schemas.find(name);
513 if(itdt==m_ds->m_schemas.end())
514 throw Exception(
"There is not a DataSetType with the given name!");
516 std::map<std::string, DataSet*>::iterator itds = m_ds->m_datasets.find(name);
517 if(itds==m_ds->m_datasets.end())
518 throw Exception(
"There is not a DataSet with the given name!");
526 m_ds->m_schemas.erase(itdt);
527 m_ds->m_datasets.erase(itds);
529 m_ds->m_schemas.insert(std::pair<std::string, te::da::DataSetType*>(newName,dt));
530 m_ds->m_datasets.insert(std::pair<std::string, DataSet*>(newName,ds));
537 const std::map<std::string, std::string>& ,
550 const std::vector<std::size_t>& ,
552 const std::map<std::string, std::string>& ,
571 if(dataSetExists(name))
572 throw Exception(
"There is already a DataSet with the new name!");
574 m_ds->m_datasets.insert(std::pair<std::string, DataSet*>(name,d));
575 m_ds->m_schemas.insert(std::pair<std::string, te::da::DataSetType*>(name,t));
585 return std::auto_ptr<te::da::DataSet>(ds->
filter(dt, r));
595 return std::auto_ptr<te::da::DataSet>(ds->
filter(g, sr, dt, tr));
605 return std::auto_ptr<te::da::DataSet>(ds->
filter(e, sr, dt, tr));
608 std::auto_ptr<te::dt::DateTimePeriod>
618 std::map<std::string, te::da::DataSetType*>::const_iterator it = m_ds->m_schemas.find(datasetName);
619 if(it==m_ds->m_schemas.end())
620 throw Exception(
"There is not a DataSetType with the given name!");
626 std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(datasetName);
627 if(it==m_ds->m_datasets.end())
628 throw Exception(
"There is not a DataSet with the given name!");
std::auto_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.
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. A dataset can be connected or disconnected. A connected dataset, after its creation through the data source transactor, continues to depend on the connection given by its associated data source. Differently, a disconnected dataset, after its creation, no more depends of the connection given by the data source, and it continues to live after the connection has been released to the data source.
std::auto_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 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.
It describes an index associated to a DataSetType.
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
bool hasDataSets()
It checks if the data source has any dataset.
Property * getProperty(std::size_t i) const
It returns the i-th property.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
void cancel()
It requests that the data source stop the processing of the current command.
std::auto_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.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
Implementation of a in-memory data set that contains spatiotemporal observations indexed by time and ...
int getGeomPropIdx() const
It returns the index of the property that contains the observed geometries.
A Select models a query to be used when retrieving data from a DataSource.
std::auto_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.
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
An exception class for the TerraLib ST memory driver.
void begin()
It starts a new transaction.
It describes a primary key (pk) constraint.
std::auto_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::auto_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 dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
const std::string & getName() const
It returns the property name.
void add(Constraint *c)
It adds a new constraint.
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
It describes a sequence (a number generator).
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
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.
Constraint * clone()
It returns a clone of the object.
SpatialRelation
Spatial relations between geometric objects.
It models a foreign key constraint for a DataSetType.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
DataSet * getData(const std::string &datasetName)
It returns the DataSet associated to a given name.
DataSource * getSTMemDataSource() const
It returns its associated ST In-Memory DataSource.
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
void setName(const std::string &name)
It sets the property name.
AccessPolicy
Supported data access policies (can be used as bitfield).
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.
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
An implementation of DataSourceTransactor class for the ST In-memory driver.
void commit()
It commits the transaction.
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
A Query is independent from the data source language/dialect.
Transactor(DataSource *parent)
It constructs a Transactor.
std::auto_ptr< te::dt::DateTimePeriod > getTemporalExtent() const
It returns the temporal extent of the observations.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
TemporalRelation
Temporal relations between date and time (Source: Allen, 1991).
std::size_t getPropertyPosition(const std::string &name) const
It returns the property position based on its name.
It describes a unique key (uk) constraint.
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
void optimize(const std::map< std::string, std::string > &opInfo)
For some data access drivers, this method will perform some operations to optimize the data storage...
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.
virtual const std::string & getName() const
It returns the constraint name.
void add(const std::string &datasetName, te::da::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 renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
Implements a DataSource that contains In-Memory DataSets indexed by space and time.
TraverseType
A dataset can be traversed in two ways:
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
A class that models the description of a dataset.
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
It models a property definition.
std::auto_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
Property * clone() const
It returns a clone of the object.
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
std::size_t size() const
It returns the collection size, if it is known.
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
A class that describes a check constraint.
An Envelope defines a 2D rectangular region.
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
std::auto_ptr< te::dt::DateTimePeriod > getTemporalExtent(const std::string &name)
It returns the temporal extent associated to a DataSet.
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
te::da::DataSetType * getType(const std::string &datasetName)
It returns the DataSetType associated to a given name.
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.
virtual Property * clone() const =0
It returns a clone of the object.
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
~Transactor()
It constructs a Transactor.
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
A dataset is the unit of information manipulated by the data access module of TerraLib.
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 addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
std::auto_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.
Implementation of an in-memory data set that contains spatiotemporal observations indexed by time and...
Implements a DataSource that contains st memory DataSets indexed by space and time.
std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.