6 #include "RelationalAccess/ISchema.h"
7 #include "RelationalAccess/ITable.h"
8 #include "RelationalAccess/IQuery.h"
9 #include "RelationalAccess/ICursor.h"
10 #include "RelationalAccess/TableDescription.h"
11 #include "RelationalAccess/ITablePrivilegeManager.h"
12 #include "RelationalAccess/ITableDataEditor.h"
13 #include "RelationalAccess/IBulkOperation.h"
14 #include "CoralBase/Attribute.h"
27 static const std::string s_column(
"PARAMETER_NAME");
32 static const std::string s_column(
"PARAMETER_VALUE");
45 if( !paramName.empty() && !paramValue.empty() ){
47 coral::AttributeList dataToInsert;
48 dataToInsert.extend<
std::string>( parameterNameColumn());
49 dataToInsert.extend<
std::string>( parameterValueColumn());
50 dataToInsert[ parameterNameColumn() ].data<
std::string>() = paramName;
51 dataToInsert[ parameterValueColumn() ].data<
std::string>() = paramValue;
52 table.dataEditor().insertRow( dataToInsert );
59 std::auto_ptr<coral::IQuery>
query(mainTable.newQuery());
60 coral::ICursor& cursor =
query->execute();
61 while ( cursor.next() ) {
63 const coral::AttributeList& row = cursor.currentRow();
66 dest.insert( std::make_pair( paramName, paramValue ) );
86 throwException(
"ORA database main table already exists in this schema.",
87 "OraMainTable::create");
90 coral::TableDescription descr(
"OraDb" );
92 descr.insertColumn( parameterNameColumn(),
93 coral::AttributeSpecification::typeNameForType<std::string>() );
94 descr.insertColumn( parameterValueColumn(),
95 coral::AttributeSpecification::typeNameForType<std::string>() );
96 descr.setNotNullConstraint( parameterNameColumn() );
97 descr.setNotNullConstraint( parameterValueColumn() );
98 descr.setPrimaryKey( std::vector<std::string>( 1, parameterNameColumn() ) );
100 coral::ITable&
table =
schema().createTable( descr );
102 coral::AttributeList dataToInsert;
103 dataToInsert.extend<
std::string>( parameterNameColumn());
104 dataToInsert.extend<
std::string>( parameterValueColumn());
107 table.dataEditor().insertRow( dataToInsert );
137 m_tableName( tname ){
146 coral::AttributeList insertData;
147 insertData.extend<
std::string>(sequenceNameColumn());
148 insertData.extend<
int>(sequenceValueColumn());
149 coral::AttributeList::iterator iAttribute = insertData.begin();
152 iAttribute->data<
int >() = -1;
153 schema().tableHandle(
name() ).dataEditor().insertRow( insertData );
160 std::auto_ptr< coral::IQuery >
query(
schema().tableHandle(
name() ).newQuery() );
161 query->limitReturnedRows( 1, 0 );
162 query->addToOutputList( sequenceValueColumn() );
163 query->defineOutputType( sequenceValueColumn(), coral::AttributeSpecification::typeNameForType<int>() );
164 query->setForUpdate();
165 std::string whereClause( sequenceNameColumn() +
" = :" + sequenceNameColumn() );
166 coral::AttributeList rowData;
168 rowData.begin()->data<
std::string >() = sequenceName;
169 query->setCondition( whereClause, rowData );
170 coral::ICursor& cursor = query->execute();
171 if ( cursor.next() ) {
172 lastId = cursor.currentRow().begin()->data<
int >();
180 coral::AttributeList updateData;
181 updateData.extend<
std::string>(sequenceNameColumn());
182 updateData.extend<
int>(sequenceValueColumn());
183 std::string setClause( sequenceValueColumn() +
" = :" + sequenceValueColumn() );
184 std::string whereClause( sequenceNameColumn() +
" = :" + sequenceNameColumn() );
186 coral::AttributeList::iterator iAttribute = updateData.begin();
189 iAttribute->data<
int >() = lastValue;
190 schema().tableHandle(
name() ).dataEditor().updateRows( setClause,whereClause,updateData );
194 coral::AttributeList whereData;
195 whereData.extend<
std::string>(sequenceNameColumn());
196 whereData[ sequenceNameColumn() ].data<
std::string>() = sequenceName;
197 std::string whereClause( sequenceNameColumn() +
" = :" + sequenceNameColumn() );
198 schema().tableHandle(
name() ).dataEditor().deleteRows( whereClause, whereData );
211 throwException(
"ORA database sequence table already exists in this schema.",
212 "OraSequenceTable::create");
216 description.setName(
name() );
218 description.insertColumn( sequenceNameColumn(), coral::AttributeSpecification::typeNameForType<std::string>() );
219 description.setNotNullConstraint( sequenceNameColumn() );
221 description.insertColumn( sequenceValueColumn(),coral::AttributeSpecification::typeNameForType<int>() );
222 description.setNotNullConstraint( sequenceValueColumn() );
224 description.setPrimaryKey( std::vector< std::string >( 1, sequenceNameColumn() ) );
225 schema().createTable( description );
233 static const std::string s_table(
"ORA_MAPPING_VERSION");
259 throwException(
"ORA database mapping version table already exists in this schema.",
260 "OraMappingVersionTable::create");
263 coral::TableDescription description0(
"OraDb" );
265 description0.insertColumn( mappingVersionColumn(),
266 coral::AttributeSpecification::typeNameForType<std::string>(), 1000,
false);
267 description0.setNotNullConstraint( mappingVersionColumn() );
268 description0.setPrimaryKey( mappingVersionColumn() );
269 schema().createTable( description0 );
278 static const std::string s_table(
"ORA_MAPPING_ELEMENT");
308 static const std::string s_col(
"VARIABLE_PAR_INDEX");
345 throwException(
"ORA database mapping element table already exists in this schema.",
346 "OraMappingElementTable::create");
350 coral::TableDescription description2(
"OraDb" );
352 description2.insertColumn( mappingVersionColumn(),
353 coral::AttributeSpecification::typeNameForType<std::string>(), 1000,
false );
354 description2.setNotNullConstraint( mappingVersionColumn() );
355 description2.insertColumn( elementIdColumn(),
356 coral::AttributeSpecification::typeNameForType<int>() );
357 description2.setNotNullConstraint( elementIdColumn() );
358 description2.insertColumn( elementTypeColumn(),
359 coral::AttributeSpecification::typeNameForType<std::string>() );
360 description2.setNotNullConstraint( elementTypeColumn() );
361 description2.insertColumn( scopeNameColumn(),
362 coral::AttributeSpecification::typeNameForType<std::string>() );
363 description2.setNotNullConstraint( scopeNameColumn() );
364 description2.insertColumn( variableNameColumn(),
365 coral::AttributeSpecification::typeNameForType<std::string>() );
366 description2.setNotNullConstraint( variableNameColumn() );
367 description2.insertColumn( variableParIndexColumn(),
368 coral::AttributeSpecification::typeNameForType<unsigned int>() );
369 description2.setNotNullConstraint( variableParIndexColumn() );
370 description2.insertColumn( variableTypeColumn(),
371 coral::AttributeSpecification::typeNameForType<std::string>() );
372 description2.setNotNullConstraint( variableTypeColumn() );
373 description2.insertColumn( tableNameColumn(),
374 coral::AttributeSpecification::typeNameForType<std::string>() );
375 description2.setNotNullConstraint( tableNameColumn() );
376 description2.insertColumn( columnNameColumn(),
377 coral::AttributeSpecification::typeNameForType<std::string>() );
378 description2.setNotNullConstraint( columnNameColumn() );
379 std::vector<std::string> cols2;
380 cols2.push_back( elementIdColumn() );
381 cols2.push_back( variableParIndexColumn() );
382 description2.setPrimaryKey( cols2 );
383 std::string fkName20 = mappingVersionColumn()+
"_FK_1";
384 description2.createForeignKey( fkName20, mappingVersionColumn(),
386 schema().createTable( description2 );
407 static const std::string s_column(
"CONTAINER_NAME");
417 static const std::string s_column(
"NUMBER_OF_OBJECTS");
432 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
433 coral::AttributeList outputBuffer;
434 outputBuffer.extend<
int>( containerIdColumn() );
435 outputBuffer.extend<
std::string>( containerNameColumn() );
436 outputBuffer.extend<
std::string>( classNameColumn() );
437 outputBuffer.extend<
unsigned int>( numberOfObjectsColumn() );
438 query->defineOutput( outputBuffer );
439 coral::ICursor& cursor =
query->execute();
440 while ( cursor.next() ) {
442 const coral::AttributeList& row = cursor.currentRow();
443 int containerId = row[ containerIdColumn() ].data<
int >();
446 unsigned int numberOfObjects = row[ numberOfObjectsColumn()].data<
unsigned int >();
447 dest.insert( std::make_pair( containerName,
ContainerHeaderData( containerId, className, numberOfObjects ) )) ;
455 coral::AttributeList dataToInsert;
456 unsigned int numberOfObjects = 0;
457 dataToInsert.extend<
int>( containerIdColumn());
458 dataToInsert.extend<
std::string>( containerNameColumn());
459 dataToInsert.extend<
std::string>( classNameColumn());
460 dataToInsert.extend<
unsigned int>( numberOfObjectsColumn());
461 dataToInsert[ containerIdColumn() ].data<
int>() = containerId;
462 dataToInsert[ containerNameColumn() ].data<
std::string>() = containerName;
463 dataToInsert[ classNameColumn() ].data<
std::string>() = className;
464 dataToInsert[ numberOfObjectsColumn() ].data<
unsigned int>() = numberOfObjects;
466 containerTable.dataEditor().insertRow( dataToInsert );
470 std::stringstream whereClause;
471 whereClause << containerIdColumn() <<
"= :" <<containerIdColumn();
472 coral::AttributeList whereData;
473 whereData.extend<
int >( containerIdColumn() );
474 whereData.begin()->data<
int >() =
id;
476 containerTable.dataEditor().deleteRows(whereClause.str(),whereData);
481 std::stringstream whereClause;
482 whereClause << containerIdColumn() <<
"= :" <<containerIdColumn();
483 coral::AttributeList updateData;
484 updateData.extend<
int>( containerIdColumn() );
485 updateData.begin()->data<
int>() = containerId;
487 containerTable.dataEditor().updateRows(setClause,whereClause.str(),updateData);
493 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
494 query->addToOutputList( classNameColumn() );
495 query->defineOutputType( classNameColumn() , coral::AttributeSpecification::typeNameForType<std::string>() );
496 query->addToOutputList( numberOfObjectsColumn() );
497 query->defineOutputType( numberOfObjectsColumn() , coral::AttributeSpecification::typeNameForType<unsigned int>() );
498 std::stringstream whereClause;
499 whereClause << containerIdColumn() <<
"= :" <<containerIdColumn();
500 coral::AttributeList whereData;
501 whereData.extend<
int>( containerIdColumn() );
502 whereData.begin()->data<
int>() =
id;
503 query->setCondition( whereClause.str(), whereData );
504 query->setForUpdate();
505 coral::ICursor& cursor =
query->execute();
506 if( cursor.next() ) {
508 const coral::AttributeList& row = cursor.currentRow();
511 dest.
numberOfObjects = row[ numberOfObjectsColumn()].data<
unsigned int >();
517 std::stringstream setClause;
518 setClause << numberOfObjectsColumn() <<
" = " <<numberOfObjectsColumn() <<
" + 1";
519 return updateContainer( containerId, setClause.str() );
523 std::stringstream setClause;
524 setClause << numberOfObjectsColumn() <<
" = " <<numberOfObjectsColumn() <<
" - 1";
525 return updateContainer( containerId, setClause.str() );
529 if( numberOfObjectsForContainerIds.size() ){
531 std::stringstream whereClause;
532 whereClause << containerIdColumn() <<
"= :" <<containerIdColumn();
533 std::stringstream setClause;
534 setClause << numberOfObjectsColumn() <<
" = :" <<numberOfObjectsColumn();
535 coral::AttributeList updateData;
536 updateData.extend<
unsigned int>( numberOfObjectsColumn() );
537 updateData.extend<
int>( containerIdColumn() );
540 std::auto_ptr<coral::IBulkOperation> bulkUpdate( containerTable.dataEditor().bulkUpdateRows( setClause.str(), whereClause.str(), updateData,(int)numberOfObjectsForContainerIds.size()));
542 for( std::map<int,unsigned int>::const_iterator iCont = numberOfObjectsForContainerIds.begin();
543 iCont != numberOfObjectsForContainerIds.end(); ++iCont ){
544 updateData[containerIdColumn()].data<
int>() = iCont->first;
545 updateData[numberOfObjectsColumn()].data<
unsigned int>() = iCont->second;
546 bulkUpdate->processNextIteration();
562 throwException(
"ORA database container header table already exists in this schema.",
563 "OraContainerHeaderTable::create");
566 coral::TableDescription descr(
"OraDb" );
568 descr.insertColumn( containerIdColumn(),
569 coral::AttributeSpecification::typeNameForType<int>() );
570 descr.insertColumn( containerNameColumn(),
571 coral::AttributeSpecification::typeNameForType<std::string>() );
572 descr.insertColumn( classNameColumn(),
573 coral::AttributeSpecification::typeNameForType<std::string>() );
574 descr.insertColumn( numberOfObjectsColumn(),
575 coral::AttributeSpecification::typeNameForType<unsigned int>() );
576 descr.setNotNullConstraint( containerIdColumn() );
577 descr.setNotNullConstraint( containerNameColumn() );
578 descr.setNotNullConstraint( classNameColumn() );
579 descr.setNotNullConstraint( numberOfObjectsColumn() );
580 descr.setPrimaryKey( std::vector<std::string>( 1, containerIdColumn() ) );
581 descr.setUniqueConstraint( containerNameColumn() );
582 schema().createTable( descr );
590 static const std::string s_table(
"ORA_CLASS_VERSION");
610 static const std::string s_col(
"DEPENDENCY_INDEX");
643 throwException(
"ORA database class version table already exists in this schema.",
644 "OraClassVersionTable::create");
647 coral::TableDescription description1(
"OraDb" );
649 description1.insertColumn( classNameColumn(),
650 coral::AttributeSpecification::typeNameForType<std::string>(), 1000,
false);
651 description1.setNotNullConstraint( classNameColumn() );
652 description1.insertColumn( classVersionColumn(),
653 coral::AttributeSpecification::typeNameForType<std::string>(), 1000,
false);
654 description1.setNotNullConstraint( classVersionColumn() );
655 description1.insertColumn( classIdColumn(),
656 coral::AttributeSpecification::typeNameForType<std::string>(), 1000,
false);
657 description1.setNotNullConstraint( classIdColumn() );
658 description1.insertColumn( dependencyIndexColumn(),
659 coral::AttributeSpecification::typeNameForType<int>() );
660 description1.setNotNullConstraint( dependencyIndexColumn() );
661 description1.insertColumn( containerIdColumn(),
662 coral::AttributeSpecification::typeNameForType<int>() );
663 description1.setNotNullConstraint( containerIdColumn() );
664 description1.insertColumn( mappingVersionColumn(),
665 coral::AttributeSpecification::typeNameForType<std::string>(), 1000,
false);
666 description1.setNotNullConstraint( mappingVersionColumn() );
667 std::vector<std::string> cols1;
668 cols1.push_back( classIdColumn() );
669 cols1.push_back( containerIdColumn() );
670 description1.setPrimaryKey( cols1 );
671 std::string fk10Name = mappingVersionColumn()+
"_FK10";
672 description1.createForeignKey( fk10Name, mappingVersionColumn(),
674 std::string fk11Name = containerIdColumn()+
"_FK11";
675 description1.createForeignKey( fk11Name, containerIdColumn(),
677 schema().createTable( description1 );
685 m_schema( dbSchema ){
695 coral::ICursor& cursor =
query->execute();
696 while ( cursor.next() ) {
698 const coral::AttributeList& currentRow = cursor.currentRow();
700 dest.insert( mappingVersion );
709 std::auto_ptr<coral::IQuery>
query(mappingTable.newQuery());
710 coral::AttributeList outputBuffer;
718 query->defineOutput( outputBuffer );
726 std::ostringstream condition;
728 coral::AttributeList condData;
730 coral::AttributeList::iterator iAttribute = condData.begin();
732 query->setCondition( condition.str(), condData );
736 coral::ICursor& cursor =
query->execute();
737 while ( cursor.next() ) {
739 const coral::AttributeList& currentRow = cursor.currentRow();
755 coral::AttributeList rowBuffer;
758 mappingVersionTable.dataEditor().insertRow( rowBuffer );
762 coral::AttributeList dataBuffer;
774 for( std::map < int, MappingRawElement >::const_iterator iElem = mapping.
elements.begin();
775 iElem != mapping.
elements.end(); iElem++ ){
776 for(
size_t iParamIndex = 0; iParamIndex < iElem->second.columns.size(); iParamIndex++ ){
785 mappingElementTable.dataEditor().insertRow( dataBuffer );
792 coral::AttributeList whereData;
804 std::auto_ptr<coral::IQuery>
query(m_schema.newQuery());
807 query->setDistinct();
810 std::ostringstream condition;
812 coral::AttributeList condData;
813 query->setCondition(condition.str(),condData);
814 coral::ICursor& cursor =
query->execute();
815 while ( cursor.next() ) {
817 const coral::AttributeList& currentRow = cursor.currentRow();
820 dest.insert(std::make_pair(tableName,containerId));
854 query->setDistinct();
856 std::ostringstream condition;
859 coral::AttributeList condData;
862 query->setCondition(condition.str(),condData);
863 coral::ICursor& cursor =
query->execute();
864 while ( cursor.next() ) {
866 const coral::AttributeList& currentRow = cursor.currentRow();
868 destination.insert( className );
878 query->setDistinct();
880 std::ostringstream condition;
882 coral::AttributeList condData;
885 query->setCondition(condition.str(),condData);
886 coral::ICursor& cursor =
query->execute();
887 while ( cursor.next() ) {
889 const coral::AttributeList& currentRow = cursor.currentRow();
891 destination.insert( classVersion );
897 std::set<std::string>&
dest,
898 bool onlyDependency ){
901 query->setDistinct();
903 std::ostringstream condition;
905 coral::AttributeList condData;
907 if( onlyDependency ){
911 query->setCondition(condition.str(),condData);
912 coral::ICursor& cursor =
query->execute();
913 while ( cursor.next() ) {
915 const coral::AttributeList& currentRow = cursor.currentRow();
917 dest.insert( mappingVersion );
923 std::map<std::string,std::string>& versionMap ){
926 query->setDistinct();
929 std::ostringstream condition;
931 coral::AttributeList condData;
934 query->setCondition(condition.str(),condData);
935 coral::ICursor& cursor =
query->execute();
936 while ( cursor.next() ) {
938 const coral::AttributeList& currentRow = cursor.currentRow();
941 versionMap.insert( std::make_pair(classVersion,mappingVersion ) );
952 query->setDistinct();
954 std::ostringstream condition;
956 coral::AttributeList condData;
959 query->setCondition(condition.str(),condData);
960 coral::ICursor& cursor =
query->execute();
961 while ( cursor.next() ) {
963 const coral::AttributeList& currentRow = cursor.currentRow();
965 destination.insert( mappingVersion );
977 std::ostringstream condition;
980 coral::AttributeList condData;
983 coral::AttributeList::iterator iAttribute = condData.begin();
986 iAttribute->data<
int >() = containerId;
987 query->setCondition( condition.str(), condData );
988 coral::ICursor& cursor =
query->execute();
989 while ( cursor.next() ) {
991 const coral::AttributeList& currentRow = cursor.currentRow();
1002 std::ostringstream condition;
1004 coral::AttributeList condData;
1006 coral::AttributeList::iterator iAttribute = condData.begin();
1007 iAttribute->data<
std::string >() = mappingVersion;
1008 query->setCondition( condition.str(), condData );
1009 coral::ICursor& cursor =
query->execute();
1010 while ( cursor.next() ) {
1012 const coral::AttributeList& currentRow = cursor.currentRow();
1021 int dependencyIndex,
1032 coral::AttributeList::iterator iInAttr = inputData.begin();
1041 iInAttr->data<
int >() = dependencyIndex;
1043 iInAttr->data<
int >() = containerId;
1044 classVersionTable.dataEditor().insertRow( inputData );
1055 coral::AttributeList::iterator iInAttr = inputData.begin();
1060 iInAttr->data<
int >() = containerId;
1064 classVersionTable.dataEditor().updateRows( setClause,whereClause, inputData );
1073 static const std::string s_table(
"ORA_NAMING_SERVICE" );
1083 static const std::string s_column(
"CONTAINER_ID");
1109 throwException(
"ORA naming service table already exists in this schema.",
1110 "OraNameTable::create");
1113 coral::TableDescription descr(
"OraDb" );
1115 descr.insertColumn( objectNameColumn(),
1116 coral::AttributeSpecification::typeNameForType<std::string>() );
1117 descr.insertColumn( containerIdColumn(),
1118 coral::AttributeSpecification::typeNameForType<int>() );
1119 descr.insertColumn( itemIdColumn(),
1120 coral::AttributeSpecification::typeNameForType<int>() );
1121 descr.setNotNullConstraint( objectNameColumn() );
1122 descr.setNotNullConstraint( containerIdColumn() );
1123 descr.setNotNullConstraint( itemIdColumn() );
1124 descr.setPrimaryKey( std::vector<std::string>( 1, objectNameColumn() ) );
1126 schema().createTable( descr );
1136 coral::AttributeList dataToInsert;
1137 dataToInsert.extend<
std::string>( objectNameColumn() );
1138 dataToInsert.extend<
int>( containerIdColumn());
1139 dataToInsert.extend<
int>( itemIdColumn());
1140 dataToInsert[ objectNameColumn() ].data<
std::string>() = name;
1141 dataToInsert[ containerIdColumn() ].data<
int>() = contId;
1142 dataToInsert[ itemIdColumn() ].data<
int>() = itemId;
1144 containerTable.dataEditor().insertRow( dataToInsert );
1148 coral::AttributeList whereData;
1149 whereData.extend<
std::string>( objectNameColumn() );
1151 std::string condition = objectNameColumn() +
" = :" + objectNameColumn();
1152 return schema().tableHandle(
tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1157 coral::AttributeList whereData;
1158 return schema().tableHandle(
tableName() ).dataEditor().deleteRows( condition, whereData )>0;
1165 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1166 coral::AttributeList outputBuffer;
1167 outputBuffer.extend<
int>( containerIdColumn() );
1168 outputBuffer.extend<
int>( itemIdColumn() );
1169 query->defineOutput( outputBuffer );
1170 query->addToOutputList( containerIdColumn() );
1171 query->addToOutputList( itemIdColumn() );
1172 std::ostringstream condition;
1173 condition << objectNameColumn()<<
"= :"<< objectNameColumn();
1174 coral::AttributeList condData;
1175 condData.extend<
std::string>( objectNameColumn() );
1176 coral::AttributeList::iterator iAttribute = condData.begin();
1178 query->setCondition( condition.str(), condData );
1179 coral::ICursor& cursor =
query->execute();
1180 while ( cursor.next() ) {
1182 const coral::AttributeList& row = cursor.currentRow();
1183 int containerId = row[ containerIdColumn() ].data<
int >();
1184 int itemId = row[ itemIdColumn() ].data<
int >();
1185 destination.first = containerId;
1186 destination.second = itemId;
1196 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1197 coral::AttributeList outputBuffer;
1198 outputBuffer.extend<
std::string>( objectNameColumn() );
1199 query->defineOutput( outputBuffer );
1200 query->addToOutputList( objectNameColumn() );
1201 std::ostringstream condition;
1202 condition << containerIdColumn()<<
"= :"<< containerIdColumn();
1203 condition <<
" AND ";
1204 condition << itemIdColumn()<<
"= :"<< itemIdColumn();
1205 coral::AttributeList condData;
1206 condData.extend<
int>( containerIdColumn() );
1207 condData.extend<
int>( itemIdColumn() );
1208 coral::AttributeList::iterator iAttribute = condData.begin();
1209 iAttribute->data<
int >() = contId;
1211 iAttribute->data<
int >() = itemId;
1212 query->setCondition( condition.str(), condData );
1213 coral::ICursor& cursor =
query->execute();
1214 while ( cursor.next() ) {
1216 const coral::AttributeList& row = cursor.currentRow();
1218 destination.push_back( name );
1227 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1228 coral::AttributeList outputBuffer;
1229 outputBuffer.extend<
std::string>( objectNameColumn() );
1230 query->defineOutput( outputBuffer );
1231 query->addToOutputList( objectNameColumn() );
1232 std::ostringstream condition;
1233 condition << containerIdColumn()<<
"= :"<< containerIdColumn();
1234 coral::AttributeList condData;
1235 condData.extend<
int>( containerIdColumn() );
1236 coral::AttributeList::iterator iAttribute = condData.begin();
1237 iAttribute->data<
int >() = contId;
1238 query->setCondition( condition.str(), condData );
1239 coral::ICursor& cursor =
query->execute();
1240 while ( cursor.next() ) {
1242 const coral::AttributeList& row = cursor.currentRow();
1244 destination.push_back( name );
1252 std::auto_ptr<coral::IQuery>
query( containerTable.newQuery());
1253 coral::AttributeList outputBuffer;
1254 outputBuffer.extend<
std::string>( objectNameColumn() );
1255 query->defineOutput( outputBuffer );
1256 query->addToOutputList( objectNameColumn() );
1257 coral::ICursor& cursor =
query->execute();
1258 while ( cursor.next() ) {
1260 const coral::AttributeList& row = cursor.currentRow();
1262 destination.push_back( name );
1269 m_schema( dbSchema ),
1270 m_mainTable( dbSchema ),
1271 m_sequenceTable( dbSchema ),
1272 m_mappingVersionTable( dbSchema ),
1273 m_mappingElementTable( dbSchema ),
1274 m_containerHeaderTable( dbSchema ),
1275 m_classVersionTable( dbSchema ),
1276 m_mappingSchema( dbSchema ),
1277 m_namingServiceTable( dbSchema ){
1284 if(!m_mainTable.exists()){
1287 if(!m_namingServiceTable.exists())
1288 throwException(
"ORA database is corrupted. Naming Service table is missing",
"OraDatabaseSchema::exists");
1289 if(!m_sequenceTable.exists())
1290 throwException(
"ORA database is corrupted. Sequence table is missing.",
"OraDatabaseSchema::exists");
1291 if(!m_mappingVersionTable.exists())
1292 throwException(
"ORA database is corrupted. Mapping Version table is missing.",
"OraDatabaseSchema::exists");
1293 if(!m_mappingElementTable.exists())
1294 throwException(
"ORA database is corrupted. Mapping Element table is missing.",
"OraDatabaseSchema::exists");
1295 if(!m_containerHeaderTable.exists())
1296 throwException(
"ORA database is corrupted. Container Header table is missing.",
"OraDatabaseSchema::exists");
1297 if(!m_classVersionTable.exists())
1298 throwException(
"ORA database is corrupted. Class Version table is missing.",
"OraDatabaseSchema::exists");
1303 m_mainTable.create();
1305 m_sequenceTable.create();
1306 m_mappingVersionTable.create();
1307 m_mappingElementTable.create();
1308 m_containerHeaderTable.create();
1309 m_classVersionTable.create();
1310 m_namingServiceTable.create();
1314 m_namingServiceTable.drop();
1315 m_classVersionTable.drop();
1316 m_containerHeaderTable.drop();
1317 m_mappingElementTable.drop();
1318 m_mappingVersionTable.drop();
1319 m_sequenceTable.drop();
1325 m_mainTable.setAccessPermission( principal, forWrite );
1326 m_sequenceTable.setAccessPermission( principal, forWrite );
1327 m_mappingVersionTable.setAccessPermission( principal, forWrite );
1328 m_mappingElementTable.setAccessPermission( principal, forWrite );
1329 m_containerHeaderTable.setAccessPermission( principal, forWrite );
1330 m_classVersionTable.setAccessPermission( principal, forWrite );
1331 m_namingServiceTable.setAccessPermission( principal, forWrite );
1339 return m_sequenceTable;
1343 return m_mappingVersionTable;
1347 return m_mappingElementTable;
1351 return m_containerHeaderTable;
1355 return m_classVersionTable;
1359 return m_mappingSchema;
1363 return m_namingServiceTable;
1372 if( m_schema.existsTable( tableName )){
1373 throwException(
"ORA_TEST_DROP table already exists in this schema.",
1374 "OraNameTable::testDropPermission");
1377 coral::TableDescription descr(
"OraDb" );
1378 descr.setName( tableName );
1379 descr.insertColumn(
"DUMMY",
1380 coral::AttributeSpecification::typeNameForType<int>() );
1381 m_schema.createTable( descr );
1387 if(ret ) m_schema.dropIfExistsTable( tableName );
static std::string versionParameterName()
static std::string classIdColumn()
void sinchronize(const std::string &sequenceName, int lastValue)
bool testDropPermission()
static std::string userSchemaVersionParameterName()
void setMappingVersion(const std::string &classId, int containerId, const std::string &mappingVersion)
OraDatabaseSchema(coral::ISchema &dbSchema)
MappingRawElement & addElement(int elementId)
virtual ~OraNamingServiceTable()
void setParameter(const std::string ¶mName, const std::string ¶mValue)
static std::string objectNameColumn()
bool getMapping(const std::string &version, MappingRawData &destination)
static char const * tname
static std::string sequenceNameColumn()
bool getContainerTableMap(std::map< std::string, int > &destination)
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 variableNameColumn()
void removeMapping(const std::string &version)
IDatabaseTable & mappingElementTable()
static std::string mappingVersionColumn()
std::map< int, MappingRawElement > elements
virtual ~OraClassVersionTable()
virtual ~OraMappingElementTable()
static std::string mappingVersionColumn()
bool getLastId(const std::string &sequenceName, int &lastId)
OraSequenceTable(coral::ISchema &dbSchema)
IDatabaseTable & classVersionTable()
static std::string tableName()
bool getNamesForObject(int contId, int itemId, std::vector< std::string > &destination)
static std::string tableName()
bool getClassVersionListForContainer(int containerId, std::map< std::string, std::string > &versionMap)
IMappingSchema & mappingSchema()
OraMappingElementTable(coral::ISchema &dbSchema)
IContainerHeaderTable & containerHeaderTable()
static std::string classNameColumn()
OraClassVersionTable(coral::ISchema &dbSchema)
static std::string tableNameColumn()
static std::string containerIdColumn()
std::string schemaVersion()
virtual ~OraMappingSchema()
bool getNamesForContainer(int contId, std::vector< std::string > &destination)
bool getParameters(std::map< std::string, std::string > &destination)
static std::string elementTypeColumn()
bool getClassVersionListForMappingVersion(const std::string &mappingVersion, std::set< std::string > &destination)
bool getVersionList(std::set< std::string > &destination)
OraMappingVersionTable(coral::ISchema &dbSchema)
static std::string tableName()
static std::string variableParIndexColumn()
static std::string tableName()
INamingServiceTable & namingServiceTable()
static std::string sequenceValueColumn()
static std::string tableName()
ISequenceTable & sequenceTable()
void erase(const std::string &sequenceName)
void setAccessPermission(const std::string &principal, bool forWrite)
static std::string itemIdColumn()
virtual ~OraSequenceTable()
static std::string tableName()
static std::string variableTypeColumn()
static std::string parameterNameColumn()
virtual ~OraMappingVersionTable()
static bool existsMainTable(coral::ISchema &dbSchema)
static std::string classVersionColumn()
OraNamingServiceTable(coral::ISchema &dbSchema)
bool getAllNames(std::vector< std::string > &destination)
bool eraseObjectName(const std::string &name)
bool getObjectByName(const std::string &name, std::pair< int, int > &destination)
static std::string mappingVersionColumn()
bool getMappingVersionListForContainer(int containerId, std::set< std::string > &destination, bool onlyDependency=false)
static std::string dependencyIndexColumn()
bool getMappingVersionListForTable(const std::string &tableName, std::set< std::string > &destination)
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
std::vector< std::vector< double > > tmp
void create(const std::string &userSchemaVersion)
bool containerForMappingVersion(const std::string &mappingVersion, int &destination)
virtual ~OraDatabaseSchema()
static std::string scopeNameColumn()
OraMappingSchema(coral::ISchema &dbSchema)
static std::string columnNameColumn()
bool add(const std::string &sequenceName)
IDatabaseTable & mappingVersionTable()
void setObjectName(const std::string &name, int contId, int itemId)
static std::string elementIdColumn()
bool selectMappingVersion(const std::string &classId, int containerId, std::string &destination)
void storeMapping(const MappingRawData &mapping)
static std::string version()
std::string className(const T &t)
bool getDependentClassesInContainerMapping(int containerId, std::set< std::string > &destination)
static std::string parameterValueColumn()
OraMainTable(coral::ISchema &dbSchema)
static std::string containerIdColumn()