CMS 3D CMS Logo

GTSchema.cc
Go to the documentation of this file.
2 #include "GTSchema.h"
3 //
4 namespace cond {
5 
6  namespace persistency {
7 
8  GLOBAL_TAG::Table::Table(coral::ISchema& schema) : m_schema(schema) {}
9 
10  bool GLOBAL_TAG::Table::exists() { return existsTable(m_schema, tname); }
11 
13  if (exists()) {
14  throwException("GLOBAL_TAG table already exists in this schema.", "GLOBAL_TAG::Table::create");
15  }
17  descr.setPrimaryKey<NAME>();
18  createTable(m_schema, descr.get());
19  }
20 
22  Query<NAME> q(m_schema);
23  q.addCondition<NAME>(name);
24  for (auto row : q) {
25  }
26 
27  return q.retrievedRows();
28  }
29 
31  cond::Time_t& validity,
32  boost::posix_time::ptime& snapshotTime) {
34  q.addCondition<NAME>(name);
35  for (auto row : q)
36  std::tie(validity, snapshotTime) = row;
37 
38  return q.retrievedRows();
39  }
40 
42  cond::Time_t& validity,
45  boost::posix_time::ptime& snapshotTime) {
47  q.addCondition<NAME>(name);
48  for (const auto& row : q)
49  std::tie(validity, description, release, snapshotTime) = row;
50 
51  return q.retrievedRows();
52  }
53 
55  cond::Time_t validity,
56  const std::string& description,
57  const std::string& release,
58  const boost::posix_time::ptime& snapshotTime,
59  const boost::posix_time::ptime& insertionTime) {
61  std::tie(name, validity, description, release, snapshotTime, insertionTime));
62  insertInTable(m_schema, tname, dataToInsert.get());
63  }
64 
66  cond::Time_t validity,
67  const std::string& description,
68  const std::string& release,
69  const boost::posix_time::ptime& snapshotTime,
70  const boost::posix_time::ptime& insertionTime) {
73  std::tie(validity, description, release, snapshotTime, insertionTime));
74  buffer.addWhereCondition<NAME>(name);
75  updateTable(m_schema, tname, buffer);
76  }
77 
78  GLOBAL_TAG_MAP::Table::Table(coral::ISchema& schema) : m_schema(schema) {}
79 
80  bool GLOBAL_TAG_MAP::Table::exists() { return existsTable(m_schema, tname); }
81 
83  if (exists()) {
84  throwException("GLOBAL_TAG_MAP table already exists in this schema.", "GLOBAL_TAG_MAP::Table::create");
85  }
88  createTable(m_schema, descr.get());
89  }
90 
92  std::vector<std::tuple<std::string, std::string, std::string> >& tags) {
94  q.addCondition<GLOBAL_TAG_NAME>(gtName);
95  q.addOrderClause<RECORD>();
96  q.addOrderClause<LABEL>();
97  for (auto row : q) {
98  if (std::get<1>(row) == "-") {
99  std::get<1>(row) = "";
100  }
101  tags.push_back(row);
102  }
103  return q.retrievedRows();
104  }
105 
107  const std::string&,
108  const std::string&,
109  std::vector<std::tuple<std::string, std::string, std::string> >& tags) {
110  return select(gtName, tags);
111  }
112 
114  const std::vector<std::tuple<std::string, std::string, std::string> >& tags) {
116  for (auto row : tags)
117  inserter.insert(std::tuple_cat(std::tie(gtName), row));
118  inserter.flush();
119  }
120 
121  GTSchema::GTSchema(coral::ISchema& schema) : m_gtTable(schema), m_gtMapTable(schema) {}
122 
124  if (!m_gtTable.exists())
125  return false;
126  if (!m_gtMapTable.exists())
127  return false;
128  return true;
129  }
130 
132  m_gtTable.create();
134  }
135 
137 
139 
140  } // namespace persistency
141 } // namespace cond
bool select(const std::string &gtName, std::vector< std::tuple< std::string, std::string, std::string > > &tags) override
Definition: GTSchema.cc:91
bool select(const std::string &name) override
Definition: GTSchema.cc:21
void update(const std::string &name, cond::Time_t validity, const std::string &description, const std::string &release, const boost::posix_time::ptime &snapshotTime, const boost::posix_time::ptime &insertionTime) override
Definition: GTSchema.cc:65
void create() override
Definition: GTSchema.cc:131
static constexpr char const * tname
Definition: GTSchema.h:52
const coral::TableDescription & get()
Definition: DbCore.h:338
GLOBAL_TAG::Table m_gtTable
Definition: GTSchema.h:92
void insert(const std::string &name, cond::Time_t validity, const std::string &description, const std::string &release, const boost::posix_time::ptime &snapshotTime, const boost::posix_time::ptime &insertionTime) override
Definition: GTSchema.cc:54
Table(coral::ISchema &schema)
Definition: GTSchema.cc:8
void insert(const P &params)
Definition: DbCore.h:687
GLOBAL_TAG_MAP::Table & gtMapTable() override
Definition: GTSchema.cc:138
GTSchema(coral::ISchema &schema)
Definition: GTSchema.cc:121
unsigned long long Time_t
Definition: Time.h:14
void insert(const std::string &gtName, const std::vector< std::tuple< std::string, std::string, std::string > > &tags) override
Definition: GTSchema.cc:113
const coral::AttributeList & get() const
Definition: DbCore.h:201
bool exists() override
Definition: GTSchema.cc:123
static constexpr char const * tname
Definition: GTSchema.h:13
GLOBAL_TAG::Table & gtTable() override
Definition: GTSchema.cc:136
Definition: plugin.cc:23
GLOBAL_TAG_MAP::Table m_gtMapTable
Definition: GTSchema.h:93
Table(coral::ISchema &schema)
Definition: GTSchema.cc:78
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12