CMS 3D CMS Logo

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

#include <RelationalMapping.h>

Inheritance diagram for ora::ArrayMapping:
ora::IRelationalMapping

Public Member Functions

 ArrayMapping (const edm::TypeWithDict &attributeType, TableRegister &tableRegister)
 
void process (MappingElement &parentElement, const std::string &attributeName, const std::string &attributeNameForSchema, const std::string &scopeNameForSchema)
 
 ~ArrayMapping ()
 
- Public Member Functions inherited from ora::IRelationalMapping
virtual ~IRelationalMapping ()
 

Private Attributes

TableRegisterm_tableRegister
 
edm::TypeWithDict m_type
 

Detailed Description

Definition at line 129 of file RelationalMapping.h.

Constructor & Destructor Documentation

ora::ArrayMapping::ArrayMapping ( const edm::TypeWithDict attributeType,
TableRegister tableRegister 
)

Definition at line 353 of file RelationalMapping.cc.

353  :
354  m_type(attributeType), m_tableRegister( tableRegister ){
355 }
TableRegister & m_tableRegister
edm::TypeWithDict m_type
ora::ArrayMapping::~ArrayMapping ( )

Definition at line 357 of file RelationalMapping.cc.

357  {
358 }

Member Function Documentation

void ora::ArrayMapping::process ( MappingElement parentElement,
const std::string &  attributeName,
const std::string &  attributeNameForSchema,
const std::string &  scopeNameForSchema 
)
virtual

Implements ora::IRelationalMapping.

Definition at line 360 of file RelationalMapping.cc.

References ora::MappingElement::appendSubElement(), ora::MappingElement::arrayMappingElementType(), className(), ora::MappingRules::columnNameForId(), ora::MappingRules::columnNameForPosition(), ora::MappingElement::columnNames(), mps_check::columns, ora::ClassUtils::containerDataType(), ora::ClassUtils::containerKeyType(), ora::ClassUtils::containerValueType(), i, ora::ClassUtils::isTypeAssociativeContainer(), ora::ClassUtils::isTypeNonAssociativeContainer(), ora::ClassUtils::isTypePVector(), ora::ClassUtils::isTypeQueryableVector(), ora::MappingRules::MaxTableNameLength, hlt_dqm_clientPB-live_cfg::me, ora::MappingRules::newNameForArraySchemaObject(), ora::RelationalMappingFactory::newProcessor(), ora::MappingElement::OraArrayMappingElementType(), ora::ClassUtils::resolvedType(), ora::MappingElement::setColumnNames(), AlCaHLTBitMon_QueryRunRegistry::string, HLT_25ns10e33_v2_cff::tableName, ora::MappingElement::tableName(), ora::throwException(), ora::MappingRules::variableNameForContainerKey(), and ora::MappingRules::variableNameForContainerValue().

