-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExtractAcademicsConferences.php
74 lines (65 loc) · 2.32 KB
/
ExtractAcademicsConferences.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
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of ExtractAcademicsConferences
*
* @author 6opC4C3
*/
class ExtractAcademicsConferences {
private $queryMsa;
private $jsonToObj;
public function __construct(){
$this->queryMsa = new QueryMsa();
$this->jsonToObj = new JsonToObject();
}
private function saveConferences(&$conferences){
$conferenceDao = new ConferenceDao();
foreach($conferences as $conference){
$conferenceDao->insert($conference);
}
}
private function searchConferencesByIds($batchCount, $conferenceIds){
$conferencesFound = array();
$jsonResults = $this->queryMsa->searchConferences($conferenceIds);
if(isset($jsonResults)){
$conferencesFound = $this->jsonToObj->toConferences($jsonResults);
$this->saveConferences($conferencesFound);
}
return $conferencesFound;
}
public function retrieveConferencesForPapers(){
$paperDao = new PaperDao();
// Papers without journal
$papers = $paperDao->findPapersWithoutConference();
$recordIds = array();
$count = 0;
$flush = false;
$batchCount = 0;
foreach($papers as $paper){
$flush = false;
if($paper->msaConferenceId > 0){
$recordIds[$count] = $paper->msaConferenceId;
if($count >= QueryMsa::MAX_RECORDS_PER_QUERY){
$recordIdsUnique = array_unique($recordIds, SORT_NUMERIC);
$this->searchConferencesByIds($batchCount, $recordIdsUnique);
$count = 0;
unset($recordIds);
$recordIds = array();
$flush = true;
$batchCount++;
}else{
$count++;
}
}
}
if($flush == false && count($recordIds)> 0){
$recordIdsUnique = array_unique($recordIds, SORT_NUMERIC);
$this->searchConferencesByIds($batchCount, $recordIdsUnique);
}
(new ConferenceDao())->fixEraEntryForeignKey();
}
}