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 >
OMSServiceQueryfilterGE (const std::string &varName, const T &value)
 
template<typename T >
OMSServiceQueryfilterGT (const std::string &varName, const T &value)
 
template<typename T >
OMSServiceQueryfilterLE (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)
 
OMSServiceQuerylimit (int value)
 
 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 GE = "GE"
 
static constexpr const char *const GT = "GT"
 
static constexpr const char *const LE = "LE"
 
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::string m_limit
 
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:247

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:250

◆ execute()

bool cond::OMSServiceQuery::execute ( )

Definition at line 98 of file OMSAccess.cc.

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

98  {
99  bool ret = false;
102  if (m_status == 200 || m_status == 201) {
103  m_result = std::make_unique<OMSServiceResult>();
104  m_result->parseData(out);
105  ret = true;
106  }
107  return ret;
108  }
ret
prodAgent to be discontinued
unsigned long m_status
Definition: OMSAccess.h:252
std::string url()
Definition: OMSAccess.cc:114
unsigned long httpGet(const std::string &urlString, std::string &info)
Definition: WebUtils.cc:16
std::unique_ptr< OMSServiceResult > m_result
Definition: OMSAccess.h:251

◆ filter()

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

Definition at line 186 of file OMSAccess.h.

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

186  {
187  std::stringstream filter;
188  if (m_filter.empty()) {
189  filter << "?";
190  if (!m_limit.empty()) {
191  m_limit.front() = '&';
192  }
193  } else {
194  filter << m_filter << "&";
195  }
196  filter << "filter[" << varName << "][" << cmp << "]=" << impl::to_string(value);
197  m_filter = filter.str();
198  return *this;
199  }
std::string m_filter
Definition: OMSAccess.h:248
OMSServiceQuery & filter(const char *cmp, const std::string &varName, const T &value)
Definition: OMSAccess.h:186
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Definition: value.py:1
std::string m_limit
Definition: OMSAccess.h:249

◆ filterEQ()

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

Definition at line 202 of file OMSAccess.h.

References EQ, and relativeConstraints::value.

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

◆ filterGE()

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

Definition at line 214 of file OMSAccess.h.

References GE, and relativeConstraints::value.

214  {
215  return filter<T>(GE, varName, value);
216  }
static constexpr const char *const GE
Definition: OMSAccess.h:173

◆ filterGT()

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

Definition at line 210 of file OMSAccess.h.

References GT, and relativeConstraints::value.

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

◆ filterLE()

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

Definition at line 222 of file OMSAccess.h.

References LE, and relativeConstraints::value.

222  {
223  return filter<T>(LE, varName, value);
224  }
static constexpr const char *const LE
Definition: OMSAccess.h:171

◆ filterLT()

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

Definition at line 218 of file OMSAccess.h.

References LT, and relativeConstraints::value.

218  {
219  return filter<T>(LT, varName, value);
220  }
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 206 of file OMSAccess.h.

References NEQ, and relativeConstraints::value.

Referenced by filterNotNull().

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

◆ filterNotNull()

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

Definition at line 226 of file OMSAccess.h.

References filterNEQ(), and SNULL.

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

◆ limit()

OMSServiceQuery & cond::OMSServiceQuery::limit ( int  value)

Definition at line 86 of file OMSAccess.cc.

References m_filter, m_limit, and relativeConstraints::value.

86  {
87  std::stringstream pageLimit;
88  if (m_filter.empty()) {
89  pageLimit << "?";
90  } else {
91  pageLimit << "&";
92  }
93  pageLimit << "page[limit]=" << value;
94  m_limit = pageLimit.str();
95  return *this;
96  }
std::string m_filter
Definition: OMSAccess.h:248
std::string m_limit
Definition: OMSAccess.h:249

◆ result()

OMSServiceResult & cond::OMSServiceQuery::result ( )

Definition at line 112 of file OMSAccess.cc.

References m_result.

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

◆ status()

unsigned long cond::OMSServiceQuery::status ( )

Definition at line 110 of file OMSAccess.cc.

References m_status.

110 { return m_status; }
unsigned long m_status
Definition: OMSAccess.h:252

◆ url()

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

Definition at line 114 of file OMSAccess.cc.

References m_filter, m_limit, m_url, and m_varList.

Referenced by execute().

114 { return m_url + m_filter + m_limit + m_varList; }
std::string m_url
Definition: OMSAccess.h:247
std::string m_filter
Definition: OMSAccess.h:248
std::string m_limit
Definition: OMSAccess.h:249
std::string m_varList
Definition: OMSAccess.h:250

Member Data Documentation

◆ EQ

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

Definition at line 169 of file OMSAccess.h.

Referenced by filterEQ().

◆ GE

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

Definition at line 173 of file OMSAccess.h.

Referenced by filterGE().

◆ GT

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

Definition at line 172 of file OMSAccess.h.

Referenced by filterGT().

◆ LE

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

Definition at line 171 of file OMSAccess.h.

Referenced by filterLE().

◆ 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 248 of file OMSAccess.h.

Referenced by filter(), limit(), and url().

◆ m_limit

std::string cond::OMSServiceQuery::m_limit
private

Definition at line 249 of file OMSAccess.h.

Referenced by filter(), limit(), and url().

◆ m_result

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

Definition at line 251 of file OMSAccess.h.

Referenced by execute(), and result().

◆ m_status

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

Definition at line 252 of file OMSAccess.h.

Referenced by execute(), and status().

◆ m_url

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

Definition at line 247 of file OMSAccess.h.

Referenced by OMSServiceQuery(), and url().

◆ m_varList

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

Definition at line 250 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 174 of file OMSAccess.h.

Referenced by filterNotNull().