Blame view

list_config.go 15.2 KB
ea858b8a7   Marko Tikvić   refactoring
1
  package webutility
39765a430   Marko Tikvić   added list and se...
2

1d0f61553   Marko Tikvić   can't fetch clob
3
  import "gopkg.in/rana/ora.v4"
39765a430   Marko Tikvić   added list and se...
4
5
6
7
8
9
10
11
12
  
  type ListOptions struct {
  	GlobalFilter  bool   `json:"globalFilter"`
  	LocalFilters  bool   `json:"localFilters"`
  	RemoteFilters bool   `json:"remoteFilters"`
  	Pagination    bool   `json:"pagination"`
  	PageSize      uint64 `json:"pageSize"`
  	Pivot         bool   `json:"pivot"`
  	Detail        bool   `json:"detail"`
812040e29   Marko Tikvić   hmmm
13
  	Total         bool   `json:"total"`
39765a430   Marko Tikvić   added list and se...
14
15
16
  }
  
  type ListFilter struct {
7d3deb50d   Marko Tikvić   modified list_con...
17
  	Position       uint32   `json:"-"`
90f4ed079   Marko Tikvić   sped up loadTable()
18
19
20
21
22
23
24
25
26
27
28
  	ObjectType     string   `json:"-"`
  	FiltersField   string   `json:"filtersField"`
  	DefaultValues  string   `json:"defaultValues"`
  	FiltersType    string   `json:"filtersType"`
  	FiltersLabel   string   `json:"filtersLabel"`
  	DropdownConfig Dropdown `json:"dropdownConfig"`
  }
  
  type Dropdown struct {
  	ObjectType   string `json:"objectType"`
  	FiltersField string `json:"filtersField"`
e1fbb41f9   Marko Tikvić   added comments
29
  	IDField      string `json:"idField"`
90f4ed079   Marko Tikvić   sped up loadTable()
30
  	LabelField   string `json:"labelField"`
39765a430   Marko Tikvić   added list and se...
31
32
33
34
  }
  
  type ListGraph struct {
  	ObjectType string `json:"objectType"`
d66628295   Marko Tikvić   cleaned up
35
36
  	X          string `json:"xField"`
  	Y          string `json:"yField"`
39765a430   Marko Tikvić   added list and se...
37
  	GroupField string `json:"groupField"`
d66628295   Marko Tikvić   cleaned up
38
  	Label      string `json:"label"`
39765a430   Marko Tikvić   added list and se...
39
40
41
42
43
44
45
46
47
48
  }
  
  type ListActions struct {
  	Create bool `json:"create"`
  	Update bool `json:"update"`
  	Delete bool `json:"delete"`
  	Export bool `json:"export"`
  	Print  bool `json:"print"`
  	Graph  bool `json:"graph"`
  }
7d3deb50d   Marko Tikvić   modified list_con...
49
  type ListNavNode struct {
f1f300b13   Marko Tikvić   Added nav node field
50
51
52
53
54
55
  	ObjectType        string `json:"objectType"`
  	LabelField        string `json:"label"`
  	Icon              string `json:"icon"`
  	ParentObjectType  string `json:"parentObjectType"`
  	ParentIDField     string `json:"parentIdField"`
  	ParentFilterField string `json:"parentFilterField"`
39765a430   Marko Tikvić   added list and se...
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
  }
  
  type ListParentNode struct {
  	ObjectType  string `json:"objectType"`
  	LabelField  string `json:"labelField"`
  	FilterField string `json:"filterField"`
  }
  
  type ListPivot struct {
  	ObjectType    string `json:"objectType"`
  	GroupField    string `json:"groupField"`
  	DistinctField string `json:"distinctField"`
  	Value         string `json:"valueField"`
  }
  
  type ListDetails struct {
  	ObjectType        string `json:"objectType"`
  	ParentObjectType  string `json:"parentObjectType"`
  	ParentFilterField string `json:"parentFilterField"`
  	SingleDetail      bool   `json:"singleDetail"`
  }
  
  type ListConfig struct {
  	ObjectType string           `json:"objectType"`
  	Title      string           `json:"title"`
  	LazyLoad   bool             `json:"lazyLoad"`
  	InlineEdit bool             `json:"inlineEdit"`
  	Options    ListOptions      `json:"options"`
  	Filters    []ListFilter     `json:"defaultFilters"`
  	Graphs     []ListGraph      `json:"graphs"`
  	Actions    ListActions      `json:"actions"`
  	Parent     []ListParentNode `json:"parent"`
7d3deb50d   Marko Tikvić   modified list_con...
88
  	Navigation []ListNavNode    `json:"navigation"`
39765a430   Marko Tikvić   added list and se...
89
90
91
  	Pivots     []ListPivot      `json:"pivots"`
  	Details    ListDetails      `json:"details"`
  }
