9 #include "RelationalAccess/ISchema.h"
10 #include "RelationalAccess/ITable.h"
11 #include "RelationalAccess/IQuery.h"
12 #include "RelationalAccess/ICursor.h"
13 #include "RelationalAccess/TableDescription.h"
14 #include "RelationalAccess/ITablePrivilegeManager.h"
15 #include "RelationalAccess/ITableDataEditor.h"
16 #include "RelationalAccess/IBulkOperation.h"
17 #include "CoralBase/Attribute.h"
57 return schema().existsTable( tableName() );
61 if(
schema().existsTable( tableName() )){
62 throwException(
"POOL database main table already exists in this schema.",
63 "PoolMainTable::create");
65 throwException(
"POOL database cannot be created.",
"PoolMainTable::create");
69 schema().dropIfExistsTable( tableName() );
102 coral::AttributeList insertData;
103 insertData.extend<
std::string>(sequenceNameColumn());
104 insertData.extend<
int>(sequenceValueColumn());
105 coral::AttributeList::iterator iAttribute = insertData.begin();
108 iAttribute->data<
int >() = 0;
109 schema().tableHandle( tableName() ).dataEditor().insertRow( insertData );
117 throwException(
"Sequence Table handle has not been initialized.",
"PoolSequenceTable::getLastId");
121 std::map<std::string,PoolDbCacheData*>& seq = m_dbCache->sequences();
122 std::map<std::string,PoolDbCacheData*>::iterator iS = seq.find( sequenceName );
123 if( iS != seq.end()){
124 if( iS->second->m_nobjWr == 0 )
return false;
125 lastId = iS->second->m_nobjWr-1;
130 std::auto_ptr< coral::IQuery >
query(
schema().tableHandle( tableName() ).newQuery() );
131 query->limitReturnedRows( 1, 0 );
132 query->addToOutputList( sequenceValueColumn() );
133 query->defineOutputType( sequenceValueColumn(), coral::AttributeSpecification::typeNameForType<int>() );
134 query->setForUpdate();
135 std::string whereClause( sequenceNameColumn() +
" = :" + sequenceNameColumn() );
136 coral::AttributeList rowData;
138 rowData.begin()->data<
std::string >() = sequenceName;
139 query->setCondition( whereClause, rowData );
140 coral::ICursor& cursor = query->execute();
141 if ( cursor.next() ) {
142 lastId = cursor.currentRow().begin()->data<
int >();
151 throwException(
"Sequence Table handle has not been initialized.",
"PoolSequenceTable::sinchronize");
154 std::map<std::string,PoolDbCacheData*>& seq = m_dbCache->sequences();
155 std::map<std::string,PoolDbCacheData*>::iterator iS = seq.find( sequenceName );
156 if( iS != seq.end()){
157 iS->second->m_nobjWr = lastValue+1;
161 coral::AttributeList updateData;
162 updateData.extend<
std::string>(sequenceNameColumn());
163 updateData.extend<
int>(sequenceValueColumn());
164 std::string setClause( sequenceValueColumn() +
" = :" + sequenceValueColumn() );
165 std::string whereClause( sequenceNameColumn() +
" = :" + sequenceNameColumn() );
167 coral::AttributeList::iterator iAttribute = updateData.begin();
170 iAttribute->data<
int >() = lastValue;
171 schema().tableHandle( tableName() ).dataEditor().updateRows( setClause,whereClause,updateData );
175 coral::AttributeList whereData;
176 whereData.extend<
std::string>(sequenceNameColumn());
177 whereData[ sequenceNameColumn() ].data<
std::string>() = sequenceName;
178 std::string whereClause( sequenceNameColumn() +
" = :" + sequenceNameColumn() );
179 schema().tableHandle( tableName() ).dataEditor().deleteRows( whereClause, whereData );
188 throwException(
"Sequence Table handle has not been initialized.",
"PoolSequenceTable::exists");
191 return schema().existsTable( tableName() );
195 if(
schema().existsTable( tableName() )){
196 throwException(
"POOL database sequence table already exists in this schema.",
197 "PoolSequenceTable::create");
199 throwException(
"POOL database cannot be created.",
"PoolSequenceTable::create");
203 schema().dropIfExistsTable( tableName() );
207 static const std::string s_table(
"POOL_OR_MAPPING_VERSIONS");
233 return schema().existsTable( tableName() );
237 if(
schema().existsTable( tableName() )){
238 throwException(
"POOL database mapping version table already exists in this schema.",
239 "PoolMappingVersionTable::create");
241 throwException(
"POOL database cannot be created.",
"PoolMappingVersionTable::create");
245 schema().dropIfExistsTable( tableName() );
249 static const std::string s_table(
"POOL_OR_MAPPING_ELEMENTS");
279 static const std::string s_col(
"VARIABLE_PAR_INDEX");
310 return schema().existsTable( tableName() );
314 if(
schema().existsTable( tableName() )){
315 throwException(
"POOL database mapping element table already exists in this schema.",
316 "PoolMappingElementTable::create");
318 throwException(
"POOL database cannot be created.",
"PoolMappingElementTable::create");
322 schema().dropIfExistsTable( tableName() );
329 m_mappingVersion(
"" ),
337 unsigned int nobjWr ):
340 m_className( className ),
341 m_mappingVersion( mappingVersion ),
350 m_name( rhs.m_name ),
351 m_className( rhs.m_className ),
352 m_mappingVersion( rhs.m_mappingVersion ),
353 m_nobjWr( rhs.m_nobjWr ){
378 std::map<int,PoolDbCacheData >::iterator iData = m_idMap.insert( std::make_pair(
id, data )).first;
380 if( iS == m_sequences.end() ){
381 throwException(
"ContainerId Sequence is empty",
"PoolDbCache::add");
383 if(
id > (
int)iS->second->m_nobjWr ){
384 iS->second->m_nobjWr = id;
396 for(std::map<int,PoolDbCacheData >::const_iterator iData = m_idMap.begin();
397 iData != m_idMap.end(); iData++ ){
398 if( iData->second.m_name == name ){
407 std::map<int,PoolDbCacheData >::iterator iC = m_idMap.find(
id );
408 if( iC == m_idMap.end() ){
409 throwException(
"Container has not been found in the cache.",
"PoolDbCache::find");
432 static const std::string s_name(
"POOL_RSS_CONTAINERS");
444 static const std::string s_column(
"CONTAINER_NAME");
449 static const std::string s_column(
"CONTAINER_TYPE");
464 static const std::string s_column(
"MAPPING_VERSION");
469 static const std::string s_column(
"NUMBER_OF_WRITTEN_OBJECTS");
474 static const std::string s_column(
"NUMBER_OF_DELETED_OBJECTS");
492 m_dbCache = &dbCache;
498 throwException(
"Container Table handle has not been initialized.",
"PoolContainerHeaderTable::getContainerData");
502 coral::ITable& containerTable =
schema().tableHandle( tableName() );
503 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
504 coral::AttributeList outputBuffer;
505 outputBuffer.extend<
int>( containerIdColumn() );
506 outputBuffer.extend<
std::string>( containerNameColumn() );
507 outputBuffer.extend<
std::string>( classNameColumn() );
508 outputBuffer.extend<
std::string>( baseMappingVersionColumn() );
509 outputBuffer.extend<
unsigned int>( numberOfWrittenObjectsColumn() );
510 outputBuffer.extend<
unsigned int>( numberOfDeletedObjectsColumn() );
511 query->defineOutput( outputBuffer );
512 query->addToOutputList( containerIdColumn() );
513 query->addToOutputList( containerNameColumn() );
514 query->addToOutputList( classNameColumn() );
515 query->addToOutputList( baseMappingVersionColumn() );
516 query->addToOutputList( numberOfWrittenObjectsColumn() );
517 query->addToOutputList( numberOfDeletedObjectsColumn() );
518 std::stringstream condition;
519 condition << containerTypeColumn()<<
" = :"<<containerTypeColumn();
520 coral::AttributeList condData;
521 condData.extend<
std::string>( containerTypeColumn() );
522 condData[ containerTypeColumn() ].data<
std::string>()=homogeneousContainerType();
523 query->setCondition( condition.str(), condData );
524 coral::ICursor& cursor =
query->execute();
525 while ( cursor.next() ) {
527 const coral::AttributeList& row = cursor.currentRow();
528 int containerId = row[ containerIdColumn() ].data<
int >() - 1;
532 unsigned int numberOfWrittenObjects = row[ numberOfWrittenObjectsColumn()].data<
unsigned int >();
533 unsigned int numberOfDeletedObjects = row[ numberOfDeletedObjectsColumn()].data<
unsigned int >();
536 numberOfWrittenObjects-numberOfDeletedObjects ) )) ;
537 m_dbCache->add( containerId,
PoolDbCacheData(containerId, containerName, className, baseMappingVersion, numberOfWrittenObjects) );
570 throwException(
"Cannot create new Containers into POOL database.",
"PoolContainerHeaderTable::addContainer");
575 throwException(
"Container Table handle has not been initialized.",
"PoolContainerHeaderTable::removeContainer");
577 m_dbCache->remove(
id );
578 std::stringstream whereClause;
579 whereClause << containerIdColumn() <<
"= :" <<containerIdColumn();
580 coral::AttributeList whereData;
581 whereData.extend<
int >( containerIdColumn() );
582 whereData.begin()->data<
int >() =
id + 1;
583 coral::ITable& containerTable =
schema().tableHandle( tableName() );
584 containerTable.dataEditor().deleteRows(whereClause.str(),whereData);
589 coral::ITable& containerTable =
schema().tableHandle( tableName() );
590 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
591 query->addToOutputList( classNameColumn() );
592 query->defineOutputType( classNameColumn() , coral::AttributeSpecification::typeNameForType<std::string>() );
593 query->addToOutputList( numberOfWrittenObjectsColumn() );
594 query->defineOutputType( numberOfWrittenObjectsColumn(), coral::AttributeSpecification::typeNameForType<unsigned int>() );
595 query->addToOutputList( numberOfDeletedObjectsColumn() );
596 query->defineOutputType( numberOfDeletedObjectsColumn(), coral::AttributeSpecification::typeNameForType<unsigned int>() );
597 std::stringstream whereClause;
598 whereClause << containerIdColumn() <<
"= :" <<containerIdColumn();
599 coral::AttributeList whereData;
600 whereData.extend<
int>( containerIdColumn() );
601 whereData.begin()->data<
int>() =
id +1 ;
602 query->setCondition( whereClause.str(), whereData );
603 query->setForUpdate();
604 coral::ICursor& cursor =
query->execute();
605 if( cursor.next() ) {
607 const coral::AttributeList& row = cursor.currentRow();
610 unsigned int numberOfWrittenObjects = row[ numberOfWrittenObjectsColumn()].data<
unsigned int >();
611 unsigned int numberOfDeletedObjects = row[ numberOfDeletedObjectsColumn()].data<
unsigned int >();
618 throwException(
"Operation not supported into POOL database.",
"PoolContainerHeaderTable::incrementNumberOfObjects");
622 throwException(
"Operation not supported into POOL database.",
"PoolContainerHeaderTable::decrementNumberOfObjects");
626 if( numberOfObjectsForContainerIds.size() ){
629 throwException(
"Container Table handle has not been initialized.",
"PoolContainerHeaderTable::updateNumberOfObjects");
632 std::stringstream whereClause;
633 whereClause << containerIdColumn() <<
" = :" <<containerIdColumn();
634 std::stringstream setClause;
635 setClause << numberOfWrittenObjectsColumn()<<
" = :"<<numberOfWrittenObjectsColumn();
636 setClause <<
" , "<< numberOfDeletedObjectsColumn()<<
" = :"<<numberOfDeletedObjectsColumn();
637 coral::AttributeList updateData;
638 updateData.extend<
unsigned int>( numberOfWrittenObjectsColumn() );
639 updateData.extend<
unsigned int>( numberOfDeletedObjectsColumn() );
640 updateData.extend<
int>( containerIdColumn() );
642 coral::ITable& containerTable =
schema().tableHandle( tableName() );
643 std::auto_ptr<coral::IBulkOperation> bulkUpdate( containerTable.dataEditor().bulkUpdateRows( setClause.str(), whereClause.str(), updateData,(int)numberOfObjectsForContainerIds.size()+1));
645 for( std::map<int,unsigned int>::const_iterator iCont = numberOfObjectsForContainerIds.begin();
646 iCont != numberOfObjectsForContainerIds.end(); ++iCont ){
649 unsigned int nwrt = contData.
m_nobjWr;
650 unsigned int ndel = nwrt-iCont->second;
652 updateData[containerIdColumn()].data<
int>() = iCont->first + 1;
653 updateData[numberOfWrittenObjectsColumn()].data<
unsigned int>() = nwrt;
654 updateData[numberOfDeletedObjectsColumn()].data<
unsigned int>() = ndel;
655 bulkUpdate->processNextIteration();
667 return schema().existsTable( tableName() );
671 if(
schema().existsTable( tableName() )){
672 throwException(
"POOL database container header table already exists in this schema.",
673 "PoolContainerHeaderTable::create");
675 throwException(
"POOL database cannot be created.",
"PoolContainerHeaderTable::create");
679 schema().dropIfExistsTable( tableName() );
683 static const std::string s_table(
"POOL_OR_CLASS_VERSIONS");
715 return schema().existsTable( tableName() );
719 if(
schema().existsTable( tableName() )){
720 throwException(
"POOL database class version table already exists in this schema.",
721 "PoolClassVersionTable::create");
723 throwException(
"POOL database cannot be created.",
"PoolClassVersionTable::create");
727 schema().dropIfExistsTable( tableName() );
737 size_t ind = variableName.find(
"pool::PVector");
738 if( ind != std::string::npos ){
739 return "ora::PVector"+variableName.substr(13);
751 m_schema( dbSchema ),
759 m_dbCache = &dbCache;
766 coral::ICursor& cursor =
query->execute();
767 while ( cursor.next() ) {
769 const coral::AttributeList& currentRow = cursor.currentRow();
771 dest.insert( mappingVersion );
779 std::map<std::string, std::vector<MappingRawElement> >::const_iterator iSc = elementsByScope.find( scope );
780 if( iSc != elementsByScope.end() ){
781 for( std::vector<MappingRawElement>::const_iterator iMap = iSc->second.begin();
782 iMap != iSc->second.end(); ++iMap ){
784 elem.
scopeName = extraScope+
"::"+iMap->scopeName;
786 rebuildPoolMapping( scope+
"::"+iMap->variableName, extraScope, elementsByScope, dest, counter );
796 std::auto_ptr<coral::IQuery>
query(mappingTable.newQuery());
797 coral::AttributeList outputBuffer;
804 query->defineOutput( outputBuffer );
811 std::ostringstream condition;
813 coral::AttributeList condData;
815 coral::AttributeList::iterator iAttribute = condData.begin();
817 query->setCondition( condition.str(), condData );
822 coral::ICursor& cursor =
query->execute();
823 std::set<std::string> topElements;
824 std::map<std::string,MappingRawElement> elementsByVarName;
825 while ( cursor.next() ) {
827 const coral::AttributeList& currentRow = cursor.currentRow();
831 std::map<std::string,MappingRawElement>::iterator iE = elementsByVarName.find( elemId );
832 if( iE == elementsByVarName.end() ) {
833 iE = elementsByVarName.insert( std::make_pair( elemId,
MappingRawElement())).first;
842 if( topElements.find( elemId ) == topElements.end() ){
843 topElements.insert( elemId );
851 std::map<std::string, std::vector<MappingRawElement> > elementsByScope;
852 for( std::map<std::string,MappingRawElement>::iterator iEl = elementsByVarName.begin();
853 iEl != elementsByVarName.end(); ++iEl ){
855 std::vector<std::string> reverseCols;
856 for( std::vector<std::string>::reverse_iterator iR = iEl->second.columns.rbegin();
857 iR != iEl->second.columns.rend(); ++iR ){
858 reverseCols.push_back( *iR );
860 iEl->second.columns = reverseCols;
862 if( scope != emptyScope() ){
863 std::map<std::string, std::vector<MappingRawElement> >::iterator iS = elementsByScope.find( scope );
864 if( iS == elementsByScope.end() ){
865 elementsByScope.insert( std::make_pair( scope, std::vector<MappingRawElement>(1,iEl->second ) ));
867 iS->second.push_back( iEl->second );
873 for( std::set<std::string>::const_iterator iEl = topElements.begin();
874 iEl != topElements.end(); ++iEl ){
876 std::map<std::string,MappingRawElement>::iterator iE = elementsByVarName.find( *iEl );
883 firstElement.
scopeName = iE->second.variableName;
887 rebuildPoolMapping( iE->second.variableName, iE->second.variableName, elementsByScope, dest, eid );
895 coral::AttributeList rowBuffer;
898 mappingVersionTable.dataEditor().insertRow( rowBuffer );
902 coral::AttributeList dataBuffer;
914 for( std::map < int, MappingRawElement >::const_iterator iElem = mapping.
elements.begin();
915 iElem != mapping.
elements.end(); iElem++ ){
916 for(
size_t iParamIndex = 0; iParamIndex < iElem->second.columns.size(); iParamIndex++ ){
917 std::stringstream elemIdx;
918 elemIdx << iElem->first;
929 mappingElementTable.dataEditor().insertRow( dataBuffer );
936 coral::AttributeList whereData;
952 std::set<std::string>&
dest,
953 bool onlyDependency ){
955 std::auto_ptr<coral::IQuery>
query( m_schema.newQuery() );
960 query->setDistinct();
961 std::ostringstream condition;
965 coral::AttributeList condData;
968 if( onlyDependency ){
973 query->setCondition(condition.str(),condData);
974 coral::ICursor& cursor =
query->execute();
975 while ( cursor.next() ) {
977 const coral::AttributeList& currentRow = cursor.currentRow();
979 dest.insert( mappingVersion );
986 std::set<std::string>& ){
996 std::auto_ptr<coral::IQuery>
query( classVersionTable.newQuery() );
997 query->setDistinct();
999 std::ostringstream condition;
1001 coral::AttributeList condData;
1004 query->setCondition(condition.str(),condData);
1005 coral::ICursor& cursor =
query->execute();
1006 while ( cursor.next() ) {
1008 const coral::AttributeList& currentRow = cursor.currentRow();
1010 destination.insert( classVersion );
1016 std::map<std::string,std::string>& versionMap ){
1019 std::auto_ptr<coral::IQuery>
query( m_schema.newQuery() );
1024 query->setDistinct();
1025 std::ostringstream condition;
1028 coral::AttributeList condData;
1031 query->setCondition(condition.str(),condData);
1032 coral::ICursor& cursor =
query->execute();
1033 while ( cursor.next() ) {
1035 const coral::AttributeList& currentRow = cursor.currentRow();
1038 versionMap.insert( std::make_pair(classVersion, mappingVersion ) );
1044 std::set<std::string>& ){
1053 destination.clear();
1056 if( !isBaseId.first ){
1057 std::auto_ptr<coral::IQuery>
query( m_schema.newQuery() );
1061 std::ostringstream condition;
1065 coral::AttributeList condData;
1068 coral::AttributeList::iterator iAttribute = condData.begin();
1071 iAttribute->data<
int >() = containerId + 1;
1072 query->setCondition( condition.str(), condData );
1073 coral::ICursor& cursor =
query->execute();
1074 while ( cursor.next() ) {
1076 const coral::AttributeList& currentRow = cursor.currentRow();
1082 if( containerData.
m_className == isBaseId.second ){
1104 throwException(
"MappingSchema handle has not been initialized.",
"PoolMappingSchema::insertClassVersion");
1113 std::string containerName = m_dbCache->nameById( containerId );
1114 coral::AttributeList::iterator iInAttr = inputData.begin();
1120 classVersionTable.dataEditor().insertRow( inputData );
1127 throwException(
"MappingSchema handle has not been initialized.",
"PoolMappingSchema::setMappingVersion");
1135 std::string containerName = m_dbCache->nameById( containerId );
1136 coral::AttributeList::iterator iInAttr = inputData.begin();
1145 classVersionTable.dataEditor().updateRows( setClause,whereClause, inputData );
1171 m_dbCache( dbCache ){
1178 int contId,
int itemId ){
1179 coral::AttributeList dataToInsert;
1180 dataToInsert.extend<
std::string>( objectNameColumn() );
1182 dataToInsert.extend<
int>( timetypeColumn());
1185 dataToInsert[ objectNameColumn() ].data<
std::string>() = name;
1186 dataToInsert[ tokenColumn() ].data<
std::string>() = token;
1187 dataToInsert[ timetypeColumn() ].data<
int>() = -1;
1188 coral::ITable& containerTable =
schema().tableHandle( tableName() );
1189 containerTable.dataEditor().insertRow( dataToInsert );
1193 coral::AttributeList whereData;
1194 whereData.extend<
std::string>( objectNameColumn() );
1196 std::string condition = objectNameColumn() +
" = :" + objectNameColumn();
1197 return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1202 coral::AttributeList whereData;
1203 return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1209 coral::ITable& containerTable =
schema().tableHandle( tableName() );
1210 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1211 coral::AttributeList outputBuffer;
1212 outputBuffer.extend<
std::string>( tokenColumn() );
1213 query->defineOutput( outputBuffer );
1214 query->addToOutputList( tokenColumn() );
1215 std::ostringstream condition;
1216 condition << objectNameColumn()<<
"= :"<< objectNameColumn();
1217 coral::AttributeList condData;
1218 condData.extend<
std::string>( objectNameColumn() );
1219 coral::AttributeList::iterator iAttribute = condData.begin();
1221 query->setCondition( condition.str(), condData );
1222 coral::ICursor& cursor =
query->execute();
1223 while ( cursor.next() ) {
1225 const coral::AttributeList& row = cursor.currentRow();
1228 destination.first = m_dbCache.idByName( tokData.first );
1229 destination.second = tokData.second;
1238 coral::ITable& containerTable =
schema().tableHandle( tableName() );
1239 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1240 coral::AttributeList outputBuffer;
1241 outputBuffer.extend<
std::string>( objectNameColumn() );
1242 query->defineOutput( outputBuffer );
1243 query->addToOutputList( objectNameColumn() );
1244 std::ostringstream condition;
1245 condition << tokenColumn()<<
"= :"<< tokenColumn();
1248 coral::AttributeList condData;
1250 coral::AttributeList::iterator iAttribute = condData.begin();
1252 query->setCondition( condition.str(), condData );
1253 coral::ICursor& cursor =
query->execute();
1254 while ( cursor.next() ) {
1256 const coral::AttributeList& row = cursor.currentRow();
1258 destination.push_back( name );
1267 coral::ITable& containerTable =
schema().tableHandle( tableName() );
1268 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1269 coral::AttributeList outputBuffer;
1270 outputBuffer.extend<
std::string>( objectNameColumn() );
1271 query->defineOutput( outputBuffer );
1272 query->addToOutputList( objectNameColumn() );
1273 std::ostringstream condition;
1274 condition << tokenColumn()<<
" LIKE :"<< tokenColumn();
1277 coral::AttributeList condData;
1279 coral::AttributeList::iterator iAttribute = condData.begin();
1280 iAttribute->data<
std::string >() = tokenFragment;
1281 query->setCondition( condition.str(), condData );
1282 coral::ICursor& cursor =
query->execute();
1283 while ( cursor.next() ) {
1285 const coral::AttributeList& row = cursor.currentRow();
1287 destination.push_back( name );
1295 coral::ITable& containerTable =
schema().tableHandle( tableName() );
1296 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1297 coral::AttributeList outputBuffer;
1298 outputBuffer.extend<
std::string>( objectNameColumn() );
1299 query->defineOutput( outputBuffer );
1300 query->addToOutputList( objectNameColumn() );
1301 coral::ICursor& cursor =
query->execute();
1302 while ( cursor.next() ) {
1304 const coral::AttributeList& row = cursor.currentRow();
1306 destination.push_back( name );
1316 return schema().existsTable( tableName() );
1320 if(
schema().existsTable( tableName() )){
1322 "CondMetadataTable::create");
1324 throwException(
"Cond Metadata table cannot be created.",
"CondMetadataTable::create");
1328 if( !
schema().existsTable( tableName() )){
1329 throwException(
"Metadata table does not exists in this schema.",
1330 "CondMetadataTable::drop");
1332 throwException(
"Cond Metadata table cannot be dropped.",
"CondMetadataTable::drop");
1342 m_schema( dbSchema ),
1344 m_mainTable( dbSchema ),
1345 m_sequenceTable( dbSchema ),
1346 m_mappingVersionTable( dbSchema ),
1347 m_mappingElementTable( dbSchema ),
1348 m_containerHeaderTable( dbSchema ),
1349 m_classVersionTable( dbSchema ),
1350 m_mappingSchema( dbSchema ),
1351 m_metadataTable( dbSchema, m_dbCache ){
1361 if(!m_mainTable.exists()){
1365 if(!m_sequenceTable.exists() ||
1366 !m_mappingVersionTable.exists() ||
1367 !m_mappingElementTable.exists() ||
1368 !m_containerHeaderTable.exists() ||
1369 !m_classVersionTable.exists()){
1371 "PoolDatabaseSchema::exists");
1373 if( !m_metadataTable.exists()){
1375 "PoolDatabaseSchema::exists");
1381 throwException(
"POOL database cannot be created.",
"PoolDatabaseSchema::create");
1385 m_classVersionTable.drop();
1386 m_mappingElementTable.drop();
1387 m_sequenceTable.drop();
1388 m_containerHeaderTable.drop();
1389 m_mappingVersionTable.drop();
1395 m_mainTable.setAccessPermission( principal, forWrite );
1396 m_sequenceTable.setAccessPermission( principal, forWrite );
1397 m_mappingVersionTable.setAccessPermission( principal, forWrite );
1398 m_mappingElementTable.setAccessPermission( principal, forWrite );
1399 m_containerHeaderTable.setAccessPermission( principal, forWrite );
1400 m_classVersionTable.setAccessPermission( principal, forWrite );
1401 m_metadataTable.setAccessPermission( principal, forWrite );
1409 return m_sequenceTable;
1413 return m_mappingVersionTable;
1417 return m_mappingElementTable;
1421 return m_containerHeaderTable;
1425 return m_classVersionTable;
1429 return m_mappingSchema;
1433 return m_metadataTable;
static std::string versionParameterName()
IDatabaseTable & mappingElementTable()
IMappingSchema & mappingSchema()
static std::string tableName()
MappingRawElement & addElement(int elementId)
static std::string tableNameColumn()
static std::string tableName()
static std::string variableTypeColumn()
PoolDbCacheData m_mappingData
PoolMappingSchema m_mappingSchema
std::map< std::string, PoolDbCacheData * > & sequences()
static std::string dependencyMappingElementType()
Returns the name of the dependent class mapping element type.
std::pair< std::string, int > parseToken(const std::string &objectId)
PoolSequenceTable(coral::ISchema &dbSchema)
std::string mappingTypeFromPool(const std::string &mappingType)
PoolDbCacheData m_databaseData
static std::string tableName()
static std::string columnNameColumn()
PoolMappingSchema(coral::ISchema &dbSchema)
int idByName(const std::string &name)
static std::string mappingVersionColumn()
void init(PoolDbCache &dbCache)
void setAccessPermission(const std::string &principal, bool forWrite)
INamingServiceTable & namingServiceTable()
std::map< int, MappingRawElement > elements
void removeMapping(const std::string &version)
std::string writeTokenContainerFragment(const std::string &containerName, const std::string &className)
void sinchronize(const std::string &sequenceName, int lastValue)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool getClassVersionListForContainer(int containerId, std::map< std::string, std::string > &versionMap)
void add(int id, const PoolDbCacheData &data)
PoolSequenceTable m_sequenceTable
bool getContainerTableMap(std::map< std::string, int > &destination)
static std::string variableParIndexColumn()
static std::string emptyScope()
static std::string classVersionColumn()
std::string poolSchemaVersion()
IDatabaseTable & mappingVersionTable()
void create(const std::string &userSchemaVersion)
bool selectMappingVersion(const std::string &classId, int containerId, std::string &destination)
PoolMappingElementTable(coral::ISchema &dbSchema)
void setMappingVersion(const std::string &classId, int containerId, const std::string &mappingVersion)
static std::string elementIdColumn()
static std::string sequenceNameForMapping()
virtual ~PoolMappingVersionTable()
bool getMappingVersionListForContainer(int containerId, std::set< std::string > &destination, bool onlyDependency=false)
bool getMapping(const std::string &version, MappingRawData &destination)
void setParameter(const std::string ¶mName, const std::string ¶mValue)
bool containerForMappingVersion(const std::string &mappingVersion, int &destination)
static std::string emptyScope()
static bool existsMainTable(coral::ISchema &dbSchema)
static std::string version()
static std::string objectMappingElementType()
Returns the name of the object mapping element type.
PoolDbCacheData & find(int id)
bool getParameters(std::map< std::string, std::string > &destination)
PoolClassVersionTable(coral::ISchema &dbSchema)
bool getLastId(const std::string &sequenceName, int &lastId)
static std::string classVersionFromId(const std::string &classId)
static std::pair< bool, std::string > classNameFromBaseId(const std::string &classId)
static std::string sequenceNameColumn()
void rebuildPoolMapping(const std::string &scope, const std::string &extraScope, const std::map< std::string, std::vector< MappingRawElement > > &elementsByScope, ora::MappingRawData &dest, int &counter)
PoolDbCacheData & operator=(const PoolDbCacheData &rhs)
static std::string sequenceValueColumn()
virtual ~PoolMappingSchema()
IContainerHeaderTable & containerHeaderTable()
void init(PoolDbCache &dbCache)
PoolMappingVersionTable(coral::ISchema &dbSchema)
virtual ~PoolSequenceTable()
bool getClassVersionListForMappingVersion(const std::string &mappingVersion, std::set< std::string > &destination)
const std::string & nameById(int id)
PoolDatabaseSchema(coral::ISchema &dbSchema)
static std::string mappingVersionColumn()
PoolMainTable(coral::ISchema &dbSchema)
std::string variableNameFromPool(const std::string &variableName)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
static std::string containerNameColumn()
std::vector< std::vector< double > > tmp
std::string m_mappingVersion
char data[epos_bytes_allocation]
static std::string OraArrayMappingElementType()
Returns the name of the ORA array mapping element type.
static std::string scopeNameColumn()
static std::atomic< unsigned int > counter
PoolContainerHeaderTable m_containerHeaderTable
void storeMapping(const MappingRawData &mapping)
static std::string variableNameColumn()
bool getMappingVersionListForTable(const std::string &tableName, std::set< std::string > &destination)
static std::string sequenceNameForContainer(const std::string &containerName)
void insertClassVersion(const std::string &className, const std::string &classVersion, const std::string &classId, int dependencyIndex, int containerId, const std::string &mappingVersion)
static std::string sequenceNameForContainerId()
sequence names
bool getVersionList(std::set< std::string > &destination)
static std::string tableName()
bool add(const std::string &sequenceName)
static std::string mappingVersionColumn()
static std::string containerNameColumn()
virtual ~PoolDatabaseSchema()
IDatabaseTable & classVersionTable()
virtual ~PoolClassVersionTable()
std::string writeToken(const std::string &containerName, int oid0, int oid1, const std::string &className)
virtual ~PoolMappingElementTable()
static std::string classMappingElementType()
Returns the name of the class mapping element type.
ISequenceTable & sequenceTable()
static std::string elementTypeColumn()
std::string className(const T &t)
std::string schemaVersion()
bool getDependentClassesInContainerMapping(int containerId, std::set< std::string > &destination)
void erase(const std::string &sequenceName)
static std::string tableName()