-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
593 lines (470 loc) · 28.7 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
import os
import connection
import base64
import json
from flask import request, jsonify, send_file, redirect
from sqlalchemy.orm import Session, sessionmaker, mapper
from model import ResponseData, Serialisasi
# app configuration
app = connection.config.app #config app
app.config['CORS_HEADERS'] = 'Content-Type'
app.config['TESTING'] = True
app.config['DEBUG'] = True
imagedir = './dir/www/'
cursor = connection.config.conn.cursor()
@app.before_request
def before_request():
if not request.is_secure and app.env != "development":
url = request.url.replace("http://", "https://", 1)
code = 301
return redirect(url, code=code)
def Base64Encoder(string):
with open(string, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
return encoded_string
# ketika di main menu
@app.route("/",methods=['GET','POST'])
def index():
try :
# mengambil jumlah jurnal, conference, books, thesis, paten dan research yang ada
temp_row = None
arrayHasilPublikasiITS = []
# jurnal, konferensi, buku, tesis, patent, penelitian = 0, 0, 0, 0, 0, 0
cursor.execute('SELECT SUM(journals) AS journals FROM resits.dbo.mapping_temp_dosen;')
for row in cursor :
x = Serialisasi(journals = row.journals)
temp_row = x.__dict__
arrayHasilPublikasiITS.append(temp_row)
cursor.execute('SELECT SUM(conferences) AS conferences FROM resits.dbo.mapping_temp_dosen;')
for row in cursor :
x = Serialisasi(conferences = row.conferences)
temp_row = x.__dict__
arrayHasilPublikasiITS.append(temp_row)
cursor.execute('SELECT SUM(books) AS books FROM resits.dbo.mapping_temp_dosen;')
for row in cursor :
x = Serialisasi(books = row.books)
temp_row = x.__dict__
arrayHasilPublikasiITS.append(temp_row)
cursor.execute('SELECT SUM(thesis) AS thesis FROM resits.dbo.mapping_temp_dosen;')
for row in cursor :
x = Serialisasi(thesis = row.thesis)
temp_row = x.__dict__
arrayHasilPublikasiITS.append(temp_row)
cursor.execute('SELECT SUM(paten) AS paten FROM resits.dbo.mapping_temp_dosen;')
for row in cursor :
x = Serialisasi(paten = row.paten)
temp_row = x.__dict__
arrayHasilPublikasiITS.append(temp_row)
cursor.execute('SELECT SUM(research) AS research FROM resits.dbo.mapping_temp_dosen;')
for row in cursor :
x = Serialisasi(research = row.research)
temp_row = x.__dict__
arrayHasilPublikasiITS.append(temp_row)
result = {}
result['hasil_publikasi'] = arrayHasilPublikasiITS
resultDashboard = {}
resultDashboard['dashboard_data'] = [result]
result_len = len(arrayHasilPublikasiITS)
all_data = [resultDashboard]
response = ResponseData("200","Data Berhasil Ditemukan", all_data, result_len)
response = json.dumps(response.__dict__)
return str(response)
except Exception as e:
if hasattr(e, 'message'):
data = [e]
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 001",data, result_len)
response = json.dumps(response.__dict__)
return str(response)
else:
data = []
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 002",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
@app.route('/peneliti', methods=['GET'])
def Peneliti():
try:
if request.method == 'GET':
abjadDict = {}
abjadSort = request.args.get('abjad')
# topSort = request.args.get('top')
facultySort = request.args.get('fakultas')
deptSort = request.args.get('departemen')
sizeSort = request.args.get('size')
# print(abjadSort, topSort, facultySort, deptSort)
## APABILA TIDAK ADA ARGUMEN ABJAD YANG INGIN DIKELOMPOKKAN, MAKA HASILNYA
## ADALAH TOTAL MASING-MASING INISIAL AWAL
if abjadSort != None :
if abjadSort == 'none' :
temp_row = None
arrayPeneliti = []
cursor.execute('SELECT DISTINCT peg.kode, peg.nama FROM resits.dbo.tmst_pegawai as peg INNER JOIN resits.dbo.tran_publikasi_dosen_tetap as pub ON peg.kode = pub.kode_pegawai ORDER BY peg.nama ASC;')
for row in cursor :
if row.nama is None : continue
firstLetter = nameInitial(row.nama.upper())
if firstLetter is None : continue
isAdded = False
if len(abjadDict) == 0 :
abjadDict[firstLetter] = 1
else :
for abjad in abjadDict.keys() :
if abjad == firstLetter :
abjadDict[abjad] = abjadDict[abjad] + 1
isAdded = True
break
if isAdded == False :
abjadDict[firstLetter] = 1
for abjad in sorted(abjadDict.keys()) :
x = Serialisasi(inisial = abjad,
total = abjadDict[abjad])
temp_row = x.__dict__
arrayPeneliti.append(temp_row)
## DEBUG
## BAGIAN INI UNTUK MELIHAT ABJAD YANG TELAH TERSIMPAN DAN
## JUMLAHNYA
# print(abjadDict.keys())
# print(abjadDict.values())
# total = 0
# for jumlahAbjad in abjadDict.values():
# total += jumlahAbjad
# print(total)
listPeneliti = {}
listPeneliti['inisial_peneliti'] = arrayPeneliti
else :
temp_row = None
arrayPeneliti = []
cursor.execute("SELECT peg.nama, peg.kode as kode, COUNT(pub.kode_publikasi) as jumlah FROM resits.dbo.tran_publikasi_dosen_tetap as pub INNER JOIN resits.dbo.tmst_pegawai as peg ON peg.kode = pub.kode_pegawai WHERE peg.nama LIKE '"+str(abjadSort.upper())+"%' OR peg.nama LIKE ' "+str(abjadSort.upper())+"%' GROUP BY peg.kode, peg.nama ORDER BY ltrim(peg.nama) ASC;")
for row in cursor :
if row.nama is None : continue
x = Serialisasi(kode_dosen = row.kode,
nama = row.nama,
jumlah = row.jumlah)
temp_row = x.__dict__
arrayPeneliti.append(temp_row)
listPeneliti = {}
listPeneliti['nama_peneliti'] = arrayPeneliti
if facultySort != None :
if facultySort == 'none' :
temp_row = None
arrayPeneliti = []
if sizeSort == 'true':
cursor.execute("SELECT peg.kode_fakultas, fak.akronim_inggris, COUNT(peg.kode) as jumlah FROM resits.dbo.tmst_pegawai as peg INNER JOIN (SELECT DISTINCT kode_pegawai FROM resits.dbo.tran_publikasi_dosen_tetap) as pub ON peg.kode = pub.kode_pegawai INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON peg.kode_fakultas = fak.kode INNER JOIN resits.dbo.tmst_jurusan_baru as jur ON peg.kode_jurusan = jur.kode GROUP BY peg.kode_fakultas, fak.akronim_inggris HAVING COUNT(peg.kode) > 1 ORDER BY jumlah ASC")
else:
cursor.execute("SELECT peg.kode_fakultas, fak.akronim_inggris, COUNT(peg.kode) as jumlah FROM resits.dbo.tmst_pegawai as peg INNER JOIN (SELECT DISTINCT kode_pegawai FROM resits.dbo.tran_publikasi_dosen_tetap) as pub ON peg.kode = pub.kode_pegawai INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON peg.kode_fakultas = fak.kode INNER JOIN resits.dbo.tmst_jurusan_baru as jur ON peg.kode_jurusan = jur.kode GROUP BY peg.kode_fakultas, fak.akronim_inggris HAVING COUNT(peg.kode) > 1 ORDER BY fak.akronim_inggris ASC")
print("Fakultas=None")
for row in cursor :
x = Serialisasi(kode_fakultas = row.kode_fakultas,
nama_fakultas = row.akronim_inggris,
jumlah = row.jumlah)
temp_row = x.__dict__
arrayPeneliti.append(temp_row)
listPeneliti = {}
listPeneliti['fakultas_peneliti'] = arrayPeneliti
else :
temp_row = None
arrayPeneliti = []
if sizeSort == 'true':
cursor.execute("SELECT peg.kode_fakultas, fak.akronim_inggris as nama_fakultas, peg.kode_jurusan, jur.nama_inggris as nama_departemen, count(peg.kode_jurusan) as fakultas_publikasi FROM resits.dbo.tmst_pegawai as peg INNER JOIN (SELECT DISTINCT kode_pegawai FROM resits.dbo.tran_publikasi_dosen_tetap) as pub ON peg.kode = pub.kode_pegawai INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON peg.kode_fakultas = fak.kode INNER JOIN resits.dbo.tmst_jurusan_baru as jur ON peg.kode_jurusan = jur.kode WHERE peg.kode_fakultas = "+str(facultySort)+" GROUP BY peg.kode_fakultas, peg.kode_jurusan, jur.nama_inggris, fak.akronim_inggris ORDER BY fakultas_publikasi ASC")
else:
cursor.execute("SELECT peg.kode_fakultas, fak.akronim_inggris as nama_fakultas, peg.kode_jurusan, jur.nama_inggris as nama_departemen, count(peg.kode_jurusan) as fakultas_publikasi FROM resits.dbo.tmst_pegawai as peg INNER JOIN (SELECT DISTINCT kode_pegawai FROM resits.dbo.tran_publikasi_dosen_tetap) as pub ON peg.kode = pub.kode_pegawai INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON peg.kode_fakultas = fak.kode INNER JOIN resits.dbo.tmst_jurusan_baru as jur ON peg.kode_jurusan = jur.kode WHERE peg.kode_fakultas = "+str(facultySort)+" GROUP BY peg.kode_fakultas, peg.kode_jurusan, jur.nama_inggris, fak.akronim_inggris ORDER BY jur.nama_inggris ASC")
print("Fakultas=Available, Departement=None")
for row in cursor :
x = Serialisasi(kode_fakultas = row.kode_fakultas,
nama_fakultas = row.nama_fakultas,
kode_departemen = row.kode_jurusan,
nama_departemen = row.nama_departemen,
jumlah = row.fakultas_publikasi
)
temp_row = x.__dict__
arrayPeneliti.append(temp_row)
listPeneliti = {}
listPeneliti['departemen_peneliti'] = arrayPeneliti
if deptSort != None :
temp_row = None
arrayPeneliti = []
cursor.execute("SELECT peg.nama, peg.kode as kode, jur.nama_inggris as nama_departemen, peg.kode_jurusan as kode_jurusan, COUNT(pub.kode_publikasi) as jumlah FROM resits.dbo.tran_publikasi_dosen_tetap as pub INNER JOIN resits.dbo.tmst_pegawai as peg ON peg.kode = pub.kode_pegawai INNER JOIN resits.dbo.tmst_jurusan_baru as jur ON jur.kode = peg.kode_jurusan WHERE peg.kode_jurusan = "+str(deptSort)+" GROUP BY peg.kode, peg.nama, peg.kode_jurusan, jur.nama_inggris ORDER BY ltrim(peg.nama) ASC;")
print("Fakultas=Available, Departement=Available")
for row in cursor :
x = Serialisasi(kode_dosen = row.kode,
nama_departemen = row.nama_departemen,
nama = row.nama,
jumlah = row.jumlah
)
temp_row = x.__dict__
arrayPeneliti.append(temp_row)
listPeneliti = {}
listPeneliti['nama_peneliti'] = arrayPeneliti
data_len = len(arrayPeneliti)
all_data = [listPeneliti]
response = ResponseData("200","Data Berhasil Ditemukan", all_data, data_len)
response = json.dumps(response.__dict__)
return str(response)
except Exception as e:
if hasattr(e, 'message'):
data = [e]
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 005",e, data_len)
response = json.dumps(response.__dict__)
return str(response)
else:
data = []
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 006",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
def nameInitial(name):
for letter in name :
if letter == ' ' : continue
else : return letter
# @app.route('/fakultas')
@app.route('/gelar', methods=['GET'])
def gelarPeneliti():
try:
if request.method == 'GET':
gelarDict = {}
temp_row = None
id_target = request.args.get('kode')
if id_target == "none" :
arrayGelar = []
cursor.execute("SELECT DISTINCT peg.kode_jenjang_pendidikan as jenjang_pendidikan, COUNT(peg.kode_jenjang_pendidikan) as jumlah FROM resits.dbo.tmst_pegawai as peg INNER JOIN (SELECT DISTINCT kode_pegawai FROM resits.dbo.tran_publikasi_dosen_tetap) as pub ON peg.kode = pub.kode_pegawai WHERE peg.kode_jenjang_pendidikan IN ('S1', 'S2', 'S3') GROUP BY peg.kode_jenjang_pendidikan ORDER BY peg.kode_jenjang_pendidikan ASC")
for row in cursor :
jenis_gelar = row.jenjang_pendidikan
jumlah_gelar = row.jumlah
x = Serialisasi(gelar = jenis_gelar,
jumlah = jumlah_gelar)
temp_row = x.__dict__
arrayGelar.append(temp_row)
listGelar = {}
listGelar['gelar_peneliti'] = arrayGelar
else :
arrayGelar = []
cursor.execute("SELECT peg.nama, peg.kode as kode,peg.kode_jenjang_pendidikan as pendidikan, COUNT(pub.kode_publikasi) as jumlah FROM resits.dbo.tran_publikasi_dosen_tetap as pub INNER JOIN resits.dbo.tmst_pegawai as peg ON peg.kode = pub.kode_pegawai WHERE peg.kode_jenjang_pendidikan = '"+str(id_target)+"' GROUP BY peg.kode, peg.nama, peg.kode_jenjang_pendidikan ORDER BY ltrim(peg.nama) ASC;")
for row in cursor :
nama = row.nama
kode = row.kode
pendidikan = row.pendidikan
jumlah = row.jumlah
x = Serialisasi(nama = nama,
kode_dosen = kode,
pendidikan_dosen = pendidikan,
jumlah = jumlah
)
temp_row = x.__dict__
arrayGelar.append(temp_row)
listGelar = {}
listGelar['nama_peneliti'] = arrayGelar
data_len = len(arrayGelar)
all_data = [listGelar]
response = ResponseData("200","Data Berhasil Ditemukan", all_data, data_len)
response = json.dumps(response.__dict__)
return str(response)
except Exception as e:
if hasattr(e, 'message'):
data = [e]
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 001",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
else:
data = []
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 002",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
@app.route('/publikasi', methods=['GET'])
def publikasi():
try:
if request.method == 'GET':
temp_row = None
kode_fakultas = request.args.get('fakultas')
kata_kunci = request.args.get('katakunci')
kode_publikasi = request.args.get('publikasi')
sizeSort = request.args.get('size')
if kode_fakultas == "none" :
arrayLaboratorium = []
if sizeSort == 'true':
cursor.execute("SELECT peg.kode_fakultas, fak.akronim_inggris, COUNT(peg.kode_fakultas) as jumlah_publikasi from resits.dbo.tran_publikasi_dosen_tetap as pub INNER JOIN resits.dbo.tmst_pegawai as peg ON peg.kode = pub.kode_pegawai INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON fak.kode = peg.kode_fakultas GROUP BY peg.kode_fakultas, fak.akronim_inggris ORDER BY jumlah_publikasi ASC;")
else:
cursor.execute("SELECT peg.kode_fakultas, fak.akronim_inggris, COUNT(peg.kode_fakultas) as jumlah_publikasi from resits.dbo.tran_publikasi_dosen_tetap as pub INNER JOIN resits.dbo.tmst_pegawai as peg ON peg.kode = pub.kode_pegawai INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON fak.kode = peg.kode_fakultas GROUP BY peg.kode_fakultas, fak.akronim_inggris ORDER BY fak.akronim_inggris ASC;")
# print(departemen_kode)
for row in cursor :
fakultas_lab = row.kode_fakultas
nama_fakultas = row.akronim_inggris
jumlah_publikasi = row.jumlah_publikasi
x = Serialisasi(kode_fakultas = fakultas_lab,
nama_fakultas = nama_fakultas,
jumlah = jumlah_publikasi
)
temp_row = x.__dict__
arrayLaboratorium.append(temp_row)
listLaboratorium = {}
listLaboratorium['fakultas_peneliti'] = arrayLaboratorium
# print(listGelar)
else :
if kata_kunci == None :
arrayLaboratorium = []
# cursor.execute("SELECT lab.kode_jurusan as fakultas, lab.kode_fakultas as kode_jurusan, jurbar.nama_inggris, COUNT(anglab.kode_pegawai) as jumlah FROM resits.dbo.tmst_laboratorium_baru as lab INNER JOIN resits.dbo.anggota_labs as anglab ON anglab.kode_labs = lab.kode INNER JOIN resits.dbo.tmst_jurusan_baru as jurbar ON lab.kode_fakultas = jurbar.kode WHERE lab.kode_jurusan = "+str(id_target)+" GROUP BY lab.kode_fakultas, lab.kode_jurusan, jurbar.nama_inggris ORDER BY lab.kode_jurusan;")
if sizeSort == 'true':
cursor.execute("SELECT katkun.kode_fakultas, fak.akronim_inggris as nama_fakultas, katkun.kata, katkun.idf, katkun.df from resits.dbo.tmst_bobot_kata_kunci as katkun INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON katkun.kode_fakultas = fak.kode WHERE katkun.kode_fakultas = "+str(kode_fakultas)+" ORDER BY katkun.df ASC;")
else:
cursor.execute("SELECT katkun.kode_fakultas, fak.akronim_inggris as nama_fakultas, katkun.kata, katkun.idf, katkun.df from resits.dbo.tmst_bobot_kata_kunci as katkun INNER JOIN resits.dbo.tmst_fakultas_baru as fak ON katkun.kode_fakultas = fak.kode WHERE katkun.kode_fakultas = "+str(kode_fakultas)+" ORDER BY katkun.kata ASC;")
for row in cursor :
kode_fakultas = row.kode_fakultas
nama_fakultas = row.nama_fakultas
kata = row.kata
idf = row.idf
df = row.df
x = Serialisasi(kode_fakultas = kode_fakultas,
nama_fakultas = nama_fakultas,
kata_kunci = kata,
idf = idf,
df = df
)
temp_row = x.__dict__
arrayLaboratorium.append(temp_row)
listLaboratorium = {}
listLaboratorium['fakultas_publikasi'] = arrayLaboratorium
else :
if kode_publikasi == None :
arrayLaboratorium = []
# cursor.execute("SELECT lab.kode_fakultas as jurusan, lab.kode_jurusan as fakultas, COUNT(anglab.kode_pegawai) as jumlah, lab.nama_inggris FROM resits.dbo.tmst_laboratorium_baru as lab INNER JOIN resits.dbo.anggota_labs as anglab ON anglab.kode_labs = lab.kode WHERE lab.kode_fakultas = "+str(departemen_kode)+" GROUP BY lab.kode_fakultas, lab.kode_jurusan, lab.nama_inggris ORDER BY lab.kode_jurusan")
cursor.execute("SELECT pub.kode_pegawai, peg.nama, COUNT(pub.judul) as jumlah_publikasi FROM resits.dbo.tran_publikasi_dosen_tetap as pub INNER JOIN resits.dbo.tmst_pegawai as peg ON peg.kode = pub.kode_pegawai WHERE pub.judul LIKE '%"+str(kata_kunci)+"%' AND peg.kode_fakultas = "+str(kode_fakultas)+"GROUP BY peg.nama, pub.kode_pegawai ORDER BY ltrim(peg.nama) ASC")
for row in cursor :
kode_dosen = row.kode_pegawai
nama_dosen = row.nama
jumlah_publikasi = row.jumlah_publikasi
x = Serialisasi(kode_dosen = kode_dosen,
nama = nama_dosen,
jumlah = jumlah_publikasi
)
temp_row = x.__dict__
arrayLaboratorium.append(temp_row)
listLaboratorium = {}
listLaboratorium['nama_peneliti'] = arrayLaboratorium
else :
arrayLaboratorium = []
data_len = len(arrayLaboratorium)
all_data = [listLaboratorium]
response = ResponseData("200","Data Berhasil Ditemukan", all_data, data_len)
response = json.dumps(response.__dict__)
return str(response)
except Exception as e:
if hasattr(e, 'message'):
data = [e]
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 001",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
else:
data = []
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 002",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
@app.route('/detailpeneliti', methods=['GET'])
def detailPeneliti():
try:
if request.method == 'GET':
temp_row = None
id_target = request.args.get('id_peneliti')
arrayDetailPeneliti = []
cursor.execute('SELECT peg.nama AS nama_dosen, peg.tanggal_lahir as tanggal_lahir, fak.akronim_inggris AS nama_fakultas, jur.nama_inggris AS nama_jurusan, maptemp.journals, maptemp.conferences, maptemp.books, maptemp.thesis, maptemp.paten, maptemp.research FROM resits.dbo.tmst_pegawai AS peg LEFT JOIN resits.dbo.tmst_fakultas_baru AS fak ON (peg.kode_fakultas = fak.kode) LEFT JOIN resits.dbo.tmst_jurusan_baru AS jur ON (peg.kode_jurusan = jur.kode) INNER JOIN resits.dbo.mapping_temp_dosen AS maptemp ON (peg.kode = maptemp.kode_pegawai) WHERE peg.kode = '+str(id_target)+';')
for row in cursor :
total_publikasi = int(row.journals) + int(row.conferences) + int(row.books) + int(row.thesis) + int(row.paten) + int(row.research)
x = Serialisasi(nama = row.nama_dosen,
tanggal_lahir = row.tanggal_lahir,
fakultas = row.nama_fakultas,
departemen = row.nama_jurusan,
jurnal = row.journals,
konferensi = row.conferences,
buku = row.books,
tesis = row.thesis,
paten = row.paten,
penelitian = row.research,
totalpublikasi = total_publikasi)
# x = Serialisasi(nama = row.nama_dosen,
# fakultas = row.nama_fakultas)
temp_row = x.__dict__
arrayDetailPeneliti.append(temp_row)
detailPeneliti = {}
detailPeneliti['detail_peneliti'] = arrayDetailPeneliti
data_len = len(arrayDetailPeneliti)
all_data =[detailPeneliti]
response = ResponseData("200","Data Berhasil Ditemukan", all_data, data_len)
response = json.dumps(response.__dict__)
return str(response)
except Exception as e:
if hasattr(e, 'message'):
data = [e]
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 001",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
else:
data = []
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 002",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
@app.route('/publikasipeneliti', methods=['GET'])
def publikasiPeneliti():
try:
if request.method == 'GET':
temp_row = None
# print("a")
id_target = request.args.get('id_publikasi')
arrayPublikasiPeneliti = []
cursor.execute("SELECT peg.nama, peg.kode as kode, pub.kode_publikasi, pub.judul, pub.tahun, pub.abstraksi FROM resits.dbo.tran_publikasi_dosen_tetap as pub INNER JOIN resits.dbo.tmst_pegawai as peg ON peg.kode = pub.kode_pegawai WHERE peg.kode = '"+str(id_target)+"';")
for row in cursor :
kode_publikasi = row.kode_publikasi
nama_publikasi = row.judul
tahun = row.tahun
abstraksi = row.abstraksi
x = Serialisasi(kode_publikasi = kode_publikasi,
nama_publikasi = nama_publikasi,
tahun = tahun,
abstraksi = abstraksi
)
temp_row = x.__dict__
arrayPublikasiPeneliti.append(temp_row)
listPublikasi = {}
listPublikasi['nama_publikasi'] = arrayPublikasiPeneliti
data_len = len(arrayPublikasiPeneliti)
all_data = [listPublikasi]
response = ResponseData("200","Data Berhasil Ditemukan", all_data, data_len)
response = json.dumps(response.__dict__)
return str(response)
except Exception as e:
if hasattr(e, 'message'):
data = [e]
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 001",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
else:
data = []
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 002",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
# cek testing
@app.route("/version",methods=['GET','POST'])
def testing():
try :
cursor.execute('SELECT @@VERSION;')
row = cursor.fetchone()
return str(row)
except Exception as e:
if hasattr(e, 'message'):
data = [e]
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 001",data, data_len)
response = json.dumps(response.__dict__)
return str(response)
else:
data = []
data_len = ""
response = ResponseData("500","Terjadi Kesalahan Pada Server, 002",data, data_len)
response = json.dumps(response.__dict__)
return str(response)