Qore CdsRestDataProvider Module Reference  1.0.0
CdsRestRecordIterator.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
26 namespace CdsRestDataProvider {
28 class CdsRestRecordIterator : public AbstractDataProviderRecordIterator {
29 
30 public:
31 
32 private:
34  CdsRestClient::CdsRestClient rest;
35 
37  string name;
38 
40  hash<CdsRestRecordInfo> record_info;
41 
44 
45 public:
46 
48 
54  constructor(CdsRestClient::CdsRestClient rest, string name, hash<CdsRestRecordInfo> record_info,
55  *hash<auto> where_cond, *hash<auto> search_options) {
56  self.rest = rest;
57  self.name = name;
58  self.record_info = record_info;
59 
60  // make query
61  __7_ string query = makeQuery(where_cond, search_options);
62  hash<auto> info;
63  try {
64  string uri = name + "s";
65  if (query) {
66  uri += sprintf("?%s", query);
67  }
68  i = new ListHashIterator(rest.get(uri, NOTHING, \info).body.value);
69  } catch (hash<ExceptionInfo> ex) {
70  // ensure that any error response body is included in the exception
71  hash<auto> ex_arg = {
72  "query": query,
73  } + info{"response-code", "response-body"};
74  throw ex.err, ex.desc, ex_arg;
75  }
76  }
77 
79 
82  bool valid();
83 
84 
86 
92  bool next();
93 
94 
96 
98  hash<auto> getValue();
99 
100 
102 
108  auto memberGate(string key);
109 
110 
112  string getOrClause(list<auto> arglist);
113 
114 
116  __7_ string makeQuery(__7_ hash<auto> where_cond, __7_ hash<auto> search_options);
117 
118 
120 
122  __7_ hash<string, DataProvider::AbstractDataField> getRecordType();
123 
124 
125  string getArgValue(string key, auto value);
126 
127 
128 protected:
129  string getOrderBy(softlist<string> coll);
130 public:
131 
132 
133 protected:
134  bool checkColumnName(string col);
135 public:
136 
137 
138 protected:
139  string getColumnNames(__7_ softlist<auto> column_names);
140 public:
141 
142 
143 protected:
144  string doWhereExpression(hash<auto> where_cond, __7_ hash<auto> search_options);
145 public:
146 
147 
148 protected:
149  string doWhereExpressionIntern(string key, auto value);
150 public:
151 
152 };
153 };
Defines the record iterator class for Table-based iterators.
Definition: CdsRestRecordIterator.qc.dox.h:28
hash< auto > getValue()
Returns a single record if the iterator is valid.
__7_ string makeQuery(__7_ hash< auto > where_cond, __7_ hash< auto > search_options)
Returns the filter for a request.
string name
current object name
Definition: CdsRestRecordIterator.qc.dox.h:37
__7_ hash< string, DataProvider::AbstractDataField > getRecordType()
Returns the record description, if available.
Qore::ListHashIterator i
record iterator
Definition: CdsRestRecordIterator.qc.dox.h:43
string getOrClause(list< auto > arglist)
Returns "or" clauses.
auto memberGate(string key)
Returns the value of the given field in the current row, if the iterator is valid.
CdsRestClient::CdsRestClient rest
The REST client object for API calls.
Definition: CdsRestRecordIterator.qc.dox.h:34
bool next()
Increments the row pointer when retrieving rows from a select statement; returns True if there is a r...
bool valid()
Returns True if the iterator is valid.
hash< CdsRestRecordInfo > record_info
Record info for the entity.
Definition: CdsRestRecordIterator.qc.dox.h:40
constructor(CdsRestClient::CdsRestClient rest, string name, hash< CdsRestRecordInfo > record_info, *hash< auto > where_cond, *hash< auto > search_options)
creates the iterator
Definition: CdsRestRecordIterator.qc.dox.h:54
const NOTHING
string sprintf(string fmt,...)
Qore CdsRestDataProvider module definition.
Definition: CdsEntityDataProvider.qc.dox.h:26