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->openIovDb( SessionImpl::CREATE );
79  }
80 
82  m_session->openIovDb();
83  IOVProxy proxy( m_session );
84  proxy.load( tag, full );
85  return proxy;
86  }
87 
89  m_session->openIovDb();
90  return m_session->iovSchema().tagTable().select( tag );
91  }
92 
94  m_session->openIovDb();
95  IOVProxy proxy( m_session );
96  return proxy;
97  }
98 
99  IOVEditor Session::createIov( const std::string& payloadType, const std::string& tag, cond::TimeType timeType,
100  cond::SynchronizationType synchronizationType ){
101  m_session->openIovDb( SessionImpl::CREATE );
102  if( m_session->iovSchema().tagTable().select( tag ) )
103  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIov");
104  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
105  return editor;
106  }
107 
109  cond::SynchronizationType synchronizationType ){
110  m_session->openIovDb( SessionImpl::CREATE );
111  if( m_session->iovSchema().tagTable().select( tag ) )
112  throwException( "The specified tag \""+tag+"\" already exist in the database.","Session::createIovForPayload");
113  std::string payloadType("");
114  if( !m_session->iovSchema().payloadTable().getType( payloadHash, payloadType ) )
115  throwException( "The specified payloadId \""+payloadHash+"\" does not exist in the database.","Session::createIovForPayload");
116  IOVEditor editor( m_session, tag, timeType, payloadType, synchronizationType );
117  return editor;
118  }
119 
121  m_session->openIovDb();
123  editor.load( tag );
124  return editor;
125  }
126 
128  m_session->openGTDb();
129  if( m_session->gtSchema().gtTable().select( name ) )
130  throwException( "The specified Global Tag \""+name+"\" already exist in the database.","Session::createGlobalTag");
131  GTEditor editor( m_session, name );
132  return editor;
133  }
134 
136  m_session->openGTDb();
138  editor.load( name );
139  return editor;
140  }
141 
143  m_session->openGTDb();
144  GTProxy proxy( m_session );
145  proxy.load( name );
146  return proxy;
147  }
148 
149  GTProxy Session::readGlobalTag( const std::string& name, const std::string& preFix, const std::string& postFix ){
150  m_session->openGTDb();
151  GTProxy proxy( m_session );
152  proxy.load( name, preFix, postFix );
153  return proxy;
154  }
155 
157  const cond::Binary& payloadData,
158  const boost::posix_time::ptime& creationTime ){
159  m_session->openIovDb( SessionImpl::CREATE );
160  return m_session->iovSchema().payloadTable().insertIfNew( payloadObjectType, payloadData, creationTime );
161  }
162 
163  bool Session::fetchPayloadData( const cond::Hash& payloadHash,
164  std::string& payloadType,
165  cond::Binary& payloadData ){
166  m_session->openIovDb();
167  return m_session->iovSchema().payloadTable().select( payloadHash, payloadType, payloadData );
168  }
169 
171  return m_session->isOra();
172  }
173 
174  bool Session::checkMigrationLog( const std::string& sourceAccount, const std::string& sourceTag, std::string& destTag ){
175  if(! m_session->iovSchema().tagMigrationTable().exists() ) m_session->iovSchema().tagMigrationTable().create();
176  //throwException( "Migration Log Table does not exist in this schema.","Session::checkMigrationLog");
177  return m_session->iovSchema().tagMigrationTable().select( sourceAccount, sourceTag, destTag );
178  }
179 
180  void Session::addToMigrationLog( const std::string& sourceAccount, const std::string& sourceTag, const std::string& destTag ){
181  if(! m_session->iovSchema().tagMigrationTable().exists() ) m_session->iovSchema().tagMigrationTable().create();
182  m_session->iovSchema().tagMigrationTable().insert( sourceAccount, sourceTag, destTag,
183  boost::posix_time::microsec_clock::universal_time() );
184  }
185 
187  return m_session->connectionString;
188  }
189 
190  coral::ISessionProxy& Session::coralSession(){
191  if( !m_session->coralSession.get() ) throwException( "The session is not active.","Session::coralSession");
192  return *m_session->coralSession;
193  }
194 
195  coral::ISchema& Session::nominalSchema(){
196  return coralSession().nominalSchema();
197  }
198 
200  m_transaction(transaction),m_status(true){
202  }
203 
205  if(!m_status && m_transaction.isActive() ) {
207  }
208  }
209 
210  void TransactionScope::start( bool readOnly ){
211  m_transaction.start( readOnly );
212  m_status = false;
213  }
214 
217  m_status = true;
218  }
219 
221  m_status = true;
222  }
223 
224  }
225 }
GTEditor editGlobalTag(const std::string &name)
Definition: Session.cc:135
Transaction(SessionImpl &session)
Definition: Session.cc:9
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:123
bool fetchPayloadData(const cond::Hash &payloadHash, std::string &payloadType, cond::Binary &payloadData)
Definition: Session.cc:163
void start(bool readOnly=true)
Definition: Session.cc:22
void addToMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, const std::string &destinationTag)
Definition: Session.cc:180
void load(const std::string &tag)
Definition: IOVEditor.cc:68
TransactionScope(Transaction &transaction)
Definition: Session.cc:199
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:125
coral::ISchema & nominalSchema()
Definition: Session.cc:195
Definition: GenABIO.cc:193
void start(bool readOnly=true)
Definition: Session.cc:210
std::string Hash
Definition: Types.h:38
std::string connectionString()
Definition: Session.cc:186
IOVEditor editIov(const std::string &tag)
Definition: Session.cc:120
void startTransaction(bool readOnly=true)
Definition: SessionImpl.cc:111
IOVEditor createIovForPayload(const Hash &payloadHash, const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.cc:108
tuple editor
Definition: idDealer.py:73
bool checkMigrationLog(const std::string &sourceAccount, const std::string &sourceTag, std::string &destinationTag)
Definition: Session.cc:174
bool existsIov(const std::string &tag)
Definition: Session.cc:88
coral::ISessionProxy & coralSession()
Definition: Session.cc:190
IOVEditor createIov(const std::string &tag, cond::TimeType timeType, cond::SynchronizationType synchronizationType=cond::OFFLINE)
Definition: Session.h:151
SynchronizationType
Definition: Types.h:26
bool isTransactionActive(bool deep=true) const
Definition: SessionImpl.cc:156
GTEditor createGlobalTag(const std::string &name)
Definition: Session.cc:127
Session & operator=(const Session &rhs)
Definition: Session.cc:56
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:142
void load(const std::string &gtName)
Definition: GTEditor.cc:53
Transaction m_transaction
Definition: Session.h:148
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:11
std::shared_ptr< SessionImpl > m_session
Definition: Session.h:147
cond::Hash storePayloadData(const std::string &payloadObjectType, const cond::Binary &payloadData, const boost::posix_time::ptime &creationTime)
Definition: Session.cc:156