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 std::string s_name("POOL_RSS_DB");
24  return s_name;
25 }
26 
27 ora::PoolMainTable::PoolMainTable( coral::ISchema& dbSchema ):
28  m_schema( dbSchema ){
29 }
30 
32 }
33 
34 bool ora::PoolMainTable::getParameters( std::map<std::string,std::string>& ){
35  return false;
36 }
37 
39  return poolSchemaVersion();
40 }
41 
43  return m_schema.existsTable( tableName() );
44 }
45 
47  if( m_schema.existsTable( tableName() )){
48  throwException( "POOL database main table already exists in this schema.",
49  "PoolMainTable::create");
50  }
51  throwException( "POOL database cannot be created.","PoolMainTable::create");
52 }
53 
55  m_schema.dropIfExistsTable( tableName() );
56 }
57 
59  static std::string s_name("POOL_RSS_SEQ");
60  return s_name;
61 }
62 
64  static std::string s_column("NAME");
65  return s_column;
66 }
67 
69  static std::string s_column("VALUE");
70  return s_column;
71 }
72 
74  m_schema( schema),
75  m_dbCache( 0 ){
76 }
77 
79 }
80 
82  m_dbCache = &dbCache;
83 }
84 
85 bool
86 ora::PoolSequenceTable::add( const std::string& sequenceName ){
87  // Create the entry in the table if it does not exist.
88  coral::AttributeList insertData;
89  insertData.extend<std::string>(sequenceNameColumn());
90  insertData.extend<int>(sequenceValueColumn());
91  coral::AttributeList::iterator iAttribute = insertData.begin();
92  iAttribute->data< std::string >() = sequenceName;
93  ++iAttribute;
94  iAttribute->data< int >() = 0;
95  m_schema.tableHandle( tableName() ).dataEditor().insertRow( insertData );
96  return true;
97 }
98 
99 bool
100 ora::PoolSequenceTable::getLastId( const std::string& sequenceName,
101  int& lastId ) {
102  if(!m_dbCache){
103  throwException("Sequence Table handle has not been initialized.","PoolSequenceTable::getLastId");
104  }
105 
106  // first lookup in the cache for the built in sequences...
107  std::map<std::string,PoolDbCacheData*>& seq = m_dbCache->sequences();
108  std::map<std::string,PoolDbCacheData*>::iterator iS = seq.find( sequenceName );
109  if( iS != seq.end()){
110  if( iS->second->m_nobjWr == 0 ) return false;
111  lastId = iS->second->m_nobjWr-1;
112  return true;
113  }
114 
115  // otherwise, look up into the regular sequence table.
116  std::auto_ptr< coral::IQuery > query( m_schema.tableHandle( tableName() ).newQuery() );
117  query->limitReturnedRows( 1, 0 );
118  query->addToOutputList( sequenceValueColumn() );
119  query->defineOutputType( sequenceValueColumn(), coral::AttributeSpecification::typeNameForType<int>() );
120  query->setForUpdate();
121  std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() );
122  coral::AttributeList rowData;
123  rowData.extend<std::string>(sequenceNameColumn());
124  rowData.begin()->data< std::string >() = sequenceName;
125  query->setCondition( whereClause, rowData );
126  coral::ICursor& cursor = query->execute();
127  if ( cursor.next() ) {
128  lastId = cursor.currentRow().begin()->data<int >();
129  return true;
130  }
131  return false;
132 }
133 
134 void ora::PoolSequenceTable::sinchronize( const std::string& sequenceName,
135  int lastValue ){
136  if(!m_dbCache){
137  throwException("Sequence Table handle has not been initialized.","PoolSequenceTable::sinchronize");
138  }
139  // nothing to do in the db if the sequence is in the cache...
140  std::map<std::string,PoolDbCacheData*>& seq = m_dbCache->sequences();
141  std::map<std::string,PoolDbCacheData*>::iterator iS = seq.find( sequenceName );
142  if( iS != seq.end()){
143  iS->second->m_nobjWr = lastValue+1;
144  return;
145  }
146 
147  coral::AttributeList updateData;
148  updateData.extend<std::string>(sequenceNameColumn());
149  updateData.extend<int>(sequenceValueColumn());
150  std::string setClause( sequenceValueColumn() + " = :" + sequenceValueColumn() );
151  std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() );
152  // Increment the oid in the database as well
153  coral::AttributeList::iterator iAttribute = updateData.begin();
154  iAttribute->data< std::string >() = sequenceName;
155  ++iAttribute;
156  iAttribute->data< int >() = lastValue;
157  m_schema.tableHandle( tableName() ).dataEditor().updateRows( setClause,whereClause,updateData );
158 }
159 
160 void ora::PoolSequenceTable::erase( const std::string& sequenceName ){
161  coral::AttributeList whereData;
162  whereData.extend<std::string>(sequenceNameColumn());
163  whereData[ sequenceNameColumn() ].data<std::string>() = sequenceName;
164  std::string whereClause( sequenceNameColumn() + " = :" + sequenceNameColumn() );
165  m_schema.tableHandle( tableName() ).dataEditor().deleteRows( whereClause, whereData );
166 }
167 
169  if(!m_dbCache){
170  throwException("Sequence Table handle has not been initialized.","PoolSequenceTable::exists");
171  }
172  // ????
173  return m_schema.existsTable( tableName() );
174 }
175 
177  if( m_schema.existsTable( tableName() )){
178  throwException( "POOL database sequence table already exists in this schema.",
179  "PoolSequenceTable::create");
180  }
181  throwException( "POOL database cannot be created.","PoolSequenceTable::create");
182 }
183 
185  m_schema.dropIfExistsTable( tableName() );
186 }
187 
189  static std::string s_table("POOL_OR_MAPPING_VERSIONS");
190  return s_table;
191 }
192 
194  static std::string s_col("MAPPING_VERSION");
195  return s_col;
196 }
197 
199  static std::string s_col("CONTAINER_ID");
200  return s_col;
201 }
202 
204  m_schema( dbSchema ){
205 }
206 
208 }
209 
211  return m_schema.existsTable( tableName() );
212 }
213 
215  if( m_schema.existsTable( tableName() )){
216  throwException( "POOL database mapping version table already exists in this schema.",
217  "PoolMappingVersionTable::create");
218  }
219  throwException( "POOL database cannot be created.","PoolMappingVersionTable::create");
220 }
221 
223  m_schema.dropIfExistsTable( tableName() );
224 }
225 
226 
228  static std::string s_table("POOL_OR_MAPPING_ELEMENTS");
229  return s_table;
230 }
231 
233  static std::string s_col("MAPPING_VERSION");
234  return s_col;
235 }
236 
238  static std::string s_col("ELEMENT_ID");
239  return s_col;
240 }
241 
243  static std::string s_col("ELEMENT_TYPE");
244  return s_col;
245 }
246 
248  static std::string s_col("VARIABLE_SCOPE");
249  return s_col;
250 }
251 
253  static std::string s_col("VARIABLE_NAME");
254  return s_col;
255 }
256 
258  static std::string s_col("VARIABLE_PAR_INDEX");
259  return s_col;
260 }
261 
263  static std::string s_col("VARIABLE_TYPE");
264  return s_col;
265 }
266 
268  static std::string s_col("TABLE_NAME");
269  return s_col;
270 }
271 
273  static std::string s_col("COLUMN_NAME");
274  return s_col;
275 }
276 
278  m_schema( dbSchema ){
279 }
280 
282 }
283 
285  return m_schema.existsTable( tableName() );
286 }
287 
289  if( m_schema.existsTable( tableName() )){
290  throwException( "POOL database mapping element table already exists in this schema.",
291  "PoolMappingElementTable::create");
292  }
293  throwException( "POOL database cannot be created.","PoolMappingElementTable::create");
294 }
295 
297  m_schema.dropIfExistsTable( tableName() );
298 }
299 
301  m_id( 0 ),
302  m_name("" ),
303  m_className("" ),
304  m_mappingVersion( "" ),
305  m_nobjWr( 0 ){
306 }
307 
309  const std::string& name,
310  const std::string& className,
311  const std::string& mappingVersion,
312  unsigned int nobjWr ):
313  m_id( id ),
314  m_name( name ),
315  m_className( className ),
316  m_mappingVersion( mappingVersion ),
317  m_nobjWr( nobjWr ){
318 }
319 
321 }
322 
324  m_id( rhs.m_id ),
325  m_name( rhs.m_name ),
326  m_className( rhs.m_className ),
327  m_mappingVersion( rhs.m_mappingVersion ),
328  m_nobjWr( rhs.m_nobjWr ){
329 }
330 
332  m_id = rhs.m_id;
333  m_name = rhs.m_name;
334  m_className = rhs.m_className;
335  m_mappingVersion = rhs.m_mappingVersion;
336  m_nobjWr = rhs.m_nobjWr;
337  return *this;
338 }
339 
341  m_databaseData(),
342  m_mappingData(),
343  m_idMap(),
344  m_sequences(){
347 }
348 
350 }
351 
353  std::map<int,PoolDbCacheData >::iterator iData = m_idMap.insert( std::make_pair( id, data )).first;
354  std::map<std::string,PoolDbCacheData*>::iterator iS = m_sequences.find( MappingRules::sequenceNameForContainerId() );
355  if( iS == m_sequences.end() ){
356  throwException( "ContainerId Sequence is empty","PoolDbCache::add");
357  }
358  if( id > (int)iS->second->m_nobjWr ){
359  iS->second->m_nobjWr = id;
360  }
361  m_sequences.insert( std::make_pair( MappingRules::sequenceNameForContainer( data.m_name ),&iData->second ) );
362 }
363 
364 const std::string& ora::PoolDbCache::nameById( int id ){
365  PoolDbCacheData& data = find( id );
366  return data.m_name;
367 }
368 
369 int ora::PoolDbCache::idByName( const std::string& name ){
370  int ret = -1;
371  for(std::map<int,PoolDbCacheData >::const_iterator iData = m_idMap.begin();
372  iData != m_idMap.end(); iData++ ){
373  if( iData->second.m_name == name ){
374  ret = iData->first;
375  break;
376  }
377  }
378  return ret;
379 }
380 
382  std::map<int,PoolDbCacheData >::iterator iC = m_idMap.find( id );
383  if( iC == m_idMap.end() ){
384  throwException("Container has not been found in the cache.","PoolDbCache::find");
385  }
386  return iC->second;
387 }
388 
390  std::string name = find( id ).m_name;
391  m_sequences.erase( MappingRules::sequenceNameForContainer( name ) );
392  m_idMap.erase( id );
393 }
394 
395 std::map<std::string,ora::PoolDbCacheData*>& ora::PoolDbCache::sequences(){
396  return m_sequences;
397 }
398 
400  m_sequences.clear();
401  m_idMap.clear();
402  m_sequences.insert(std::make_pair( MappingRules::sequenceNameForContainerId(), &m_databaseData ) );
403  m_sequences.insert(std::make_pair( MappingRules::sequenceNameForMapping(), &m_mappingData ) );
404 }
405 
407  static std::string s_name("POOL_RSS_CONTAINERS");
408  return s_name;
409 }
410 
411 
413  static std::string s_column("CONTAINER_ID");
414  return s_column;
415 }
416 
417 
419  static std::string s_column("CONTAINER_NAME");
420  return s_column;
421 }
422 
424  static std::string s_column("CONTAINER_TYPE");
425  return s_column;
426 }
427 
429  static std::string s_column("TABLE_NAME");
430  return s_column;
431 }
432 
434  static std::string s_column("CLASS_NAME");
435  return s_column;
436 }
437 
439  static std::string s_column("MAPPING_VERSION");
440  return s_column;
441 }
442 
444  static std::string s_column("NUMBER_OF_WRITTEN_OBJECTS");
445  return s_column;
446 }
447 
449  static std::string s_column("NUMBER_OF_DELETED_OBJECTS");
450  return s_column;
451 }
452 
454  static std::string s_type("Homogeneous");
455  return s_type;
456 }
457 
459  m_schema(dbSchema),
460  m_dbCache( 0 ){
461 }
462 
464 }
465 
467  m_dbCache = &dbCache;
468 }
469 
472  if(!m_dbCache){
473  throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::getContainerData");
474  }
475  bool ret = false;
476  m_dbCache->clear();
477  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
478  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
479  coral::AttributeList outputBuffer;
480  outputBuffer.extend<int>( containerIdColumn() );
481  outputBuffer.extend<std::string>( containerNameColumn() );
482  outputBuffer.extend<std::string>( classNameColumn() );
483  outputBuffer.extend<std::string>( baseMappingVersionColumn() );
484  outputBuffer.extend<unsigned int>( numberOfWrittenObjectsColumn() );
485  outputBuffer.extend<unsigned int>( numberOfDeletedObjectsColumn() );
486  query->defineOutput( outputBuffer );
487  query->addToOutputList( containerIdColumn() );
488  query->addToOutputList( containerNameColumn() );
489  query->addToOutputList( classNameColumn() );
490  query->addToOutputList( baseMappingVersionColumn() );
491  query->addToOutputList( numberOfWrittenObjectsColumn() );
492  query->addToOutputList( numberOfDeletedObjectsColumn() );
493  std::stringstream condition;
494  condition << containerTypeColumn()<<" = :"<<containerTypeColumn();
495  coral::AttributeList condData;
496  condData.extend<std::string>( containerTypeColumn() );
497  condData[ containerTypeColumn() ].data<std::string>()=homogeneousContainerType();
498  query->setCondition( condition.str(), condData );
499  coral::ICursor& cursor = query->execute();
500  while ( cursor.next() ) {
501  ret = true;
502  const coral::AttributeList& row = cursor.currentRow();
503  int containerId = row[ containerIdColumn() ].data< int >() - 1; //POOL starts counting from 1!
504  std::string containerName = row[ containerNameColumn()].data< std::string >();
505  std::string className = row[ classNameColumn()].data< std::string >();
506  std::string baseMappingVersion = row[ baseMappingVersionColumn()].data< std::string >();
507  unsigned int numberOfWrittenObjects = row[ numberOfWrittenObjectsColumn()].data< unsigned int >();
508  unsigned int numberOfDeletedObjects = row[ numberOfDeletedObjectsColumn()].data< unsigned int >();
509  // containers non-homogeneous are ignored.
510  dest.insert( std::make_pair( containerName, ContainerHeaderData( containerId, className,
511  numberOfWrittenObjects-numberOfDeletedObjects ) )) ;
512  m_dbCache->add( containerId, PoolDbCacheData(containerId, containerName, className, baseMappingVersion, numberOfWrittenObjects) );
513  }
514  return ret;
515 }
516 
518  const std::string& containerName,
519  const std::string& className ){
545  throwException( "Cannot create new Containers into POOL database.","PoolContainerHeaderTable::addContainer");
546 }
547 
549  if(!m_dbCache){
550  throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::removeContainer");
551  }
552  m_dbCache->remove( id );
553  std::stringstream whereClause;
554  whereClause << containerIdColumn() << "= :" <<containerIdColumn();
555  coral::AttributeList whereData;
556  whereData.extend< int >( containerIdColumn() );
557  whereData.begin()->data< int >() = id + 1; //POOL starts counting from 1!;
558  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
559  containerTable.dataEditor().deleteRows(whereClause.str(),whereData);
560 }
561 
563  throwException( "Operation not supported into POOL database.","PoolContainerHeaderTable::incrementNumberOfObjects");
564 }
565 
567  throwException( "Operation not supported into POOL database.","PoolContainerHeaderTable::decrementNumberOfObjects");
568 }
569 
570 void ora::PoolContainerHeaderTable::updateNumberOfObjects( const std::map<int,unsigned int>& numberOfObjectsForContainerIds ){
571  if( numberOfObjectsForContainerIds.size() ){
572 
573  if(!m_dbCache){
574  throwException("Container Table handle has not been initialized.","PoolContainerHeaderTable::updateNumberOfObjects");
575  }
576 
577  std::stringstream whereClause;
578  whereClause << containerIdColumn() << " = :" <<containerIdColumn();
579  std::stringstream setClause;
580  setClause << numberOfWrittenObjectsColumn()<< " = :"<<numberOfWrittenObjectsColumn();
581  setClause << " , "<< numberOfDeletedObjectsColumn()<< " = :"<<numberOfDeletedObjectsColumn();
582  coral::AttributeList updateData;
583  updateData.extend<unsigned int>( numberOfWrittenObjectsColumn() );
584  updateData.extend<unsigned int>( numberOfDeletedObjectsColumn() );
585  updateData.extend<int>( containerIdColumn() );
586 
587  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
588  std::auto_ptr<coral::IBulkOperation> bulkUpdate( containerTable.dataEditor().bulkUpdateRows( setClause.str(), whereClause.str(), updateData,(int)numberOfObjectsForContainerIds.size()+1));
589 
590  for( std::map<int,unsigned int>::const_iterator iCont = numberOfObjectsForContainerIds.begin();
591  iCont != numberOfObjectsForContainerIds.end(); ++iCont ){
592 
593  PoolDbCacheData& contData = m_dbCache->find( iCont->first );
594  unsigned int nwrt = contData.m_nobjWr;
595  unsigned int ndel = nwrt-iCont->second;
596 
597  updateData[containerIdColumn()].data<int>() = iCont->first + 1; //POOL starts counting from 1!;
598  updateData[numberOfWrittenObjectsColumn()].data<unsigned int>() = nwrt;
599  updateData[numberOfDeletedObjectsColumn()].data<unsigned int>() = ndel;
600  bulkUpdate->processNextIteration();
601 
602  }
603  bulkUpdate->flush();
604  }
605 }
606 
608  return m_schema.existsTable( tableName() );
609 }
610 
612  if( m_schema.existsTable( tableName() )){
613  throwException( "POOL database container header table already exists in this schema.",
614  "PoolContainerHeaderTable::create");
615  }
616  throwException( "POOL database cannot be created.","PoolContainerHeaderTable::create");
617 }
618 
620  m_schema.dropIfExistsTable( tableName() );
621 }
622 
624  static std::string s_table("POOL_OR_CLASS_VERSIONS");
625  return s_table;
626 }
627 
629  static std::string s_col("CLASS_VERSION");
630  return s_col;
631 }
632 
634  static std::string s_col("CONTAINER_ID");
635  return s_col;
636 
637 }
638 
640  static std::string s_col("MAPPING_VERSION");
641  return s_col;
642 }
643 
645  m_schema( dbSchema ){
646 }
647 
649 }
650 
652  return m_schema.existsTable( tableName() );
653 }
654 
656  if( m_schema.existsTable( tableName() )){
657  throwException( "POOL database class version table already exists in this schema.",
658  "PoolClassVersionTable::create");
659  }
660  throwException( "POOL database cannot be created.","PoolClassVersionTable::create");
661 }
662 
664  m_schema.dropIfExistsTable( tableName() );
665 }
666 
667 namespace ora {
668  std::string mappingTypeFromPool( const std::string& mappingType ){
669  if( mappingType == "PoolArray" ) return MappingElement::OraArrayMappingElementType();
670  return mappingType;
671  }
672 
673  std::string variableNameFromPool( const std::string& variableName ){
674  size_t ind = variableName.find("pool::PVector");
675  if( ind != std::string::npos ){
676  return "ora::PVector"+variableName.substr(13);
677  }
678  return variableName;
679  }
680 }
681 
683  static std::string s_scope(" ");
684  return s_scope;
685 }
686 
687 ora::PoolMappingSchema::PoolMappingSchema( coral::ISchema& dbSchema ):
688  m_schema( dbSchema ),
689  m_dbCache( 0 ){
690 }
691 
693 }
694 
696  m_dbCache = &dbCache;
697 }
698 
699 bool ora::PoolMappingSchema::getVersionList( std::set<std::string>& dest ){
700  bool ret = false;
701  std::auto_ptr<coral::IQuery> query( m_schema.tableHandle( PoolMappingVersionTable::tableName() ).newQuery() );
703  coral::ICursor& cursor = query->execute();
704  while ( cursor.next() ) {
705  ret = true;
706  const coral::AttributeList& currentRow = cursor.currentRow();
707  std::string mappingVersion = currentRow[ PoolMappingVersionTable::mappingVersionColumn()].data<std::string>();
708  dest.insert( mappingVersion );
709  }
710  return ret;
711 }
712 
713 namespace ora {
714 
715  void rebuildPoolMapping( const std::string& scope, const std::string& extraScope, const std::map<std::string, std::vector<MappingRawElement> >& elementsByScope, ora::MappingRawData& dest, int& counter ){
716  std::map<std::string, std::vector<MappingRawElement> >::const_iterator iSc = elementsByScope.find( scope );
717  if( iSc != elementsByScope.end() ){
718  for( std::vector<MappingRawElement>::const_iterator iMap = iSc->second.begin();
719  iMap != iSc->second.end(); ++iMap ){
720  MappingRawElement& elem = dest.addElement( counter ) = *iMap;
721  elem.scopeName = extraScope+"::"+iMap->scopeName;
722  counter++;
723  rebuildPoolMapping( scope+"::"+iMap->variableName, extraScope, elementsByScope, dest, counter );
724  }
725  }
726  }
727 }
728 
731  bool ret = false;
732  coral::ITable& mappingTable = m_schema.tableHandle( PoolMappingElementTable::tableName() );
733  std::auto_ptr<coral::IQuery> query(mappingTable.newQuery());
734  coral::AttributeList outputBuffer;
735  outputBuffer.extend<std::string>( PoolMappingElementTable::elementTypeColumn() );
736  outputBuffer.extend<std::string>( PoolMappingElementTable::scopeNameColumn() );
737  outputBuffer.extend<std::string>( PoolMappingElementTable::variableNameColumn() );
738  outputBuffer.extend<std::string>( PoolMappingElementTable::variableTypeColumn() );
739  outputBuffer.extend<std::string>( PoolMappingElementTable::tableNameColumn() );
740  outputBuffer.extend<std::string>( PoolMappingElementTable::columnNameColumn() );
741  query->defineOutput( outputBuffer );
743  query->addToOutputList( PoolMappingElementTable::scopeNameColumn() );
746  query->addToOutputList( PoolMappingElementTable::tableNameColumn() );
747  query->addToOutputList( PoolMappingElementTable::columnNameColumn() );
748  std::ostringstream condition;
750  coral::AttributeList condData;
751  condData.extend<std::string>( PoolMappingElementTable::mappingVersionColumn() );
752  coral::AttributeList::iterator iAttribute = condData.begin();
753  iAttribute->data< std::string >() = version;
754  query->setCondition( condition.str(), condData );
755  query->addToOrderList( PoolMappingElementTable::scopeNameColumn() );
757  // check the order: column order has to be swapped!
759  coral::ICursor& cursor = query->execute();
760  std::set<std::string> topElements;
761  std::map<std::string,MappingRawElement> elementsByVarName;
762  while ( cursor.next() ) {
763  ret = true;
764  const coral::AttributeList& currentRow = cursor.currentRow();
765  std::string scope = currentRow[ PoolMappingElementTable::scopeNameColumn() ].data<std::string>();
766  std::string varName = currentRow[ PoolMappingElementTable::variableNameColumn() ].data<std::string>();
767  std::string elemId = scope+"::"+varName;
768  std::map<std::string,MappingRawElement>::iterator iE = elementsByVarName.find( elemId );
769  if( iE == elementsByVarName.end() ) {
770  iE = elementsByVarName.insert( std::make_pair( elemId, MappingRawElement())).first;
771  MappingRawElement& elem = iE->second;
772  elem.elementType = mappingTypeFromPool( currentRow[ PoolMappingElementTable::elementTypeColumn() ].data<std::string>() );
773  elem.scopeName = scope;
774  elem.variableName = variableNameFromPool( varName );
775  elem.variableType = currentRow[ PoolMappingElementTable::variableTypeColumn() ].data<std::string>();
776  elem.tableName = currentRow[ PoolMappingElementTable::tableNameColumn() ].data<std::string>();
777  if(elem.scopeName == emptyScope()) {
779  if( topElements.find( elemId ) == topElements.end() ){
780  topElements.insert( elemId );
781  }
782  }
783  }
784  }
785  iE->second.columns.push_back( currentRow[ PoolMappingElementTable::columnNameColumn() ].data<std::string>() );
786  }
787  // re-ordering by scope
788  std::map<std::string, std::vector<MappingRawElement> > elementsByScope;
789  for( std::map<std::string,MappingRawElement>::iterator iEl = elementsByVarName.begin();
790  iEl != elementsByVarName.end(); ++iEl ){
791  // reversing the columns
792  std::vector<std::string> reverseCols;
793  for( std::vector<std::string>::reverse_iterator iR = iEl->second.columns.rbegin();
794  iR != iEl->second.columns.rend(); ++iR ){
795  reverseCols.push_back( *iR );
796  }
797  iEl->second.columns = reverseCols;
798  std::string scope = iEl->second.scopeName;
799  if( scope != emptyScope() ){
800  std::map<std::string, std::vector<MappingRawElement> >::iterator iS = elementsByScope.find( scope );
801  if( iS == elementsByScope.end() ){
802  elementsByScope.insert( std::make_pair( scope, std::vector<MappingRawElement>(1,iEl->second ) ));
803  } else {
804  iS->second.push_back( iEl->second );
805  }
806  }
807  }
808  // rebuilding + adding class elements
809  int eid = 0;
810  for( std::set<std::string>::const_iterator iEl = topElements.begin();
811  iEl != topElements.end(); ++iEl ){
812  // adding the class elements...
813  std::map<std::string,MappingRawElement>::iterator iE = elementsByVarName.find( *iEl );
814  MappingRawElement classElement = iE->second;
816  classElement.scopeName = MappingRawElement::emptyScope();
817  dest.addElement( eid ) = classElement;
818  eid++;
819  MappingRawElement firstElement = iE->second;
820  firstElement.scopeName = iE->second.variableName;
821  dest.addElement( eid ) = firstElement;
822  eid++;
823  // rebuilding extending the scope...
824  rebuildPoolMapping( iE->second.variableName, iE->second.variableName, elementsByScope, dest, eid );
825  }
826  return ret;
827 }
828 
830  // first update the version table
831  coral::ITable& mappingVersionTable = m_schema.tableHandle( PoolMappingVersionTable::tableName() );
832  coral::AttributeList rowBuffer;
833  rowBuffer.extend< std::string >( PoolMappingVersionTable::mappingVersionColumn() );
834  rowBuffer[ PoolMappingVersionTable::mappingVersionColumn() ].data<std::string>()= mapping.version;
835  mappingVersionTable.dataEditor().insertRow( rowBuffer );
836 
837  // then update the element tables
838  coral::ITable& mappingElementTable = m_schema.tableHandle( PoolMappingElementTable::tableName() );
839  coral::AttributeList dataBuffer;
840  dataBuffer.extend< std::string >( PoolMappingElementTable::mappingVersionColumn() );
841  dataBuffer.extend< std::string >( PoolMappingElementTable::elementIdColumn() );
842  dataBuffer.extend< std::string >( PoolMappingElementTable::elementTypeColumn() );
843  dataBuffer.extend< std::string >( PoolMappingElementTable::scopeNameColumn() );
844  dataBuffer.extend< std::string >( PoolMappingElementTable::variableNameColumn() );
845  dataBuffer.extend< unsigned int >( PoolMappingElementTable::variableParIndexColumn() );
846  dataBuffer.extend< std::string >( PoolMappingElementTable::variableTypeColumn() );
847  dataBuffer.extend< std::string >( PoolMappingElementTable::tableNameColumn() );
848  dataBuffer.extend< std::string >( PoolMappingElementTable::columnNameColumn() );
849  dataBuffer[ PoolMappingElementTable::mappingVersionColumn() ].data<std::string>()= mapping.version;
850 
851  for( std::map < int, MappingRawElement >::const_iterator iElem = mapping.elements.begin();
852  iElem != mapping.elements.end(); iElem++ ){
853  for( size_t iParamIndex = 0; iParamIndex < iElem->second.columns.size(); iParamIndex++ ){
854  std::stringstream elemIdx;
855  elemIdx << iElem->first;
856  std::string scopeName = iElem->second.scopeName;
857  if( scopeName == MappingRawElement::emptyScope() ) scopeName = std::string(" ");
858  dataBuffer[ PoolMappingElementTable::elementIdColumn() ].data<std::string>() = elemIdx.str();
859  dataBuffer[ PoolMappingElementTable::elementTypeColumn()].data<std::string>()= iElem->second.elementType;
860  dataBuffer[ PoolMappingElementTable::scopeNameColumn() ].data<std::string>()= scopeName;
861  dataBuffer[ PoolMappingElementTable::variableNameColumn() ].data<std::string>()= iElem->second.variableName;
862  dataBuffer[ PoolMappingElementTable::variableParIndexColumn() ].data<unsigned int>() = iParamIndex;
863  dataBuffer[ PoolMappingElementTable::variableTypeColumn() ].data<std::string>()= iElem->second.variableType;
864  dataBuffer[ PoolMappingElementTable::tableNameColumn() ].data<std::string>()= iElem->second.tableName;
865  dataBuffer[ PoolMappingElementTable::columnNameColumn() ].data<std::string>()= iElem->second.columns[iParamIndex];
866  mappingElementTable.dataEditor().insertRow( dataBuffer );
867  }
868  }
869 }
870 
872  // Remove all rows in the tables with the version.
873  coral::AttributeList whereData;
874  whereData.extend<std::string>( PoolMappingVersionTable::mappingVersionColumn() );
875  whereData.begin()->data<std::string>() = version;
876 
878  m_schema.tableHandle( PoolClassVersionTable::tableName() ).dataEditor().deleteRows( condition, whereData );
879  m_schema.tableHandle( PoolMappingElementTable::tableName() ).dataEditor().deleteRows( condition, whereData );
880  m_schema.tableHandle( PoolMappingVersionTable::tableName() ).dataEditor().deleteRows( condition, whereData );
881 }
882 
883 bool ora::PoolMappingSchema::getContainerTableMap( std::map<std::string, int>&){
884  // not implemented for the moment
885  return false;
886 }
887 
889  std::set<std::string>& dest,
890  bool onlyDependency ){
891  bool ret = false;
892  std::auto_ptr<coral::IQuery> query( m_schema.newQuery() );
893  query->addToTableList( PoolClassVersionTable::tableName(), "T0" );
894  query->addToTableList( PoolContainerHeaderTable::tableName(), "T1" );
895  query->addToTableList( PoolMappingElementTable::tableName(), "T2" );
896  query->addToOutputList( "T0."+PoolClassVersionTable::mappingVersionColumn() );
897  query->setDistinct();
898  std::ostringstream condition;
902  coral::AttributeList condData;
903  condData.extend< int >( PoolContainerHeaderTable::containerIdColumn() );
904  condData[ PoolContainerHeaderTable::containerIdColumn() ].data< int >() = containerId + 1; //POOL starts counting from 1!;
905  if( onlyDependency ){
907  condData.extend< std::string >( PoolMappingElementTable::elementTypeColumn() );
909  }
910  query->setCondition(condition.str(),condData);
911  coral::ICursor& cursor = query->execute();
912  while ( cursor.next() ) {
913  ret = true;
914  const coral::AttributeList& currentRow = cursor.currentRow();
915  std::string mappingVersion = currentRow[ "T0."+PoolClassVersionTable::mappingVersionColumn() ].data<std::string>();
916  dest.insert( mappingVersion );
917  }
918  return ret;
919 }
920 
921 
923  std::set<std::string>& ){
924  // not implemented for the moment
925  return false;
926 }
927 
928 bool ora::PoolMappingSchema::getClassVersionListForMappingVersion( const std::string& mappingVersion,
929  std::set<std::string>& destination ){
930 
931  bool ret = false;
932  coral::ITable& classVersionTable = m_schema.tableHandle( PoolClassVersionTable::tableName() );
933  std::auto_ptr<coral::IQuery> query( classVersionTable.newQuery() );
934  query->setDistinct();
935  query->addToOutputList( PoolClassVersionTable::classVersionColumn() );
936  std::ostringstream condition;
938  coral::AttributeList condData;
939  condData.extend<std::string>(PoolClassVersionTable::mappingVersionColumn());
940  condData[ PoolClassVersionTable::mappingVersionColumn() ].data< std::string >() = mappingVersion;
941  query->setCondition(condition.str(),condData);
942  coral::ICursor& cursor = query->execute();
943  while ( cursor.next() ) {
944  ret = true;
945  const coral::AttributeList& currentRow = cursor.currentRow();
946  std::string classVersion = currentRow[ PoolClassVersionTable::classVersionColumn() ].data<std::string>();
947  destination.insert( classVersion );
948  }
949  return ret;
950 }
951 
953  std::map<std::string,std::string>& versionMap ){
954 
955  bool ret = false;
956  std::auto_ptr<coral::IQuery> query( m_schema.newQuery() );
957  query->addToTableList( PoolClassVersionTable::tableName(), "T0" );
958  query->addToTableList( PoolContainerHeaderTable::tableName(), "T1" );
959  query->addToOutputList( "T0."+PoolClassVersionTable::classVersionColumn() );
960  query->addToOutputList( "T0."+PoolClassVersionTable::mappingVersionColumn() );
961  query->setDistinct();
962  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  query->setCondition(condition.str(),condData);
969  coral::ICursor& cursor = query->execute();
970  while ( cursor.next() ) {
971  ret = true;
972  const coral::AttributeList& currentRow = cursor.currentRow();
973  std::string classVersion = currentRow[ "T0."+PoolClassVersionTable::classVersionColumn() ].data<std::string>();
974  std::string mappingVersion = currentRow[ "T0."+PoolClassVersionTable::mappingVersionColumn() ].data<std::string>();
975  versionMap.insert( std::make_pair(classVersion, mappingVersion ) );
976  }
977  return ret;
978 }
979 
981  std::set<std::string>& ){
982  // not implemented for the moment
983  return false;
984 }
985 
986 bool ora::PoolMappingSchema::selectMappingVersion( const std::string& classId,
987  int containerId,
988  std::string& destination ){
989  bool ret = false;
990  destination.clear();
991 
992  std::pair<bool,std::string> isBaseId = MappingRules::classNameFromBaseId( classId );
993  if( !isBaseId.first ){
994  std::auto_ptr<coral::IQuery> query( m_schema.newQuery() );
995  query->addToTableList( PoolClassVersionTable::tableName(), "T0" );
996  query->addToTableList( PoolContainerHeaderTable::tableName(), "T1" );
997  query->addToOutputList( "T0."+PoolClassVersionTable::mappingVersionColumn() );
998  std::ostringstream condition;
1002  coral::AttributeList condData;
1003  condData.extend<std::string>( PoolClassVersionTable::classVersionColumn() );
1004  condData.extend<int>( PoolContainerHeaderTable::containerIdColumn() );
1005  coral::AttributeList::iterator iAttribute = condData.begin();
1006  iAttribute->data< std::string >() = MappingRules::classVersionFromId( classId );
1007  ++iAttribute;
1008  iAttribute->data< int >() = containerId + 1; //POOL starts counting from 1!;
1009  query->setCondition( condition.str(), condData );
1010  coral::ICursor& cursor = query->execute();
1011  while ( cursor.next() ) {
1012  ret = true;
1013  const coral::AttributeList& currentRow = cursor.currentRow();
1014  destination = currentRow["T0."+PoolClassVersionTable::mappingVersionColumn()].data<std::string>();
1015  }
1016  } else {
1017  PoolDbCacheData& containerData = m_dbCache->find( containerId );
1018  // in POOL db this will be only possible for top level classes (not for dependencies)
1019  if( containerData.m_className == isBaseId.second ){
1020  destination = containerData.m_mappingVersion;
1021  ret = true;
1022  }
1023  }
1024 
1025  return ret;
1026 }
1027 
1029  int& ){
1030  // not implemented for the moment
1031  return false;
1032 }
1033 
1034 void ora::PoolMappingSchema::insertClassVersion( const std::string&, //className
1035  const std::string& classVersion,
1036  const std::string&, //classId
1037  int, // dependencyIndex,
1038  int containerId,
1039  const std::string& mappingVersion ){
1040  if(!m_dbCache){
1041  throwException("MappingSchema handle has not been initialized.","PoolMappingSchema::insertClassVersion");
1042  }
1043 
1044  coral::ITable& classVersionTable = m_schema.tableHandle( PoolClassVersionTable::tableName() );
1045  coral::AttributeList inputData;
1046  inputData.extend<std::string>( PoolClassVersionTable::mappingVersionColumn());
1047  inputData.extend<std::string>( PoolClassVersionTable::classVersionColumn());
1048  inputData.extend<std::string>( PoolClassVersionTable::containerNameColumn());
1049 
1050  std::string containerName = m_dbCache->nameById( containerId );
1051  coral::AttributeList::iterator iInAttr = inputData.begin();
1052  iInAttr->data< std::string >() = mappingVersion;
1053  ++iInAttr;
1054  iInAttr->data< std::string >() = classVersion;
1055  ++iInAttr;
1056  iInAttr->data< std::string >() = containerName;
1057  classVersionTable.dataEditor().insertRow( inputData );
1058 }
1059 
1060 void ora::PoolMappingSchema::setMappingVersion( const std::string& classId,
1061  int containerId,
1062  const std::string& mappingVersion ){
1063  if(!m_dbCache){
1064  throwException("MappingSchema handle has not been initialized.","PoolMappingSchema::setMappingVersion");
1065  }
1066  coral::ITable& classVersionTable = m_schema.tableHandle( PoolClassVersionTable::tableName() );
1067  coral::AttributeList inputData;
1068  inputData.extend<std::string>( PoolClassVersionTable::mappingVersionColumn());
1069  inputData.extend<std::string>( PoolClassVersionTable::classVersionColumn());
1070  inputData.extend<std::string>( PoolClassVersionTable::containerNameColumn());
1071  std::string classVersion = MappingRules::classVersionFromId( classId );
1072  std::string containerName = m_dbCache->nameById( containerId );
1073  coral::AttributeList::iterator iInAttr = inputData.begin();
1074  iInAttr->data< std::string >() = mappingVersion;
1075  ++iInAttr;
1076  iInAttr->data< std::string >() = classVersion;
1077  ++iInAttr;
1078  iInAttr->data< std::string >() = containerName;
1080  std::string whereClause = PoolClassVersionTable::classVersionColumn()+" =:"+ PoolClassVersionTable::classVersionColumn()+" AND "+
1082  classVersionTable.dataEditor().updateRows( setClause,whereClause, inputData );
1083 }
1084 
1086  static std::string s_name("METADATA");
1087  return s_name;
1088 }
1089 
1091  static std::string s_column("NAME");
1092  return s_column;
1093 }
1094 
1096  static std::string s_column("TOKEN");
1097  return s_column;
1098 }
1099 
1101  static std::string s_column("TIMETYPE");
1102  return s_column;
1103 }
1104 
1106  PoolDbCache& dbCache ):
1107  m_schema( dbSchema ),
1108  m_dbCache( dbCache ){
1109 }
1110 
1112 }
1113 
1115  int contId, int itemId ){
1116  coral::AttributeList dataToInsert;
1117  dataToInsert.extend<std::string>( objectNameColumn() );
1118  dataToInsert.extend<std::string>( tokenColumn());
1119  dataToInsert.extend<int>( timetypeColumn());
1120  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1121  std::string token = cond::writeToken( contData.m_name, contId, itemId, contData.m_className );
1122  dataToInsert[ objectNameColumn() ].data<std::string>() = name;
1123  dataToInsert[ tokenColumn() ].data<std::string>() = token;
1124  dataToInsert[ timetypeColumn() ].data<int>() = -1; // is it fine ???
1125  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
1126  containerTable.dataEditor().insertRow( dataToInsert );
1127 }
1128 
1130  coral::AttributeList whereData;
1131  whereData.extend<std::string>( objectNameColumn() );
1132  whereData.begin()->data<std::string>() = name;
1133  std::string condition = objectNameColumn() + " = :" + objectNameColumn();
1134  return m_schema.tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1135 }
1136 
1138  std::string condition("");
1139  coral::AttributeList whereData;
1140  return m_schema.tableHandle( tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1141 }
1142 
1144  std::pair<int,int>& destination ){
1145  bool ret = false;
1146  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
1147  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1148  coral::AttributeList outputBuffer;
1149  outputBuffer.extend<std::string>( tokenColumn() );
1150  query->defineOutput( outputBuffer );
1151  query->addToOutputList( tokenColumn() );
1152  std::ostringstream condition;
1153  condition << objectNameColumn()<<"= :"<< objectNameColumn();
1154  coral::AttributeList condData;
1155  condData.extend<std::string>( objectNameColumn() );
1156  coral::AttributeList::iterator iAttribute = condData.begin();
1157  iAttribute->data< std::string >() = name;
1158  query->setCondition( condition.str(), condData );
1159  coral::ICursor& cursor = query->execute();
1160  while ( cursor.next() ) {
1161  ret = true;
1162  const coral::AttributeList& row = cursor.currentRow();
1163  std::string token = row[ tokenColumn() ].data< std::string >();
1164  std::pair<std::string,int> tokData = cond::parseToken( token );
1165  destination.first = m_dbCache.idByName( tokData.first );
1166  destination.second = tokData.second;
1167  }
1168  return ret;
1169 }
1170 
1172  int itemId,
1173  std::vector<std::string>& destination ){
1174  bool ret = false;
1175  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
1176  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1177  coral::AttributeList outputBuffer;
1178  outputBuffer.extend<std::string>( objectNameColumn() );
1179  query->defineOutput( outputBuffer );
1180  query->addToOutputList( objectNameColumn() );
1181  std::ostringstream condition;
1182  condition << tokenColumn()<<"= :"<< tokenColumn();
1183  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1184  std::string token = cond::writeToken( contData.m_name, contId, itemId, contData.m_className );
1185  coral::AttributeList condData;
1186  condData.extend<std::string>( tokenColumn() );
1187  coral::AttributeList::iterator iAttribute = condData.begin();
1188  iAttribute->data< std::string >() = token;
1189  query->setCondition( condition.str(), condData );
1190  coral::ICursor& cursor = query->execute();
1191  while ( cursor.next() ) {
1192  ret = true;
1193  const coral::AttributeList& row = cursor.currentRow();
1194  std::string name = row[ objectNameColumn() ].data< std::string >();
1195  destination.push_back( name );
1196  }
1197  return ret;
1198 }
1199 
1201  std::vector<std::string>& destination ){
1202 
1203  bool ret = false;
1204  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
1205  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1206  coral::AttributeList outputBuffer;
1207  outputBuffer.extend<std::string>( objectNameColumn() );
1208  query->defineOutput( outputBuffer );
1209  query->addToOutputList( objectNameColumn() );
1210  std::ostringstream condition;
1211  condition << tokenColumn()<<" LIKE :"<< tokenColumn();
1212  ora::PoolDbCacheData& contData = m_dbCache.find( contId );
1213  std::string tokenFragment = cond::writeTokenContainerFragment( contData.m_name, contData.m_className )+"%";
1214  coral::AttributeList condData;
1215  condData.extend<std::string>( tokenColumn() );
1216  coral::AttributeList::iterator iAttribute = condData.begin();
1217  iAttribute->data< std::string >() = tokenFragment;
1218  query->setCondition( condition.str(), condData );
1219  coral::ICursor& cursor = query->execute();
1220  while ( cursor.next() ) {
1221  ret = true;
1222  const coral::AttributeList& row = cursor.currentRow();
1223  std::string name = row[ objectNameColumn() ].data< std::string >();
1224  destination.push_back( name );
1225  }
1226  return ret;
1227 }
1228 
1229 bool ora::CondMetadataTable::getAllNames( std::vector<std::string>& destination ){
1230 
1231  bool ret = false;
1232  coral::ITable& containerTable = m_schema.tableHandle( tableName() );
1233  std::auto_ptr<coral::IQuery> query( containerTable.newQuery());
1234  coral::AttributeList outputBuffer;
1235  outputBuffer.extend<std::string>( objectNameColumn() );
1236  query->defineOutput( outputBuffer );
1237  query->addToOutputList( objectNameColumn() );
1238  coral::ICursor& cursor = query->execute();
1239  while ( cursor.next() ) {
1240  ret = true;
1241  const coral::AttributeList& row = cursor.currentRow();
1242  std::string name = row[ objectNameColumn() ].data< std::string >();
1243  destination.push_back( name );
1244  }
1245  return ret;
1246 }
1247 
1249  return m_schema.existsTable( tableName() );
1250 }
1251 
1253  if( m_schema.existsTable( tableName() )){
1254  throwException( "Metadata table already exists in this schema.",
1255  "CondMetadataTable::create");
1256  }
1257  throwException( "Cond Metadata table cannot be created.","CondMetadataTable::create");
1258 }
1259 
1261  if( !m_schema.existsTable( tableName() )){
1262  throwException( "Metadata table does not exists in this schema.",
1263  "CondMetadataTable::drop");
1264  }
1265  throwException( "Cond Metadata table cannot be dropped.","CondMetadataTable::drop");
1266 }
1267 
1268 bool ora::PoolDatabaseSchema::existsMainTable( coral::ISchema& dbSchema ){
1269  PoolMainTable tmp( dbSchema );
1270  return tmp.exists();
1271 }
1272 
1274  IDatabaseSchema( dbSchema ),
1275  m_schema( dbSchema ),
1276  m_dbCache(),
1277  m_mainTable( dbSchema ),
1278  m_sequenceTable( dbSchema ),
1279  m_mappingVersionTable( dbSchema ),
1280  m_mappingElementTable( dbSchema ),
1281  m_containerHeaderTable( dbSchema ),
1282  m_classVersionTable( dbSchema ),
1283  m_mappingSchema( dbSchema ),
1284  m_metadataTable( dbSchema, m_dbCache ){
1288 }
1289 
1291 }
1292 
1294  if(!m_mainTable.exists()){
1295  return false;
1296  }
1297 
1298  if(!m_sequenceTable.exists() ||
1299  !m_mappingVersionTable.exists() ||
1300  !m_mappingElementTable.exists() ||
1301  !m_containerHeaderTable.exists() ||
1302  !m_classVersionTable.exists()){
1303  throwException( "POOL database is corrupted..",
1304  "PoolDatabaseSchema::exists");
1305  }
1306  if( !m_metadataTable.exists()){
1307  throwException( "Metadata table has not been found.",
1308  "PoolDatabaseSchema::exists");
1309  }
1310  return true;
1311 }
1312 
1314  throwException( "POOL database cannot be created.","PoolDatabaseSchema::create");
1315 }
1316 
1318  m_classVersionTable.drop();
1319  m_mappingElementTable.drop();
1320  m_sequenceTable.drop();
1321  m_containerHeaderTable.drop();
1322  m_mappingVersionTable.drop();
1323  m_mainTable.drop();
1324 }
1325 
1327  return m_mainTable;
1328 }
1329 
1331  return m_sequenceTable;
1332 }
1333 
1335  return m_mappingVersionTable;
1336 }
1337 
1339  return m_mappingElementTable;
1340 }
1341 
1343  return m_containerHeaderTable;
1344 }
1345 
1347  return m_classVersionTable;
1348 }
1349 
1351  return m_mappingSchema;
1352 }
1353 
1355  return m_metadataTable;
1356 }
1357 
1358 
IDatabaseTable & mappingElementTable()
IMappingSchema & mappingSchema()
void init(PoolDbCache &dbCache)
static std::string numberOfWrittenObjectsColumn()
static std::string tableName()
MappingRawElement & addElement(int elementId)
static std::string & objectNameColumn()
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)
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)
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 emptyScope()
static std::string classVersionColumn()
std::string poolSchemaVersion()
IDatabaseTable & mappingVersionTable()
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:28
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()
bool containerForMappingVersion(const std::string &mappingVersion, int &destination)
static std::string emptyScope()
static bool existsMainTable(coral::ISchema &dbSchema)
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)
Definition: MappingRules.cc:51
static std::string homogeneousContainerType()
PoolContainerHeaderTable(coral::ISchema &dbSchema)
static std::pair< bool, std::string > classNameFromBaseId(const std::string &classId)
Definition: MappingRules.cc:72
static std::string sequenceNameColumn()
static std::string & tokenColumn()
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()
static std::string sequenceValueColumn()
IContainerHeaderTable & containerHeaderTable()
void init(PoolDbCache &dbCache)
PoolMappingVersionTable(coral::ISchema &dbSchema)
bool getAllNames(std::vector< std::string > &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)
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()
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:14
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:9
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.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 & timetypeColumn()
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
static std::string & tableName()
std::string schemaVersion()
bool getDependentClassesInContainerMapping(int containerId, std::set< std::string > &destination)
void erase(const std::string &sequenceName)