CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

FEConfigLUTInfo Class Reference

#include <FEConfigLUTInfo.h>

Inheritance diagram for FEConfigLUTInfo:
IODConfig IDBObject

List of all members.

Public Member Functions

 FEConfigLUTInfo ()
int fetchID () throw (std::runtime_error)
int fetchNextId () throw (std::runtime_error)
Tm getDBTime () const
int getID ()
int getId () const
int getNumberOfGroups () const
std::string getTable ()
int getVersion () const
bool operator!= (const FEConfigLUTInfo &r) const
bool operator== (const FEConfigLUTInfo &r) const
void setByID (int id) throw (std::runtime_error)
void setDBTime (Tm x)
void setId (int id)
void setID (int id)
void setNumberOfGroups (int iov_id)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setVersion (int id)
 ~FEConfigLUTInfo ()

Private Member Functions

void clear ()
void fetchData (FEConfigLUTInfo *result) throw (std::runtime_error)
void fetchLastData (FEConfigLUTInfo *result) throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

Tm m_db_time
int m_ID
int m_iov_id
int m_version

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 11 of file FEConfigLUTInfo.h.


Constructor & Destructor Documentation

FEConfigLUTInfo::FEConfigLUTInfo ( )

Definition at line 13 of file FEConfigLUTInfo.cc.

References hitfit::clear(), and NULL.

FEConfigLUTInfo::~FEConfigLUTInfo ( )

Definition at line 32 of file FEConfigLUTInfo.cc.

{
}

Member Function Documentation

void FEConfigLUTInfo::clear ( void  ) [private]

Definition at line 26 of file FEConfigLUTInfo.cc.

                           {
   m_iov_id=0;
}
void FEConfigLUTInfo::fetchData ( FEConfigLUTInfo result) throw (std::runtime_error) [private]

Definition at line 128 of file FEConfigLUTInfo.cc.

References DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, and query::result.

{
  this->checkConnection();
  result->clear();
  if(result->getId()==0 && (result->getConfigTag()=="") ){
    throw(std::runtime_error("FEConfigLUTInfo::fetchData(): no Id defined for this FEConfigLUTInfo "));
  }

  try {
    DateHandler dh(m_env, m_conn);

    m_readStmt->setSQL("SELECT * FROM " + getTable() +   
                       " where ( lut_conf_id= :1 or (tag=:2 AND version=:3 ) )" );
    m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());
    m_readStmt->setInt(3, result->getVersion());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();

    // 1 is the id and 2 is the config tag and 3 is the version

    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));
    result->setVersion(rset->getInt(3));
    result->setNumberOfGroups(rset->getInt(4));
    Date dbdate = rset->getDate(5);
    result->setDBTime( dh.dateToTm( dbdate ));

  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTInfo::fetchData():  "+e.getMessage()));
  }
}
int FEConfigLUTInfo::fetchID ( ) throw (std::runtime_error)

Definition at line 189 of file FEConfigLUTInfo.cc.

References alignCSCRings::e.

{
  // Return from memory if available
  if (m_ID!=0) {
    return m_ID;
  }

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT lut_conf_id FROM "+ getTable()+
                 " WHERE  tag=:1 and version=:2 " );

    stmt->setString(1, getConfigTag() );
    stmt->setInt(2, getVersion() );

    ResultSet* rset = stmt->executeQuery();

    if (rset->next()) {
      m_ID = rset->getInt(1);
    } else {
      m_ID = 0;
    }
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTInfo::fetchID:  "+e.getMessage()));
  }

  return m_ID;
}
void FEConfigLUTInfo::fetchLastData ( FEConfigLUTInfo result) throw (std::runtime_error) [private]

Definition at line 163 of file FEConfigLUTInfo.cc.

References DateHandler::dateToTm(), cuy::dh, alignCSCRings::e, and query::result.

{
  this->checkConnection();
  result->clear();
  try {
    DateHandler dh(m_env, m_conn);

    m_readStmt->setSQL("SELECT * FROM " + getTable() +   
                       " where   lut_conf_id = ( select max( lut_conf_id) from "+ getTable() +" ) " );
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();

    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));
    result->setVersion(rset->getInt(3));
    result->setNumberOfGroups(rset->getInt(4));
    Date dbdate = rset->getDate(5);
    result->setDBTime( dh.dateToTm( dbdate ));

  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTInfo::fetchData():  "+e.getMessage()));
  }
}
int FEConfigLUTInfo::fetchNextId ( ) throw (std::runtime_error)

Definition at line 38 of file FEConfigLUTInfo.cc.

References alignCSCRings::e, and query::result.

                                                          {

  int result=0;
  try {
    this->checkConnection();

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select FE_CONFIG_LUT_SQ.NextVal from DUAL ");
    ResultSet* rset = m_readStmt->executeQuery();
    while (rset->next ()){
      result= rset->getInt(1);
    }
    result++;
    m_conn->terminateStatement(m_readStmt);
    return result; 

  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTInfo::fetchNextId():  "+e.getMessage()));
  }

}
Tm FEConfigLUTInfo::getDBTime ( ) const [inline]

Definition at line 35 of file FEConfigLUTInfo.h.

References m_db_time.

{  return m_db_time;}
int FEConfigLUTInfo::getId ( ) const [inline]

Definition at line 26 of file FEConfigLUTInfo.h.

References m_ID.

