-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcRESTAPISystemObject.pkg
More file actions
150 lines (114 loc) · 4.2 KB
/
cRESTAPISystemObject.pkg
File metadata and controls
150 lines (114 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//==============================================================================
// cRESTApiSystemObject.pkg
// ------------------------
// This is just a cut-down version of the oApiObject for dealing with system
// tables (single record tables). It basically only does Instance and Update.
//------------------------------------------------------------------------------
// Date Author Comments
// ---------- ------ --------------------------------------------------------
// 11/08/2020 MJP Modified in line with refactoring of cRESTAPIObject
// 14/12/2018 MJP Changed class name to cRESTAPISystemObject as per
// Sture's suggestions
// 11/10/2018 MJP Original
//==============================================================================
Use cRESTApiObject.pkg
Class cRESTApiSystemObject is a cRESTApiObject
Function IsSystemFileObject Returns Boolean
Function_Return True
End_Function
Procedure End_Construct_Object
Handle htTable
Boolean bSys
Set psInstName to (psCollName(Self))
Forward Send End_Construct_Object
// Assertion:
Get Main_File of (phoDD(Self)) to htTable
Get_Attribute DF_FILE_IS_SYSTEM_FILE of htTable to bSys
If not bSys Begin
Error 682 ("cRESTApiSystemObject" * ;
Name(Self) + ;
"'s Main_File is not a system table - use cRESTApiObject instead")
End
End_Procedure
// Procedure List
// ==============
// Lists a collection
Procedure List
Send Instance ""
End_Procedure
// Procedure Instance
// ==================
// Returns details of an instance
Procedure Instance String sID
Integer[] aiFields
Handle hoInst hoResp
If (pbAllowFieldSelection(Self)) ;
Get RequestFieldsList to aiFields
If not (SizeOfArray(aiFields)) ;
Get paiDefaultInstanceFields to aiFields
Send Request_Assign of (phoDD(Self))
Get JsonFromDD (phoDD(Self)) aiFields to hoInst
Send ReturnInstance hoInst C_restModeInstance
End_Procedure
// Procedure Create
// ================
// Creates an instance
Procedure Create
// Overridden to do nothing
End_Procedure
// Procedure Update
// ================
// Updates an instance
Procedure Update String sID
Handle hoJson hoResp hoInst hoDD
Integer[] aiFields
Integer iErr
String sErrMsg
If (pbReadOnly(Self)) Begin
Send NotAllowed
Procedure_Return
End
If (pbNoUpdate(Self)) Begin
Send NotAllowed
Procedure_Return
End
Get phoDD to hoDD
Send Request_Assign of hoDD
Get phoRequestJson to hoJson
If (hoJson = -1) ;
Procedure_Return
If not hoJson Begin
Send NoJson
Procedure_Return
End
Send UpdateDDFromJson hoDD hoJson
If (Should_Save(hoDD)) Begin
Get Request_Validate of hoDD to iErr
If iErr Begin
Send UpdateError C_restModeUpdate
Procedure_Return
End
Move (False) to Err
Send Request_Save of hoDD
If (Err) Begin
Send UpdateError C_restModeUpdate
Procedure_Return
End
If (pbAllowFieldSelection(Self)) ;
Get RequestFieldsList to aiFields
If not (SizeOfArray(aiFields)) ;
Get paiDefaultInstanceFields to aiFields
Get JsonFromDD hoDD aiFields to hoInst
Send ReturnInstance hoInst C_restModeUpdate
End
Else Begin
Send NothingToUpdate
End
End_Procedure
// Procedure Delete
// ================
// Deletes an instance
Procedure Delete String sID
// Overridden to do nothing
End_Procedure
End_Class