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 
12  bool GLOBAL_TAG::Table::exists(){
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 
24  bool GLOBAL_TAG::Table::select( const std::string& name,
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 
39  bool GLOBAL_TAG::Table::select( const std::string& name,
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;
49  Query< VALIDITY, DESCRIPTION, RELEASE > q( m_schema );
50  q.addCondition<NAME>( name );
51  for ( auto row : q ) std::tie( validity, description, release ) = row;
52  return q.retrievedRows();
53  }
54 
55  void GLOBAL_TAG::Table::insert( const std::string& name,
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 ){
61  RowBuffer< NAME, VALIDITY, DESCRIPTION, RELEASE, SNAPSHOT_TIME, INSERTION_TIME >
62  dataToInsert( std::tie( name, validity, description, release, snapshotTime, insertionTime ) );
63  insertInTable( m_schema, tname, dataToInsert.get() );
64  }
65 
66  void GLOBAL_TAG::Table::update( const std::string& name,
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 
78  GLOBAL_TAG_MAP::Table::Table( coral::ISchema& schema ):
79  m_schema( schema ){
80  }
81 
82  bool GLOBAL_TAG_MAP::Table::exists(){
83  return existsTable( m_schema, tname );
84  }
85 
86  bool GLOBAL_TAG_MAP::Table::select( const std::string& gtName,
87  std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
88  Query< RECORD, LABEL, TAG_NAME > q( m_schema );
89  q.addCondition< GLOBAL_TAG_NAME >( gtName );
90  q.addOrderClause<RECORD>();
91  q.addOrderClause<LABEL>();
92  for ( auto row : q ) {
93  tags.push_back( row );
94  }
95  return q.retrievedRows();
96  }
97 
98  bool GLOBAL_TAG_MAP::Table::select( const std::string& gtName, const std::string&, const std::string&,
99  std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
100  return select( gtName, tags );
101  }
102 
103  void GLOBAL_TAG_MAP::Table::insert( const std::string& gtName,
104  const std::vector<std::tuple<std::string,std::string,std::string> >& tags ){
105  BulkInserter<GLOBAL_TAG_NAME, RECORD, LABEL, TAG_NAME > inserter( m_schema, tname );
106  for( auto row : tags ) inserter.insert( std::tuple_cat( std::tie( gtName ),row ) );
107  inserter.flush();
108  }
109 
110  GTSchema::GTSchema( coral::ISchema& schema ):
111  m_gtTable( schema ),
112  m_gtMapTable( schema ){
113  }
114 
116  if( !m_gtTable.exists() ) return false;
117  if( !m_gtMapTable.exists() ) return false;
118  return true;
119  }
120 
121  GLOBAL_TAG::Table& GTSchema::gtTable(){
122  return m_gtTable;
123  }
124 
125  GLOBAL_TAG_MAP::Table& GTSchema::gtMapTable(){
126  return m_gtMapTable;
127  }
128 
129  }
130 }
GLOBAL_TAG::Table & gtTable()
Definition: GTSchema.cc:121
GLOBAL_TAG::Table m_gtTable
Definition: GTSchema.h:73
GTSchema(coral::ISchema &schema)
Definition: GTSchema.cc:110
unsigned long long Time_t
Definition: Time.h:16
GLOBAL_TAG_MAP::Table & gtMapTable()
Definition: GTSchema.cc:125
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
tuple tags
Definition: o2o.py:248
tuple description
Definition: idDealer.py:66
#define update(a, b)
GLOBAL_TAG_MAP::Table m_gtMapTable
Definition: GTSchema.h:74