27 #include "../core/translator/Translator.h" 28 #include "../dataaccess/dataset/DataSetType.h" 29 #include "../dataaccess/dataset/PrimaryKey.h" 30 #include "../datatype/DateTimePeriod.h" 76 return std::unique_ptr<te::da::DataSet>(
ds);
80 const std::string& propertyName,
90 throw Exception(
"Not supported by ST In-Memory driver!");
91 return std::unique_ptr<te::da::DataSet>(ds->
filter(e, r));
95 const std::string& propertyName,
105 throw Exception(
"Not supported by ST In-Memory driver!");
106 return std::unique_ptr<te::da::DataSet>(ds->
filter(g, r));
113 return std::unique_ptr<te::da::DataSet>();
121 return std::unique_ptr<te::da::DataSet>();
134 std::unique_ptr<te::da::PreparedQuery>
137 return std::unique_ptr<te::da::PreparedQuery> ();
140 std::unique_ptr<te::da::BatchExecutor>
143 return std::unique_ptr<te::da::BatchExecutor> ();
163 std::map<std::string, DataSet*>::const_iterator it =
m_ds->
m_datasets.find(datasetName);
176 std::vector<std::string> result;
177 std::map<std::string, DataSet*>::const_iterator it =
m_ds->
m_datasets.begin();
180 result.push_back(it->first);
199 boost::ptr_vector<te::dt::Property> properties;
203 const std::size_t np = type->
size();
205 for(std::size_t i = 0; i != np; ++i)
211 std::unique_ptr<te::dt::Property>
219 std::unique_ptr<te::dt::Property>
224 return std::unique_ptr<te::dt::Property>(type->
getProperty(propertyPos)->
clone());
229 std::vector<std::string> propertyNames;
233 const std::size_t np = type->
size();
235 for(std::size_t i = 0; i != np; ++i)
238 return propertyNames;
307 std::unique_ptr<te::da::ForeignKey>
310 return std::unique_ptr<te::da::ForeignKey>();
315 return std::vector<std::string>();
335 return std::unique_ptr<te::da::UniqueKey>();
340 return std::vector<std::string>(0);
360 return std::unique_ptr<te::da::CheckConstraint>();
365 return std::vector<std::string>();
385 return std::unique_ptr<te::da::Index>();
390 return std::vector<std::string>(0);
399 const std::map<std::string, std::string>& )
411 return std::unique_ptr<te::da::Sequence>();
416 return std::vector<std::string>(0);
435 const std::string& propertyName)
440 throw Exception(
"Not supported by ST In-Memory driver!");
446 std::size_t propertyPos)
450 throw Exception(
"Not supported by ST In-Memory driver!");
468 std::map<std::string, DataSet*>::const_iterator it =
m_ds->
m_datasets.find(name);
481 const std::map<std::string, std::string>& )
489 std::map<std::string, te::da::DataSetType*>::iterator itdt =
m_ds->
m_schemas.find(name);
491 throw Exception(
"There is not a DataSetType with the given name!");
493 std::map<std::string, DataSet*>::iterator itds =
m_ds->
m_datasets.find(name);
495 throw Exception(
"There is not a DataSet with the given name!");
497 delete(itdt->second);
498 delete(itds->second);
507 throw Exception(
"The is already a DataSet with the new name!");
509 std::map<std::string, te::da::DataSetType*>::iterator itdt =
m_ds->
m_schemas.find(name);
511 throw Exception(
"There is not a DataSetType with the given name!");
513 std::map<std::string, DataSet*>::iterator itds =
m_ds->
m_datasets.find(name);
515 throw Exception(
"There is not a DataSet with the given name!");
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));
534 const std::map<std::string, std::string>& ,
548 const std::vector<std::size_t>& ,
550 const std::map<std::string, std::string>& ,
570 throw Exception(
"There is already a DataSet with the new name!");
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));
583 return std::unique_ptr<te::da::DataSet>(ds->
filter(dt, r));
593 return std::unique_ptr<te::da::DataSet>(ds->
filter(g, sr, dt, tr));
603 return std::unique_ptr<te::da::DataSet>(ds->
filter(e, sr, dt, tr));
606 std::unique_ptr<te::dt::DateTimePeriod>
616 std::map<std::string, te::da::DataSetType*>::const_iterator it =
m_ds->
m_schemas.find(datasetName);
618 throw Exception(
"There is not a DataSetType with the given name!");
624 std::map<std::string, DataSet*>::const_iterator it =
m_ds->
m_datasets.find(datasetName);
626 throw Exception(
"There is not a DataSet with the given name!");
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.
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.
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.
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.
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...
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.
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.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
It describes a unique key (uk) constraint.
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.
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.
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.
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.
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.