CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
ora::PoolMappingSchema Class Reference

#include <PoolDatabaseSchema.h>

Inheritance diagram for ora::PoolMappingSchema:
ora::IMappingSchema

Public Member Functions

bool containerForMappingVersion (const std::string &mappingVersion, int &destination)
 
bool getClassVersionListForContainer (int containerId, std::map< std::string, std::string > &versionMap)
 
bool getClassVersionListForMappingVersion (const std::string &mappingVersion, std::set< std::string > &destination)
 
bool getContainerTableMap (std::map< std::string, int > &destination)
 
bool getDependentClassesInContainerMapping (int containerId, std::set< std::string > &destination)
 
bool getMapping (const std::string &version, MappingRawData &destination)
 
bool getMappingVersionListForContainer (int containerId, std::set< std::string > &destination, bool onlyDependency=false)
 
bool getMappingVersionListForTable (const std::string &tableName, std::set< std::string > &destination)
 
bool getVersionList (std::set< std::string > &destination)
 
void init (PoolDbCache &dbCache)
 
void insertClassVersion (const std::string &className, const std::string &classVersion, const std::string &classId, int dependencyIndex, int containerId, const std::string &mappingVersion)
 
 PoolMappingSchema (coral::ISchema &dbSchema)
 
void removeMapping (const std::string &version)
 
bool selectMappingVersion (const std::string &classId, int containerId, std::string &destination)
 
void setMappingVersion (const std::string &classId, int containerId, const std::string &mappingVersion)
 
void storeMapping (const MappingRawData &mapping)
 
virtual ~PoolMappingSchema ()
 
- Public Member Functions inherited from ora::IMappingSchema
virtual ~IMappingSchema ()
 

Static Public Member Functions

static std::string emptyScope ()
 

Private Attributes

PoolDbCachem_dbCache
 
coral::ISchema & m_schema
 

Detailed Description

Definition at line 173 of file PoolDatabaseSchema.h.

Constructor & Destructor Documentation

ora::PoolMappingSchema::PoolMappingSchema ( coral::ISchema &  dbSchema)
explicit

Definition at line 750 of file PoolDatabaseSchema.cc.

750  :
751  m_schema( dbSchema ),
752  m_dbCache( 0 ){
753 }
ora::PoolMappingSchema::~PoolMappingSchema ( )
virtual

Definition at line 755 of file PoolDatabaseSchema.cc.

755  {
756 }

Member Function Documentation

bool ora::PoolMappingSchema::containerForMappingVersion ( const std::string &  mappingVersion,
int &  destination 
)
virtual

Implements ora::IMappingSchema.

Definition at line 1091 of file PoolDatabaseSchema.cc.

1092  {
1093  // not implemented for the moment
1094  return false;
1095 }
std::string ora::PoolMappingSchema::emptyScope ( )
static

Definition at line 745 of file PoolDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

745  {
746  static const std::string s_scope(" ");
747  return s_scope;
748 }
bool ora::PoolMappingSchema::getClassVersionListForContainer ( int  containerId,
std::map< std::string, std::string > &  versionMap 
)
virtual

Implements ora::IMappingSchema.

Definition at line 1015 of file PoolDatabaseSchema.cc.

References ora::PoolClassVersionTable::classVersionColumn(), ora::PoolContainerHeaderTable::containerIdColumn(), ora::PoolContainerHeaderTable::containerNameColumn(), ora::PoolClassVersionTable::containerNameColumn(), ora::PoolClassVersionTable::mappingVersionColumn(), o2o::query, run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, ora::PoolContainerHeaderTable::tableName(), and ora::PoolClassVersionTable::tableName().

1016  {
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 }
static std::string containerNameColumn()
static std::string containerIdColumn()
static std::string classVersionColumn()
static std::string mappingVersionColumn()
tuple query
Definition: o2o.py:269
static std::string tableName()
static std::string containerNameColumn()
bool ora::PoolMappingSchema::getClassVersionListForMappingVersion ( const std::string &  mappingVersion,
std::set< std::string > &  destination 
)
virtual

