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 ):
9  m_schema( schema ){
10  }
11 
13  return existsTable( m_schema, tname );
14  }
15 
17  if( exists() ){
18  throwException( "GLOBAL_TAG table already exists in this schema.",
19  "GLOBAL_TAG::Table::create");
20  }
22  descr.setPrimaryKey<NAME>();
23  createTable( m_schema, descr.get() );
24  }
25 
28  q.addCondition<NAME>( name );
29  for ( auto row : q ) {}
30 
31  return q.retrievedRows();
32  }
33 
35  cond::Time_t& validity,
36  boost::posix_time::ptime& snapshotTime ){
38  q.addCondition<NAME>( name );
39  for ( auto row : q ) std::tie( validity, snapshotTime ) = row;
40 
41  return q.retrievedRows();
42  }
43 
45  cond::Time_t& validity,
48  boost::posix_time::ptime& snapshotTime ){
50  q.addCondition<NAME>( name );
51  for ( auto row : q ) std::tie( validity, description, release, snapshotTime ) = row;
52 
53  return q.retrievedRows();
54  }
55 
57  cond::Time_t validity,
58  const std::string& description,
59  const std::string& release,
60  const boost::posix_time::ptime& snapshotTime,
61  const boost::posix_time::ptime& insertionTime ){
63  dataToInsert( std::tie( name, validity, description, release, snapshotTime, insertionTime ) );
64  insertInTable( m_schema, tname, dataToInsert.get() );
65  }
66 
68  cond::Time_t validity,
69  const std::string& description,
70  const std::string& release,
71  const boost::posix_time::ptime& snapshotTime,
72  const boost::posix_time::ptime& insertionTime ){
74  buffer.setColumnData< VALIDITY, DESCRIPTION, RELEASE, SNAPSHOT_TIME, INSERTION_TIME >( std::tie( validity, description, release, snapshotTime, insertionTime ) );
75  buffer.addWhereCondition<NAME>( name );
76  updateTable( m_schema, tname, buffer );
77  }
78 
80  m_schema( schema ){
81  }
82 
84  return existsTable( m_schema, tname );
85  }
86 
88  if( exists() ){
89  throwException( "GLOBAL_TAG_MAP table already exists in this schema.",
90  "GLOBAL_TAG_MAP::Table::create");
91  }
94  createTable( m_schema, descr.get() );
95  }
96 
98  std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
100  q.addCondition< GLOBAL_TAG_NAME >( gtName );
101  q.addOrderClause<RECORD>();
102  q.addOrderClause<LABEL>();
103  for ( auto row : q ) {
104  if ( std::get<1>(row) == "-" ) {
105  std::get<1>(row) = "";
106  }
107  tags.push_back( row );
108  }
109  return q.retrievedRows();
110  }
111 
113  std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
114  return select( gtName, tags );
115  }
116 
118  const std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
120  for( auto row : tags ) inserter.insert( std::tuple_cat( std::tie( gtName ),row ) );
121  inserter.flush();
122  }
123 
124  GTSchema::GTSchema( coral::ISchema& schema ):
125  m_gtTable( schema ),
126  m_gtMapTable( schema ){
127  }
128 
130  if( !m_gtTable.exists() ) return false;
131  if( !m_gtMapTable.exists() ) return false;
132  return true;
133  }
134 
136  m_gtTable.create();
138  }
139 
141  return m_gtTable;
142  }
143 
145  return m_gtMapTable;
146  }
147 
148  }
149 }
bool select(const std::string &gtName, std::vector< std::tuple< std::string, std::string, std::string > > &tags) override
Definition: GTSchema.cc:97
bool select(const std::string &name) override
Definition: GTSchema.cc:26
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:67
void create() override
Definition: GTSchema.cc:135
const coral::TableDescription & get()
Definition: DbCore.h:262
static char const * tname
Definition: GTSchema.h:13
GLOBAL_TAG::Table m_gtTable
Definition: GTSchema.h:76
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:56
Table(coral::ISchema &schema)
Definition: GTSchema.cc:8
void insert(const P &params)
Definition: DbCore.h:590
GLOBAL_TAG_MAP::Table & gtMapTable() override
Definition: GTSchema.cc:144
GTSchema(coral::ISchema &schema)
Definition: GTSchema.cc:124
unsigned long long Time_t
Definition: Time.h:16
const coral::AttributeList & get() const
Definition: DbCore.h:167
Query & addCondition(const T &value, const std::string condition="=")
Definition: DbCore.h:425
void insert(const std::string &gtName, const std::vector< std::tuple< std::string, std::string, std::string > > &tags) override
Definition: GTSchema.cc:117
Query & addOrderClause(bool ascending=true)
Definition: DbCore.h:438
bool exists() override
Definition: GTSchema.cc:129
void setColumnData(const Params &params)
Definition: DbCore.h:514
GLOBAL_TAG::Table & gtTable() override
Definition: GTSchema.cc:140
Definition: plugin.cc:24
static char const * tname
Definition: GTSchema.h:41
GLOBAL_TAG_MAP::Table m_gtMapTable
Definition: GTSchema.h:77
Table(coral::ISchema &schema)
Definition: GTSchema.cc:79
void addWhereCondition(const P &param, const std::string condition="=")
Definition: DbCore.h:523
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:14