CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
cond::persistency::RunInfoEditor Class Reference

#include <RunInfoEditor.h>

Public Member Functions

size_t flush ()
 
cond::Time_t getLastInserted ()
 
void init ()
 
void insert (cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
 
void insertNew (cond::Time_t runNumber, const boost::posix_time::ptime &start, const boost::posix_time::ptime &end)
 
RunInfoEditoroperator= (const RunInfoEditor &rhs)
 
 RunInfoEditor ()
 
 RunInfoEditor (const std::shared_ptr< SessionImpl > &session)
 
 RunInfoEditor (const RunInfoEditor &rhs)
 

Private Member Functions

void checkTransaction (const std::string &ctx)
 

Private Attributes

std::shared_ptr< RunInfoEditorDatam_data
 
std::shared_ptr< SessionImplm_session
 

Detailed Description

Definition at line 28 of file RunInfoEditor.h.

Constructor & Destructor Documentation

RunInfoEditor::RunInfoEditor ( )

Definition at line 22 of file RunInfoEditor.cc.

22  :
23  m_data(),
24  m_session(){
25  }
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61
RunInfoEditor::RunInfoEditor ( const std::shared_ptr< SessionImpl > &  session)
explicit

Definition at line 27 of file RunInfoEditor.cc.

27  :
28  m_data( new RunInfoEditorData ),
29  m_session( session ){
30 
31  }
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61
RunInfoEditor::RunInfoEditor ( const RunInfoEditor rhs)

Definition at line 33 of file RunInfoEditor.cc.

33  :
34  m_data( rhs.m_data ),
35  m_session( rhs.m_session ){
36  }
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61

Member Function Documentation

void RunInfoEditor::checkTransaction ( const std::string &  ctx)
private

Definition at line 107 of file RunInfoEditor.cc.

References m_session, and cond::persistency::throwException().

Referenced by flush(), getLastInserted(), and init().

107  {
108  if( !m_session.get() ) throwException("The session is not active.",ctx );
109  if( !m_session->isTransactionActive( false ) ) throwException("The transaction is not active.",ctx );
110  }
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
size_t RunInfoEditor::flush ( )

Definition at line 67 of file RunInfoEditor.cc.

References checkTransaction(), m_data, m_session, mps_check::msg, cond::persistency::throwException(), and update.

Referenced by RunInfoUpdate::appendNewRun(), and RunInfoUpdate::import().

67  {
68  size_t ret = 0;
69  if( m_data.get() ){
70  checkTransaction( "RunInfoEditor::flush" );
71  m_session->runInfoSchema().runInfoTable().insert( m_data->runBuffer );
72  ret += m_data->runBuffer.size();
73  for( auto update: m_data->updateBuffer ) {
74  cond::Time_t newRun = std::get<0>(update);
75  boost::posix_time::ptime& newRunStart = std::get<1>(update);
76  boost::posix_time::ptime& newRunEnd = std::get<2>(update);
77  boost::posix_time::ptime existingRunStart;
78  boost::posix_time::ptime existingRunEnd;
79  if( m_session->runInfoSchema().runInfoTable().select( newRun, existingRunStart, existingRunEnd ) ){
80  if( newRunStart!=existingRunStart ) {
81  std::stringstream msg;
82  msg<< "Attempt to update start time of existing run "<< newRun;
83  throwException(msg.str(),"RunInfoEditor::flush");
84  }
85  if( existingRunEnd == newRunEnd ){
86  // nothing to do
87  continue;
88  } else {
89  if( existingRunEnd!=existingRunStart ){
90  std::stringstream msg;
91  msg<< "Attempt to update end time of existing run "<< newRun;
92  throwException(msg.str(),"RunInfoEditor::flush");
93  }
94  }
95  m_session->runInfoSchema().runInfoTable().updateEnd( newRun, newRunEnd );
96  } else {
97  m_session->runInfoSchema().runInfoTable().insertOne( newRun, newRunStart, newRunEnd );
98  }
99  ret++;
100  }
101  m_data->runBuffer.clear();
102  m_data->updateBuffer.clear();
103  }
104  return ret;
105  }
unsigned long long Time_t
Definition: Time.h:16
tuple msg
Definition: mps_check.py:285
void checkTransaction(const std::string &ctx)
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61
#define update(a, b)
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
cond::Time_t RunInfoEditor::getLastInserted ( )

Definition at line 51 of file RunInfoEditor.cc.

References checkTransaction(), m_data, m_session, and cond::time::MIN_VAL().

Referenced by RunInfoUpdate::import().

51  {
52  if( m_data.get() ){
53  checkTransaction( "RunInfoEditor::getLastInserted" );
54  return m_session->runInfoSchema().runInfoTable().getLastInserted();
55  }
56  return cond::time::MIN_VAL;
57  }
const Time_t MIN_VAL(0)
void checkTransaction(const std::string &ctx)
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61
void RunInfoEditor::init ( void  )

Definition at line 44 of file RunInfoEditor.cc.

References checkTransaction(), m_data, and m_session.

Referenced by cond::persistency::Session::editRunInfo().

44  {
45  if( m_data.get() ){
46  checkTransaction( "RunInfoEditor::init" );
47  if( !m_session->runInfoSchema().exists() ) m_session->runInfoSchema().create();
48  }
49  }
void checkTransaction(const std::string &ctx)
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61
void RunInfoEditor::insert ( cond::Time_t  runNumber,
const boost::posix_time::ptime &  start,
const boost::posix_time::ptime &  end 
)

Definition at line 59 of file RunInfoEditor.cc.

References m_data.

Referenced by BeautifulSoup.PageElement::append(), and RunInfoUpdate::import().

59  {
60  if( m_data.get() ) m_data->runBuffer.push_back( std::tie( runNumber, start, end ) );
61  }
Definition: start.py:1
#define end
Definition: vmac.h:39
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
void RunInfoEditor::insertNew ( cond::Time_t  runNumber,
const boost::posix_time::ptime &  start,
const boost::posix_time::ptime &  end 
)

Definition at line 63 of file RunInfoEditor.cc.

References m_data.

Referenced by RunInfoUpdate::appendNewRun().

63  {
64  if( m_data.get() ) m_data->updateBuffer.push_back( std::tie( runNumber, start, end ) );
65  }
Definition: start.py:1
#define end
Definition: vmac.h:39
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
RunInfoEditor & RunInfoEditor::operator= ( const RunInfoEditor rhs)

Definition at line 38 of file RunInfoEditor.cc.

References m_data, and m_session.

38  {
39  m_data = rhs.m_data;
40  m_session = rhs.m_session;
41  return *this;
42  }
std::shared_ptr< RunInfoEditorData > m_data
Definition: RunInfoEditor.h:60
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoEditor.h:61

Member Data Documentation

std::shared_ptr<RunInfoEditorData> cond::persistency::RunInfoEditor::m_data
private

Definition at line 60 of file RunInfoEditor.h.

Referenced by flush(), getLastInserted(), init(), insert(), insertNew(), and operator=().

std::shared_ptr<SessionImpl> cond::persistency::RunInfoEditor::m_session
private

Definition at line 61 of file RunInfoEditor.h.

Referenced by checkTransaction(), flush(), getLastInserted(), init(), and operator=().