6ec91280b   Marko Tikvić   working on docume...
92
93
  // GetListConfig returns list configuration for the provided object type for the front-end application
  // or an error if it fails.
90f4ed079   Marko Tikvić   sped up loadTable()
94
  func GetListConfig(db *ora.Ses, objType string) (ListConfig, error) {
e1fbb41f9   Marko Tikvić   added comments
95
  	resp := newDefaultList(objType)
90f4ed079   Marko Tikvić   sped up loadTable()
96
97
98
  	var err error
  
  	err = setListParams(db, &resp, objType)
7d3deb50d   Marko Tikvić   modified list_con...
99
  	resp.Navigation, err = getListNavigation(db, objType)
90f4ed079   Marko Tikvić   sped up loadTable()
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  	resp.Actions, err = getListActions(db, objType)
  	resp.Filters, err = getListFilters(db, objType)
  	resp.Options, err = getListOptions(db, objType)
  	resp.Parent, err = getListParent(db, objType)
  	resp.Graphs, err = getListGraph(db, objType)
  	resp.Pivots, err = getListPivot(db, objType)
  	resp.Details, err = getListDetails(db, objType)
  
  	if err != nil {
  		return ListConfig{}, err
  	}
  
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
114
115
  // GetListConfigObjectIDField takes in database connection and an object type and it returns the
  // ID field name for the provided object type.
e1fbb41f9   Marko Tikvić   added comments
116
  func GetListConfigObjectIDField(db *ora.Ses, otype string) string {
39765a430   Marko Tikvić   added list and se...
117
118
119
120
121
122
123
  	var resp string
  	var err error
  	var stmt *ora.Stmt
  
  	stmt, err = db.Prep(`SELECT
  		ID_FIELD
  		FROM LIST_CONFIG_ID_FIELD
d66628295   Marko Tikvić   cleaned up
124
  		WHERE OBJECT_TYPE = '`+otype+`'`,
39765a430   Marko Tikvić   added list and se...
125
126
127
128
129
130
131
132
133
134
135
136
  		ora.S)
  
  	defer stmt.Close()
  
  	if err != nil {
  		return ""
  	}
  
  	rset, err := stmt.Qry()
  	if rset.Next() {
  		resp = rset.Row[0].(string)
  	}
1d0f61553   Marko Tikvić   can't fetch clob
137
  	if rset.Err() != nil {
39765a430   Marko Tikvić   added list and se...
138
139
140
141
142
  		return ""
  	}
  
  	return resp
  }
6ec91280b   Marko Tikvić   working on docume...
143
  // newDefaultList returns default configuration for the provided object type.
e1fbb41f9   Marko Tikvić   added comments
144
  func newDefaultList(objType string) ListConfig {
39765a430   Marko Tikvić   added list and se...
145
146
  	list := ListConfig{
  		ObjectType: objType,
d66628295   Marko Tikvić   cleaned up
147
148
  		Title:      objType,
  		LazyLoad:   false,
39765a430   Marko Tikvić   added list and se...
149
  		Options: ListOptions{
d66628295   Marko Tikvić   cleaned up
150
151
  			GlobalFilter:  true,
  			LocalFilters:  true,
39765a430   Marko Tikvić   added list and se...
152
  			RemoteFilters: false,
d66628295   Marko Tikvić   cleaned up
153
154
  			Pagination:    true,
  			PageSize:      20,
39765a430   Marko Tikvić   added list and se...
155
156
157
158
159
160
161
  		},
  		Filters: nil,
  		Actions: ListActions{
  			Create: false,
  			Update: false,
  			Delete: false,
  			Export: false,
d66628295   Marko Tikvić   cleaned up
162
163
  			Print:  false,
  			Graph:  false,
39765a430   Marko Tikvić   added list and se...
164
  		},
d66628295   Marko Tikvić   cleaned up
165
  		Parent:     nil,
7d3deb50d   Marko Tikvić   modified list_con...
166
  		Navigation: nil,
39765a430   Marko Tikvić   added list and se...
167
168
169
170
  	}
  
  	return list
  }
6ec91280b   Marko Tikvić   working on docume...
171
  // setListParams sets the default parameters of the provided configuration list for the provided object type.
39765a430   Marko Tikvić   added list and se...
172
173
174
  func setListParams(db *ora.Ses, list *ListConfig, objType string) error {
  	var err error
  	var stmt *ora.Stmt
f1f300b13   Marko Tikvić   Added nav node field
175
  	query := `SELECT
39765a430   Marko Tikvić   added list and se...
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
  		OBJECT_TYPE, TITLE, LAZY_LOAD, INLINE_EDIT
  		FROM LIST_CONFIG
  		WHERE OBJECT_TYPE = '` + objType + `'`
  
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.U32, ora.U32)
  	if err != nil {
  		return err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return err
  	}
  	if rset.Next() {
  		otype := rset.Row[0].(string)
  		if otype != "" {
  			list.ObjectType = otype
  		}
  
  		title := rset.Row[1].(string)
  		if title != "" {
  			list.Title = title
  		}
  		list.LazyLoad = rset.Row[2].(uint32) != 0
  		list.InlineEdit = rset.Row[3].(uint32) != 0
  	}
1d0f61553   Marko Tikvić   can't fetch clob
203
204
  	if rset.Err() != nil {
  		return rset.Err()
39765a430   Marko Tikvić   added list and se...
205
206
207
  	}
  	return nil
  }
