CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
cond::OMSServiceQuery Class Reference

#include <OMSAccess.h>

Public Member Functions

OMSServiceQueryaddOutputVar (const std::string &varName)
 
OMSServiceQueryaddOutputVars (const std::initializer_list< const char *> &varNames)
 
bool execute ()
 
template<typename T >
OMSServiceQueryfilter (const char *cmp, const std::string &varName, const T &value)
 
template<typename T >
OMSServiceQueryfilterEQ (const std::string &varName, const T &value)
 
template<typename T >
OMSServiceQueryfilterGT (const std::string &varName, const T &value)
 
template<typename T >
OMSServiceQueryfilterLT (const std::string &varName, const T &value)
 
template<typename T >
OMSServiceQueryfilterNEQ (const std::string &varName, const T &value)
 
OMSServiceQueryfilterNotNull (const std::string &varName)
 
 OMSServiceQuery ()=delete
 
 OMSServiceQuery (const std::string &baseUrl, const std::string &function)
 
OMSServiceResultresult ()
 
unsigned long status ()
 
std::string url ()
 

Static Public Attributes

static constexpr const char *const EQ = "EQ"
 
static constexpr const char *const GT = "GT"
 
static constexpr const char *const LT = "LT"
 
static constexpr const char *const NEQ = "NEQ"
 
static constexpr const char *const SNULL = "null"
 

Private Member Functions

void addVar (const std::string &varName)
 

Private Attributes

std::string m_filter
 
std::unique_ptr< OMSServiceResultm_result
 
unsigned long m_status = 0
 
std::string m_url
 
std::string m_varList
 

Detailed Description

Definition at line 165 of file OMSAccess.h.

Constructor & Destructor Documentation

◆ OMSServiceQuery() [1/2]

cond::OMSServiceQuery::OMSServiceQuery ( )
delete

◆ OMSServiceQuery() [2/2]

cond::OMSServiceQuery::OMSServiceQuery ( const std::string &  baseUrl,
const std::string &  function 
)

Definition at line 72 of file OMSAccess.cc.

References m_url.

72  {
73  m_url = baseUrl + "/" + function;
74  }
std::string m_url
Definition: OMSAccess.h:231

Member Function Documentation

◆ addOutputVar()

OMSServiceQuery & cond::OMSServiceQuery::addOutputVar ( const std::string &  varName)

Definition at line 76 of file OMSAccess.cc.

References addVar().

76  {
77  addVar(varName);
78  return *this;
79  }
void addVar(const std::string &varName)
Definition: OMSAccess.cc:61

◆ addOutputVars()

OMSServiceQuery & cond::OMSServiceQuery::addOutputVars ( const std::initializer_list< const char *> &  varNames)

Definition at line 80 of file OMSAccess.cc.

References addVar(), findQualityFiles::v, and varNames.

80  {
81  for (auto v : varNames)
82  addVar(v);
83  return *this;
84  }
constexpr char const * varNames[]
void addVar(const std::string &varName)
Definition: OMSAccess.cc:61

◆ addVar()

void cond::OMSServiceQuery::addVar ( const std::string &  varName)
private

Definition at line 61 of file OMSAccess.cc.

References m_varList.

Referenced by addOutputVar(), and addOutputVars().

61  {
62  std::stringstream varList;
63  if (m_varList.empty()) {
64  varList << "&fields=";
65  } else {
66  varList << m_varList << ",";
67  }
68  varList << varName;
69  m_varList = varList.str();
70  }
std::string m_varList
Definition: OMSAccess.h:233

◆ execute()

bool cond::OMSServiceQuery::execute ( )

Definition at line 86 of file OMSAccess.cc.

References cond::httpGet(), m_result, m_status, MillePedeFileConverter_cfg::out, runTheMatrix::ret, AlCaHLTBitMon_QueryRunRegistry::string, and url().

86  {
87  bool ret = false;
90  if (m_status == 200 || m_status == 201) {
91  m_result = std::make_unique<OMSServiceResult>();
92  m_result->parseData(out);
93  ret = true;
94  }
95  return ret;
96  }
ret
prodAgent to be discontinued
unsigned long m_status
Definition: OMSAccess.h:235
std::string url()
Definition: OMSAccess.cc:102
unsigned long httpGet(const std::string &urlString, std::string &info)
Definition: WebUtils.cc:16
std::unique_ptr< OMSServiceResult > m_result
Definition: OMSAccess.h:234

◆ filter()

template<typename T >
OMSServiceQuery& cond::OMSServiceQuery::filter ( const char *  cmp,
const std::string &  varName,
const T value 
)
inline

Definition at line 184 of file OMSAccess.h.

References fileCollector::cmp, m_filter, and cond::impl::to_string().

184  {
185  std::stringstream filter;
186  if (m_filter.empty()) {
187  filter << "?";
188  } else {
189  filter << m_filter << "&";
190  }
191  filter << "filter[" << varName << "][" << cmp << "]=" << impl::to_string(value);
192  m_filter = filter.str();
193  return *this;
194  }
std::string m_filter
Definition: OMSAccess.h:232
OMSServiceQuery & filter(const char *cmp, const std::string &varName, const T &value)
Definition: OMSAccess.h:184
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Definition: value.py:1

