7#include "CoralBase/Attribute.h"
8#include "CoralBase/AttributeList.h"
9#include "CoralBase/AttributeSpecification.h"
10#include "CoralKernel/Context.h"
11#include "GaudiKernel/MsgStream.h"
13#include "RelationalAccess/IAuthenticationCredentials.h"
14#include "RelationalAccess/IAuthenticationService.h"
15#include "RelationalAccess/ICursor.h"
16#include "RelationalAccess/IQuery.h"
17#include "RelationalAccess/IRelationalDomain.h"
18#include "RelationalAccess/IRelationalService.h"
19#include "RelationalAccess/ISchema.h"
20#include "RelationalAccess/ITable.h"
21#include "RelationalAccess/ITransaction.h"
22#include "RelationalAccess/SchemaException.h"
33 query->setRowCacheSize(1);
34 query->addToTableList(
"MDT_HEAD");
35 query->addToOutputList(
"max(HEAD_ID)",
"max_head_id");
36 coral::ICursor& cursor =
query->execute();
39 log << MSG::WARNING <<
"Query for head_id failed!" <<
endmsg;
42 const coral::AttributeList&
al = cursor.currentRow();
43 return static_cast<int>(
al[
"max_head_id"].data<
double>());
44 }
catch (coral::SchemaException& e) {
46 log << MSG::WARNING <<
"Schema exception : " << e.what() <<
endmsg;
55 log << MSG::WARNING <<
"CalibHeadOperations::GetHeadInfo: Cannot get latest head id" <<
endmsg;
61 query->addToTableList(
"MDT_HEAD");
62 query->addToOutputList(
"LOWRUN");
63 query->addToOutputList(
"UPRUN");
64 query->addToOutputList(
"LOWTIME");
65 query->addToOutputList(
"UPTIME");
66 std::string condition =
"HEAD_ID=:hid";
67 coral::AttributeList conditionData;
68 conditionData.extend<
int>(
"hid");
69 conditionData[
"hid"].data<
int>() = head_id;
70 query->setCondition(condition, conditionData);
71 coral::ICursor& cursor =
query->execute();
74 log << MSG::WARNING <<
"No information about head_id=" << head_id <<
" found!" <<
endmsg;
77 const coral::AttributeList&
al = cursor.currentRow();
78 lowrun =
al[
"LOWRUN"].data<
int>();
79 uprun =
al[
"UPRUN"].data<
int>();
80 lowtime =
al[
"LOWTIME"].data<
int>();
81 uptime =
al[
"UPTIME"].data<
int>();
83 }
catch (coral::SchemaException& e) {
85 log << MSG::WARNING <<
"Schema exception : " << e.what() <<
endmsg;
91 const std::string& writer_user,
const std::string& writer_password) {
93 if (head_id < 0)
return nullptr;
97 query->setRowCacheSize(1);
98 query->addToTableList(
"MDT_HEAD");
99 query->addToTableList(
"MDT_DATA_SCHEMA");
100 query->addToOutputList(
"MDT_DATA_SCHEMA.SCHEMA_NAME",
"SCHEMA");
101 query->addToOutputList(
"MDT_DATA_SCHEMA.WRITER_ACCOUNT",
"WRITER_ACCOUNT");
102 query->addToOutputList(
"MDT_DATA_SCHEMA.ACTIVE",
"ACTIVE");
103 query->addToOutputList(
"MDT_DATA_SCHEMA.ARCHIVED",
"ARCHIVED");
104 query->addToOutputList(
"MDT_DATA_SCHEMA.ARCHIVE_CONNECTION_STRING",
"ARCHIVE_CONNECTION_STRING");
105 std::string condition =
"MDT_HEAD.DATA_SCHEMA=MDT_DATA_SCHEMA.SCHEMA_NAME and MDT_HEAD.HEAD_ID=:hid";
106 coral::AttributeList conditionData;
107 conditionData.extend<
int>(
"hid");
108 conditionData[
"hid"].data<
int>() = head_id;
109 query->setCondition(condition, conditionData);
110 coral::ICursor& cursor =
query->execute();
111 if (!cursor.next()) {
113 log << MSG::WARNING <<
"No information about head_id=" << head_id <<
" found!" <<
endmsg;
116 const coral::AttributeList&
al = cursor.currentRow();
119 log << MSG::WARNING <<
"Can only write to the active schema" <<
endmsg;
127 std::string user, passwd;
129 conn->SetLogin(user, passwd);
134 ret->
SetLogin(writer_user, writer_password);
136 }
catch (coral::SchemaException& e) {
138 log << MSG::WARNING <<
"Schema exception : " << e.what() <<
endmsg;
char data[hepevt_bytes_allocation_ATLAS]
void SetTargetUser(const std::string &target_user)
void SetLogin(const std::string &username, const std::string &password)
CalibDbConnection * GetDataConnection(int head_id=-1, bool write=false, const std::string &writer_connection="", const std::string &writer_user="", const std::string &writer_password="")
virtual ~CalibHeadOperations()
CalibDbConnection * m_meta_connection
CalibHeadOperations(CalibDbConnection &db_conn)
bool GetHeadInfo(int &head_id, int &lowrun, int &uprun, int &lowtime, int &uptime)
singleton-like access to IMessageSvc via open function and helper
IMessageSvc * getMessageSvc(bool quiet=false)
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.