CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CondTools/DT/src/DTLVStatusHandler.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2010/09/14 13:54:17 $
00005  *  $Revision: 1.5 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //-----------------------
00011 // This Class' Header --
00012 //-----------------------
00013 #include "CondTools/DT/interface/DTLVStatusHandler.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 #include "CondFormats/DTObjects/interface/DTLVStatus.h"
00019 
00020 
00021 #include "CondCore/DBCommon/interface/DbTransaction.h"
00022 
00023 #include "RelationalAccess/ISchema.h"
00024 #include "RelationalAccess/ITable.h"
00025 #include "RelationalAccess/ICursor.h"
00026 #include "RelationalAccess/IQuery.h"
00027 #include "CoralBase/AttributeList.h"
00028 #include "CoralBase/AttributeSpecification.h"
00029 #include "CoralBase/Attribute.h"
00030 
00031 //---------------
00032 // C++ Headers --
00033 //---------------
00034 
00035 
00036 //-------------------
00037 // Initializations --
00038 //-------------------
00039 
00040 
00041 //----------------
00042 // Constructors --
00043 //----------------
00044 DTLVStatusHandler::DTLVStatusHandler( const edm::ParameterSet& ps ):
00045  dataTag(               ps.getParameter<std::string> ( "tag" ) ),
00046  onlineConnect(         ps.getParameter<std::string> ( "onlineDB" ) ),
00047  onlineAuthentication(  ps.getParameter<std::string> ( 
00048                         "onlineAuthentication" ) ),
00049  bufferConnect(         ps.getParameter<std::string> ( "bufferDB" ) ),
00050  omds_conn(),
00051  buff_conn(),
00052  omds_session(),
00053  buff_session() {
00054   std::cout << " PopCon application for DT DCS data (CCB status) export "
00055             << std::endl;
00056 }
00057 
00058 //--------------
00059 // Destructor --
00060 //--------------
00061 DTLVStatusHandler::~DTLVStatusHandler() {
00062 }
00063 
00064 //--------------
00065 // Operations --
00066 //--------------
00067 void DTLVStatusHandler::getNewObjects() {
00068 
00069   // online DB connection
00070   std::cout << "configure omds DbConnection" << std::endl;
00071   //  conn->configure( cond::CmsDefaults );
00072   omds_conn.configuration().setAuthenticationPath( onlineAuthentication );
00073   omds_conn.configure();
00074   std::cout << "create omds DbSession" << std::endl;
00075   omds_session = omds_conn.createSession();
00076   std::cout << "open omds session" << std::endl;
00077   omds_session.open( onlineConnect );
00078   std::cout << "start omds transaction" << std::endl;
00079   omds_session.transaction().start();
00080   std::cout << "" << std::endl;
00081 
00082   // buffer DB connection
00083   std::cout << "configure buffer DbConnection" << std::endl;
00084   buff_conn.configuration().setAuthenticationPath( onlineAuthentication );
00085   buff_conn.configure();
00086   std::cout << "create buffer DbSession" << std::endl;
00087   cond::DbSession buff_session = buff_conn.createSession();
00088   std::cout << "open buffer session" << std::endl;
00089   buff_session.open( bufferConnect );
00090   std::cout << "start buffer transaction" << std::endl;
00091   buff_session.transaction().start();
00092 
00093   // offline info
00094 
00095   //to access the information on the tag inside the offline database:
00096   cond::TagInfo const & ti = tagInfo();
00097   unsigned int last = ti.lastInterval.first;
00098   std::cout << "latest DCS data (CCB status) already copied for run: "
00099             << last << std::endl;
00100 
00101   if ( last == 0 ) {
00102     DTLVStatus* dummyConf = new DTLVStatus( dataTag );
00103     cond::Time_t snc = 1;
00104     m_to_transfer.push_back( std::make_pair( dummyConf, snc ) );
00105   }
00106 
00107   //to access the information on last successful log entry for this tag:
00108 //  cond::LogDBEntry const & lde = logDBEntry();     
00109 
00110   //to access the lastest payload (Ref is a smart pointer)
00111 //  Ref payload = lastPayload();
00112 
00113   unsigned lastRun = last;
00114   std::cout << "check for new runs since " << lastRun << std::endl;
00115 
00116   buff_session.transaction().commit();
00117   buff_session.close();
00118   omds_session.close();
00119 
00120   return;
00121 
00122 }
00123 
00124 
00125 std::string DTLVStatusHandler::id() const {
00126   return dataTag;
00127 }
00128 
00129