CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions

l1t::OMDSReader Class Reference

#include <OMDSReader.h>

Inheritance diagram for l1t::OMDSReader:
l1t::DataManager

List of all members.

Classes

class  QueryResults

Public Member Functions

const QueryResults basicQuery (const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
const QueryResults basicQuery (const std::string &columnName, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
template<class T >
const QueryResults basicQueryGenericKey (const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
template<class T >
const QueryResults basicQueryGenericKey (const std::string &columnName, const std::string &schemaName, const std::string &tableName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
const QueryResults basicQueryView (const std::vector< std::string > &columnNames, const std::string &schemaName, const std::string &viewName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
const QueryResults basicQueryView (const std::string &columnName, const std::string &schemaName, const std::string &viewName, const std::string &conditionLHS="", const QueryResults conditionRHS=QueryResults(), const std::string &conditionRHSName="") const
std::vector< std::string > columnNames (const std::string &schemaName, const std::string &tableName) const
std::vector< std::string > columnNamesView (const std::string &schemaName, const std::string &viewName) const
void connect (const std::string &connectString, const std::string &authenticationPath)
 OMDSReader ()
 OMDSReader (const std::string &connectString, const std::string &authenticationPath)
template<class T >
const QueryResults singleAttribute (const T &data) const
virtual ~OMDSReader ()

Private Member Functions

 OMDSReader (const OMDSReader &)
const OMDSReaderoperator= (const OMDSReader &)

Detailed Description

Definition at line 44 of file OMDSReader.h.


Constructor & Destructor Documentation

OMDSReader::OMDSReader ( )

Definition at line 38 of file OMDSReader.cc.

    : DataManager()
  {}
OMDSReader::OMDSReader ( const std::string &  connectString,
const std::string &  authenticationPath 
)

Definition at line 42 of file OMDSReader.cc.

References l1t::DataManager::session, and cond::DbSession::transaction().

    : DataManager( connectString, authenticationPath, true )
  {
    session->transaction().start( true ) ;
  }
OMDSReader::~OMDSReader ( ) [virtual]

Definition at line 62 of file OMDSReader.cc.

{
}
l1t::OMDSReader::OMDSReader ( const OMDSReader ) [private]

Member Function Documentation

const OMDSReader::QueryResults OMDSReader::basicQuery ( const std::vector< std::string > &  columnNames,
const std::string &  schemaName,
const std::string &  tableName,
const std::string &  conditionLHS = "",
const QueryResults  conditionRHS = QueryResults(),
const std::string &  conditionRHSName = "" 
) const

Definition at line 87 of file OMDSReader.cc.

References l1t::OMDSReader::QueryResults::attributeLists(), l1t::OMDSReader::QueryResults::columnNames(), end, l1t::OMDSReader::QueryResults::fillVariable(), cond::DbSession::nominalSchema(), l1t::OMDSReader::QueryResults::numberRows(), o2o::query, cond::DbSession::schema(), python::IdGenerator::schema, l1t::DataManager::session, asciidump::table, and tmp.

Referenced by L1GtPsbSetupConfigOnlineProd::addPsbFromDb(), basicQuery(), basicQueryView(), RCTObjectKeysOnlineProd::fillObjectKeys(), DTTFRSKeysOnlineProd::fillObjectKeys(), L1GctRSObjectKeysOnlineProd::fillObjectKeys(), DTTFTSCObjectKeysOnlineProd::fillObjectKeys(), L1RCT_RSKeysOnlineProd::fillObjectKeys(), L1MuGMTRSKeysOnlineProd::fillObjectKeys(), L1MuGMTParametersKeysOnlineProd::fillObjectKeys(), L1GctTSCObjectKeysOnlineProd::fillObjectKeys(), CSCTFObjectKeysOnlineProd::fillObjectKeys(), L1MuTriggerScaleKeysOnlineProd::fillObjectKeys(), L1GtTscObjectKeysOnlineProd::keyL1GtParameters(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskAlgoTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskTechTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskVetoTechTrig(), L1GtTscObjectKeysOnlineProd::keyL1GtTriggerMenu(), L1EmEtScaleOnlineProd::newObject(), L1GtPsbSetupConfigOnlineProd::newObject(), L1GctChannelMaskOnlineProd::newObject(), L1GtParametersConfigOnlineProd::newObject(), L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::newObject(), DTTFMasksOnlineProd::newObject(), L1HfRingEtScaleOnlineProd::newObject(), L1CaloHcalScaleConfigOnlineProd::newObject(), L1GctJetFinderParamsOnlineProd::newObject(), L1MuCSCPtLutConfigOnlineProd::newObject(), L1RCTParametersOnlineProd::newObject(), L1CaloEcalScaleConfigOnlineProd::newObject(), DTTFParametersOnlineProd::newObject(), CSCTFConfigOnlineProd::newObject(), L1MuTriggerPtScaleOnlineProducer::newObject(), L1RCTChannelMaskOnlineProd::newObject(), L1GtTriggerMaskVetoTechTrigConfigOnlineProd::newObject(), CSCTFAlignmentOnlineProd::newObject(), L1MuTriggerScalesOnlineProducer::newObject(), L1GtTriggerMaskAlgoTrigConfigOnlineProd::newObject(), L1MuGMTChannelMaskOnlineProducer::newObject(), L1GtTriggerMaskTechTrigConfigOnlineProd::newObject(), L1JetEtScaleOnlineProd::newObject(), L1HtMissScaleOnlineProd::newObject(), L1GtPrescaleFactorsTechTrigConfigOnlineProd::newObject(), and L1SubsystemKeysOnlineProd::produce().

  {
    coral::ISchema& schema = schemaName.empty() ?
      session->nominalSchema() :
      session->schema( schemaName ) ;

    coral::ITable& table = schema.tableHandle( tableName ) ;

    // Pointer is deleted automatically at end of function.
    boost::shared_ptr< coral::IQuery > query( table.newQuery() ) ;

    // Construct query
    std::vector< std::string >::const_iterator it = columnNames.begin() ;
    std::vector< std::string >::const_iterator end = columnNames.end() ;
    for( ; it != end ; ++it )
      {
        query->addToOutputList( *it ) ;
      }

    // Only apply condition if RHS has one row.
    if( !conditionLHS.empty() && conditionRHS.numberRows() == 1 )
      {
        if( !conditionRHSName.empty() )
          {
            // Assume all RHS types are strings.
            coral::AttributeList attList ;
            attList.extend( conditionRHSName, typeid( std::string ) ) ;
            std::string tmp ;
            conditionRHS.fillVariable( conditionRHSName, tmp ) ;
            attList[ conditionRHSName ].data< std::string >() = tmp ;

            query->setCondition( conditionLHS + " = :" + conditionRHSName,
                                 attList ) ;
          }
        else if( conditionRHS.columnNames().size() == 1 )
          // check for only one column
          {
            query->setCondition( conditionLHS + " = :" +
                                   conditionRHS.columnNames().front(),
                                 conditionRHS.attributeLists().front() ) ;
          }
      }

    coral::ICursor& cursor = query->execute() ;

    // Copy AttributeLists for external use because the cursor is deleted
    // when the query goes out of scope.
    std::vector< coral::AttributeList > atts ;
    while( cursor.next() )
      {
        atts.push_back( cursor.currentRow() ) ;
      } ;

    return QueryResults( columnNames, atts ) ;
  }
const OMDSReader::QueryResults OMDSReader::basicQuery ( const std::string &  columnName,
const std::string &  schemaName,
const std::string &  tableName,
const std::string &  conditionLHS = "",
const QueryResults  conditionRHS = QueryResults(),
const std::string &  conditionRHSName = "" 
) const

Definition at line 150 of file OMDSReader.cc.

References basicQuery(), and columnNames().

  {
    std::vector< std::string > columnNames ;
    columnNames.push_back( columnName ) ;
    return basicQuery( columnNames, schemaName, tableName,
                        conditionLHS, conditionRHS, conditionRHSName ) ;
  }
template<class T >
const OMDSReader::QueryResults OMDSReader::basicQueryGenericKey ( const std::vector< std::string > &  columnNames,
const std::string &  schemaName,
const std::string &  tableName,
const std::string &  conditionLHS = "",
const QueryResults  conditionRHS = QueryResults(),
const std::string &  conditionRHSName = "" 
) const

Definition at line 217 of file OMDSReader.h.

References l1t::OMDSReader::QueryResults::attributeLists(), l1t::OMDSReader::QueryResults::columnNames(), end, l1t::OMDSReader::QueryResults::fillVariable(), cond::DbSession::nominalSchema(), l1t::OMDSReader::QueryResults::numberRows(), o2o::query, cond::DbSession::schema(), python::IdGenerator::schema, l1t::DataManager::session, asciidump::table, and tmp.

Referenced by L1GtRsObjectKeysOnlineProd::keyL1GtPrescaleFactorsAlgoTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtPrescaleFactorsTechTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskAlgoTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskTechTrig(), and L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskVetoTechTrig().

  {
    coral::ISchema& schema = schemaName.empty() ?
      session->nominalSchema() :
      session->schema( schemaName ) ;

    coral::ITable& table = schema.tableHandle( tableName ) ;

    // Pointer is deleted automatically at end of function.
    boost::shared_ptr< coral::IQuery > query( table.newQuery() ) ;

    // Construct query
    std::vector< std::string >::const_iterator it = columnNames.begin() ;
    std::vector< std::string >::const_iterator end = columnNames.end() ;
    for( ; it != end ; ++it )
      {
        query->addToOutputList( *it ) ;
      }

    // Only apply condition if RHS has one row.
    if( !conditionLHS.empty() && conditionRHS.numberRows() == 1 )
      {
        if( !conditionRHSName.empty() )
          {
            // Use type of dummyVariable to determine type of condition RHS
            coral::AttributeList attList ;
            attList.extend( conditionRHSName, typeid( T ) ) ;
            T tmp ;
            conditionRHS.fillVariable( conditionRHSName, tmp ) ;
            attList[ conditionRHSName ].data< T >() = tmp ;

            query->setCondition( conditionLHS + " = :" + conditionRHSName,
                                 attList ) ;
          }
        else if( conditionRHS.columnNames().size() == 1 )
          // check for only one column
          {
            query->setCondition( conditionLHS + " = :" +
                                   conditionRHS.columnNames().front(),
                                 conditionRHS.attributeLists().front() ) ;
          }
      }

    coral::ICursor& cursor = query->execute() ;

    // Copy AttributeLists for external use because the cursor is deleted
    // when the query goes out of scope.
    std::vector< coral::AttributeList > atts ;
    while( cursor.next() )
      {
        atts.push_back( cursor.currentRow() ) ;
      } ;

    return QueryResults( columnNames, atts ) ;
  }
template<class T >
const OMDSReader::QueryResults OMDSReader::basicQueryGenericKey ( const std::string &  columnName,
const std::string &  schemaName,
const std::string &  tableName,
const std::string &  conditionLHS = "",
const QueryResults  conditionRHS = QueryResults(),
const std::string &  conditionRHSName = "" 
) const

Definition at line 280 of file OMDSReader.h.

References columnNames().

  {
    std::vector< std::string > columnNames ;
    columnNames.push_back( columnName ) ;
    return basicQueryGenericKey< T >( columnNames, schemaName, tableName,
                                 conditionLHS, conditionRHS, conditionRHSName);
  }
const OMDSReader::QueryResults OMDSReader::basicQueryView ( const std::string &  columnName,
const std::string &  schemaName,
const std::string &  viewName,
const std::string &  conditionLHS = "",
const QueryResults  conditionRHS = QueryResults(),
const std::string &  conditionRHSName = "" 
) const

Definition at line 263 of file OMDSReader.cc.

References basicQuery(), and columnNames().

  {
    std::vector< std::string > columnNames ;
    columnNames.push_back( columnName ) ;
    return basicQuery( columnNames, schemaName, viewName,
            conditionLHS, conditionRHS, conditionRHSName ) ;
  }
const OMDSReader::QueryResults OMDSReader::basicQueryView ( const std::vector< std::string > &  columnNames,
const std::string &  schemaName,
const std::string &  viewName,
const std::string &  conditionLHS = "",
const QueryResults  conditionRHS = QueryResults(),
const std::string &  conditionRHSName = "" 
) const

Definition at line 191 of file OMDSReader.cc.

References l1t::OMDSReader::QueryResults::attributeLists(), l1t::OMDSReader::QueryResults::columnNames(), l1t::OMDSReader::QueryResults::fillVariable(), cond::DbSession::nominalSchema(), l1t::OMDSReader::QueryResults::numberRows(), o2o::query, cond::DbSession::schema(), python::IdGenerator::schema, l1t::DataManager::session, and tmp.

Referenced by L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::newObject(), L1CaloHcalScaleConfigOnlineProd::newObject(), L1GtPrescaleFactorsTechTrigConfigOnlineProd::newObject(), L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoCondFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuCondFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuGeneralFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuObjectParametersFromDB(), and L1GtTriggerMenuConfigOnlineProd::tableMenuTechTrigFromDB().

  {
    coral::ISchema& schema = schemaName.empty() ?
      session->nominalSchema() :
      session->schema( schemaName ) ;

    //    coral::IView& view = schema.viewHandle( viewName ) ;

    // Pointer is deleted automatically at end of function.
    coral::IQuery* query = schema.newQuery(); ;

    // Construct query
    for (std::vector<std::string>::const_iterator constIt = columnNames.begin(); constIt
            != columnNames.end(); ++constIt) {
        query->addToOutputList(*constIt);
    }

    query->addToTableList(viewName);

    // Only apply condition if RHS has one row.
    if (!conditionLHS.empty() && conditionRHS.numberRows() == 1) {

        if (!conditionRHSName.empty()) {
            // Assume all RHS types are strings.
            coral::AttributeList attList;
            attList.extend(conditionRHSName, typeid(std::string));
            std::string tmp;
            conditionRHS.fillVariable(conditionRHSName, tmp);
            attList[conditionRHSName].data<std::string> () = tmp;

            query->setCondition(conditionLHS + " = :" + conditionRHSName, attList);
        } else if (conditionRHS.columnNames().size() == 1)
        // check for only one column
        {
            query->setCondition(
                    conditionLHS + " = :" + conditionRHS.columnNames().front(),
                    conditionRHS.attributeLists().front());
        }
    }

    coral::ICursor& cursor = query->execute();

    // Copy AttributeLists for external use because the cursor is deleted
    // when the query goes out of scope.
    std::vector<coral::AttributeList> atts;
    while (cursor.next()) {
        atts.push_back(cursor.currentRow());
    };

    delete query;

//    // Run a wildcard query on the view
//    coral::IQuery* query2 = workingSchema.newQuery();
//    query2->addToTableList(V0);
//    coral::ICursor& cursor2 = query2->execute();
//    while ( cursor2.next() ) {
//      cursor2.currentRow().toOutputStream( std::cout ) << std::endl;
//    }
//    delete query2;



    return QueryResults(columnNames, atts);
  }
std::vector< std::string > OMDSReader::columnNames ( const std::string &  schemaName,
const std::string &  tableName 
) const

Definition at line 165 of file OMDSReader.cc.

References i, h::names, cond::DbSession::nominalSchema(), cond::DbSession::schema(), python::IdGenerator::schema, l1t::DataManager::session, and asciidump::table.

Referenced by basicQuery(), basicQueryGenericKey(), basicQueryView(), L1GtPsbSetupConfigOnlineProd::newObject(), L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::newObject(), L1GtTriggerMaskVetoTechTrigConfigOnlineProd::newObject(), L1GtTriggerMaskAlgoTrigConfigOnlineProd::newObject(), L1GtTriggerMaskTechTrigConfigOnlineProd::newObject(), and L1GtPrescaleFactorsTechTrigConfigOnlineProd::newObject().

  {
    coral::ISchema& schema = schemaName.empty() ?
      session->nominalSchema() :
      session->schema( schemaName ) ;

    coral::ITable& table = schema.tableHandle( tableName ) ;
    const coral::ITableDescription& tableDesc = table.description() ;

    std::vector< std::string > names ;
    int nCols = tableDesc.numberOfColumns() ;

    for( int i = 0 ; i < nCols ; ++i )
      {
        const coral::IColumn& column = tableDesc.columnDescription( i ) ;
        names.push_back( column.name() ) ;
      }

    return names ;
  }
std::vector< std::string > OMDSReader::columnNamesView ( const std::string &  schemaName,
const std::string &  viewName 
) const

Definition at line 278 of file OMDSReader.cc.

References i, h::names, cond::DbSession::nominalSchema(), cond::DbSession::schema(), python::IdGenerator::schema, and l1t::DataManager::session.

Referenced by L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoCondFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuCondFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuGeneralFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuObjectParametersFromDB(), and L1GtTriggerMenuConfigOnlineProd::tableMenuTechTrigFromDB().

  {
    coral::ISchema& schema = schemaName.empty() ?
      session->nominalSchema() :
      session->schema( schemaName ) ;

    std::set< std::string > views = schema.listViews ();
    std::vector< std::string > names ;

    if (schema.existsView (viewName)) {

        coral::IView& view = schema.viewHandle( viewName ) ;

        int nCols = view.numberOfColumns() ;

        for (int i = 0; i < nCols; ++i) {
            const coral::IColumn& column = view.column(i);
            names.push_back(column.name());
        }

        return names ;

    }

    return names ;

  }
void OMDSReader::connect ( const std::string &  connectString,
const std::string &  authenticationPath 
)

Definition at line 50 of file OMDSReader.cc.

References l1t::DataManager::session, and cond::DbSession::transaction().

Referenced by L1ConfigOnlineProdBase< TRcd, TData >::L1ConfigOnlineProdBase().

  {
    DataManager::connect( connectString, authenticationPath, true ) ;
    session->transaction().start( true ) ;
  }
const OMDSReader& l1t::OMDSReader::operator= ( const OMDSReader ) [private]
template<class T >
const OMDSReader::QueryResults OMDSReader::singleAttribute ( const T data) const

Definition at line 295 of file OMDSReader.h.

References h::names.

Referenced by L1GtPsbSetupConfigOnlineProd::addPsbFromDb(), RCTObjectKeysOnlineProd::fillObjectKeys(), DTTFTSCObjectKeysOnlineProd::fillObjectKeys(), L1MuGMTParametersKeysOnlineProd::fillObjectKeys(), CSCTFObjectKeysOnlineProd::fillObjectKeys(), L1GctTSCObjectKeysOnlineProd::fillObjectKeys(), L1MuTriggerScaleKeysOnlineProd::fillObjectKeys(), L1GtTscObjectKeysOnlineProd::keyL1GtParameters(), L1GtRsObjectKeysOnlineProd::keyL1GtPrescaleFactorsAlgoTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtPrescaleFactorsTechTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskAlgoTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskTechTrig(), L1GtRsObjectKeysOnlineProd::keyL1GtTriggerMaskVetoTechTrig(), L1GtTscObjectKeysOnlineProd::keyL1GtTriggerMenu(), L1GctChannelMaskOnlineProd::newObject(), L1GtPsbSetupConfigOnlineProd::newObject(), L1EmEtScaleOnlineProd::newObject(), L1GtParametersConfigOnlineProd::newObject(), DTTFMasksOnlineProd::newObject(), L1GtPrescaleFactorsAlgoTrigConfigOnlineProd::newObject(), L1HfRingEtScaleOnlineProd::newObject(), L1CaloHcalScaleConfigOnlineProd::newObject(), L1MuCSCPtLutConfigOnlineProd::newObject(), L1GctJetFinderParamsOnlineProd::newObject(), L1RCTParametersOnlineProd::newObject(), CSCTFConfigOnlineProd::newObject(), DTTFParametersOnlineProd::newObject(), L1CaloEcalScaleConfigOnlineProd::newObject(), L1MuTriggerPtScaleOnlineProducer::newObject(), CSCTFAlignmentOnlineProd::newObject(), L1GtTriggerMaskVetoTechTrigConfigOnlineProd::newObject(), L1RCTChannelMaskOnlineProd::newObject(), L1GtTriggerMaskAlgoTrigConfigOnlineProd::newObject(), L1MuTriggerScalesOnlineProducer::newObject(), L1MuGMTChannelMaskOnlineProducer::newObject(), L1GtTriggerMaskTechTrigConfigOnlineProd::newObject(), L1GtPrescaleFactorsTechTrigConfigOnlineProd::newObject(), L1HtMissScaleOnlineProd::newObject(), L1JetEtScaleOnlineProd::newObject(), L1SubsystemKeysOnlineProd::produce(), L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoCondFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuAlgoFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuCondFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuGeneralFromDB(), L1GtTriggerMenuConfigOnlineProd::tableMenuObjectParametersFromDB(), and L1GtTriggerMenuConfigOnlineProd::tableMenuTechTrigFromDB().

  {
    std::vector< std::string > names ;
    names.push_back( "dummy" ) ;

    coral::AttributeList attList ;
    attList.extend( "dummy", typeid( T ) ) ;
    attList[ "dummy" ].data< T >() = data ;

    std::vector< coral::AttributeList > atts ;
    atts.push_back( attList ) ;

    return QueryResults( names, atts ) ;
  }