6ec91280b   Marko Tikvić   working on docume...
208
  // getListNavigation returns list navigation node slice for the provided objectType.
a392b07b6   Marko Tikvić   navigation
209
  func getListNavigation(db *ora.Ses, listObjType string) ([]ListNavNode, error) {
7d3deb50d   Marko Tikvić   modified list_con...
210
  	resp := make([]ListNavNode, 0)
39765a430   Marko Tikvić   added list and se...
211
212
  	var err error
  	var stmt *ora.Stmt
f1f300b13   Marko Tikvić   Added nav node field
213
214
215
  	query := `SELECT
  		a.OBJECT_TYPE, a.PARENT_OBJECT_TYPE, a.LABEL, a.ICON, a.PARENT_FILTER_FIELD, b.PARENT_ID_FIELD, b.RB
  		FROM LIST_CONFIG_NAVIGATION b
a392b07b6   Marko Tikvić   navigation
216
  		JOIN LIST_CONFIG_CHILD a ON b.PARENT_CHILD_ID = a.PARENT_CHILD_ID
d66628295   Marko Tikvić   cleaned up
217
  		WHERE b.LIST_OBJECT_TYPE = '` + listObjType + `'
7d3deb50d   Marko Tikvić   modified list_con...
218
  		ORDER BY b.RB ASC`
39765a430   Marko Tikvić   added list and se...
219

7d3deb50d   Marko Tikvić   modified list_con...
220
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S, ora.S, ora.S)
39765a430   Marko Tikvić   added list and se...
221
222
223
224
225
226
227
228
229
230
  	if err != nil {
  		return resp, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return resp, err
  	}
  	for rset.Next() {
7d3deb50d   Marko Tikvić   modified list_con...
231
  		resp = append(resp, ListNavNode{
d66628295   Marko Tikvić   cleaned up
232
233
234
235
  			ObjectType:        rset.Row[0].(string),
  			ParentObjectType:  rset.Row[1].(string),
  			LabelField:        rset.Row[2].(string),
  			Icon:              rset.Row[3].(string),
f1f300b13   Marko Tikvić   Added nav node field
236
  			ParentFilterField: rset.Row[4].(string),
d66628295   Marko Tikvić   cleaned up
237
  			ParentIDField:     rset.Row[5].(string),
f1f300b13   Marko Tikvić   Added nav node field
238
  			// RB is ignored
39765a430   Marko Tikvić   added list and se...
239
240
  		})
  	}
