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

343  :
344  m_type(attributeType), m_tableRegister( tableRegister ){
345 }
TableRegister & m_tableRegister
ora::ArrayMapping::~ArrayMapping ( )

Definition at line 347 of file RelationalMapping.cc.

347  {
348 }

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 350 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 python.Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::dumpPython(), python.Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::open(), python.Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::outputEventContent(), python.Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProcess(), and python.Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProperty().

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

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.