2 #include "RelationalAccess/ISchema.h"
3 #include "RelationalAccess/ITable.h"
4 #include "RelationalAccess/ITableDataEditor.h"
5 #include "RelationalAccess/IQuery.h"
6 #include "RelationalAccess/ICursor.h"
7 #include "CoralBase/AttributeList.h"
8 #include "CoralBase/Attribute.h"
9 #include "CoralBase/AttributeSpecification.h"
10 #include "CoralBase/TimeStamp.h"
15 const std::string& datatableName,
16 const std::string& entryname,
17 const std::string& branchname){
18 unsigned long long entry_id=0;
19 coral::IQuery* qHandle=schema.newQuery();
22 qHandle->addToOutputList(
"e.ENTRY_ID",
"entry_id");
24 coral::AttributeList qCondition;
25 qCondition.extend(
"entryname",
typeid(std::string));
26 qCondition.extend(
"branchname",
typeid(std::string));
27 qCondition[
"entryname"].data<std::string>()=entryname;
28 qCondition[
"branchname"].data<std::string>()=branchname;
29 std::string qConditionStr(
"r.REVISION_ID=e.REVISION_ID and e.NAME=:entryname AND r.BRANCH_NAME=:branchname");
31 coral::AttributeList qResult;
32 qResult.extend(
"entry_id",
typeid(
unsigned long long));
33 qHandle->defineOutput(qResult);
34 qHandle->setCondition(qConditionStr,qCondition);
35 coral::ICursor& cursor=qHandle->execute();
37 entry_id=cursor.currentRow()[
"entry_id"].data<
unsigned long long>();
44 const std::string& datatableName,
54 const std::string& datatableName,
62 const std::string& datatableName,
64 unsigned long long branchid,
65 const std::string& branchname ){
66 coral::AttributeList revdata;
67 revdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
68 revdata.extend(
"BRANCH_ID",
typeid(
unsigned long long));
69 revdata.extend(
"BRANCH_NAME",
typeid(std::string));
70 revdata.extend(
"CTIME",
typeid(coral::TimeStamp));
71 revdata[
"REVISION_ID"].data<
unsigned long long>()=entry.
revision_id;
72 revdata[
"BRANCH_ID"].data<
unsigned long long>()=branchid;
73 revdata[
"BRANCH_NAME"].data<std::string>()=branchname;
76 schema.tableHandle(revTableName).dataEditor().insertRow(revdata);
78 coral::AttributeList entrydata;
79 entrydata.extend(
"REVISION_ID",
typeid(
unsigned long long));
80 entrydata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
81 entrydata.extend(
"NAME",
typeid(std::string));
82 entrydata[
"REVISION_ID"].data<
unsigned long long>()=entry.
revision_id;
83 entrydata[
"ENTRY_ID"].data<
unsigned long long>()=entry.
entry_id;
84 entrydata[
"NAME"].data<std::string>()=entry.
entry_name;
86 schema.tableHandle(
entryTableName).dataEditor().insertRow(entrydata);
88 coral::AttributeList revmapdata;
89 revmapdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
90 revmapdata.extend(
"DATA_ID",
typeid(
unsigned long long));
92 revmapdata[
"REVISION_ID"].data<
unsigned long long>()=entry.
revision_id;
93 revmapdata[
"DATA_ID"].data<
unsigned long long>()=entry.
data_id;
96 schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
100 const std::string& datatableName,
102 unsigned long long branchid,
103 std::string& branchname ){
104 coral::AttributeList revdata;
105 revdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
106 revdata.extend(
"BRANCH_ID",
typeid(
unsigned long long));
107 revdata.extend(
"BRANCH_NAME",
typeid(std::string));
108 revdata.extend(
"CTIME",
typeid(coral::TimeStamp));
109 revdata[
"REVISION_ID"].data<
unsigned long long>()=revision.
revision_id;
110 revdata[
"BRANCH_ID"].data<
unsigned long long>()=branchid;
111 revdata[
"BRANCH_NAME"].data<std::string>()=branchname;
114 coral::AttributeList revmapdata;
115 revmapdata.extend(
"REVISION_ID",
typeid(
unsigned long long));
116 revmapdata.extend(
"DATA_ID",
typeid(
unsigned long long));
117 revmapdata[
"REVISION_ID"].data<
unsigned long long>()=revision.
revision_id;
118 revmapdata[
"DATA_ID"].data<
unsigned long long>()=revision.
data_id;
120 schema.tableHandle(revmapTableName).dataEditor().insertRow(revmapdata);
126 lumirundata.extend(
"DATA_ID",
typeid(
unsigned long long));
127 lumirundata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
128 lumirundata.extend(
"ENTRY_NAME",
typeid(std::string));
129 lumirundata.extend(
"RUNNUM",
typeid(
unsigned int));
130 lumirundata.extend(
"SOURCE",
typeid(std::string));
131 lumirundata.extend(
"NOMINALEGEV",
typeid(
float));
132 lumirundata.extend(
"NCOLLIDINGBUNCHES",
typeid(
unsigned int));
133 lumirundata[
"DATA_ID"].data<
unsigned long long>()=lumientry.
data_id;
134 lumirundata[
"ENTRY_ID"].data<
unsigned long long>()=lumientry.
entry_id;
135 lumirundata[
"ENTRY_NAME"].data<std::string>()=lumientry.
entry_name;
136 lumirundata[
"RUNNUM"].data<
unsigned int>()=lumientry.
runnumber;
137 lumirundata[
"SOURCE"].data<std::string>()=lumientry.
source;
138 lumirundata[
"NOMINALEGEV"].data<
float>()=lumientry.
bgev;
139 lumirundata[
"NCOLLIDINGBUNCHES"].data<
unsigned int>()=lumientry.
ncollidingbunches;
147 trgrundata.extend(
"DATA_ID",
typeid(
unsigned long long));
148 trgrundata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
149 trgrundata.extend(
"ENTRY_NAME",
typeid(std::string));
150 trgrundata.extend(
"RUNNUM",
typeid(
unsigned int));
151 trgrundata.extend(
"SOURCE",
typeid(std::string));
152 trgrundata.extend(
"BITZERONAME",
typeid(std::string));
153 trgrundata.extend(
"BITNAMECLOB",
typeid(std::string));
154 trgrundata[
"DATA_ID"].data<
unsigned long long>()=trgentry.
data_id;
155 trgrundata[
"ENTRY_ID"].data<
unsigned long long>()=trgentry.
entry_id;
156 trgrundata[
"ENTRY_NAME"].data<std::string>()=trgentry.
entry_name;
157 trgrundata[
"RUNNUM"].data<
unsigned int>()=trgentry.
runnumber;
158 trgrundata[
"SOURCE"].data<std::string>()=trgentry.
source;
159 trgrundata[
"BITZERONAME"].data<std::string>()=trgentry.
bitzeroname;
160 trgrundata[
"BITNAMECLOB"].data<std::string>()=trgentry.
bitnames;
168 hltrundata.extend(
"DATA_ID",
typeid(
unsigned long long));
169 hltrundata.extend(
"ENTRY_ID",
typeid(
unsigned long long));
170 hltrundata.extend(
"ENTRY_NAME",
typeid(std::string));
171 hltrundata.extend(
"RUNNUM",
typeid(
unsigned int));
172 hltrundata.extend(
"SOURCE",
typeid(std::string));
173 hltrundata.extend(
"NPATH",
typeid(
unsigned int));
174 hltrundata.extend(
"PATHNAMECLOB",
typeid(std::string));
175 hltrundata[
"DATA_ID"].data<
unsigned long long>()=hltentry.
data_id;
176 hltrundata[
"ENTRY_ID"].data<
unsigned long long>()=hltentry.
entry_id;
177 hltrundata[
"ENTRY_NAME"].data<std::string>()=hltentry.
entry_name;
178 hltrundata[
"RUNNUM"].data<
unsigned int>()=hltentry.
runnumber;
179 hltrundata[
"SOURCE"].data<std::string>()=hltentry.
source;
180 hltrundata[
"NPATH"].data<
unsigned int>()=hltentry.
npath;
181 hltrundata[
"PATHNAMECLOB"].data<std::string>()=hltentry.
pathnames;
static const std::string trgdataTableName()
void addEntry(coral::ISchema &schema, const std::string &datatableName, const Entry &entry, unsigned long long branch_id, const std::string &branchname)
static const std::string hltdataTableName()
void insertLumiRunData(coral::ISchema &schema, const LumiEntry &lumientry)
unsigned long long data_id
std::pair< std::string, MonitorElement * > entry
static const std::string revmapTableName(const std::string &datatablename)
unsigned long long getEntryInBranchByName(coral::ISchema &schema, const std::string &datatableName, const std::string &entryname, const std::string &branchname)
static const std::string entryTableName(const std::string &datatablename)
unsigned long long revision_id
void insertTrgRunData(coral::ISchema &schema, const TrgEntry &trgentry)
static const std::string lumidataTableName()
unsigned long long entry_id
void bookNewEntry(coral::ISchema &schema, const std::string &datatableName, Entry &entry)
void insertHltRunData(coral::ISchema &schema, const HltEntry &hltentry)
unsigned int ncollidingbunches
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
void addRevision(coral::ISchema &schema, const std::string &datatableName, const Entry &revision, unsigned long long branch_id, std::string &branchname)
static const std::string revisionTableName()
void bookNewRevision(coral::ISchema &schema, const std::string &datatableName, Entry &revision)