Implements ora::IMappingSchema.

Definition at line 991 of file PoolDatabaseSchema.cc.

References ora::PoolClassVersionTable::classVersionColumn(), ora::PoolClassVersionTable::mappingVersionColumn(), o2o::query, run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, and ora::PoolClassVersionTable::tableName().

992  {
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 }
string destination
static std::string classVersionColumn()
static std::string mappingVersionColumn()
tuple query
Definition: o2o.py:269
static std::string tableName()
bool ora::PoolMappingSchema::getContainerTableMap ( std::map< std::string, int > &  destination)
virtual

Implements ora::IMappingSchema.

Definition at line 946 of file PoolDatabaseSchema.cc.

946  {
947  // not implemented for the moment
948  return false;
949 }
bool ora::PoolMappingSchema::getDependentClassesInContainerMapping ( int  containerId,
std::set< std::string > &  destination 
)
virtual

Implements ora::IMappingSchema.

Definition at line 985 of file PoolDatabaseSchema.cc.

986  {
987  // not implemented for the moment
988  return false;
989 }
bool ora::PoolMappingSchema::getMapping ( const std::string &  version,
ora::MappingRawData dest 
)
virtual

Implements ora::IMappingSchema.

Definition at line 792 of file PoolDatabaseSchema.cc.

References ora::MappingRawData::addElement(), ora::MappingElement::classMappingElementType(), ora::PoolMappingElementTable::columnNameColumn(), HTMLExport::elem(), ora::MappingRawElement::elementType, ora::PoolMappingElementTable::elementTypeColumn(), ora::MappingRawElement::emptyScope(), ora::mappingTypeFromPool(), ora::PoolMappingElementTable::mappingVersionColumn(), ora::MappingElement::objectMappingElementType(), o2o::query, ora::rebuildPoolMapping(), run_regression::ret, ora::MappingRawElement::scopeName, ora::PoolMappingElementTable::scopeNameColumn(), AlCaHLTBitMon_QueryRunRegistry::string, ora::MappingRawElement::tableName, ora::PoolMappingElementTable::tableName(), ora::PoolMappingElementTable::tableNameColumn(), ora::MappingRawElement::variableName, ora::PoolMappingElementTable::variableNameColumn(), ora::variableNameFromPool(), ora::PoolMappingElementTable::variableParIndexColumn(), ora::MappingRawElement::variableType, and ora::PoolMappingElementTable::variableTypeColumn().

