Loading...
Searching...
No Matches
ServiceNowTableDataProvider.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
namespace ServiceNowRestDataProvider {
hashdecl ServiceNowRestRecordInfo {
hash<string, AbstractDataField> record_type;
#! The original field type names
hash<string, string> field_types;
#! Hash of date/time fields for this record
hash<string, bool> date_time_fields;
#! Hash of boolean fields for this record
hash<string, bool> bool_fields;
#! Hash of integer fields for this record
hash<string, bool> int_fields;
}
class ServiceNowTableDataProvider : public DataProvider::AbstractDataProvider {
public:
ServiceNowRestClient::ServiceNowRestClient rest;
string name;
hash<auto> access;
hash<auto> meta;
const SysColumns = {
"sys_created_by": {
"internal_type": {
"value": "string",
}
},
"sys_created_on": {
"internal_type": {
"value": "glide_date_time",
}
},
"sys_updated_by": {
"internal_type": {
"value": "string",
}
},
"sys_updated_on": {
"internal_type": {
"value": "glide_date_time",
}
},
};
const Expressions = {
DP_OP_AND: {
"exp": AbstractDataProvider::GenericExpressions{DP_OP_AND},
"impl": string sub (string cn, auto arg) {
throw "WHERE-ERROR", "ServiceNow does not support nested boolean logic in queries";
},
},
QUERY_OP_EQ: {
"exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_EQ}, QUERY_OP_EQ),
"impl": string sub (string cn, auto arg) {
return sprintf("%s=%s", cn, arg);
},
},
QUERY_OP_NE: {
"exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_NE}, QUERY_OP_NE),
"impl": string sub (string cn, auto arg) {
return sprintf("%s!=%s", cn, arg);
},
},
QUERY_OP_LT: {
"exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LT}, QUERY_OP_LT),
"impl": string sub (string cn, auto arg) {
return sprintf("%s<%s", cn, arg);
},
},
QUERY_OP_LE: {
"exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_LE}, QUERY_OP_LE),
"impl": string sub (string cn, auto arg) {
return sprintf("%s<=%s", cn, arg);
},
},
QUERY_OP_GT: {
"exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GT}, QUERY_OP_GT),
"impl": string sub (string cn, auto arg) {
return sprintf("%s>%s", cn, arg);
},
},
QUERY_OP_GE: {
"exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_GE}, QUERY_OP_GE),
"impl": string sub (string cn, auto arg) {
return sprintf("%s>=%s", cn, arg);
},
},
QUERY_OP_IN: {
"exp": sym(AbstractDataProvider::GenericExpressions{DP_SEARCH_OP_IN}, QUERY_OP_IN),
"impl": string sub (string cn, auto arg) {
return sprintf("%sIN%s", cn, (foldl $1 + "," + $2, arg));
},
},
QUERY_OP_NOTIN: {
"exp": <DataProviderExpressionInfo>{
"type": DET_Operator,
"label": QUERY_OP_NOTIN,
"name": "notin",
"desc": "An expression with the ServiceNow 'notin' operator",
"symbol": "NOTIN",
"args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
"return_type": AbstractDataProviderTypeMap."bool",
},
"impl": string sub (string cn, auto arg) {
return sprintf("%sNOTIN%s", cn, (foldl $1 + "," + $2, arg));
},
},
QUERY_OP_LIKE: {
"exp": <DataProviderExpressionInfo>{
"type": DET_Operator,
"label": QUERY_OP_LIKE,
"name": "like",
"desc": "An expression with the ServiceNow 'like' operator",
"symbol": "LIKE",
"args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
"return_type": AbstractDataProviderTypeMap."bool",
},
"impl": string sub (string cn, auto arg) {
return sprintf("%sLIKE%s", cn, arg);
},
},
QUERY_OP_NOTLIKE: {
"exp": <DataProviderExpressionInfo>{
"type": DET_Operator,
"label": QUERY_OP_NOTLIKE,
"name": "notlike",
"desc": "An expression with the ServiceNow 'notlike' operator",
"symbol": "NOTLIKE",
"args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
"return_type": AbstractDataProviderTypeMap."bool",
},
"impl": string sub (string cn, auto arg) {
return sprintf("%sNOTLIKE%s", cn, arg);
},
},
QUERY_OP_STARTSWITH: {
"exp": <DataProviderExpressionInfo>{
"type": DET_Operator,
"label": QUERY_OP_STARTSWITH,
"name": "like",
"desc": "An expression with the ServiceNow 'startswith' operator",
"symbol": "STARTSWITH",
"args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
"return_type": AbstractDataProviderTypeMap."bool",
},
"impl": string sub (string cn, auto arg) {
return sprintf("%sSTARTSWITH%s", cn, arg);
},
},
QUERY_OP_ENDSWITH: {
"exp": <DataProviderExpressionInfo>{
"type": DET_Operator,
"label": QUERY_OP_ENDSWITH,
"name": "like",
"desc": "An expression with the ServiceNow 'endswith' operator",
"symbol": "ENDSWITH",
"args": (DataProviderSignatureFieldType, DataProviderSignatureStringValueType),
"return_type": AbstractDataProviderTypeMap."bool",
},
"impl": string sub (string cn, auto arg) {
return sprintf("%sISEMPTY", cn);
},
},
QUERY_OP_ISNOTEMPTY: {
"exp": <DataProviderExpressionInfo>{
"type": DET_Operator,
"label": QUERY_OP_ISNOTEMPTY,
"name": "notlike",
"desc": "An expression with the ServiceNow 'isnotempty' operator",
"symbol": "ISNOTEMPTY",
"args": (DataProviderSignatureFieldType,),
"return_type": AbstractDataProviderTypeMap."bool",
},
"impl": string sub (string cn, auto arg) {
return sprintf("%sISNOTEMPTY", cn);
},
},
};
protected:
hash<ServiceNowRestRecordInfo> record_info();
string uri_path = "table/";
public:
constructor(ServiceNowRestClient rest, string name, hash<auto> access, hash<auto> meta);
string getName();
string getDesc();
protected:
*hash<string, DataProvider::AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
public:
private DataProvider::AbstractDataProviderRecordIterator searchRecordsImpl(*hash<auto> where_cond,
*hash<auto> search_options) {
return new ServiceNowRestRecordIterator(rest, name, record_info, where_cond, search_options);
}
protected:
hash<DataProvider::DataProviderInfo> getStaticInfoImpl();
public:
protected:
*hash<auto> createRecordImpl(hash<auto> rec, *hash<auto> create_options);
public:
private int updateRecordsImpl(hash<auto> set, hash<DataProviderExpression> where_cond,
*hash<auto> search_options) {
/*
if (where_cond.sys_id && where_cond.size() == 1) {
updateSingleRecord(where_cond.sys_id, set);
return 1;
}
*/
AbstractDataProviderRecordIterator i = searchRecords(where_cond, search_options + {"columns": "sys_id"});
int count = 0;
map (updateSingleRecord(i.getValue().sys_id, set), ++count), i;
return count;
}
protected:
int deleteRecordsImpl(*hash<DataProviderExpression> where_cond, *hash<auto> search_options);
public:
protected:
updateSingleRecord(string id, hash<auto> set);
public:
protected:
deleteSingleRecord(string id);
public:
protected:
getRecordInfoIntern();
public:
private hash<DataProviderExpression> getEqualityComparisonExpression(int role, hash<DataProviderInfo> info, string key,
auto value) {
return <DataProviderExpression>{
"exp": info.expressions.eq,
"args": (<DataProviderFieldReference>{"field": key},) + value,
};
}
};
};
namespace Priv {
hash<DataProviderExpressionInfo> sym(hash<DataProviderExpressionInfo> exp, string label);
};
ServiceNowRestDataProvider::ServiceNowRestRecordIterator
Defines the record iterator class for Table-based iterators.
Definition: ServiceNowRestRecordIterator.qc.dox.h:28
ServiceNowRestDataProvider::ServiceNowTableDataProvider
The ServiceNowTableDataProvider data provider class.
Definition: ServiceNowTableDataProvider.qc.dox.h:46
ServiceNowRestDataProvider::ServiceNowTableDataProvider::SysColumns
const SysColumns
System columns.
Definition: ServiceNowTableDataProvider.qc.dox.h:62
ServiceNowRestDataProvider::ServiceNowTableDataProvider::getRecordInfoIntern
getRecordInfoIntern()
Retrieves the record type.
ServiceNowRestDataProvider::ServiceNowTableDataProvider::createRecordImpl
*hash< auto > createRecordImpl(hash< auto > rec, *hash< auto > create_options)
Creates the given record to the data provider.
ServiceNowRestDataProvider::ServiceNowTableDataProvider::meta
hash< auto > meta
Metadata description.
Definition: ServiceNowTableDataProvider.qc.dox.h:59
ServiceNowRestDataProvider::ServiceNowTableDataProvider::access
hash< auto > access
Access description.
Definition: ServiceNowTableDataProvider.qc.dox.h:56
ServiceNowRestDataProvider::ServiceNowTableDataProvider::deleteSingleRecord
deleteSingleRecord(string id)
deletes a single record
ServiceNowRestDataProvider::ServiceNowTableDataProvider::getEqualityComparisonExpression
private hash< DataProviderExpression > getEqualityComparisonExpression(int role, hash< DataProviderInfo > info, string key, auto value)
Returns an equality comparison expression.
Definition: ServiceNowTableDataProvider.qc.dox.h:331
ServiceNowRestDataProvider::ServiceNowTableDataProvider::updateSingleRecord
updateSingleRecord(string id, hash< auto > set)
updates a single record
ServiceNowRestDataProvider::ServiceNowTableDataProvider::uri_path
string uri_path
URI path prefix.
Definition: ServiceNowTableDataProvider.qc.dox.h:226
ServiceNowRestDataProvider::ServiceNowTableDataProvider::constructor
constructor(ServiceNowRestClient rest, string name, hash< auto > access, hash< auto > meta)
Creates the object from the arguments.
ServiceNowRestDataProvider::ServiceNowTableDataProvider::Expressions
const Expressions
Supported expressions.
Definition: ServiceNowTableDataProvider.qc.dox.h:86
ServiceNowRestDataProvider::ServiceNowTableDataProvider::name
string name
Current object name.
Definition: ServiceNowTableDataProvider.qc.dox.h:53
ServiceNowRestDataProvider::ServiceNowTableDataProvider::record_info
hash< ServiceNowRestRecordInfo > record_info()
Record info for the table.
ServiceNowRestDataProvider::ServiceNowTableDataProvider::searchRecordsImpl
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
ServiceNowRestDataProvider::ServiceNowTableDataProvider::getStaticInfoImpl
hash< DataProvider::DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
ServiceNowRestDataProvider::ServiceNowTableDataProvider::deleteRecordsImpl
int deleteRecordsImpl(*hash< DataProviderExpression > where_cond, *hash< auto > search_options)
Deletes zero or more records.
ServiceNowRestDataProvider::ServiceNowTableDataProvider::getName
string getName()
Returns the data provider name.
ServiceNowRestDataProvider::ServiceNowTableDataProvider::rest
ServiceNowRestClient::ServiceNowRestClient rest
The REST client object for API calls.
Definition: ServiceNowTableDataProvider.qc.dox.h:50
ServiceNowRestDataProvider::ServiceNowTableDataProvider::updateRecordsImpl
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
ServiceNowRestDataProvider::ServiceNowTableDataProvider::getDesc
string getDesc()
Returns the data provider description.
ServiceNowRestDataProvider::QUERY_OP_ENDSWITH
const QUERY_OP_ENDSWITH
ends with operator
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:50
ServiceNowRestDataProvider::QUERY_OP_STARTSWITH
const QUERY_OP_STARTSWITH
starts with operator
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:55
ServiceNowRestDataProvider::QUERY_OP_IN
const QUERY_OP_IN
the Query "IN" operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:100
ServiceNowRestDataProvider::QUERY_OP_GE
const QUERY_OP_GE
the Query greater than or equals operator (>=) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:75
ServiceNowRestDataProvider::QUERY_OP_NE
const QUERY_OP_NE
the Query not equals operator (!= or <>) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:80
ServiceNowRestDataProvider::QUERY_OP_GT
const QUERY_OP_GT
the Query greater than operator (>) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:70
ServiceNowRestDataProvider::QUERY_OP_LT
const QUERY_OP_LT
the Query less than (<) operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:60
ServiceNowRestDataProvider::QUERY_OP_LIKE
const QUERY_OP_LIKE
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:40
ServiceNowRestDataProvider::QUERY_OP_LE
const QUERY_OP_LE
the Query less than or equals (<=) operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:65
ServiceNowRestDataProvider::QUERY_OP_EQ
const QUERY_OP_EQ
the Query equals operator (=) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:85
ServiceNowRestDataProvider::QUERY_OP_ISNOTEMPTY
const QUERY_OP_ISNOTEMPTY
the Query "is not empty string" operator (ISNOTEMPTY) for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:95
ServiceNowRestDataProvider::QUERY_OP_NOTIN
const QUERY_OP_NOTIN
the Query "NOTIN" operator for use in queries
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:105
ServiceNowRestDataProvider::QUERY_OP_NOTLIKE
const QUERY_OP_NOTLIKE
not like operator
Definition: ServiceNowRestDataProviderDefs.qc.dox.h:45
Priv
ServiceNowRestDataProvider
Qore ServiceNowRestDataProvider module definition.
Definition: ServiceNowRestDataProvider.qc.dox.h:26
ServiceNowRestDataProvider::ServiceNowRestRecordInfo
hashdecl ServiceNowRestRecordInfo
contains ServiceNow object record information
Definition: ServiceNowTableDataProvider.qc.dox.h:28