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)
450 DataSet* ds = getData(datasetName);
452 throw Exception(
"Not supported by ST In-Memory driver!");
459 DataSet* ds = getData(datasetName);
465 return !m_ds->m_datasets.empty();
470 std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(name);
471 if(it== m_ds->m_datasets.end())
483 const std::map<std::string, std::string>& )
491 std::map<std::string, te::da::DataSetType*>::iterator itdt = m_ds->m_schemas.find(name);
492 if(itdt==m_ds->m_schemas.end())
493 throw Exception(
"There is not a DataSetType with the given name!");
495 std::map<std::string, DataSet*>::iterator itds = m_ds->m_datasets.find(name);
496 if(itds==m_ds->m_datasets.end())
497 throw Exception(
"There is not a DataSet with the given name!");
499 delete(itdt->second);
500 delete(itds->second);
501 m_ds->m_schemas.erase(itdt);
502 m_ds->m_datasets.erase(itds);
508 if(dataSetExists(newName))
509 throw Exception(
"The is already a DataSet with the new name!");
511 std::map<std::string, te::da::DataSetType*>::iterator itdt = m_ds->m_schemas.find(name);
512 if(itdt==m_ds->m_schemas.end())
513 throw Exception(
"There is not a DataSetType with the given name!");
515 std::map<std::string, DataSet*>::iterator itds = m_ds->m_datasets.find(name);
516 if(itds==m_ds->m_datasets.end())
517 throw Exception(
"There is not a DataSet with the given name!");
525 m_ds->m_schemas.erase(itdt);
526 m_ds->m_datasets.erase(itds);
528 m_ds->m_schemas.insert(std::pair<std::string, te::da::DataSetType*>(newName,dt));
529 m_ds->m_datasets.insert(std::pair<std::string, DataSet*>(newName,ds));
536 const std::map<std::string, std::string>& ,
549 const std::vector<std::size_t>& ,
551 const std::map<std::string, std::string>& ,
570 if(dataSetExists(name))
571 throw Exception(
"There is already a DataSet with the new name!");
573 m_ds->m_datasets.insert(std::pair<std::string, DataSet*>(name,d));
574 m_ds->m_schemas.insert(std::pair<std::string, te::da::DataSetType*>(name,t));
584 return std::auto_ptr<te::da::DataSet>(ds->
filter(dt, r));
594 return std::auto_ptr<te::da::DataSet>(ds->
filter(g, sr, dt, tr));
604 return std::auto_ptr<te::da::DataSet>(ds->
filter(e, sr, dt, tr));
607 std::auto_ptr<te::dt::DateTimePeriod>
617 std::map<std::string, te::da::DataSetType*>::const_iterator it = m_ds->m_schemas.find(datasetName);
618 if(it==m_ds->m_schemas.end())
619 throw Exception(
"There is not a DataSetType with the given name!");
625 std::map<std::string, DataSet*>::const_iterator it = m_ds->m_datasets.find(datasetName);
626 if(it==m_ds->m_datasets.end())
627 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.
An implementation of DataSourceTransactor class for the ST In-memory driver.
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.
Implements a DataSource that contains st memory DataSets indexed by space and time.
std::auto_ptr< te::dt::DateTimePeriod > getTemporalExtent(const std::string &name)
It returns the temporal extent associated to a DataSet.
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.
CharEncoding
Supported charsets (character encoding).
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.
bool hasDataSets()
It checks if the data source has any dataset.
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
A class that models the description of a dataset.
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.
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.
An exception class for the TerraLib ST memory driver.
DataSet * getData(const std::string &datasetName)
It returns the DataSet associated to a 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.
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.
virtual Property * clone() const =0
It returns a clone of the object.
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.
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
SpatialRelation
Spatial relations between geometric objects.
It describes a sequence (a number generator).
A class that describes a check constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
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.
std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
te::da::DataSetType * getType(const std::string &datasetName)
It returns the DataSetType associated to a given name.
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::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.
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.
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.
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 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...
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.
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
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 dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
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.
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
It describes a unique key (uk) constraint.
te::common::CharEncoding getEncoding()
It return the DataSource current encoding.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
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.
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.
std::auto_ptr< te::dt::DateTimePeriod > getTemporalExtent() const
It returns the temporal extent of the observations.
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...
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.
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.
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.
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::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.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
A Query is independent from the data source language/dialect.
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.
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::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.
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.