1d0f61553   Marko Tikvić   can't fetch clob
241
242
  	if rset.Err() != nil {
  		return nil, rset.Err()
39765a430   Marko Tikvić   added list and se...
243
244
245
246
  	}
  
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
247
  // getListActions returns list actions for the provided object type.
39765a430   Marko Tikvić   added list and se...
248
249
250
251
  func getListActions(db *ora.Ses, objType string) (ListActions, error) {
  	var resp ListActions
  	var err error
  	var stmt *ora.Stmt
f1f300b13   Marko Tikvić   Added nav node field
252
  	query := `SELECT
39765a430   Marko Tikvić   added list and se...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
  		ACTION_CREATE, ACTION_UPDATE, ACTION_DELETE, ACTION_EXPORT,
  		ACTION_PRINT, ACTION_GRAPH
  		FROM LIST_CONFIG
  		WHERE OBJECT_TYPE = '` + objType + `'`
  
  	stmt, err = db.Prep(query, ora.U32, ora.U32, ora.U32, ora.U32,
  		ora.U32, ora.U32)
  	if err != nil {
  		return ListActions{}, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return ListActions{}, err
  	}
  	if rset.Next() {
  		resp.Create = rset.Row[0].(uint32) != 0
  		resp.Update = rset.Row[1].(uint32) != 0
  		resp.Delete = rset.Row[2].(uint32) != 0
  		resp.Export = rset.Row[3].(uint32) != 0
  		resp.Print = rset.Row[4].(uint32) != 0
  		resp.Graph = rset.Row[5].(uint32) != 0
  	}
1d0f61553   Marko Tikvić   can't fetch clob
277
278
  	if rset.Err() != nil {
  		return ListActions{}, rset.Err()
39765a430   Marko Tikvić   added list and se...
279
280
281
  	}
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
282
  // getListFiters returns list filter slice for the provided object type.
39765a430   Marko Tikvić   added list and se...
283
284
  func getListFilters(db *ora.Ses, objType string) ([]ListFilter, error) {
  	resp := make([]ListFilter, 0)
7d3deb50d   Marko Tikvić   modified list_con...
285
  	filtersFields, err := getFilterFieldsAndPosition(db, objType)
39765a430   Marko Tikvić   added list and se...
286
287
288
  	if err != nil {
  		return nil, err
  	}
7d3deb50d   Marko Tikvić   modified list_con...
289
  	for field, pos := range filtersFields {
39765a430   Marko Tikvić   added list and se...
290
291
  		filters, _ := getFiltersByFilterField(db, field)
  		for _, filter := range filters {
90f4ed079   Marko Tikvić   sped up loadTable()
292
  			var f ListFilter
7d3deb50d   Marko Tikvić   modified list_con...
293
  			f.Position = pos
90f4ed079   Marko Tikvić   sped up loadTable()
294
295
296
297
298
299
300
301
302
303
304
305
  			f.ObjectType = objType
  			f.FiltersField = field
  			f.DefaultValues = filter.DefaultValues
  			f.FiltersLabel = filter.Label
  			f.FiltersType = filter.Type
  			if filter.Type == "dropdown" {
  				f.DropdownConfig, err = getFilterDropdownConfig(db, field)
  				if err != nil {
  					return nil, err
  				}
  			}
  			resp = append(resp, f)
39765a430   Marko Tikvić   added list and se...
306
307
  		}
  	}
7d3deb50d   Marko Tikvić   modified list_con...
308
  	sortFilters(resp)
39765a430   Marko Tikvić   added list and se...
309
310
  	return resp, nil
  }
e1fbb41f9   Marko Tikvić   added comments
311
  // getFilterFieldsAndPosition returns a map of filter fields and their respective position in the menu.
7d3deb50d   Marko Tikvić   modified list_con...
312
313
  func getFilterFieldsAndPosition(db *ora.Ses, objType string) (map[string]uint32, error) {
  	filtersField := make(map[string]uint32, 0)
39765a430   Marko Tikvić   added list and se...
314
315
316
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
7d3deb50d   Marko Tikvić   modified list_con...
317
  		FILTERS_FIELD, RB
39765a430   Marko Tikvić   added list and se...
318
319
  		FROM LIST_CONFIG_FILTERS
  		WHERE OBJECT_TYPE = '` + objType + `'`
7d3deb50d   Marko Tikvić   modified list_con...
320
  	stmt, err = db.Prep(query, ora.S, ora.U32)
39765a430   Marko Tikvić   added list and se...
321
322
323
324
325
326
327
328
329
330
  	if err != nil {
  		return nil, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return nil, err
  	}
  	for rset.Next() {
7d3deb50d   Marko Tikvić   modified list_con...
331
  		filtersField[rset.Row[0].(string)] = rset.Row[1].(uint32)
39765a430   Marko Tikvić   added list and se...
332
  	}
1d0f61553   Marko Tikvić   can't fetch clob
333
334
  	if rset.Err() != nil {
  		return nil, rset.Err()
39765a430   Marko Tikvić   added list and se...
335
336
337
  	}
  	return filtersField, nil
  }
7d3deb50d   Marko Tikvić   modified list_con...
338
  type _filter struct {
39765a430   Marko Tikvić   added list and se...
339
  	DefaultValues string
7d3deb50d   Marko Tikvić   modified list_con...
340
341
  	Label         string
  	Type          string
39765a430   Marko Tikvić   added list and se...
342
  }
6ec91280b   Marko Tikvić   working on docume...
343
  // getFiltersByFilterField returns filter slice for the provided filter field.
7d3deb50d   Marko Tikvić   modified list_con...
344
345
  func getFiltersByFilterField(db *ora.Ses, filtersField string) ([]_filter, error) {
  	resp := make([]_filter, 0)
39765a430   Marko Tikvić   added list and se...
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
  		FILTERS_TYPE, FILTERS_LABEL, DEFAULT_VALUES
  		FROM LIST_FILTERS_FIELD
  		WHERE FILTERS_FIELD = '` + filtersField + `'`
  
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S)
  	if err != nil {
  		return resp, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return resp, err
  	}
  	for rset.Next() {
7d3deb50d   Marko Tikvić   modified list_con...
364
  		resp = append(resp, _filter{
d66628295   Marko Tikvić   cleaned up
365
366
  			Type:          rset.Row[0].(string),
  			Label:         rset.Row[1].(string),
39765a430   Marko Tikvić   added list and se...
367
368
369
  			DefaultValues: rset.Row[2].(string),
  		})
  	}
1d0f61553   Marko Tikvić   can't fetch clob
370
371
  	if rset.Err() != nil {
  		return resp, rset.Err()
39765a430   Marko Tikvić   added list and se...
372
373
374
  	}
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
375
  // getFilterDropdownConfig returns dropdown menu for the provided filter field.
90f4ed079   Marko Tikvić   sped up loadTable()
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
  func getFilterDropdownConfig(db *ora.Ses, filtersField string) (Dropdown, error) {
  	var resp Dropdown
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
  		FILTERS_FIELD, OBJECT_TYPE, ID_FIELD, LABEL_FIELD
  		FROM LIST_DROPDOWN_FILTER
  		WHERE FILTERS_FIELD = '` + filtersField + `'`
  
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S, ora.S)
  	if err != nil {
  		return resp, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return resp, err
  	}
  	if rset.Next() {
  		resp.FiltersField = rset.Row[0].(string)
  		resp.ObjectType = rset.Row[1].(string)
e1fbb41f9   Marko Tikvić   added comments
398
  		resp.IDField = rset.Row[2].(string)
90f4ed079   Marko Tikvić   sped up loadTable()
399
400
  		resp.LabelField = rset.Row[3].(string)
  	}
1d0f61553   Marko Tikvić   can't fetch clob
401
402
  	if rset.Err() != nil {
  		return resp, rset.Err()
90f4ed079   Marko Tikvić   sped up loadTable()
403
404
405
  	}
  	return resp, nil
  }
e1fbb41f9   Marko Tikvić   added comments
406
  // sortFilters bubble sorts provided filters slice by position field.
7d3deb50d   Marko Tikvić   modified list_con...
407
408
409
410
411
  func sortFilters(filters []ListFilter) {
  	done := false
  	var temp ListFilter
  	for !done {
  		done = true
d66628295   Marko Tikvić   cleaned up
412
  		for i := 0; i < len(filters)-1; i++ {
7d3deb50d   Marko Tikvić   modified list_con...
413
414
415
416
417
418
419
420
421
  			if filters[i].Position > filters[i+1].Position {
  				done = false
  				temp = filters[i]
  				filters[i] = filters[i+1]
  				filters[i+1] = temp
  			}
  		}
  	}
  }
6ec91280b   Marko Tikvić   working on docume...
422
  // getListGraph return list graph slice for the provided object type.
39765a430   Marko Tikvić   added list and se...
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
  func getListGraph(db *ora.Ses, objType string) ([]ListGraph, error) {
  	resp := make([]ListGraph, 0)
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
  		OBJECT_TYPE, X_FIELD, Y_FIELD, GROUP_FIELD, LABEL
  		FROM LIST_GRAPHS
  		WHERE OBJECT_TYPE = '` + objType + `'`
  
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S, ora.S)
  	if err != nil {
  		return resp, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return resp, err
  	}
  	for rset.Next() {
  		resp = append(resp, ListGraph{
  			ObjectType: rset.Row[0].(string),
d66628295   Marko Tikvić   cleaned up
445
446
  			X:          rset.Row[1].(string),
  			Y:          rset.Row[2].(string),
39765a430   Marko Tikvić   added list and se...
447
  			GroupField: rset.Row[3].(string),
d66628295   Marko Tikvić   cleaned up
448
  			Label:      rset.Row[4].(string),
39765a430   Marko Tikvić   added list and se...
449
450
  		})
  	}
1d0f61553   Marko Tikvić   can't fetch clob
451
452
  	if rset.Err() != nil {
  		return resp, rset.Err()
39765a430   Marko Tikvić   added list and se...
453
454
455
  	}
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
456
  // getListOptions returns list options for the provided object type.
39765a430   Marko Tikvić   added list and se...
457
458
459
460
461
462
  func getListOptions(db *ora.Ses, objType string) (ListOptions, error) {
  	var resp ListOptions
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
  		GLOBAL_FILTER, LOCAL_FILTER, REMOTE_FILTER, PAGINATION, 
812040e29   Marko Tikvić   hmmm
463
  		PAGE_SIZE, PIVOT, DETAIL, TOTAL
39765a430   Marko Tikvić   added list and se...
464
465
466
467
  		FROM LIST_CONFIG
  		WHERE OBJECT_TYPE = '` + objType + `'`
  
  	stmt, err = db.Prep(query, ora.U32, ora.U32, ora.U32, ora.U32,
812040e29   Marko Tikvić   hmmm
468
  		ora.U64, ora.U64, ora.U32, ora.U32)
39765a430   Marko Tikvić   added list and se...
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
  	if err != nil {
  		return ListOptions{}, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return ListOptions{}, err
  	}
  	if rset.Next() {
  		resp.GlobalFilter = rset.Row[0].(uint32) != 0
  		resp.LocalFilters = rset.Row[1].(uint32) != 0
  		resp.RemoteFilters = rset.Row[2].(uint32) != 0
  		resp.Pagination = rset.Row[3].(uint32) != 0
  		resp.PageSize = rset.Row[4].(uint64)
  		resp.Pivot = rset.Row[5].(uint64) != 0
  		resp.Detail = rset.Row[6].(uint32) != 0
812040e29   Marko Tikvić   hmmm
486
  		resp.Total = rset.Row[7].(uint32) != 0
39765a430   Marko Tikvić   added list and se...
487
  	}
1d0f61553   Marko Tikvić   can't fetch clob
488
489
  	if rset.Err() != nil {
  		return ListOptions{}, rset.Err()
39765a430   Marko Tikvić   added list and se...
490
491
492
  	}
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
493
  // getListParent returns list parent node slice for the provided object type.
39765a430   Marko Tikvić   added list and se...
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
  func getListParent(db *ora.Ses, objType string) ([]ListParentNode, error) {
  	resp := make([]ListParentNode, 0)
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
  		PARENT_OBJECT_TYPE, PARENT_LABEL_FIELD, PARENT_FILTER_FIELD
  		FROM LIST_CONFIG_CHILD
  		WHERE OBJECT_TYPE = '` + objType + `'`
  
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S)
  	if err != nil {
  		return resp, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return resp, err
  	}
  	for rset.Next() {
  		resp = append(resp, ListParentNode{
d66628295   Marko Tikvić   cleaned up
515
516
  			ObjectType:  rset.Row[0].(string),
  			LabelField:  rset.Row[1].(string),
39765a430   Marko Tikvić   added list and se...
517
518
519
  			FilterField: rset.Row[2].(string),
  		})
  	}
1d0f61553   Marko Tikvić   can't fetch clob
520
521
  	if rset.Err() != nil {
  		return nil, rset.Err()
39765a430   Marko Tikvić   added list and se...
522
523
524
525
  	}
  
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
526
  // getListPivot list pivot slice for the provided object type.
39765a430   Marko Tikvić   added list and se...
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
  func getListPivot(db *ora.Ses, objType string) ([]ListPivot, error) {
  	resp := make([]ListPivot, 0)
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
  		OBJECT_TYPE, GROUP_FIELD, DISTINCT_FIELD, VALUE_FIELD
  		FROM LIST_PIVOTS
  		WHERE OBJECT_TYPE = '` + objType + `'`
  
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S, ora.S)
  	if err != nil {
  		return resp, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return resp, err
  	}
  	for rset.Next() {
  		resp = append(resp, ListPivot{
d66628295   Marko Tikvić   cleaned up
548
549
  			ObjectType:    rset.Row[0].(string),
  			GroupField:    rset.Row[1].(string),
39765a430   Marko Tikvić   added list and se...
550
  			DistinctField: rset.Row[2].(string),
d66628295   Marko Tikvić   cleaned up
551
  			Value:         rset.Row[3].(string),
39765a430   Marko Tikvić   added list and se...
552
553
  		})
  	}
1d0f61553   Marko Tikvić   can't fetch clob
554
555
  	if rset.Err() != nil {
  		return nil, rset.Err()
39765a430   Marko Tikvić   added list and se...
556
557
558
559
  	}
  
  	return resp, nil
  }
6ec91280b   Marko Tikvić   working on docume...
560
  // getListDetails returns list details for the provided object type.
39765a430   Marko Tikvić   added list and se...
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
  func getListDetails(db *ora.Ses, objType string) (ListDetails, error) {
  	var resp ListDetails
  	var err error
  	var stmt *ora.Stmt
  	query := `SELECT 
  		OBJECT_TYPE, PARENT_OBJECT_TYPE, PARENT_FILTER_FIELD, SINGLE_DETAIL
  		FROM LIST_CONFIG_DETAIL
  		WHERE PARENT_OBJECT_TYPE = '` + objType + `'`
  
  	stmt, err = db.Prep(query, ora.S, ora.S, ora.S, ora.U32)
  	if err != nil {
  		return resp, err
  	}
  	defer stmt.Close()
  
  	rset, err := stmt.Qry()
  	if err != nil {
  		return resp, err
  	}
  	if rset.Next() {
  		resp.ObjectType = rset.Row[0].(string)
  		resp.ParentObjectType = rset.Row[1].(string)
  		resp.ParentFilterField = rset.Row[2].(string)
  		resp.SingleDetail = rset.Row[3].(uint32) != 0
  	}
1d0f61553   Marko Tikvić   can't fetch clob
586
587
  	if rset.Err() != nil {
  		return resp, rset.Err()
39765a430   Marko Tikvić   added list and se...
588
589
590
591
  	}
  
  	return resp, nil
  }