CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Session.cc
Go to the documentation of this file.
2 #include "SessionImpl.h"
3 //
4 
5 namespace cond {
6 
7  namespace persistency {
8 
10  m_session( &session ){
11  }
12 
14  m_session( rhs.m_session ){
15  }
16 
18  m_session = rhs.m_session;
19  return *this;
20  }
21 
22  void Transaction::start( bool readOnly ){
23  m_session->startTransaction( readOnly );
24  }
25 
28  }
29 
32  }
33 
36  }
37 
39  m_session( new SessionImpl ),
40  m_transaction( *m_session ){
41  }
42 
43  Session::Session( const std::shared_ptr<SessionImpl>& sessionImpl ):
44  m_session( sessionImpl ),
45  m_transaction( *m_session ){
46  }
47 
48  Session::Session( const Session& rhs ):
49  m_session( rhs.m_session ),
50  m_transaction( rhs.m_transaction ){
51  }
52 
54  }
55 
57  m_session = rhs.m_session;
59  return *this;
60  }
61 
63  m_session->close();
64  }
65 
67  return m_transaction;
68  }
69 
70  //
73  return m_session->transaction->iovDbExists;
74  }
75 
76  //
78  m_session->openDb();
79  }
80 
82  m_session->openIovDb();
83  IOVProxy proxy( m_session );
84  proxy.load( tag, full );
85  return proxy;
86  }
87 
89  const boost::posix_time::ptime& snapshottime,
90  bool full ){
91  m_session->openIovDb();
92  IOVProxy proxy( m_session );
93  proxy.load( tag, snapshottime, full );
94  return proxy;
95  }
96 
98  m_session->openIovDb();
99  return m_session->iovSchema().tagTable().select( tag );
100  }
101 
103  m_session->openIovDb();
104  IOVProxy proxy( m_session );
105  return proxy;
106  }
107 
109  cond::SynchronizationType synchronizationType ){
110  m_session->openDb();
111  if( m_session->iovSchema().tagTable().select( tag ) )
112  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
113  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
114  return editor;
115  }
116 
118  const std::string& tag,
119  cond::TimeType timeType,
120  cond::SynchronizationType synchronizationType,
121  const boost::posix_time::ptime& creationTime ){
122  m_session->openDb();
123  if( m_session->iovSchema().tagTable().select( tag ) )
124  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
125  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType, creationTime );
126  return editor;
127  }
128 
130  cond::SynchronizationType synchronizationType ){
131  m_session->openDb();
132  if( m_session->iovSchema().tagTable().select( tag ) )
133  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
135  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
136  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
137  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
138  return editor;
139  }
140 
142  m_session->openIovDb();
144  editor.load( tag );
145  return editor;
146  }
147 
149  m_session->openIovDb();
150  m_session->iovSchema().iovTable().erase( tag );
151  }
152 
154  m_session->openGTDb();
155  return m_session->gtSchema().gtTable().select( name );
156  }
157 
159  m_session->openGTDb();
160  if( m_session->gtSchema().gtTable().select( name ) )
161  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
162  GTEditor editor( m_session, name );
163  return editor;
164  }
165 
167  m_session->openGTDb();
169  editor.load( name );
170  return editor;
171  }
172 
174  m_session->openGTDb();
175  GTProxy proxy( m_session );
176  proxy.load( name );
177  return proxy;
178  }
179 
180  GTProxy Session::readGlobalTag( const std::string& name, const std::string& preFix, const std::string& postFix ){
181  m_session->openGTDb();
182  GTProxy proxy( m_session );
183  proxy.load( name, preFix, postFix );
184  return proxy;
185  }
186 
188  const std::pair<Binary,Binary>& payloadAndStreamerInfoData,
189  const boost::posix_time::ptime& creationTime ){
190  m_session->openDb();
191  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadAndStreamerInfoData.first,
192  payloadAndStreamerInfoData.second, creationTime );
193  }
194 
195  bool Session::fetchPayloadData( const cond::Hash& payloadHash,
197  cond::Binary& payloadData,
198  cond::Binary& streamerInfoData ){
199  m_session->openIovDb();
200  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData, streamerInfoData );
201  }
202 
204  return m_session->connectionString;
205  }
206 
207  coral::ISessionProxy& Session::coralSession(){
208  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
209  return *m_session->coralSession;
210  }
211 
212  coral::ISchema& Session::nominalSchema(){
213  return coralSession().nominalSchema();
214  }
215 
217  m_transaction(transaction),m_status(true){
219  }
220 
222  if(!m_status && m_transaction.isActive() ) {
224  }
225  }
226 
227  void TransactionScope::start( bool readOnly ){
228  m_transaction.start( readOnly );
229  m_status = false;
230  }
231 
234  m_status = true;
235  }
236 
238  m_status = true;
239  }
240 
241  }
242 }
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:166
Transaction(SessionImpl &session)
Definition: Session.cc:9
bool existsGlobalTag(const std::string &name)
Definition: Session.cc:153
void clearIov(const std::string &tag)
Definition: Session.cc:148
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:130
void start(bool readOnly=true)
Definition: Session.cc:22
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.h:173
void load(const std::string &tag)
Definition: IOVEditor.cc:73
TransactionScope(Transaction &transaction)
Definition: Session.cc:216
Transaction & transaction()
Definition: Session.cc:66
TimeType
Definition: Time.h:21
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
Transaction & operator=(const Transaction &rhs)
Definition: Session.cc:17
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:130
coral::ISchema & nominalSchema()
Definition: Session.cc:212
Definition: GenABIO.cc:180
void start(bool readOnly=true)
Definition: Session.cc:227
tuple transaction
Definition: idDealer.py:60
std::string Hash
Definition: Types.h:45
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData, cond::Binary &streamerInfoData)
Definition: Session.cc:195
std::string connectionString()
Definition: Session.cc:203
cond::Hash storePayloadData(const std::string &payloadObjectType, const std::pair< Binary, Binary > &payloadAndStreamerInfoData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:187
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:141
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:63
tuple editor
Definition: idDealer.py:73
bool existsIov(const std::string &tag)
Definition: Session.cc:97
coral::ISessionProxy & coralSession()
Definition: Session.cc:207
SynchronizationType
Definition: Types.h:29
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:97
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::SYNCH_ANY)
Definition: Session.cc:129
session
Definition: models.py:201
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:158
Session & operator=(const Session &rhs)
Definition: Session.cc:56
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:173
void load(const std::string &gtName)
Definition: GTEditor.cc:60
Transaction m_transaction
Definition: Session.h:170
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:169