forked from SIBiUSP/coletaprod
-
Notifications
You must be signed in to change notification settings - Fork 9
/
lattes_xml_to_elastic_dedup.php
2024 lines (1762 loc) · 108 KB
/
lattes_xml_to_elastic_dedup.php
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
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
require 'inc/config.php';
require 'inc/functions.php';
function get_curriculum($identificador)
{
try {
global $index_cv;
global $client;
$params = [
'index' => $index_cv,
'id' => $identificador
];
// Get doc at /my_index/_doc/my_id
$response = $client->get($params);
return $response;
} catch (\Exception $e) {
echo $e->getMessage();
}
}
function comparaprod_doi($doi)
{
global $index;
global $type;
global $client;
$query['query']['query_string']['query'] = "doi:\"$doi\"";
$params = [];
$params['index'] = $index;
$params['type'] = $type;
$params['size'] = 100;
$params['body'] = $query;
$cursor = $client->search($params);
$total = $cursor['hits']['total']['value'];
echo 'Resultado total com DOI: '.$total.'';
foreach ($cursor['hits']['hits'] as $r) {
echo '<br/>';
echo ''.$r['_id'].' - '.$r['_source']['name'].' - '.$r['_source']['datePublished'].' - '.$r['_source']['tipo'].'';
echo '<br/>';
}
if ($total >= 1) {
return $r;
} else {
return 'Não encontrado';
}
}
function comparaprod_title($doc)
{
global $index;
global $client;
$query['query']['bool']['filter'][]["term"]["tipo.keyword"] = $doc["doc"]["tipo"];
$query['query']['bool']['filter'][]["term"]["datePublished.keyword"] = $doc["doc"]["datePublished"];
$query["query"]["bool"]["must"]["query_string"]["query"] = '(name:"'.$doc["doc"]["name"].'"^5) AND (author:'.$doc["doc"]['author'][0]['person']['name'].')';
if (!empty($doc['doc']['isPartOf']['name'])) {
$query['query']['bool']['filter'][]["term"]["isPartOf.name.keyword"] = $doc['doc']['isPartOf']['name'];
}
if (!empty($doc['doc']['publisher']['organization']['name'])) {
$query['query']['bool']['filter'][]["term"]["publisher.organization.name.keyword"] = $doc['doc']['publisher']['organization']['name'];
}
if (!empty($doc['doc']['isbn'])) {
$query['query']['bool']['filter'][]["term"]["isbn.keyword"] = $doc['doc']['isbn'];
}
$params = [];
$params['index'] = $index;
$params['size'] = 10;
$params['body'] = $query;
$cursor = $client->search($params);
$total = $cursor['hits']['total']['value'];
echo 'Resultado total com Titulo: '.$total.'';
foreach ($cursor['hits']['hits'] as $r) {
echo '<br/>';
echo 'Score: '.$r['_score'].' - '.$r['_id'].' - '.$r['_source']['name'].' - '.$r['_source']['datePublished'].' - '.$r['_source']['tipo'].'';
echo '<br/>';
}
if ($total >= 1) {
return $r;
} else {
return 'Não encontrado';
}
}
function processaAutoresLattes($autores_array)
{
$i = 0;
if (is_array($autores_array)) {
foreach ($autores_array as $autor) {
$autor = get_object_vars($autor);
$array_result['doc']['author'][$i]['person']['name'] = $autor['@attributes']['NOME-COMPLETO-DO-AUTOR'];
$array_result['doc']['author'][$i]['nomeParaCitacao'] = $autor['@attributes']['NOME-PARA-CITACAO'];
$array_result['doc']['author'][$i]['ordemDeAutoria'] = $autor['@attributes']['ORDEM-DE-AUTORIA'];
if (isset($autor['@attributes']['NRO-ID-CNPQ'])) {
$array_result['doc']['author'][$i]['nroIdCnpq'] = $autor['@attributes']['NRO-ID-CNPQ'];
}
$i++;
}
} else {
$autor = get_object_vars($autores_array);
$array_result['doc']['author'][$i]['person']['name'] = $autor['@attributes']['NOME-COMPLETO-DO-AUTOR'];
$array_result['doc']['author'][$i]['nomeParaCitacao'] = $autor['@attributes']['NOME-PARA-CITACAO'];
$array_result['doc']['author'][$i]['ordemDeAutoria'] = $autor['@attributes']['ORDEM-DE-AUTORIA'];
if (isset($autor['@attributes']['NRO-ID-CNPQ'])) {
$array_result['doc']['author'][$i]['nroIdCnpq'] = $autor['@attributes']['NRO-ID-CNPQ'];
}
}
if (!empty($array_result)) {
return $array_result;
} else {
$array_empty = [];
return $array_empty;
}
unset($array_result);
}
function processaPalavrasChaveLattes($palavras_chave)
{
$palavras_chave = get_object_vars($palavras_chave);
foreach (range(1, 6) as $number) {
if (!empty($palavras_chave['@attributes']["PALAVRA-CHAVE-$number"])) {
$array_result['doc']['about'][] = $palavras_chave['@attributes']["PALAVRA-CHAVE-$number"];
}
}
if (isset($array_result)) {
return $array_result;
}
unset($array_result);
}
function processaPalavrasChaveFormacaoLattes($palavras_chave)
{
$palavras_chave = get_object_vars($palavras_chave);
foreach (range(1, 6) as $number) {
if (!empty($palavras_chave['@attributes']["PALAVRA-CHAVE-$number"])) {
$array_result["palavras_chave"][] = $palavras_chave["@attributes"]["PALAVRA-CHAVE-$number"];
}
}
if (isset($array_result)) {
return $array_result;
}
unset($array_result);
}
function processaAreaDoConhecimentoLattes($areas_do_conhecimento)
{
$i = 0;
foreach ($areas_do_conhecimento as $ac) {
$ac = get_object_vars($ac);
foreach ($ac as $ac_record) {
$array_result["doc"]["area_do_conhecimento"][$i]["nomeGrandeAreaDoConhecimento"] = $ac_record["NOME-GRANDE-AREA-DO-CONHECIMENTO"];
$array_result["doc"]["area_do_conhecimento"][$i]["nomeDaAreaDoConhecimento"] = $ac_record["NOME-DA-AREA-DO-CONHECIMENTO"];
$array_result["doc"]["area_do_conhecimento"][$i]["nomeDaSubAreaDoConhecimento"] = $ac_record["NOME-DA-SUB-AREA-DO-CONHECIMENTO"];
$array_result["doc"]["area_do_conhecimento"][$i]["nomeDaEspecialidade"] = $ac_record["NOME-DA-ESPECIALIDADE"];
}
$i++;
}
if (!empty($array_result)) {
return $array_result;
} else {
$array_empty = [];
return $array_empty;
}
unset($array_result);
}
function processaAreaDoConhecimentoFormacaoLattes($areas_do_conhecimento)
{
$i = 0;
foreach ($areas_do_conhecimento as $ac) {
$ac = get_object_vars($ac);
foreach ($ac as $ac_record) {
$array_result["area_do_conhecimento"][$i]["nomeGrandeAreaDoConhecimento"] = $ac_record["NOME-GRANDE-AREA-DO-CONHECIMENTO"];
$array_result["area_do_conhecimento"][$i]["nomeDaAreaDoConhecimento"] = $ac_record["NOME-DA-AREA-DO-CONHECIMENTO"];
$array_result["area_do_conhecimento"][$i]["nomeDaSubAreaDoConhecimento"] = $ac_record["NOME-DA-SUB-AREA-DO-CONHECIMENTO"];
$array_result["area_do_conhecimento"][$i]["nomeDaEspecialidade"] = $ac_record["NOME-DA-ESPECIALIDADE"];
}
$i++;
}
return $array_result;
unset($array_result);
}
function construct_vinculo($request, $curriculo){
// Vinculo
if (isset($doc["doc"]["vinculo"])) {
$i_vinculo = count($doc["doc"]["vinculo"]);
$i_vinculo++;
} else {
$i_vinculo = 0;
}
$doc["doc"]["vinculo"][$i_vinculo]["nome"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'NOME-COMPLETO'};
$doc["doc"]["vinculo"][$i_vinculo]["lattes_id"] = (string)$curriculo->attributes()->{'NUMERO-IDENTIFICADOR'};
if (isset($request['unidade'])) {
$doc["doc"]["vinculo"][$i_vinculo]["unidade"] = explode("|", $request['unidade']);
}
if (isset($request['departamento'])) {
$doc["doc"]["vinculo"][$i_vinculo]["departamento"] = explode("|", $request['departamento']);
}
if (isset($request['numfuncional'])) {
$doc["doc"]["vinculo"][$i_vinculo]["numfuncional"] = $request['numfuncional'];
}
if (isset($request['tipvin'])) {
$doc["doc"]["vinculo"][$i_vinculo]["tipvin"] = explode("|", $request['tipvin']);
}
if (isset($request['divisao'])) {
$doc["doc"]["vinculo"][$i_vinculo]["divisao"] = explode("|", $request['divisao']);
}
if (isset($request['secao'])) {
$doc['doc']["vinculo"][$i_vinculo]['secao'] = explode("|", $request['secao']);
}
if (isset($request['ppg_nome'])) {
$doc['doc']["vinculo"][$i_vinculo]['ppg_nome'] = explode("|", $request['ppg_nome']);
}
if (isset($request['ppg_capes'])) {
$doc['doc']["vinculo"][$i_vinculo]['ppg_capes'] = explode("|", $request['ppg_capes']);
}
if (isset($request['genero'])) {
$doc['doc']["vinculo"][$i_vinculo]['genero'] = $request['genero'];
}
if (isset($request['etnia'])) {
$doc['doc']["vinculo"][$i_vinculo]['etnia'] = $request['etnia'];
}
if (isset($request['ano_ingresso'])) {
$doc['doc']["vinculo"][$i_vinculo]['ano_ingresso'] = substr($request['ano_ingresso'],-4);
}
if (isset($request['desc_nivel'])) {
$doc['doc']["vinculo"][$i_vinculo]['desc_nivel'] = explode("|", $request['desc_nivel']);
}
if (isset($request['desc_curso'])) {
$doc['doc']["vinculo"][$i_vinculo]['desc_curso'] = explode("|", $request['desc_curso']);
}
if (isset($request['campus'])) {
$doc['doc']["vinculo"][$i_vinculo]['campus'] = explode("|", $request['campus']);
}
if (isset($request['desc_gestora'])) {
$doc['doc']["vinculo"][$i_vinculo]['desc_gestora'] = explode("|", $request['desc_gestora']);
}
return $doc['doc']["vinculo"];
}
function my_array_unique($array, $keep_key_assoc = false) {
$duplicate_keys = array();
$tmp = array();
foreach ($array as $key => $val) {
// convert objects to arrays, in_array() does not support objects
if (is_object($val))
$val = (array)$val;
if (!in_array($val, $tmp))
$tmp[] = $val;
else
$duplicate_keys[] = $key;
}
foreach ($duplicate_keys as $key)
unset($array[$key]);
return $keep_key_assoc ? $array : array_values($array);
}
function upsert($doc, $sha256) {
// Comparador
if (!empty($doc['doc']['doi'])) {
$result_comparaprod = comparaprod_doi($doc['doc']['doi']);
if (is_array($result_comparaprod)) {
$result_comparaprod['_source']['vinculo'] = array_merge($result_comparaprod['_source']['vinculo'], $doc['doc']["vinculo"]);
$result_comparaprod['_source']['vinculo'] = my_array_unique($result_comparaprod['_source']['vinculo']);
$doc_existing['doc'] = $result_comparaprod['_source'];
$doc_existing["doc"]["concluido"] = "Não";
$doc_existing["doc_as_upsert"] = true;
$resultado = Elasticsearch::update($result_comparaprod['_id'], $doc_existing);
} else {
if (isset($doc['doc']['instituicao']['ano_ingresso'])) {
if (intval($doc["doc"]["datePublished"]) >= intval($doc['doc']["instituicao"]['ano_ingresso'])) {
$resultado = Elasticsearch::update($sha256, $doc);
}
} else {
$resultado = Elasticsearch::update($sha256, $doc);
}
}
} else {
$result_comparaprod = comparaprod_title($doc);
if (is_array($result_comparaprod)) {
$result_comparaprod['_source']['vinculo'] = array_merge($result_comparaprod['_source']['vinculo'], $doc['doc']["vinculo"]);
$result_comparaprod['_source']['vinculo'] = my_array_unique($result_comparaprod['_source']['vinculo']);
$doc_existing['doc'] = $result_comparaprod['_source'];
$doc_existing["doc"]["concluido"] = "Não";
$doc_existing["doc_as_upsert"] = true;
$resultado = Elasticsearch::update($result_comparaprod['_id'], $doc_existing);
} else {
if (isset($doc['doc']['instituicao']['ano_ingresso'])) {
if (intval($doc["doc"]["datePublished"]) >= intval($doc['doc']["instituicao"]['ano_ingresso'])) {
$resultado = Elasticsearch::update($sha256, $doc);
}
} else {
$resultado = Elasticsearch::update($sha256, $doc);
}
}
}
return $resultado;
}
if (!isset($_POST['numfuncional'])) {
$_POST['numfuncional'] = null;
}
if (!isset($_GET['unidade'])) {
$_POST['unidade'] = null;
}
if (!isset($_GET['tag'])) {
$_POST['tag'] = null;
}
// Testa se foi enviado um arquivo
if ($_FILES['file']['size'] != 0) {
$curriculo = simplexml_load_file($_FILES['file']['tmp_name']);
} else {
echo "Não foi enviado um arquivo XML";
if (isset($_REQUEST['unidade'])) {
$query["doc"]["unidade"] = explode("|", $_REQUEST['unidade']);
}
if (isset($_REQUEST['departamento'])) {
$query["doc"]["departamento"] = explode("|", $_REQUEST['departamento']);
}
if (isset($_REQUEST['tipvin'])) {
$query["doc"]["tipvin"] = explode("|", $_REQUEST['tipvin']);
}
if (isset($_REQUEST['divisao'])) {
$query["doc"]["divisao"] = explode("|", $_REQUEST['divisao']);
}
if (isset($_REQUEST['secao'])) {
$query['doc']['secao'] = explode("|", $_REQUEST['secao']);
}
if (isset($_REQUEST['ppg_nome'])) {
$query['doc']['ppg_nome'] = explode("|", $_REQUEST['ppg_nome']);
}
if (isset($_REQUEST['ppg_capes'])) {
$query['doc']['ppg_capes'] = explode("|", $_REQUEST['ppg_nome']);
}
if (isset($_REQUEST['genero'])) {
$query['doc']['genero'] = $_REQUEST['genero'];
}
if (isset($_REQUEST['etnia'])) {
$query['doc']['etnia'] = $_REQUEST['etnia'];
}
if (isset($_REQUEST['ano_ingresso'])) {
$query['doc']['ano_ingresso'] = $_REQUEST['ano_ingresso'];
}
if (isset($_REQUEST['desc_nivel'])) {
$query['doc']['desc_nivel'] = explode("|", $_REQUEST['desc_nivel']);
}
if (isset($_REQUEST['desc_curso'])) {
$query['doc']['desc_curso'] = explode("|", $_REQUEST['desc_curso']);
}
if (isset($_REQUEST['campus'])) {
$query['doc']['campus'] = explode("|", $_REQUEST['campus']);
}
if (isset($_REQUEST['desc_gestora'])) {
$query['doc']['desc_gestora'] = explode("|", $_REQUEST['desc_gestora']);
}
//$query["doc"]["lattesID"] = "Lattes ID não encontrado";
if (isset($_REQUEST['nome_completo'])) {
$query["doc"]["nome_completo"] = $_REQUEST['nome_completo'];
}
if (isset($_REQUEST['uuid'])) {
$id = $_REQUEST['uuid'];
} else {
$id = uniqid(rand(), true);
}
$query["doc_as_upsert"] = true;
$resultado_curriculo = Elasticsearch::update($id, $query, $index_cv);
print_r($resultado_curriculo);
unset($query);
exit();
}
// Inicio Currículo
$identificador = (string)$curriculo->attributes()->{'NUMERO-IDENTIFICADOR'};
$result_get_curriculo = get_curriculum($identificador);
$doc_curriculo_array = [];
if ($result_get_curriculo["found"] == true) {
$ppg_array = $result_get_curriculo["_source"]["ppg_nome"];
if (isset($_REQUEST['ppg_nome'])) {
$ppg_array[] = $_REQUEST['ppg_nome'];
}
$doc_curriculo_array['doc']['ppg_nome'] = array_unique($ppg_array);
} else {
if (isset($_REQUEST['ppg_nome'])) {
$doc_curriculo_array['doc']['ppg_nome'] = explode("|", $_REQUEST['ppg_nome']);
}
};
$doc_curriculo_array["doc"]["source"] = "Base Lattes";
$doc_curriculo_array["doc"]["type"] = "Curriculum";
$doc_curriculo_array["doc"]["tag"] = $_REQUEST['tag'];
$doc_curriculo_array["doc"]["unidade"] = explode("|", $_REQUEST['unidade']);
$doc_curriculo_array["doc"]["departamento"] = explode("|", $_REQUEST['departamento']);
$doc_curriculo_array["doc"]["numfuncional"] = $_REQUEST['numfuncional'];
if (isset($_REQUEST['tipvin'])) {
$doc_curriculo_array["doc"]["tipvin"] = explode("|", $_REQUEST['tipvin']);
}
if (isset($_REQUEST['divisao'])) {
$doc_curriculo_array["doc"]["divisao"] = explode("|", $_REQUEST['divisao']);
}
if (isset($_REQUEST['secao'])) {
$doc_curriculo_array['doc']['secao'] = explode("|", $_REQUEST['secao']);
}
if (isset($_REQUEST['ppg_capes'])) {
$doc_curriculo_array['doc']['ppg_capes'] = explode("|", $_REQUEST['ppg_capes']);
}
if (isset($_REQUEST['genero'])) {
$doc_curriculo_array['doc']['genero'] = $_REQUEST['genero'];
}
if (isset($_REQUEST['etnia'])) {
$doc_curriculo_array['doc']['etnia'] = $_REQUEST['etnia'];
}
if (isset($_REQUEST['ano_ingresso'])) {
$doc_curriculo_array['doc']['ano_ingresso'] = $_REQUEST['ano_ingresso'];
}
if (isset($_REQUEST['desc_nivel'])) {
$doc_curriculo_array['doc']['desc_nivel'] = explode("|", $_REQUEST['desc_nivel']);
}
if (isset($_REQUEST['desc_curso'])) {
$doc_curriculo_array['doc']['desc_curso'] = explode("|", $_REQUEST['desc_curso']);
}
if (isset($_REQUEST['campus'])) {
$doc_curriculo_array['doc']['campus'] = explode("|", $_REQUEST['campus']);
}
if (isset($_REQUEST['desc_gestora'])) {
$doc_curriculo_array['doc']['desc_gestora'] = explode("|", $_REQUEST['desc_gestora']);
}
print_r($curriculo->attributes()->{'DATA-ATUALIZACAO'});
$doc_curriculo_array["doc"]["data_atualizacao"] = substr((string)$curriculo->attributes()->{'DATA-ATUALIZACAO'}, 4, 4)."-".substr((string)$curriculo->attributes()->{'DATA-ATUALIZACAO'}, 2, 2);
echo "<br/>";
print_r($doc_curriculo_array["doc"]["data_atualizacao"]);
$doc_curriculo_array["doc"]["nome_completo"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'NOME-COMPLETO'};
$doc_curriculo_array["doc"]["nome_em_citacoes_bibliograficas"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'NOME-EM-CITACOES-BIBLIOGRAFICAS'};
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'NACIONALIDADE'})) {
$doc_curriculo_array["doc"]["nacionalidade"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'NACIONALIDADE'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'PAIS-DE-NASCIMENTO'})) {
$doc_curriculo_array["doc"]["pais_de_nascimento"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'PAIS-DE-NASCIMENTO'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'SIGLA-PAIS-NACIONALIDADE'})) {
$doc_curriculo_array["doc"]["sigla_pais_nacionalidade"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'SIGLA-PAIS-NACIONALIDADE'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'PAIS-DE-NACIONALIDADE'})) {
$doc_curriculo_array["doc"]["pais_de_nacionalidade"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'PAIS-DE-NACIONALIDADE'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'UF-NASCIMENTO'})) {
$doc_curriculo_array["doc"]["uf_nascimento"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'UF-NASCIMENTO'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'CIDADE-NASCIMENTO'})) {
$doc_curriculo_array["doc"]["cidade_nascimento"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'CIDADE-NASCIMENTO'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'DATA-FALECIMENTO'})) {
$doc_curriculo_array["doc"]["data_falecimento"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'DATA-FALECIMENTO'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->attributes()->{'ORCID-ID'})) {
$doc_curriculo_array["doc"]["orcid_id"] = (string)$curriculo->{'DADOS-GERAIS'}->attributes()->{'ORCID-ID'};
}
if (isset($curriculo->{'DADOS-GERAIS'}->{'RESUMO-CV'})) {
$doc_curriculo_array["doc"]["resumo_cv"]["texto_resumo_cv_rh"] = str_replace('"', '\"', (string)$curriculo->{'DADOS-GERAIS'}->{'RESUMO-CV'}->attributes()->{'TEXTO-RESUMO-CV-RH'});
if (isset($cursor["docs"][0]["dadosGerais"]["resumoCv"]["textoResumoCvRhEn"])) {
$doc_curriculo_array["doc"]["resumo_cv"]["texto_resumo_cv_rh_en"] = str_replace('"', '\"', (string)$curriculo->{'DADOS-GERAIS'}->{'RESUMO-CV'}->attributes()->{'TEXTO-RESUMO-CV-RH-EN'});
}
}
// // if (isset($cursor["docs"][0]["linksPesquisador"])){
// // foreach ($cursor["docs"][0]["linksPesquisador"] as $links_pesquisador) {
// // //print_r($links_pesquisador);
// // if ($links_pesquisador["origemLink"] == "orcid") {
// // $doc_curriculo_array["doc"]["orcid"] = $links_pesquisador["link"]["path"];
// // }
// // }
// // }
// Endereço profissional atual
if (isset($curriculo->{'DADOS-GERAIS'}->{'ENDERECO'})) {
$doc_curriculo_array["doc"]["endereco"]["flagDePreferencia"] = (string)$curriculo->{'DADOS-GERAIS'}->{'ENDERECO'}->attributes()->{'FLAG-DE-PREFERENCIA'};
if (isset($curriculo->{'DADOS-GERAIS'}->{'ENDERECO'}->{'ENDERECO-PROFISSIONAL'})) {
$enderecoProfissionalArray = get_object_vars($curriculo->{'DADOS-GERAIS'}->{'ENDERECO'}->{'ENDERECO-PROFISSIONAL'});
foreach (["CODIGO-INSTITUICAO-EMPRESA","NOME-INSTITUICAO-EMPRESA","CODIGO-ORGAO","NOME-ORGAO","CODIGO-UNIDADE","NOME-UNIDADE","LOGRADOURO-COMPLEMENTO","PAIS","UF","CEP","CIDADE","BAIRRO","HOME-PAGE"] as $endprof_campos) {
if (!empty($enderecoProfissionalArray["@attributes"][$endprof_campos])) {
$endprof_campos_corrigido = pregReplaceVariableName(strtolower($endprof_campos));
$doc_curriculo_array["doc"]["endereco"]["endereco_profissional"][$endprof_campos_corrigido] = $enderecoProfissionalArray["@attributes"][$endprof_campos];
}
}
}
}
// // // Quadro de citações
// // if (isset($cursor["docs"][0]["producaoBibliografica"]["artigosPublicados"]["totalQuadroCitacoes"])) {
// // $i = 0;
// // foreach ($cursor["docs"][0]["producaoBibliografica"]["artigosPublicados"]["totalQuadroCitacoes"] as $citacoes) {
// // foreach (["nomeBase","codigoBase","sequencialIndicador","numeroCitacoes","dataCitacao","textoArgumento","indiceH","numeroTrabalhos","uriPesquisadorBase","uriLogoBase"] as $citacoes_campos) {
// // if (isset ($citacoes[$citacoes_campos])) {
// // $doc_curriculo_array["doc"]["citacoes"][$citacoes["nomeBase"]][$citacoes_campos] = $citacoes[$citacoes_campos];
// // }
// // }
// // foreach (["uriPesquisadorBase"] as $identificador_pesquisador) {
// // if (!empty($citacoes[$identificador_pesquisador])) {
// // $doc_curriculo_array["doc"]["uri_pesquisador"][] = $citacoes[$identificador_pesquisador];
// // }
// // }
// // $i++;
// // }
// // }
// Formação Acadêmica Titulação
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'})) {
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'GRADUACAO'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'GRADUACAO'} as $graduacao) {
$graduacao = get_object_vars($graduacao);
$formacao_array["sequenciaFormacao"] = $graduacao['@attributes']["SEQUENCIA-FORMACAO"];
$formacao_array["nivel"] = $graduacao['@attributes']["NIVEL"];
$formacao_array["tituloDoTrabalhoDeConclusaoDeCurso"] = $graduacao['@attributes']["TITULO-DO-TRABALHO-DE-CONCLUSAO-DE-CURSO"];
$formacao_array["nomeDoOrientador"] = $graduacao['@attributes']["NOME-DO-ORIENTADOR"];
$formacao_array["codigoInstituicao"] = $graduacao['@attributes']["CODIGO-INSTITUICAO"];
$formacao_array["nomeInstituicao"] = $graduacao['@attributes']["NOME-INSTITUICAO"];
$formacao_array["codigoCurso"] = $graduacao['@attributes']["CODIGO-CURSO"];
$formacao_array["nomeCurso"] = $graduacao['@attributes']["NOME-CURSO"];
$formacao_array["codigoAreaCurso"] = $graduacao['@attributes']["CODIGO-AREA-CURSO"];
$formacao_array["statusDoCurso"] = $graduacao['@attributes']["STATUS-DO-CURSO"];
$formacao_array["anoDeInicio"] = $graduacao['@attributes']["ANO-DE-INICIO"];
$formacao_array["anoDeConclusao"] = $graduacao['@attributes']["ANO-DE-CONCLUSAO"];
$formacao_array["flagBolsa"] = $graduacao['@attributes']["FLAG-BOLSA"];
$formacao_array["codigoAgenciaFinanciadora"] = $graduacao['@attributes']["CODIGO-AGENCIA-FINANCIADORA"];
$formacao_array["nomeAgencia"] = $graduacao['@attributes']["NOME-AGENCIA"];
if (isset($graduacao['@attributes']["FORMACAO-ACADEMICA-TITULACAO"])) {
$formacao_array["formacaoAcademicaTitulacao"] = $graduacao['@attributes']["FORMACAO-ACADEMICA-TITULACAO"];
}
$doc_curriculo_array["doc"]["formacao_academica_titulacao_graduacao"][] = $formacao_array;
unset($formacao_array);
}
}
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'ESPECIALIZACAO'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'ESPECIALIZACAO'} as $especializacao) {
$especializacao = get_object_vars($especializacao);
$formacao_array["sequenciaFormacao"] = $especializacao['@attributes']["SEQUENCIA-FORMACAO"];
$formacao_array["nivel"] = $especializacao['@attributes']["NIVEL"];
$formacao_array["tituloDaMonografia"] = $especializacao['@attributes']["TITULO-DA-MONOGRAFIA"];
$formacao_array["nomeDoOrientador"] = $especializacao['@attributes']["NOME-DO-ORIENTADOR"];
$formacao_array["codigoInstituicao"] = $especializacao['@attributes']["CODIGO-INSTITUICAO"];
$formacao_array["nomeInstituicao"] = $especializacao['@attributes']["NOME-INSTITUICAO"];
$formacao_array["codigoCurso"] = $especializacao['@attributes']["CODIGO-CURSO"];
$formacao_array["nomeCurso"] = $especializacao['@attributes']["NOME-CURSO"];
$formacao_array["statusDoCurso"] = $especializacao['@attributes']["STATUS-DO-CURSO"];
$formacao_array["anoDeInicio"] = $especializacao['@attributes']["ANO-DE-INICIO"];
$formacao_array["anoDeConclusao"] = $especializacao['@attributes']["ANO-DE-CONCLUSAO"];
$formacao_array["flagBolsa"] = $especializacao['@attributes']["FLAG-BOLSA"];
$formacao_array["codigoAgenciaFinanciadora"] = $especializacao['@attributes']["CODIGO-AGENCIA-FINANCIADORA"];
$formacao_array["nomeAgencia"] = $especializacao['@attributes']["NOME-AGENCIA"];
$formacao_array["cargaHoraria"] = $especializacao['@attributes']["CARGA-HORARIA"];
$doc_curriculo_array["doc"]["formacao_academica_titulacao_especializacao"][] = $formacao_array;
unset($formacao_array);
}
}
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'MESTRADO'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'MESTRADO'} as $mestrado) {
$mestrado = get_object_vars($mestrado);
$formacao_array["sequenciaFormacao"] = $mestrado['@attributes']["SEQUENCIA-FORMACAO"];
$formacao_array["nivel"] = $mestrado['@attributes']["NIVEL"];
$formacao_array["tituloDaDissertacaoTese"] = $mestrado['@attributes']["TITULO-DA-DISSERTACAO-TESE"];
$formacao_array["nomeDoOrientador"] = $mestrado['@attributes']["NOME-COMPLETO-DO-ORIENTADOR"];
$formacao_array["nomeDoCoOrientador"] = $mestrado['@attributes']["NOME-DO-CO-ORIENTADOR"];
$formacao_array["codigoInstituicao"] = $mestrado['@attributes']["CODIGO-INSTITUICAO"];
$formacao_array["nomeInstituicao"] = $mestrado['@attributes']["NOME-INSTITUICAO"];
$formacao_array["codigoCurso"] = $mestrado['@attributes']["CODIGO-CURSO"];
$formacao_array["codigoCursoCapes"] = $mestrado['@attributes']["CODIGO-CURSO-CAPES"];
$formacao_array["nomeCurso"] = $mestrado['@attributes']["NOME-CURSO"];
$formacao_array["codigoAreaCurso"] = $mestrado['@attributes']["CODIGO-AREA-CURSO"];
$formacao_array["statusDoCurso"] = $mestrado['@attributes']["STATUS-DO-CURSO"];
$formacao_array["anoDeInicio"] = $mestrado['@attributes']["ANO-DE-INICIO"];
$formacao_array["anoDeConclusao"] = $mestrado['@attributes']["ANO-DE-CONCLUSAO"];
$formacao_array["flagBolsa"] = $mestrado['@attributes']["FLAG-BOLSA"];
$formacao_array["tipoMestrado"] = $mestrado['@attributes']["TIPO-MESTRADO"];
$formacao_array["codigoAgenciaFinanciadora"] = $mestrado['@attributes']["CODIGO-AGENCIA-FINANCIADORA"];
$formacao_array["nomeAgencia"] = $mestrado['@attributes']["NOME-AGENCIA"];
$formacao_array["anoDeObtencaoDoTitulo"] = $mestrado['@attributes']["ANO-DE-OBTENCAO-DO-TITULO"];
if (isset($mestrado["PALAVRAS-CHAVE"])) {
$array_result_pc = processaPalavrasChaveFormacaoLattes($mestrado["PALAVRAS-CHAVE"]);
if (isset($array_result_pc)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_pc);
}
}
if (isset($mestrado["AREAS-DO-CONHECIMENTO"])) {
if (!empty($mestrado["AREAS-DO-CONHECIMENTO"])) {
$array_result_ac = processaAreaDoConhecimentoFormacaoLattes($mestrado["AREAS-DO-CONHECIMENTO"]);
if (isset($array_result_ac)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_ac);
}
}
}
$doc_curriculo_array["doc"]["formacao_academica_titulacao_mestrado"][] = $formacao_array;
unset($formacao_array);
}
}
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'MESTRADO-PROFISSIONALIZANTE'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'MESTRADO-PROFISSIONALIZANTE'} as $mestradoProf) {
$mestradoProf = get_object_vars($mestradoProf);
$formacao_array["sequenciaFormacao"]=$mestradoProf['@attributes']["SEQUENCIA-FORMACAO"];
$formacao_array["nivel"]=$mestradoProf['@attributes']["NIVEL"];
$formacao_array["codigoInstituicao"]=$mestradoProf['@attributes']["CODIGO-INSTITUICAO"];
$formacao_array["nomeInstituicao"]=$mestradoProf['@attributes']["NOME-INSTITUICAO"];
$formacao_array["codigoCurso"]=$mestradoProf['@attributes']["CODIGO-CURSO"];
$formacao_array["nomeCurso"]=$mestradoProf['@attributes']["NOME-CURSO"];
$formacao_array["codigoAreaCurso"]=$mestradoProf['@attributes']["CODIGO-AREA-CURSO"];
$formacao_array["statusDoCurso"]=$mestradoProf['@attributes']["STATUS-DO-CURSO"];
$formacao_array["anoDeInicio"]=$mestradoProf['@attributes']["ANO-DE-INICIO"];
$formacao_array["anoDeConclusao"]=$mestradoProf['@attributes']["ANO-DE-CONCLUSAO"];
$formacao_array["flagBolsa"]=$mestradoProf['@attributes']["FLAG-BOLSA"];
$formacao_array["codigoAgenciaFinanciadora"]=$mestradoProf['@attributes']["CODIGO-AGENCIA-FINANCIADORA"];
$formacao_array["nomeAgencia"]=$mestradoProf['@attributes']["NOME-AGENCIA"];
$formacao_array["anoDeObtencaoDoTitulo"]=$mestradoProf['@attributes']["ANO-DE-OBTENCAO-DO-TITULO"];
$formacao_array["tituloDaDissertacaoTese"]=$mestradoProf['@attributes']["TITULO-DA-DISSERTACAO-TESE"];
$formacao_array["nomeDoOrientador"]=$mestradoProf['@attributes']["NOME-COMPLETO-DO-ORIENTADOR"];
$formacao_array["nomeDoCoOrientador"]=$mestradoProf['@attributes']["NOME-DO-CO-ORIENTADOR"];
if (isset($mestradoProf["PALAVRAS-CHAVE"])) {
$array_result_pc = processaPalavrasChaveFormacaoLattes($mestradoProf["PALAVRAS-CHAVE"]);
if (isset($array_result_pc)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_pc);
}
}
if (isset($mestradoProf["AREAS-DO-CONHECIMENTO"])) {
if (!empty($mestradoProf["AREAS-DO-CONHECIMENTO"])) {
$array_result_ac = processaAreaDoConhecimentoFormacaoLattes($mestradoProf["AREAS-DO-CONHECIMENTO"]);
if (isset($array_result_ac)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_ac);
}
}
}
$doc_curriculo_array["doc"]["formacao_academica_titulacao_mestradoProfissionalizante"][] = $formacao_array;
unset($formacao_array);
}
}
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'DOUTORADO'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'DOUTORADO'} as $doutorado) {
$doutorado = get_object_vars($doutorado);
$formacao_array["sequenciaFormacao"]=$doutorado['@attributes']["SEQUENCIA-FORMACAO"];
$formacao_array["nivel"]=$doutorado['@attributes']["NIVEL"];
$formacao_array["codigoInstituicao"]=$doutorado['@attributes']["CODIGO-INSTITUICAO"];
$formacao_array["nomeInstituicao"]=$doutorado['@attributes']["NOME-INSTITUICAO"];
$formacao_array["codigoCurso"]=$doutorado['@attributes']["CODIGO-CURSO"];
$formacao_array["nomeCurso"]=$doutorado['@attributes']["NOME-CURSO"];
$formacao_array["codigoAreaCurso"]=$doutorado['@attributes']["CODIGO-AREA-CURSO"];
$formacao_array["statusDoCurso"]=$doutorado['@attributes']["STATUS-DO-CURSO"];
$formacao_array["anoDeInicio"]=$doutorado['@attributes']["ANO-DE-INICIO"];
$formacao_array["anoDeConclusao"]=$doutorado['@attributes']["ANO-DE-CONCLUSAO"];
$formacao_array["flagBolsa"]=$doutorado['@attributes']["FLAG-BOLSA"];
$formacao_array["codigoAgenciaFinanciadora"]=$doutorado['@attributes']["CODIGO-AGENCIA-FINANCIADORA"];
$formacao_array["nomeAgencia"]=$doutorado['@attributes']["NOME-AGENCIA"];
$formacao_array["anoDeObtencaoDoTitulo"]=$doutorado['@attributes']["ANO-DE-OBTENCAO-DO-TITULO"];
$formacao_array["tituloDaDissertacaoTese"]=$doutorado['@attributes']["TITULO-DA-DISSERTACAO-TESE"];
$formacao_array["nomeDoOrientador"]=$doutorado['@attributes']["NOME-COMPLETO-DO-ORIENTADOR"];
$formacao_array["tipoDoutorado"]=$doutorado['@attributes']["TIPO-DOUTORADO"];
$formacao_array["numeroIDOrientador"]=$doutorado['@attributes']["NUMERO-ID-ORIENTADOR"];
$formacao_array["codigoCursoCapes"]=$doutorado['@attributes']["CODIGO-CURSO-CAPES"];
$formacao_array["nomeDoCoOrientador"]=$doutorado['@attributes']["NOME-DO-CO-ORIENTADOR"];
$formacao_array["codigoInstituicaoCoTutela"]=$doutorado['@attributes']["CODIGO-INSTITUICAO-CO-TUTELA"];
$formacao_array["codigoInstituicaoSanduiche"]=$doutorado['@attributes']["CODIGO-INSTITUICAO-SANDUICHE"];
if (isset($doutorado["PALAVRAS-CHAVE"])) {
$array_result_pc = processaPalavrasChaveFormacaoLattes($doutorado["PALAVRAS-CHAVE"]);
if (isset($array_result_pc)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_pc);
}
}
if (isset($doutorado["AREAS-DO-CONHECIMENTO"])) {
if (!empty($doutorado["AREAS-DO-CONHECIMENTO"])) {
$array_result_ac = processaAreaDoConhecimentoFormacaoLattes($doutorado["AREAS-DO-CONHECIMENTO"]);
if (isset($array_result_ac)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_ac);
}
}
}
$doc_curriculo_array["doc"]["formacao_academica_titulacao_doutorado"][] = $formacao_array;
unset($formacao_array);
}
}
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'POS-DOUTORADO'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'POS-DOUTORADO'} as $posDoutorado) {
$posDoutorado = get_object_vars($posDoutorado);
$formacao_array["sequenciaFormacao"]=$posDoutorado['@attributes']["SEQUENCIA-FORMACAO"];
$formacao_array["nivel"]=$posDoutorado['@attributes']["NIVEL"];
$formacao_array["codigoInstituicao"]=$posDoutorado['@attributes']["CODIGO-INSTITUICAO"];
$formacao_array["nomeInstituicao"]=$posDoutorado['@attributes']["NOME-INSTITUICAO"];
$formacao_array["anoDeInicio"]=$posDoutorado['@attributes']["ANO-DE-INICIO"];
$formacao_array["anoDeConclusao"]=$posDoutorado['@attributes']["ANO-DE-CONCLUSAO"];
$formacao_array["anoDeObtencaoDoTitulo"]=$posDoutorado['@attributes']["ANO-DE-OBTENCAO-DO-TITULO"];
$formacao_array["flagBolsa"]=$posDoutorado['@attributes']["FLAG-BOLSA"];
$formacao_array["codigoAgenciaFinanciadora"]=$posDoutorado['@attributes']["CODIGO-AGENCIA-FINANCIADORA"];
$formacao_array["nomeAgencia"]=$posDoutorado['@attributes']["NOME-AGENCIA"];
$formacao_array["statusDoCurso"]=$posDoutorado['@attributes']["STATUS-DO-CURSO"];
$formacao_array["numeroIDOrientador"]=$posDoutorado['@attributes']["NUMERO-ID-ORIENTADOR"];
$formacao_array["tituloDoTrabalho"]=$posDoutorado['@attributes']["TITULO-DO-TRABALHO"];
if (isset($posDoutorado["PALAVRAS-CHAVE"])) {
$array_result_pc = processaPalavrasChaveFormacaoLattes($posDoutorado["PALAVRAS-CHAVE"]);
if (isset($array_result_pc)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_pc);
}
}
if (isset($posDoutorado["AREAS-DO-CONHECIMENTO"])) {
if (!empty($posDoutorado["AREAS-DO-CONHECIMENTO"])) {
$array_result_ac = processaAreaDoConhecimentoFormacaoLattes($posDoutorado["AREAS-DO-CONHECIMENTO"]);
if (isset($array_result_ac)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_ac);
}
}
}
$doc_curriculo_array["doc"]["formacao_academica_titulacao_pos_doutorado"][] = $formacao_array;
unset($formacao_array);
}
}
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'LIVRE-DOCENCIA'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'LIVRE-DOCENCIA'} as $livreDocencia) {
$livreDocencia = get_object_vars($livreDocencia);
$formacao_array["sequenciaFormacao"]=$livreDocencia['@attributes']["SEQUENCIA-FORMACAO"];
$formacao_array["nivel"]=$livreDocencia['@attributes']["NIVEL"];
$formacao_array["codigoInstituicao"]=$livreDocencia['@attributes']["CODIGO-INSTITUICAO"];
$formacao_array["nomeInstituicao"]=$livreDocencia['@attributes']["NOME-INSTITUICAO"];
$formacao_array["anoDeObtencaoDoTitulo"]=$livreDocencia['@attributes']["ANO-DE-OBTENCAO-DO-TITULO"];
$formacao_array["tituloDoTrabalho"]=$livreDocencia['@attributes']["TITULO-DO-TRABALHO"];
if (isset($livreDocencia["PALAVRAS-CHAVE"])) {
$array_result_pc = processaPalavrasChaveFormacaoLattes($livreDocencia["PALAVRAS-CHAVE"]);
if (isset($array_result_pc)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_pc);
}
}
if (isset($livreDocencia["AREAS-DO-CONHECIMENTO"])) {
if (!empty($livreDocencia["AREAS-DO-CONHECIMENTO"])) {
$array_result_ac = processaAreaDoConhecimentoFormacaoLattes($livreDocencia["AREAS-DO-CONHECIMENTO"]);
if (isset($array_result_ac)) {
$formacao_array = array_merge_recursive($formacao_array, $array_result_ac);
}
}
}
$doc_curriculo_array["doc"]["formacao_academica_titulacao_livreDocencia"][] = $formacao_array;
unset($formacao_array);
}
}
}
// Formação máxima
if (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'LIVRE-DOCENCIA'})) {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Livre Docência";
} elseif (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'POS-DOUTORADO'})) {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Pós Doutorado";
} elseif (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'DOUTORADO'})) {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Doutorado";
} elseif (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'MESTRADO-PROFISSIONALIZANTE'})) {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Mestrado";
} elseif (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'MESTRADO'})) {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Mestrado";
} elseif (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'ESPECIALIZACAO'})) {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Especialização";
} elseif (isset($curriculo->{'DADOS-GERAIS'}->{'FORMACAO-ACADEMICA-TITULACAO'}->{'GRADUACAO'})) {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Graduação";
} else {
$doc_curriculo_array["doc"]["formacao_maxima"] = "Sem formação informada";
}
// Projetos de pesquisa
if (isset($curriculo->{'DADOS-GERAIS'}->{'ATUACOES-PROFISSIONAIS'})) {
$doc_curriculo_array["doc"]["atuacoes_profissionais"] = $curriculo->{'DADOS-GERAIS'}->{'ATUACOES-PROFISSIONAIS'};
}
// Idiomas
if (isset($curriculo->{'DADOS-GERAIS'}->{'IDIOMAS'})) {
foreach ($curriculo->{'DADOS-GERAIS'}->{'IDIOMAS'}->{'IDIOMA'} as $idioma) {
$idioma = get_object_vars($idioma);
$idioma_array["idioma"]=$idioma['@attributes']["IDIOMA"];
$idioma_array["descricaoDoIdioma"]=$idioma['@attributes']["DESCRICAO-DO-IDIOMA"];
$idioma_array["proficienciaDeLeitura"]=$idioma['@attributes']["PROFICIENCIA-DE-LEITURA"];
$idioma_array["proficienciaDeFala"]=$idioma['@attributes']["PROFICIENCIA-DE-FALA"];
$idioma_array["proficienciaDeFala"]=$idioma['@attributes']["PROFICIENCIA-DE-FALA"];
$idioma_array["proficienciaDeEscrita"]=$idioma['@attributes']["PROFICIENCIA-DE-ESCRITA"];
$idioma_array["proficienciaDeCompreensao"]=$idioma['@attributes']["PROFICIENCIA-DE-COMPREENSAO"];
$doc_curriculo_array["doc"]["idiomas"][] = $idioma_array;
unset($idioma_array);
}
}
// Premios - Títulos
if (isset($curriculo->{'DADOS-GERAIS'}->{'PREMIOS-TITULOS'})) {
$i_premio = 0;
foreach ($curriculo->{'DADOS-GERAIS'}->{'PREMIOS-TITULOS'}->{'PREMIO-TITULO'} as $premioTitulo) {
$premioTitulo = get_object_vars($premioTitulo);
$doc_curriculo_array["doc"]["premios_titulos"][$i_premio]["nomeDoPremioOuTitulo"]=$premioTitulo['@attributes']["NOME-DO-PREMIO-OU-TITULO"];
$doc_curriculo_array["doc"]["premios_titulos"][$i_premio]["nomeDaEntidadePromotora"]=$premioTitulo['@attributes']["NOME-DA-ENTIDADE-PROMOTORA"];
$doc_curriculo_array["doc"]["premios_titulos"][$i_premio]["anoDaPremiacao"]=$premioTitulo['@attributes']["ANO-DA-PREMIACAO"];
$doc_curriculo_array["doc"]["premios_titulos"][$i_premio]["nomeDoPremioOuTituloIngles"]=$premioTitulo['@attributes']["NOME-DO-PREMIO-OU-TITULO-INGLES"];
$i_premio++;
}
}
// Licença Maternidade
if (isset($curriculo->{'DADOS-GERAIS'}->{'LICENCAS'})) {
$i_licenca = 0;
foreach ($curriculo->{'DADOS-GERAIS'}->{'LICENCAS'}->{'LICENCA'} as $licenca) {
$licenca = get_object_vars($licenca);
$licenca_array[$i_premio]["tipoLicenca"]=$licenca['@attributes']["TIPO-LICENCA"];
$licenca_array[$i_premio]["dataInicioLicenca"]=$licenca['@attributes']["DATA-INICIO-LICENCA"];
$licenca_array[$i_premio]["dataFimLicenca"]=$licenca['@attributes']["DATA-FIM-LICENCA"];
$doc_curriculo_array["doc"]["licencas"][] = $licenca_array;
$i_licenca++;
unset($licenca_array);
}
}
// Orientações em andamento
if (isset($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'})) {
// echo "<pre>".print_r($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'},true)."</pre>";
// Mestrado
$i_orientacao = 0;
if (isset($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'}->{'ORIENTACAO-EM-ANDAMENTO-DE-MESTRADO'})) {
foreach ($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'}->{'ORIENTACAO-EM-ANDAMENTO-DE-MESTRADO'} as $orientacao) {
$orientacao = get_object_vars($orientacao);
$dadosBasicosDaOrientacao = get_object_vars($orientacao["DADOS-BASICOS-DA-ORIENTACAO-EM-ANDAMENTO-DE-MESTRADO"]);
$detalhamentoDaOrientacao = get_object_vars($orientacao["DETALHAMENTO-DA-ORIENTACAO-EM-ANDAMENTO-DE-MESTRADO"]);
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["natureza"]=$dadosBasicosDaOrientacao['@attributes']["NATUREZA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["titulo"]=$dadosBasicosDaOrientacao['@attributes']["TITULO-DO-TRABALHO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["ano"]=$dadosBasicosDaOrientacao['@attributes']["ANO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["tipoDeOrientacao"]=$detalhamentoDaOrientacao['@attributes']["TIPO-DE-ORIENTACAO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDoOrientando"]=$detalhamentoDaOrientacao['@attributes']["NOME-DO-ORIENTANDO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDaInstituicao"]=$detalhamentoDaOrientacao['@attributes']["NOME-INSTITUICAO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDoCurso"]=$detalhamentoDaOrientacao['@attributes']["NOME-CURSO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["flagBolsa"]=$detalhamentoDaOrientacao['@attributes']["FLAG-BOLSA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDaAgencia"]=$detalhamentoDaOrientacao['@attributes']["NOME-DA-AGENCIA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["numeroIDOrientado"]=$detalhamentoDaOrientacao['@attributes']["NUMERO-ID-ORIENTADO"];
//$doc_curriculo_array["doc"]["orientacoes"][] = $orientacao_array;
$i_orientacao++;
}
}
// Doutorado
if (isset($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'}->{'ORIENTACAO-EM-ANDAMENTO-DE-DOUTORADO'})) {
foreach ($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'}->{'ORIENTACAO-EM-ANDAMENTO-DE-DOUTORADO'} as $orientacao) {
$orientacao = get_object_vars($orientacao);
$dadosBasicosDaOrientacao = get_object_vars($orientacao["DADOS-BASICOS-DA-ORIENTACAO-EM-ANDAMENTO-DE-DOUTORADO"]);
$detalhamentoDaOrientacao = get_object_vars($orientacao["DETALHAMENTO-DA-ORIENTACAO-EM-ANDAMENTO-DE-DOUTORADO"]);
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["natureza"]=$dadosBasicosDaOrientacao['@attributes']["NATUREZA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["titulo"]=$dadosBasicosDaOrientacao['@attributes']["TITULO-DO-TRABALHO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["ano"]=$dadosBasicosDaOrientacao['@attributes']["ANO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["tipoDeOrientacao"]=$detalhamentoDaOrientacao['@attributes']["TIPO-DE-ORIENTACAO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDoOrientando"]=$detalhamentoDaOrientacao['@attributes']["NOME-DO-ORIENTANDO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDaInstituicao"]=$detalhamentoDaOrientacao['@attributes']["NOME-INSTITUICAO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDoCurso"]=$detalhamentoDaOrientacao['@attributes']["NOME-CURSO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["flagBolsa"]=$detalhamentoDaOrientacao['@attributes']["FLAG-BOLSA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDaAgencia"]=$detalhamentoDaOrientacao['@attributes']["NOME-DA-AGENCIA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["numeroIDOrientado"]=$detalhamentoDaOrientacao['@attributes']["NUMERO-ID-ORIENTANDO"];
//$doc_curriculo_array["doc"]["orientacoes"][] = $orientacao_array;
$i_orientacao++;
}
}
// Pós-doutorado
if (isset($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'}->{'ORIENTACAO-EM-ANDAMENTO-DE-POS-DOUTORADO'})) {
foreach ($curriculo->{'DADOS-COMPLEMENTARES'}->{'ORIENTACOES-EM-ANDAMENTO'}->{'ORIENTACAO-EM-ANDAMENTO-DE-POS-DOUTORADO'} as $orientacao) {
$orientacao = get_object_vars($orientacao);
$dadosBasicosDaOrientacao = get_object_vars($orientacao["DADOS-BASICOS-DA-ORIENTACAO-EM-ANDAMENTO-DE-POS-DOUTORADO"]);
$detalhamentoDaOrientacao = get_object_vars($orientacao["DETALHAMENTO-DA-ORIENTACAO-EM-ANDAMENTO-DE-POS-DOUTORADO"]);
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["natureza"]=$dadosBasicosDaOrientacao['@attributes']["NATUREZA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["titulo"]=$dadosBasicosDaOrientacao['@attributes']["TITULO-DO-TRABALHO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["ano"]=$dadosBasicosDaOrientacao['@attributes']["ANO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["tipoDeOrientacao"]=$detalhamentoDaOrientacao['@attributes']["TIPO-DE-ORIENTACAO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDoOrientando"]=$detalhamentoDaOrientacao['@attributes']["NOME-DO-ORIENTANDO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDaInstituicao"]=$detalhamentoDaOrientacao['@attributes']["NOME-INSTITUICAO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDoCurso"]=$detalhamentoDaOrientacao['@attributes']["NOME-CURSO"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["flagBolsa"]=$detalhamentoDaOrientacao['@attributes']["FLAG-BOLSA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["nomeDaAgencia"]=$detalhamentoDaOrientacao['@attributes']["NOME-DA-AGENCIA"];
$doc_curriculo_array["doc"]["orientacoes"][$i_orientacao]["numeroIDOrientado"]=$detalhamentoDaOrientacao['@attributes']["NUMERO-ID-ORIENTANDO"];
//$doc_curriculo_array["doc"]["orientacoes"][] = $orientacao_array;
$i_orientacao++;
}
}
}
// Orientações concluídas
if (isset($curriculo->{'OUTRA-PRODUCAO'}->{'ORIENTACOES-CONCLUIDAS'})) {
//var_dump($curriculo->{'OUTRA-PRODUCAO'}->{'ORIENTACOES-CONCLUIDAS'});
$i_orientacao_concluida = 0;
if (isset($curriculo->{'OUTRA-PRODUCAO'}->{'ORIENTACOES-CONCLUIDAS'}->{'ORIENTACOES-CONCLUIDAS-PARA-MESTRADO'})) {
foreach ($curriculo->{'OUTRA-PRODUCAO'}->{'ORIENTACOES-CONCLUIDAS'}->{'ORIENTACOES-CONCLUIDAS-PARA-MESTRADO'} as $orientacao_concluida) {
$orientacao_concluida = get_object_vars($orientacao_concluida);
$dadosBasicosDaOrientacao = get_object_vars($orientacao_concluida["DADOS-BASICOS-DE-ORIENTACOES-CONCLUIDAS-PARA-MESTRADO"]);
$detalhamentoDaOrientacao = get_object_vars($orientacao_concluida["DETALHAMENTO-DE-ORIENTACOES-CONCLUIDAS-PARA-MESTRADO"]);
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["natureza"]=$dadosBasicosDaOrientacao['@attributes']["NATUREZA"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["titulo"]=$dadosBasicosDaOrientacao['@attributes']["TITULO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["ano"]=$dadosBasicosDaOrientacao['@attributes']["ANO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["tipoDeOrientacao"]=$detalhamentoDaOrientacao['@attributes']["TIPO-DE-ORIENTACAO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDoOrientando"]=$detalhamentoDaOrientacao['@attributes']["NOME-DO-ORIENTADO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDaInstituicao"]=$detalhamentoDaOrientacao['@attributes']["NOME-DA-INSTITUICAO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDoCurso"]=$detalhamentoDaOrientacao['@attributes']["NOME-DO-CURSO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["flagBolsa"]=$detalhamentoDaOrientacao['@attributes']["FLAG-BOLSA"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDaAgencia"]=$detalhamentoDaOrientacao['@attributes']["NOME-DA-AGENCIA"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["numeroIDOrientado"]=$detalhamentoDaOrientacao['@attributes']["NUMERO-ID-ORIENTADO"];
$i_orientacao_concluida++;
}
}
if (isset($curriculo->{'OUTRA-PRODUCAO'}->{'ORIENTACOES-CONCLUIDAS'}->{'ORIENTACOES-CONCLUIDAS-PARA-DOUTORADO'})) {
foreach ($curriculo->{'OUTRA-PRODUCAO'}->{'ORIENTACOES-CONCLUIDAS'}->{'ORIENTACOES-CONCLUIDAS-PARA-DOUTORADO'} as $orientacao_concluida) {
$orientacao_concluida = get_object_vars($orientacao_concluida);
$dadosBasicosDaOrientacao = get_object_vars($orientacao_concluida["DADOS-BASICOS-DE-ORIENTACOES-CONCLUIDAS-PARA-DOUTORADO"]);
$detalhamentoDaOrientacao = get_object_vars($orientacao_concluida["DETALHAMENTO-DE-ORIENTACOES-CONCLUIDAS-PARA-DOUTORADO"]);
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["natureza"]=$dadosBasicosDaOrientacao['@attributes']["NATUREZA"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["titulo"]=$dadosBasicosDaOrientacao['@attributes']["TITULO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["ano"]=$dadosBasicosDaOrientacao['@attributes']["ANO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["tipoDeOrientacao"]=$detalhamentoDaOrientacao['@attributes']["TIPO-DE-ORIENTACAO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDoOrientando"]=$detalhamentoDaOrientacao['@attributes']["NOME-DO-ORIENTADO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDaInstituicao"]=$detalhamentoDaOrientacao['@attributes']["NOME-DA-INSTITUICAO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDoCurso"]=$detalhamentoDaOrientacao['@attributes']["NOME-DO-CURSO"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["flagBolsa"]=$detalhamentoDaOrientacao['@attributes']["FLAG-BOLSA"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["nomeDaAgencia"]=$detalhamentoDaOrientacao['@attributes']["NOME-DA-AGENCIA"];
$doc_curriculo_array["doc"]["orientacoesconcluidas"][$i_orientacao_concluida]["numeroIDOrientado"]=$detalhamentoDaOrientacao['@attributes']["NUMERO-ID-ORIENTADO"];
$i_orientacao_concluida++;
}
}
}
$doc_curriculo_array["doc"]["lattesID"] = $identificador;
$doc_curriculo_array["doc"]["dataDeColeta"] = date('Y-m-d');
$doc_curriculo_array["doc_as_upsert"] = true;
$resultado_curriculo = Elasticsearch::update($identificador, $doc_curriculo_array, $index_cv);
var_dump($resultado_curriculo);
//Parser de Trabalhos-em-Eventos
if (isset($curriculo->{'PRODUCAO-BIBLIOGRAFICA'}->{'TRABALHOS-EM-EVENTOS'})) {
$trabalhosEmEventosArray = $curriculo->{'PRODUCAO-BIBLIOGRAFICA'}->{'TRABALHOS-EM-EVENTOS'}->{'TRABALHO-EM-EVENTOS'};
foreach ($trabalhosEmEventosArray as $obra) {
$obra = get_object_vars($obra);
$dadosBasicosDoTrabalho = get_object_vars($obra["DADOS-BASICOS-DO-TRABALHO"]);
$detalhamentoDoTrabalho = get_object_vars($obra["DETALHAMENTO-DO-TRABALHO"]);
$doc["doc"]["type"] = "Work";
$doc["doc"]["tipo"] = "Trabalhos em eventos";
$doc["doc"]["source"] = "Base Lattes";
$doc["doc"]["lattes_ids"][] = (string)$curriculo->attributes()->{'NUMERO-IDENTIFICADOR'};
if (isset($_REQUEST['tag'])) {