Referenced by ConfigBuilder.ConfigBuilder::addExtraStream(), ConfigBuilder.ConfigBuilder::completeInputCommand(), ConfigBuilder.ConfigBuilder::doNotInlineEventContent(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::dumpPython(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::open(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::outputEventContent(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), ConfigBuilder.ConfigBuilder::prepare_PATFILTER(), ConfigBuilder.ConfigBuilder::prepare_VALIDATION(), ConfigBuilder.ConfigBuilder::renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder::renameInputTagsInSequence(), ConfigBuilder.ConfigBuilder::scheduleSequence(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProcess(), and Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProperty().

363  {
364  std::string tableName = parentElement.tableName();
365  std::string initialTable(tableName);
366 
367  std::string arrayTable(initialTable);
368  unsigned int i=0;
369  while(m_tableRegister.checkTable(arrayTable)){
371  i++;
372  }
373  m_tableRegister.insertTable(arrayTable);
374 
376 
380  }
381  ora::MappingElement& me = parentElement.appendSubElement( elementType,attributeName,className,arrayTable );
382  const std::vector<std::string>& parentColumns = parentElement.columnNames();
383  if( parentColumns.empty()){
384  throwException( "No column name found in the parent mapping element.","ArrayMapping::process");
385  }
386 
387  std::vector<std::string> columns;
388  // always comes the oid first
389  columns.push_back( ora::MappingRules::columnNameForId() );
390  std::vector<std::string>::const_iterator iColumn = parentColumns.begin();
391  // then copy the columns except the id...
392  iColumn++;
393  for ( ;iColumn != parentColumns.end(); iColumn++ ) {
394  columns.push_back( ora::MappingRules::columnNameForId() + "_" + *iColumn );
395  }
396  // and finally add the position!
397  columns.push_back( ora::MappingRules::columnNameForPosition() );
398 
399  me.setColumnNames( columns );
400  m_tableRegister.insertColumns(arrayTable, columns );
401 
402  std::string arrayScopeNameForSchema = scopeNameForSchema;
403  if( !arrayScopeNameForSchema.empty() ) arrayScopeNameForSchema +="_";
404  arrayScopeNameForSchema += attributeNameForSchema;
405 
406 
407  bool singleItemContainer = ora::ClassUtils::isTypeNonAssociativeContainer(m_type);
408  bool associativeContainer = ora::ClassUtils::isTypeAssociativeContainer(m_type);
409 
410  edm::TypeWithDict contentType;
411  edm::TypeWithDict keyType;
412  std::string contentTypeName;
413 
414  if( singleItemContainer ){
415  contentType = ClassUtils::containerValueType(m_type);
416  contentTypeName = "value_type";
417  }
418  else if ( associativeContainer ) { // This is an associative container type
419  contentType = ClassUtils::containerDataType( m_type );
420  contentTypeName = "mapped_type";
422  if( !keyType || !ClassUtils::resolvedType(keyType) ){
423  throwException( "Cannot not resolve the type of the key item of container \""+m_type.cppName()+"\".",
424  "ArrayMapping::process");
425  }
426  }
427  else {
428  // Not supported container
429  throwException( "Container type=\""+m_type.cppName()+"\".is not supported.",
430  "ArrayMapping::process");
431  }
432 
433  if( !contentType || !ClassUtils::resolvedType(contentType) ){
434  throwException( "Cannot not resolve the type of the content item of container \""+m_type.cppName()+"\".",
435  "ArrayMapping::process");
436  }
437  RelationalMappingFactory mappingFactory( m_tableRegister );
438  if ( keyType ) {
439  std::string keyTypeName = "key_type";
441  std::auto_ptr<IRelationalMapping> keyProcessor( mappingFactory.newProcessor( keyType ) );
442  keyProcessor->process( me, keyTypeName, keyTypeNameForSchema, arrayScopeNameForSchema );
443  }
444  std::string contentTypeNameForSchema = MappingRules::variableNameForContainerValue();
445  std::auto_ptr<IRelationalMapping> contentProcessor( mappingFactory.newProcessor( contentType ) );
446  contentProcessor->process( me, contentTypeName, contentTypeNameForSchema, arrayScopeNameForSchema );
447 }
int i
Definition: DBlmapReader.cc:9
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
static std::string arrayMappingElementType()
Returns the name of the array mapping element type.
static std::string variableNameForContainerKey()
bool insertColumns(const std::string &tableName, const std::vector< std::string > &columns)
static std::string variableNameForContainerValue()
TableRegister & m_tableRegister
bool isTypeNonAssociativeContainer(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:301
static std::string columnNameForPosition()
std::string cppName() const
bool isTypePVector(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:355
edm::TypeWithDict m_type
void insertTable(const std::string &tableName)
static std::string newNameForArraySchemaObject(const std::string &initialName, unsigned int index, size_t maxLength)
static std::string columnNameForId()
bool isTypeAssociativeContainer(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:286
bool isTypeQueryableVector(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:367
edm::TypeWithDict containerKeyType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:429
edm::TypeWithDict containerDataType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:449
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static std::string OraArrayMappingElementType()
Returns the name of the ORA array mapping element type.
tuple columns
Definition: mps_check.py:210
edm::TypeWithDict containerValueType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:410
static const size_t MaxTableNameLength
Definition: MappingRules.h:19
bool checkTable(const std::string &tableName)
std::string className(const T &t)
Definition: ClassName.h:30
void setColumnNames(const std::vector< std::string > &columns)

Member Data Documentation

TableRegister& ora::ArrayMapping::m_tableRegister
private

Definition at line 139 of file RelationalMapping.h.

edm::TypeWithDict ora::ArrayMapping::m_type
private

Definition at line 138 of file RelationalMapping.h.