test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PoolDatabaseSchema.cc
Go to the documentation of this file.
3 #include "PoolDatabaseSchema.h"
4 #include "MappingRules.h"
5 #include "MappingElement.h"
6 //
7 #include <memory>
8 // externals
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"
18 
19 namespace ora {
20 }
21 
23  static const std::string s_version("POOL");
24  return s_version;
25 }
26 
28  static const std::string s_name("POOL_RSS_DB");
29  return s_name;
30 }
31 
32 ora::PoolMainTable::PoolMainTable( coral::ISchema& dbSchema ):
33  IMainTable( dbSchema ){
34 }
35 
37 }
38 
40  const std::string& ){
41 }
42 
43 bool ora::PoolMainTable::getParameters( std::map<std::string,std::string>& dest){
44  dest.insert(std::make_pair( IMainTable::versionParameterName(), version() ) );
45  return true;
46 }
47 
49  return poolSchemaVersion();
50 }
51 
53  return tableName();
54 }
55 
57  return schema().existsTable( tableName() );
58 }
59 
61  if( schema().existsTable( tableName() )){
62  throwException( "POOL database main table already exists in this schema.",
63  "PoolMainTable::create");
64  }
65  throwException( "POOL database cannot be created.","PoolMainTable::create");
66 }
67 
69  schema().dropIfExistsTable( tableName() );
70 }
71 
73  static const std::string s_name("POOL_RSS_SEQ");
74  return s_name;
75 }
76 
78  static const std::string s_column("NAME");
79  return s_column;
80 }
81 
83  static const std::string s_column("VALUE");
84  return s_column;
85 }
86 
88  ISequenceTable( schema),
89  m_dbCache( 0 ){
90 }
91 
93 }
94 
96  m_dbCache = &dbCache;
97 }
98 
99 bool
101  // Create the entry in the table if it does not exist.
102  coral::AttributeList insertData;
103  insertData.extend<std::string>(sequenceNameColumn());
104  insertData.extend<int>(sequenceValueColumn());
105  coral::AttributeList::iterator iAttribute = insertData.begin();
106  iAttribute->data< std::string >() = sequenceName;
107  ++iAttribute;
108  iAttribute->data< int >() = 0;
109  schema().tableHandle( tableName() ).dataEditor().insertRow( insertData );
110  return true;
111 }
112 
113 bool
115  int& lastId ) {
116  if(!m_dbCache){
117  throwException("Sequence Table handle has not been initialized.","PoolSequenceTable::getLastId");
118  }
119 
120  // first lookup in the cache for the built in sequences...
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;
126  return true;
127  }
128 
129  // otherwise, look up into the regular sequence table.
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;
137  rowData.extend<std::string>(sequenceNameColumn());
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 >();
143  return true;
144  }
145  return false;
146 }
147 
149  int lastValue ){
150  if(!m_dbCache){
151  throwException("Sequence Table handle has not been initialized.","PoolSequenceTable::sinchronize");
152  }
153  // nothing to do in the db if the sequence is in the cache...
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;
158  return;
159  }
160 
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() );
166  // Increment the oid in the database as well
167  coral::AttributeList::iterator iAttribute = updateData.begin();
168  iAttribute->data< std::string >() = sequenceName;
169  ++iAttribute;
170  iAttribute->data< int >() = lastValue;
171  schema().tableHandle( tableName() ).dataEditor().updateRows( setClause,whereClause,updateData );
172 }
173 
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 );
180 }
181 
183  return tableName();
184 }
185 
187  if(!m_dbCache){
188  throwException("Sequence Table handle has not been initialized.","PoolSequenceTable::exists");
189  }
190  // ????
191  return schema().existsTable( tableName() );
192 }
193 
195  if( schema().existsTable( tableName() )){
196  throwException( "POOL database sequence table already exists in this schema.",
197  "PoolSequenceTable::create");
198  }
199  throwException( "POOL database cannot be created.","PoolSequenceTable::create");
200 }
201 
203  schema().dropIfExistsTable( tableName() );
204 }
205 
207  static const std::string s_table("POOL_OR_MAPPING_VERSIONS");
208  return s_table;
209 }
210 
212  static const std::string s_col("MAPPING_VERSION");
213  return s_col;
214 }
215 
217  static const std::string s_col("CONTAINER_ID");
218  return s_col;
219 }
220 
222  IDatabaseTable( dbSchema ){
223 }
224 
226 }
227 
229  return tableName();
230 }
231 
233  return schema().existsTable( tableName() );
234 }
235 
237  if( schema().existsTable( tableName() )){
238  throwException( "POOL database mapping version table already exists in this schema.",
239  "PoolMappingVersionTable::create");
240  }
241  throwException( "POOL database cannot be created.","PoolMappingVersionTable::create");
242 }
243 
245  schema().dropIfExistsTable( tableName() );
246 }
247 
249  static const std::string s_table("POOL_OR_MAPPING_ELEMENTS");
250  return s_table;
251 }
252 
254  static const std::string s_col("MAPPING_VERSION");
255  return s_col;
256 }
257 
259  static const std::string s_col("ELEMENT_ID");
260  return s_col;
261 }
262 
264  static const std::string s_col("ELEMENT_TYPE");
265  return s_col;
266 }
267 
269  static const std::string s_col("VARIABLE_SCOPE");
270  return s_col;
271 }
272 
274  static const std::string s_col("VARIABLE_NAME");
275  return s_col;
276 }
277 
279  static const std::string s_col("VARIABLE_PAR_INDEX");
280  return s_col;
281 }
282 
284  static const std::string s_col("VARIABLE_TYPE");
285  return s_col;
286 }
287 
289  static const std::string s_col("TABLE_NAME");
290  return s_col;
291 }
292 
294  static const std::string s_col("COLUMN_NAME");
295  return s_col;
296 }
297 
299  IDatabaseTable( dbSchema ){
300 }
301 
303 }
304 
306  return tableName();
307 }
308 
310  return schema().existsTable( tableName() );
311 }
312 
314  if( schema().existsTable( tableName() )){
315  throwException( "POOL database mapping element table already exists in this schema.",
316  "PoolMappingElementTable::create");
317  }
318  throwException( "POOL database cannot be created.","PoolMappingElementTable::create");
319 }
320 
322  schema().dropIfExistsTable( tableName() );
323 }
324 
326  m_id( 0 ),
327  m_name("" ),
328  m_className("" ),
329  m_mappingVersion( "" ),
330  m_nobjWr( 0 ){
331 }
332 
334  const std::string& name,
335  const std::string& className,
336  const std::string& mappingVersion,
337  unsigned int nobjWr ):
338  m_id( id ),
339  m_name( name ),
340  m_className( className ),
341  m_mappingVersion( mappingVersion ),
342  m_nobjWr( nobjWr ){
343 }
344 
346 }
347 
349  m_id( rhs.m_id ),
350  m_name( rhs.m_name ),
351  m_className( rhs.m_className ),
352  m_mappingVersion( rhs.m_mappingVersion ),
353  m_nobjWr( rhs.m_nobjWr ){
354 }
355 
357  m_id = rhs.m_id;
358  m_name = rhs.m_name;
359  m_className = rhs.m_className;
360  m_mappingVersion = rhs.m_mappingVersion;
361  m_nobjWr = rhs.m_nobjWr;
362  return *this;
363 }
364 
366  m_databaseData(),
367  m_mappingData(),
368  m_idMap(),
369  m_sequences(){
372 }
373 
375 }
376 
378  std::map<int,PoolDbCacheData >::iterator iData = m_idMap.insert( std::make_pair( id, data )).first;
379  std::map<std::string,PoolDbCacheData*>::iterator iS = m_sequences.find( MappingRules::sequenceNameForContainerId() );
380  if( iS == m_sequences.end() ){
381  throwException( "ContainerId Sequence is empty","PoolDbCache::add");
382  }
383  if( id > (int)iS->second->m_nobjWr ){
384  iS->second->m_nobjWr = id;
385  }
386  m_sequences.insert( std::make_pair( MappingRules::sequenceNameForContainer( data.m_name ),&iData->second ) );
387 }
388 
390  PoolDbCacheData& data = find( id );
391  return data.m_name;
392 }
393 
395  int ret = -1;
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 ){
399  ret = iData->first;
400  break;
401  }
402  }
403  return ret;
404 }
405 
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");
410  }
411  return iC->second;
412 }
413 
415  std::string name = find( id ).m_name;
416  m_sequences.erase( MappingRules::sequenceNameForContainer( name ) );
417  m_idMap.erase( id );
418 }
419 
420 std::map<std::string,ora::PoolDbCacheData*>& ora::PoolDbCache::sequences(){
421  return m_sequences;
422 }
423 
425  m_sequences.clear();
426  m_idMap.clear();
427  m_sequences.insert(std::make_pair( MappingRules::sequenceNameForContainerId(), &m_databaseData ) );
428  m_sequences.insert(std::make_pair( MappingRules::sequenceNameForMapping(), &m_mappingData ) );
429 }
430 
432  static const std::string s_name("POOL_RSS_CONTAINERS");
433  return s_name;
434 }
435 
436 
438  static const std::string s_column("CONTAINER_ID");
439  return s_column;
440 }
441 
442 
444  static const std::string s_column("CONTAINER_NAME");
445  return s_column;
446 }
447 
449  static const std::string s_column("CONTAINER_TYPE");
450  return s_column;
451 }
452 
454  static const std::string s_column("TABLE_NAME");
455  return s_column;
456 }
457 
459  static const std::string s_column("CLASS_NAME");
460  return s_column;
461 }
462 
464  static const std::string s_column("MAPPING_VERSION");
465  return s_column;
466 }
467 
469  static const std::string s_column("NUMBER_OF_WRITTEN_OBJECTS");
470  return s_column;
471 }
472 
474  static const std::string s_column("NUMBER_OF_DELETED_OBJECTS");
475  return s_column;
476 }
477 
479  static const std::string s_type("Homogeneous");
480  return s_type;
481 }
482 
484  IContainerHeaderTable(dbSchema),
485  m_dbCache( 0 ){
486 }
487 
489 }
490 
492  m_dbCache = &dbCache;
493 }
494 
497  if(!m_dbCache){
498  throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::getContainerData");
499  }
500  bool ret = false;
501  m_dbCache->clear();
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() ) {
526  ret = true;
527  const coral::AttributeList& row = cursor.currentRow();
528  int containerId = row[ containerIdColumn() ].data< int >() - 1; //POOL starts counting from 1!
529  std::string containerName = row[ containerNameColumn()].data< std::string >();
530  std::string className = row[ classNameColumn()].data< std::string >();
531  std::string baseMappingVersion = row[ baseMappingVersionColumn()].data< std::string >();
532  unsigned int numberOfWrittenObjects = row[ numberOfWrittenObjectsColumn()].data< unsigned int >();
533  unsigned int numberOfDeletedObjects = row[ numberOfDeletedObjectsColumn()].data< unsigned int >();
534  // containers non-homogeneous are ignored.
535  dest.insert( std::make_pair( containerName, ContainerHeaderData( containerId, className,
536  numberOfWrittenObjects-numberOfDeletedObjects ) )) ;
537  m_dbCache->add( containerId, PoolDbCacheData(containerId, containerName, className, baseMappingVersion, numberOfWrittenObjects) );
538  }
539  return ret;
540 }
541 
543  const std::string& containerName,
544  const std::string& className ){
570  throwException( "Cannot create new Containers into POOL database.","PoolContainerHeaderTable::addContainer");
571 }
572 
574  if(!m_dbCache){
575  throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::removeContainer");
576  }
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; //POOL starts counting from 1!;
583  coral::ITable& containerTable = schema().tableHandle( tableName() );
584  containerTable.dataEditor().deleteRows(whereClause.str(),whereData);
585 }
586 
588  bool ret = false;
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 ; //POOL starts counting from 1!;
602  query->setCondition( whereClause.str(), whereData );
603  query->setForUpdate();
604  coral::ICursor& cursor = query->execute();
605  if( cursor.next() ) {
606  ret = true;
607  const coral::AttributeList& row = cursor.currentRow();
608  dest.id = id;
609  dest.className = row[ classNameColumn()].data< std::string >();
610  unsigned int numberOfWrittenObjects = row[ numberOfWrittenObjectsColumn()].data< unsigned int >();
611  unsigned int numberOfDeletedObjects = row[ numberOfDeletedObjectsColumn()].data< unsigned int >();
612  dest.numberOfObjects = numberOfWrittenObjects-numberOfDeletedObjects;
613  }
614  return ret;
615 }
616 
618  throwException( "Operation not supported into POOL database.","PoolContainerHeaderTable::incrementNumberOfObjects");
619 }
620 
622  throwException( "Operation not supported into POOL database.","PoolContainerHeaderTable::decrementNumberOfObjects");
623 }
624 
625 void ora::PoolContainerHeaderTable::updateNumberOfObjects( const std::map<int,unsigned int>& numberOfObjectsForContainerIds ){
626  if( numberOfObjectsForContainerIds.size() ){
627 
628  if(!m_dbCache){
629  throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::updateNumberOfObjects");
630  }
631 
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() );
641 
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));
644 
645  for( std::map<int,unsigned int>::const_iterator iCont = numberOfObjectsForContainerIds.begin();
646  iCont != numberOfObjectsForContainerIds.end(); ++iCont ){
647 
648  PoolDbCacheData& contData = m_dbCache->find( iCont->first );
649  unsigned int nwrt = contData.m_nobjWr;
650  unsigned int ndel = nwrt-iCont->second;
651 
652  updateData[containerIdColumn()].data<int>() = iCont->first + 1; //POOL starts counting from 1!;
653  updateData[numberOfWrittenObjectsColumn()].data<unsigned int>() = nwrt;
654  updateData[numberOfDeletedObjectsColumn()].data<unsigned int>() = ndel;
655  bulkUpdate->processNextIteration();
656 
657  }
658  bulkUpdate->flush();
659  }
660 }
661 
663  return tableName();
664 }
665 
667  return schema().existsTable( tableName() );
668 }
669 
671  if( schema().existsTable( tableName() )){
672  throwException( "POOL database container header table already exists in this schema.",
673  "PoolContainerHeaderTable::create");
674  }
675  throwException( "POOL database cannot be created.","PoolContainerHeaderTable::create");
676 }
677 
679  schema().dropIfExistsTable( tableName() );
680 }
681 
683  static const std::string s_table("POOL_OR_CLASS_VERSIONS");
684  return s_table;
685 }
686 
688  static const std::string s_col("CLASS_VERSION");
689  return s_col;
690 }
691 
693  static const std::string s_col("CONTAINER_ID");
694  return s_col;
695 
696 }
697 
699  static const std::string s_col("MAPPING_VERSION");
700  return s_col;
701 }
702 
704  IDatabaseTable( dbSchema ){
705 }
706 
708 }
709 
711  return tableName();
712 }
713 
715  return schema().existsTable( tableName() );
716 }
717 
719  if( schema().existsTable( tableName() )){
720  throwException( "POOL database class version table already exists in this schema.",
721  "PoolClassVersionTable::create");
722  }
723  throwException( "POOL database cannot be created.","PoolClassVersionTable::create");
724 }
725 
727  schema().dropIfExistsTable( tableName() );
728 }
729 
730 namespace ora {
732  if( mappingType == "PoolArray" ) return MappingElement::OraArrayMappingElementType();
733  return mappingType;
734  }
735 
737  size_t ind = variableName.find("pool::PVector");
738  if( ind != std::string::npos ){
739  return "ora::PVector"+variableName.substr(13);
740  }
741  return variableName;
742  }
743 }
744 
746  static const std::string s_scope(" ");
747  return s_scope;
748 }
749 
750 ora::PoolMappingSchema::PoolMappingSchema( coral::ISchema& dbSchema ):
751  m_schema( dbSchema ),
752  m_dbCache( 0 ){
753 }
754 
756 }
757 
759  m_dbCache = &dbCache;
760 }
761 
762 bool ora::PoolMappingSchema::getVersionList( std::set<std::string>& dest ){
763  bool ret = false;
764  std::auto_ptr<coral::IQuery> query( m_schema.tableHandle( PoolMappingVersionTable::tableName() ).newQuery() );
766  coral::ICursor& cursor = query->execute();
767  while ( cursor.next() ) {
768  ret = true;
769  const coral::AttributeList& currentRow = cursor.currentRow();
770  std::string mappingVersion = currentRow[ PoolMappingVersionTable::mappingVersionColumn()].data<std::string>();
771  dest.insert( mappingVersion );
772  }
773  return ret;
774 }
775 
776 namespace ora {
777 
778  void rebuildPoolMapping( const std::string& scope, const std::string& extraScope, const std::map<std::string, std::vector<MappingRawElement> >& elementsByScope, ora::MappingRawData& dest, int& counter ){
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 ){
783  MappingRawElement& elem = dest.addElement( counter ) = *iMap;
784  elem.scopeName = extraScope+"::"+iMap->scopeName;
785  counter++;
786  rebuildPoolMapping( scope+"::"+iMap->variableName, extraScope, elementsByScope, dest, counter );
787  }
788  }
789  }
790 }
791 
794  bool ret = false;
795  coral::ITable& mappingTable = m_schema.tableHandle( PoolMappingElementTable::tableName() );
796  std::auto_ptr<coral::IQuery> query(mappingTable.newQuery());
797  coral::AttributeList outputBuffer;
799  outputBuffer.extend<std::string>( PoolMappingElementTable::scopeNameColumn() );
802  outputBuffer.extend<std::string>( PoolMappingElementTable::tableNameColumn() );
803  outputBuffer.extend<std::string>( PoolMappingElementTable::columnNameColumn() );
804  query->defineOutput( outputBuffer );
806  query->addToOutputList( PoolMappingElementTable::scopeNameColumn() );
809  query->addToOutputList( PoolMappingElementTable::tableNameColumn() );
810  query->addToOutputList( PoolMappingElementTable::columnNameColumn() );
811  std::ostringstream condition;
813  coral::AttributeList condData;
815  coral::AttributeList::iterator iAttribute = condData.begin();
816  iAttribute->data< std::string >() = version;
817  query->setCondition( condition.str(), condData );
818  query->addToOrderList( PoolMappingElementTable::scopeNameColumn() );
820  // check the order: column order has to be swapped!
822  coral::ICursor& cursor = query->execute();
823  std::set<std::string> topElements;
824  std::map<std::string,MappingRawElement> elementsByVarName;
825  while ( cursor.next() ) {
826  ret = true;
827  const coral::AttributeList& currentRow = cursor.currentRow();
828  std::string scope = currentRow[ PoolMappingElementTable::scopeNameColumn() ].data<std::string>();
829  std::string varName = currentRow[ PoolMappingElementTable::variableNameColumn() ].data<std::string>();
830  std::string elemId = scope+"::"+varName;
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;
834  MappingRawElement& elem = iE->second;
835  elem.elementType = mappingTypeFromPool( currentRow[ PoolMappingElementTable::elementTypeColumn() ].data<std::string>() );
836  elem.scopeName = scope;
837  elem.variableName = variableNameFromPool( varName );
839  elem.tableName = currentRow[ PoolMappingElementTable::tableNameColumn() ].data<std::string>();
840  if(elem.scopeName == emptyScope()) {
842  if( topElements.find( elemId ) == topElements.end() ){
843  topElements.insert( elemId );
844  }
845  }
846  }
847  }
848  iE->second.columns.push_back( currentRow[ PoolMappingElementTable::columnNameColumn() ].data<std::string>() );
849  }
850  // re-ordering by scope
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 ){
854  // reversing the columns
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 );
859  }
860  iEl->second.columns = reverseCols;
861  std::string scope = iEl->second.scopeName;
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 ) ));
866  } else {
867  iS->second.push_back( iEl->second );
868  }
869  }
870  }
871  // rebuilding + adding class elements
872  int eid = 0;
873  for( std::set<std::string>::const_iterator iEl = topElements.begin();
874  iEl != topElements.end(); ++iEl ){
875  // adding the class elements...
876  std::map<std::string,MappingRawElement>::iterator iE = elementsByVarName.find( *iEl );
877  MappingRawElement classElement = iE->second;
879  classElement.scopeName = MappingRawElement::emptyScope();
880  dest.addElement( eid ) = classElement;
881  eid++;
882  MappingRawElement firstElement = iE->second;
883  firstElement.scopeName = iE->second.variableName;
884  dest.addElement( eid ) = firstElement;
885  eid++;
886  // rebuilding extending the scope...
887  rebuildPoolMapping( iE->second.variableName, iE->second.variableName, elementsByScope, dest, eid );
888  }
889  return ret;
890 }
891 
893  // first update the version table
894  coral::ITable& mappingVersionTable = m_schema.tableHandle( PoolMappingVersionTable::tableName() );
895  coral::AttributeList rowBuffer;
897  rowBuffer[ PoolMappingVersionTable::mappingVersionColumn() ].data<std::string>()= mapping.version;
898  mappingVersionTable.dataEditor().insertRow( rowBuffer );
899 
900  // then update the element tables
901  coral::ITable& mappingElementTable = m_schema.tableHandle( PoolMappingElementTable::tableName() );
902  coral::AttributeList dataBuffer;
904  dataBuffer.extend< std::string >( PoolMappingElementTable::elementIdColumn() );
906  dataBuffer.extend< std::string >( PoolMappingElementTable::scopeNameColumn() );
908  dataBuffer.extend< unsigned int >( PoolMappingElementTable::variableParIndexColumn() );
910  dataBuffer.extend< std::string >( PoolMappingElementTable::tableNameColumn() );
911  dataBuffer.extend< std::string >( PoolMappingElementTable::columnNameColumn() );
912  dataBuffer[ PoolMappingElementTable::mappingVersionColumn() ].data<std::string>()= mapping.version;
913 
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;
919  std::string scopeName = iElem->second.scopeName;
920  if( scopeName == MappingRawElement::emptyScope() ) scopeName = std::string(" ");
921  dataBuffer[ PoolMappingElementTable::elementIdColumn() ].data<std::string>() = elemIdx.str();
922  dataBuffer[ PoolMappingElementTable::elementTypeColumn()].data<std::string>()= iElem->second.elementType;
923  dataBuffer[ PoolMappingElementTable::scopeNameColumn() ].data<std::string>()= scopeName;
924  dataBuffer[ PoolMappingElementTable::variableNameColumn() ].data<std::string>()= iElem->second.variableName;
925  dataBuffer[ PoolMappingElementTable::variableParIndexColumn() ].data<unsigned int>() = iParamIndex;
926  dataBuffer[ PoolMappingElementTable::variableTypeColumn() ].data<std::string>()= iElem->second.variableType;
927  dataBuffer[ PoolMappingElementTable::tableNameColumn() ].data<std::string>()= iElem->second.tableName;
928  dataBuffer[ PoolMappingElementTable::columnNameColumn() ].data<std::string>()= iElem->second.columns[iParamIndex];
929  mappingElementTable.dataEditor().insertRow( dataBuffer );
930  }
931  }
932 }
933 
935  // Remove all rows in the tables with the version.
936  coral::AttributeList whereData;
938  whereData.begin()->data<std::string>() = version;
939 
941  m_schema.tableHandle( PoolClassVersionTable::tableName() ).dataEditor().deleteRows( condition, whereData );
942  m_schema.tableHandle( PoolMappingElementTable::tableName() ).dataEditor().deleteRows( condition, whereData );
943  m_schema.tableHandle( PoolMappingVersionTable::tableName() ).dataEditor().deleteRows( condition, whereData );
944 }
945 
946 bool ora::PoolMappingSchema::getContainerTableMap( std::map<std::string, int>&){
947  // not implemented for the moment
948  return false;
949 }
950 
952  std::set<std::string>& dest,
953  bool onlyDependency ){
954  bool ret = false;
955  std::auto_ptr<coral::IQuery> query( m_schema.newQuery() );
956  query->addToTableList( PoolClassVersionTable::tableName(), "T0" );
957  query->addToTableList( PoolContainerHeaderTable::tableName(), "T1" );
958  query->addToTableList( PoolMappingElementTable::tableName(), "T2" );
959  query->addToOutputList( "T0."+PoolClassVersionTable::mappingVersionColumn() );
960  query->setDistinct();
961  std::ostringstream condition;
965  coral::AttributeList condData;
966  condData.extend< int >( PoolContainerHeaderTable::containerIdColumn() );
967  condData[ PoolContainerHeaderTable::containerIdColumn() ].data< int >() = containerId + 1; //POOL starts counting from 1!;
968  if( onlyDependency ){
972  }
973  query->setCondition(condition.str(),condData);
974  coral::ICursor& cursor = query->execute();
975  while ( cursor.next() ) {
976  ret = true;
977  const coral::AttributeList& currentRow = cursor.currentRow();
978  std::string mappingVersion = currentRow[ "T0."+PoolClassVersionTable::mappingVersionColumn() ].data<std::string>();
979  dest.insert( mappingVersion );
980  }
981  return ret;
982 }
983 
984 
986  std::set<std::string>& ){
987  // not implemented for the moment
988  return false;
989 }
990 
992  std::set<std::string>& destination ){
993 
994  bool ret = false;
995  coral::ITable& classVersionTable = m_schema.tableHandle( PoolClassVersionTable::tableName() );
996  std::auto_ptr<coral::IQuery> query( classVersionTable.newQuery() );
997  query->setDistinct();
998  query->addToOutputList( PoolClassVersionTable::classVersionColumn() );
999  std::ostringstream condition;
1001  coral::AttributeList condData;
1003  condData[ PoolClassVersionTable::mappingVersionColumn() ].data< std::string >() = mappingVersion;
1004  query->setCondition(condition.str(),condData);
1005  coral::ICursor& cursor = query->execute();
1006  while ( cursor.next() ) {
1007  ret = true;
1008  const coral::AttributeList& currentRow = cursor.currentRow();
1009  std::string classVersion = currentRow[ PoolClassVersionTable::classVersionColumn() ].data<std::string>();
1010  destination.insert( classVersion );
1011  }
1012  return ret;
1013 }
1014 
1016  std::map<std::string,std::string>& versionMap ){
1017 
1018  bool ret = false;
1019  std::auto_ptr<coral::IQuery> query( m_schema.newQuery() );
1020  query->addToTableList( PoolClassVersionTable::tableName(), "T0" );
1021  query->addToTableList( PoolContainerHeaderTable::tableName(), "T1" );
1022  query->addToOutputList( "T0."+PoolClassVersionTable::classVersionColumn() );
1023  query->addToOutputList( "T0."+PoolClassVersionTable::mappingVersionColumn() );
1024  query->setDistinct();
1025  std::ostringstream condition;
1028  coral::AttributeList condData;
1029  condData.extend< int >( PoolContainerHeaderTable::containerIdColumn() );
1030  condData[ PoolContainerHeaderTable::containerIdColumn() ].data< int >() = containerId + 1; //POOL starts counting from 1!;
1031  query->setCondition(condition.str(),condData);
1032  coral::ICursor& cursor = query->execute();
1033  while ( cursor.next() ) {
1034  ret = true;
1035  const coral::AttributeList& currentRow = cursor.currentRow();
1036  std::string classVersion = currentRow[ "T0."+PoolClassVersionTable::classVersionColumn() ].data<std::string>();
1037  std::string mappingVersion = currentRow[ "T0."+PoolClassVersionTable::mappingVersionColumn() ].data<std::string>();
1038  versionMap.insert( std::make_pair(classVersion, mappingVersion ) );
1039  }
1040  return ret;
1041 }
1042 
1044  std::set<std::string>& ){
1045  // not implemented for the moment
1046  return false;
1047 }
1048 
1050  int containerId,
1052  bool ret = false;
1053  destination.clear();
1054 
1055  std::pair<bool,std::string> isBaseId = MappingRules::classNameFromBaseId( classId );
1056  if( !isBaseId.first ){
1057  std::auto_ptr<coral::IQuery> query( m_schema.newQuery() );
1058  query->addToTableList( PoolClassVersionTable::tableName(), "T0" );
1059  query->addToTableList( PoolContainerHeaderTable::tableName(), "T1" );
1060  query->addToOutputList( "T0."+PoolClassVersionTable::mappingVersionColumn() );
1061  std::ostringstream condition;
1065  coral::AttributeList condData;
1067  condData.extend<int>( PoolContainerHeaderTable::containerIdColumn() );
1068  coral::AttributeList::iterator iAttribute = condData.begin();
1069  iAttribute->data< std::string >() = MappingRules::classVersionFromId( classId );
1070  ++iAttribute;
1071  iAttribute->data< int >() = containerId + 1; //POOL starts counting from 1!;
1072  query->setCondition( condition.str(), condData );
1073  coral::ICursor& cursor = query->execute();
1074  while ( cursor.next() ) {
1075  ret = true;
1076  const coral::AttributeList& currentRow = cursor.currentRow();
1077  destination = currentRow["T0."+PoolClassVersionTable::mappingVersionColumn()].data<std::string>();
1078  }
1079  } else {
1080  PoolDbCacheData& containerData = m_dbCache->find( containerId );
1081  // in POOL db this will be only possible for top level classes (not for dependencies)
1082  if( containerData.m_className == isBaseId.second ){
1083  destination = containerData.m_mappingVersion;
1084  ret = true;
1085  }
1086  }
1087 
1088  return ret;
1089 }
1090 
1092  int& ){
1093  // not implemented for the moment
1094  return false;
1095 }
1096 
1098  const std::string& classVersion,
1099  const std::string&, //classId
1100  int, // dependencyIndex,
1101  int containerId,
1102  const std::string& mappingVersion ){
1103  if(!m_dbCache){
1104  throwException("MappingSchema handle has not been initialized.","PoolMappingSchema::insertClassVersion");
1105  }
1106 
1107  coral::ITable& classVersionTable = m_schema.tableHandle( PoolClassVersionTable::tableName() );
1108  coral::AttributeList inputData;
1112 
1113  std::string containerName = m_dbCache->nameById( containerId );
1114  coral::AttributeList::iterator iInAttr = inputData.begin();
1115  iInAttr->data< std::string >() = mappingVersion;
1116  ++iInAttr;
1117  iInAttr->data< std::string >() = classVersion;
1118  ++iInAttr;
1119  iInAttr->data< std::string >() = containerName;
1120  classVersionTable.dataEditor().insertRow( inputData );
1121 }
1122 
1124  int containerId,
1125  const std::string& mappingVersion ){
1126  if(!m_dbCache){
1127  throwException("MappingSchema handle has not been initialized.","PoolMappingSchema::setMappingVersion");
1128  }
1129  coral::ITable& classVersionTable = m_schema.tableHandle( PoolClassVersionTable::tableName() );
1130  coral::AttributeList inputData;
1134  std::string classVersion = MappingRules::classVersionFromId( classId );
1135  std::string containerName = m_dbCache->nameById( containerId );
1136  coral::AttributeList::iterator iInAttr = inputData.begin();
1137  iInAttr->data< std::string >() = mappingVersion;
1138  ++iInAttr;
1139  iInAttr->data< std::string >() = classVersion;
1140  ++iInAttr;
1141  iInAttr->data< std::string >() = containerName;
1145  classVersionTable.dataEditor().updateRows( setClause,whereClause, inputData );
1146 }
1147 
1149  static const std::string s_name("METADATA");
1150  return s_name;
1151 }
1152 
1154  static const std::string s_column("NAME");
1155  return s_column;
1156 }
1157 
1159  static const std::string s_column("TOKEN");
1160  return s_column;
1161 }
1162 
1164  static const std::string s_column("TIMETYPE");
1165  return s_column;
1166 }
1167 
1169  PoolDbCache& dbCache ):
1170  INamingServiceTable( dbSchema ),
1171  m_dbCache( dbCache ){
1172 }
1173 
1175 }
1176 
1178  int contId, int itemId ){
1179  coral::AttributeList dataToInsert;
1180  dataToInsert.extend<std::string>( objectNameColumn() );
1181  dataToInsert.extend<std::string>( tokenColumn());
1182  dataToInsert.extend<int>( timetypeColumn());
1183  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1184  std::string token = cond::writeToken( contData.m_name, contId, itemId, contData.m_className );
1185  dataToInsert[ objectNameColumn() ].data<std::string>() = name;
1186  dataToInsert[ tokenColumn() ].data<std::string>() = token;
1187  dataToInsert[ timetypeColumn() ].data<int>() = -1; // is it fine ???
1188  coral::ITable& containerTable = schema().tableHandle( tableName() );
1189  containerTable.dataEditor().insertRow( dataToInsert );
1190 }
1191 
1193  coral::AttributeList whereData;
1194  whereData.extend<std::string>( objectNameColumn() );
1195  whereData.begin()->data<std::string>() = name;
1196  std::string condition = objectNameColumn() + " = :" + objectNameColumn();
1197  return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1198 }
1199 
1201  std::string condition("");
1202  coral::AttributeList whereData;
1203  return schema().tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1204 }
1205 
1207  std::pair<int,int>& destination ){
1208  bool ret = false;
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();
1220  iAttribute->data< std::string >() = name;
1221  query->setCondition( condition.str(), condData );
1222  coral::ICursor& cursor = query->execute();
1223  while ( cursor.next() ) {
1224  ret = true;
1225  const coral::AttributeList& row = cursor.currentRow();
1226  std::string token = row[ tokenColumn() ].data< std::string >();
1227  std::pair<std::string,int> tokData = cond::parseToken( token );
1228  destination.first = m_dbCache.idByName( tokData.first );
1229  destination.second = tokData.second;
1230  }
1231  return ret;
1232 }
1233 
1235  int itemId,
1236  std::vector<std::string>& destination ){
1237  bool ret = false;
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();
1246  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1247  std::string token = cond::writeToken( contData.m_name, contId, itemId, contData.m_className );
1248  coral::AttributeList condData;
1249  condData.extend<std::string>( tokenColumn() );
1250  coral::AttributeList::iterator iAttribute = condData.begin();
1251  iAttribute->data< std::string >() = token;
1252  query->setCondition( condition.str(), condData );
1253  coral::ICursor& cursor = query->execute();
1254  while ( cursor.next() ) {
1255  ret = true;
1256  const coral::AttributeList& row = cursor.currentRow();
1257  std::string name = row[ objectNameColumn() ].data< std::string >();
1258  destination.push_back( name );
1259  }
1260  return ret;
1261 }
1262 
1264  std::vector<std::string>& destination ){
1265 
1266  bool ret = false;
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();
1275  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1276  std::string tokenFragment = cond::writeTokenContainerFragment( contData.m_name, contData.m_className )+"%";
1277  coral::AttributeList condData;
1278  condData.extend<std::string>( tokenColumn() );
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() ) {
1284  ret = true;
1285  const coral::AttributeList& row = cursor.currentRow();
1286  std::string name = row[ objectNameColumn() ].data< std::string >();
1287  destination.push_back( name );
1288  }
1289  return ret;
1290 }
1291 
1292 bool ora::CondMetadataTable::getAllNames( std::vector<std::string>& destination ){
1293 
1294  bool ret = false;
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() ) {
1303  ret = true;
1304  const coral::AttributeList& row = cursor.currentRow();
1305  std::string name = row[ objectNameColumn() ].data< std::string >();
1306  destination.push_back( name );
1307  }
1308  return ret;
1309 }
1310 
1312  return tableName();
1313 }
1314 
1316  return schema().existsTable( tableName() );
1317 }
1318 
1320  if( schema().existsTable( tableName() )){
1321  throwException( "Metadata table already exists in this schema.",
1322  "CondMetadataTable::create");
1323  }
1324  throwException( "Cond Metadata table cannot be created.","CondMetadataTable::create");
1325 }
1326 
1328  if( !schema().existsTable( tableName() )){
1329  throwException( "Metadata table does not exists in this schema.",
1330  "CondMetadataTable::drop");
1331  }
1332  throwException( "Cond Metadata table cannot be dropped.","CondMetadataTable::drop");
1333 }
1334 
1335 bool ora::PoolDatabaseSchema::existsMainTable( coral::ISchema& dbSchema ){
1336  PoolMainTable tmp( dbSchema );
1337  return tmp.exists();
1338 }
1339 
1341  IDatabaseSchema( dbSchema ),
1342  m_schema( dbSchema ),
1343  m_dbCache(),
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 ){
1355 }
1356 
1358 }
1359 
1361  if(!m_mainTable.exists()){
1362  return false;
1363  }
1364 
1365  if(!m_sequenceTable.exists() ||
1366  !m_mappingVersionTable.exists() ||
1367  !m_mappingElementTable.exists() ||
1368  !m_containerHeaderTable.exists() ||
1369  !m_classVersionTable.exists()){
1370  throwException( "POOL database is corrupted..",
1371  "PoolDatabaseSchema::exists");
1372  }
1373  if( !m_metadataTable.exists()){
1374  throwException( "Metadata table has not been found.",
1375  "PoolDatabaseSchema::exists");
1376  }
1377  return true;
1378 }
1379 
1381  throwException( "POOL database cannot be created.","PoolDatabaseSchema::create");
1382 }
1383 
1385  m_classVersionTable.drop();
1386  m_mappingElementTable.drop();
1387  m_sequenceTable.drop();
1388  m_containerHeaderTable.drop();
1389  m_mappingVersionTable.drop();
1390  m_mainTable.drop();
1391 }
1392 
1394  bool forWrite ){
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 );
1402 }
1403 
1405  return m_mainTable;
1406 }
1407 
1409  return m_sequenceTable;
1410 }
1411 
1413  return m_mappingVersionTable;
1414 }
1415 
1417  return m_mappingElementTable;
1418 }
1419 
1421  return m_containerHeaderTable;
1422 }
1423 
1425  return m_classVersionTable;
1426 }
1427 
1429  return m_mappingSchema;
1430 }
1431 
1433  return m_metadataTable;
1434 }
1435 
1436 
static std::string versionParameterName()
IDatabaseTable & mappingElementTable()
IMappingSchema & mappingSchema()
void init(PoolDbCache &dbCache)
static std::string numberOfWrittenObjectsColumn()
tuple ret
prodAgent to be discontinued
static std::string tableName()
MappingRawElement & addElement(int elementId)
bool getNamesForObject(int contId, int itemId, std::vector< std::string > &destination)
static std::string tableNameColumn()
static std::string tableName()
static std::string variableTypeColumn()
PoolDbCacheData m_mappingData
PoolMappingSchema m_mappingSchema
static std::string containerNameColumn()
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)
Definition: PoolToken.cc:16
PoolSequenceTable(coral::ISchema &dbSchema)
static std::string containerTypeColumn()
std::string mappingTypeFromPool(const std::string &mappingType)
tuple schema
Definition: dataDML.py:2334
void setObjectName(const std::string &name, int contId, int itemId)
PoolDbCacheData m_databaseData
static std::string columnNameColumn()
static std::string baseMappingVersionColumn()
PoolMappingSchema(coral::ISchema &dbSchema)
int idByName(const std::string &name)
static std::string mappingVersionColumn()
void init(PoolDbCache &dbCache)
void updateNumberOfObjects(const std::map< int, unsigned int > &numberOfObjectsForContainerIds)
void setAccessPermission(const std::string &principal, bool forWrite)
static std::string tableNameColumn()
INamingServiceTable & namingServiceTable()
std::map< int, MappingRawElement > elements
void removeMapping(const std::string &version)
static std::string containerIdColumn()
std::string writeTokenContainerFragment(const std::string &containerName, const std::string &className)
Definition: PoolToken.cc:56
bool getContainerData(std::map< std::string, ContainerHeaderData > &destination)
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)
Definition: FindCaloHit.cc:7
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 tokenColumn()
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()
Definition: MappingRules.cc:30
bool eraseObjectName(const std::string &name)
bool getMappingVersionListForContainer(int containerId, std::set< std::string > &destination, bool onlyDependency=false)
bool getMapping(const std::string &version, MappingRawData &destination)
static std::string numberOfDeletedObjectsColumn()
void setParameter(const std::string &paramName, const std::string &paramValue)
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 objectNameColumn()
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)
static std::string timetypeColumn()
bool getLastId(const std::string &sequenceName, int &lastId)
static std::string classVersionFromId(const std::string &classId)
Definition: MappingRules.cc:69
static std::string homogeneousContainerType()
PoolContainerHeaderTable(coral::ISchema &dbSchema)
static std::pair< bool, std::string > classNameFromBaseId(const std::string &classId)
Definition: MappingRules.cc:90
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 classNameColumn()
m_id("(unknown)")
static std::string sequenceValueColumn()
IContainerHeaderTable & containerHeaderTable()
void init(PoolDbCache &dbCache)
PoolMappingVersionTable(coral::ISchema &dbSchema)
bool getAllNames(std::vector< std::string > &destination)
bool lockContainer(int id, ContainerHeaderData &destination)
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)
void addContainer(int id, const std::string &containerName, const std::string &className)
std::string variableNameFromPool(const std::string &variableName)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static std::string containerNameColumn()
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
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()
tuple query
Definition: o2o.py:269
bool getMappingVersionListForTable(const std::string &tableName, std::set< std::string > &destination)
static std::string sequenceNameForContainer(const std::string &containerName)
Definition: MappingRules.cc:15
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
Definition: MappingRules.cc:10
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()
IDatabaseTable & classVersionTable()
std::string writeToken(const std::string &containerName, int oid0, int oid1, const std::string &className)
Definition: PoolToken.cc:45
bool getNamesForContainer(int contId, std::vector< std::string > &destination)
static std::string classMappingElementType()
Returns the name of the class mapping element type.
ISequenceTable & sequenceTable()
static std::string elementTypeColumn()
CondMetadataTable(coral::ISchema &dbSchema, PoolDbCache &dbCache)
bool getObjectByName(const std::string &name, std::pair< int, int > &destination)
std::string className(const T &t)
Definition: ClassName.h:30
tuple inputData
Definition: idDealer.py:72
std::string schemaVersion()
bool getDependentClassesInContainerMapping(int containerId, std::set< std::string > &destination)
void erase(const std::string &sequenceName)
static std::string tableName()