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 174 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 82 of file OMSAccess.cc.

References m_url.

82  {
83  m_url = baseUrl + "/" + function;
84  }
std::string m_url
Definition: OMSAccess.h:256

Member Function Documentation

◆ addOutputVar()

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

Definition at line 86 of file OMSAccess.cc.

References addVar().

86  {
87  addVar(varName);
88  return *this;
89  }
void addVar(const std::string &varName)
Definition: OMSAccess.cc:71

◆ addOutputVars()

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

Definition at line 90 of file OMSAccess.cc.

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

90  {
91  for (auto v : varNames)
92  addVar(v);
93  return *this;
94  }
constexpr char const * varNames[]
void addVar(const std::string &varName)
Definition: OMSAccess.cc:71

◆ addVar()

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

Definition at line 71 of file OMSAccess.cc.

References m_varList.

Referenced by addOutputVar(), and addOutputVars().

71  {
72  std::stringstream varList;
73  if (m_varList.empty()) {
74  varList << "&fields=";
75  } else {
76  varList << m_varList << ",";
77  }
78  varList << varName;
79  m_varList = varList.str();
80  }
std::string m_varList
Definition: OMSAccess.h:259

◆ execute()

bool cond::OMSServiceQuery::execute ( )

Definition at line 108 of file OMSAccess.cc.

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

108  {
109  bool ret = false;
112  if (m_status == 200 || m_status == 201) {
113  m_result = std::make_unique<OMSServiceResult>();
114  m_result->parseData(out);
115  ret = true;
116  }
117  return ret;
118  }
ret
prodAgent to be discontinued
unsigned long m_status
Definition: OMSAccess.h:261
std::string url()
Definition: OMSAccess.cc:124
unsigned long httpGet(const std::string &urlString, std::string &info)
Definition: WebUtils.cc:16
std::unique_ptr< OMSServiceResult > m_result
Definition: OMSAccess.h:260

◆ filter()

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

Definition at line 195 of file OMSAccess.h.

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

195  {
196  std::stringstream filter;
197  if (m_filter.empty()) {
198  filter << "?";
199  if (!m_limit.empty()) {
200  m_limit.front() = '&';
201  }
202  } else {
203  filter << m_filter << "&";
204  }
205  filter << "filter[" << varName << "][" << cmp << "]=" << impl::to_string(value);
206  m_filter = filter.str();
207  return *this;
208  }
std::string m_filter
Definition: OMSAccess.h:257
OMSServiceQuery & filter(const char *cmp, const std::string &varName, const T &value)
Definition: OMSAccess.h:195
std::string to_string(const V &value)
Definition: OMSAccess.h:77
Definition: value.py:1
std::string m_limit
Definition: OMSAccess.h:258

◆ filterEQ()

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

Definition at line 211 of file OMSAccess.h.

References EQ, and relativeConstraints::value.

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

◆ filterGE()

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

Definition at line 223 of file OMSAccess.h.

References GE, and relativeConstraints::value.

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

◆ filterGT()

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

Definition at line 219 of file OMSAccess.h.

References GT, and relativeConstraints::value.

219  {
220  return filter<T>(GT, varName, value);
221  }
static constexpr const char *const GT
Definition: OMSAccess.h:181

◆ filterLE()

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

Definition at line 231 of file OMSAccess.h.

References LE, and relativeConstraints::value.

231  {
232  return filter<T>(LE, varName, value);
233  }
static constexpr const char *const LE
Definition: OMSAccess.h:180

◆ filterLT()

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

Definition at line 227 of file OMSAccess.h.

References LT, and relativeConstraints::value.

227  {
228  return filter<T>(LT, varName, value);
229  }
static constexpr const char *const LT
Definition: OMSAccess.h:179

◆ filterNEQ()

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

Definition at line 215 of file OMSAccess.h.

References NEQ, and relativeConstraints::value.

Referenced by filterNotNull().

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

◆ filterNotNull()

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

Definition at line 235 of file OMSAccess.h.

References filterNEQ(), and SNULL.

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

◆ limit()

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

Definition at line 96 of file OMSAccess.cc.

References m_filter, m_limit, and relativeConstraints::value.

96  {
97  std::stringstream pageLimit;
98  if (m_filter.empty()) {
99  pageLimit << "?";
100  } else {
101  pageLimit << "&";
102  }
103  pageLimit << "page[limit]=" << value;
104  m_limit = pageLimit.str();
105  return *this;
106  }
std::string m_filter
Definition: OMSAccess.h:257
std::string m_limit
Definition: OMSAccess.h:258

◆ result()

OMSServiceResult & cond::OMSServiceQuery::result ( )

Definition at line 122 of file OMSAccess.cc.

References m_result.

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

◆ status()

unsigned long cond::OMSServiceQuery::status ( )

Definition at line 120 of file OMSAccess.cc.

References m_status.

120 { return m_status; }
unsigned long m_status
Definition: OMSAccess.h:261

◆ url()

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

Definition at line 124 of file OMSAccess.cc.

References m_filter, m_limit, m_url, and m_varList.

Referenced by execute().

124 { return m_url + m_filter + m_limit + m_varList; }
std::string m_url
Definition: OMSAccess.h:256
std::string m_filter
Definition: OMSAccess.h:257
std::string m_limit
Definition: OMSAccess.h:258
std::string m_varList
Definition: OMSAccess.h:259

Member Data Documentation

◆ EQ

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

Definition at line 178 of file OMSAccess.h.

Referenced by filterEQ().

◆ GE

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

Definition at line 182 of file OMSAccess.h.

Referenced by filterGE().

◆ GT

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

Definition at line 181 of file OMSAccess.h.

Referenced by filterGT().

◆ LE

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

Definition at line 180 of file OMSAccess.h.

Referenced by filterLE().

◆ LT

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

Definition at line 179 of file OMSAccess.h.

Referenced by filterLT().

◆ m_filter

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

Definition at line 257 of file OMSAccess.h.

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

◆ m_limit

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

Definition at line 258 of file OMSAccess.h.

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

◆ m_result

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

Definition at line 260 of file OMSAccess.h.

Referenced by execute(), and result().

◆ m_status

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

Definition at line 261 of file OMSAccess.h.

Referenced by execute(), and status().

◆ m_url

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

Definition at line 256 of file OMSAccess.h.

Referenced by OMSServiceQuery(), and url().

◆ m_varList

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

Definition at line 259 of file OMSAccess.h.

Referenced by addVar(), and url().

◆ NEQ

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

Definition at line 177 of file OMSAccess.h.

Referenced by filterNEQ().

◆ SNULL

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

Definition at line 183 of file OMSAccess.h.

Referenced by filterNotNull().