Qore ServiceNowRestDataProvider Module Reference 1.2
Loading...
Searching...
No Matches
ServiceNowTableDataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
30 hash<string, AbstractDataField> record_type;
31
32 #! The original field type names
33 hash<string, string> field_types;
34
35 #! Hash of date/time fields for this record
36 hash<string, bool> date_time_fields;
37
38 #! Hash of boolean fields for this record
39 hash<string, bool> bool_fields;
40
41 #! Hash of integer fields for this record
42 hash<string, bool> int_fields;
43}
44
47
48public:
51
53 string name;
54
56 hash<auto> access;
57
59 hash<auto> meta;
60
62 const SysColumns = {
63 "sys_created_by": {
64 "internal_type": {
65 "value": "string",
66 }
67 },
68 "sys_created_on": {
69 "internal_type": {
70 "value": "glide_date_time",
71 }
72 },
73 "sys_updated_by": {
74 "internal_type": {
75 "value": "string",
76 }
77 },
78 "sys_updated_on": {
79 "internal_type": {
80 "value": "glide_date_time",
81 }
82 },
83 };
84
86 const Expressions = {
87 DP_OP_AND: {
88 "exp": AbstractDataProvider::GenericExpressions{DP_OP_AND},
89 "impl": string sub (string cn, auto arg) {
90 throw "WHERE-ERROR", "ServiceNow does not support nested boolean logic in queries";
91 },
92 },
94 "exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_EQ}, QUERY_OP_EQ),
95 "impl": string sub (string cn, auto arg) {
96 return sprintf("%s=%s", cn, arg);
97 },
98 },
100 "exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NE}, QUERY_OP_NE),
101 "impl": string sub (string cn, auto arg) {
102 return sprintf("%s!=%s", cn, arg);
103 },
104 },
105 QUERY_OP_LT: {
106 "exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LT}, QUERY_OP_LT),
107 "impl": string sub (string cn, auto arg) {
108 return sprintf("%s<%s", cn, arg);
109 },
110 },
111 QUERY_OP_LE: {
112 "exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LE}, QUERY_OP_LE),
113 "impl": string sub (string cn, auto arg) {
114 return sprintf("%s<=%s", cn, arg);
115 },
116 },
117 QUERY_OP_GT: {
118 "exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GT}, QUERY_OP_GT),
119 "impl": string sub (string cn, auto arg) {
120 return sprintf("%s>%s", cn, arg);
121 },
122 },
123 QUERY_OP_GE: {
124 "exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GE}, QUERY_OP_GE),
125 "impl": string sub (string cn, auto arg) {
126 return sprintf("%s>=%s", cn, arg);
127 },
128 },
129 QUERY_OP_IN: {
130 "exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_IN}, QUERY_OP_IN),
131 "impl": string sub (string cn, auto arg) {
132 return sprintf("%sIN%s", cn, (foldl $1 + "," + $2, arg));
133 },
134 },
136 "exp": <DataProviderExpressionInfo>{
137 "type": DET_Operator,
138 "label": QUERY_OP_NOTIN,
139 "name": "notin",
140 "desc": "An expression with the ServiceNow 'notin' operator",
141 "symbol": "NOTIN",
142 "args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
143 "return_type": AbstractDataProviderTypeMap."bool",
144 },
145 "impl": string sub (string cn, auto arg) {
146 return sprintf("%sNOTIN%s", cn, (foldl $1 + "," + $2, arg));
147 },
148 },
150 "exp": <DataProviderExpressionInfo>{
151 "type": DET_Operator,
152 "label": QUERY_OP_LIKE,
153 "name": "like",
154 "desc": "An expression with the ServiceNow 'like' operator",
155 "symbol": "LIKE",
156 "args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
157 "return_type": AbstractDataProviderTypeMap."bool",
158 },
159 "impl": string sub (string cn, auto arg) {
160 return sprintf("%sLIKE%s", cn, arg);
161 },
162 },
164 "exp": <DataProviderExpressionInfo>{
165 "type": DET_Operator,
166 "label": QUERY_OP_NOTLIKE,
167 "name": "notlike",
168 "desc": "An expression with the ServiceNow 'notlike' operator",
169 "symbol": "NOTLIKE",
170 "args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
171 "return_type": AbstractDataProviderTypeMap."bool",
172 },
173 "impl": string sub (string cn, auto arg) {
174 return sprintf("%sNOTLIKE%s", cn, arg);
175 },
176 },
178 "exp": <DataProviderExpressionInfo>{
179 "type": DET_Operator,
180 "label": QUERY_OP_STARTSWITH,
181 "name": "like",
182 "desc": "An expression with the ServiceNow 'startswith' operator",
183 "symbol": "STARTSWITH",
184 "args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
185 "return_type": AbstractDataProviderTypeMap."bool",
186 },
187 "impl": string sub (string cn, auto arg) {
188 return sprintf("%sSTARTSWITH%s", cn, arg);
189 },
190 },
192 "exp": <DataProviderExpressionInfo>{
193 "type": DET_Operator,
194 "label": QUERY_OP_ENDSWITH,
195 "name": "like",
196 "desc": "An expression with the ServiceNow 'endswith' operator",
197 "symbol": "ENDSWITH",
198 "args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
199 "return_type": AbstractDataProviderTypeMap."bool",
200 },
201 "impl": string sub (string cn, auto arg) {
202 return sprintf("%sISEMPTY", cn);
203 },
204 },
206 "exp": <DataProviderExpressionInfo>{
207 "type": DET_Operator,
208 "label": QUERY_OP_ISNOTEMPTY,
209 "name": "notlike",
210 "desc": "An expression with the ServiceNow 'isnotempty' operator",
211 "symbol": "ISNOTEMPTY",
212 "args": (DataProviderSignatureFieldType,),
213 "return_type": AbstractDataProviderTypeMap."bool",
214 },
215 "impl": string sub (string cn, auto arg) {
216 return sprintf("%sISNOTEMPTY", cn);
217 },
218 },
219 };
220
221protected:
223 hash<ServiceNowRestRecordInfo> record_info();
224
226 string uri_path = "table/";
227
228public:
229
231 constructor(ServiceNowRestClient rest, string name, hash<auto> access, hash<auto> meta);
232
233
235 string getName();
236
237
239 string getDesc();
240
241
242protected:
243 *hash<string, DataProvider::AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
244public:
245
246
248
254 *hash<auto> search_options) {
255 return new ServiceNowRestRecordIterator(rest, name, record_info, where_cond, search_options);
256 }
257
259protected:
260 hash<DataProvider::DataProviderInfo> getStaticInfoImpl();
261public:
262
263
265
273protected:
274 *hash<auto> createRecordImpl(hash<auto> rec, *hash<auto> create_options);
275public:
276
277
279
285 private int updateRecordsImpl(hash<auto> set, hash<DataProviderExpression> where_cond,
286 *hash<auto> search_options) {
287 /*
288 if (where_cond.sys_id && where_cond.size() == 1) {
289 updateSingleRecord(where_cond.sys_id, set);
290 return 1;
291 }
292 */
293
294 AbstractDataProviderRecordIterator i = searchRecords(where_cond, search_options + {"columns": "sys_id"});
295 int count = 0;
296 map (updateSingleRecord(i.getValue().sys_id, set), ++count), i;
297 return count;
298 }
299
301
307protected:
308 int deleteRecordsImpl(*hash<DataProviderExpression> where_cond, *hash<auto> search_options);
309public:
310
311
313protected:
314 updateSingleRecord(string id, hash<auto> set);
315public:
316
317
319protected:
321public:
322
323
325protected:
327public:
328
329
331 private hash<DataProviderExpression> getEqualityComparisonExpression(int role, hash<DataProviderInfo> info, string key,
332 auto value) {
333 return <DataProviderExpression>{
334 "exp": info.expressions.eq,
335 "args": (<DataProviderFieldReference>{"field": key},) + value,
336 };
337 }
338};
339};
340
341namespace Priv {
342hash<DataProviderExpressionInfo> sym(hash<DataProviderExpressionInfo> exp, string label);
343
344};
AbstractDataProviderRecordIterator searchRecords(*hash< auto > where_cond, *hash< auto > search_options)
Defines the record iterator class for Table-based iterators.
Definition: ServiceNowRestRecordIterator.qc.dox.h:28
The ServiceNowTableDataProvider data provider class.
Definition: ServiceNowTableDataProvider.qc.dox.h:46
const SysColumns
System columns.
Definition: ServiceNowTableDataProvider.qc.dox.h:62
*hash< auto > createRecordImpl(hash< auto > rec, *hash< auto > create_options)
Creates the given record to the data provider.
hash< auto > meta
Metadata description.
Definition: ServiceNowTableDataProvider.qc.dox.h:59
hash< auto > access
Access description.
Definition: ServiceNowTableDataProvider.qc.dox.h:56
deleteSingleRecord(string id)
deletes a single record
private hash< DataProviderExpression > getEqualityComparisonExpression(int role, hash< DataProviderInfo > info, string key, auto value)
Returns an equality comparison expression.
Definition: ServiceNowTableDataProvider.qc.dox.h:331
updateSingleRecord(string id, hash< auto > set)
updates a single record
string uri_path
URI path prefix.
Definition: ServiceNowTableDataProvider.qc.dox.h:226
constructor(ServiceNowRestClient rest, string name, hash< auto > access, hash< auto > meta)
Creates the object from the arguments.
const Expressions
Supported expressions.
Definition: ServiceNowTableDataProvider.qc.dox.h:86
string name
Current object name.
Definition: ServiceNowTableDataProvider.qc.dox.h:53
hash< ServiceNowRestRecordInfo > record_info()
Record info for the table.
private DataProvider::AbstractDataProviderRecordIterator searchRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
Returns an iterator for zero or more records matching the search options.
Definition: ServiceNowTableDataProvider.qc.dox.h:253
hash< DataProvider::DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
int deleteRecordsImpl(*hash< DataProviderExpression > where_cond, *hash< auto > search_options)
Deletes zero or more records.
string getName()
Returns the data provider name.
ServiceNowRestClient::ServiceNowRestClient rest
The REST client object for API calls.
Definition: ServiceNowTableDataProvider.qc.dox.h:50
private int updateRecordsImpl(hash< auto > set, hash< DataProviderExpression > where_cond, *hash< auto > search_options)
Updates zero or more records matching the search options.
Definition: ServiceNowTableDataProvider.qc.dox.h:285
string getDesc()
Returns the data provider description.
const QUERY_OP_ENDSWITH
ends with operator
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:50
const QUERY_OP_STARTSWITH
starts with operator
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:55
const QUERY_OP_IN
the Query "IN" operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:100
const QUERY_OP_GE
the Query greater than or equals operator (>=) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:75
const QUERY_OP_NE
the Query not equals operator (!= or <>) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:80
const QUERY_OP_GT
the Query greater than operator (>) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:70
const QUERY_OP_LT
the Query less than (<) operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:60
const QUERY_OP_LIKE
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:40
const QUERY_OP_LE
the Query less than or equals (<=) operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:65
const QUERY_OP_EQ
the Query equals operator (=) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:85
const QUERY_OP_ISNOTEMPTY
the Query "is not empty string" operator (ISNOTEMPTY) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:95
const QUERY_OP_NOTIN
the Query "NOTIN" operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:105
const QUERY_OP_NOTLIKE
not like operator
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:45
Qore ServiceNowRestDataProvider module definition.
Definition: ServiceNowRestDataProvider.qc.dox.h:26
hashdecl ServiceNowRestRecordInfo
contains ServiceNow object record information
Definition: ServiceNowTableDataProvider.qc.dox.h:28