@ccmaymay/concrete 4.15.0 → 4.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/ActiveLearnerClientService.js +249 -249
  2. package/ActiveLearnerServerService.js +642 -642
  3. package/AnnotateCommunicationService.js +696 -696
  4. package/AnnotateWithContextService.js +298 -298
  5. package/FeedbackService.js +750 -750
  6. package/FetchCommunicationService.js +709 -709
  7. package/README.md +125 -0
  8. package/ResultsServerService.js +2138 -2138
  9. package/SearchProxyService.js +962 -962
  10. package/SearchService.js +685 -685
  11. package/Service.js +373 -373
  12. package/StoreCommunicationService.js +255 -255
  13. package/SummarizationService.js +479 -479
  14. package/access_types.js +168 -168
  15. package/annotate_types.js +26 -26
  16. package/audio_types.js +110 -110
  17. package/cluster_types.js +398 -398
  18. package/communication_fu.js +432 -432
  19. package/communication_types.js +845 -845
  20. package/concrete.js +64 -64
  21. package/context_types.js +65 -65
  22. package/email_types.js +477 -477
  23. package/entities_types.js +658 -658
  24. package/ex_types.js +82 -82
  25. package/language_types.js +123 -123
  26. package/learn_types.js +207 -207
  27. package/linking_types.js +286 -286
  28. package/metadata_types.js +926 -926
  29. package/nitf_types.js +1005 -1005
  30. package/package.json +26 -5
  31. package/results_types.js +18 -18
  32. package/search_types.js +661 -661
  33. package/services_types.js +384 -384
  34. package/situations_types.js +1268 -1268
  35. package/spans_types.js +151 -151
  36. package/structure_types.js +2311 -2311
  37. package/summarization_types.js +433 -433
  38. package/tokenization_fu.js +33 -33
  39. package/tokentagging_fu.js +241 -241
  40. package/twitter_types.js +1553 -1553
  41. package/util.js +117 -117
  42. package/uuid_types.js +67 -67