Referenced by getID(), and EcalTPGDBApp::writeToConfDB_TPGLUT().

{ return m_ID; }
int FEConfigLUTInfo::getID ( ) [inline]

Definition at line 29 of file FEConfigLUTInfo.h.

References getId().

{ return getId() ;}
int FEConfigLUTInfo::getNumberOfGroups ( ) const [inline]

Definition at line 23 of file FEConfigLUTInfo.h.

References m_iov_id.

{return m_iov_id;  }
std::string FEConfigLUTInfo::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 19 of file FEConfigLUTInfo.h.

{ return "FE_CONFIG_LUT_INFO"; }
int FEConfigLUTInfo::getVersion ( ) const [inline]

Definition at line 32 of file FEConfigLUTInfo.h.

References m_version.

{ return m_version; }
bool FEConfigLUTInfo::operator!= ( const FEConfigLUTInfo r) const [inline]

Definition at line 47 of file FEConfigLUTInfo.h.

References alignCSCRings::r.

{ return !(*this == r); }
bool FEConfigLUTInfo::operator== ( const FEConfigLUTInfo r) const [inline]

Definition at line 46 of file FEConfigLUTInfo.h.

References m_ID.

{  return (m_ID   == r.m_ID ); }
void FEConfigLUTInfo::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 60 of file FEConfigLUTInfo.cc.

References alignCSCRings::e, and getId().

{
  this->checkConnection();

  int next_id=0;
  if(getId()==0){
    next_id=fetchNextId();
  }

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( lut_conf_id, tag, version, number_of_groups) " 
                        " VALUES ( :1, :2, :3 , :4) " );

    m_writeStmt->setInt(1, next_id);
    m_ID=next_id;

  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTInfo::prepareWrite():  "+e.getMessage()));
  }

}
void FEConfigLUTInfo::setByID ( int  id) throw (std::runtime_error)

Definition at line 223 of file FEConfigLUTInfo.cc.

References DateHandler::dateToTm(), cuy::dh, and alignCSCRings::e.

{
   this->checkConnection();

   DateHandler dh(m_env, m_conn);

   try {
     Statement* stmt = m_conn->createStatement();

     stmt->setSQL("SELECT * FROM fe_config_lut_info WHERE lut_conf_id = :1");
     stmt->setInt(1, id);
     
     ResultSet* rset = stmt->executeQuery();
     if (rset->next()) {
       this->setId(rset->getInt(1));
       this->setConfigTag(rset->getString(2));
       this->setVersion(rset->getInt(3));
       this->setNumberOfGroups(rset->getInt(4));
       Date dbdate = rset->getDate(5);
       this->setDBTime( dh.dateToTm( dbdate ));
     } else {
       throw(std::runtime_error("FEConfigLUTInfo::setByID:  Given config_id is not in the database"));
     }
     
     m_conn->terminateStatement(stmt);
   } catch (SQLException &e) {
     throw(std::runtime_error("FEConfigLUTInfo::setByID:  "+e.getMessage()));
   }
}
void FEConfigLUTInfo::setDBTime ( Tm  x) [inline]

Definition at line 36 of file FEConfigLUTInfo.h.

References m_db_time, and x.

{ m_db_time=x; } 
void FEConfigLUTInfo::setId ( int  id) [inline]
void FEConfigLUTInfo::setID ( int  id) [inline]

Definition at line 28 of file FEConfigLUTInfo.h.

References setId().

{setId(id);} 
void FEConfigLUTInfo::setNumberOfGroups ( int  iov_id) [inline]

Definition at line 22 of file FEConfigLUTInfo.h.

References m_iov_id.

Referenced by EcalTPGDBApp::writeToConfDB_TPGLUT().

{ m_iov_id = iov_id;  }
void FEConfigLUTInfo::setParameters ( std::map< std::string, std::string >  my_keys_map)
void FEConfigLUTInfo::setVersion ( int  id) [inline]

Definition at line 31 of file FEConfigLUTInfo.h.

References m_version.

{ m_version = id; }
void FEConfigLUTInfo::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 100 of file FEConfigLUTInfo.cc.

References alignCSCRings::e.

{
  this->checkConnection();
  this->checkPrepare();

  try {

    // number 1 is the id 
    m_writeStmt->setString(2, this->getConfigTag());
    m_writeStmt->setInt(3, this->getVersion());
    m_writeStmt->setInt(4, this->getNumberOfGroups());

    m_writeStmt->executeUpdate();


  } catch (SQLException &e) {
    throw(std::runtime_error("FEConfigLUTInfo::writeDB():  "+e.getMessage()));
  }
  // Now get the ID
  if (!this->fetchID()) {
    throw(std::runtime_error("FEConfigLUTInfo::writeDB:  Failed to write"));
  }


}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 13 of file FEConfigLUTInfo.h.


Member Data Documentation

Definition at line 53 of file FEConfigLUTInfo.h.

Referenced by getDBTime(), and setDBTime().

int FEConfigLUTInfo::m_ID [private]

Definition at line 52 of file FEConfigLUTInfo.h.

Referenced by getId(), operator==(), and setId().

Definition at line 51 of file FEConfigLUTInfo.h.

Referenced by getNumberOfGroups(), and setNumberOfGroups().

Definition at line 54 of file FEConfigLUTInfo.h.

Referenced by getVersion(), and setVersion().