◆ filterEQ()

template<typename T >
OMSServiceQuery& cond::OMSServiceQuery::filterEQ ( const std::string &  varName,
const T value 
)
inline

Definition at line 197 of file OMSAccess.h.

References EQ, and relativeConstraints::value.

197  {
198  return filter<T>(EQ, varName, value);
199  }
static constexpr const char *const EQ
Definition: OMSAccess.h:169

◆ filterGT()

template<typename T >
OMSServiceQuery& cond::OMSServiceQuery::filterGT ( const std::string &  varName,
const T value 
)
inline

Definition at line 205 of file OMSAccess.h.

References GT, and relativeConstraints::value.

205  {
206  return filter<T>(GT, varName, value);
207  }
static constexpr const char *const GT
Definition: OMSAccess.h:171

◆ filterLT()

template<typename T >
OMSServiceQuery& cond::OMSServiceQuery::filterLT ( const std::string &  varName,
const T value 
)
inline

Definition at line 209 of file OMSAccess.h.

References LT, and relativeConstraints::value.

209  {
210  return filter<T>(LT, varName, value);
211  }
static constexpr const char *const LT
Definition: OMSAccess.h:170

◆ filterNEQ()

template<typename T >
OMSServiceQuery& cond::OMSServiceQuery::filterNEQ ( const std::string &  varName,
const T value 
)
inline

Definition at line 201 of file OMSAccess.h.

References NEQ, and relativeConstraints::value.

Referenced by filterNotNull().

201  {
202  return filter<T>(NEQ, varName, value);
203  }
static constexpr const char *const NEQ
Definition: OMSAccess.h:168

◆ filterNotNull()

OMSServiceQuery& cond::OMSServiceQuery::filterNotNull ( const std::string &  varName)
inline

Definition at line 213 of file OMSAccess.h.

References filterNEQ(), and SNULL.

213 { return filterNEQ(varName, SNULL); }
OMSServiceQuery & filterNEQ(const std::string &varName, const T &value)
Definition: OMSAccess.h:201
static constexpr const char *const SNULL
Definition: OMSAccess.h:172

◆ result()

OMSServiceResult & cond::OMSServiceQuery::result ( )

Definition at line 100 of file OMSAccess.cc.

References m_result.

100 { return *m_result; }
std::unique_ptr< OMSServiceResult > m_result
Definition: OMSAccess.h:234

◆ status()

unsigned long cond::OMSServiceQuery::status ( )

Definition at line 98 of file OMSAccess.cc.

References m_status.

98 { return m_status; }
unsigned long m_status
Definition: OMSAccess.h:235

◆ url()

std::string cond::OMSServiceQuery::url ( )

Definition at line 102 of file OMSAccess.cc.

References m_filter, m_url, and m_varList.

Referenced by execute().

102 { return m_url + m_filter + m_varList; }
std::string m_url
Definition: OMSAccess.h:231
std::string m_filter
Definition: OMSAccess.h:232
std::string m_varList
Definition: OMSAccess.h:233

Member Data Documentation

◆ EQ

constexpr const char* const cond::OMSServiceQuery::EQ = "EQ"
static

Definition at line 169 of file OMSAccess.h.

Referenced by filterEQ().

◆ GT

constexpr const char* const cond::OMSServiceQuery::GT = "GT"
static

Definition at line 171 of file OMSAccess.h.

Referenced by filterGT().

◆ LT

constexpr const char* const cond::OMSServiceQuery::LT = "LT"
static

Definition at line 170 of file OMSAccess.h.

Referenced by filterLT().

◆ m_filter

std::string cond::OMSServiceQuery::m_filter
private

Definition at line 232 of file OMSAccess.h.

Referenced by filter(), and url().

◆ m_result

std::unique_ptr<OMSServiceResult> cond::OMSServiceQuery::m_result
private

Definition at line 234 of file OMSAccess.h.

Referenced by execute(), and result().

◆ m_status

unsigned long cond::OMSServiceQuery::m_status = 0
private

Definition at line 235 of file OMSAccess.h.

Referenced by execute(), and status().

◆ m_url

std::string cond::OMSServiceQuery::m_url
private

Definition at line 231 of file OMSAccess.h.

Referenced by OMSServiceQuery(), and url().

◆ m_varList

std::string cond::OMSServiceQuery::m_varList
private

Definition at line 233 of file OMSAccess.h.

Referenced by addVar(), and url().

◆ NEQ

constexpr const char* const cond::OMSServiceQuery::NEQ = "NEQ"
static

Definition at line 168 of file OMSAccess.h.

Referenced by filterNEQ().

◆ SNULL

constexpr const char* const cond::OMSServiceQuery::SNULL = "null"
static

Definition at line 172 of file OMSAccess.h.

Referenced by filterNotNull().