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 Reflex::Type &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
 
Reflex::Type m_type
 

Detailed Description

Definition at line 129 of file RelationalMapping.h.

Constructor & Destructor Documentation

ora::ArrayMapping::ArrayMapping ( const Reflex::Type &  attributeType,
TableRegister tableRegister 
)

Definition at line 351 of file RelationalMapping.cc.

351  :
352  m_type(attributeType), m_tableRegister( tableRegister ){
353 }
TableRegister & m_tableRegister
ora::ArrayMapping::~ArrayMapping ( )

Definition at line 355 of file RelationalMapping.cc.

355  {
356 }

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 358 of file RelationalMapping.cc.

References ora::MappingElement::appendSubElement(), ora::MappingElement::arrayMappingElementType(), className(), ora::MappingRules::columnNameForId(), ora::MappingRules::columnNameForPosition(), ora::MappingElement::columnNames(), 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, ora::MappingRules::newNameForArraySchemaObject(), ora::RelationalMappingFactory::newProcessor(), ora::MappingElement::OraArrayMappingElementType(), ora::ClassUtils::resolvedType(), ora::MappingElement::setColumnNames(), ora::MappingElement::tableName(), ora::throwException(), ora::MappingRules::variableNameForContainerKey(), and ora::MappingRules::variableNameForContainerValue().

Referenced by Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::dumpPython(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::open(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::outputEventContent(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProcess(), and Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProperty().

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

Member Data Documentation

TableRegister& ora::ArrayMapping::m_tableRegister
private

Definition at line 139 of file RelationalMapping.h.

Reflex::Type ora::ArrayMapping::m_type
private

Definition at line 138 of file RelationalMapping.h.