It represents the system catalog of a DataSource. More...
#include <DataSourceCatalog.h>
Classes | |
struct | dataset_name_cmp |
struct | sequence_name_cmp |
Public Member Functions | |
Basic Methods | |
Basic methods for a DataSourceCatalog. | |
DataSourceCatalog () | |
It creates a new DataSourceCatalog. More... | |
~DataSourceCatalog () | |
Destructor. More... | |
unsigned int | getId () const |
It returns the catalog identifier. More... | |
void | setId (unsigned int id) |
It sets the catalog identifier. More... | |
DataSource * | getDataSource () const |
It returns the DataSource associated to the catalog. More... | |
void | setDataSource (DataSource *ds) |
It sets the DataSource associated to the catalog. More... | |
void | clear () |
It clears the catalog, releasing all the resources used by it. More... | |
DataSetType Management Methods | |
Methods for managing DataSetTypes. | |
std::size_t | getNumberOfDataSets () const |
It returns the number of datasets in the catalog. More... | |
bool | datasetExists (const std::string &name) const |
It checks if a dataset schema with the given name is in the catalog. More... | |
void | add (const DataSetTypePtr &dt) |
It adds a new dataset schema to the catalog. More... | |
void | remove (DataSetType *dt, const bool cascade=false) |
It removes the dataset schema from the catalog. More... | |
void | rename (DataSetType *dt, const std::string &newName) |
It renames the dataset schema in the catalog. More... | |
const DataSetTypePtr & | getDataSetType (std::size_t i) const |
It returns the i-th dataset schema. More... | |
const DataSetTypePtr & | getDataSetType (const std::string &name) const |
It searches for a dataset schema with the given name in the catalog. More... | |
Sequence Management Methods | |
Methods for managing Sequences. | |
std::size_t | getNumberOfSequences () const |
It returns the number of sequences in the catalog. More... | |
void | add (Sequence *s) |
It adds a new sequence to the catalog. More... | |
void | remove (Sequence *s) |
It removes the sequence from the catalog. More... | |
void | detach (Sequence *s) |
It will detaches the Sequence from the catalog. More... | |
Sequence * | getSequence (std::size_t i) const |
It returns the i-th Sequence. More... | |
Sequence * | getSequence (const std::string &name) const |
It searches for a Sequence with the given name in the catalog. More... | |
Helper Methods | |
Methods used to keep the associations among catalog's objects. | |
void | addRef (ForeignKey *fk) |
It checks if the referenced DataSetType is in the catalog and associate the fk to it. More... | |
void | removeRef (ForeignKey *fk) |
It drops the reference between the foreign key and its referenced DataSetType. More... | |
std::pair< std::multimap < DataSetType *, ForeignKey * > ::const_iterator, std::multimap< DataSetType *, ForeignKey * > ::const_iterator > | getRefFK (DataSetType *dt) const |
It returns the list of fk referencing the given DataSetType in the catalog. More... | |
void | dropDependentSequences (te::dt::Property *p) |
It drops Sequences that depends on the property. More... | |
Protected Member Functions | |
Helper Methods for Sequences | |
Methods used in the internals of DataSourceCatalog to manage Sequences. | |
void | checkSequenceDependency (Sequence *s) const |
It checks if the Sequence is owned by a DataSetType property and if that DataSetType is in the catalog. More... | |
void | indexSequenceDependency (Sequence *s) |
It looks if the sequence is owned by a given DataSetType property and insert this information into the sequence depency index. More... | |
void | dropDependentSequences (DataSetType *dt) |
It drops Sequences that depends on the DataSetType dt. More... | |
void | dropDependentSequenceEntry (Sequence *s) |
It drops the Sequence entry in the DataSetType sequence dependency list. More... | |
Helper Methods for Foreign Keys | |
Methods used in the internals of DataSourceCatalog to manage Foreign Keys. | |
void | checkFKsDependency (DataSetType *dt) const |
It checks if the DataSetTypes referenced by dt's foreign keys are in the catalog. More... | |
void | indexFKs (DataSetType *dt) |
It looks for foreign keys in the DataSetType dt and try to index then with respect to referenced DataSetTypes. More... | |
void | dropDependentFKs (DataSetType *dt) |
It drops foreign keys from other DataSetTypes that depends on the attributes in the given DataSetType dt. More... | |
Private Types | |
typedef boost::multi_index::multi_index_container < DataSetTypePtr, boost::multi_index::indexed_by < boost::multi_index::ordered_unique < dataset_name_cmp > , boost::multi_index::random_access<> > > | dataset_idx_type |
typedef boost::multi_index::multi_index_container < Sequence *, boost::multi_index::indexed_by < boost::multi_index::ordered_unique < sequence_name_cmp > , boost::multi_index::random_access<> > > | sequence_idx_type |
Private Attributes | |
dataset_idx_type | m_datasets |
std::multimap< DataSetType *, ForeignKey * > | m_dependentFkIdx |
A multimap : datasettype -> fk. It tells for a DataSetType the list of fk referencing it. More... | |
DataSource * | m_ds |
The DataSource associated to the Catalog. More... | |
unsigned int | m_id |
An identification number inside the DataSource. More... | |
std::multimap< DataSetType *, sequence_idx_type::iterator > | m_seqFTIdx |
A multimap : owner-dt -> sequence-it. More... | |
sequence_idx_type | m_sequences |
Static Private Attributes | |
static DataSetTypePtr | sm_nullds |
It represents the system catalog of a DataSource.
Definition at line 68 of file DataSourceCatalog.h.
|
private |
Definition at line 459 of file DataSourceCatalog.h.
|
private |
Definition at line 474 of file DataSourceCatalog.h.
te::da::DataSourceCatalog::DataSourceCatalog | ( | ) |
It creates a new DataSourceCatalog.
Definition at line 46 of file DataSourceCatalog.cpp.
te::da::DataSourceCatalog::~DataSourceCatalog | ( | ) |
Destructor.
Definition at line 52 of file DataSourceCatalog.cpp.
References te::common::FreeContents().
void te::da::DataSourceCatalog::add | ( | const DataSetTypePtr & | dt | ) |
It adds a new dataset schema to the catalog.
dt | The dataset schema to be added to the catalog. |
Exception | It throws an exception if the dataset schema can not be added. |
Definition at line 79 of file DataSourceCatalog.cpp.
References TE_TR.
Referenced by te::da::Sequence::Sequence().
void te::da::DataSourceCatalog::add | ( | Sequence * | s | ) |
It adds a new sequence to the catalog.
s | The sequence to be added to the catalog. |
Exception | It throws an exception if the sequence can not be added. |
Exception | It throws an exception if the sequence is owned by a given DataSetType property and this DataSetType is not in the catalog. |
Definition at line 178 of file DataSourceCatalog.cpp.
References te::da::Sequence::getName(), te::da::Sequence::setCatalog(), and TE_TR.
void te::da::DataSourceCatalog::addRef | ( | ForeignKey * | fk | ) |
It checks if the referenced DataSetType is in the catalog and associate the fk to it.
fk | The foreign key to keep the association. |
It | throws an exception if the referenced DataSetType is not in the DataSourceCatalog. |
Definition at line 218 of file DataSourceCatalog.cpp.
References te::dt::Property::getName(), te::da::ForeignKey::getReferencedDataSetType(), and TE_TR.
|
protected |
It checks if the DataSetTypes referenced by dt's foreign keys are in the catalog.
dt | The DataSetType we are checking the foreign key dependency is ok. |
Exception | It throws an exception if one of the foreign key has a referenced FetaureType that is not in the catalog. |
Definition at line 401 of file DataSourceCatalog.cpp.
References te::da::DataSetType::getForeignKey(), te::dt::Property::getName(), te::da::DataSetType::getNumberOfForeignKeys(), te::da::ForeignKey::getReferencedDataSetType(), and TE_TR.
|
protected |
It checks if the Sequence is owned by a DataSetType property and if that DataSetType is in the catalog.
s | The Sequence we are checking the dependency of a FetaureType. |
Exception | It throws an exception if the sequence is owned by a FetaureType that is not in the catalog nor could be determined. |
Definition at line 294 of file DataSourceCatalog.cpp.
References te::dt::DATASET_TYPE, te::dt::Property::getName(), te::da::Sequence::getOwner(), te::dt::Property::getParent(), te::dt::Property::getType(), and TE_TR.
void te::da::DataSourceCatalog::clear | ( | ) |
It clears the catalog, releasing all the resources used by it.
Definition at line 57 of file DataSourceCatalog.cpp.
References te::common::FreeContents().
bool te::da::DataSourceCatalog::datasetExists | ( | const std::string & | name | ) | const |
It checks if a dataset schema with the given name is in the catalog.
name | The dataset schema name to be cheked in the catalog. |
Definition at line 72 of file DataSourceCatalog.cpp.
void te::da::DataSourceCatalog::detach | ( | Sequence * | s | ) |
It will detaches the Sequence from the catalog.
s | The Sequence to be detached from the catalog. |
Definition at line 195 of file DataSourceCatalog.cpp.
References te::da::Sequence::getName().
|
protected |
It drops foreign keys from other DataSetTypes that depends on the attributes in the given DataSetType dt.
dt | A DataSetType that belongs to the catalog. |
Definition at line 430 of file DataSourceCatalog.cpp.
References te::da::Constraint::getDataSetType(), and te::da::DataSetType::remove().
|
protected |
It drops the Sequence entry in the DataSetType sequence dependency list.
s | A Sequence to be removed from the list of dependency. |
Exception | It throws an exception if the sequence is owned by a dt and it is not in the catalog. |
Definition at line 361 of file DataSourceCatalog.cpp.
References te::dt::DATASET_TYPE, te::dt::Property::getName(), te::da::Sequence::getName(), te::da::Sequence::getOwner(), te::dt::Property::getParent(), te::dt::Property::getType(), and TE_TR.
void te::da::DataSourceCatalog::dropDependentSequences | ( | te::dt::Property * | p | ) |
It drops Sequences that depends on the property.
p | A Property that may owns a sequence in the catalog. |
Definition at line 255 of file DataSourceCatalog.cpp.
References te::dt::DATASET_TYPE, te::dt::Property::getName(), te::da::Sequence::getOwner(), te::dt::Property::getParent(), and te::dt::Property::getType().
|
protected |
It drops Sequences that depends on the DataSetType dt.
dt | A DataSetType that belongs to the catalog. |
Definition at line 342 of file DataSourceCatalog.cpp.
const te::da::DataSetTypePtr & te::da::DataSourceCatalog::getDataSetType | ( | std::size_t | i | ) | const |
It returns the i-th dataset schema.
i | The dataset schema index. |
Definition at line 157 of file DataSourceCatalog.cpp.
Referenced by te::serialize::xml::Save().
const te::da::DataSetTypePtr & te::da::DataSourceCatalog::getDataSetType | ( | const std::string & | name | ) | const |
It searches for a dataset schema with the given name in the catalog.
name | The name of the searched dataset schema. |
Definition at line 166 of file DataSourceCatalog.cpp.
|
inline |
It returns the DataSource associated to the catalog.
Definition at line 505 of file DataSourceCatalog.h.
References m_ds.
|
inline |
It returns the catalog identifier.
Definition at line 495 of file DataSourceCatalog.h.
References m_id.
|
inline |
It returns the number of datasets in the catalog.
Definition at line 515 of file DataSourceCatalog.h.
References m_datasets.
Referenced by te::serialize::xml::Save().
|
inline |
It returns the number of sequences in the catalog.
Definition at line 520 of file DataSourceCatalog.h.
References m_sequences.
|
inline |
It returns the list of fk referencing the given DataSetType in the catalog.
dt | The DataSetType we are searching for foreign keys referencing it. |
Definition at line 340 of file DataSourceCatalog.h.
te::da::Sequence * te::da::DataSourceCatalog::getSequence | ( | std::size_t | i | ) | const |
It returns the i-th Sequence.
i | The Sequence index. |
Definition at line 201 of file DataSourceCatalog.cpp.
te::da::Sequence * te::da::DataSourceCatalog::getSequence | ( | const std::string & | name | ) | const |
It searches for a Sequence with the given name in the catalog.
name | The name of the searched Sequence. |
Definition at line 208 of file DataSourceCatalog.cpp.
|
protected |
It looks for foreign keys in the DataSetType dt and try to index then with respect to referenced DataSetTypes.
dt | The DataSetType whose foreign keys will be indexed. |
Definition at line 415 of file DataSourceCatalog.cpp.
References te::da::DataSetType::getForeignKey(), te::dt::Property::getName(), te::da::DataSetType::getNumberOfForeignKeys(), and te::da::ForeignKey::getReferencedDataSetType().
|
protected |
It looks if the sequence is owned by a given DataSetType property and insert this information into the sequence depency index.
s | The sequence we want to index owner information. |
Exception | It throws an exception if the sequence is owned by a FetaureType that is not in the catalog nor could be determined. |
Definition at line 315 of file DataSourceCatalog.cpp.
References te::dt::DATASET_TYPE, te::dt::Property::getName(), te::da::Sequence::getName(), te::da::Sequence::getOwner(), te::dt::Property::getParent(), te::dt::Property::getType(), and TE_TR.
void te::da::DataSourceCatalog::remove | ( | DataSetType * | dt, |
const bool | cascade = false |
||
) |
It removes the dataset schema from the catalog.
dt | The dataset schema to be removed from the catalog. |
cascade | If true the method will remove also all objects that depends on the dataset schema (like sequences and foreign keys). |
Definition at line 100 of file DataSourceCatalog.cpp.
References te::da::DataSetType::getCatalog(), te::dt::Property::getName(), and TE_TR.
void te::da::DataSourceCatalog::remove | ( | Sequence * | s | ) |
It removes the sequence from the catalog.
s | The sequence to be removed from the catalog. |
Definition at line 189 of file DataSourceCatalog.cpp.
void te::da::DataSourceCatalog::removeRef | ( | ForeignKey * | fk | ) |
It drops the reference between the foreign key and its referenced DataSetType.
fk | The foreign key to remove the association from the catalog. |
It | throws an exception if the referenced DataSetType is not in the DataSourceCatalog. |
Definition at line 228 of file DataSourceCatalog.cpp.
References te::dt::Property::getName(), te::da::ForeignKey::getReferencedDataSetType(), and TE_TR.
void te::da::DataSourceCatalog::rename | ( | DataSetType * | dt, |
const std::string & | newName | ||
) |
It renames the dataset schema in the catalog.
dt | The dataset schema to be renamed. |
newName | The new name to be assigned to dt. |
Exception | It throws an exception if there is already a dataset schema with the new name in the catalog, or if it doesn't belong to the catalog. |
Definition at line 129 of file DataSourceCatalog.cpp.
References te::da::DataSetType::getCatalog(), te::dt::Property::getName(), and TE_TR.
|
inline |
It sets the DataSource associated to the catalog.
ds | The DataSource to be associated to the catalog. |
Definition at line 510 of file DataSourceCatalog.h.
References m_ds.
|
inline |
It sets the catalog identifier.
id | A number that can be used to identify the catalog in its DataSource. |
Definition at line 500 of file DataSourceCatalog.h.
References m_id.
|
private |
Definition at line 477 of file DataSourceCatalog.h.
Referenced by getNumberOfDataSets().
|
private |
A multimap : datasettype -> fk. It tells for a DataSetType the list of fk referencing it.
Definition at line 485 of file DataSourceCatalog.h.
|
private |
The DataSource associated to the Catalog.
Definition at line 488 of file DataSourceCatalog.h.
Referenced by getDataSource(), and setDataSource().
|
private |
An identification number inside the DataSource.
Definition at line 487 of file DataSourceCatalog.h.
|
private |
A multimap : owner-dt -> sequence-it.
Definition at line 482 of file DataSourceCatalog.h.
|
private |
Definition at line 480 of file DataSourceCatalog.h.
Referenced by getNumberOfSequences().
|
staticprivate |
Definition at line 490 of file DataSourceCatalog.h.