@@ -1,2138 +1,2138 @@
1
- //
2
- // Autogenerated by Thrift Compiler (0.15.0)
3
- //
4
- // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- //
6
- "use strict";
7
-
8
- const thrift = require('thrift');
9
- const Thrift = thrift.Thrift;
10
- const Int64 = require('node-int64');
11
-
12
- const services_ttypes = require('./services_types');
13
- const uuid_ttypes = require('./uuid_types');
14
- const search_ttypes = require('./search_types');
15
- const communication_ttypes = require('./communication_types');
16
-
17
-
18
- const Service = require('./Service');
19
- const ServiceClient = Service.Client;
20
- const ServiceProcessor = Service.Processor;
21
- const ttypes = require('./results_types');
22
- //HELPER FUNCTIONS AND STRUCTURES
23
-
24
- const ResultsServerService_registerSearchResult_args = class {
25
- constructor(args) {
26
- this.result = null;
27
- this.taskType = null;
28
- if (args) {
29
- if (args.result !== undefined && args.result !== null) {
30
- this.result = new search_ttypes.SearchResult(args.result);
31
- }
32
- if (args.taskType !== undefined && args.taskType !== null) {
33
- this.taskType = args.taskType;
34
- }
35
- }
36
- }
37
-
38
- read (input) {
39
- input.readStructBegin();
40
- while (true) {
41
- const ret = input.readFieldBegin();
42
- const ftype = ret.ftype;
43
- const fid = ret.fid;
44
- if (ftype == Thrift.Type.STOP) {
45
- break;
46
- }
47
- switch (fid) {
48
- case 1:
49
- if (ftype == Thrift.Type.STRUCT) {
50
- this.result = new search_ttypes.SearchResult();
51
- this.result.read(input);
52
- } else {
53
- input.skip(ftype);
54
- }
55
- break;
56
- case 2:
57
- if (ftype == Thrift.Type.I32) {
58
- this.taskType = input.readI32();
59
- } else {
60
- input.skip(ftype);
61
- }
62
- break;
63
- default:
64
- input.skip(ftype);
65
- }
66
- input.readFieldEnd();
67
- }
68
- input.readStructEnd();
69
- return;
70
- }
71
-
72
- write (output) {
73
- output.writeStructBegin('ResultsServerService_registerSearchResult_args');
74
- if (this.result !== null && this.result !== undefined) {
75
- output.writeFieldBegin('result', Thrift.Type.STRUCT, 1);
76
- this.result.write(output);
77
- output.writeFieldEnd();
78
- }
79
- if (this.taskType !== null && this.taskType !== undefined) {
80
- output.writeFieldBegin('taskType', Thrift.Type.I32, 2);
81
- output.writeI32(this.taskType);
82
- output.writeFieldEnd();
83
- }
84
- output.writeFieldStop();
85
- output.writeStructEnd();
86
- return;
87
- }
88
-
89
- };
90
- const ResultsServerService_registerSearchResult_result = class {
91
- constructor(args) {
92
- this.ex = null;
93
- if (args instanceof services_ttypes.ServicesException) {
94
- this.ex = args;
95
- return;
96
- }
97
- if (args) {
98
- if (args.ex !== undefined && args.ex !== null) {
99
- this.ex = args.ex;
100
- }
101
- }
102
- }
103
-
104
- read (input) {
105
- input.readStructBegin();
106
- while (true) {
107
- const ret = input.readFieldBegin();
108
- const ftype = ret.ftype;
109
- const fid = ret.fid;
110
- if (ftype == Thrift.Type.STOP) {
111
- break;
112
- }
113
- switch (fid) {
114
- case 1:
115
- if (ftype == Thrift.Type.STRUCT) {
116
- this.ex = new services_ttypes.ServicesException();
117
- this.ex.read(input);
118
- } else {
119
- input.skip(ftype);
120
- }
121
- break;
122
- case 0:
123
- input.skip(ftype);
124
- break;
125
- default:
126
- input.skip(ftype);
127
- }
128
- input.readFieldEnd();
129
- }
130
- input.readStructEnd();
131
- return;
132
- }
133
-
134
- write (output) {
135
- output.writeStructBegin('ResultsServerService_registerSearchResult_result');
136
- if (this.ex !== null && this.ex !== undefined) {
137
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
138
- this.ex.write(output);
139
- output.writeFieldEnd();
140
- }
141
- output.writeFieldStop();
142
- output.writeStructEnd();
143
- return;
144
- }
145
-
146
- };
147
- const ResultsServerService_getSearchResults_args = class {
148
- constructor(args) {
149
- this.taskType = null;
150
- this.limit = null;
151
- if (args) {
152
- if (args.taskType !== undefined && args.taskType !== null) {
153
- this.taskType = args.taskType;
154
- }
155
- if (args.limit !== undefined && args.limit !== null) {
156
- this.limit = args.limit;
157
- }
158
- }
159
- }
160
-
161
- read (input) {
162
- input.readStructBegin();
163
- while (true) {
164
- const ret = input.readFieldBegin();
165
- const ftype = ret.ftype;
166
- const fid = ret.fid;
167
- if (ftype == Thrift.Type.STOP) {
168
- break;
169
- }
170
- switch (fid) {
171
- case 1:
172
- if (ftype == Thrift.Type.I32) {
173
- this.taskType = input.readI32();
174
- } else {
175
- input.skip(ftype);
176
- }
177
- break;
178
- case 2:
179
- if (ftype == Thrift.Type.I32) {
180
- this.limit = input.readI32();
181
- } else {
182
- input.skip(ftype);
183
- }
184
- break;
185
- default:
186
- input.skip(ftype);
187
- }
188
- input.readFieldEnd();
189
- }
190
- input.readStructEnd();
191
- return;
192
- }
193
-
194
- write (output) {
195
- output.writeStructBegin('ResultsServerService_getSearchResults_args');
196
- if (this.taskType !== null && this.taskType !== undefined) {
197
- output.writeFieldBegin('taskType', Thrift.Type.I32, 1);
198
- output.writeI32(this.taskType);
199
- output.writeFieldEnd();
200
- }
201
- if (this.limit !== null && this.limit !== undefined) {
202
- output.writeFieldBegin('limit', Thrift.Type.I32, 2);
203
- output.writeI32(this.limit);
204
- output.writeFieldEnd();
205
- }
206
- output.writeFieldStop();
207
- output.writeStructEnd();
208
- return;
209
- }
210
-
211
- };
212
- const ResultsServerService_getSearchResults_result = class {
213
- constructor(args) {
214
- this.success = null;
215
- this.ex = null;
216
- if (args instanceof services_ttypes.ServicesException) {
217
- this.ex = args;
218
- return;
219
- }
220
- if (args) {
221
- if (args.success !== undefined && args.success !== null) {
222
- this.success = Thrift.copyList(args.success, [search_ttypes.SearchResult]);
223
- }
224
- if (args.ex !== undefined && args.ex !== null) {
225
- this.ex = args.ex;
226
- }
227
- }
228
- }
229
-
230
- read (input) {
231
- input.readStructBegin();
232
- while (true) {
233
- const ret = input.readFieldBegin();
234
- const ftype = ret.ftype;
235
- const fid = ret.fid;
236
- if (ftype == Thrift.Type.STOP) {
237
- break;
238
- }
239
- switch (fid) {
240
- case 0:
241
- if (ftype == Thrift.Type.LIST) {
242
- this.success = [];
243
- const _rtmp31 = input.readListBegin();
244
- const _size0 = _rtmp31.size || 0;
245
- for (let _i2 = 0; _i2 < _size0; ++_i2) {
246
- let elem3 = null;
247
- elem3 = new search_ttypes.SearchResult();
248
- elem3.read(input);
249
- this.success.push(elem3);
250
- }
251
- input.readListEnd();
252
- } else {
253
- input.skip(ftype);
254
- }
255
- break;
256
- case 1:
257
- if (ftype == Thrift.Type.STRUCT) {
258
- this.ex = new services_ttypes.ServicesException();
259
- this.ex.read(input);
260
- } else {
261
- input.skip(ftype);
262
- }
263
- break;
264
- default:
265
- input.skip(ftype);
266
- }
267
- input.readFieldEnd();
268
- }
269
- input.readStructEnd();
270
- return;
271
- }
272
-
273
- write (output) {
274
- output.writeStructBegin('ResultsServerService_getSearchResults_result');
275
- if (this.success !== null && this.success !== undefined) {
276
- output.writeFieldBegin('success', Thrift.Type.LIST, 0);
277
- output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
278
- for (let iter4 in this.success) {
279
- if (this.success.hasOwnProperty(iter4)) {
280
- iter4 = this.success[iter4];
281
- iter4.write(output);
282
- }
283
- }
284
- output.writeListEnd();
285
- output.writeFieldEnd();
286
- }
287
- if (this.ex !== null && this.ex !== undefined) {
288
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
289
- this.ex.write(output);
290
- output.writeFieldEnd();
291
- }
292
- output.writeFieldStop();
293
- output.writeStructEnd();
294
- return;
295
- }
296
-
297
- };
298
- const ResultsServerService_getSearchResultsByUser_args = class {
299
- constructor(args) {
300
- this.taskType = null;
301
- this.userId = null;
302
- this.limit = null;
303
- if (args) {
304
- if (args.taskType !== undefined && args.taskType !== null) {
305
- this.taskType = args.taskType;
306
- }
307
- if (args.userId !== undefined && args.userId !== null) {
308
- this.userId = args.userId;
309
- }
310
- if (args.limit !== undefined && args.limit !== null) {
311
- this.limit = args.limit;
312
- }
313
- }
314
- }
315
-
316
- read (input) {
317
- input.readStructBegin();
318
- while (true) {
319
- const ret = input.readFieldBegin();
320
- const ftype = ret.ftype;
321
- const fid = ret.fid;
322
- if (ftype == Thrift.Type.STOP) {
323
- break;
324
- }
325
- switch (fid) {
326
- case 1:
327
- if (ftype == Thrift.Type.I32) {
328
- this.taskType = input.readI32();
329
- } else {
330
- input.skip(ftype);
331
- }
332
- break;
333
- case 2:
334
- if (ftype == Thrift.Type.STRING) {
335
- this.userId = input.readString();
336
- } else {
337
- input.skip(ftype);
338
- }
339
- break;
340
- case 3:
341
- if (ftype == Thrift.Type.I32) {
342
- this.limit = input.readI32();
343
- } else {
344
- input.skip(ftype);
345
- }
346
- break;
347
- default:
348
- input.skip(ftype);
349
- }
350
- input.readFieldEnd();
351
- }
352
- input.readStructEnd();
353
- return;
354
- }
355
-
356
- write (output) {
357
- output.writeStructBegin('ResultsServerService_getSearchResultsByUser_args');
358
- if (this.taskType !== null && this.taskType !== undefined) {
359
- output.writeFieldBegin('taskType', Thrift.Type.I32, 1);
360
- output.writeI32(this.taskType);
361
- output.writeFieldEnd();
362
- }
363
- if (this.userId !== null && this.userId !== undefined) {
364
- output.writeFieldBegin('userId', Thrift.Type.STRING, 2);
365
- output.writeString(this.userId);
366
- output.writeFieldEnd();
367
- }
368
- if (this.limit !== null && this.limit !== undefined) {
369
- output.writeFieldBegin('limit', Thrift.Type.I32, 3);
370
- output.writeI32(this.limit);
371
- output.writeFieldEnd();
372
- }
373
- output.writeFieldStop();
374
- output.writeStructEnd();
375
- return;
376
- }
377
-
378
- };
379
- const ResultsServerService_getSearchResultsByUser_result = class {
380
- constructor(args) {
381
- this.success = null;
382
- this.ex = null;
383
- if (args instanceof services_ttypes.ServicesException) {
384
- this.ex = args;
385
- return;
386
- }
387
- if (args) {
388
- if (args.success !== undefined && args.success !== null) {
389
- this.success = Thrift.copyList(args.success, [search_ttypes.SearchResult]);
390
- }
391
- if (args.ex !== undefined && args.ex !== null) {
392
- this.ex = args.ex;
393
- }
394
- }
395
- }
396
-
397
- read (input) {
398
- input.readStructBegin();
399
- while (true) {
400
- const ret = input.readFieldBegin();
401
- const ftype = ret.ftype;
402
- const fid = ret.fid;
403
- if (ftype == Thrift.Type.STOP) {
404
- break;
405
- }
406
- switch (fid) {
407
- case 0:
408
- if (ftype == Thrift.Type.LIST) {
409
- this.success = [];
410
- const _rtmp36 = input.readListBegin();
411
- const _size5 = _rtmp36.size || 0;
412
- for (let _i7 = 0; _i7 < _size5; ++_i7) {
413
- let elem8 = null;
414
- elem8 = new search_ttypes.SearchResult();
415
- elem8.read(input);
416
- this.success.push(elem8);
417
- }
418
- input.readListEnd();
419
- } else {
420
- input.skip(ftype);
421
- }
422
- break;
423
- case 1:
424
- if (ftype == Thrift.Type.STRUCT) {
425
- this.ex = new services_ttypes.ServicesException();
426
- this.ex.read(input);
427
- } else {
428
- input.skip(ftype);
429
- }
430
- break;
431
- default:
432
- input.skip(ftype);
433
- }
434
- input.readFieldEnd();
435
- }
436
- input.readStructEnd();
437
- return;
438
- }
439
-
440
- write (output) {
441
- output.writeStructBegin('ResultsServerService_getSearchResultsByUser_result');
442
- if (this.success !== null && this.success !== undefined) {
443
- output.writeFieldBegin('success', Thrift.Type.LIST, 0);
444
- output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
445
- for (let iter9 in this.success) {
446
- if (this.success.hasOwnProperty(iter9)) {
447
- iter9 = this.success[iter9];
448
- iter9.write(output);
449
- }
450
- }
451
- output.writeListEnd();
452
- output.writeFieldEnd();
453
- }
454
- if (this.ex !== null && this.ex !== undefined) {
455
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
456
- this.ex.write(output);
457
- output.writeFieldEnd();
458
- }
459
- output.writeFieldStop();
460
- output.writeStructEnd();
461
- return;
462
- }
463
-
464
- };
465
- const ResultsServerService_getLatestSearchResult_args = class {
466
- constructor(args) {
467
- this.userId = null;
468
- if (args) {
469
- if (args.userId !== undefined && args.userId !== null) {
470
- this.userId = args.userId;
471
- }
472
- }
473
- }
474
-
475
- read (input) {
476
- input.readStructBegin();
477
- while (true) {
478
- const ret = input.readFieldBegin();
479
- const ftype = ret.ftype;
480
- const fid = ret.fid;
481
- if (ftype == Thrift.Type.STOP) {
482
- break;
483
- }
484
- switch (fid) {
485
- case 1:
486
- if (ftype == Thrift.Type.STRING) {
487
- this.userId = input.readString();
488
- } else {
489
- input.skip(ftype);
490
- }
491
- break;
492
- case 0:
493
- input.skip(ftype);
494
- break;
495
- default:
496
- input.skip(ftype);
497
- }
498
- input.readFieldEnd();
499
- }
500
- input.readStructEnd();
501
- return;
502
- }
503
-
504
- write (output) {
505
- output.writeStructBegin('ResultsServerService_getLatestSearchResult_args');
506
- if (this.userId !== null && this.userId !== undefined) {
507
- output.writeFieldBegin('userId', Thrift.Type.STRING, 1);
508
- output.writeString(this.userId);
509
- output.writeFieldEnd();
510
- }
511
- output.writeFieldStop();
512
- output.writeStructEnd();
513
- return;
514
- }
515
-
516
- };
517
- const ResultsServerService_getLatestSearchResult_result = class {
518
- constructor(args) {
519
- this.success = null;
520
- this.ex = null;
521
- if (args instanceof services_ttypes.ServicesException) {
522
- this.ex = args;
523
- return;
524
- }
525
- if (args) {
526
- if (args.success !== undefined && args.success !== null) {
527
- this.success = new search_ttypes.SearchResult(args.success);
528
- }
529
- if (args.ex !== undefined && args.ex !== null) {
530
- this.ex = args.ex;
531
- }
532
- }
533
- }
534
-
535
- read (input) {
536
- input.readStructBegin();
537
- while (true) {
538
- const ret = input.readFieldBegin();
539
- const ftype = ret.ftype;
540
- const fid = ret.fid;
541
- if (ftype == Thrift.Type.STOP) {
542
- break;
543
- }
544
- switch (fid) {
545
- case 0:
546
- if (ftype == Thrift.Type.STRUCT) {
547
- this.success = new search_ttypes.SearchResult();
548
- this.success.read(input);
549
- } else {
550
- input.skip(ftype);
551
- }
552
- break;
553
- case 1:
554
- if (ftype == Thrift.Type.STRUCT) {
555
- this.ex = new services_ttypes.ServicesException();
556
- this.ex.read(input);
557
- } else {
558
- input.skip(ftype);
559
- }
560
- break;
561
- default:
562
- input.skip(ftype);
563
- }
564
- input.readFieldEnd();
565
- }
566
- input.readStructEnd();
567
- return;
568
- }
569
-
570
- write (output) {
571
- output.writeStructBegin('ResultsServerService_getLatestSearchResult_result');
572
- if (this.success !== null && this.success !== undefined) {
573
- output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
574
- this.success.write(output);
575
- output.writeFieldEnd();
576
- }
577
- if (this.ex !== null && this.ex !== undefined) {
578
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
579
- this.ex.write(output);
580
- output.writeFieldEnd();
581
- }
582
- output.writeFieldStop();
583
- output.writeStructEnd();
584
- return;
585
- }
586
-
587
- };
588
- const ResultsServerService_getSearchResult_args = class {
589
- constructor(args) {
590
- this.searchResultId = null;
591
- if (args) {
592
- if (args.searchResultId !== undefined && args.searchResultId !== null) {
593
- this.searchResultId = new uuid_ttypes.UUID(args.searchResultId);
594
- }
595
- }
596
- }
597
-
598
- read (input) {
599
- input.readStructBegin();
600
- while (true) {
601
- const ret = input.readFieldBegin();
602
- const ftype = ret.ftype;
603
- const fid = ret.fid;
604
- if (ftype == Thrift.Type.STOP) {
605
- break;
606
- }
607
- switch (fid) {
608
- case 1:
609
- if (ftype == Thrift.Type.STRUCT) {
610
- this.searchResultId = new uuid_ttypes.UUID();
611
- this.searchResultId.read(input);
612
- } else {
613
- input.skip(ftype);
614
- }
615
- break;
616
- case 0:
617
- input.skip(ftype);
618
- break;
619
- default:
620
- input.skip(ftype);
621
- }
622
- input.readFieldEnd();
623
- }
624
- input.readStructEnd();
625
- return;
626
- }
627
-
628
- write (output) {
629
- output.writeStructBegin('ResultsServerService_getSearchResult_args');
630
- if (this.searchResultId !== null && this.searchResultId !== undefined) {
631
- output.writeFieldBegin('searchResultId', Thrift.Type.STRUCT, 1);
632
- this.searchResultId.write(output);
633
- output.writeFieldEnd();
634
- }
635
- output.writeFieldStop();
636
- output.writeStructEnd();
637
- return;
638
- }
639
-
640
- };
641
- const ResultsServerService_getSearchResult_result = class {
642
- constructor(args) {
643
- this.success = null;
644
- this.ex = null;
645
- if (args instanceof services_ttypes.ServicesException) {
646
- this.ex = args;
647
- return;
648
- }
649
- if (args) {
650
- if (args.success !== undefined && args.success !== null) {
651
- this.success = new search_ttypes.SearchResult(args.success);
652
- }
653
- if (args.ex !== undefined && args.ex !== null) {
654
- this.ex = args.ex;
655
- }
656
- }
657
- }
658
-
659
- read (input) {
660
- input.readStructBegin();
661
- while (true) {
662
- const ret = input.readFieldBegin();
663
- const ftype = ret.ftype;
664
- const fid = ret.fid;
665
- if (ftype == Thrift.Type.STOP) {
666
- break;
667
- }
668
- switch (fid) {
669
- case 0:
670
- if (ftype == Thrift.Type.STRUCT) {
671
- this.success = new search_ttypes.SearchResult();
672
- this.success.read(input);
673
- } else {
674
- input.skip(ftype);
675
- }
676
- break;
677
- case 1:
678
- if (ftype == Thrift.Type.STRUCT) {
679
- this.ex = new services_ttypes.ServicesException();
680
- this.ex.read(input);
681
- } else {
682
- input.skip(ftype);
683
- }
684
- break;
685
- default:
686
- input.skip(ftype);
687
- }
688
- input.readFieldEnd();
689
- }
690
- input.readStructEnd();
691
- return;
692
- }
693
-
694
- write (output) {
695
- output.writeStructBegin('ResultsServerService_getSearchResult_result');
696
- if (this.success !== null && this.success !== undefined) {
697
- output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
698
- this.success.write(output);
699
- output.writeFieldEnd();
700
- }
701
- if (this.ex !== null && this.ex !== undefined) {
702
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
703
- this.ex.write(output);
704
- output.writeFieldEnd();
705
- }
706
- output.writeFieldStop();
707
- output.writeStructEnd();
708
- return;
709
- }
710
-
711
- };
712
- const ResultsServerService_startSession_args = class {
713
- constructor(args) {
714
- this.searchResultId = null;
715
- this.taskType = null;
716
- if (args) {
717
- if (args.searchResultId !== undefined && args.searchResultId !== null) {
718
- this.searchResultId = new uuid_ttypes.UUID(args.searchResultId);
719
- }
720
- if (args.taskType !== undefined && args.taskType !== null) {
721
- this.taskType = args.taskType;
722
- }
723
- }
724
- }
725
-
726
- read (input) {
727
- input.readStructBegin();
728
- while (true) {
729
- const ret = input.readFieldBegin();
730
- const ftype = ret.ftype;
731
- const fid = ret.fid;
732
- if (ftype == Thrift.Type.STOP) {
733
- break;
734
- }
735
- switch (fid) {
736
- case 1:
737
- if (ftype == Thrift.Type.STRUCT) {
738
- this.searchResultId = new uuid_ttypes.UUID();
739
- this.searchResultId.read(input);
740
- } else {
741
- input.skip(ftype);
742
- }
743
- break;
744
- case 2:
745
- if (ftype == Thrift.Type.I32) {
746
- this.taskType = input.readI32();
747
- } else {
748
- input.skip(ftype);
749
- }
750
- break;
751
- default:
752
- input.skip(ftype);
753
- }
754
- input.readFieldEnd();
755
- }
756
- input.readStructEnd();
757
- return;
758
- }
759
-
760
- write (output) {
761
- output.writeStructBegin('ResultsServerService_startSession_args');
762
- if (this.searchResultId !== null && this.searchResultId !== undefined) {
763
- output.writeFieldBegin('searchResultId', Thrift.Type.STRUCT, 1);
764
- this.searchResultId.write(output);
765
- output.writeFieldEnd();
766
- }
767
- if (this.taskType !== null && this.taskType !== undefined) {
768
- output.writeFieldBegin('taskType', Thrift.Type.I32, 2);
769
- output.writeI32(this.taskType);
770
- output.writeFieldEnd();
771
- }
772
- output.writeFieldStop();
773
- output.writeStructEnd();
774
- return;
775
- }
776
-
777
- };
778
- const ResultsServerService_startSession_result = class {
779
- constructor(args) {
780
- this.success = null;
781
- this.ex = null;
782
- if (args instanceof services_ttypes.ServicesException) {
783
- this.ex = args;
784
- return;
785
- }
786
- if (args) {
787
- if (args.success !== undefined && args.success !== null) {
788
- this.success = new uuid_ttypes.UUID(args.success);
789
- }
790
- if (args.ex !== undefined && args.ex !== null) {
791
- this.ex = args.ex;
792
- }
793
- }
794
- }
795
-
796
- read (input) {
797
- input.readStructBegin();
798
- while (true) {
799
- const ret = input.readFieldBegin();
800
- const ftype = ret.ftype;
801
- const fid = ret.fid;
802
- if (ftype == Thrift.Type.STOP) {
803
- break;
804
- }
805
- switch (fid) {
806
- case 0:
807
- if (ftype == Thrift.Type.STRUCT) {
808
- this.success = new uuid_ttypes.UUID();
809
- this.success.read(input);
810
- } else {
811
- input.skip(ftype);
812
- }
813
- break;
814
- case 1:
815
- if (ftype == Thrift.Type.STRUCT) {
816
- this.ex = new services_ttypes.ServicesException();
817
- this.ex.read(input);
818
- } else {
819
- input.skip(ftype);
820
- }
821
- break;
822
- default:
823
- input.skip(ftype);
824
- }
825
- input.readFieldEnd();
826
- }
827
- input.readStructEnd();
828
- return;
829
- }
830
-
831
- write (output) {
832
- output.writeStructBegin('ResultsServerService_startSession_result');
833
- if (this.success !== null && this.success !== undefined) {
834
- output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
835
- this.success.write(output);
836
- output.writeFieldEnd();
837
- }
838
- if (this.ex !== null && this.ex !== undefined) {
839
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
840
- this.ex.write(output);
841
- output.writeFieldEnd();
842
- }
843
- output.writeFieldStop();
844
- output.writeStructEnd();
845
- return;
846
- }
847
-
848
- };
849
- const ResultsServerService_stopSession_args = class {
850
- constructor(args) {
851
- this.sessionId = null;
852
- if (args) {
853
- if (args.sessionId !== undefined && args.sessionId !== null) {
854
- this.sessionId = new uuid_ttypes.UUID(args.sessionId);
855
- }
856
- }
857
- }
858
-
859
- read (input) {
860
- input.readStructBegin();
861
- while (true) {
862
- const ret = input.readFieldBegin();
863
- const ftype = ret.ftype;
864
- const fid = ret.fid;
865
- if (ftype == Thrift.Type.STOP) {
866
- break;
867
- }
868
- switch (fid) {
869
- case 1:
870
- if (ftype == Thrift.Type.STRUCT) {
871
- this.sessionId = new uuid_ttypes.UUID();
872
- this.sessionId.read(input);
873
- } else {
874
- input.skip(ftype);
875
- }
876
- break;
877
- case 0:
878
- input.skip(ftype);
879
- break;
880
- default:
881
- input.skip(ftype);
882
- }
883
- input.readFieldEnd();
884
- }
885
- input.readStructEnd();
886
- return;
887
- }
888
-
889
- write (output) {
890
- output.writeStructBegin('ResultsServerService_stopSession_args');
891
- if (this.sessionId !== null && this.sessionId !== undefined) {
892
- output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
893
- this.sessionId.write(output);
894
- output.writeFieldEnd();
895
- }
896
- output.writeFieldStop();
897
- output.writeStructEnd();
898
- return;
899
- }
900
-
901
- };
902
- const ResultsServerService_stopSession_result = class {
903
- constructor(args) {
904
- this.ex = null;
905
- if (args instanceof services_ttypes.ServicesException) {
906
- this.ex = args;
907
- return;
908
- }
909
- if (args) {
910
- if (args.ex !== undefined && args.ex !== null) {
911
- this.ex = args.ex;
912
- }
913
- }
914
- }
915
-
916
- read (input) {
917
- input.readStructBegin();
918
- while (true) {
919
- const ret = input.readFieldBegin();
920
- const ftype = ret.ftype;
921
- const fid = ret.fid;
922
- if (ftype == Thrift.Type.STOP) {
923
- break;
924
- }
925
- switch (fid) {
926
- case 1:
927
- if (ftype == Thrift.Type.STRUCT) {
928
- this.ex = new services_ttypes.ServicesException();
929
- this.ex.read(input);
930
- } else {
931
- input.skip(ftype);
932
- }
933
- break;
934
- case 0:
935
- input.skip(ftype);
936
- break;
937
- default:
938
- input.skip(ftype);
939
- }
940
- input.readFieldEnd();
941
- }
942
- input.readStructEnd();
943
- return;
944
- }
945
-
946
- write (output) {
947
- output.writeStructBegin('ResultsServerService_stopSession_result');
948
- if (this.ex !== null && this.ex !== undefined) {
949
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
950
- this.ex.write(output);
951
- output.writeFieldEnd();
952
- }
953
- output.writeFieldStop();
954
- output.writeStructEnd();
955
- return;
956
- }
957
-
958
- };
959
- const ResultsServerService_getNextChunk_args = class {
960
- constructor(args) {
961
- this.sessionId = null;
962
- if (args) {
963
- if (args.sessionId !== undefined && args.sessionId !== null) {
964
- this.sessionId = new uuid_ttypes.UUID(args.sessionId);
965
- }
966
- }
967
- }
968
-
969
- read (input) {
970
- input.readStructBegin();
971
- while (true) {
972
- const ret = input.readFieldBegin();
973
- const ftype = ret.ftype;
974
- const fid = ret.fid;
975
- if (ftype == Thrift.Type.STOP) {
976
- break;
977
- }
978
- switch (fid) {
979
- case 1:
980
- if (ftype == Thrift.Type.STRUCT) {
981
- this.sessionId = new uuid_ttypes.UUID();
982
- this.sessionId.read(input);
983
- } else {
984
- input.skip(ftype);
985
- }
986
- break;
987
- case 0:
988
- input.skip(ftype);
989
- break;
990
- default:
991
- input.skip(ftype);
992
- }
993
- input.readFieldEnd();
994
- }
995
- input.readStructEnd();
996
- return;
997
- }
998
-
999
- write (output) {
1000
- output.writeStructBegin('ResultsServerService_getNextChunk_args');
1001
- if (this.sessionId !== null && this.sessionId !== undefined) {
1002
- output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
1003
- this.sessionId.write(output);
1004
- output.writeFieldEnd();
1005
- }
1006
- output.writeFieldStop();
1007
- output.writeStructEnd();
1008
- return;
1009
- }
1010
-
1011
- };
1012
- const ResultsServerService_getNextChunk_result = class {
1013
- constructor(args) {
1014
- this.success = null;
1015
- this.ex = null;
1016
- if (args instanceof services_ttypes.ServicesException) {
1017
- this.ex = args;
1018
- return;
1019
- }
1020
- if (args) {
1021
- if (args.success !== undefined && args.success !== null) {
1022
- this.success = Thrift.copyList(args.success, [services_ttypes.AnnotationUnitIdentifier]);
1023
- }
1024
- if (args.ex !== undefined && args.ex !== null) {
1025
- this.ex = args.ex;
1026
- }
1027
- }
1028
- }
1029
-
1030
- read (input) {
1031
- input.readStructBegin();
1032
- while (true) {
1033
- const ret = input.readFieldBegin();
1034
- const ftype = ret.ftype;
1035
- const fid = ret.fid;
1036
- if (ftype == Thrift.Type.STOP) {
1037
- break;
1038
- }
1039
- switch (fid) {
1040
- case 0:
1041
- if (ftype == Thrift.Type.LIST) {
1042
- this.success = [];
1043
- const _rtmp311 = input.readListBegin();
1044
- const _size10 = _rtmp311.size || 0;
1045
- for (let _i12 = 0; _i12 < _size10; ++_i12) {
1046
- let elem13 = null;
1047
- elem13 = new services_ttypes.AnnotationUnitIdentifier();
1048
- elem13.read(input);
1049
- this.success.push(elem13);
1050
- }
1051
- input.readListEnd();
1052
- } else {
1053
- input.skip(ftype);
1054
- }
1055
- break;
1056
- case 1:
1057
- if (ftype == Thrift.Type.STRUCT) {
1058
- this.ex = new services_ttypes.ServicesException();
1059
- this.ex.read(input);
1060
- } else {
1061
- input.skip(ftype);
1062
- }
1063
- break;
1064
- default:
1065
- input.skip(ftype);
1066
- }
1067
- input.readFieldEnd();
1068
- }
1069
- input.readStructEnd();
1070
- return;
1071
- }
1072
-
1073
- write (output) {
1074
- output.writeStructBegin('ResultsServerService_getNextChunk_result');
1075
- if (this.success !== null && this.success !== undefined) {
1076
- output.writeFieldBegin('success', Thrift.Type.LIST, 0);
1077
- output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
1078
- for (let iter14 in this.success) {
1079
- if (this.success.hasOwnProperty(iter14)) {
1080
- iter14 = this.success[iter14];
1081
- iter14.write(output);
1082
- }
1083
- }
1084
- output.writeListEnd();
1085
- output.writeFieldEnd();
1086
- }
1087
- if (this.ex !== null && this.ex !== undefined) {
1088
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
1089
- this.ex.write(output);
1090
- output.writeFieldEnd();
1091
- }
1092
- output.writeFieldStop();
1093
- output.writeStructEnd();
1094
- return;
1095
- }
1096
-
1097
- };
1098
- const ResultsServerService_submitAnnotation_args = class {
1099
- constructor(args) {
1100
- this.sessionId = null;
1101
- this.unitId = null;
1102
- this.communication = null;
1103
- if (args) {
1104
- if (args.sessionId !== undefined && args.sessionId !== null) {
1105
- this.sessionId = new uuid_ttypes.UUID(args.sessionId);
1106
- }
1107
- if (args.unitId !== undefined && args.unitId !== null) {
1108
- this.unitId = new services_ttypes.AnnotationUnitIdentifier(args.unitId);
1109
- }
1110
- if (args.communication !== undefined && args.communication !== null) {
1111
- this.communication = new communication_ttypes.Communication(args.communication);
1112
- }
1113
- }
1114
- }
1115
-
1116
- read (input) {
1117
- input.readStructBegin();
1118
- while (true) {
1119
- const ret = input.readFieldBegin();
1120
- const ftype = ret.ftype;
1121
- const fid = ret.fid;
1122
- if (ftype == Thrift.Type.STOP) {
1123
- break;
1124
- }
1125
- switch (fid) {
1126
- case 1:
1127
- if (ftype == Thrift.Type.STRUCT) {
1128
- this.sessionId = new uuid_ttypes.UUID();
1129
- this.sessionId.read(input);
1130
- } else {
1131
- input.skip(ftype);
1132
- }
1133
- break;
1134
- case 2:
1135
- if (ftype == Thrift.Type.STRUCT) {
1136
- this.unitId = new services_ttypes.AnnotationUnitIdentifier();
1137
- this.unitId.read(input);
1138
- } else {
1139
- input.skip(ftype);
1140
- }
1141
- break;
1142
- case 3:
1143
- if (ftype == Thrift.Type.STRUCT) {
1144
- this.communication = new communication_ttypes.Communication();
1145
- this.communication.read(input);
1146
- } else {
1147
- input.skip(ftype);
1148
- }
1149
- break;
1150
- default:
1151
- input.skip(ftype);
1152
- }
1153
- input.readFieldEnd();
1154
- }
1155
- input.readStructEnd();
1156
- return;
1157
- }
1158
-
1159
- write (output) {
1160
- output.writeStructBegin('ResultsServerService_submitAnnotation_args');
1161
- if (this.sessionId !== null && this.sessionId !== undefined) {
1162
- output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
1163
- this.sessionId.write(output);
1164
- output.writeFieldEnd();
1165
- }
1166
- if (this.unitId !== null && this.unitId !== undefined) {
1167
- output.writeFieldBegin('unitId', Thrift.Type.STRUCT, 2);
1168
- this.unitId.write(output);
1169
- output.writeFieldEnd();
1170
- }
1171
- if (this.communication !== null && this.communication !== undefined) {
1172
- output.writeFieldBegin('communication', Thrift.Type.STRUCT, 3);
1173
- this.communication.write(output);
1174
- output.writeFieldEnd();
1175
- }
1176
- output.writeFieldStop();
1177
- output.writeStructEnd();
1178
- return;
1179
- }
1180
-
1181
- };
1182
- const ResultsServerService_submitAnnotation_result = class {
1183
- constructor(args) {
1184
- this.ex = null;
1185
- if (args instanceof services_ttypes.ServicesException) {
1186
- this.ex = args;
1187
- return;
1188
- }
1189
- if (args) {
1190
- if (args.ex !== undefined && args.ex !== null) {
1191
- this.ex = args.ex;
1192
- }
1193
- }
1194
- }
1195
-
1196
- read (input) {
1197
- input.readStructBegin();
1198
- while (true) {
1199
- const ret = input.readFieldBegin();
1200
- const ftype = ret.ftype;
1201
- const fid = ret.fid;
1202
- if (ftype == Thrift.Type.STOP) {
1203
- break;
1204
- }
1205
- switch (fid) {
1206
- case 1:
1207
- if (ftype == Thrift.Type.STRUCT) {
1208
- this.ex = new services_ttypes.ServicesException();
1209
- this.ex.read(input);
1210
- } else {
1211
- input.skip(ftype);
1212
- }
1213
- break;
1214
- case 0:
1215
- input.skip(ftype);
1216
- break;
1217
- default:
1218
- input.skip(ftype);
1219
- }
1220
- input.readFieldEnd();
1221
- }
1222
- input.readStructEnd();
1223
- return;
1224
- }
1225
-
1226
- write (output) {
1227
- output.writeStructBegin('ResultsServerService_submitAnnotation_result');
1228
- if (this.ex !== null && this.ex !== undefined) {
1229
- output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
1230
- this.ex.write(output);
1231
- output.writeFieldEnd();
1232
- }
1233
- output.writeFieldStop();
1234
- output.writeStructEnd();
1235
- return;
1236
- }
1237
-
1238
- };
1239
- const ResultsServerServiceClient = exports.Client = class ResultsServerServiceClient extends ServiceClient {
1240
- constructor(output, pClass) {
1241
- super(output, pClass);
1242
- this.output = output;
1243
- this.pClass = pClass;
1244
- this._seqid = 0;
1245
- this._reqs = {};
1246
- }
1247
- seqid () { return this._seqid; }
1248
- new_seqid () { return this._seqid += 1; }
1249
-
1250
- registerSearchResult (result, taskType) {
1251
- this._seqid = this.new_seqid();
1252
- const self = this;
1253
- return new Promise((resolve, reject) => {
1254
- self._reqs[self.seqid()] = (error, result) => {
1255
- return error ? reject(error) : resolve(result);
1256
- };
1257
- self.send_registerSearchResult(result, taskType);
1258
- });
1259
- }
1260
-
1261
- send_registerSearchResult (result, taskType) {
1262
- const output = new this.pClass(this.output);
1263
- const params = {
1264
- result: result,
1265
- taskType: taskType
1266
- };
1267
- const args = new ResultsServerService_registerSearchResult_args(params);
1268
- try {
1269
- output.writeMessageBegin('registerSearchResult', Thrift.MessageType.CALL, this.seqid());
1270
- args.write(output);
1271
- output.writeMessageEnd();
1272
- return this.output.flush();
1273
- }
1274
- catch (e) {
1275
- delete this._reqs[this.seqid()];
1276
- if (typeof output.reset === 'function') {
1277
- output.reset();
1278
- }
1279
- throw e;
1280
- }
1281
- }
1282
-
1283
- recv_registerSearchResult (input, mtype, rseqid) {
1284
- const callback = this._reqs[rseqid] || function() {};
1285
- delete this._reqs[rseqid];
1286
- if (mtype == Thrift.MessageType.EXCEPTION) {
1287
- const x = new Thrift.TApplicationException();
1288
- x.read(input);
1289
- input.readMessageEnd();
1290
- return callback(x);
1291
- }
1292
- const result = new ResultsServerService_registerSearchResult_result();
1293
- result.read(input);
1294
- input.readMessageEnd();
1295
-
1296
- if (null !== result.ex) {
1297
- return callback(result.ex);
1298
- }
1299
- callback(null);
1300
- }
1301
-
1302
- getSearchResults (taskType, limit) {
1303
- this._seqid = this.new_seqid();
1304
- const self = this;
1305
- return new Promise((resolve, reject) => {
1306
- self._reqs[self.seqid()] = (error, result) => {
1307
- return error ? reject(error) : resolve(result);
1308
- };
1309
- self.send_getSearchResults(taskType, limit);
1310
- });
1311
- }
1312
-
1313
- send_getSearchResults (taskType, limit) {
1314
- const output = new this.pClass(this.output);
1315
- const params = {
1316
- taskType: taskType,
1317
- limit: limit
1318
- };
1319
- const args = new ResultsServerService_getSearchResults_args(params);
1320
- try {
1321
- output.writeMessageBegin('getSearchResults', Thrift.MessageType.CALL, this.seqid());
1322
- args.write(output);
1323
- output.writeMessageEnd();
1324
- return this.output.flush();
1325
- }
1326
- catch (e) {
1327
- delete this._reqs[this.seqid()];
1328
- if (typeof output.reset === 'function') {
1329
- output.reset();
1330
- }
1331
- throw e;
1332
- }
1333
- }
1334
-
1335
- recv_getSearchResults (input, mtype, rseqid) {
1336
- const callback = this._reqs[rseqid] || function() {};
1337
- delete this._reqs[rseqid];
1338
- if (mtype == Thrift.MessageType.EXCEPTION) {
1339
- const x = new Thrift.TApplicationException();
1340
- x.read(input);
1341
- input.readMessageEnd();
1342
- return callback(x);
1343
- }
1344
- const result = new ResultsServerService_getSearchResults_result();
1345
- result.read(input);
1346
- input.readMessageEnd();
1347
-
1348
- if (null !== result.ex) {
1349
- return callback(result.ex);
1350
- }
1351
- if (null !== result.success) {
1352
- return callback(null, result.success);
1353
- }
1354
- return callback('getSearchResults failed: unknown result');
1355
- }
1356
-
1357
- getSearchResultsByUser (taskType, userId, limit) {
1358
- this._seqid = this.new_seqid();
1359
- const self = this;
1360
- return new Promise((resolve, reject) => {
1361
- self._reqs[self.seqid()] = (error, result) => {
1362
- return error ? reject(error) : resolve(result);
1363
- };
1364
- self.send_getSearchResultsByUser(taskType, userId, limit);
1365
- });
1366
- }
1367
-
1368
- send_getSearchResultsByUser (taskType, userId, limit) {
1369
- const output = new this.pClass(this.output);
1370
- const params = {
1371
- taskType: taskType,
1372
- userId: userId,
1373
- limit: limit
1374
- };
1375
- const args = new ResultsServerService_getSearchResultsByUser_args(params);
1376
- try {
1377
- output.writeMessageBegin('getSearchResultsByUser', Thrift.MessageType.CALL, this.seqid());
1378
- args.write(output);
1379
- output.writeMessageEnd();
1380
- return this.output.flush();
1381
- }
1382
- catch (e) {
1383
- delete this._reqs[this.seqid()];
1384
- if (typeof output.reset === 'function') {
1385
- output.reset();
1386
- }
1387
- throw e;
1388
- }
1389
- }
1390
-
1391
- recv_getSearchResultsByUser (input, mtype, rseqid) {
1392
- const callback = this._reqs[rseqid] || function() {};
1393
- delete this._reqs[rseqid];
1394
- if (mtype == Thrift.MessageType.EXCEPTION) {
1395
- const x = new Thrift.TApplicationException();
1396
- x.read(input);
1397
- input.readMessageEnd();
1398
- return callback(x);
1399
- }
1400
- const result = new ResultsServerService_getSearchResultsByUser_result();
1401
- result.read(input);
1402
- input.readMessageEnd();
1403
-
1404
- if (null !== result.ex) {
1405
- return callback(result.ex);
1406
- }
1407
- if (null !== result.success) {
1408
- return callback(null, result.success);
1409
- }
1410
- return callback('getSearchResultsByUser failed: unknown result');
1411
- }
1412
-
1413
- getLatestSearchResult (userId) {
1414
- this._seqid = this.new_seqid();
1415
- const self = this;
1416
- return new Promise((resolve, reject) => {
1417
- self._reqs[self.seqid()] = (error, result) => {
1418
- return error ? reject(error) : resolve(result);
1419
- };
1420
- self.send_getLatestSearchResult(userId);
1421
- });
1422
- }
1423
-
1424
- send_getLatestSearchResult (userId) {
1425
- const output = new this.pClass(this.output);
1426
- const params = {
1427
- userId: userId
1428
- };
1429
- const args = new ResultsServerService_getLatestSearchResult_args(params);
1430
- try {
1431
- output.writeMessageBegin('getLatestSearchResult', Thrift.MessageType.CALL, this.seqid());
1432
- args.write(output);
1433
- output.writeMessageEnd();
1434
- return this.output.flush();
1435
- }
1436
- catch (e) {
1437
- delete this._reqs[this.seqid()];
1438
- if (typeof output.reset === 'function') {
1439
- output.reset();
1440
- }
1441
- throw e;
1442
- }
1443
- }
1444
-
1445
- recv_getLatestSearchResult (input, mtype, rseqid) {
1446
- const callback = this._reqs[rseqid] || function() {};
1447
- delete this._reqs[rseqid];
1448
- if (mtype == Thrift.MessageType.EXCEPTION) {
1449
- const x = new Thrift.TApplicationException();
1450
- x.read(input);
1451
- input.readMessageEnd();
1452
- return callback(x);
1453
- }
1454
- const result = new ResultsServerService_getLatestSearchResult_result();
1455
- result.read(input);
1456
- input.readMessageEnd();
1457
-
1458
- if (null !== result.ex) {
1459
- return callback(result.ex);
1460
- }
1461
- if (null !== result.success) {
1462
- return callback(null, result.success);
1463
- }
1464
- return callback('getLatestSearchResult failed: unknown result');
1465
- }
1466
-
1467
- getSearchResult (searchResultId) {
1468
- this._seqid = this.new_seqid();
1469
- const self = this;
1470
- return new Promise((resolve, reject) => {
1471
- self._reqs[self.seqid()] = (error, result) => {
1472
- return error ? reject(error) : resolve(result);
1473
- };
1474
- self.send_getSearchResult(searchResultId);
1475
- });
1476
- }
1477
-
1478
- send_getSearchResult (searchResultId) {
1479
- const output = new this.pClass(this.output);
1480
- const params = {
1481
- searchResultId: searchResultId
1482
- };
1483
- const args = new ResultsServerService_getSearchResult_args(params);
1484
- try {
1485
- output.writeMessageBegin('getSearchResult', Thrift.MessageType.CALL, this.seqid());
1486
- args.write(output);
1487
- output.writeMessageEnd();
1488
- return this.output.flush();
1489
- }
1490
- catch (e) {
1491
- delete this._reqs[this.seqid()];
1492
- if (typeof output.reset === 'function') {
1493
- output.reset();
1494
- }
1495
- throw e;
1496
- }
1497
- }
1498
-
1499
- recv_getSearchResult (input, mtype, rseqid) {
1500
- const callback = this._reqs[rseqid] || function() {};
1501
- delete this._reqs[rseqid];
1502
- if (mtype == Thrift.MessageType.EXCEPTION) {
1503
- const x = new Thrift.TApplicationException();
1504
- x.read(input);
1505
- input.readMessageEnd();
1506
- return callback(x);
1507
- }
1508
- const result = new ResultsServerService_getSearchResult_result();
1509
- result.read(input);
1510
- input.readMessageEnd();
1511
-
1512
- if (null !== result.ex) {
1513
- return callback(result.ex);
1514
- }
1515
- if (null !== result.success) {
1516
- return callback(null, result.success);
1517
- }
1518
- return callback('getSearchResult failed: unknown result');
1519
- }
1520
-
1521
- startSession (searchResultId, taskType) {
1522
- this._seqid = this.new_seqid();
1523
- const self = this;
1524
- return new Promise((resolve, reject) => {
1525
- self._reqs[self.seqid()] = (error, result) => {
1526
- return error ? reject(error) : resolve(result);
1527
- };
1528
- self.send_startSession(searchResultId, taskType);
1529
- });
1530
- }
1531
-
1532
- send_startSession (searchResultId, taskType) {
1533
- const output = new this.pClass(this.output);
1534
- const params = {
1535
- searchResultId: searchResultId,
1536
- taskType: taskType
1537
- };
1538
- const args = new ResultsServerService_startSession_args(params);
1539
- try {
1540
- output.writeMessageBegin('startSession', Thrift.MessageType.CALL, this.seqid());
1541
- args.write(output);
1542
- output.writeMessageEnd();
1543
- return this.output.flush();
1544
- }
1545
- catch (e) {
1546
- delete this._reqs[this.seqid()];
1547
- if (typeof output.reset === 'function') {
1548
- output.reset();
1549
- }
1550
- throw e;
1551
- }
1552
- }
1553
-
1554
- recv_startSession (input, mtype, rseqid) {
1555
- const callback = this._reqs[rseqid] || function() {};
1556
- delete this._reqs[rseqid];
1557
- if (mtype == Thrift.MessageType.EXCEPTION) {
1558
- const x = new Thrift.TApplicationException();
1559
- x.read(input);
1560
- input.readMessageEnd();
1561
- return callback(x);
1562
- }
1563
- const result = new ResultsServerService_startSession_result();
1564
- result.read(input);
1565
- input.readMessageEnd();
1566
-
1567
- if (null !== result.ex) {
1568
- return callback(result.ex);
1569
- }
1570
- if (null !== result.success) {
1571
- return callback(null, result.success);
1572
- }
1573
- return callback('startSession failed: unknown result');
1574
- }
1575
-
1576
- stopSession (sessionId) {
1577
- this._seqid = this.new_seqid();
1578
- const self = this;
1579
- return new Promise((resolve, reject) => {
1580
- self._reqs[self.seqid()] = (error, result) => {
1581
- return error ? reject(error) : resolve(result);
1582
- };
1583
- self.send_stopSession(sessionId);
1584
- });
1585
- }
1586
-
1587
- send_stopSession (sessionId) {
1588
- const output = new this.pClass(this.output);
1589
- const params = {
1590
- sessionId: sessionId
1591
- };
1592
- const args = new ResultsServerService_stopSession_args(params);
1593
- try {
1594
- output.writeMessageBegin('stopSession', Thrift.MessageType.CALL, this.seqid());
1595
- args.write(output);
1596
- output.writeMessageEnd();
1597
- return this.output.flush();
1598
- }
1599
- catch (e) {
1600
- delete this._reqs[this.seqid()];
1601
- if (typeof output.reset === 'function') {
1602
- output.reset();
1603
- }
1604
- throw e;
1605
- }
1606
- }
1607
-
1608
- recv_stopSession (input, mtype, rseqid) {
1609
- const callback = this._reqs[rseqid] || function() {};
1610
- delete this._reqs[rseqid];
1611
- if (mtype == Thrift.MessageType.EXCEPTION) {
1612
- const x = new Thrift.TApplicationException();
1613
- x.read(input);
1614
- input.readMessageEnd();
1615
- return callback(x);
1616
- }
1617
- const result = new ResultsServerService_stopSession_result();
1618
- result.read(input);
1619
- input.readMessageEnd();
1620
-
1621
- if (null !== result.ex) {
1622
- return callback(result.ex);
1623
- }
1624
- callback(null);
1625
- }
1626
-
1627
- getNextChunk (sessionId) {
1628
- this._seqid = this.new_seqid();
1629
- const self = this;
1630
- return new Promise((resolve, reject) => {
1631
- self._reqs[self.seqid()] = (error, result) => {
1632
- return error ? reject(error) : resolve(result);
1633
- };
1634
- self.send_getNextChunk(sessionId);
1635
- });
1636
- }
1637
-
1638
- send_getNextChunk (sessionId) {
1639
- const output = new this.pClass(this.output);
1640
- const params = {
1641
- sessionId: sessionId
1642
- };
1643
- const args = new ResultsServerService_getNextChunk_args(params);
1644
- try {
1645
- output.writeMessageBegin('getNextChunk', Thrift.MessageType.CALL, this.seqid());
1646
- args.write(output);
1647
- output.writeMessageEnd();
1648
- return this.output.flush();
1649
- }
1650
- catch (e) {
1651
- delete this._reqs[this.seqid()];
1652
- if (typeof output.reset === 'function') {
1653
- output.reset();
1654
- }
1655
- throw e;
1656
- }
1657
- }
1658
-
1659
- recv_getNextChunk (input, mtype, rseqid) {
1660
- const callback = this._reqs[rseqid] || function() {};
1661
- delete this._reqs[rseqid];
1662
- if (mtype == Thrift.MessageType.EXCEPTION) {
1663
- const x = new Thrift.TApplicationException();
1664
- x.read(input);
1665
- input.readMessageEnd();
1666
- return callback(x);
1667
- }
1668
- const result = new ResultsServerService_getNextChunk_result();
1669
- result.read(input);
1670
- input.readMessageEnd();
1671
-
1672
- if (null !== result.ex) {
1673
- return callback(result.ex);
1674
- }
1675
- if (null !== result.success) {
1676
- return callback(null, result.success);
1677
- }
1678
- return callback('getNextChunk failed: unknown result');
1679
- }
1680
-
1681
- submitAnnotation (sessionId, unitId, communication) {
1682
- this._seqid = this.new_seqid();
1683
- const self = this;
1684
- return new Promise((resolve, reject) => {
1685
- self._reqs[self.seqid()] = (error, result) => {
1686
- return error ? reject(error) : resolve(result);
1687
- };
1688
- self.send_submitAnnotation(sessionId, unitId, communication);
1689
- });
1690
- }
1691
-
1692
- send_submitAnnotation (sessionId, unitId, communication) {
1693
- const output = new this.pClass(this.output);
1694
- const params = {
1695
- sessionId: sessionId,
1696
- unitId: unitId,
1697
- communication: communication
1698
- };
1699
- const args = new ResultsServerService_submitAnnotation_args(params);
1700
- try {
1701
- output.writeMessageBegin('submitAnnotation', Thrift.MessageType.CALL, this.seqid());
1702
- args.write(output);
1703
- output.writeMessageEnd();
1704
- return this.output.flush();
1705
- }
1706
- catch (e) {
1707
- delete this._reqs[this.seqid()];
1708
- if (typeof output.reset === 'function') {
1709
- output.reset();
1710
- }
1711
- throw e;
1712
- }
1713
- }
1714
-
1715
- recv_submitAnnotation (input, mtype, rseqid) {
1716
- const callback = this._reqs[rseqid] || function() {};
1717
- delete this._reqs[rseqid];
1718
- if (mtype == Thrift.MessageType.EXCEPTION) {
1719
- const x = new Thrift.TApplicationException();
1720
- x.read(input);
1721
- input.readMessageEnd();
1722
- return callback(x);
1723
- }
1724
- const result = new ResultsServerService_submitAnnotation_result();
1725
- result.read(input);
1726
- input.readMessageEnd();
1727
-
1728
- if (null !== result.ex) {
1729
- return callback(result.ex);
1730
- }
1731
- callback(null);
1732
- }
1733
- };
1734
- const ResultsServerServiceProcessor = exports.Processor = class ResultsServerServiceProcessor extends ServiceProcessor {
1735
- constructor(handler) {
1736
- super(handler);
1737
- this._handler = handler;
1738
- }
1739
- process (input, output) {
1740
- const r = input.readMessageBegin();
1741
- if (this['process_' + r.fname]) {
1742
- return this['process_' + r.fname].call(this, r.rseqid, input, output);
1743
- } else {
1744
- input.skip(Thrift.Type.STRUCT);
1745
- input.readMessageEnd();
1746
- const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
1747
- output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
1748
- x.write(output);
1749
- output.writeMessageEnd();
1750
- output.flush();
1751
- }
1752
- }
1753
- process_registerSearchResult (seqid, input, output) {
1754
- const args = new ResultsServerService_registerSearchResult_args();
1755
- args.read(input);
1756
- input.readMessageEnd();
1757
- if (this._handler.registerSearchResult.length === 2) {
1758
- Promise.resolve(this._handler.registerSearchResult.bind(this._handler)(
1759
- args.result,
1760
- args.taskType
1761
- )).then(result => {
1762
- const result_obj = new ResultsServerService_registerSearchResult_result({success: result});
1763
- output.writeMessageBegin("registerSearchResult", Thrift.MessageType.REPLY, seqid);
1764
- result_obj.write(output);
1765
- output.writeMessageEnd();
1766
- output.flush();
1767
- }).catch(err => {
1768
- let result;
1769
- if (err instanceof services_ttypes.ServicesException) {
1770
- result = new ResultsServerService_registerSearchResult_result(err);
1771
- output.writeMessageBegin("registerSearchResult", Thrift.MessageType.REPLY, seqid);
1772
- } else {
1773
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1774
- output.writeMessageBegin("registerSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1775
- }
1776
- result.write(output);
1777
- output.writeMessageEnd();
1778
- output.flush();
1779
- });
1780
- } else {
1781
- this._handler.registerSearchResult(args.result, args.taskType, (err, result) => {
1782
- let result_obj;
1783
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1784
- result_obj = new ResultsServerService_registerSearchResult_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1785
- output.writeMessageBegin("registerSearchResult", Thrift.MessageType.REPLY, seqid);
1786
- } else {
1787
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1788
- output.writeMessageBegin("registerSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1789
- }
1790
- result_obj.write(output);
1791
- output.writeMessageEnd();
1792
- output.flush();
1793
- });
1794
- }
1795
- }
1796
- process_getSearchResults (seqid, input, output) {
1797
- const args = new ResultsServerService_getSearchResults_args();
1798
- args.read(input);
1799
- input.readMessageEnd();
1800
- if (this._handler.getSearchResults.length === 2) {
1801
- Promise.resolve(this._handler.getSearchResults.bind(this._handler)(
1802
- args.taskType,
1803
- args.limit
1804
- )).then(result => {
1805
- const result_obj = new ResultsServerService_getSearchResults_result({success: result});
1806
- output.writeMessageBegin("getSearchResults", Thrift.MessageType.REPLY, seqid);
1807
- result_obj.write(output);
1808
- output.writeMessageEnd();
1809
- output.flush();
1810
- }).catch(err => {
1811
- let result;
1812
- if (err instanceof services_ttypes.ServicesException) {
1813
- result = new ResultsServerService_getSearchResults_result(err);
1814
- output.writeMessageBegin("getSearchResults", Thrift.MessageType.REPLY, seqid);
1815
- } else {
1816
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1817
- output.writeMessageBegin("getSearchResults", Thrift.MessageType.EXCEPTION, seqid);
1818
- }
1819
- result.write(output);
1820
- output.writeMessageEnd();
1821
- output.flush();
1822
- });
1823
- } else {
1824
- this._handler.getSearchResults(args.taskType, args.limit, (err, result) => {
1825
- let result_obj;
1826
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1827
- result_obj = new ResultsServerService_getSearchResults_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1828
- output.writeMessageBegin("getSearchResults", Thrift.MessageType.REPLY, seqid);
1829
- } else {
1830
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1831
- output.writeMessageBegin("getSearchResults", Thrift.MessageType.EXCEPTION, seqid);
1832
- }
1833
- result_obj.write(output);
1834
- output.writeMessageEnd();
1835
- output.flush();
1836
- });
1837
- }
1838
- }
1839
- process_getSearchResultsByUser (seqid, input, output) {
1840
- const args = new ResultsServerService_getSearchResultsByUser_args();
1841
- args.read(input);
1842
- input.readMessageEnd();
1843
- if (this._handler.getSearchResultsByUser.length === 3) {
1844
- Promise.resolve(this._handler.getSearchResultsByUser.bind(this._handler)(
1845
- args.taskType,
1846
- args.userId,
1847
- args.limit
1848
- )).then(result => {
1849
- const result_obj = new ResultsServerService_getSearchResultsByUser_result({success: result});
1850
- output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.REPLY, seqid);
1851
- result_obj.write(output);
1852
- output.writeMessageEnd();
1853
- output.flush();
1854
- }).catch(err => {
1855
- let result;
1856
- if (err instanceof services_ttypes.ServicesException) {
1857
- result = new ResultsServerService_getSearchResultsByUser_result(err);
1858
- output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.REPLY, seqid);
1859
- } else {
1860
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1861
- output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.EXCEPTION, seqid);
1862
- }
1863
- result.write(output);
1864
- output.writeMessageEnd();
1865
- output.flush();
1866
- });
1867
- } else {
1868
- this._handler.getSearchResultsByUser(args.taskType, args.userId, args.limit, (err, result) => {
1869
- let result_obj;
1870
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1871
- result_obj = new ResultsServerService_getSearchResultsByUser_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1872
- output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.REPLY, seqid);
1873
- } else {
1874
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1875
- output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.EXCEPTION, seqid);
1876
- }
1877
- result_obj.write(output);
1878
- output.writeMessageEnd();
1879
- output.flush();
1880
- });
1881
- }
1882
- }
1883
- process_getLatestSearchResult (seqid, input, output) {
1884
- const args = new ResultsServerService_getLatestSearchResult_args();
1885
- args.read(input);
1886
- input.readMessageEnd();
1887
- if (this._handler.getLatestSearchResult.length === 1) {
1888
- Promise.resolve(this._handler.getLatestSearchResult.bind(this._handler)(
1889
- args.userId
1890
- )).then(result => {
1891
- const result_obj = new ResultsServerService_getLatestSearchResult_result({success: result});
1892
- output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.REPLY, seqid);
1893
- result_obj.write(output);
1894
- output.writeMessageEnd();
1895
- output.flush();
1896
- }).catch(err => {
1897
- let result;
1898
- if (err instanceof services_ttypes.ServicesException) {
1899
- result = new ResultsServerService_getLatestSearchResult_result(err);
1900
- output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.REPLY, seqid);
1901
- } else {
1902
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1903
- output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1904
- }
1905
- result.write(output);
1906
- output.writeMessageEnd();
1907
- output.flush();
1908
- });
1909
- } else {
1910
- this._handler.getLatestSearchResult(args.userId, (err, result) => {
1911
- let result_obj;
1912
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1913
- result_obj = new ResultsServerService_getLatestSearchResult_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1914
- output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.REPLY, seqid);
1915
- } else {
1916
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1917
- output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1918
- }
1919
- result_obj.write(output);
1920
- output.writeMessageEnd();
1921
- output.flush();
1922
- });
1923
- }
1924
- }
1925
- process_getSearchResult (seqid, input, output) {
1926
- const args = new ResultsServerService_getSearchResult_args();
1927
- args.read(input);
1928
- input.readMessageEnd();
1929
- if (this._handler.getSearchResult.length === 1) {
1930
- Promise.resolve(this._handler.getSearchResult.bind(this._handler)(
1931
- args.searchResultId
1932
- )).then(result => {
1933
- const result_obj = new ResultsServerService_getSearchResult_result({success: result});
1934
- output.writeMessageBegin("getSearchResult", Thrift.MessageType.REPLY, seqid);
1935
- result_obj.write(output);
1936
- output.writeMessageEnd();
1937
- output.flush();
1938
- }).catch(err => {
1939
- let result;
1940
- if (err instanceof services_ttypes.ServicesException) {
1941
- result = new ResultsServerService_getSearchResult_result(err);
1942
- output.writeMessageBegin("getSearchResult", Thrift.MessageType.REPLY, seqid);
1943
- } else {
1944
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1945
- output.writeMessageBegin("getSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1946
- }
1947
- result.write(output);
1948
- output.writeMessageEnd();
1949
- output.flush();
1950
- });
1951
- } else {
1952
- this._handler.getSearchResult(args.searchResultId, (err, result) => {
1953
- let result_obj;
1954
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1955
- result_obj = new ResultsServerService_getSearchResult_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1956
- output.writeMessageBegin("getSearchResult", Thrift.MessageType.REPLY, seqid);
1957
- } else {
1958
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1959
- output.writeMessageBegin("getSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1960
- }
1961
- result_obj.write(output);
1962
- output.writeMessageEnd();
1963
- output.flush();
1964
- });
1965
- }
1966
- }
1967
- process_startSession (seqid, input, output) {
1968
- const args = new ResultsServerService_startSession_args();
1969
- args.read(input);
1970
- input.readMessageEnd();
1971
- if (this._handler.startSession.length === 2) {
1972
- Promise.resolve(this._handler.startSession.bind(this._handler)(
1973
- args.searchResultId,
1974
- args.taskType
1975
- )).then(result => {
1976
- const result_obj = new ResultsServerService_startSession_result({success: result});
1977
- output.writeMessageBegin("startSession", Thrift.MessageType.REPLY, seqid);
1978
- result_obj.write(output);
1979
- output.writeMessageEnd();
1980
- output.flush();
1981
- }).catch(err => {
1982
- let result;
1983
- if (err instanceof services_ttypes.ServicesException) {
1984
- result = new ResultsServerService_startSession_result(err);
1985
- output.writeMessageBegin("startSession", Thrift.MessageType.REPLY, seqid);
1986
- } else {
1987
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1988
- output.writeMessageBegin("startSession", Thrift.MessageType.EXCEPTION, seqid);
1989
- }
1990
- result.write(output);
1991
- output.writeMessageEnd();
1992
- output.flush();
1993
- });
1994
- } else {
1995
- this._handler.startSession(args.searchResultId, args.taskType, (err, result) => {
1996
- let result_obj;
1997
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1998
- result_obj = new ResultsServerService_startSession_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1999
- output.writeMessageBegin("startSession", Thrift.MessageType.REPLY, seqid);
2000
- } else {
2001
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2002
- output.writeMessageBegin("startSession", Thrift.MessageType.EXCEPTION, seqid);
2003
- }
2004
- result_obj.write(output);
2005
- output.writeMessageEnd();
2006
- output.flush();
2007
- });
2008
- }
2009
- }
2010
- process_stopSession (seqid, input, output) {
2011
- const args = new ResultsServerService_stopSession_args();
2012
- args.read(input);
2013
- input.readMessageEnd();
2014
- if (this._handler.stopSession.length === 1) {
2015
- Promise.resolve(this._handler.stopSession.bind(this._handler)(
2016
- args.sessionId
2017
- )).then(result => {
2018
- const result_obj = new ResultsServerService_stopSession_result({success: result});
2019
- output.writeMessageBegin("stopSession", Thrift.MessageType.REPLY, seqid);
2020
- result_obj.write(output);
2021
- output.writeMessageEnd();
2022
- output.flush();
2023
- }).catch(err => {
2024
- let result;
2025
- if (err instanceof services_ttypes.ServicesException) {
2026
- result = new ResultsServerService_stopSession_result(err);
2027
- output.writeMessageBegin("stopSession", Thrift.MessageType.REPLY, seqid);
2028
- } else {
2029
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2030
- output.writeMessageBegin("stopSession", Thrift.MessageType.EXCEPTION, seqid);
2031
- }
2032
- result.write(output);
2033
- output.writeMessageEnd();
2034
- output.flush();
2035
- });
2036
- } else {
2037
- this._handler.stopSession(args.sessionId, (err, result) => {
2038
- let result_obj;
2039
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
2040
- result_obj = new ResultsServerService_stopSession_result((err !== null || typeof err === 'undefined') ? err : {success: result});
2041
- output.writeMessageBegin("stopSession", Thrift.MessageType.REPLY, seqid);
2042
- } else {
2043
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2044
- output.writeMessageBegin("stopSession", Thrift.MessageType.EXCEPTION, seqid);
2045
- }
2046
- result_obj.write(output);
2047
- output.writeMessageEnd();
2048
- output.flush();
2049
- });
2050
- }
2051
- }
2052
- process_getNextChunk (seqid, input, output) {
2053
- const args = new ResultsServerService_getNextChunk_args();
2054
- args.read(input);
2055
- input.readMessageEnd();
2056
- if (this._handler.getNextChunk.length === 1) {
2057
- Promise.resolve(this._handler.getNextChunk.bind(this._handler)(
2058
- args.sessionId
2059
- )).then(result => {
2060
- const result_obj = new ResultsServerService_getNextChunk_result({success: result});
2061
- output.writeMessageBegin("getNextChunk", Thrift.MessageType.REPLY, seqid);
2062
- result_obj.write(output);
2063
- output.writeMessageEnd();
2064
- output.flush();
2065
- }).catch(err => {
2066
- let result;
2067
- if (err instanceof services_ttypes.ServicesException) {
2068
- result = new ResultsServerService_getNextChunk_result(err);
2069
- output.writeMessageBegin("getNextChunk", Thrift.MessageType.REPLY, seqid);
2070
- } else {
2071
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2072
- output.writeMessageBegin("getNextChunk", Thrift.MessageType.EXCEPTION, seqid);
2073
- }
2074
- result.write(output);
2075
- output.writeMessageEnd();
2076
- output.flush();
2077
- });
2078
- } else {
2079
- this._handler.getNextChunk(args.sessionId, (err, result) => {
2080
- let result_obj;
2081
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
2082
- result_obj = new ResultsServerService_getNextChunk_result((err !== null || typeof err === 'undefined') ? err : {success: result});
2083
- output.writeMessageBegin("getNextChunk", Thrift.MessageType.REPLY, seqid);
2084
- } else {
2085
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2086
- output.writeMessageBegin("getNextChunk", Thrift.MessageType.EXCEPTION, seqid);
2087
- }
2088
- result_obj.write(output);
2089
- output.writeMessageEnd();
2090
- output.flush();
2091
- });
2092
- }
2093
- }
2094
- process_submitAnnotation (seqid, input, output) {
2095
- const args = new ResultsServerService_submitAnnotation_args();
2096
- args.read(input);
2097
- input.readMessageEnd();
2098
- if (this._handler.submitAnnotation.length === 3) {
2099
- Promise.resolve(this._handler.submitAnnotation.bind(this._handler)(
2100
- args.sessionId,
2101
- args.unitId,
2102
- args.communication
2103
- )).then(result => {
2104
- const result_obj = new ResultsServerService_submitAnnotation_result({success: result});
2105
- output.writeMessageBegin("submitAnnotation", Thrift.MessageType.REPLY, seqid);
2106
- result_obj.write(output);
2107
- output.writeMessageEnd();
2108
- output.flush();
2109
- }).catch(err => {
2110
- let result;
2111
- if (err instanceof services_ttypes.ServicesException) {
2112
- result = new ResultsServerService_submitAnnotation_result(err);
2113
- output.writeMessageBegin("submitAnnotation", Thrift.MessageType.REPLY, seqid);
2114
- } else {
2115
- result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2116
- output.writeMessageBegin("submitAnnotation", Thrift.MessageType.EXCEPTION, seqid);
2117
- }
2118
- result.write(output);
2119
- output.writeMessageEnd();
2120
- output.flush();
2121
- });
2122
- } else {
2123
- this._handler.submitAnnotation(args.sessionId, args.unitId, args.communication, (err, result) => {
2124
- let result_obj;
2125
- if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
2126
- result_obj = new ResultsServerService_submitAnnotation_result((err !== null || typeof err === 'undefined') ? err : {success: result});
2127
- output.writeMessageBegin("submitAnnotation", Thrift.MessageType.REPLY, seqid);
2128
- } else {
2129
- result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2130
- output.writeMessageBegin("submitAnnotation", Thrift.MessageType.EXCEPTION, seqid);
2131
- }
2132
- result_obj.write(output);
2133
- output.writeMessageEnd();
2134
- output.flush();
2135
- });
2136
- }
2137
- }
2138
- };
1
+ //
2
+ // Autogenerated by Thrift Compiler (0.15.0)
3
+ //
4
+ // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ //
6
+ "use strict";
7
+
8
+ const thrift = require('thrift');
9
+ const Thrift = thrift.Thrift;
10
+ const Int64 = require('node-int64');
11
+
12
+ const services_ttypes = require('./services_types');
13
+ const uuid_ttypes = require('./uuid_types');
14
+ const search_ttypes = require('./search_types');
15
+ const communication_ttypes = require('./communication_types');
16
+
17
+
18
+ const Service = require('./Service');
19
+ const ServiceClient = Service.Client;
20
+ const ServiceProcessor = Service.Processor;
21
+ const ttypes = require('./results_types');
22
+ //HELPER FUNCTIONS AND STRUCTURES
23
+
24
+ const ResultsServerService_registerSearchResult_args = class {
25
+ constructor(args) {
26
+ this.result = null;
27
+ this.taskType = null;
28
+ if (args) {
29
+ if (args.result !== undefined && args.result !== null) {
30
+ this.result = new search_ttypes.SearchResult(args.result);
31
+ }
32
+ if (args.taskType !== undefined && args.taskType !== null) {
33
+ this.taskType = args.taskType;
34
+ }
35
+ }
36
+ }
37
+
38
+ read (input) {
39
+ input.readStructBegin();
40
+ while (true) {
41
+ const ret = input.readFieldBegin();
42
+ const ftype = ret.ftype;
43
+ const fid = ret.fid;
44
+ if (ftype == Thrift.Type.STOP) {
45
+ break;
46
+ }
47
+ switch (fid) {
48
+ case 1:
49
+ if (ftype == Thrift.Type.STRUCT) {
50
+ this.result = new search_ttypes.SearchResult();
51
+ this.result.read(input);
52
+ } else {
53
+ input.skip(ftype);
54
+ }
55
+ break;
56
+ case 2:
57
+ if (ftype == Thrift.Type.I32) {
58
+ this.taskType = input.readI32();
59
+ } else {
60
+ input.skip(ftype);
61
+ }
62
+ break;
63
+ default:
64
+ input.skip(ftype);
65
+ }
66
+ input.readFieldEnd();
67
+ }
68
+ input.readStructEnd();
69
+ return;
70
+ }
71
+
72
+ write (output) {
73
+ output.writeStructBegin('ResultsServerService_registerSearchResult_args');
74
+ if (this.result !== null && this.result !== undefined) {
75
+ output.writeFieldBegin('result', Thrift.Type.STRUCT, 1);
76
+ this.result.write(output);
77
+ output.writeFieldEnd();
78
+ }
79
+ if (this.taskType !== null && this.taskType !== undefined) {
80
+ output.writeFieldBegin('taskType', Thrift.Type.I32, 2);
81
+ output.writeI32(this.taskType);
82
+ output.writeFieldEnd();
83
+ }
84
+ output.writeFieldStop();
85
+ output.writeStructEnd();
86
+ return;
87
+ }
88
+
89
+ };
90
+ const ResultsServerService_registerSearchResult_result = class {
91
+ constructor(args) {
92
+ this.ex = null;
93
+ if (args instanceof services_ttypes.ServicesException) {
94
+ this.ex = args;
95
+ return;
96
+ }
97
+ if (args) {
98
+ if (args.ex !== undefined && args.ex !== null) {
99
+ this.ex = args.ex;
100
+ }
101
+ }
102
+ }
103
+
104
+ read (input) {
105
+ input.readStructBegin();
106
+ while (true) {
107
+ const ret = input.readFieldBegin();
108
+ const ftype = ret.ftype;
109
+ const fid = ret.fid;
110
+ if (ftype == Thrift.Type.STOP) {
111
+ break;
112
+ }
113
+ switch (fid) {
114
+ case 1:
115
+ if (ftype == Thrift.Type.STRUCT) {
116
+ this.ex = new services_ttypes.ServicesException();
117
+ this.ex.read(input);
118
+ } else {
119
+ input.skip(ftype);
120
+ }
121
+ break;
122
+ case 0:
123
+ input.skip(ftype);
124
+ break;
125
+ default:
126
+ input.skip(ftype);
127
+ }
128
+ input.readFieldEnd();
129
+ }
130
+ input.readStructEnd();
131
+ return;
132
+ }
133
+
134
+ write (output) {
135
+ output.writeStructBegin('ResultsServerService_registerSearchResult_result');
136
+ if (this.ex !== null && this.ex !== undefined) {
137
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
138
+ this.ex.write(output);
139
+ output.writeFieldEnd();
140
+ }
141
+ output.writeFieldStop();
142
+ output.writeStructEnd();
143
+ return;
144
+ }
145
+
146
+ };
147
+ const ResultsServerService_getSearchResults_args = class {
148
+ constructor(args) {
149
+ this.taskType = null;
150
+ this.limit = null;
151
+ if (args) {
152
+ if (args.taskType !== undefined && args.taskType !== null) {
153
+ this.taskType = args.taskType;
154
+ }
155
+ if (args.limit !== undefined && args.limit !== null) {
156
+ this.limit = args.limit;
157
+ }
158
+ }
159
+ }
160
+
161
+ read (input) {
162
+ input.readStructBegin();
163
+ while (true) {
164
+ const ret = input.readFieldBegin();
165
+ const ftype = ret.ftype;
166
+ const fid = ret.fid;
167
+ if (ftype == Thrift.Type.STOP) {
168
+ break;
169
+ }
170
+ switch (fid) {
171
+ case 1:
172
+ if (ftype == Thrift.Type.I32) {
173
+ this.taskType = input.readI32();
174
+ } else {
175
+ input.skip(ftype);
176
+ }
177
+ break;
178
+ case 2:
179
+ if (ftype == Thrift.Type.I32) {
180
+ this.limit = input.readI32();
181
+ } else {
182
+ input.skip(ftype);
183
+ }
184
+ break;
185
+ default:
186
+ input.skip(ftype);
187
+ }
188
+ input.readFieldEnd();
189
+ }
190
+ input.readStructEnd();
191
+ return;
192
+ }
193
+
194
+ write (output) {
195
+ output.writeStructBegin('ResultsServerService_getSearchResults_args');
196
+ if (this.taskType !== null && this.taskType !== undefined) {
197
+ output.writeFieldBegin('taskType', Thrift.Type.I32, 1);
198
+ output.writeI32(this.taskType);
199
+ output.writeFieldEnd();
200
+ }
201
+ if (this.limit !== null && this.limit !== undefined) {
202
+ output.writeFieldBegin('limit', Thrift.Type.I32, 2);
203
+ output.writeI32(this.limit);
204
+ output.writeFieldEnd();
205
+ }
206
+ output.writeFieldStop();
207
+ output.writeStructEnd();
208
+ return;
209
+ }
210
+
211
+ };
212
+ const ResultsServerService_getSearchResults_result = class {
213
+ constructor(args) {
214
+ this.success = null;
215
+ this.ex = null;
216
+ if (args instanceof services_ttypes.ServicesException) {
217
+ this.ex = args;
218
+ return;
219
+ }
220
+ if (args) {
221
+ if (args.success !== undefined && args.success !== null) {
222
+ this.success = Thrift.copyList(args.success, [search_ttypes.SearchResult]);
223
+ }
224
+ if (args.ex !== undefined && args.ex !== null) {
225
+ this.ex = args.ex;
226
+ }
227
+ }
228
+ }
229
+
230
+ read (input) {
231
+ input.readStructBegin();
232
+ while (true) {
233
+ const ret = input.readFieldBegin();
234
+ const ftype = ret.ftype;
235
+ const fid = ret.fid;
236
+ if (ftype == Thrift.Type.STOP) {
237
+ break;
238
+ }
239
+ switch (fid) {
240
+ case 0:
241
+ if (ftype == Thrift.Type.LIST) {
242
+ this.success = [];
243
+ const _rtmp31 = input.readListBegin();
244
+ const _size0 = _rtmp31.size || 0;
245
+ for (let _i2 = 0; _i2 < _size0; ++_i2) {
246
+ let elem3 = null;
247
+ elem3 = new search_ttypes.SearchResult();
248
+ elem3.read(input);
249
+ this.success.push(elem3);
250
+ }
251
+ input.readListEnd();
252
+ } else {
253
+ input.skip(ftype);
254
+ }
255
+ break;
256
+ case 1:
257
+ if (ftype == Thrift.Type.STRUCT) {
258
+ this.ex = new services_ttypes.ServicesException();
259
+ this.ex.read(input);
260
+ } else {
261
+ input.skip(ftype);
262
+ }
263
+ break;
264
+ default:
265
+ input.skip(ftype);
266
+ }
267
+ input.readFieldEnd();
268
+ }
269
+ input.readStructEnd();
270
+ return;
271
+ }
272
+
273
+ write (output) {
274
+ output.writeStructBegin('ResultsServerService_getSearchResults_result');
275
+ if (this.success !== null && this.success !== undefined) {
276
+ output.writeFieldBegin('success', Thrift.Type.LIST, 0);
277
+ output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
278
+ for (let iter4 in this.success) {
279
+ if (this.success.hasOwnProperty(iter4)) {
280
+ iter4 = this.success[iter4];
281
+ iter4.write(output);
282
+ }
283
+ }
284
+ output.writeListEnd();
285
+ output.writeFieldEnd();
286
+ }
287
+ if (this.ex !== null && this.ex !== undefined) {
288
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
289
+ this.ex.write(output);
290
+ output.writeFieldEnd();
291
+ }
292
+ output.writeFieldStop();
293
+ output.writeStructEnd();
294
+ return;
295
+ }
296
+
297
+ };
298
+ const ResultsServerService_getSearchResultsByUser_args = class {
299
+ constructor(args) {
300
+ this.taskType = null;
301
+ this.userId = null;
302
+ this.limit = null;
303
+ if (args) {
304
+ if (args.taskType !== undefined && args.taskType !== null) {
305
+ this.taskType = args.taskType;
306
+ }
307
+ if (args.userId !== undefined && args.userId !== null) {
308
+ this.userId = args.userId;
309
+ }
310
+ if (args.limit !== undefined && args.limit !== null) {
311
+ this.limit = args.limit;
312
+ }
313
+ }
314
+ }
315
+
316
+ read (input) {
317
+ input.readStructBegin();
318
+ while (true) {
319
+ const ret = input.readFieldBegin();
320
+ const ftype = ret.ftype;
321
+ const fid = ret.fid;
322
+ if (ftype == Thrift.Type.STOP) {
323
+ break;
324
+ }
325
+ switch (fid) {
326
+ case 1:
327
+ if (ftype == Thrift.Type.I32) {
328
+ this.taskType = input.readI32();
329
+ } else {
330
+ input.skip(ftype);
331
+ }
332
+ break;
333
+ case 2:
334
+ if (ftype == Thrift.Type.STRING) {
335
+ this.userId = input.readString();
336
+ } else {
337
+ input.skip(ftype);
338
+ }
339
+ break;
340
+ case 3:
341
+ if (ftype == Thrift.Type.I32) {
342
+ this.limit = input.readI32();
343
+ } else {
344
+ input.skip(ftype);
345
+ }
346
+ break;
347
+ default:
348
+ input.skip(ftype);
349
+ }
350
+ input.readFieldEnd();
351
+ }
352
+ input.readStructEnd();
353
+ return;
354
+ }
355
+
356
+ write (output) {
357
+ output.writeStructBegin('ResultsServerService_getSearchResultsByUser_args');
358
+ if (this.taskType !== null && this.taskType !== undefined) {
359
+ output.writeFieldBegin('taskType', Thrift.Type.I32, 1);
360
+ output.writeI32(this.taskType);
361
+ output.writeFieldEnd();
362
+ }
363
+ if (this.userId !== null && this.userId !== undefined) {
364
+ output.writeFieldBegin('userId', Thrift.Type.STRING, 2);
365
+ output.writeString(this.userId);
366
+ output.writeFieldEnd();
367
+ }
368
+ if (this.limit !== null && this.limit !== undefined) {
369
+ output.writeFieldBegin('limit', Thrift.Type.I32, 3);
370
+ output.writeI32(this.limit);
371
+ output.writeFieldEnd();
372
+ }
373
+ output.writeFieldStop();
374
+ output.writeStructEnd();
375
+ return;
376
+ }
377
+
378
+ };
379
+ const ResultsServerService_getSearchResultsByUser_result = class {
380
+ constructor(args) {
381
+ this.success = null;
382
+ this.ex = null;
383
+ if (args instanceof services_ttypes.ServicesException) {
384
+ this.ex = args;
385
+ return;
386
+ }
387
+ if (args) {
388
+ if (args.success !== undefined && args.success !== null) {
389
+ this.success = Thrift.copyList(args.success, [search_ttypes.SearchResult]);
390
+ }
391
+ if (args.ex !== undefined && args.ex !== null) {
392
+ this.ex = args.ex;
393
+ }
394
+ }
395
+ }
396
+
397
+ read (input) {
398
+ input.readStructBegin();
399
+ while (true) {
400
+ const ret = input.readFieldBegin();
401
+ const ftype = ret.ftype;
402
+ const fid = ret.fid;
403
+ if (ftype == Thrift.Type.STOP) {
404
+ break;
405
+ }
406
+ switch (fid) {
407
+ case 0:
408
+ if (ftype == Thrift.Type.LIST) {
409
+ this.success = [];
410
+ const _rtmp36 = input.readListBegin();
411
+ const _size5 = _rtmp36.size || 0;
412
+ for (let _i7 = 0; _i7 < _size5; ++_i7) {
413
+ let elem8 = null;
414
+ elem8 = new search_ttypes.SearchResult();
415
+ elem8.read(input);
416
+ this.success.push(elem8);
417
+ }
418
+ input.readListEnd();
419
+ } else {
420
+ input.skip(ftype);
421
+ }
422
+ break;
423
+ case 1:
424
+ if (ftype == Thrift.Type.STRUCT) {
425
+ this.ex = new services_ttypes.ServicesException();
426
+ this.ex.read(input);
427
+ } else {
428
+ input.skip(ftype);
429
+ }
430
+ break;
431
+ default:
432
+ input.skip(ftype);
433
+ }
434
+ input.readFieldEnd();
435
+ }
436
+ input.readStructEnd();
437
+ return;
438
+ }
439
+
440
+ write (output) {
441
+ output.writeStructBegin('ResultsServerService_getSearchResultsByUser_result');
442
+ if (this.success !== null && this.success !== undefined) {
443
+ output.writeFieldBegin('success', Thrift.Type.LIST, 0);
444
+ output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
445
+ for (let iter9 in this.success) {
446
+ if (this.success.hasOwnProperty(iter9)) {
447
+ iter9 = this.success[iter9];
448
+ iter9.write(output);
449
+ }
450
+ }
451
+ output.writeListEnd();
452
+ output.writeFieldEnd();
453
+ }
454
+ if (this.ex !== null && this.ex !== undefined) {
455
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
456
+ this.ex.write(output);
457
+ output.writeFieldEnd();
458
+ }
459
+ output.writeFieldStop();
460
+ output.writeStructEnd();
461
+ return;
462
+ }
463
+
464
+ };
465
+ const ResultsServerService_getLatestSearchResult_args = class {
466
+ constructor(args) {
467
+ this.userId = null;
468
+ if (args) {
469
+ if (args.userId !== undefined && args.userId !== null) {
470
+ this.userId = args.userId;
471
+ }
472
+ }
473
+ }
474
+
475
+ read (input) {
476
+ input.readStructBegin();
477
+ while (true) {
478
+ const ret = input.readFieldBegin();
479
+ const ftype = ret.ftype;
480
+ const fid = ret.fid;
481
+ if (ftype == Thrift.Type.STOP) {
482
+ break;
483
+ }
484
+ switch (fid) {
485
+ case 1:
486
+ if (ftype == Thrift.Type.STRING) {
487
+ this.userId = input.readString();
488
+ } else {
489
+ input.skip(ftype);
490
+ }
491
+ break;
492
+ case 0:
493
+ input.skip(ftype);
494
+ break;
495
+ default:
496
+ input.skip(ftype);
497
+ }
498
+ input.readFieldEnd();
499
+ }
500
+ input.readStructEnd();
501
+ return;
502
+ }
503
+
504
+ write (output) {
505
+ output.writeStructBegin('ResultsServerService_getLatestSearchResult_args');
506
+ if (this.userId !== null && this.userId !== undefined) {
507
+ output.writeFieldBegin('userId', Thrift.Type.STRING, 1);
508
+ output.writeString(this.userId);
509
+ output.writeFieldEnd();
510
+ }
511
+ output.writeFieldStop();
512
+ output.writeStructEnd();
513
+ return;
514
+ }
515
+
516
+ };
517
+ const ResultsServerService_getLatestSearchResult_result = class {
518
+ constructor(args) {
519
+ this.success = null;
520
+ this.ex = null;
521
+ if (args instanceof services_ttypes.ServicesException) {
522
+ this.ex = args;
523
+ return;
524
+ }
525
+ if (args) {
526
+ if (args.success !== undefined && args.success !== null) {
527
+ this.success = new search_ttypes.SearchResult(args.success);
528
+ }
529
+ if (args.ex !== undefined && args.ex !== null) {
530
+ this.ex = args.ex;
531
+ }
532
+ }
533
+ }
534
+
535
+ read (input) {
536
+ input.readStructBegin();
537
+ while (true) {
538
+ const ret = input.readFieldBegin();
539
+ const ftype = ret.ftype;
540
+ const fid = ret.fid;
541
+ if (ftype == Thrift.Type.STOP) {
542
+ break;
543
+ }
544
+ switch (fid) {
545
+ case 0:
546
+ if (ftype == Thrift.Type.STRUCT) {
547
+ this.success = new search_ttypes.SearchResult();
548
+ this.success.read(input);
549
+ } else {
550
+ input.skip(ftype);
551
+ }
552
+ break;
553
+ case 1:
554
+ if (ftype == Thrift.Type.STRUCT) {
555
+ this.ex = new services_ttypes.ServicesException();
556
+ this.ex.read(input);
557
+ } else {
558
+ input.skip(ftype);
559
+ }
560
+ break;
561
+ default:
562
+ input.skip(ftype);
563
+ }
564
+ input.readFieldEnd();
565
+ }
566
+ input.readStructEnd();
567
+ return;
568
+ }
569
+
570
+ write (output) {
571
+ output.writeStructBegin('ResultsServerService_getLatestSearchResult_result');
572
+ if (this.success !== null && this.success !== undefined) {
573
+ output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
574
+ this.success.write(output);
575
+ output.writeFieldEnd();
576
+ }
577
+ if (this.ex !== null && this.ex !== undefined) {
578
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
579
+ this.ex.write(output);
580
+ output.writeFieldEnd();
581
+ }
582
+ output.writeFieldStop();
583
+ output.writeStructEnd();
584
+ return;
585
+ }
586
+
587
+ };
588
+ const ResultsServerService_getSearchResult_args = class {
589
+ constructor(args) {
590
+ this.searchResultId = null;
591
+ if (args) {
592
+ if (args.searchResultId !== undefined && args.searchResultId !== null) {
593
+ this.searchResultId = new uuid_ttypes.UUID(args.searchResultId);
594
+ }
595
+ }
596
+ }
597
+
598
+ read (input) {
599
+ input.readStructBegin();
600
+ while (true) {
601
+ const ret = input.readFieldBegin();
602
+ const ftype = ret.ftype;
603
+ const fid = ret.fid;
604
+ if (ftype == Thrift.Type.STOP) {
605
+ break;
606
+ }
607
+ switch (fid) {
608
+ case 1:
609
+ if (ftype == Thrift.Type.STRUCT) {
610
+ this.searchResultId = new uuid_ttypes.UUID();
611
+ this.searchResultId.read(input);
612
+ } else {
613
+ input.skip(ftype);
614
+ }
615
+ break;
616
+ case 0:
617
+ input.skip(ftype);
618
+ break;
619
+ default:
620
+ input.skip(ftype);
621
+ }
622
+ input.readFieldEnd();
623
+ }
624
+ input.readStructEnd();
625
+ return;
626
+ }
627
+
628
+ write (output) {
629
+ output.writeStructBegin('ResultsServerService_getSearchResult_args');
630
+ if (this.searchResultId !== null && this.searchResultId !== undefined) {
631
+ output.writeFieldBegin('searchResultId', Thrift.Type.STRUCT, 1);
632
+ this.searchResultId.write(output);
633
+ output.writeFieldEnd();
634
+ }
635
+ output.writeFieldStop();
636
+ output.writeStructEnd();
637
+ return;
638
+ }
639
+
640
+ };
641
+ const ResultsServerService_getSearchResult_result = class {
642
+ constructor(args) {
643
+ this.success = null;
644
+ this.ex = null;
645
+ if (args instanceof services_ttypes.ServicesException) {
646
+ this.ex = args;
647
+ return;
648
+ }
649
+ if (args) {
650
+ if (args.success !== undefined && args.success !== null) {
651
+ this.success = new search_ttypes.SearchResult(args.success);
652
+ }
653
+ if (args.ex !== undefined && args.ex !== null) {
654
+ this.ex = args.ex;
655
+ }
656
+ }
657
+ }
658
+
659
+ read (input) {
660
+ input.readStructBegin();
661
+ while (true) {
662
+ const ret = input.readFieldBegin();
663
+ const ftype = ret.ftype;
664
+ const fid = ret.fid;
665
+ if (ftype == Thrift.Type.STOP) {
666
+ break;
667
+ }
668
+ switch (fid) {
669
+ case 0:
670
+ if (ftype == Thrift.Type.STRUCT) {
671
+ this.success = new search_ttypes.SearchResult();
672
+ this.success.read(input);
673
+ } else {
674
+ input.skip(ftype);
675
+ }
676
+ break;
677
+ case 1:
678
+ if (ftype == Thrift.Type.STRUCT) {
679
+ this.ex = new services_ttypes.ServicesException();
680
+ this.ex.read(input);
681
+ } else {
682
+ input.skip(ftype);
683
+ }
684
+ break;
685
+ default:
686
+ input.skip(ftype);
687
+ }
688
+ input.readFieldEnd();
689
+ }
690
+ input.readStructEnd();
691
+ return;
692
+ }
693
+
694
+ write (output) {
695
+ output.writeStructBegin('ResultsServerService_getSearchResult_result');
696
+ if (this.success !== null && this.success !== undefined) {
697
+ output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
698
+ this.success.write(output);
699
+ output.writeFieldEnd();
700
+ }
701
+ if (this.ex !== null && this.ex !== undefined) {
702
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
703
+ this.ex.write(output);
704
+ output.writeFieldEnd();
705
+ }
706
+ output.writeFieldStop();
707
+ output.writeStructEnd();
708
+ return;
709
+ }
710
+
711
+ };
712
+ const ResultsServerService_startSession_args = class {
713
+ constructor(args) {
714
+ this.searchResultId = null;
715
+ this.taskType = null;
716
+ if (args) {
717
+ if (args.searchResultId !== undefined && args.searchResultId !== null) {
718
+ this.searchResultId = new uuid_ttypes.UUID(args.searchResultId);
719
+ }
720
+ if (args.taskType !== undefined && args.taskType !== null) {
721
+ this.taskType = args.taskType;
722
+ }
723
+ }
724
+ }
725
+
726
+ read (input) {
727
+ input.readStructBegin();
728
+ while (true) {
729
+ const ret = input.readFieldBegin();
730
+ const ftype = ret.ftype;
731
+ const fid = ret.fid;
732
+ if (ftype == Thrift.Type.STOP) {
733
+ break;
734
+ }
735
+ switch (fid) {
736
+ case 1:
737
+ if (ftype == Thrift.Type.STRUCT) {
738
+ this.searchResultId = new uuid_ttypes.UUID();
739
+ this.searchResultId.read(input);
740
+ } else {
741
+ input.skip(ftype);
742
+ }
743
+ break;
744
+ case 2:
745
+ if (ftype == Thrift.Type.I32) {
746
+ this.taskType = input.readI32();
747
+ } else {
748
+ input.skip(ftype);
749
+ }
750
+ break;
751
+ default:
752
+ input.skip(ftype);
753
+ }
754
+ input.readFieldEnd();
755
+ }
756
+ input.readStructEnd();
757
+ return;
758
+ }
759
+
760
+ write (output) {
761
+ output.writeStructBegin('ResultsServerService_startSession_args');
762
+ if (this.searchResultId !== null && this.searchResultId !== undefined) {
763
+ output.writeFieldBegin('searchResultId', Thrift.Type.STRUCT, 1);
764
+ this.searchResultId.write(output);
765
+ output.writeFieldEnd();
766
+ }
767
+ if (this.taskType !== null && this.taskType !== undefined) {
768
+ output.writeFieldBegin('taskType', Thrift.Type.I32, 2);
769
+ output.writeI32(this.taskType);
770
+ output.writeFieldEnd();
771
+ }
772
+ output.writeFieldStop();
773
+ output.writeStructEnd();
774
+ return;
775
+ }
776
+
777
+ };
778
+ const ResultsServerService_startSession_result = class {
779
+ constructor(args) {
780
+ this.success = null;
781
+ this.ex = null;
782
+ if (args instanceof services_ttypes.ServicesException) {
783
+ this.ex = args;
784
+ return;
785
+ }
786
+ if (args) {
787
+ if (args.success !== undefined && args.success !== null) {
788
+ this.success = new uuid_ttypes.UUID(args.success);
789
+ }
790
+ if (args.ex !== undefined && args.ex !== null) {
791
+ this.ex = args.ex;
792
+ }
793
+ }
794
+ }
795
+
796
+ read (input) {
797
+ input.readStructBegin();
798
+ while (true) {
799
+ const ret = input.readFieldBegin();
800
+ const ftype = ret.ftype;
801
+ const fid = ret.fid;
802
+ if (ftype == Thrift.Type.STOP) {
803
+ break;
804
+ }
805
+ switch (fid) {
806
+ case 0:
807
+ if (ftype == Thrift.Type.STRUCT) {
808
+ this.success = new uuid_ttypes.UUID();
809
+ this.success.read(input);
810
+ } else {
811
+ input.skip(ftype);
812
+ }
813
+ break;
814
+ case 1:
815
+ if (ftype == Thrift.Type.STRUCT) {
816
+ this.ex = new services_ttypes.ServicesException();
817
+ this.ex.read(input);
818
+ } else {
819
+ input.skip(ftype);
820
+ }
821
+ break;
822
+ default:
823
+ input.skip(ftype);
824
+ }
825
+ input.readFieldEnd();
826
+ }
827
+ input.readStructEnd();
828
+ return;
829
+ }
830
+
831
+ write (output) {
832
+ output.writeStructBegin('ResultsServerService_startSession_result');
833
+ if (this.success !== null && this.success !== undefined) {
834
+ output.writeFieldBegin('success', Thrift.Type.STRUCT, 0);
835
+ this.success.write(output);
836
+ output.writeFieldEnd();
837
+ }
838
+ if (this.ex !== null && this.ex !== undefined) {
839
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
840
+ this.ex.write(output);
841
+ output.writeFieldEnd();
842
+ }
843
+ output.writeFieldStop();
844
+ output.writeStructEnd();
845
+ return;
846
+ }
847
+
848
+ };
849
+ const ResultsServerService_stopSession_args = class {
850
+ constructor(args) {
851
+ this.sessionId = null;
852
+ if (args) {
853
+ if (args.sessionId !== undefined && args.sessionId !== null) {
854
+ this.sessionId = new uuid_ttypes.UUID(args.sessionId);
855
+ }
856
+ }
857
+ }
858
+
859
+ read (input) {
860
+ input.readStructBegin();
861
+ while (true) {
862
+ const ret = input.readFieldBegin();
863
+ const ftype = ret.ftype;
864
+ const fid = ret.fid;
865
+ if (ftype == Thrift.Type.STOP) {
866
+ break;
867
+ }
868
+ switch (fid) {
869
+ case 1:
870
+ if (ftype == Thrift.Type.STRUCT) {
871
+ this.sessionId = new uuid_ttypes.UUID();
872
+ this.sessionId.read(input);
873
+ } else {
874
+ input.skip(ftype);
875
+ }
876
+ break;
877
+ case 0:
878
+ input.skip(ftype);
879
+ break;
880
+ default:
881
+ input.skip(ftype);
882
+ }
883
+ input.readFieldEnd();
884
+ }
885
+ input.readStructEnd();
886
+ return;
887
+ }
888
+
889
+ write (output) {
890
+ output.writeStructBegin('ResultsServerService_stopSession_args');
891
+ if (this.sessionId !== null && this.sessionId !== undefined) {
892
+ output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
893
+ this.sessionId.write(output);
894
+ output.writeFieldEnd();
895
+ }
896
+ output.writeFieldStop();
897
+ output.writeStructEnd();
898
+ return;
899
+ }
900
+
901
+ };
902
+ const ResultsServerService_stopSession_result = class {
903
+ constructor(args) {
904
+ this.ex = null;
905
+ if (args instanceof services_ttypes.ServicesException) {
906
+ this.ex = args;
907
+ return;
908
+ }
909
+ if (args) {
910
+ if (args.ex !== undefined && args.ex !== null) {
911
+ this.ex = args.ex;
912
+ }
913
+ }
914
+ }
915
+
916
+ read (input) {
917
+ input.readStructBegin();
918
+ while (true) {
919
+ const ret = input.readFieldBegin();
920
+ const ftype = ret.ftype;
921
+ const fid = ret.fid;
922
+ if (ftype == Thrift.Type.STOP) {
923
+ break;
924
+ }
925
+ switch (fid) {
926
+ case 1:
927
+ if (ftype == Thrift.Type.STRUCT) {
928
+ this.ex = new services_ttypes.ServicesException();
929
+ this.ex.read(input);
930
+ } else {
931
+ input.skip(ftype);
932
+ }
933
+ break;
934
+ case 0:
935
+ input.skip(ftype);
936
+ break;
937
+ default:
938
+ input.skip(ftype);
939
+ }
940
+ input.readFieldEnd();
941
+ }
942
+ input.readStructEnd();
943
+ return;
944
+ }
945
+
946
+ write (output) {
947
+ output.writeStructBegin('ResultsServerService_stopSession_result');
948
+ if (this.ex !== null && this.ex !== undefined) {
949
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
950
+ this.ex.write(output);
951
+ output.writeFieldEnd();
952
+ }
953
+ output.writeFieldStop();
954
+ output.writeStructEnd();
955
+ return;
956
+ }
957
+
958
+ };
959
+ const ResultsServerService_getNextChunk_args = class {
960
+ constructor(args) {
961
+ this.sessionId = null;
962
+ if (args) {
963
+ if (args.sessionId !== undefined && args.sessionId !== null) {
964
+ this.sessionId = new uuid_ttypes.UUID(args.sessionId);
965
+ }
966
+ }
967
+ }
968
+
969
+ read (input) {
970
+ input.readStructBegin();
971
+ while (true) {
972
+ const ret = input.readFieldBegin();
973
+ const ftype = ret.ftype;
974
+ const fid = ret.fid;
975
+ if (ftype == Thrift.Type.STOP) {
976
+ break;
977
+ }
978
+ switch (fid) {
979
+ case 1:
980
+ if (ftype == Thrift.Type.STRUCT) {
981
+ this.sessionId = new uuid_ttypes.UUID();
982
+ this.sessionId.read(input);
983
+ } else {
984
+ input.skip(ftype);
985
+ }
986
+ break;
987
+ case 0:
988
+ input.skip(ftype);
989
+ break;
990
+ default:
991
+ input.skip(ftype);
992
+ }
993
+ input.readFieldEnd();
994
+ }
995
+ input.readStructEnd();
996
+ return;
997
+ }
998
+
999
+ write (output) {
1000
+ output.writeStructBegin('ResultsServerService_getNextChunk_args');
1001
+ if (this.sessionId !== null && this.sessionId !== undefined) {
1002
+ output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
1003
+ this.sessionId.write(output);
1004
+ output.writeFieldEnd();
1005
+ }
1006
+ output.writeFieldStop();
1007
+ output.writeStructEnd();
1008
+ return;
1009
+ }
1010
+
1011
+ };
1012
+ const ResultsServerService_getNextChunk_result = class {
1013
+ constructor(args) {
1014
+ this.success = null;
1015
+ this.ex = null;
1016
+ if (args instanceof services_ttypes.ServicesException) {
1017
+ this.ex = args;
1018
+ return;
1019
+ }
1020
+ if (args) {
1021
+ if (args.success !== undefined && args.success !== null) {
1022
+ this.success = Thrift.copyList(args.success, [services_ttypes.AnnotationUnitIdentifier]);
1023
+ }
1024
+ if (args.ex !== undefined && args.ex !== null) {
1025
+ this.ex = args.ex;
1026
+ }
1027
+ }
1028
+ }
1029
+
1030
+ read (input) {
1031
+ input.readStructBegin();
1032
+ while (true) {
1033
+ const ret = input.readFieldBegin();
1034
+ const ftype = ret.ftype;
1035
+ const fid = ret.fid;
1036
+ if (ftype == Thrift.Type.STOP) {
1037
+ break;
1038
+ }
1039
+ switch (fid) {
1040
+ case 0:
1041
+ if (ftype == Thrift.Type.LIST) {
1042
+ this.success = [];
1043
+ const _rtmp311 = input.readListBegin();
1044
+ const _size10 = _rtmp311.size || 0;
1045
+ for (let _i12 = 0; _i12 < _size10; ++_i12) {
1046
+ let elem13 = null;
1047
+ elem13 = new services_ttypes.AnnotationUnitIdentifier();
1048
+ elem13.read(input);
1049
+ this.success.push(elem13);
1050
+ }
1051
+ input.readListEnd();
1052
+ } else {
1053
+ input.skip(ftype);
1054
+ }
1055
+ break;
1056
+ case 1:
1057
+ if (ftype == Thrift.Type.STRUCT) {
1058
+ this.ex = new services_ttypes.ServicesException();
1059
+ this.ex.read(input);
1060
+ } else {
1061
+ input.skip(ftype);
1062
+ }
1063
+ break;
1064
+ default:
1065
+ input.skip(ftype);
1066
+ }
1067
+ input.readFieldEnd();
1068
+ }
1069
+ input.readStructEnd();
1070
+ return;
1071
+ }
1072
+
1073
+ write (output) {
1074
+ output.writeStructBegin('ResultsServerService_getNextChunk_result');
1075
+ if (this.success !== null && this.success !== undefined) {
1076
+ output.writeFieldBegin('success', Thrift.Type.LIST, 0);
1077
+ output.writeListBegin(Thrift.Type.STRUCT, this.success.length);
1078
+ for (let iter14 in this.success) {
1079
+ if (this.success.hasOwnProperty(iter14)) {
1080
+ iter14 = this.success[iter14];
1081
+ iter14.write(output);
1082
+ }
1083
+ }
1084
+ output.writeListEnd();
1085
+ output.writeFieldEnd();
1086
+ }
1087
+ if (this.ex !== null && this.ex !== undefined) {
1088
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
1089
+ this.ex.write(output);
1090
+ output.writeFieldEnd();
1091
+ }
1092
+ output.writeFieldStop();
1093
+ output.writeStructEnd();
1094
+ return;
1095
+ }
1096
+
1097
+ };
1098
+ const ResultsServerService_submitAnnotation_args = class {
1099
+ constructor(args) {
1100
+ this.sessionId = null;
1101
+ this.unitId = null;
1102
+ this.communication = null;
1103
+ if (args) {
1104
+ if (args.sessionId !== undefined && args.sessionId !== null) {
1105
+ this.sessionId = new uuid_ttypes.UUID(args.sessionId);
1106
+ }
1107
+ if (args.unitId !== undefined && args.unitId !== null) {
1108
+ this.unitId = new services_ttypes.AnnotationUnitIdentifier(args.unitId);
1109
+ }
1110
+ if (args.communication !== undefined && args.communication !== null) {
1111
+ this.communication = new communication_ttypes.Communication(args.communication);
1112
+ }
1113
+ }
1114
+ }
1115
+
1116
+ read (input) {
1117
+ input.readStructBegin();
1118
+ while (true) {
1119
+ const ret = input.readFieldBegin();
1120
+ const ftype = ret.ftype;
1121
+ const fid = ret.fid;
1122
+ if (ftype == Thrift.Type.STOP) {
1123
+ break;
1124
+ }
1125
+ switch (fid) {
1126
+ case 1:
1127
+ if (ftype == Thrift.Type.STRUCT) {
1128
+ this.sessionId = new uuid_ttypes.UUID();
1129
+ this.sessionId.read(input);
1130
+ } else {
1131
+ input.skip(ftype);
1132
+ }
1133
+ break;
1134
+ case 2:
1135
+ if (ftype == Thrift.Type.STRUCT) {
1136
+ this.unitId = new services_ttypes.AnnotationUnitIdentifier();
1137
+ this.unitId.read(input);
1138
+ } else {
1139
+ input.skip(ftype);
1140
+ }
1141
+ break;
1142
+ case 3:
1143
+ if (ftype == Thrift.Type.STRUCT) {
1144
+ this.communication = new communication_ttypes.Communication();
1145
+ this.communication.read(input);
1146
+ } else {
1147
+ input.skip(ftype);
1148
+ }
1149
+ break;
1150
+ default:
1151
+ input.skip(ftype);
1152
+ }
1153
+ input.readFieldEnd();
1154
+ }
1155
+ input.readStructEnd();
1156
+ return;
1157
+ }
1158
+
1159
+ write (output) {
1160
+ output.writeStructBegin('ResultsServerService_submitAnnotation_args');
1161
+ if (this.sessionId !== null && this.sessionId !== undefined) {
1162
+ output.writeFieldBegin('sessionId', Thrift.Type.STRUCT, 1);
1163
+ this.sessionId.write(output);
1164
+ output.writeFieldEnd();
1165
+ }
1166
+ if (this.unitId !== null && this.unitId !== undefined) {
1167
+ output.writeFieldBegin('unitId', Thrift.Type.STRUCT, 2);
1168
+ this.unitId.write(output);
1169
+ output.writeFieldEnd();
1170
+ }
1171
+ if (this.communication !== null && this.communication !== undefined) {
1172
+ output.writeFieldBegin('communication', Thrift.Type.STRUCT, 3);
1173
+ this.communication.write(output);
1174
+ output.writeFieldEnd();
1175
+ }
1176
+ output.writeFieldStop();
1177
+ output.writeStructEnd();
1178
+ return;
1179
+ }
1180
+
1181
+ };
1182
+ const ResultsServerService_submitAnnotation_result = class {
1183
+ constructor(args) {
1184
+ this.ex = null;
1185
+ if (args instanceof services_ttypes.ServicesException) {
1186
+ this.ex = args;
1187
+ return;
1188
+ }
1189
+ if (args) {
1190
+ if (args.ex !== undefined && args.ex !== null) {
1191
+ this.ex = args.ex;
1192
+ }
1193
+ }
1194
+ }
1195
+
1196
+ read (input) {
1197
+ input.readStructBegin();
1198
+ while (true) {
1199
+ const ret = input.readFieldBegin();
1200
+ const ftype = ret.ftype;
1201
+ const fid = ret.fid;
1202
+ if (ftype == Thrift.Type.STOP) {
1203
+ break;
1204
+ }
1205
+ switch (fid) {
1206
+ case 1:
1207
+ if (ftype == Thrift.Type.STRUCT) {
1208
+ this.ex = new services_ttypes.ServicesException();
1209
+ this.ex.read(input);
1210
+ } else {
1211
+ input.skip(ftype);
1212
+ }
1213
+ break;
1214
+ case 0:
1215
+ input.skip(ftype);
1216
+ break;
1217
+ default:
1218
+ input.skip(ftype);
1219
+ }
1220
+ input.readFieldEnd();
1221
+ }
1222
+ input.readStructEnd();
1223
+ return;
1224
+ }
1225
+
1226
+ write (output) {
1227
+ output.writeStructBegin('ResultsServerService_submitAnnotation_result');
1228
+ if (this.ex !== null && this.ex !== undefined) {
1229
+ output.writeFieldBegin('ex', Thrift.Type.STRUCT, 1);
1230
+ this.ex.write(output);
1231
+ output.writeFieldEnd();
1232
+ }
1233
+ output.writeFieldStop();
1234
+ output.writeStructEnd();
1235
+ return;
1236
+ }
1237
+
1238
+ };
1239
+ const ResultsServerServiceClient = exports.Client = class ResultsServerServiceClient extends ServiceClient {
1240
+ constructor(output, pClass) {
1241
+ super(output, pClass);
1242
+ this.output = output;
1243
+ this.pClass = pClass;
1244
+ this._seqid = 0;
1245
+ this._reqs = {};
1246
+ }
1247
+ seqid () { return this._seqid; }
1248
+ new_seqid () { return this._seqid += 1; }
1249
+
1250
+ registerSearchResult (result, taskType) {
1251
+ this._seqid = this.new_seqid();
1252
+ const self = this;
1253
+ return new Promise((resolve, reject) => {
1254
+ self._reqs[self.seqid()] = (error, result) => {
1255
+ return error ? reject(error) : resolve(result);
1256
+ };
1257
+ self.send_registerSearchResult(result, taskType);
1258
+ });
1259
+ }
1260
+
1261
+ send_registerSearchResult (result, taskType) {
1262
+ const output = new this.pClass(this.output);
1263
+ const params = {
1264
+ result: result,
1265
+ taskType: taskType
1266
+ };
1267
+ const args = new ResultsServerService_registerSearchResult_args(params);
1268
+ try {
1269
+ output.writeMessageBegin('registerSearchResult', Thrift.MessageType.CALL, this.seqid());
1270
+ args.write(output);
1271
+ output.writeMessageEnd();
1272
+ return this.output.flush();
1273
+ }
1274
+ catch (e) {
1275
+ delete this._reqs[this.seqid()];
1276
+ if (typeof output.reset === 'function') {
1277
+ output.reset();
1278
+ }
1279
+ throw e;
1280
+ }
1281
+ }
1282
+
1283
+ recv_registerSearchResult (input, mtype, rseqid) {
1284
+ const callback = this._reqs[rseqid] || function() {};
1285
+ delete this._reqs[rseqid];
1286
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1287
+ const x = new Thrift.TApplicationException();
1288
+ x.read(input);
1289
+ input.readMessageEnd();
1290
+ return callback(x);
1291
+ }
1292
+ const result = new ResultsServerService_registerSearchResult_result();
1293
+ result.read(input);
1294
+ input.readMessageEnd();
1295
+
1296
+ if (null !== result.ex) {
1297
+ return callback(result.ex);
1298
+ }
1299
+ callback(null);
1300
+ }
1301
+
1302
+ getSearchResults (taskType, limit) {
1303
+ this._seqid = this.new_seqid();
1304
+ const self = this;
1305
+ return new Promise((resolve, reject) => {
1306
+ self._reqs[self.seqid()] = (error, result) => {
1307
+ return error ? reject(error) : resolve(result);
1308
+ };
1309
+ self.send_getSearchResults(taskType, limit);
1310
+ });
1311
+ }
1312
+
1313
+ send_getSearchResults (taskType, limit) {
1314
+ const output = new this.pClass(this.output);
1315
+ const params = {
1316
+ taskType: taskType,
1317
+ limit: limit
1318
+ };
1319
+ const args = new ResultsServerService_getSearchResults_args(params);
1320
+ try {
1321
+ output.writeMessageBegin('getSearchResults', Thrift.MessageType.CALL, this.seqid());
1322
+ args.write(output);
1323
+ output.writeMessageEnd();
1324
+ return this.output.flush();
1325
+ }
1326
+ catch (e) {
1327
+ delete this._reqs[this.seqid()];
1328
+ if (typeof output.reset === 'function') {
1329
+ output.reset();
1330
+ }
1331
+ throw e;
1332
+ }
1333
+ }
1334
+
1335
+ recv_getSearchResults (input, mtype, rseqid) {
1336
+ const callback = this._reqs[rseqid] || function() {};
1337
+ delete this._reqs[rseqid];
1338
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1339
+ const x = new Thrift.TApplicationException();
1340
+ x.read(input);
1341
+ input.readMessageEnd();
1342
+ return callback(x);
1343
+ }
1344
+ const result = new ResultsServerService_getSearchResults_result();
1345
+ result.read(input);
1346
+ input.readMessageEnd();
1347
+
1348
+ if (null !== result.ex) {
1349
+ return callback(result.ex);
1350
+ }
1351
+ if (null !== result.success) {
1352
+ return callback(null, result.success);
1353
+ }
1354
+ return callback('getSearchResults failed: unknown result');
1355
+ }
1356
+
1357
+ getSearchResultsByUser (taskType, userId, limit) {
1358
+ this._seqid = this.new_seqid();
1359
+ const self = this;
1360
+ return new Promise((resolve, reject) => {
1361
+ self._reqs[self.seqid()] = (error, result) => {
1362
+ return error ? reject(error) : resolve(result);
1363
+ };
1364
+ self.send_getSearchResultsByUser(taskType, userId, limit);
1365
+ });
1366
+ }
1367
+
1368
+ send_getSearchResultsByUser (taskType, userId, limit) {
1369
+ const output = new this.pClass(this.output);
1370
+ const params = {
1371
+ taskType: taskType,
1372
+ userId: userId,
1373
+ limit: limit
1374
+ };
1375
+ const args = new ResultsServerService_getSearchResultsByUser_args(params);
1376
+ try {
1377
+ output.writeMessageBegin('getSearchResultsByUser', Thrift.MessageType.CALL, this.seqid());
1378
+ args.write(output);
1379
+ output.writeMessageEnd();
1380
+ return this.output.flush();
1381
+ }
1382
+ catch (e) {
1383
+ delete this._reqs[this.seqid()];
1384
+ if (typeof output.reset === 'function') {
1385
+ output.reset();
1386
+ }
1387
+ throw e;
1388
+ }
1389
+ }
1390
+
1391
+ recv_getSearchResultsByUser (input, mtype, rseqid) {
1392
+ const callback = this._reqs[rseqid] || function() {};
1393
+ delete this._reqs[rseqid];
1394
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1395
+ const x = new Thrift.TApplicationException();
1396
+ x.read(input);
1397
+ input.readMessageEnd();
1398
+ return callback(x);
1399
+ }
1400
+ const result = new ResultsServerService_getSearchResultsByUser_result();
1401
+ result.read(input);
1402
+ input.readMessageEnd();
1403
+
1404
+ if (null !== result.ex) {
1405
+ return callback(result.ex);
1406
+ }
1407
+ if (null !== result.success) {
1408
+ return callback(null, result.success);
1409
+ }
1410
+ return callback('getSearchResultsByUser failed: unknown result');
1411
+ }
1412
+
1413
+ getLatestSearchResult (userId) {
1414
+ this._seqid = this.new_seqid();
1415
+ const self = this;
1416
+ return new Promise((resolve, reject) => {
1417
+ self._reqs[self.seqid()] = (error, result) => {
1418
+ return error ? reject(error) : resolve(result);
1419
+ };
1420
+ self.send_getLatestSearchResult(userId);
1421
+ });
1422
+ }
1423
+
1424
+ send_getLatestSearchResult (userId) {
1425
+ const output = new this.pClass(this.output);
1426
+ const params = {
1427
+ userId: userId
1428
+ };
1429
+ const args = new ResultsServerService_getLatestSearchResult_args(params);
1430
+ try {
1431
+ output.writeMessageBegin('getLatestSearchResult', Thrift.MessageType.CALL, this.seqid());
1432
+ args.write(output);
1433
+ output.writeMessageEnd();
1434
+ return this.output.flush();
1435
+ }
1436
+ catch (e) {
1437
+ delete this._reqs[this.seqid()];
1438
+ if (typeof output.reset === 'function') {
1439
+ output.reset();
1440
+ }
1441
+ throw e;
1442
+ }
1443
+ }
1444
+
1445
+ recv_getLatestSearchResult (input, mtype, rseqid) {
1446
+ const callback = this._reqs[rseqid] || function() {};
1447
+ delete this._reqs[rseqid];
1448
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1449
+ const x = new Thrift.TApplicationException();
1450
+ x.read(input);
1451
+ input.readMessageEnd();
1452
+ return callback(x);
1453
+ }
1454
+ const result = new ResultsServerService_getLatestSearchResult_result();
1455
+ result.read(input);
1456
+ input.readMessageEnd();
1457
+
1458
+ if (null !== result.ex) {
1459
+ return callback(result.ex);
1460
+ }
1461
+ if (null !== result.success) {
1462
+ return callback(null, result.success);
1463
+ }
1464
+ return callback('getLatestSearchResult failed: unknown result');
1465
+ }
1466
+
1467
+ getSearchResult (searchResultId) {
1468
+ this._seqid = this.new_seqid();
1469
+ const self = this;
1470
+ return new Promise((resolve, reject) => {
1471
+ self._reqs[self.seqid()] = (error, result) => {
1472
+ return error ? reject(error) : resolve(result);
1473
+ };
1474
+ self.send_getSearchResult(searchResultId);
1475
+ });
1476
+ }
1477
+
1478
+ send_getSearchResult (searchResultId) {
1479
+ const output = new this.pClass(this.output);
1480
+ const params = {
1481
+ searchResultId: searchResultId
1482
+ };
1483
+ const args = new ResultsServerService_getSearchResult_args(params);
1484
+ try {
1485
+ output.writeMessageBegin('getSearchResult', Thrift.MessageType.CALL, this.seqid());
1486
+ args.write(output);
1487
+ output.writeMessageEnd();
1488
+ return this.output.flush();
1489
+ }
1490
+ catch (e) {
1491
+ delete this._reqs[this.seqid()];
1492
+ if (typeof output.reset === 'function') {
1493
+ output.reset();
1494
+ }
1495
+ throw e;
1496
+ }
1497
+ }
1498
+
1499
+ recv_getSearchResult (input, mtype, rseqid) {
1500
+ const callback = this._reqs[rseqid] || function() {};
1501
+ delete this._reqs[rseqid];
1502
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1503
+ const x = new Thrift.TApplicationException();
1504
+ x.read(input);
1505
+ input.readMessageEnd();
1506
+ return callback(x);
1507
+ }
1508
+ const result = new ResultsServerService_getSearchResult_result();
1509
+ result.read(input);
1510
+ input.readMessageEnd();
1511
+
1512
+ if (null !== result.ex) {
1513
+ return callback(result.ex);
1514
+ }
1515
+ if (null !== result.success) {
1516
+ return callback(null, result.success);
1517
+ }
1518
+ return callback('getSearchResult failed: unknown result');
1519
+ }
1520
+
1521
+ startSession (searchResultId, taskType) {
1522
+ this._seqid = this.new_seqid();
1523
+ const self = this;
1524
+ return new Promise((resolve, reject) => {
1525
+ self._reqs[self.seqid()] = (error, result) => {
1526
+ return error ? reject(error) : resolve(result);
1527
+ };
1528
+ self.send_startSession(searchResultId, taskType);
1529
+ });
1530
+ }
1531
+
1532
+ send_startSession (searchResultId, taskType) {
1533
+ const output = new this.pClass(this.output);
1534
+ const params = {
1535
+ searchResultId: searchResultId,
1536
+ taskType: taskType
1537
+ };
1538
+ const args = new ResultsServerService_startSession_args(params);
1539
+ try {
1540
+ output.writeMessageBegin('startSession', Thrift.MessageType.CALL, this.seqid());
1541
+ args.write(output);
1542
+ output.writeMessageEnd();
1543
+ return this.output.flush();
1544
+ }
1545
+ catch (e) {
1546
+ delete this._reqs[this.seqid()];
1547
+ if (typeof output.reset === 'function') {
1548
+ output.reset();
1549
+ }
1550
+ throw e;
1551
+ }
1552
+ }
1553
+
1554
+ recv_startSession (input, mtype, rseqid) {
1555
+ const callback = this._reqs[rseqid] || function() {};
1556
+ delete this._reqs[rseqid];
1557
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1558
+ const x = new Thrift.TApplicationException();
1559
+ x.read(input);
1560
+ input.readMessageEnd();
1561
+ return callback(x);
1562
+ }
1563
+ const result = new ResultsServerService_startSession_result();
1564
+ result.read(input);
1565
+ input.readMessageEnd();
1566
+
1567
+ if (null !== result.ex) {
1568
+ return callback(result.ex);
1569
+ }
1570
+ if (null !== result.success) {
1571
+ return callback(null, result.success);
1572
+ }
1573
+ return callback('startSession failed: unknown result');
1574
+ }
1575
+
1576
+ stopSession (sessionId) {
1577
+ this._seqid = this.new_seqid();
1578
+ const self = this;
1579
+ return new Promise((resolve, reject) => {
1580
+ self._reqs[self.seqid()] = (error, result) => {
1581
+ return error ? reject(error) : resolve(result);
1582
+ };
1583
+ self.send_stopSession(sessionId);
1584
+ });
1585
+ }
1586
+
1587
+ send_stopSession (sessionId) {
1588
+ const output = new this.pClass(this.output);
1589
+ const params = {
1590
+ sessionId: sessionId
1591
+ };
1592
+ const args = new ResultsServerService_stopSession_args(params);
1593
+ try {
1594
+ output.writeMessageBegin('stopSession', Thrift.MessageType.CALL, this.seqid());
1595
+ args.write(output);
1596
+ output.writeMessageEnd();
1597
+ return this.output.flush();
1598
+ }
1599
+ catch (e) {
1600
+ delete this._reqs[this.seqid()];
1601
+ if (typeof output.reset === 'function') {
1602
+ output.reset();
1603
+ }
1604
+ throw e;
1605
+ }
1606
+ }
1607
+
1608
+ recv_stopSession (input, mtype, rseqid) {
1609
+ const callback = this._reqs[rseqid] || function() {};
1610
+ delete this._reqs[rseqid];
1611
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1612
+ const x = new Thrift.TApplicationException();
1613
+ x.read(input);
1614
+ input.readMessageEnd();
1615
+ return callback(x);
1616
+ }
1617
+ const result = new ResultsServerService_stopSession_result();
1618
+ result.read(input);
1619
+ input.readMessageEnd();
1620
+
1621
+ if (null !== result.ex) {
1622
+ return callback(result.ex);
1623
+ }
1624
+ callback(null);
1625
+ }
1626
+
1627
+ getNextChunk (sessionId) {
1628
+ this._seqid = this.new_seqid();
1629
+ const self = this;
1630
+ return new Promise((resolve, reject) => {
1631
+ self._reqs[self.seqid()] = (error, result) => {
1632
+ return error ? reject(error) : resolve(result);
1633
+ };
1634
+ self.send_getNextChunk(sessionId);
1635
+ });
1636
+ }
1637
+
1638
+ send_getNextChunk (sessionId) {
1639
+ const output = new this.pClass(this.output);
1640
+ const params = {
1641
+ sessionId: sessionId
1642
+ };
1643
+ const args = new ResultsServerService_getNextChunk_args(params);
1644
+ try {
1645
+ output.writeMessageBegin('getNextChunk', Thrift.MessageType.CALL, this.seqid());
1646
+ args.write(output);
1647
+ output.writeMessageEnd();
1648
+ return this.output.flush();
1649
+ }
1650
+ catch (e) {
1651
+ delete this._reqs[this.seqid()];
1652
+ if (typeof output.reset === 'function') {
1653
+ output.reset();
1654
+ }
1655
+ throw e;
1656
+ }
1657
+ }
1658
+
1659
+ recv_getNextChunk (input, mtype, rseqid) {
1660
+ const callback = this._reqs[rseqid] || function() {};
1661
+ delete this._reqs[rseqid];
1662
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1663
+ const x = new Thrift.TApplicationException();
1664
+ x.read(input);
1665
+ input.readMessageEnd();
1666
+ return callback(x);
1667
+ }
1668
+ const result = new ResultsServerService_getNextChunk_result();
1669
+ result.read(input);
1670
+ input.readMessageEnd();
1671
+
1672
+ if (null !== result.ex) {
1673
+ return callback(result.ex);
1674
+ }
1675
+ if (null !== result.success) {
1676
+ return callback(null, result.success);
1677
+ }
1678
+ return callback('getNextChunk failed: unknown result');
1679
+ }
1680
+
1681
+ submitAnnotation (sessionId, unitId, communication) {
1682
+ this._seqid = this.new_seqid();
1683
+ const self = this;
1684
+ return new Promise((resolve, reject) => {
1685
+ self._reqs[self.seqid()] = (error, result) => {
1686
+ return error ? reject(error) : resolve(result);
1687
+ };
1688
+ self.send_submitAnnotation(sessionId, unitId, communication);
1689
+ });
1690
+ }
1691
+
1692
+ send_submitAnnotation (sessionId, unitId, communication) {
1693
+ const output = new this.pClass(this.output);
1694
+ const params = {
1695
+ sessionId: sessionId,
1696
+ unitId: unitId,
1697
+ communication: communication
1698
+ };
1699
+ const args = new ResultsServerService_submitAnnotation_args(params);
1700
+ try {
1701
+ output.writeMessageBegin('submitAnnotation', Thrift.MessageType.CALL, this.seqid());
1702
+ args.write(output);
1703
+ output.writeMessageEnd();
1704
+ return this.output.flush();
1705
+ }
1706
+ catch (e) {
1707
+ delete this._reqs[this.seqid()];
1708
+ if (typeof output.reset === 'function') {
1709
+ output.reset();
1710
+ }
1711
+ throw e;
1712
+ }
1713
+ }
1714
+
1715
+ recv_submitAnnotation (input, mtype, rseqid) {
1716
+ const callback = this._reqs[rseqid] || function() {};
1717
+ delete this._reqs[rseqid];
1718
+ if (mtype == Thrift.MessageType.EXCEPTION) {
1719
+ const x = new Thrift.TApplicationException();
1720
+ x.read(input);
1721
+ input.readMessageEnd();
1722
+ return callback(x);
1723
+ }
1724
+ const result = new ResultsServerService_submitAnnotation_result();
1725
+ result.read(input);
1726
+ input.readMessageEnd();
1727
+
1728
+ if (null !== result.ex) {
1729
+ return callback(result.ex);
1730
+ }
1731
+ callback(null);
1732
+ }
1733
+ };
1734
+ const ResultsServerServiceProcessor = exports.Processor = class ResultsServerServiceProcessor extends ServiceProcessor {
1735
+ constructor(handler) {
1736
+ super(handler);
1737
+ this._handler = handler;
1738
+ }
1739
+ process (input, output) {
1740
+ const r = input.readMessageBegin();
1741
+ if (this['process_' + r.fname]) {
1742
+ return this['process_' + r.fname].call(this, r.rseqid, input, output);
1743
+ } else {
1744
+ input.skip(Thrift.Type.STRUCT);
1745
+ input.readMessageEnd();
1746
+ const x = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN_METHOD, 'Unknown function ' + r.fname);
1747
+ output.writeMessageBegin(r.fname, Thrift.MessageType.EXCEPTION, r.rseqid);
1748
+ x.write(output);
1749
+ output.writeMessageEnd();
1750
+ output.flush();
1751
+ }
1752
+ }
1753
+ process_registerSearchResult (seqid, input, output) {
1754
+ const args = new ResultsServerService_registerSearchResult_args();
1755
+ args.read(input);
1756
+ input.readMessageEnd();
1757
+ if (this._handler.registerSearchResult.length === 2) {
1758
+ Promise.resolve(this._handler.registerSearchResult.bind(this._handler)(
1759
+ args.result,
1760
+ args.taskType
1761
+ )).then(result => {
1762
+ const result_obj = new ResultsServerService_registerSearchResult_result({success: result});
1763
+ output.writeMessageBegin("registerSearchResult", Thrift.MessageType.REPLY, seqid);
1764
+ result_obj.write(output);
1765
+ output.writeMessageEnd();
1766
+ output.flush();
1767
+ }).catch(err => {
1768
+ let result;
1769
+ if (err instanceof services_ttypes.ServicesException) {
1770
+ result = new ResultsServerService_registerSearchResult_result(err);
1771
+ output.writeMessageBegin("registerSearchResult", Thrift.MessageType.REPLY, seqid);
1772
+ } else {
1773
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1774
+ output.writeMessageBegin("registerSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1775
+ }
1776
+ result.write(output);
1777
+ output.writeMessageEnd();
1778
+ output.flush();
1779
+ });
1780
+ } else {
1781
+ this._handler.registerSearchResult(args.result, args.taskType, (err, result) => {
1782
+ let result_obj;
1783
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1784
+ result_obj = new ResultsServerService_registerSearchResult_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1785
+ output.writeMessageBegin("registerSearchResult", Thrift.MessageType.REPLY, seqid);
1786
+ } else {
1787
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1788
+ output.writeMessageBegin("registerSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1789
+ }
1790
+ result_obj.write(output);
1791
+ output.writeMessageEnd();
1792
+ output.flush();
1793
+ });
1794
+ }
1795
+ }
1796
+ process_getSearchResults (seqid, input, output) {
1797
+ const args = new ResultsServerService_getSearchResults_args();
1798
+ args.read(input);
1799
+ input.readMessageEnd();
1800
+ if (this._handler.getSearchResults.length === 2) {
1801
+ Promise.resolve(this._handler.getSearchResults.bind(this._handler)(
1802
+ args.taskType,
1803
+ args.limit
1804
+ )).then(result => {
1805
+ const result_obj = new ResultsServerService_getSearchResults_result({success: result});
1806
+ output.writeMessageBegin("getSearchResults", Thrift.MessageType.REPLY, seqid);
1807
+ result_obj.write(output);
1808
+ output.writeMessageEnd();
1809
+ output.flush();
1810
+ }).catch(err => {
1811
+ let result;
1812
+ if (err instanceof services_ttypes.ServicesException) {
1813
+ result = new ResultsServerService_getSearchResults_result(err);
1814
+ output.writeMessageBegin("getSearchResults", Thrift.MessageType.REPLY, seqid);
1815
+ } else {
1816
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1817
+ output.writeMessageBegin("getSearchResults", Thrift.MessageType.EXCEPTION, seqid);
1818
+ }
1819
+ result.write(output);
1820
+ output.writeMessageEnd();
1821
+ output.flush();
1822
+ });
1823
+ } else {
1824
+ this._handler.getSearchResults(args.taskType, args.limit, (err, result) => {
1825
+ let result_obj;
1826
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1827
+ result_obj = new ResultsServerService_getSearchResults_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1828
+ output.writeMessageBegin("getSearchResults", Thrift.MessageType.REPLY, seqid);
1829
+ } else {
1830
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1831
+ output.writeMessageBegin("getSearchResults", Thrift.MessageType.EXCEPTION, seqid);
1832
+ }
1833
+ result_obj.write(output);
1834
+ output.writeMessageEnd();
1835
+ output.flush();
1836
+ });
1837
+ }
1838
+ }
1839
+ process_getSearchResultsByUser (seqid, input, output) {
1840
+ const args = new ResultsServerService_getSearchResultsByUser_args();
1841
+ args.read(input);
1842
+ input.readMessageEnd();
1843
+ if (this._handler.getSearchResultsByUser.length === 3) {
1844
+ Promise.resolve(this._handler.getSearchResultsByUser.bind(this._handler)(
1845
+ args.taskType,
1846
+ args.userId,
1847
+ args.limit
1848
+ )).then(result => {
1849
+ const result_obj = new ResultsServerService_getSearchResultsByUser_result({success: result});
1850
+ output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.REPLY, seqid);
1851
+ result_obj.write(output);
1852
+ output.writeMessageEnd();
1853
+ output.flush();
1854
+ }).catch(err => {
1855
+ let result;
1856
+ if (err instanceof services_ttypes.ServicesException) {
1857
+ result = new ResultsServerService_getSearchResultsByUser_result(err);
1858
+ output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.REPLY, seqid);
1859
+ } else {
1860
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1861
+ output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.EXCEPTION, seqid);
1862
+ }
1863
+ result.write(output);
1864
+ output.writeMessageEnd();
1865
+ output.flush();
1866
+ });
1867
+ } else {
1868
+ this._handler.getSearchResultsByUser(args.taskType, args.userId, args.limit, (err, result) => {
1869
+ let result_obj;
1870
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1871
+ result_obj = new ResultsServerService_getSearchResultsByUser_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1872
+ output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.REPLY, seqid);
1873
+ } else {
1874
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1875
+ output.writeMessageBegin("getSearchResultsByUser", Thrift.MessageType.EXCEPTION, seqid);
1876
+ }
1877
+ result_obj.write(output);
1878
+ output.writeMessageEnd();
1879
+ output.flush();
1880
+ });
1881
+ }
1882
+ }
1883
+ process_getLatestSearchResult (seqid, input, output) {
1884
+ const args = new ResultsServerService_getLatestSearchResult_args();
1885
+ args.read(input);
1886
+ input.readMessageEnd();
1887
+ if (this._handler.getLatestSearchResult.length === 1) {
1888
+ Promise.resolve(this._handler.getLatestSearchResult.bind(this._handler)(
1889
+ args.userId
1890
+ )).then(result => {
1891
+ const result_obj = new ResultsServerService_getLatestSearchResult_result({success: result});
1892
+ output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.REPLY, seqid);
1893
+ result_obj.write(output);
1894
+ output.writeMessageEnd();
1895
+ output.flush();
1896
+ }).catch(err => {
1897
+ let result;
1898
+ if (err instanceof services_ttypes.ServicesException) {
1899
+ result = new ResultsServerService_getLatestSearchResult_result(err);
1900
+ output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.REPLY, seqid);
1901
+ } else {
1902
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1903
+ output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1904
+ }
1905
+ result.write(output);
1906
+ output.writeMessageEnd();
1907
+ output.flush();
1908
+ });
1909
+ } else {
1910
+ this._handler.getLatestSearchResult(args.userId, (err, result) => {
1911
+ let result_obj;
1912
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1913
+ result_obj = new ResultsServerService_getLatestSearchResult_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1914
+ output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.REPLY, seqid);
1915
+ } else {
1916
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1917
+ output.writeMessageBegin("getLatestSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1918
+ }
1919
+ result_obj.write(output);
1920
+ output.writeMessageEnd();
1921
+ output.flush();
1922
+ });
1923
+ }
1924
+ }
1925
+ process_getSearchResult (seqid, input, output) {
1926
+ const args = new ResultsServerService_getSearchResult_args();
1927
+ args.read(input);
1928
+ input.readMessageEnd();
1929
+ if (this._handler.getSearchResult.length === 1) {
1930
+ Promise.resolve(this._handler.getSearchResult.bind(this._handler)(
1931
+ args.searchResultId
1932
+ )).then(result => {
1933
+ const result_obj = new ResultsServerService_getSearchResult_result({success: result});
1934
+ output.writeMessageBegin("getSearchResult", Thrift.MessageType.REPLY, seqid);
1935
+ result_obj.write(output);
1936
+ output.writeMessageEnd();
1937
+ output.flush();
1938
+ }).catch(err => {
1939
+ let result;
1940
+ if (err instanceof services_ttypes.ServicesException) {
1941
+ result = new ResultsServerService_getSearchResult_result(err);
1942
+ output.writeMessageBegin("getSearchResult", Thrift.MessageType.REPLY, seqid);
1943
+ } else {
1944
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1945
+ output.writeMessageBegin("getSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1946
+ }
1947
+ result.write(output);
1948
+ output.writeMessageEnd();
1949
+ output.flush();
1950
+ });
1951
+ } else {
1952
+ this._handler.getSearchResult(args.searchResultId, (err, result) => {
1953
+ let result_obj;
1954
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1955
+ result_obj = new ResultsServerService_getSearchResult_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1956
+ output.writeMessageBegin("getSearchResult", Thrift.MessageType.REPLY, seqid);
1957
+ } else {
1958
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1959
+ output.writeMessageBegin("getSearchResult", Thrift.MessageType.EXCEPTION, seqid);
1960
+ }
1961
+ result_obj.write(output);
1962
+ output.writeMessageEnd();
1963
+ output.flush();
1964
+ });
1965
+ }
1966
+ }
1967
+ process_startSession (seqid, input, output) {
1968
+ const args = new ResultsServerService_startSession_args();
1969
+ args.read(input);
1970
+ input.readMessageEnd();
1971
+ if (this._handler.startSession.length === 2) {
1972
+ Promise.resolve(this._handler.startSession.bind(this._handler)(
1973
+ args.searchResultId,
1974
+ args.taskType
1975
+ )).then(result => {
1976
+ const result_obj = new ResultsServerService_startSession_result({success: result});
1977
+ output.writeMessageBegin("startSession", Thrift.MessageType.REPLY, seqid);
1978
+ result_obj.write(output);
1979
+ output.writeMessageEnd();
1980
+ output.flush();
1981
+ }).catch(err => {
1982
+ let result;
1983
+ if (err instanceof services_ttypes.ServicesException) {
1984
+ result = new ResultsServerService_startSession_result(err);
1985
+ output.writeMessageBegin("startSession", Thrift.MessageType.REPLY, seqid);
1986
+ } else {
1987
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
1988
+ output.writeMessageBegin("startSession", Thrift.MessageType.EXCEPTION, seqid);
1989
+ }
1990
+ result.write(output);
1991
+ output.writeMessageEnd();
1992
+ output.flush();
1993
+ });
1994
+ } else {
1995
+ this._handler.startSession(args.searchResultId, args.taskType, (err, result) => {
1996
+ let result_obj;
1997
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
1998
+ result_obj = new ResultsServerService_startSession_result((err !== null || typeof err === 'undefined') ? err : {success: result});
1999
+ output.writeMessageBegin("startSession", Thrift.MessageType.REPLY, seqid);
2000
+ } else {
2001
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2002
+ output.writeMessageBegin("startSession", Thrift.MessageType.EXCEPTION, seqid);
2003
+ }
2004
+ result_obj.write(output);
2005
+ output.writeMessageEnd();
2006
+ output.flush();
2007
+ });
2008
+ }
2009
+ }
2010
+ process_stopSession (seqid, input, output) {
2011
+ const args = new ResultsServerService_stopSession_args();
2012
+ args.read(input);
2013
+ input.readMessageEnd();
2014
+ if (this._handler.stopSession.length === 1) {
2015
+ Promise.resolve(this._handler.stopSession.bind(this._handler)(
2016
+ args.sessionId
2017
+ )).then(result => {
2018
+ const result_obj = new ResultsServerService_stopSession_result({success: result});
2019
+ output.writeMessageBegin("stopSession", Thrift.MessageType.REPLY, seqid);
2020
+ result_obj.write(output);
2021
+ output.writeMessageEnd();
2022
+ output.flush();
2023
+ }).catch(err => {
2024
+ let result;
2025
+ if (err instanceof services_ttypes.ServicesException) {
2026
+ result = new ResultsServerService_stopSession_result(err);
2027
+ output.writeMessageBegin("stopSession", Thrift.MessageType.REPLY, seqid);
2028
+ } else {
2029
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2030
+ output.writeMessageBegin("stopSession", Thrift.MessageType.EXCEPTION, seqid);
2031
+ }
2032
+ result.write(output);
2033
+ output.writeMessageEnd();
2034
+ output.flush();
2035
+ });
2036
+ } else {
2037
+ this._handler.stopSession(args.sessionId, (err, result) => {
2038
+ let result_obj;
2039
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
2040
+ result_obj = new ResultsServerService_stopSession_result((err !== null || typeof err === 'undefined') ? err : {success: result});
2041
+ output.writeMessageBegin("stopSession", Thrift.MessageType.REPLY, seqid);
2042
+ } else {
2043
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2044
+ output.writeMessageBegin("stopSession", Thrift.MessageType.EXCEPTION, seqid);
2045
+ }
2046
+ result_obj.write(output);
2047
+ output.writeMessageEnd();
2048
+ output.flush();
2049
+ });
2050
+ }
2051
+ }
2052
+ process_getNextChunk (seqid, input, output) {
2053
+ const args = new ResultsServerService_getNextChunk_args();
2054
+ args.read(input);
2055
+ input.readMessageEnd();
2056
+ if (this._handler.getNextChunk.length === 1) {
2057
+ Promise.resolve(this._handler.getNextChunk.bind(this._handler)(
2058
+ args.sessionId
2059
+ )).then(result => {
2060
+ const result_obj = new ResultsServerService_getNextChunk_result({success: result});
2061
+ output.writeMessageBegin("getNextChunk", Thrift.MessageType.REPLY, seqid);
2062
+ result_obj.write(output);
2063
+ output.writeMessageEnd();
2064
+ output.flush();
2065
+ }).catch(err => {
2066
+ let result;
2067
+ if (err instanceof services_ttypes.ServicesException) {
2068
+ result = new ResultsServerService_getNextChunk_result(err);
2069
+ output.writeMessageBegin("getNextChunk", Thrift.MessageType.REPLY, seqid);
2070
+ } else {
2071
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2072
+ output.writeMessageBegin("getNextChunk", Thrift.MessageType.EXCEPTION, seqid);
2073
+ }
2074
+ result.write(output);
2075
+ output.writeMessageEnd();
2076
+ output.flush();
2077
+ });
2078
+ } else {
2079
+ this._handler.getNextChunk(args.sessionId, (err, result) => {
2080
+ let result_obj;
2081
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
2082
+ result_obj = new ResultsServerService_getNextChunk_result((err !== null || typeof err === 'undefined') ? err : {success: result});
2083
+ output.writeMessageBegin("getNextChunk", Thrift.MessageType.REPLY, seqid);
2084
+ } else {
2085
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2086
+ output.writeMessageBegin("getNextChunk", Thrift.MessageType.EXCEPTION, seqid);
2087
+ }
2088
+ result_obj.write(output);
2089
+ output.writeMessageEnd();
2090
+ output.flush();
2091
+ });
2092
+ }
2093
+ }
2094
+ process_submitAnnotation (seqid, input, output) {
2095
+ const args = new ResultsServerService_submitAnnotation_args();
2096
+ args.read(input);
2097
+ input.readMessageEnd();
2098
+ if (this._handler.submitAnnotation.length === 3) {
2099
+ Promise.resolve(this._handler.submitAnnotation.bind(this._handler)(
2100
+ args.sessionId,
2101
+ args.unitId,
2102
+ args.communication
2103
+ )).then(result => {
2104
+ const result_obj = new ResultsServerService_submitAnnotation_result({success: result});
2105
+ output.writeMessageBegin("submitAnnotation", Thrift.MessageType.REPLY, seqid);
2106
+ result_obj.write(output);
2107
+ output.writeMessageEnd();
2108
+ output.flush();
2109
+ }).catch(err => {
2110
+ let result;
2111
+ if (err instanceof services_ttypes.ServicesException) {
2112
+ result = new ResultsServerService_submitAnnotation_result(err);
2113
+ output.writeMessageBegin("submitAnnotation", Thrift.MessageType.REPLY, seqid);
2114
+ } else {
2115
+ result = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2116
+ output.writeMessageBegin("submitAnnotation", Thrift.MessageType.EXCEPTION, seqid);
2117
+ }
2118
+ result.write(output);
2119
+ output.writeMessageEnd();
2120
+ output.flush();
2121
+ });
2122
+ } else {
2123
+ this._handler.submitAnnotation(args.sessionId, args.unitId, args.communication, (err, result) => {
2124
+ let result_obj;
2125
+ if ((err === null || typeof err === 'undefined') || err instanceof services_ttypes.ServicesException) {
2126
+ result_obj = new ResultsServerService_submitAnnotation_result((err !== null || typeof err === 'undefined') ? err : {success: result});
2127
+ output.writeMessageBegin("submitAnnotation", Thrift.MessageType.REPLY, seqid);
2128
+ } else {
2129
+ result_obj = new Thrift.TApplicationException(Thrift.TApplicationExceptionType.UNKNOWN, err.message);
2130
+ output.writeMessageBegin("submitAnnotation", Thrift.MessageType.EXCEPTION, seqid);
2131
+ }
2132
+ result_obj.write(output);
2133
+ output.writeMessageEnd();
2134
+ output.flush();
2135
+ });
2136
+ }
2137
+ }
2138
+ };