793  {
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 );
838  elem.variableType = currentRow[ PoolMappingElementTable::variableTypeColumn() ].data<std::string>();
839  elem.tableName = currentRow[ PoolMappingElementTable::tableNameColumn() ].data<std::string>();
840  if(elem.scopeName == emptyScope()) {
841  if( elem.elementType == MappingElement::objectMappingElementType() ){
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;
878  classElement.elementType = MappingElement::classMappingElementType();
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 }
MappingRawElement & addElement(int elementId)
static std::string tableNameColumn()
static std::string variableTypeColumn()
std::string mappingTypeFromPool(const std::string &mappingType)
static std::string columnNameColumn()
static std::string mappingVersionColumn()
static std::string variableParIndexColumn()
static std::string emptyScope()
static std::string emptyScope()
static std::string objectMappingElementType()
Returns the name of the object mapping element type.
void rebuildPoolMapping(const std::string &scope, const std::string &extraScope, const std::map< std::string, std::vector< MappingRawElement > > &elementsByScope, ora::MappingRawData &dest, int &counter)
std::string variableNameFromPool(const std::string &variableName)
static std::string scopeNameColumn()
static std::string variableNameColumn()
tuple query
Definition: o2o.py:269
static std::string classMappingElementType()
Returns the name of the class mapping element type.
static std::string elementTypeColumn()
bool ora::PoolMappingSchema::getMappingVersionListForContainer ( int  containerId,
std::set< std::string > &  destination,
bool  onlyDependency = false 
)
virtual

Implements ora::IMappingSchema.

Definition at line 951 of file PoolDatabaseSchema.cc.

References ora::PoolContainerHeaderTable::containerIdColumn(), ora::PoolContainerHeaderTable::containerNameColumn(), ora::PoolClassVersionTable::containerNameColumn(), ora::MappingElement::dependencyMappingElementType(), ora::PoolMappingElementTable::elementTypeColumn(), ora::PoolMappingElementTable::mappingVersionColumn(), ora::PoolClassVersionTable::mappingVersionColumn(), o2o::query, run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, ora::PoolMappingElementTable::tableName(), ora::PoolContainerHeaderTable::tableName(), and ora::PoolClassVersionTable::tableName().

953  {
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 }
static std::string containerNameColumn()
static std::string dependencyMappingElementType()
Returns the name of the dependent class mapping element type.
static std::string mappingVersionColumn()
static std::string containerIdColumn()
static std::string mappingVersionColumn()
tuple query
Definition: o2o.py:269
static std::string tableName()
static std::string containerNameColumn()
static std::string elementTypeColumn()
bool ora::PoolMappingSchema::getMappingVersionListForTable ( const std::string &  tableName,
std::set< std::string > &  destination 
)
virtual

Implements ora::IMappingSchema.

Definition at line 1043 of file PoolDatabaseSchema.cc.

1044  {
1045  // not implemented for the moment
1046  return false;
1047 }
bool ora::PoolMappingSchema::getVersionList ( std::set< std::string > &  destination)
virtual

Implements ora::IMappingSchema.

Definition at line 762 of file PoolDatabaseSchema.cc.

References ora::PoolMappingVersionTable::mappingVersionColumn(), o2o::query, run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, and ora::PoolMappingVersionTable::tableName().

762  {
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 }
tuple query
Definition: o2o.py:269
static std::string mappingVersionColumn()
void ora::PoolMappingSchema::init ( PoolDbCache dbCache)

Definition at line 758 of file PoolDatabaseSchema.cc.

Referenced by ora::PoolDatabaseSchema::PoolDatabaseSchema().

758  {
759  m_dbCache = &dbCache;
760 }
void ora::PoolMappingSchema::insertClassVersion ( const std::string &  className,
const std::string &  classVersion,
const std::string &  classId,
int  dependencyIndex,
int  containerId,
const std::string &  mappingVersion 
)
virtual

Implements ora::IMappingSchema.

Definition at line 1097 of file PoolDatabaseSchema.cc.

References ora::PoolClassVersionTable::classVersionColumn(), ora::PoolClassVersionTable::containerNameColumn(), idDealer::inputData, ora::PoolClassVersionTable::mappingVersionColumn(), AlCaHLTBitMon_QueryRunRegistry::string, ora::PoolClassVersionTable::tableName(), and ora::throwException().

1102  {
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 }
static std::string classVersionColumn()
const std::string & nameById(int id)
static std::string mappingVersionColumn()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static std::string tableName()
static std::string containerNameColumn()
tuple inputData
Definition: idDealer.py:72
void ora::PoolMappingSchema::removeMapping ( const std::string &  version)
virtual

Implements ora::IMappingSchema.

Definition at line 934 of file PoolDatabaseSchema.cc.

References ora::PoolMappingVersionTable::mappingVersionColumn(), AlCaHLTBitMon_QueryRunRegistry::string, ora::PoolMappingVersionTable::tableName(), ora::PoolMappingElementTable::tableName(), and ora::PoolClassVersionTable::tableName().

934  {
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 }
static std::string tableName()
static std::string mappingVersionColumn()
bool ora::PoolMappingSchema::selectMappingVersion ( const std::string &  classId,
int  containerId,
std::string &  destination 
)
virtual

Implements ora::IMappingSchema.

Definition at line 1049 of file PoolDatabaseSchema.cc.

References ora::MappingRules::classNameFromBaseId(), ora::PoolClassVersionTable::classVersionColumn(), ora::MappingRules::classVersionFromId(), ora::PoolContainerHeaderTable::containerIdColumn(), ora::PoolContainerHeaderTable::containerNameColumn(), ora::PoolClassVersionTable::containerNameColumn(), ora::PoolDbCacheData::m_className, ora::PoolDbCacheData::m_mappingVersion, ora::PoolClassVersionTable::mappingVersionColumn(), o2o::query, run_regression::ret, AlCaHLTBitMon_QueryRunRegistry::string, ora::PoolContainerHeaderTable::tableName(), and ora::PoolClassVersionTable::tableName().

1051  {
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();
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 }
static std::string containerNameColumn()
string destination
static std::string containerIdColumn()
static std::string classVersionColumn()
PoolDbCacheData & find(int id)
static std::string classVersionFromId(const std::string &classId)
Definition: MappingRules.cc:68
static std::pair< bool, std::string > classNameFromBaseId(const std::string &classId)
Definition: MappingRules.cc:89
static std::string mappingVersionColumn()
tuple query
Definition: o2o.py:269
static std::string tableName()
static std::string containerNameColumn()
void ora::PoolMappingSchema::setMappingVersion ( const std::string &  classId,
int  containerId,
const std::string &  mappingVersion 
)
virtual

Implements ora::IMappingSchema.

Definition at line 1123 of file PoolDatabaseSchema.cc.

References ora::PoolClassVersionTable::classVersionColumn(), ora::MappingRules::classVersionFromId(), ora::PoolClassVersionTable::containerNameColumn(), idDealer::inputData, ora::PoolClassVersionTable::mappingVersionColumn(), AlCaHLTBitMon_QueryRunRegistry::string, ora::PoolClassVersionTable::tableName(), and ora::throwException().

1125  {
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 }
static std::string classVersionColumn()
static std::string classVersionFromId(const std::string &classId)
Definition: MappingRules.cc:68
const std::string & nameById(int id)
static std::string mappingVersionColumn()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static std::string tableName()
static std::string containerNameColumn()
tuple inputData
Definition: idDealer.py:72
void ora::PoolMappingSchema::storeMapping ( const MappingRawData mapping)
virtual

Implements ora::IMappingSchema.

Definition at line 892 of file PoolDatabaseSchema.cc.

References ora::PoolMappingElementTable::columnNameColumn(), ora::PoolMappingElementTable::elementIdColumn(), ora::MappingRawData::elements, ora::PoolMappingElementTable::elementTypeColumn(), ora::MappingRawElement::emptyScope(), ora::PoolMappingVersionTable::mappingVersionColumn(), ora::PoolMappingElementTable::mappingVersionColumn(), ora::PoolMappingElementTable::scopeNameColumn(), AlCaHLTBitMon_QueryRunRegistry::string, ora::PoolMappingVersionTable::tableName(), ora::PoolMappingElementTable::tableName(), ora::PoolMappingElementTable::tableNameColumn(), ora::PoolMappingElementTable::variableNameColumn(), ora::PoolMappingElementTable::variableParIndexColumn(), ora::PoolMappingElementTable::variableTypeColumn(), and ora::MappingRawData::version.

892  {
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 }
static std::string tableNameColumn()
static std::string variableTypeColumn()
static std::string columnNameColumn()
static std::string mappingVersionColumn()
static std::string variableParIndexColumn()
static std::string elementIdColumn()
static std::string emptyScope()
static std::string scopeNameColumn()
static std::string variableNameColumn()
static std::string mappingVersionColumn()
static std::string elementTypeColumn()

Member Data Documentation

PoolDbCache* ora::PoolMappingSchema::m_dbCache
private

Definition at line 198 of file PoolDatabaseSchema.h.

coral::ISchema& ora::PoolMappingSchema::m_schema
private

Definition at line 197 of file PoolDatabaseSchema.h.