CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  Query< NAME > q( m_schema );
18  q.addCondition<NAME>( name );
19  for ( auto row : q ) {}
20 
21  return q.retrievedRows();
22  }
23 
25  cond::Time_t& validity,
26  boost::posix_time::ptime& snapshotTime ){
27  // FIXME: FronTier reads from Oracle with a Format not compatible with the parsing in Coral: required is 'YYYY-MM-DD HH24:MI:SSXFF6'
28  // temporarely disabled to allow to work with FronTier
29  //Query< VALIDITY, SNAPSHOT_TIME > q( session.coralSchema() );
30  //q.addCondition<NAME>( name );
31  //for ( auto row : q ) std::tie( validity, snapshotTime ) = row;
32  Query< VALIDITY > q( m_schema );
33  q.addCondition<NAME>( name );
34  for ( auto row : q ) std::tie( validity ) = row;
35 
36  return q.retrievedRows();
37  }
38 
40  cond::Time_t& validity,
43  boost::posix_time::ptime& snapshotTime ){
44  // FIXME: Frontier reads from Oracle with a Format not compatible with the parsing in Coral: required is 'YYYY-MM-DD HH24:MI:SSXFF6'
45  // temporarely disabled to allow to work with FronTier
46  //Query< VALIDITY, DESCRIPTION, RELEASE, SNAPSHOT_TIME > q( session.coralSchema() );
47  //q.addCondition<NAME>( name );
48  //for ( auto row : q ) std::tie( validity, description, release, snapshotTime ) = row;
50  q.addCondition<NAME>( name );
51  for ( auto row : q ) std::tie( validity, description, release ) = row;
52  return q.retrievedRows();
53  }
54 
56  cond::Time_t validity,
57  const std::string& description,
58  const std::string& release,
59  const boost::posix_time::ptime& snapshotTime,
60  const boost::posix_time::ptime& insertionTime ){
62  dataToInsert( std::tie( name, validity, description, release, snapshotTime, insertionTime ) );
63  insertInTable( m_schema, tname, dataToInsert.get() );
64  }
65 
67  cond::Time_t validity,
68  const std::string& description,
69  const std::string& release,
70  const boost::posix_time::ptime& snapshotTime,
71  const boost::posix_time::ptime& insertionTime ){
72  UpdateBuffer buffer;
73  buffer.setColumnData< VALIDITY, DESCRIPTION, RELEASE, SNAPSHOT_TIME, INSERTION_TIME >( std::tie( validity, description, release, snapshotTime, insertionTime ) );
74  buffer.addWhereCondition<NAME>( name );
75  updateTable( m_schema, tname, buffer );
76  }
77 
79  m_schema( schema ){
80  }
81 
83  return existsTable( m_schema, tname );
84  }
85 
87  std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
89  q.addCondition< GLOBAL_TAG_NAME >( gtName );
91  q.addOrderClause<LABEL>();
92  for ( auto row : q ) {
93  if ( std::get<1>(row) == "-" ) {
94  std::get<1>(row) = "";
95  }
96  tags.push_back( row );
97  }
98  return q.retrievedRows();
99  }
100 
102  std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
103  return select( gtName, tags );
104  }
105 
107  const std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
109  for( auto row : tags ) inserter.insert( std::tuple_cat( std::tie( gtName ),row ) );
110  inserter.flush();
111  }
112 
113  GTSchema::GTSchema( coral::ISchema& schema ):
114  m_gtTable( schema ),
115  m_gtMapTable( schema ){
116  }
117 
119  if( !m_gtTable.exists() ) return false;
120  if( !m_gtMapTable.exists() ) return false;
121  return true;
122  }
123 
125  return m_gtTable;
126  }
127 
129  return m_gtMapTable;
130  }
131 
132  }
133 }
bool select(const std::string &name)
Definition: GTSchema.cc:16
GLOBAL_TAG::Table & gtTable()
Definition: GTSchema.cc:124
static char const * tname
Definition: GTSchema.h:13
GLOBAL_TAG::Table m_gtTable
Definition: GTSchema.h:73
void insert(const P &params)
Definition: DbCore.h:584
GTSchema(coral::ISchema &schema)
Definition: GTSchema.cc:113
unsigned long long Time_t
Definition: Time.h:16
void addCondition(const T &value, const std::string condition="=")
Definition: DbCore.h:428
const coral::AttributeList & get() const
Definition: DbCore.h:171
void addOrderClause(bool ascending=true)
Definition: DbCore.h:439
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)
Definition: GTSchema.cc:55
GLOBAL_TAG_MAP::Table & gtMapTable()
Definition: GTSchema.cc:128
tuple tags
Definition: o2o.py:248
tuple description
Definition: idDealer.py:66
void setColumnData(const Params &params)
Definition: DbCore.h:508
Table(coral::ISchema &schema)
Definition: GTSchema.cc:78
void insert(const std::string &gtName, const std::vector< std::tuple< std::string, std::string, std::string > > &tags)
Definition: GTSchema.cc:106
static char const * tname
Definition: GTSchema.h:40
GLOBAL_TAG_MAP::Table m_gtMapTable
Definition: GTSchema.h:74
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)
Definition: GTSchema.cc:66
bool select(const std::string &gtName, std::vector< std::tuple< std::string, std::string, std::string > > &tags)
Definition: GTSchema.cc:86
Table(coral::ISchema &schema)
Definition: GTSchema.cc:8
void addWhereCondition(const P &param, const std::string condition="=")
Definition: DbCore.h:517