1
|
<?php
|
2
|
|
3
|
defined('_JEXEC') or die('Access denied');
|
4
|
|
5
|
jimport('joomla.application.component.model');
|
6
|
jimport('joomla.base.object');
|
7
|
jimport('joomla.cache.cache');
|
8
|
jimport('joomla.http.http');
|
9
|
jimport('joomla.log.log');
|
10
|
|
11
|
// This model implements document searching using web search.
|
12
|
class OpenAireModelSearch extends JModel {
|
13
|
const LOG = 'openaire';
|
14
|
const CACHE_GROUP = 'openaire.search';
|
15
|
const PUBLICATION_STATISTICS_CACHE_ID = 'statistics.publications';
|
16
|
const DATASET_STATISTICS_CACHE_ID = 'statistics.datasets';
|
17
|
const PROJECT_STATISTICS_CACHE_ID = 'statistics.projects';
|
18
|
const PEOPLE_STATISTICS_CACHE_ID = 'statistics.people';
|
19
|
const ORGANIZATION_STATISTICS_CACHE_ID = 'statistics.organizations';
|
20
|
const DATASOURCE_STATISTICS_CACHE_ID = 'statistics.datasource';
|
21
|
const SEARCH_PUBLICATIONS_CACHE_ID = 'search.publications';
|
22
|
const SEARCH_DATASETS_CACHE_ID = 'search.datasets';
|
23
|
const SEARCH_PROJECTS_CACHE_ID = 'search.projects';
|
24
|
const SEARCH_PEOPLE_CACHE_ID = 'search.people';
|
25
|
const SEARCH_ORGANIZATIONS_CACHE_ID = 'search.organizations';
|
26
|
const SEARCH_DATASOURCES_CACHE_ID = 'search.datasources';
|
27
|
const BROWSE_PUBLICATIONS_CACHE_ID = 'browse.publications';
|
28
|
const BROWSE_DATASETS_CACHE_ID = 'browse.datasets';
|
29
|
const BROWSE_PROJECTS_CACHE_ID = 'browse.projects';
|
30
|
const BROWSE_PEOPLE_CACHE_ID = 'browse.people';
|
31
|
const BROWSE_ORGANIZATIONS_CACHE_ID = 'browse.organizations';
|
32
|
const BROWSE_DATASOURCES_CACHE_ID = 'browse.datasources';
|
33
|
const ADVANCED_SEARCH_PUBLICATIONS_CACHE_ID = 'advanced.publications';
|
34
|
const ADVANCED_SEARCH_PROJECTS_CACHE_ID = 'advanced.projects';
|
35
|
const ADVANCED_SEARCH_PEOPLE_CACHE_ID = 'advanced.people';
|
36
|
const ADVANCED_SEARCH_ORGANIZATIONS_CACHE_ID = 'advanced.organizations';
|
37
|
const ADVANCED_SEARCH_DATASOURCES_CACHE_ID = 'advanced.datasources';
|
38
|
const RESULT_CACHE_ID = 'result';
|
39
|
const PUBLICATION_CACHE_ID = 'publication';
|
40
|
const DATASET_CACHE_ID = 'dataset';
|
41
|
const PROJECT_CACHE_ID = 'project';
|
42
|
const PROJECT_PUBLICATIONS_CACHE_ID = 'project.publications';
|
43
|
const PERSON_CACHE_ID = 'person';
|
44
|
const PERSON_PUBLICATIONS_CACHE_ID = 'person.publications';
|
45
|
const ORGANIZATION_CACHE_ID = 'organization';
|
46
|
const ORGANIZATION_DATASOURCES_CACHE_ID = 'organization.datasources';
|
47
|
const DATASOURCE_CACHE_ID = 'datasource';
|
48
|
const DATASOURCE_PUBLICATIONS_CACHE_ID = 'datasource.publications';
|
49
|
const DATASOURCE_ORGANIZATIONS_CACHE_ID = 'datasource.organizations';
|
50
|
const COMPATIBLE_DATASOURCES_CACHE_ID = 'compatible.datasources';
|
51
|
const QUICK_SEARCH_PROJECTS_CACHE_ID = 'quick.search.projects';
|
52
|
const QUICK_SEARCH_ORGANIZATIONS_CACHE_ID = 'quick.search.organizations';
|
53
|
const RESULT_QUERY = '(oaftype exact result)';
|
54
|
const RESULT_ID = 'objIdentifier';
|
55
|
const PUBLICATION_QUERY = '(oaftype exact result) and (resulttypeid exact publication)';
|
56
|
const PUBLICATION_TYPE = 'instancetypenameid';
|
57
|
const PUBLICATION_LANGUAGE = 'resultlanguageid';
|
58
|
const PUBLICATION_CONTEXT = 'contextid';
|
59
|
const PUBLICATION_FUNDER = 'relfundinglevel0_id';
|
60
|
const PUBLICATION_FUNDING_STREAM = 'relfundinglevel1_id';
|
61
|
const PUBLICATION_SCIENTIFIC_AREA = 'relfundinglevel2_id';
|
62
|
const PUBLICATION_YEAR = 'resultacceptanceyear';
|
63
|
const PUBLICATION_ACCESS_MODE = 'resultbestlicense';
|
64
|
const PUBLICATION_DATASOURCE = 'resulthostingdatasourceid';
|
65
|
const PUBLICATION_PROJECT = 'relprojectid';
|
66
|
const PUBLICATION_AUTHOR_ID = 'relpersonid';
|
67
|
const PUBLICATION_ARTICLE = '0001';
|
68
|
const PUBLICATION_PREPRINT = '0016';
|
69
|
const PUBLICATION_BOOK = '0002';
|
70
|
const PUBLICATION_BOOK_PART = '0013';
|
71
|
const PUBLICATION_PHD_THESIS = '0006';
|
72
|
const PUBLICATION_MASTER_THESIS = '0007';
|
73
|
const PUBLICATION_BACHELOR_THESIS = '0008';
|
74
|
const PUBLICATION_REPORT = '0017';
|
75
|
const PUBLICATION_INTERNAL_REPORT = '0011';
|
76
|
const PUBLICATION_EXTERNAL_REPORT = '0009';
|
77
|
const PUBLICATION_TITLE = 'resulttitle';
|
78
|
const PUBLICATION_AUTHOR = 'relperson';
|
79
|
const PUBLICATION_PUBLISHER = 'resultpublisher';
|
80
|
const PUBLICATION_SUBJECT = 'resultsubject';
|
81
|
const PUBLICATION_DATE = 'resultdateofacceptance';
|
82
|
const PUBLICATION_ID = 'objIdentifier';
|
83
|
const DATASET_QUERY = '(oaftype exact result) and (resulttypeid exact dataset)';
|
84
|
const DATASET_TYPE = 'instancetypenameid';
|
85
|
const DATASET_LANGUAGE = 'resultlanguageid';
|
86
|
const DATASET_FUNDER = 'relfundinglevel0_id';
|
87
|
const DATASET_FUNDING_STREAM = 'relfundinglevel1_id';
|
88
|
const DATASET_SCIENTIFIC_AREA = 'relfundinglevel2_id';
|
89
|
const DATASET_YEAR = 'resultacceptanceyear';
|
90
|
const DATASET_ACCESS_MODE = 'resultbestlicense';
|
91
|
const DATASET_DATASOURCE = 'resulthostingdatasourceid';
|
92
|
const DATASET_PROJECT = 'relprojectid';
|
93
|
const DATASET_AUTHOR_ID = 'relpersonid';
|
94
|
const DATASET_ID = 'objIdentifier';
|
95
|
const PROJECT_QUERY = '(oaftype exact project)';
|
96
|
const PROJECT_FUNDER = 'fundinglevel0_id';
|
97
|
const PROJECT_FUNDING_STREAM = 'fundinglevel1_id';
|
98
|
const PROJECT_SCIENTIFIC_AREA = 'fundinglevel2_id';
|
99
|
const PROJECT_START_YEAR = 'projectstartyear';
|
100
|
const PROJECT_END_YEAR = 'projectendyear';
|
101
|
const PROJECT_SC39 = 'projectecsc39';
|
102
|
const PROJECT_ACRONYM = 'projectacronym';
|
103
|
const PROJECT_TITLE = 'projecttitle';
|
104
|
const PROJECT_KEYWORDS = 'projectkeywords';
|
105
|
const PROJECT_START_DATE = 'projectstartdate';
|
106
|
const PROJECT_END_DATE = 'projectenddate';
|
107
|
const PROJECT_ID = 'objIdentifier';
|
108
|
const PROJECT_CODE = 'projectcode';
|
109
|
const PERSON_QUERY = '(oaftype exact person)';
|
110
|
const PERSON_COUNTRY = 'personcountryid';
|
111
|
const PERSON_LAST_NAME = 'personsecondnames';
|
112
|
const PERSON_FIRST_NAME = 'personfirstname';
|
113
|
const PERSON_FULL_NAME = 'personfullname';
|
114
|
const PERSON_ID = 'objIdentifier';
|
115
|
const ORGANIZATION_QUERY = '(oaftype exact organization)';
|
116
|
const ORGANIZATION_COUNTRY = 'organizationcountryid';
|
117
|
const ORGANIZATION_LEGAL_BODY = 'organizationeclegalbody';
|
118
|
const ORGANIZATION_LEGAL_PERSON = 'organizationeclegalperson';
|
119
|
const ORGANIZATION_NON_PROFIT = 'organizationecnonprofit';
|
120
|
const ORGANIZATION_RESEARCH = 'organizationecresearchorganization';
|
121
|
const ORGANIZATION_EU_INTERESTS = 'organizationecinternationalorganizationeurinterests';
|
122
|
const ORGANIZATION_INTERNATIONAL = 'organizationecinternationalorganization';
|
123
|
const ORGANIZATION_ENTERPRISE = 'organizationecenterprise';
|
124
|
const ORGANIZATION_SMALL_MEDIUM_ENTERPRISE = 'organizationecsmevalidated';
|
125
|
const ORGANIZATION_NAME = 'organizationlegalname';
|
126
|
const ORGANIZATION_SHORT_NAME = 'organizationlegalshortname';
|
127
|
const ORGANIZATION_ID = 'objIdentifier';
|
128
|
const DATASOURCE_QUERY = '(oaftype exact datasource) and (datasourcecompatibilityid <> "UNKNOWN")';
|
129
|
const DATASOURCE_QUERY_COMPATIBILITY = '(oaftype exact datasource)';
|
130
|
const DATASOURCE_TYPE = 'datasourcetypeuiid';
|
131
|
const DATASOURCE_LANGUAGE = 'datasourceodlanguages';
|
132
|
const DATASOURCE_CONTENT = 'datasourceodcontenttypes';
|
133
|
const DATASOURCE_COMPATIBILITY = 'datasourcecompatibilityid';
|
134
|
const DATASOURCE_NAME = 'datasourceofficialname';
|
135
|
const DATASOURCE_ENGLISH_NAME = 'datasourceenglishname';
|
136
|
const DATASOURCE_SUBJECT = 'datasourceodsubjects';
|
137
|
const DATASOURCE_ORGANIZATION = 'relorganizationid';
|
138
|
const DATASOURCE_ID = 'objIdentifier';
|
139
|
const DATASOURCE_COMPATIBILITY_NOT_COMPATIBLE = 'notCompatible';
|
140
|
const DATASOURCE_ACCESS_OPEN = 'OPEN';
|
141
|
const DATASOURCE_ACCESS_EMBARGO = 'EMBARGO';
|
142
|
const DATASOURCE_ACCESS_RESTRICTED = 'RESTRICTED';
|
143
|
const DATASOURCE_ACCESS_CLOSED = 'CLOSED';
|
144
|
const UNKNOWN = 'UNKNOWN';
|
145
|
const UNDETERMINED = 'Undetermined';
|
146
|
const PUBLICATION = 'publication';
|
147
|
const DATASET = 'dataset';
|
148
|
const HTTP_OK = 200;
|
149
|
|
150
|
private $searchService;
|
151
|
private $publicationStatisticsExistUrl;
|
152
|
private $publicationStatisticsChartUrl;
|
153
|
private $datasourceStatisticsExistUrl;
|
154
|
private $datasourceStatisticsChartUrl;
|
155
|
private $projectStatisticsChartUrl;
|
156
|
private $cache;
|
157
|
private $http;
|
158
|
|
159
|
// Construct a new OpenAireModelSearch.
|
160
|
// $configuration the configuration to use
|
161
|
public function __construct($configuration = array()) {
|
162
|
parent :: __construct($configuration);
|
163
|
$parameters = JComponentHelper :: getParams('com_openaire');
|
164
|
$this -> searchService = $parameters -> get('searchServiceUrl');
|
165
|
$this -> publicationStatisticsExistUrl = $parameters -> get('statisticsDocumentExistUrl');
|
166
|
$this -> publicationStatisticsChartUrl = $parameters -> get('statisticsDocumentChartUrl');
|
167
|
$this -> datasourceStatisticsExistUrl = $parameters -> get('statisticsRepositoryExistUrl');
|
168
|
$this -> datasourceStatisticsChartUrl = $parameters -> get('statisticsRepositoryChartUrl');
|
169
|
$this -> projectStatisticsChartUrl = $parameters -> get('statisticsProjectChartUrl');
|
170
|
$this -> cache = JCache :: getInstance();
|
171
|
$this -> http = new JHttp();
|
172
|
}
|
173
|
|
174
|
// Retrieve the statistics exist URL for a publication.
|
175
|
// return the URL to use in order to check whether statistics exist for a publication
|
176
|
public function getPublicationStatisticsExistUrl() {
|
177
|
return $this -> publicationStatisticsExistUrl;
|
178
|
}
|
179
|
|
180
|
// Retrieve the statistics chart URL for a publication.
|
181
|
// return the URL to use in order to retrieve statistics chart for a publication
|
182
|
public function getPublicationStatisticsChartUrl() {
|
183
|
return $this -> publicationStatisticsChartUrl;
|
184
|
}
|
185
|
|
186
|
// Retrieve the statistics exist URL for a datasource.
|
187
|
// return the URL to use in order to check whether statistics exist for a datasource
|
188
|
public function getDatasourceStatisticsExistUrl() {
|
189
|
return $this -> datasourceStatisticsExistUrl;
|
190
|
}
|
191
|
|
192
|
// Retrieve the statistics chart URL for a datasource.
|
193
|
// return the URL to use in order to retrieve statistics chart for a datasource
|
194
|
public function getDatasourceStatisticsChartUrl() {
|
195
|
return $this -> datasourceStatisticsChartUrl;
|
196
|
}
|
197
|
|
198
|
// Retrieve the statistics chart URL for a project.
|
199
|
// return the URL to use in order to retrieve statistics chart for a project
|
200
|
public function getProjectStatisticsChartUrl() {
|
201
|
return $this -> projectStatisticsChartUrl;
|
202
|
}
|
203
|
|
204
|
// Retrieve publication statistics using cache if enabled.
|
205
|
// $locale the locale to use
|
206
|
// return statistics (object)
|
207
|
public function getPublicationStatistics($locale) {
|
208
|
if ($this -> cache -> getCaching()) {
|
209
|
$cacheId = self :: PUBLICATION_STATISTICS_CACHE_ID . '.' . $locale;
|
210
|
$statistics = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
211
|
if ($statistics === FALSE) {
|
212
|
$statistics = $this -> _getPublicationStatistics($locale);
|
213
|
if ($statistics !== NULL)
|
214
|
$this -> cache -> store($statistics, $cacheId, self :: CACHE_GROUP);
|
215
|
}
|
216
|
} else
|
217
|
$statistics = $this -> _getPublicationStatistics($locale);
|
218
|
return $statistics;
|
219
|
}
|
220
|
|
221
|
// Retrieve dataset statistics using cache if enabled.
|
222
|
// $locale the locale to use
|
223
|
// return statistics (object)
|
224
|
public function getDatasetStatistics($locale) {
|
225
|
if ($this -> cache -> getCaching()) {
|
226
|
$cacheId = self :: DATASET_STATISTICS_CACHE_ID . '.' . $locale;
|
227
|
$statistics = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
228
|
if ($statistics === FALSE) {
|
229
|
$statistics = $this -> _getDatasetStatistics($locale);
|
230
|
if ($statistics !== NULL)
|
231
|
$this -> cache -> store($statistics, $cacheId, self :: CACHE_GROUP);
|
232
|
}
|
233
|
} else
|
234
|
$statistics = $this -> _getDatasetStatistics($locale);
|
235
|
return $statistics;
|
236
|
}
|
237
|
|
238
|
// Retrieve project statistics using cache if enabled.
|
239
|
// $locale the locale to use
|
240
|
// return statistics (object)
|
241
|
public function getProjectStatistics($locale) {
|
242
|
if ($this -> cache -> getCaching()) {
|
243
|
$cacheId = self :: PROJECT_STATISTICS_CACHE_ID . '.' . $locale;
|
244
|
$statistics = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
245
|
if ($statistics === FALSE) {
|
246
|
$statistics = $this -> _getProjectStatistics($locale);
|
247
|
if ($statistics !== NULL)
|
248
|
$this -> cache -> store($statistics, $cacheId, self :: CACHE_GROUP);
|
249
|
}
|
250
|
} else
|
251
|
$statistics = $this -> _getProjectStatistics($locale);
|
252
|
return $statistics;
|
253
|
}
|
254
|
|
255
|
// Retrieve people statistics using cache if enabled.
|
256
|
// $locale the locale to use
|
257
|
// return statistics (object)
|
258
|
public function getPeopleStatistics($locale) {
|
259
|
if ($this -> cache -> getCaching()) {
|
260
|
$cacheId = self :: PEOPLE_STATISTICS_CACHE_ID . '.' . $locale;
|
261
|
$statistics = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
262
|
if ($statistics === FALSE) {
|
263
|
$statistics = $this -> _getPeopleStatistics($locale);
|
264
|
if ($statistics !== NULL)
|
265
|
$this -> cache -> store($statistics, $cacheId, self :: CACHE_GROUP);
|
266
|
}
|
267
|
} else
|
268
|
$statistics = $this -> _getPeopleStatistics($locale);
|
269
|
return $statistics;
|
270
|
}
|
271
|
|
272
|
// Retrieve organization statistics using cache if enabled.
|
273
|
// $locale the locale to use
|
274
|
// return statistics (object)
|
275
|
public function getOrganizationStatistics($locale) {
|
276
|
if ($this -> cache -> getCaching()) {
|
277
|
$cacheId = self :: ORGANIZATION_STATISTICS_CACHE_ID . '.' . $locale;
|
278
|
$statistics = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
279
|
if ($statistics === FALSE) {
|
280
|
$statistics = $this -> _getOrganizationStatistics($locale);
|
281
|
if ($statistics !== NULL)
|
282
|
$this -> cache -> store($statistics, $cacheId, self :: CACHE_GROUP);
|
283
|
}
|
284
|
} else
|
285
|
$statistics = $this -> _getOrganizationStatistics($locale);
|
286
|
return $statistics;
|
287
|
}
|
288
|
|
289
|
// Retrieve datasource statistics using cache if enabled.
|
290
|
// $locale the locale to use
|
291
|
// return statistics (object)
|
292
|
public function getDatasourceStatistics($locale) {
|
293
|
if ($this -> cache -> getCaching()) {
|
294
|
$cacheId = self :: DATASOURCE_STATISTICS_CACHE_ID . '.' . $locale;
|
295
|
$statistics = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
296
|
if ($statistics === FALSE) {
|
297
|
$statistics = $this -> _getDatasourceStatistics($locale);
|
298
|
if ($statistics !== NULL)
|
299
|
$this -> cache -> store($statistics, $cacheId, self :: CACHE_GROUP);
|
300
|
}
|
301
|
} else
|
302
|
$statistics = $this -> _getDatasourceStatistics($locale);
|
303
|
return $statistics;
|
304
|
}
|
305
|
|
306
|
// Perform a simple search for publications using cache if enabled.
|
307
|
// $keyword the keyword to search for
|
308
|
// $articles flag to limit searching on articles; if all flags are FALSE no limits apply
|
309
|
// $books flag to limit searching on books; if all flags are FALSE no limits apply
|
310
|
// $theses flag to limit searching on books; if all flags are FALSE no limits apply
|
311
|
// $reports flag to limit searching on reports; if all flags are FALSE no limits apply
|
312
|
// $type the ID of the publication type to use as filter or NULL for no publication type filtering
|
313
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
314
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
315
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
316
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
317
|
// $year the year of publication to use as filter or NULL for no year filtering
|
318
|
// $accessMode the ID of the access mode to use as a filter or NULL for no access mode filtering
|
319
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
320
|
// $community the ID of the community to use as filter or NULL for no community filtering
|
321
|
// $page the page of results to retrieve
|
322
|
// $size the size of the page of results to retrieve
|
323
|
// $locale the locale to use
|
324
|
// return a result (object) containing publications and statistics
|
325
|
public function searchPublications($keyword, $articles, $books, $theses, $reports, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale) {
|
326
|
if ($this -> cache -> getCaching()) {
|
327
|
$cacheId = self :: SEARCH_PUBLICATIONS_CACHE_ID . '.' . $keyword . '.' . $articles . '.' . $books . '.' . $theses . '.' . $reports . '.' . $type . '.' . $language . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $year . '.' . $accessMode . '.' . $datasource . '.' . $community . '.' . $page . '.' . $size . '.' . $locale;
|
328
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
329
|
if ($result === FALSE) {
|
330
|
$result = $this -> _searchPublications($keyword, $articles, $books, $theses, $reports, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale);
|
331
|
if ($result !== NULL)
|
332
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
333
|
}
|
334
|
} else
|
335
|
$result = $this -> _searchPublications($keyword, $articles, $books, $theses, $reports, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale);
|
336
|
return $result;
|
337
|
}
|
338
|
|
339
|
// Perform a simple search for datasets using cache if enabled.
|
340
|
// $keyword the keyword to search for
|
341
|
// $type the ID of the dataset type to use as filter or NULL for no dataset type filtering
|
342
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
343
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
344
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
345
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
346
|
// $year the year of publication to use as filter or NULL for no year filtering
|
347
|
// $accessMode the ID of the access mode to use as a filter or NULL for no access mode filtering
|
348
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
349
|
// $page the page of results to retrieve
|
350
|
// $size the size of the page of results to retrieve
|
351
|
// $locale the locale to use
|
352
|
// return a result (object) containing datasets and statistics
|
353
|
public function searchDatasets($keyword, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale) {
|
354
|
if ($this -> cache -> getCaching()) {
|
355
|
$cacheId = self :: SEARCH_DATASETS_CACHE_ID . '.' . $keyword . '.' . $type . '.' . $language . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $year . '.' . $accessMode . '.' . $datasource . '.' . $page . '.' . $size . '.' . $locale;
|
356
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
357
|
if ($result === FALSE) {
|
358
|
$result = $this -> _searchDatasets($keyword, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale);
|
359
|
if ($result !== NULL)
|
360
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
361
|
}
|
362
|
} else
|
363
|
$result = $this -> _searchDatasets($keyword, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale);
|
364
|
return $result;
|
365
|
}
|
366
|
|
367
|
// Perform a simple search for projects using cache if enabled.
|
368
|
// $keyword the keyword to search for
|
369
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
370
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
371
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
372
|
// $startYear the start year to use as filter or NULL for no start year filtering
|
373
|
// $endYear the end year to suse as filter or NULL for no end year filtering
|
374
|
// $sc39 the SC-39 status to use as filter or NULL for no SC-39 status filtering
|
375
|
// $page the page of results to retrieve
|
376
|
// $size the size of the page of results to retrieve
|
377
|
// $locale the locale to use
|
378
|
// return a result (object) containing projects and statistics
|
379
|
public function searchProjects($keyword, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale) {
|
380
|
if ($this -> cache -> getCaching()) {
|
381
|
$cacheId = self :: SEARCH_PROJECTS_CACHE_ID . '.' . $keyword . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $startYear . '.' . $endYear . '.' . (($sc39 === NULL) ? '' : (($sc39) ? 'true' : 'false')) . '.' . $page . '.' . $size . '.' . $locale;
|
382
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
383
|
if ($result === FALSE) {
|
384
|
$result = $this -> _searchProjects($keyword, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale);
|
385
|
if ($result !== NULL)
|
386
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
387
|
}
|
388
|
} else
|
389
|
$result = $this -> _searchProjects($keyword, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale);
|
390
|
return $result;
|
391
|
}
|
392
|
|
393
|
// Perform a simple search for people using cache if enabled.
|
394
|
// $keyword the keyword to search for
|
395
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
396
|
// $page the page of results to retrieve
|
397
|
// $size the size of the page of results to retrieve
|
398
|
// $locale the locale to use
|
399
|
// return a result (object) containing people and statistics
|
400
|
public function searchPeople($keyword, $country, $page, $size, $locale) {
|
401
|
if ($this -> cache -> getCaching()) {
|
402
|
$cacheId = self :: SEARCH_PEOPLE_CACHE_ID . '.' . $keyword . '.' . $country . '.' . $page . '.' . $size . '.' . $locale;
|
403
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
404
|
if ($result === FALSE) {
|
405
|
$result = $this -> _searchPeople($keyword, $country, $page, $size, $locale);
|
406
|
if ($result !== NULL)
|
407
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
408
|
}
|
409
|
} else
|
410
|
$result = $this -> _searchPeople($keyword, $country, $page, $size, $locale);
|
411
|
return $result;
|
412
|
}
|
413
|
|
414
|
// Perform a simple search for organizations using cache if enabled.
|
415
|
// $keyword the keyword to search for
|
416
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
417
|
// $type the ID of the organization type to use as filter or NULL for no organization type filtering
|
418
|
// $page the page of results to retrieve
|
419
|
// $size the size of the page of results to retrieve
|
420
|
// $locale the locale to use
|
421
|
// return a result (object) containing organizations and statistics
|
422
|
public function searchOrganizations($keyword, $country, $type, $page, $size, $locale) {
|
423
|
if ($this -> cache -> getCaching()) {
|
424
|
$cacheId = self :: SEARCH_ORGANIZATIONS_CACHE_ID . '.' . $keyword . '.' . $country . '.' . $type . '.' . $page . '.' . $size . '.' . $locale;
|
425
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
426
|
if ($result === FALSE) {
|
427
|
$result = $this -> _searchOrganizations($keyword, $country, $type, $page, $size, $locale);
|
428
|
if ($result !== NULL)
|
429
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
430
|
}
|
431
|
} else
|
432
|
$result = $this -> _searchOrganizations($keyword, $country, $type, $page, $size, $locale);
|
433
|
return $result;
|
434
|
}
|
435
|
|
436
|
// Perform a simple search for datasources using cache if enabled.
|
437
|
// $keyword the keyword to search for
|
438
|
// $type the ID of the datasource type to use as filter or NULL for no datasource type filtering
|
439
|
// $language ID of the datasource language to use as filter or NULL for no datasource language filtering
|
440
|
// $content the ID of the content to use as filter or NULL for no project filtering
|
441
|
// $compatibility the ID of the compatibility level to use as filter or NULL for no compatibility level filtering
|
442
|
// $page the page of results to retrieve
|
443
|
// $size the size of the page of results to retrieve
|
444
|
// $locale the locale to use
|
445
|
// return a result (object) containing datasources and statistics
|
446
|
public function searchDatasources($keyword, $type, $language, $content, $compatibility, $page, $size, $locale) {
|
447
|
if ($this -> cache -> getCaching()) {
|
448
|
$cacheId = self :: SEARCH_DATASOURCES_CACHE_ID . '.' . $keyword . '.' . $type . '.' . $language . '.' . $content . '.' . $compatibility . '.' . $page . '.' . $size . '.' . $locale;
|
449
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
450
|
if ($result === FALSE) {
|
451
|
$result = $this -> _searchDatasources($keyword, $type, $language, $content, $compatibility, $page, $size, $locale);
|
452
|
if ($result !== NULL)
|
453
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
454
|
}
|
455
|
} else
|
456
|
$result = $this -> _searchDatasources($keyword, $type, $language, $content, $compatibility, $page, $size, $locale);
|
457
|
return $result;
|
458
|
}
|
459
|
|
460
|
// Perform a browse for publications using cache if enabled.
|
461
|
// $type the ID of the publication type to use as filter or NULL for no publication type filtering
|
462
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
463
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
464
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
465
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
466
|
// $year the year of publication to use as filter or NULL for no year filtering
|
467
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
468
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
469
|
// $community the ID of the community to use as filter or NULL for no datasource filtering
|
470
|
// $page the page of results to retrieve
|
471
|
// $size the size of the page of results to retrieve
|
472
|
// $locale the locale to use
|
473
|
// $project the ID of the project to use as filter or NULL for no project filtering
|
474
|
// $author the ID of the author to use as filter or NULL for no author filtering
|
475
|
// return a result (object) containing publications and statistics
|
476
|
public function browsePublications($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale, $project, $author) {
|
477
|
if ($this -> cache -> getCaching()) {
|
478
|
$cacheId = self :: BROWSE_PUBLICATIONS_CACHE_ID . '.' . $type . '.' . $language . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $year . '.' . $accessMode . '.' . $datasource . '.' . $community . '.' . $page . '.' . $size . '.' . $locale . '.' . $project . '.' . $author;
|
479
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
480
|
if ($result === FALSE) {
|
481
|
$result = $this -> _browsePublications($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale, $project, $author);
|
482
|
if ($result !== NULL)
|
483
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
484
|
}
|
485
|
} else
|
486
|
$result = $this -> _browsePublications($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale, $project, $author);
|
487
|
return $result;
|
488
|
}
|
489
|
|
490
|
// Perform a browse for datasets using cache if enabled.
|
491
|
// $type the ID of the dataset type to use as filter or NULL for no dataset type filtering
|
492
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
493
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
494
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
495
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
496
|
// $year the year of publication to use as filter or NULL for no year filtering
|
497
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
498
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
499
|
// $page the page of results to retrieve
|
500
|
// $size the size of the page of results to retrieve
|
501
|
// $locale the locale to use
|
502
|
// $project the ID of the project to use as filter or NULL for no project filtering
|
503
|
// $author the ID of the author to use as filter or NULL for no author filtering
|
504
|
// return a result (object) containing datasets and statistics
|
505
|
public function browseDatasets($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale, $project, $author) {
|
506
|
if ($this -> cache -> getCaching()) {
|
507
|
$cacheId = self :: BROWSE_DATASETS_CACHE_ID . '.' . $type . '.' . $language . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $year . '.' . $accessMode . '.' . $datasource . '.' . $page . '.' . $size . '.' . $locale . '.' . $project . '.' . $author;
|
508
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
509
|
if ($result === FALSE) {
|
510
|
$result = $this -> _browseDatasets($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale, $project, $author);
|
511
|
if ($result !== NULL)
|
512
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
513
|
}
|
514
|
} else
|
515
|
$result = $this -> _browseDatasets($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale, $project, $author);
|
516
|
return $result;
|
517
|
}
|
518
|
|
519
|
// Perform a browse for projects using cache if enabled.
|
520
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
521
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
522
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
523
|
// $startYear the start year to use as filter or NULL for no start year filtering
|
524
|
// $endYear the end year to use as filter or NULL for no end year filtering
|
525
|
// $sc39 the SC-39 status to use as filter or NULL for no SC-39 status filtering
|
526
|
// $page the page of results to retrieve
|
527
|
// $size the size of the page of results to retrieve
|
528
|
// $locale the locale to use
|
529
|
// return a result (object) containing projects and statistics
|
530
|
public function browseProjects($funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale) {
|
531
|
if ($this -> cache -> getCaching()) {
|
532
|
$cacheId = self :: BROWSE_PROJECTS_CACHE_ID . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $startYear . '.' . '.' . $endYear . '.' . $sc39 . '.' .$page . '.' . $size . '.' . $locale;
|
533
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
534
|
if ($result === FALSE) {
|
535
|
$result = $this -> _browseProjects($funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale);
|
536
|
if ($result !== NULL)
|
537
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
538
|
}
|
539
|
} else
|
540
|
$result = $this -> _browseProjects($funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale);
|
541
|
return $result;
|
542
|
}
|
543
|
|
544
|
// Perform a browse for people using cache if enabled.
|
545
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
546
|
// $page the page of results to retrieve
|
547
|
// $size the size of the page of results to retrieve
|
548
|
// $locale the locale to use
|
549
|
// return a result (object) containing people and statistics
|
550
|
public function browsePeople($country, $page, $size, $locale) {
|
551
|
if ($this -> cache -> getCaching()) {
|
552
|
$cacheId = self :: BROWSE_PEOPLE_CACHE_ID . '.' . $country . '.' . $page . '.' . $size . '.' . $locale;
|
553
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
554
|
if ($result === FALSE) {
|
555
|
$result = $this -> _browsePeople($country, $page, $size, $locale);
|
556
|
if ($result !== NULL)
|
557
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
558
|
}
|
559
|
} else
|
560
|
$result = $this -> _browsePeople($country, $page, $size, $locale);
|
561
|
return $result;
|
562
|
}
|
563
|
|
564
|
// Perform a browse for organizations using cache if enabled.
|
565
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
566
|
// $type the ID of the organization type to use as filter or NULL for no organization type filtering
|
567
|
// $page the page of results to retrieve
|
568
|
// $size the size of the page of results to retrieve
|
569
|
// $locale the locale to use
|
570
|
// return a result (object) containing organizations and statistics
|
571
|
public function browseOrganizations($country, $type, $page, $size, $locale) {
|
572
|
if ($this -> cache -> getCaching()) {
|
573
|
$cacheId = self :: BROWSE_ORGANIZATIONS_CACHE_ID . '.' . $country . '.' . $type . '.' . $page . '.' . $size . '.' . $locale;
|
574
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
575
|
if ($result === FALSE) {
|
576
|
$result = $this -> _browseOrganizations($country, $type, $page, $size, $locale);
|
577
|
if ($result !== NULL)
|
578
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
579
|
}
|
580
|
} else
|
581
|
$result = $this -> _browseOrganizations($country, $type, $page, $size, $locale);
|
582
|
return $result;
|
583
|
}
|
584
|
|
585
|
// Perform a browse for datasources using cache if enabled.
|
586
|
// $type the ID of the datasource type to use as filter or NULL for no datasource type filtering
|
587
|
// $language the ID of the datasource language to use as filter or NULL for no datasource language filtering
|
588
|
// $content the ID of the content to use as filter or NULL for no content filtering
|
589
|
// $compatibility the ID of the compatibility level to use as filter or NULL for no compatibility status filtering
|
590
|
// $page the page of results to retrieve
|
591
|
// $size the size of the page of results to retrieve
|
592
|
// $locale the locale to use
|
593
|
// return a result (object) containing datasources and statistics
|
594
|
public function browseDatasources($type, $language, $content, $compatibility, $page, $size, $locale) {
|
595
|
if ($this -> cache -> getCaching()) {
|
596
|
$cacheId = self :: BROWSE_DATASOURCES_CACHE_ID . '.' . $type . '.' . $language . '.' . $content . '.' . $compatibility . '.' . $page . '.' . $size . '.' . $locale;
|
597
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
598
|
if ($result === FALSE) {
|
599
|
$result = $this -> _browseDatasources($type, $language, $content, $compatibility, $page, $size, $locale);
|
600
|
if ($result !== NULL)
|
601
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
602
|
}
|
603
|
} else
|
604
|
$result = $this -> _browseDatasources($type, $language, $content, $compatibility, $page, $size, $locale);
|
605
|
return $result;
|
606
|
}
|
607
|
|
608
|
// Perform an advanced search for publications using cache if enabled.
|
609
|
// $keywords the keywords to search for (array)
|
610
|
// $fields the fields to match keywords with (array - possible values are TITLE, AUTHOR, PUBLISHER and SUBJECT)
|
611
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
612
|
// $types the IDs of the publication types to search for
|
613
|
// $languages the IDs of the publication languages to search for
|
614
|
// $funders the IDs of the funders to search for
|
615
|
// $fundingStreams the IDs of the funding streams to search for
|
616
|
// $scientificAreas the IDs of the scientific areas to search for
|
617
|
// $date the publication date range to search for expressed in months before current date (if -1 search for any publication date, if 0 search explicitly using $fromMonth, $fromYear, $toMonth and $toYear)
|
618
|
// $fromMonth start month of the publication date range to search for if $date has value 0
|
619
|
// $fromYear start year of the publication date range to search for if $date has value 0
|
620
|
// $toMonth end month of the publication date range to search for if $date has value 0
|
621
|
// $toYear end year of the publication date range to search for if $date has value 0
|
622
|
// $accessModes the IDs of the access modes to search for
|
623
|
// $datasources the IDs of the datasources to search for
|
624
|
// $type the ID of the publication type to use as filter or NULL for no publication type filtering
|
625
|
// $language the ID of the publication language to use as filter or NULL for no publication language filtering
|
626
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
627
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
628
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
629
|
// $year the publication year to use as filter or NULL for no publication year filtering
|
630
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
631
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
632
|
// $page the page of results to retrieve
|
633
|
// $size the size of the page of results to retrieve
|
634
|
// $locale the locale to use
|
635
|
// return a result (object) containing publications and statistics
|
636
|
public function advancedSearchPublications($keywords, $fields, $constraints, $types, $languages, $funders, $fundingStreams, $scientificAreas, $date, $fromMonth, $fromYear, $toMonth, $toYear, $accessModes, $datasources, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale) {
|
637
|
if ($this -> cache -> getCaching()) {
|
638
|
$cacheId = self :: ADVANCED_SEARCH_PUBLICATIONS_CACHE_ID . '.' . implode('.', $keywords) . '.' . implode('.', $fields) . '.' . implode('.', $constraints) . '.' . implode('.', $types) . '.' . implode('.', $languages) . '.' . implode('.', $funders) . '.' . implode('.', $fundingStreams) . '.' . implode('.', $scientificAreas) . '.' . $date . '.' . $fromMonth . '.' . $fromYear . '.' . $toMonth . '.' . $toYear . '.' . implode('.', $accessModes) . '.' . implode('.', $datasources) . '.' . $type . '.' . $language . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $year . '.' . $accessMode . '.' . $datasource . '.' . $page . '.' . $size . '.' . $locale;
|
639
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
640
|
if ($result === FALSE) {
|
641
|
$result = $this -> _advancedSearchPublications($keywords, $fields, $constraints, $types, $languages, $funders, $fundingStreams, $scientificAreas, $date, $fromMonth, $fromYear, $toMonth, $toYear, $accessModes, $datasources, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale);
|
642
|
if ($result !== NULL)
|
643
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
644
|
}
|
645
|
} else
|
646
|
$result = $this -> _advancedSearchPublications($keywords, $fields, $constraints, $types, $languages, $funders, $fundingStreams, $scientificAreas, $date, $fromMonth, $fromYear, $toMonth, $toYear, $accessModes, $datasources, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale);
|
647
|
return $result;
|
648
|
}
|
649
|
|
650
|
// Perform an advanced search for projects using cache if enabled.
|
651
|
// $keywords the keywords to search for (array)
|
652
|
// $fields the fields to match keywords with (array - possible values are ACRONYM, TITLE and KEYWORDS)
|
653
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
654
|
// $funders the IDs of the funders to search for
|
655
|
// $fundingStreams the IDs of the funding streams to search for
|
656
|
// $scientificAreas the IDs of the scientific areas to search for
|
657
|
// $startDate the start date range to search for expressed in months before current date (if -1 search for any start date, if 0 search explicitly using $startFromMonth, $startFromYear, $startToMonth and $startToYear)
|
658
|
// $startFromMonth start month of the start date range to search for if $startDate has value 0
|
659
|
// $startFromYear start year of the start date range to search for if $startDate has value 0
|
660
|
// $startToMonth end month of the start date range to search for if $startDate has value 0
|
661
|
// $startToYear end year of the start date range to search for if $startDate has value 0
|
662
|
// $endDate the end date range to search for expressed in months before current date (if -1 search for any end date, if 0 search explicitly using $endFromMonth, $endFromYear, $endToMonth and $endToYear)
|
663
|
// $endFromMonth start month of the end date range to search for if $endDate has value 0
|
664
|
// $endFromYear start year of the end date range to search for if $endDate has value 0
|
665
|
// $endToMonth end month of the end date range to search for if $endDate has value 0
|
666
|
// $endToYear end year of the end date range to search for if $endDate has value 0
|
667
|
// $sc39 the SC-39 statuses to search for
|
668
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
669
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
670
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
671
|
// $startYear the start year to use as filter or NULL for no start year filtering
|
672
|
// $endYear the end year to use as filter or NULL for no end year filtering
|
673
|
// $accessMode the ID of the SC-39 status to use as filter or NULL for no SC-39 status filtering
|
674
|
// $page the page of results to retrieve
|
675
|
// $size the size of the page of results to retrieve
|
676
|
// $locale the locale to use
|
677
|
// return a result (object) containing projects and statistics
|
678
|
public function advancedSearchProjects($keywords, $fields, $constraints, $funders, $fundingStreams, $scientificAreas, $startDate, $startFromMonth, $startFromYear, $startToMonth, $startToYear, $endDate, $endFromMonth, $endFromYear, $endToMonth, $endToYear, $sc39s, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale) {
|
679
|
if ($this -> cache -> getCaching()) {
|
680
|
$cacheId = self :: ADVANCED_SEARCH_PROJECTS_CACHE_ID . '.' . implode('.', $keywords) . '.' . implode('.', $fields) . '.' . implode('.', $constraints) . '.' . implode('.', $funders) . '.' . implode('.', $fundingStreams) . '.' . implode('.', $scientificAreas) . '.' . $startDate . '.' . $startFromMonth . '.' . $startFromYear . '.' . $startToMonth . '.' . $startToYear . '.' . $endDate . '.' . $endFromMonth . '.' . $endFromYear . '.' . $endToMonth . '.' . $endToYear . '.' . implode('.', array_map(function ($sc39) {return $sc39 ? 'true' : 'false';}, $sc39s)) . '.' . $funder . '.' . $fundingStream . '.' . $scientificArea . '.' . $startYear . '.' . $endYear . '.' . (($sc39 === NULL) ? '' : ($sc39 ? 'true' : 'false')) . '.' . $page . '.' . $size . '.' . $locale;
|
681
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
682
|
if ($result === FALSE) {
|
683
|
$result = $this -> _advancedSearchProjects($keywords, $fields, $constraints, $funders, $fundingStreams, $scientificAreas, $startDate, $startFromMonth, $startFromYear, $startToMonth, $startToYear, $endDate, $endFromMonth, $endFromYear, $endToMonth, $endToYear, $sc39s, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale);
|
684
|
if ($result !== NULL)
|
685
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
686
|
}
|
687
|
} else
|
688
|
$result = $this -> _advancedSearchProjects($keywords, $fields, $constraints, $funders, $fundingStreams, $scientificAreas, $startDate, $startFromMonth, $startFromYear, $startToMonth, $startToYear, $endDate, $endFromMonth, $endFromYear, $endToMonth, $endToYear, $sc39s, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale);
|
689
|
return $result;
|
690
|
}
|
691
|
|
692
|
// Perform an advanced search for people using cache if enabled.
|
693
|
// $keywords the keywords to search for (array)
|
694
|
// $fields the fields to match keywords with (array - possible values are LAST_NAME, FIRST_NAME and FULL_NAME)
|
695
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
696
|
// $countries the IDs of the countries to search for
|
697
|
// $country the ID of the coutnry to use as filter or NULL for no country filtering
|
698
|
// $page the page of results to retrieve
|
699
|
// $size the size of the page of results to retrieve
|
700
|
// $locale the locale to use
|
701
|
// return a result (object) containing people and statistics
|
702
|
public function advancedSearchPeople($keywords, $fields, $constraints, $countries, $country, $page, $size, $locale) {
|
703
|
if ($this -> cache -> getCaching()) {
|
704
|
$cacheId = self :: ADVANCED_SEARCH_PEOPLE_CACHE_ID . '.' . implode('.', $keywords) . '.' . implode('.', $fields) . '.' . implode('.', $constraints) . '.' . implode('.', $countries) . '.' . $country . '.' . $page . '.' . $size . '.' . $locale;
|
705
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
706
|
if ($result === FALSE) {
|
707
|
$result = $this -> _advancedSearchPeople($keywords, $fields, $constraints, $countries, $country, $page, $size, $locale);
|
708
|
if ($result !== NULL)
|
709
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
710
|
}
|
711
|
} else
|
712
|
$result = $this -> _advancedSearchPeople($keywords, $fields, $constraints, $countries, $country, $page, $size, $locale);
|
713
|
return $result;
|
714
|
}
|
715
|
|
716
|
// Perform an advanced search for organizations using cache if enabled.
|
717
|
// $keywords the keywords to search for (array)
|
718
|
// $fields the fields to match keywords with (array - possible values are NAME and SHORT_NAME)
|
719
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
720
|
// $countries the IDs of the countries to search for
|
721
|
// $types the IDs of the organization types to search for
|
722
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
723
|
// $type the ID of the organization type to use as filter or NULL for no organization type filtering
|
724
|
// $page the page of results to retrieve
|
725
|
// $size the size of the page of results to retrieve
|
726
|
// $locale the locale to use
|
727
|
// return a result (object) containing people and statistics
|
728
|
public function advancedSearchOrganizations($keywords, $fields, $constraints, $countries, $types, $country, $type, $page, $size, $locale) {
|
729
|
if ($this -> cache -> getCaching()) {
|
730
|
$cacheId = self :: ADVANCED_SEARCH_ORGANIZATIONS_CACHE_ID . '.' . implode('.', $keywords) . '.' . implode('.', $fields) . '.' . implode('.', $constraints) . '.' . implode('.', $countries) . '.' . implode('.', $types) . $country . '.' . $type . '.' . $page . '.' . $size . '.' . $locale;
|
731
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
732
|
if ($result === FALSE) {
|
733
|
$result = $this -> _advancedSearchOrganizations($keywords, $fields, $constraints, $countries, $types, $country, $type, $page, $size, $locale);
|
734
|
if ($result !== NULL)
|
735
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
736
|
}
|
737
|
} else
|
738
|
$result = $this -> _advancedSearchOrganizations($keywords, $fields, $constraints, $countries, $types, $country, $type, $page, $size, $locale);
|
739
|
return $result;
|
740
|
}
|
741
|
|
742
|
// Perform an advanced search for datasources using cache if enabled.
|
743
|
// $keywords the keywords to search for (array)
|
744
|
// $fields the fields to match keywords with (array - possible values are NAME, ENGLISH_NAME and SUBJECT)
|
745
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
746
|
// $types the IDs of the datasource types to search for
|
747
|
// $languages the IDs of the datasource languages to search for
|
748
|
// $contents the IDs of the contents to search for
|
749
|
// $compatibilities the IDs of the compatibilities to search for
|
750
|
// $type the ID of the datasource type to use as filter or NULL for no datasource type filtering
|
751
|
// $language the ID of the datasource language to use as filter or NULL for no datasource language filtering
|
752
|
// $content the ID of the content to use as filter or NULL for no content filtering
|
753
|
// $compatibility the ID of the compatibility to use as filter or NULL for no compatibility filtering
|
754
|
// $page the page of results to retrieve
|
755
|
// $size the size of the page of results to retrieve
|
756
|
// $locale the locale to use
|
757
|
// return a result (object) containing datasources and statistics
|
758
|
public function advancedSearchDatasources($keywords, $fields, $constraints, $types, $languages, $contents, $compatibilities, $type, $language, $content, $compatibility, $page, $size, $locale) {
|
759
|
if ($this -> cache -> getCaching()) {
|
760
|
$cacheId = self :: ADVANCED_SEARCH_DATASOURCES_CACHE_ID . '.' . implode('.', $keywords) . '.' . implode('.', $fields) . '.' . implode('.', $constraints) . '.' . implode('.', $types) . '.' . implode('.', $languages) . '.' . implode('.', $contents) . '.' . implode('.', $compatibilities) . '.' . $type . '.' . $language . '.' . $content . '.' . $compatibility . '.' . $page . '.' . $size . '.' . $locale;
|
761
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
762
|
if ($result === FALSE) {
|
763
|
$result = $this -> _advancedSearchDatasources($keywords, $fields, $constraints, $types, $languages, $contents, $compatibilities, $type, $language, $content, $compatibility, $page, $size, $locale);
|
764
|
if ($result !== NULL)
|
765
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
766
|
}
|
767
|
} else
|
768
|
$result = $this -> _advancedSearchDatasources($keywords, $fields, $constraints, $types, $languages, $contents, $compatibilities, $type, $language, $content, $compatibility, $page, $size, $locale);
|
769
|
return $result;
|
770
|
}
|
771
|
|
772
|
// Retrieve a single publication by identifier using caching if enabled.
|
773
|
// $id the publication identifier
|
774
|
// $locale the locale to use
|
775
|
// return a publication (object) or NULL if no such publication exists
|
776
|
public function getPublication($id, $locale) {
|
777
|
if ($this -> cache -> getCaching()) {
|
778
|
$cacheId = self :: PUBLICATION_CACHE_ID . '.' . $id . '.' . $locale;
|
779
|
$publication = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
780
|
if ($publication === FALSE) {
|
781
|
$publication = $this -> _getPublication($id, $locale);
|
782
|
if ($publication !== NULL)
|
783
|
$this -> cache -> store($publication, $cacheId, self :: CACHE_GROUP);
|
784
|
}
|
785
|
} else
|
786
|
$publication = $this -> _getPublication($id, $locale);
|
787
|
return $publication;
|
788
|
}
|
789
|
// Retrieve a single publication by identifier using caching if enabled.
|
790
|
// $ids the publication identifiers
|
791
|
// $locale the locale to use
|
792
|
// return a publication (object) or NULL if no such publication exists
|
793
|
public function getResults($ids, $locale) {
|
794
|
if ($this -> cache -> getCaching()) {
|
795
|
$cacheId = self :: RESULTS_CACHE_ID . '.' . join(",",$ids) . '.' . $locale;
|
796
|
$results = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
797
|
if ($results === FALSE) {
|
798
|
$results = $this -> _getResults($ids, $locale);
|
799
|
if ($results !== NULL)
|
800
|
$this -> cache -> store($results, $cacheId, self :: CACHE_GROUP);
|
801
|
}
|
802
|
} else
|
803
|
$results = $this -> _getResults($ids, $locale);
|
804
|
return $results;
|
805
|
}
|
806
|
// Retrieve a single publication by identifier using caching if enabled.
|
807
|
// $ids the publication identifiers
|
808
|
// $locale the locale to use
|
809
|
// return a publication (object) or NULL if no such publication exists
|
810
|
public function getPublications($ids, $locale) {
|
811
|
if ($this -> cache -> getCaching()) {
|
812
|
$cacheId = self :: PUBLICATION_CACHE_ID . '.' . join(",",$ids) . '.' . $locale;
|
813
|
$publications = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
814
|
if ($publications === FALSE) {
|
815
|
$publications = $this -> _getPublications($ids, $locale);
|
816
|
if ($publications !== NULL)
|
817
|
$this -> cache -> store($publications, $cacheId, self :: CACHE_GROUP);
|
818
|
}
|
819
|
} else
|
820
|
$publications = $this -> _getPublications($ids, $locale);
|
821
|
return $publications;
|
822
|
}
|
823
|
// Retrieve a single dataset by identifier using caching if enabled.
|
824
|
// $ids the dataset identifiers
|
825
|
// $locale the locale to use
|
826
|
// return a publication (object) or NULL if no such publication exists
|
827
|
public function getDatasets($ids, $locale) {
|
828
|
if ($this -> cache -> getCaching()) {
|
829
|
$cacheId = self :: DATASET_CACHE_ID . '.' . join(",",$ids) . '.' . $locale;
|
830
|
$datasets = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
831
|
if ($datasets === FALSE) {
|
832
|
$datasets = $this -> _getDatasets($ids, $locale);
|
833
|
if ($datasets !== NULL)
|
834
|
$this -> cache -> store($datasets, $cacheId, self :: CACHE_GROUP);
|
835
|
}
|
836
|
} else
|
837
|
$publications = $this -> _getDatasets($ids, $locale);
|
838
|
return $publications;
|
839
|
}
|
840
|
// Retrieve projects by identifier using caching if enabled.
|
841
|
// $ids the project identifiers
|
842
|
// $locale the locale to use
|
843
|
// return an array of project (object) or NULL if no such projects exists
|
844
|
public function getProjects($ids, $locale) {
|
845
|
if ($this -> cache -> getCaching()) {
|
846
|
$cacheId = self :: PROJECT_CACHE_ID . '.' . join(",",$ids) . '.' . $locale;
|
847
|
$projects = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
848
|
if ($projects === FALSE) {
|
849
|
$projects = $this -> _getProjects($ids, $locale);
|
850
|
if ($projects !== NULL)
|
851
|
$this -> cache -> store($projects, $cacheId, self :: CACHE_GROUP);
|
852
|
}
|
853
|
} else
|
854
|
$projects = $this -> _getProjects($ids, $locale);
|
855
|
return $projects;
|
856
|
}
|
857
|
// Retrieve a single dataset by identifier using caching if enabled.
|
858
|
// $id the dataset identifier
|
859
|
// $locale the locale to use
|
860
|
// return a dataset (object) or NULL if no such dataset exists
|
861
|
public function getDataset($id, $locale) {
|
862
|
if ($this -> cache -> getCaching()) {
|
863
|
$cacheId = self :: DATASET_CACHE_ID . '.' . $id . '.' . $locale;
|
864
|
$dataset = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
865
|
if ($dataset === FALSE) {
|
866
|
$dataset = $this -> _getDataset($id, $locale);
|
867
|
if ($dataset !== NULL)
|
868
|
$this -> cache -> store($dataset, $cacheId, self :: CACHE_GROUP);
|
869
|
}
|
870
|
} else
|
871
|
$dataset = $this -> _getDataset($id, $locale);
|
872
|
return $dataset;
|
873
|
}
|
874
|
|
875
|
// Retrieve a single project by identifier using caching if enabled.
|
876
|
// $id the project identifier
|
877
|
// $locale the locale to use
|
878
|
// return a project (object) or NULL if no such project exists
|
879
|
public function getProject($id, $locale) {
|
880
|
if ($this -> cache -> getCaching()) {
|
881
|
$cacheId = self :: PROJECT_CACHE_ID . '.' . $id . '.' . $locale;
|
882
|
$project = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
883
|
if ($project === FALSE) {
|
884
|
$project = $this -> _getProject($id, $locale);
|
885
|
if ($project !== NULL)
|
886
|
$this -> cache -> store($project, $cacheId, self :: CACHE_GROUP);
|
887
|
}
|
888
|
} else
|
889
|
$project = $this -> _getProject($id, $locale);
|
890
|
return $project;
|
891
|
}
|
892
|
|
893
|
// Retrieve a single person by identifier using caching if enabled.
|
894
|
// $id the person identifier
|
895
|
// $locale the locale to use
|
896
|
// return a person (object) or NULL if no such person exists
|
897
|
public function getPerson($id, $locale) {
|
898
|
if ($this -> cache -> getCaching()) {
|
899
|
$cacheId = self :: PERSON_CACHE_ID . '.' . $id . '.' . $locale;
|
900
|
$person = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
901
|
if ($person === FALSE) {
|
902
|
$person = $this -> _getPerson($id, $locale);
|
903
|
if ($person !== NULL)
|
904
|
$this -> cache -> store($person, $cacheId, self :: CACHE_GROUP);
|
905
|
}
|
906
|
} else
|
907
|
$person = $this -> _getPerson($id, $locale);
|
908
|
return $person;
|
909
|
}
|
910
|
|
911
|
// Retreive a single organization by identifier using cache if enabled.
|
912
|
// $id the organization identifier
|
913
|
// $locale the locale to use
|
914
|
// return an organization (object) or NULL if no such organization exists
|
915
|
public function getOrganization($id, $locale) {
|
916
|
if ($this -> cache -> getCaching()) {
|
917
|
$cacheId = self :: ORGANIZATION_CACHE_ID . '.' . $id . '.' . $locale;
|
918
|
$organization = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
919
|
if ($organization === FALSE) {
|
920
|
$organization = $this -> _getOrganization($id, $locale);
|
921
|
if ($organization !== NULL)
|
922
|
$this -> cache -> store($organization, $cacheId, self :: CACHE_GROUP);
|
923
|
}
|
924
|
} else
|
925
|
$organization = $this -> _getOrganization($id, $locale);
|
926
|
return $organization;
|
927
|
}
|
928
|
|
929
|
// Retrieve the datasources of an organization using caching if enabled.
|
930
|
// $id the organization identifier
|
931
|
// $size the maximum number of organizations to retrieve
|
932
|
// $locale the locale to use
|
933
|
// return a result (object) containing datasources and total
|
934
|
public function getOrganizationDatasources($id, $size, $locale) {
|
935
|
if ($this -> cache -> getCaching()) {
|
936
|
$cacheId = self :: ORGANIZATION_DATASOURCES_CACHE_ID . '.' . $id . '.' . $size . '.' . $locale;
|
937
|
$result = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
938
|
if ($result === FALSE) {
|
939
|
$result = $this -> _getOrganizationDatasources($id, $size, $locale);
|
940
|
if ($result !== NULL)
|
941
|
$this -> cache -> store($result, $cacheId, self :: CACHE_GROUP);
|
942
|
}
|
943
|
} else
|
944
|
$result = $this -> _getOrganizationDatasources($id, $size, $locale);
|
945
|
return $result;
|
946
|
}
|
947
|
|
948
|
// Retrieve a single datasource by identifier using cache if enabled.
|
949
|
// $id the datasource identifier
|
950
|
// $locale the locale to use
|
951
|
// return a datasource (object) or NULL if no such datasource exists
|
952
|
public function getDatasource($id, $locale, $compatibility = false) {
|
953
|
if ($this -> cache -> getCaching()) {
|
954
|
$cacheId = self :: DATASOURCE_CACHE_ID . '.' . $id . '.' . $locale . "." . $compatibility;
|
955
|
$datasource = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
956
|
if ($datasource === FALSE) {
|
957
|
$datasource = $this -> _getDatasource($id, $locale, $compatibility);
|
958
|
if ($datasource !== NULL)
|
959
|
$this -> cache -> store($datasource, $cacheId, self :: CACHE_GROUP);
|
960
|
}
|
961
|
} else
|
962
|
$datasource = $this -> _getDatasource($id, $locale, $compatibility);
|
963
|
return $datasource;
|
964
|
}
|
965
|
|
966
|
// Retrieve all the OpenAIRE compatible datasources using cache if enabled.
|
967
|
// $locale the locale to use
|
968
|
// return the datasources (array) or NULL if any errors occur
|
969
|
public function getCompatibleDatasources($locale) {
|
970
|
if ($this -> cache -> getCaching()) {
|
971
|
$cacheId = self :: COMPATIBLE_DATASOURCES_CACHE_ID . '.' . $locale;
|
972
|
$datasources = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
973
|
if ($datasources === FALSE) {
|
974
|
$datasources = $this -> _getCompatibleDatasources($locale);
|
975
|
if ($datasources !== NULL)
|
976
|
$this -> cache -> store($datasources, $cacheId, self :: CACHE_GROUP);
|
977
|
}
|
978
|
} else
|
979
|
$datasources = $this -> _getCompatibleDatasources($locale);
|
980
|
return $datasources;
|
981
|
}
|
982
|
|
983
|
// Perform a quick search for projects, searching only by acronym, title or code and funder and using cahce if enabled.
|
984
|
// $keyword the keyword to search for
|
985
|
// $funder the funder to search for
|
986
|
// $limit the maximum number of results to retrieve
|
987
|
// $locale the locale to use
|
988
|
// return projects (array) or NULL if any errors occur
|
989
|
public function quickSearchProjects($keyword, $funder, $limit, $locale) {
|
990
|
if ($this -> cache -> getCaching()) {
|
991
|
$cacheId = self :: QUICK_SEARCH_PROJECTS_CACHE_ID . '.' . $keyword . '.' . $funder . '.' . $limit . '.' . $locale;
|
992
|
$projects = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
993
|
if ($projects === FALSE) {
|
994
|
$projects = $this -> _quickSearchProjects($keyword, $funder, $limit, $locale);
|
995
|
if ($projects !== NULL)
|
996
|
$this -> cache -> store($projects, $cacheId, self :: CACHE_GROUP);
|
997
|
}
|
998
|
} else
|
999
|
$projects = $this -> _quickSearchProjects($keyword, $funder, $limit, $locale);
|
1000
|
return $projects;
|
1001
|
}
|
1002
|
|
1003
|
// Perform a quick search for organizations, searching only by name or short name and using cache if enabled.
|
1004
|
// $keyword the keyword to search for
|
1005
|
// $limit the maximum number of results to retrieve
|
1006
|
// $locale the locale to use
|
1007
|
// return organizations (array) or NULL if any errors occur
|
1008
|
public function quickSearchOrganizations($keyword, $limit, $locale) {
|
1009
|
if ($this -> cache -> getCaching()) {
|
1010
|
$cacheId = self :: QUICK_SEARCH_ORGANIZATIONS_CACHE_ID . '.' . $keyword . '.' . $limit . '.' . $locale;
|
1011
|
$organizations = $this -> cache -> get($cacheId, self :: CACHE_GROUP);
|
1012
|
if ($organizations === FALSE) {
|
1013
|
$organizations = $this -> _quickSearchOrganizations($keyword, $limit, $locale);
|
1014
|
if ($organizations !== NULL)
|
1015
|
$this -> cache -> store($organizations, $cacheId, self :: CACHE_GROUP);
|
1016
|
}
|
1017
|
} else
|
1018
|
$organizations = $this -> _quickSearchOrganizations($keyword, $limit, $locale);
|
1019
|
return $organizations;
|
1020
|
}
|
1021
|
|
1022
|
// Retrieve publication statistics.
|
1023
|
// $locale the locale to use
|
1024
|
// return statistics (object)
|
1025
|
private function _getPublicationStatistics($locale) {
|
1026
|
try {
|
1027
|
$time = microtime(TRUE);
|
1028
|
$query = self :: PUBLICATION_QUERY;
|
1029
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1030
|
if (($response = $this -> performGet('search?action=refine&rTransformer=results_openaire_browse&fields=' . self :: PUBLICATION_TYPE . '&fields=' . self :: PUBLICATION_LANGUAGE . '&fields=' . self :: PUBLICATION_CONTEXT . '&fields=' . self :: PUBLICATION_FUNDER . '&fields=' . self :: PUBLICATION_FUNDING_STREAM . '&fields=' . self :: PUBLICATION_SCIENTIFIC_AREA . '&fields=' . self :: PUBLICATION_YEAR . '&fields=' . self :: PUBLICATION_ACCESS_MODE . '&fields=' . self :: PUBLICATION_DATASOURCE .'&fields=' . self :: PUBLICATION_CONTEXT . '&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1031
|
throw new Exception('no HTTP response');
|
1032
|
if ($response -> code != self :: HTTP_OK)
|
1033
|
throw new Exception('HTTP response code ' . $response -> code);
|
1034
|
$document = new DOMDocument();
|
1035
|
$document -> recover = TRUE;
|
1036
|
if ($document -> loadXML($response -> body) == FALSE)
|
1037
|
throw new Exception('invalid XML response');
|
1038
|
$xpath = new DOMXPath($document);
|
1039
|
$statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'funder', 'fundingStream', 'scientificArea', 'year', 'accessMode', 'datasource', 'community'), array('DOCUMENT_TYPE', 'DOCUMENT_LANGUAGE', 'FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'PUBLICATION_YEAR', 'ACCESS_MODE', 'DATASOURCE', 'CONTEXT'), array('NO_DOCUMENT_TYPE_STATISTICS_FOUND', 'NO_DOCUMENT_LANGUAGE_STATISTICS_FOUND',
|
1040
|
'NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_PUBLICATION_YEAR_STATISTICS_FOUND', 'NO_ACCESS_MODE_STATISTICS_FOUND', 'NO_DATASOURCE_STATISTICS_FOUND', 'NO_CONTEXT_STATISTICS_FOUND'), array(self :: PUBLICATION_TYPE, self :: PUBLICATION_LANGUAGE, self :: PUBLICATION_FUNDER, self :: PUBLICATION_FUNDING_STREAM, self :: PUBLICATION_SCIENTIFIC_AREA, self :: PUBLICATION_YEAR, self :: PUBLICATION_ACCESS_MODE, self :: PUBLICATION_DATASOURCE, self :: PUBLICATION_CONTEXT));
|
1041
|
JLog :: add('Retrieved publication statistics in ' . (microtime(TRUE) - $time) . ' s (locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1042
|
return $statistics;
|
1043
|
} catch (Exception $e) {
|
1044
|
JLog :: add('Error retrieving publication statistics (locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1045
|
return NULL;
|
1046
|
}
|
1047
|
}
|
1048
|
|
1049
|
// Retrieve dataset statistics.
|
1050
|
// $locale the locale to use
|
1051
|
// return statistics (object)
|
1052
|
private function _getDatasetStatistics($locale) {
|
1053
|
try {
|
1054
|
$time = microtime(TRUE);
|
1055
|
$query = self :: DATASET_QUERY;
|
1056
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1057
|
if (($response = $this -> performGet('search?action=refine&rTransformer=results_openaire_browse&fields=' . self :: DATASET_TYPE . '&fields=' . self :: DATASET_LANGUAGE . '&fields=' . self :: DATASET_FUNDER . '&fields=' . self :: DATASET_FUNDING_STREAM . '&fields=' . self :: DATASET_SCIENTIFIC_AREA . '&fields=' . self :: DATASET_YEAR . '&fields=' . self :: DATASET_ACCESS_MODE . '&fields=' . self :: DATASET_DATASOURCE . '&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1058
|
throw new Exception('no HTTP response');
|
1059
|
if ($response -> code != self :: HTTP_OK)
|
1060
|
throw new Exception('HTTP response code ' . $response -> code);
|
1061
|
$document = new DOMDocument();
|
1062
|
$document -> recover = TRUE;
|
1063
|
if ($document -> loadXML($response -> body) == FALSE)
|
1064
|
throw new Exception('invalid XML response');
|
1065
|
$xpath = new DOMXPath($document);
|
1066
|
$statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'funder', 'fundingStream', 'scientificArea', 'year', 'accessMode', 'datasource'), array('DATASET_TYPE', 'DATASET_LANGUAGE', 'FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'PUBLICATION_YEAR', 'ACCESS_MODE', 'DATASOURCE'), array('NO_DATASET_TYPE_STATISTICS_FOUND', 'NO_DATASET_LANGUAGE_STATISTICS_FOUND', 'NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_PUBLICATION_YEAR_STATISTICS_FOUND', 'NO_ACCESS_MODE_STATISTICS_FOUND', 'NO_DATASOURCE_STATISTICS_FOUND'), array(self :: DATASET_TYPE, self :: DATASET_LANGUAGE, self :: DATASET_FUNDER, self :: DATASET_FUNDING_STREAM, self :: DATASET_SCIENTIFIC_AREA, self :: DATASET_YEAR, self :: DATASET_ACCESS_MODE, self :: DATASET_DATASOURCE));
|
1067
|
JLog :: add('Retrieved dataset statistics in ' . (microtime(TRUE) - $time) . ' s (locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1068
|
return $statistics;
|
1069
|
} catch (Exception $e) {
|
1070
|
JLog :: add('Error retrieving dataset statistics (locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1071
|
return NULL;
|
1072
|
}
|
1073
|
}
|
1074
|
|
1075
|
// Retrieve project statistics.
|
1076
|
// $locale the locale to use
|
1077
|
// return statistics (object)
|
1078
|
private function _getProjectStatistics($locale) {
|
1079
|
try {
|
1080
|
$time = microtime(TRUE);
|
1081
|
$query = self :: PROJECT_QUERY;
|
1082
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1083
|
if (($response = $this -> performGet('search?action=refine&rTransformer=results_openaire_browse&fields=' . self :: PROJECT_FUNDER . '&fields=' . self :: PROJECT_FUNDING_STREAM . '&fields=' . self :: PROJECT_SCIENTIFIC_AREA . '&fields=' . self :: PROJECT_START_YEAR . '&fields=' . self :: PROJECT_END_YEAR . '&fields=' . self :: PROJECT_SC39 . '&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1084
|
throw new Exception('no HTTP response');
|
1085
|
if ($response -> code != self :: HTTP_OK)
|
1086
|
throw new Exception('HTTP response code ' . $response -> code);
|
1087
|
$document = new DOMDocument();
|
1088
|
$document -> recover = TRUE;
|
1089
|
if ($document -> loadXML($response -> body) == FALSE)
|
1090
|
throw new Exception('invalid XML response');
|
1091
|
$xpath = new DOMXPath($document);
|
1092
|
$statistics = $this -> createStatistics($xpath, array('funder', 'fundingStream', 'scientificArea', 'startYear', 'endYear', 'sc39'), array('FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'START_YEAR', 'END_YEAR', 'SPECIAL_CLAUSE_39'), array('NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_START_YEAR_STATISTICS_FOUND', 'NO_END_YEAR_STATISTICS_FOUND', 'NO_SPECIAL_CLAUSE_39_STATISTICS_FOUND'), array(self :: PROJECT_FUNDER, self :: PROJECT_FUNDING_STREAM, self :: PROJECT_SCIENTIFIC_AREA, self :: PROJECT_START_YEAR, self :: PROJECT_END_YEAR, self :: PROJECT_SC39));
|
1093
|
JLog :: add('Retrieved project statistics in ' . (microtime(TRUE) - $time) . ' s (locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1094
|
return $statistics;
|
1095
|
} catch (Exception $e) {
|
1096
|
JLog :: add('Error retrieving project statistics (locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1097
|
return NULL;
|
1098
|
}
|
1099
|
}
|
1100
|
|
1101
|
// Retrieve people statistics.
|
1102
|
// $locale the locale to use
|
1103
|
// return statistics (object)
|
1104
|
private function _getPeopleStatistics($locale) {
|
1105
|
try {
|
1106
|
$time = microtime(TRUE);
|
1107
|
$query = self :: PERSON_QUERY;
|
1108
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1109
|
if (($response = $this -> performGet('search?action=refine&rTransformer=results_openaire_browse&fields=' . self :: PERSON_COUNTRY . '&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1110
|
throw new Exception('no HTTP response');
|
1111
|
if ($response -> code != self :: HTTP_OK)
|
1112
|
throw new Exception('HTTP response code ' . $response -> code);
|
1113
|
$document = new DOMDocument();
|
1114
|
$document -> recover = TRUE;
|
1115
|
if ($document -> loadXML($response -> body) == FALSE)
|
1116
|
throw new Exception('invalid XML response');
|
1117
|
$xpath = new DOMXPath($document);
|
1118
|
$statistics = $this -> createStatistics($xpath, array('country'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: PERSON_COUNTRY));
|
1119
|
JLog :: add('Retrieved people statistics in ' . (microtime(TRUE) - $time) . ' s (locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1120
|
return $statistics;
|
1121
|
} catch (Exception $e) {
|
1122
|
JLog :: add('Error retrieving people statistics (locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1123
|
return NULL;
|
1124
|
}
|
1125
|
}
|
1126
|
|
1127
|
// Retrieve organization statistics.
|
1128
|
// $locale the locale to use
|
1129
|
// return statistics (object)
|
1130
|
private function _getOrganizationStatistics($locale) {
|
1131
|
try {
|
1132
|
$time = microtime(TRUE);
|
1133
|
$query = self :: ORGANIZATION_QUERY;
|
1134
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1135
|
if (($response = $this -> performGet('search?action=refine&rTransformer=results_openaire_browse&fields=' . self :: ORGANIZATION_COUNTRY . '&fields=' . self :: ORGANIZATION_LEGAL_BODY . '&fields=' . self :: ORGANIZATION_LEGAL_PERSON . '&fields=' . self :: ORGANIZATION_NON_PROFIT . '&fields=' . self :: ORGANIZATION_RESEARCH . '&fields=' . self :: ORGANIZATION_EU_INTERESTS . '&fields=' . self :: ORGANIZATION_INTERNATIONAL . '&fields=' . self :: ORGANIZATION_ENTERPRISE . '&fields=' . self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE . '&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1136
|
throw new Exception('no HTTP response');
|
1137
|
if ($response -> code != self :: HTTP_OK)
|
1138
|
throw new Exception('HTTP response code ' . $response -> code);
|
1139
|
$document = new DOMDocument();
|
1140
|
$document -> recover = TRUE;
|
1141
|
if ($document -> loadXML($response -> body) == FALSE)
|
1142
|
throw new Exception('invalid XML response');
|
1143
|
$xpath = new DOMXPath($document);
|
1144
|
$statistics = $this -> createStatistics($xpath, array('country'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: ORGANIZATION_COUNTRY));
|
1145
|
$statistics['type'] = new JObject();
|
1146
|
$statistics['type'] -> id = 'type';
|
1147
|
$statistics['type'] -> title = JText :: _('ORGANIZATION_TYPE');
|
1148
|
$statistics['type'] -> error = JText :: _('NO_ORGANIZATION_TYPE_STATISTICS_FOUND');
|
1149
|
$statistics['type'] -> data = array();
|
1150
|
$legalBody = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_BODY);
|
1151
|
if (($legalBody != NULL) && array_key_exists('true', $legalBody)) {
|
1152
|
$statistics['type'] -> data['legalBody'] = new JObject();
|
1153
|
$statistics['type'] -> data['legalBody'] -> id = 'legalBody';
|
1154
|
$statistics['type'] -> data['legalBody'] -> name = JText :: _('LEGAL_BODY');
|
1155
|
$statistics['type'] -> data['legalBody'] -> count = $legalBody['true'] -> count;
|
1156
|
}
|
1157
|
$legalPerson = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_PERSON);
|
1158
|
if (($legalPerson != NULL) && array_key_exists('true', $legalPerson)) {
|
1159
|
$statistics['type'] -> data['legalPerson'] = new JObject();
|
1160
|
$statistics['type'] -> data['legalPerson'] -> id = 'legalPerson';
|
1161
|
$statistics['type'] -> data['legalPerson'] -> name = JText :: _('LEGAL_PERSON');
|
1162
|
$statistics['type'] -> data['legalPerson'] -> count = $legalPerson['true'] -> count;
|
1163
|
}
|
1164
|
$nonProfit = $this -> parseStatistics($xpath, self :: ORGANIZATION_NON_PROFIT);
|
1165
|
if (($nonProfit != NULL) && array_key_exists('true', $nonProfit)) {
|
1166
|
$statistics['type'] -> data['nonProfit'] = new JObject();
|
1167
|
$statistics['type'] -> data['nonProfit'] -> id = 'nonProfit';
|
1168
|
$statistics['type'] -> data['nonProfit'] -> name = JText :: _('NON_PROFIT_ORGANIZATION');
|
1169
|
$statistics['type'] -> data['nonProfit'] -> count = $nonProfit['true'] -> count;
|
1170
|
}
|
1171
|
$research = $this -> parseStatistics($xpath, self :: ORGANIZATION_RESEARCH);
|
1172
|
if (($research != NULL) && array_key_exists('true', $research)) {
|
1173
|
$statistics['type'] -> data['research'] = new JObject();
|
1174
|
$statistics['type'] -> data['research'] -> id = 'research';
|
1175
|
$statistics['type'] -> data['research'] -> name = JText :: _('RESEARCH_ORGANIZATION');
|
1176
|
$statistics['type'] -> data['research'] -> count = $research['true'] -> count;
|
1177
|
}
|
1178
|
$euInterests = $this -> parseStatistics($xpath, self :: ORGANIZATION_EU_INTERESTS);
|
1179
|
if (($euInterests != NULL) && array_key_exists('true', $euInterests)) {
|
1180
|
$statistics['type'] -> data['euInterests'] = new JObject();
|
1181
|
$statistics['type'] -> data['euInterests'] -> id = 'euInterests';
|
1182
|
$statistics['type'] -> data['euInterests'] -> name = JText :: _('EU_INTERESTS_ORGANIZATION');
|
1183
|
$statistics['type'] -> data['euInterests'] -> count = $euInterests['true'] -> count;
|
1184
|
}
|
1185
|
$international = $this -> parseStatistics($xpath, self :: ORGANIZATION_INTERNATIONAL);
|
1186
|
if (($international != NULL) && array_key_exists('true', $international)) {
|
1187
|
$statistics['type'] -> data['international'] = new JObject();
|
1188
|
$statistics['type'] -> data['international'] -> id = 'international';
|
1189
|
$statistics['type'] -> data['international'] -> name = JText :: _('INTERNATIONAL_ORGANIZATION');
|
1190
|
$statistics['type'] -> data['international'] -> count = $international['true'] -> count;
|
1191
|
}
|
1192
|
$enterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_ENTERPRISE);
|
1193
|
if (($enterprise != NULL) && array_key_exists('true', $enterprise)) {
|
1194
|
$statistics['type'] -> data['enterprise'] = new JObject();
|
1195
|
$statistics['type'] -> data['enterprise'] -> id = 'enterprise';
|
1196
|
$statistics['type'] -> data['enterprise'] -> name = JText :: _('ENTERPRISE');
|
1197
|
$statistics['type'] -> data['enterprise'] -> count = $enterprise['true'] -> count;
|
1198
|
}
|
1199
|
$smallMediumEnterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE);
|
1200
|
if (($smallMediumEnterprise != NULL) && array_key_exists('true', $smallMediumEnterprise)) {
|
1201
|
$statistics['type'] -> data['smallMediumEnterprise'] = new JObject();
|
1202
|
$statistics['type'] -> data['smallMediumEnterprise'] -> id = 'smallMediumEnterprise';
|
1203
|
$statistics['type'] -> data['smallMediumEnterprise'] -> name = JText :: _('SMALL_MEDIUM_ENTERPRISE');
|
1204
|
$statistics['type'] -> data['smallMediumEnterprise'] -> count = $smallMediumEnterprise['true'] -> count;
|
1205
|
}
|
1206
|
uasort($statistics['type'] -> data, function ($row1, $row2) {return $row2 -> count - $row1 -> count;});
|
1207
|
JLog :: add('Retrieved organization statistics in ' . (microtime(TRUE) - $time) . ' s (locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1208
|
return $statistics;
|
1209
|
} catch (Exception $e) {
|
1210
|
JLog :: add('Error retrieving organization statistics (locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1211
|
return NULL;
|
1212
|
}
|
1213
|
}
|
1214
|
|
1215
|
// Retrieve datasource statistics.
|
1216
|
// $locale the locale to use
|
1217
|
// return statistics (object)
|
1218
|
private function _getDatasourceStatistics($locale) {
|
1219
|
try {
|
1220
|
$time = microtime(TRUE);
|
1221
|
$query = self :: DATASOURCE_QUERY;
|
1222
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1223
|
if (($response = $this -> performGet('search?action=refine&rTransformer=results_openaire_browse&fields=' . self :: DATASOURCE_TYPE . '&fields=' . self :: DATASOURCE_LANGUAGE . '&fields=' . self :: DATASOURCE_CONTENT . '&fields=' . self :: DATASOURCE_COMPATIBILITY . '&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1224
|
throw new Exception('no HTTP response');
|
1225
|
if ($response -> code != self :: HTTP_OK)
|
1226
|
throw new Exception('HTTP response code ' . $response -> code);
|
1227
|
$document = new DOMDocument();
|
1228
|
$document -> recover = TRUE;
|
1229
|
if ($document -> loadXML($response -> body) == FALSE)
|
1230
|
throw new Exception('invalid XML response');
|
1231
|
$xpath = new DOMXPath($document);
|
1232
|
$statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'content', 'compatibility'), array('DATASOURCE_TYPE', 'DATASOURCE_LANGUAGE', 'CONTENT', 'COMPATIBILITY'), array('NO_DATASOURCE_TYPE_STATISTICS_FOUND', 'NO_DATASOURCE_LANGUAGE_STATISTICS_FOUND', 'NO_CONTENT_STATISTICS_FOUND', 'NO_COMPATIBILITY_STATISTICS_FOUND'), array(self :: DATASOURCE_TYPE, self :: DATASOURCE_LANGUAGE, self :: DATASOURCE_CONTENT, self :: DATASOURCE_COMPATIBILITY));
|
1233
|
JLog :: add('Retrieved datasource statistics in ' . (microtime(TRUE) - $time) . ' s (locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1234
|
return $statistics;
|
1235
|
} catch (Exception $e) {
|
1236
|
JLog :: add('Error retrieving datasource statistics locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1237
|
return NULL;
|
1238
|
}
|
1239
|
}
|
1240
|
|
1241
|
// Perform a simple search for publications.
|
1242
|
// $keyword the keyword to search for
|
1243
|
// $articles flag to limit searching on articles; if all flags are FALSE no limits apply
|
1244
|
// $books flag to limit searching on books; if all flags are FALSE no limits apply
|
1245
|
// $theses flag to limit searching on books; if all flags are FALSE no limits apply
|
1246
|
// $reports flag to limit searching on reports; if all flags are FALSE no limits apply
|
1247
|
// $type the ID of the publication type to use as filter or NULL for no publication type filtering
|
1248
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
1249
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
1250
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
1251
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
1252
|
// $year the year of publication to use as filter or NULL for no year filtering
|
1253
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
1254
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
1255
|
// $page the page of results to retrieve
|
1256
|
// $size the size of the page of results to retrieve
|
1257
|
// $locale the locale to use
|
1258
|
// return a result (object) containing publications and statistics
|
1259
|
private function _searchPublications($keyword, $articles, $books, $theses, $reports, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale) {
|
1260
|
try {
|
1261
|
$time = microtime(TRUE);
|
1262
|
$query = self :: PUBLICATION_QUERY;
|
1263
|
$query .= ($keyword == NULL) ? '' : ' and "' . str_replace('"', '\\"', $keyword) . '"';
|
1264
|
$types = array();
|
1265
|
if ($articles) {
|
1266
|
$types[] = self :: PUBLICATION_ARTICLE;
|
1267
|
$types[] = self :: PUBLICATION_PREPRINT;
|
1268
|
}
|
1269
|
if ($books) {
|
1270
|
$types[] = self :: PUBLICATION_BOOK;
|
1271
|
$types[] = self :: PUBLICATION_BOOK_PART;
|
1272
|
}
|
1273
|
if ($theses) {
|
1274
|
$types[] = self :: PUBLICATION_PHD_THESIS;
|
1275
|
$types[] = self :: PUBLICATION_MASTER_THESIS;
|
1276
|
$types[] = self :: PUBLICATION_BACHELOR_THESIS;
|
1277
|
}
|
1278
|
if ($reports) {
|
1279
|
$types[] = self :: PUBLICATION_REPORT;
|
1280
|
$types[] = self :: PUBLICATION_INTERNAL_REPORT;
|
1281
|
$types[] = self :: PUBLICATION_EXTERNAL_REPORT;
|
1282
|
}
|
1283
|
$publicationType = self :: PUBLICATION_TYPE;
|
1284
|
$types = implode(' or ', array_map(function($type) use ($publicationType) {return '(' . $publicationType . ' exact "' . $type . '")';}, $types));
|
1285
|
$query .= ($types == NULL) ? '' : (' and (' . $types . ')');
|
1286
|
$query .= ($type == NULL) ? '' : (' and (' . self :: PUBLICATION_TYPE . ' exact "' . $type . '")');
|
1287
|
$query .= ($language == NULL) ? '' : (' and (' . self :: PUBLICATION_LANGUAGE . ' exact "' . $language . '")');
|
1288
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: PUBLICATION_FUNDER . ' exact "' . $funder . '")');
|
1289
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: PUBLICATION_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
1290
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: PUBLICATION_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
1291
|
$query .= ($year == NULL) ? '' : (' and (' . self :: PUBLICATION_YEAR . ' exact ' . $year . ')');
|
1292
|
$query .= ($accessMode == NULL) ? '' : (' and (' . self :: PUBLICATION_ACCESS_MODE . ' exact "' . $accessMode . '")');
|
1293
|
$query .= ($datasource == NULL) ? '' : (' and (' . self :: PUBLICATION_DATASOURCE . ' exact "' . $datasource . '")');
|
1294
|
$query .= ($community == NULL) ? '' : (' and (' . self :: PUBLICATION_CONTEXT . ' exact "' . $community . '")');
|
1295
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1296
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=results_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PUBLICATION_TYPE . '&fields=' . self :: PUBLICATION_LANGUAGE . '&fields=' . self :: PUBLICATION_FUNDER . '&fields=' . self :: PUBLICATION_FUNDING_STREAM . '&fields=' . self :: PUBLICATION_SCIENTIFIC_AREA . '&fields=' . self :: PUBLICATION_YEAR . '&fields=' . self :: PUBLICATION_ACCESS_MODE . '&fields=' . self :: PUBLICATION_DATASOURCE . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1297
|
throw new Exception('no HTTP response');
|
1298
|
if ($response -> code != self :: HTTP_OK)
|
1299
|
throw new Exception('HTTP response code ' . $response -> code);
|
1300
|
$document = new DOMDocument();
|
1301
|
$document -> recover = TRUE;
|
1302
|
if ($document -> loadXML($response -> body) == FALSE)
|
1303
|
throw new Exception('invalid XML response');
|
1304
|
$xpath = new DOMXPath($document);
|
1305
|
$result = new JObject();
|
1306
|
$result -> totalPublications = $this -> parseTotalResults($xpath);
|
1307
|
$result -> publications = $this -> parsePublications($xpath);
|
1308
|
$result -> statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'funder', 'fundingStream', 'scientificArea', 'year', 'accessMode', 'datasource'), array('DOCUMENT_TYPE', 'DOCUMENT_LANGUAGE', 'FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'PUBLICATION_YEAR', 'ACCESS_MODE', 'DATASOURCE'), array('NO_DOCUMENT_TYPE_STATISTICS_FOUND', 'NO_DOCUMENT_LANGUAGE_STATISTICS_FOUND', 'NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_PUBLICATION_YEAR_STATISTICS_FOUND', 'NO_ACCESS_MODE_STATISTICS_FOUND', 'NO_DATASOURCE_STATISTICS_FOUND'), array(self :: PUBLICATION_TYPE, self :: PUBLICATION_LANGUAGE, self :: PUBLICATION_FUNDER, self :: PUBLICATION_FUNDING_STREAM, self :: PUBLICATION_SCIENTIFIC_AREA, self :: PUBLICATION_YEAR, self :: PUBLICATION_ACCESS_MODE, self :: PUBLICATION_DATASOURCE));
|
1309
|
JLog :: add('Simple search retrieved ' . count($result -> publications) . ' publications in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', articles: ' . ($articles ? 'true' : 'false') . ', books: ' . ($books ? 'true' : 'false') . ', theses: ' . ($theses ? 'true' : 'false') . ', reports: ' . ($reports ? 'true' : 'false') . ', type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1310
|
return $result;
|
1311
|
} catch (Exception $e) {
|
1312
|
JLog :: add('Error performing publication simple search (keyword: ' . $keyword . ', articles: ' . ($articles ? 'true' : 'false') . ', books: ' . ($books ? 'true' : 'false') . ', theses: ' . ($theses ? 'true' : 'false') . ', reports: ' . ($reports ? 'true' : 'false') . ', type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1313
|
return NULL;
|
1314
|
}
|
1315
|
}
|
1316
|
|
1317
|
// Perform a simple search for datasets.
|
1318
|
// $keyword the keyword to search for
|
1319
|
// $type the ID of the dataset type to use as filter or NULL for no dataset type filtering
|
1320
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
1321
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
1322
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
1323
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
1324
|
// $year the year of publication to use as filter or NULL for no year filtering
|
1325
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
1326
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
1327
|
// $page the page of results to retrieve
|
1328
|
// $size the size of the page of results to retrieve
|
1329
|
// $locale the locale to use
|
1330
|
// return a result (object) containing datasets and statistics
|
1331
|
private function _searchDatasets($keyword, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale) {
|
1332
|
try {
|
1333
|
$time = microtime(TRUE);
|
1334
|
$query = self :: DATASET_QUERY;
|
1335
|
$query .= ($keyword == NULL) ? '' : ' and "' . str_replace('"', '\\"', $keyword) . '"';
|
1336
|
$query .= ($type == NULL) ? '' : (' and (' . self :: DATASET_TYPE . ' exact "' . $type . '")');
|
1337
|
$query .= ($language == NULL) ? '' : (' and (' . self :: DATASET_LANGUAGE . ' exact "' . $language . '")');
|
1338
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: DATASET_FUNDER . ' exact "' . $funder . '")');
|
1339
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: DATASET_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
1340
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: DATASET_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
1341
|
$query .= ($year == NULL) ? '' : (' and (' . self :: DATASET_YEAR . ' exact ' . $year . ')');
|
1342
|
$query .= ($accessMode == NULL) ? '' : (' and (' . self :: DATASET_ACCESS_MODE . ' exact "' . $accessMode . '")');
|
1343
|
$query .= ($datasource == NULL) ? '' : (' and (' . self :: DATASET_DATASOURCE . ' exact "' . $datasource . '")');
|
1344
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1345
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=results_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: DATASET_TYPE . '&fields=' . self :: DATASET_LANGUAGE . '&fields=' . self :: DATASET_FUNDER . '&fields=' . self :: DATASET_FUNDING_STREAM . '&fields=' . self :: DATASET_SCIENTIFIC_AREA . '&fields=' . self :: DATASET_YEAR . '&fields=' . self :: DATASET_ACCESS_MODE . '&fields=' . self :: DATASET_DATASOURCE . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1346
|
throw new Exception('no HTTP response');
|
1347
|
if ($response -> code != self :: HTTP_OK)
|
1348
|
throw new Exception('HTTP response code ' . $response -> code);
|
1349
|
$document = new DOMDocument();
|
1350
|
$document -> recover = TRUE;
|
1351
|
if ($document -> loadXML($response -> body) == FALSE)
|
1352
|
throw new Exception('invalid XML response');
|
1353
|
$xpath = new DOMXPath($document);
|
1354
|
$result = new JObject();
|
1355
|
$result -> totalDatasets = $this -> parseTotalResults($xpath);
|
1356
|
$result -> datasets = $this -> parseDatasets($xpath);
|
1357
|
$result -> statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'funder', 'fundingStream', 'scientificArea', 'year', 'accessMode', 'datasource'), array('DATASET_TYPE', 'DATASET_LANGUAGE', 'FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'PUBLICATION_YEAR', 'ACCESS_MODE', 'DATASOURCE'), array('NO_DATASET_TYPE_STATISTICS_FOUND', 'NO_DATASET_LANGUAGE_STATISTICS_FOUND', 'NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_PUBLICATION_YEAR_STATISTICS_FOUND', 'NO_ACCESS_MODE_STATISTICS_FOUND', 'NO_DATASOURCE_STATISTICS_FOUND'), array(self :: DATASET_TYPE, self :: DATASET_LANGUAGE, self :: DATASET_FUNDER, self :: DATASET_FUNDING_STREAM, self :: DATASET_SCIENTIFIC_AREA, self :: DATASET_YEAR, self :: DATASET_ACCESS_MODE, self :: DATASET_DATASOURCE));
|
1358
|
JLog :: add('Simple search retrieved ' . count($result -> datasets) . ' datasets in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1359
|
return $result;
|
1360
|
} catch (Exception $e) {
|
1361
|
JLog :: add('Error performing dataset simple search (keyword: ' . $keyword . ', type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1362
|
return NULL;
|
1363
|
}
|
1364
|
}
|
1365
|
|
1366
|
// Perform a simple search for projects.
|
1367
|
// $keyword the keyword to search for
|
1368
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
1369
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
1370
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
1371
|
// $startYear the start year to use as filter or NULL for no start year filtering
|
1372
|
// $endYear the end year to suse as filter or NULL for no end year filtering
|
1373
|
// $sc39 the SC-39 status to use as filter or NULL for no SC-39 status filtering
|
1374
|
// $page the page of results to retrieve
|
1375
|
// $size the size of the page of results to retrieve
|
1376
|
// $locale the locale to use
|
1377
|
// return a result (object) containing projects and statistics
|
1378
|
private function _searchProjects($keyword, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale) {
|
1379
|
try {
|
1380
|
$time = microtime(TRUE);
|
1381
|
$query = self :: PROJECT_QUERY;
|
1382
|
$query .= ($keyword == NULL) ? '' : ' and ((' . self :: PROJECT_ACRONYM . ' = "' . str_replace('"', '\\"', $keyword) . '") or (' . self :: PROJECT_CODE . ' = "' . str_replace('"', '\\"', $keyword) . '") or (' . self :: PROJECT_TITLE . ' = "' . str_replace('"', '\\"', $keyword) . '"))';
|
1383
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: PROJECT_FUNDER . ' exact "' . $funder . '")');
|
1384
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: PROJECT_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
1385
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: PROJECT_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
1386
|
$query .= ($startYear == NULL) ? '' : (' and (' . self :: PROJECT_START_YEAR . ' exact ' . $startYear . ')');
|
1387
|
$query .= ($endYear == NULL) ? '' : (' and (' . self :: PROJECT_END_YEAR . ' exact ' . $endYear . ')');
|
1388
|
$query .= ($sc39 === NULL) ? '' : (' and (' . self :: PROJECT_SC39 . ' exact ' . ($sc39 ? 'true' : 'false') . ')');
|
1389
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1390
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=projects_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PROJECT_FUNDER . '&fields=' . self :: PROJECT_FUNDING_STREAM . '&fields=' . self :: PROJECT_SCIENTIFIC_AREA . '&fields=' . self :: PROJECT_START_YEAR . '&fields=' . self :: PROJECT_END_YEAR . '&fields=' . self :: PROJECT_SC39 . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1391
|
throw new Exception('no HTTP response');
|
1392
|
if ($response -> code != self :: HTTP_OK)
|
1393
|
throw new Exception('HTTP response code ' . $response -> code);
|
1394
|
$document = new DOMDocument();
|
1395
|
$document -> recover = TRUE;
|
1396
|
if ($document -> loadXML($response -> body) == FALSE)
|
1397
|
throw new Exception('invalid XML response');
|
1398
|
$xpath = new DOMXPath($document);
|
1399
|
$result = new JObject();
|
1400
|
$result -> totalProjects = $this -> parseTotalResults($xpath);
|
1401
|
$result -> projects = $this -> parseProjects($xpath);
|
1402
|
$result -> statistics = $this -> createStatistics($xpath, array('funder', 'fundingStream', 'scientificArea', 'startYear', 'endYear', 'sc39'), array('FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'START_YEAR', 'END_YEAR', 'SPECIAL_CLAUSE_39'), array('NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_START_YEAR_STATISTICS_FOUND', 'NO_END_YEAR_STATISTICS_FOUND', 'NO_SPECIAL_CLAUSE_39_STATISTICS_FOUND'), array(self :: PROJECT_FUNDER, self :: PROJECT_FUNDING_STREAM, self :: PROJECT_SCIENTIFIC_AREA, self :: PROJECT_START_YEAR, self :: PROJECT_END_YEAR, self :: PROJECT_SC39));
|
1403
|
JLog :: add('Simple search retrieved ' . count($result -> projects) . ' projects in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', start year: ' . (($startYear == NULL) ? 'null' : $startYear) . ', end year: ' . (($endYear == NULL) ? 'null' : $endYear) . ', SC-39: ' . (($sc39 === NULL) ? 'null' : ($sc39 ? 'true' : 'false')) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1404
|
return $result;
|
1405
|
} catch (Exception $e) {
|
1406
|
JLog :: add('Error performing project simple search (keyword: ' . $keyword . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', start year: ' . (($startYear == NULL) ? 'null' : $startYear) . ', end year: ' . (($endYear == NULL) ? 'null' : $endYear) . ', SC-39: ' . (($sc39 === NULL) ? 'null' : ($sc39 ? 'true' : 'false')) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1407
|
return NULL;
|
1408
|
}
|
1409
|
}
|
1410
|
// Perform a simple search for people.
|
1411
|
// $keyword the keyword to search for
|
1412
|
// $country the country to use as filter or NULL for no country filtering
|
1413
|
// $page the page of results to retrieve
|
1414
|
// $size the size of the page of results to retrieve
|
1415
|
// $locale the locale to use
|
1416
|
// return a result (object) containing people and statistics
|
1417
|
private function _searchPeople($keyword, $country, $page, $size, $locale) {
|
1418
|
try {
|
1419
|
$time = microtime(TRUE);
|
1420
|
$query = self :: PERSON_QUERY;
|
1421
|
$query .= ($keyword == NULL) ? '' : ' and "' . str_replace('"', '\\"', $keyword) . '"';
|
1422
|
$query .= ($country == NULL) ? '' : (' and ('. self :: PERSON_COUNTRY . ' exact "' . $country . '")');
|
1423
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1424
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=persons_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PERSON_COUNTRY . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1425
|
throw new Exception('no HTTP response');
|
1426
|
if ($response -> code != self :: HTTP_OK)
|
1427
|
throw new Exception('HTTP response code ' . $response -> code);
|
1428
|
$document = new DOMDocument();
|
1429
|
$document -> recover = TRUE;
|
1430
|
if ($document -> loadXML($response -> body) == FALSE)
|
1431
|
throw new Exception('invalid XML response');
|
1432
|
$xpath = new DOMXPath($document);
|
1433
|
$result = new JObject();
|
1434
|
$result -> totalPeople = $this -> parseTotalResults($xpath);
|
1435
|
$result -> people = $this -> parsePeople($xpath);
|
1436
|
$result -> statistics = $this -> createStatistics($xpath, array('country'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: PERSON_COUNTRY));
|
1437
|
JLog :: add('Simple search retrieved ' . count($result -> people) . ' people in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', country: ' . (($country == NULL) ? 'null' : $country) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1438
|
return $result;
|
1439
|
} catch (Exception $e) {
|
1440
|
JLog :: add('Error performing people simple search (keyword: ' . $keyword . ', country: ' . (($country == NULL) ? 'null' : $country) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1441
|
return NULL;
|
1442
|
}
|
1443
|
}
|
1444
|
|
1445
|
// Perform a simple search for organizations.
|
1446
|
// $keyword the keyword to search for
|
1447
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
1448
|
// $type the ID of the organization type to use as filter or NULL for no organization type filtering
|
1449
|
// $page the page of results to retrieve
|
1450
|
// $size the size of the page of results to retrieve
|
1451
|
// $locale the locale to use
|
1452
|
// return a result (object) containing people and statistics
|
1453
|
private function _searchOrganizations($keyword, $country, $type, $page, $size, $locale) {
|
1454
|
try {
|
1455
|
$time = microtime(TRUE);
|
1456
|
$query = self :: ORGANIZATION_QUERY;
|
1457
|
$query .= ($keyword == NULL) ? '' : (' and "' . str_replace('"', '\\"', $keyword) . '"');
|
1458
|
$query .= ($country == NULL) ? '' : (' and ('. self :: ORGANIZATION_COUNTRY . ' exact "' . $country . '")');
|
1459
|
switch ($type) {
|
1460
|
case 'legalBody':
|
1461
|
$query .= ' and (' . self :: ORGANIZATION_LEGAL_BODY . ' exact true)';
|
1462
|
break;
|
1463
|
case 'legalPerson':
|
1464
|
$query .= ' and (' . self :: ORGANIZATION_LEGAL_PERSON . ' exact true)';
|
1465
|
break;
|
1466
|
case 'nonProfit':
|
1467
|
$query .= ' and (' . self :: ORGANIZATION_NON_PROFIT . ' exact true)';
|
1468
|
break;
|
1469
|
case 'research':
|
1470
|
$query .= ' and (' . self :: ORGANIZATION_RESEARCH . ' exact true)';
|
1471
|
break;
|
1472
|
case 'euInterests':
|
1473
|
$query .= ' and (' . self :: ORGANIZATION_EU_INTERESTS . ' exact true)';
|
1474
|
break;
|
1475
|
case 'international':
|
1476
|
$query .= ' and (' . self :: ORGANIZATION_INTERNATIONAL . ' exact true)';
|
1477
|
break;
|
1478
|
case 'enterprise':
|
1479
|
$query .= ' and (' . self :: ORGANIZATION_ENTERPRISE . ' exact true)';
|
1480
|
break;
|
1481
|
case 'smallMediumEnterprise':
|
1482
|
$query .= ' and (' . self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE . ' exact true)';
|
1483
|
}
|
1484
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1485
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=organizations_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: ORGANIZATION_COUNTRY . '&fields=' . self :: ORGANIZATION_LEGAL_BODY . '&fields=' . self :: ORGANIZATION_LEGAL_PERSON . '&fields=' . self :: ORGANIZATION_NON_PROFIT . '&fields=' . self :: ORGANIZATION_RESEARCH . '&fields=' . self :: ORGANIZATION_EU_INTERESTS . '&fields=' . self :: ORGANIZATION_INTERNATIONAL . '&fields=' . self :: ORGANIZATION_ENTERPRISE . '&fields=' . self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1486
|
throw new Exception('no HTTP response');
|
1487
|
if ($response -> code != self :: HTTP_OK)
|
1488
|
throw new Exception('HTTP response code ' . $response -> code);
|
1489
|
$document = new DOMDocument();
|
1490
|
$document -> recover = TRUE;
|
1491
|
if ($document -> loadXML($response -> body) == FALSE)
|
1492
|
throw new Exception('invalid XML response');
|
1493
|
$xpath = new DOMXPath($document);
|
1494
|
$result = new JObject();
|
1495
|
$result -> totalOrganizations = $this -> parseTotalResults($xpath);
|
1496
|
$result -> organizations = $this -> parseOrganizations($xpath);
|
1497
|
$result -> statistics = $this -> createStatistics($xpath, array('country'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: ORGANIZATION_COUNTRY));
|
1498
|
$result -> statistics['type'] = new JObject();
|
1499
|
$result -> statistics['type'] -> id = 'type';
|
1500
|
$result -> statistics['type'] -> title = JText :: _('ORGANIZATION_TYPE');
|
1501
|
$result -> statistics['type'] -> error = JText :: _('NO_ORGANIZATION_TYPE_STATISTICS_FOUND');
|
1502
|
$result -> statistics['type'] -> data = array();
|
1503
|
$legalBody = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_BODY);
|
1504
|
if (($legalBody != NULL) && array_key_exists('true', $legalBody)) {
|
1505
|
$result -> statistics['type'] -> data['legalBody'] = new JObject();
|
1506
|
$result -> statistics['type'] -> data['legalBody'] -> id = 'legalBody';
|
1507
|
$result -> statistics['type'] -> data['legalBody'] -> name = JText :: _('LEGAL_BODY');
|
1508
|
$result -> statistics['type'] -> data['legalBody'] -> count = $legalBody['true'] -> count;
|
1509
|
}
|
1510
|
$legalPerson = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_PERSON);
|
1511
|
if (($legalPerson != NULL) && array_key_exists('true', $legalPerson)) {
|
1512
|
$result -> statistics['type'] -> data['legalPerson'] = new JObject();
|
1513
|
$result -> statistics['type'] -> data['legalPerson'] -> id = 'legalPerson';
|
1514
|
$result -> statistics['type'] -> data['legalPerson'] -> name = JText :: _('LEGAL_PERSON');
|
1515
|
$result -> statistics['type'] -> data['legalPerson'] -> count = $legalPerson['true'] -> count;
|
1516
|
}
|
1517
|
$nonProfit = $this -> parseStatistics($xpath, self :: ORGANIZATION_NON_PROFIT);
|
1518
|
if (($nonProfit != NULL) && array_key_exists('true', $nonProfit)) {
|
1519
|
$result -> statistics['type'] -> data['nonProfit'] = new JObject();
|
1520
|
$result -> statistics['type'] -> data['nonProfit'] -> id = 'nonProfit';
|
1521
|
$result -> statistics['type'] -> data['nonProfit'] -> name = JText :: _('NON_PROFIT_ORGANIZATION');
|
1522
|
$result -> statistics['type'] -> data['nonProfit'] -> count = $nonProfit['true'] -> count;
|
1523
|
}
|
1524
|
$research = $this -> parseStatistics($xpath, self :: ORGANIZATION_RESEARCH);
|
1525
|
if (($research != NULL) && array_key_exists('true', $research)) {
|
1526
|
$result -> statistics['type'] -> data['research'] = new JObject();
|
1527
|
$result -> statistics['type'] -> data['research'] -> id = 'research';
|
1528
|
$result -> statistics['type'] -> data['research'] -> name = JText :: _('RESEARCH_ORGANIZATION');
|
1529
|
$result -> statistics['type'] -> data['research'] -> count = $research['true'] -> count;
|
1530
|
}
|
1531
|
$euInterests = $this -> parseStatistics($xpath, self :: ORGANIZATION_EU_INTERESTS);
|
1532
|
if (($euInterests != NULL) && array_key_exists('true', $euInterests)) {
|
1533
|
$result -> statistics['type'] -> data['euInterests'] = new JObject();
|
1534
|
$result -> statistics['type'] -> data['euInterests'] -> id = 'euInterests';
|
1535
|
$result -> statistics['type'] -> data['euInterests'] -> name = JText :: _('EU_INTERESTS_ORGANIZATION');
|
1536
|
$result -> statistics['type'] -> data['euInterests'] -> count = $euInterests['true'] -> count;
|
1537
|
}
|
1538
|
$international = $this -> parseStatistics($xpath, self :: ORGANIZATION_INTERNATIONAL);
|
1539
|
if (($international != NULL) && array_key_exists('true', $international)) {
|
1540
|
$result -> statistics['type'] -> data['international'] = new JObject();
|
1541
|
$result -> statistics['type'] -> data['international'] -> id = 'international';
|
1542
|
$result -> statistics['type'] -> data['international'] -> name = JText :: _('INTERNATIONAL_ORGANIZATION');
|
1543
|
$result -> statistics['type'] -> data['international'] -> count = $international['true'] -> count;
|
1544
|
}
|
1545
|
$enterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_ENTERPRISE);
|
1546
|
if (($enterprise != NULL) && array_key_exists('true', $enterprise)) {
|
1547
|
$result -> statistics['type'] -> data['enterprise'] = new JObject();
|
1548
|
$result -> statistics['type'] -> data['enterprise'] -> id = 'enterprise';
|
1549
|
$result -> statistics['type'] -> data['enterprise'] -> name = JText :: _('ENTERPRISE');
|
1550
|
$result -> statistics['type'] -> data['enterprise'] -> count = $enterprise['true'] -> count;
|
1551
|
}
|
1552
|
$smallMediumEnterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE);
|
1553
|
if (($smallMediumEnterprise != NULL) && array_key_exists('true', $smallMediumEnterprise)) {
|
1554
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] = new JObject();
|
1555
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] -> id = 'smallMediumEnterprise';
|
1556
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] -> name = JText :: _('SMALL_MEDIUM_ENTERPRISE');
|
1557
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] -> count = $smallMediumEnterprise['true'] -> count;
|
1558
|
}
|
1559
|
uasort($result -> statistics['type'] -> data, function ($row1, $row2) {return $row2 -> count - $row1 -> count;});
|
1560
|
JLog :: add('Simple search retrieved ' . count($result -> organizations) . ' organizations in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', country: ' . (($country == NULL) ? 'null' : $country) . ', type: ' . (($type == NULL) ? 'null' : $type) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1561
|
return $result;
|
1562
|
} catch (Exception $e) {
|
1563
|
JLog :: add('Error performing organization simple search (keyword: ' . $keyword . ', country: ' . (($country == NULL) ? 'null' : $country) . ', type: ' . (($type == NULL) ? 'null' : $type) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1564
|
return NULL;
|
1565
|
}
|
1566
|
}
|
1567
|
|
1568
|
// Perform a simple search for datasources.
|
1569
|
// $keyword the keyword to search for
|
1570
|
// $type the ID of the datasource type to use as filter or NULL for no datasource type filtering
|
1571
|
// $language the ID of the datasource language to use as filter or NULL for no datasource language filtering
|
1572
|
// $content the ID of the content to use as filter or NULL for no project filtering
|
1573
|
// $compatibility the ID of the compatibility level to use as filter or NULL for no compatibility level filtering
|
1574
|
// $page the page of results to retrieve
|
1575
|
// $size the size of the page of results to retrieve
|
1576
|
// $locale the locale to use
|
1577
|
// return a result (object) containing datasources and statistics
|
1578
|
private function _searchDatasources($keyword, $type, $language, $content, $compatibility, $page, $size, $locale) {
|
1579
|
try {
|
1580
|
$time = microtime(TRUE);
|
1581
|
$query = self :: DATASOURCE_QUERY;
|
1582
|
$query .= ($keyword == NULL) ? '' : (' and "' . str_replace('"', '\\"', $keyword) . '"');
|
1583
|
$query .= ($type == NULL) ? '' : (' and ('. self :: DATASOURCE_TYPE . ' exact "' . $type . '")');
|
1584
|
$query .= ($language == NULL) ? '' : (' and ('. self :: DATASOURCE_LANGUAGE . ' exact "' . $language . '")');
|
1585
|
$query .= ($content == NULL) ? '' : (' and ('. self :: DATASOURCE_CONTENT . ' exact "' . $content . '")');
|
1586
|
$query .= ($compatibility == NULL) ? '' : (' and ('. self :: DATASOURCE_COMPATIBILITY . ' exact "' . $compatibility . '")');
|
1587
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1588
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=datasources_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: DATASOURCE_TYPE . '&fields=' . self :: DATASOURCE_LANGUAGE . '&fields=' . self :: DATASOURCE_CONTENT . '&fields=' . self :: DATASOURCE_COMPATIBILITY . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1589
|
throw new Exception('no HTTP response');
|
1590
|
if ($response -> code != self :: HTTP_OK)
|
1591
|
throw new Exception('HTTP response code ' . $response -> code);
|
1592
|
$document = new DOMDocument();
|
1593
|
$document -> recover = TRUE;
|
1594
|
if ($document -> loadXML($response -> body) == FALSE)
|
1595
|
throw new Exception('invalid XML response');
|
1596
|
$xpath = new DOMXPath($document);
|
1597
|
$result = new JObject();
|
1598
|
$result -> totalDatasources = $this -> parseTotalResults($xpath);
|
1599
|
$result -> datasources = $this -> parseDatasources($xpath);
|
1600
|
$result -> statistics = $this -> createStatistics($xpath, array('type', 'language', 'content', 'compatibility'), array('DATASOURCE_TYPE', 'DATASOURCE_LANGUAGE', 'CONTENT', 'COMPATIBILITY'), array('NO_DATASOURCE_TYPE_STATISTICS_FOUND', 'NO_DATASOURCE_LANGUAGE_STATISTICS_FOUND', 'NO_CONTENT_STATISTICS_FOUND', 'NO_COMPATIBILITY_STATISTICS_FOUND'), array(self :: DATASOURCE_TYPE, self :: DATASOURCE_LANGUAGE, self :: DATASOURCE_CONTENT, self :: DATASOURCE_COMPATIBILITY));
|
1601
|
JLog :: add('Simple search retrieved ' . count($result -> datasources) . ' datasources in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', content: ' . (($content == NULL) ? 'null' : $content) . ', compatibility: ' . (($compatibility == NULL) ? 'null' : $compatibility) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1602
|
return $result;
|
1603
|
} catch (Exception $e) {
|
1604
|
JLog :: add('Error performing datasource simple search (keyword: ' . $keyword . ', type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', content: ' . (($content == NULL) ? 'null' : $content) . ', compatibility: ' . (($compatibility == NULL) ? 'null' : $compatibility) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1605
|
return NULL;
|
1606
|
}
|
1607
|
}
|
1608
|
|
1609
|
// Perform a browse for publications.
|
1610
|
// $type the ID of the publication type to use as filter or NULL for no publication type filtering
|
1611
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
1612
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
1613
|
// $fundingStream the ID of the fundingStream to use as filter or NULL for no funding stream filtering
|
1614
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
1615
|
// $year the year of publication to use as filter or NULL for no year filtering
|
1616
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
1617
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
1618
|
// $community the ID of the community to use as filter or NULL for no datasource filtering
|
1619
|
// $page the page of results to retrieve
|
1620
|
// $size the size of the page of results to retrieve
|
1621
|
// $locale the locale to use
|
1622
|
// $project the ID of the project to use as filter or NULL for no project filtering
|
1623
|
// $author the ID of the author to use as filter or NULL for no author filtering
|
1624
|
// return a result (object) containing publications and statistics
|
1625
|
private function _browsePublications($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $community, $page, $size, $locale, $project, $author) {
|
1626
|
try {
|
1627
|
$time = microtime(TRUE);
|
1628
|
$query = self :: PUBLICATION_QUERY;
|
1629
|
$query .= ($type == NULL) ? '' : (' and (' . self :: PUBLICATION_TYPE . ' exact "' . $type . '")');
|
1630
|
$query .= ($language == NULL) ? '' : (' and (' . self :: PUBLICATION_LANGUAGE . ' exact "' . $language . '")');
|
1631
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: PUBLICATION_FUNDER . ' exact "' . $funder . '")');
|
1632
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: PUBLICATION_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
1633
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: PUBLICATION_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
1634
|
$query .= ($year == NULL) ? '' : (' and (' . self :: PUBLICATION_YEAR . ' exact ' . $year . ')');
|
1635
|
$query .= ($accessMode == NULL) ? '' : (' and (' . self :: PUBLICATION_ACCESS_MODE . ' exact "' . $accessMode . '")');
|
1636
|
$query .= ($datasource == NULL) ? '' : (' and (' . self :: PUBLICATION_DATASOURCE . ' exact "' . $datasource . '")');
|
1637
|
$query .= ($project == NULL) ? '' : (' and (' . self :: PUBLICATION_PROJECT . ' exact "' . $project . '")');
|
1638
|
$query .= ($author == NULL) ? '' : (' and (' . self :: PUBLICATION_AUTHOR_ID . ' exact "' . $author . '")');
|
1639
|
$query .= ($community == NULL) ? '' : (' and (' . self :: PUBLICATION_CONTEXT . ' exact "' . $community . '")');
|
1640
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1641
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=results_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PUBLICATION_TYPE . '&fields=' . self :: PUBLICATION_LANGUAGE . '&fields=' . self :: PUBLICATION_FUNDER . '&fields=' . self :: PUBLICATION_FUNDING_STREAM . '&fields=' . self :: PUBLICATION_SCIENTIFIC_AREA . '&fields=' . self :: PUBLICATION_YEAR . '&fields=' . self :: PUBLICATION_ACCESS_MODE . '&fields=' . self :: PUBLICATION_DATASOURCE . '&fields=' . self :: PUBLICATION_CONTEXT . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1642
|
throw new Exception('no HTTP response');
|
1643
|
if ($response -> code != self :: HTTP_OK)
|
1644
|
throw new Exception('HTTP response code ' . $response -> code);
|
1645
|
$document = new DOMDocument();
|
1646
|
$document -> recover = TRUE;
|
1647
|
if ($document -> loadXML($response -> body) == FALSE)
|
1648
|
throw new Exception('invalid XML response');
|
1649
|
$xpath = new DOMXPath($document);
|
1650
|
$result = new JObject();
|
1651
|
$result -> totalPublications = $this -> parseTotalResults($xpath);
|
1652
|
$result -> publications = $this -> parsePublications($xpath);
|
1653
|
$result -> statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'funder', 'fundingStream', 'scientificArea', 'year', 'accessMode', 'datasource', 'community'), array('DOCUMENT_TYPE', 'DOCUMENT_LANGUAGE', 'FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'PUBLICATION_YEAR', 'ACCESS_MODE', 'DATASOURCE', 'COMMUNITY'), array('NO_DOCUMENT_TYPE_STATISTICS_FOUND', 'NO_DOCUMENT_LANGUAGE_STATISTICS_FOUND', 'NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_YEAR_STATISTICS_FOUND', 'NO_ACCESS_MODE_STATISTICS_FOUND', 'NO_CONTEXT_STATISTICS_FOUND', 'NO_DATASOURCE_STATISTICS_FOUND'), array(self :: PUBLICATION_TYPE, self :: PUBLICATION_LANGUAGE, self :: PUBLICATION_FUNDER, self :: PUBLICATION_FUNDING_STREAM, self :: PUBLICATION_SCIENTIFIC_AREA, self :: PUBLICATION_YEAR, self :: PUBLICATION_ACCESS_MODE, self :: PUBLICATION_DATASOURCE, self :: PUBLICATION_CONTEXT));
|
1654
|
JLog :: add('Browse retrieved ' . count($result -> publications) . ' publications in ' . (microtime(TRUE) - $time) . ' s (type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', community: ' . (($community == NULL) ? 'null' : $community) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ', project: ' . (($project == NULL) ? 'null' : $project) . ', author: ' . (($author == NULL) ? 'null' : $author) . ')', JLog :: INFO, self :: LOG);
|
1655
|
return $result;
|
1656
|
} catch (Exception $e) {
|
1657
|
JLog :: add('Error performing publication browse (type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', community: ' . (($community == NULL) ? 'null' : $community) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ', project: ' . (($project == NULL) ? 'null' : $project) . ', author: ' . (($author == NULL) ? 'null' : $author) . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1658
|
return NULL;
|
1659
|
}
|
1660
|
}
|
1661
|
|
1662
|
// Perform a browse for datasets.
|
1663
|
// $type the ID of the dataset type to use as filter or NULL for no dataset type filtering
|
1664
|
// $language the ID of the language to use as filter or NULL for no language filtering
|
1665
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
1666
|
// $fundingStream the ID of the fundingStream to use as filter or NULL for no funding stream filtering
|
1667
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
1668
|
// $year the year of publication to use as filter or NULL for no year filtering
|
1669
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
1670
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
1671
|
// $page the page of results to retrieve
|
1672
|
// $size the size of the page of results to retrieve
|
1673
|
// $locale the locale to use
|
1674
|
// $project the ID of the project to use as filter or NULL for no project filtering
|
1675
|
// $author the ID of the author to use as filter or NULL for no author filtering
|
1676
|
// return a result (object) containing datasets and statistics
|
1677
|
private function _browseDatasets($type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale, $project, $author) {
|
1678
|
try {
|
1679
|
$time = microtime(TRUE);
|
1680
|
$query = self :: DATASET_QUERY;
|
1681
|
$query .= ($type == NULL) ? '' : (' and (' . self :: DATASET_TYPE . ' exact "' . $type . '")');
|
1682
|
$query .= ($language == NULL) ? '' : (' and (' . self :: DATASET_LANGUAGE . ' exact "' . $language . '")');
|
1683
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: DATASET_FUNDER . ' exact "' . $funder . '")');
|
1684
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: DATASET_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
1685
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: DATASET_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
1686
|
$query .= ($year == NULL) ? '' : (' and (' . self :: DATASET_YEAR . ' exact ' . $year . ')');
|
1687
|
$query .= ($accessMode == NULL) ? '' : (' and (' . self :: DATASET_ACCESS_MODE . ' exact "' . $accessMode . '")');
|
1688
|
$query .= ($datasource == NULL) ? '' : (' and (' . self :: DATASET_DATASOURCE . ' exact "' . $datasource . '")');
|
1689
|
$query .= ($project == NULL) ? '' : (' and (' . self :: DATASET_PROJECT . ' exact "' . $project . '")');
|
1690
|
$query .= ($author == NULL) ? '' : (' and (' . self :: DATASET_AUTHOR_ID . ' exact "' . $author . '")');
|
1691
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1692
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=results_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: DATASET_TYPE . '&fields=' . self :: DATASET_LANGUAGE . '&fields=' . self :: DATASET_FUNDER . '&fields=' . self :: DATASET_FUNDING_STREAM . '&fields=' . self :: DATASET_SCIENTIFIC_AREA . '&fields=' . self :: DATASET_YEAR . '&fields=' . self :: DATASET_ACCESS_MODE . '&fields=' . self :: DATASET_DATASOURCE . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1693
|
throw new Exception('no HTTP response');
|
1694
|
if ($response -> code != self :: HTTP_OK)
|
1695
|
throw new Exception('HTTP response code ' . $response -> code);
|
1696
|
$document = new DOMDocument();
|
1697
|
$document -> recover = TRUE;
|
1698
|
if ($document -> loadXML($response -> body) == FALSE)
|
1699
|
throw new Exception('invalid XML response');
|
1700
|
$xpath = new DOMXPath($document);
|
1701
|
$result = new JObject();
|
1702
|
$result -> totalDatasets = $this -> parseTotalResults($xpath);
|
1703
|
$result -> datasets = $this -> parseDatasets($xpath);
|
1704
|
$result -> statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'funder', 'fundingStream', 'scientificArea', 'year', 'accessMode', 'datasource'), array('DATASET_TYPE', 'DATASET_LANGUAGE', 'FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'PUBLICATION_YEAR', 'ACCESS_MODE', 'DATASOURCE'), array('NO_DATASET_TYPE_STATISTICS_FOUND', 'NO_DATASET_LANGUAGE_STATISTICS_FOUND', 'NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_YEAR_STATISTICS_FOUND', 'NO_ACCESS_MODE_STATISTICS_FOUND', 'NO_DATASOURCE_STATISTICS_FOUND'), array(self :: DATASET_TYPE, self :: DATASET_LANGUAGE, self :: DATASET_FUNDER, self :: DATASET_FUNDING_STREAM, self :: DATASET_SCIENTIFIC_AREA, self :: DATASET_YEAR, self :: DATASET_ACCESS_MODE, self :: DATASET_DATASOURCE));
|
1705
|
JLog :: add('Browse retrieved ' . count($result -> datasets) . ' datasets in ' . (microtime(TRUE) - $time) . ' s (type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ', project: ' . (($project == NULL) ? 'null' : $project) . ', author: ' . (($author == NULL) ? 'null' : $author) . ')', JLog :: INFO, self :: LOG);
|
1706
|
return $result;
|
1707
|
} catch (Exception $e) {
|
1708
|
JLog :: add('Error performing dataset browse (type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ', project: ' . (($project == NULL) ? 'null' : $project) . ', author: ' . (($author == NULL) ? 'null' : $author) . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1709
|
return NULL;
|
1710
|
}
|
1711
|
}
|
1712
|
|
1713
|
// Perform a browse for projects.
|
1714
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
1715
|
// $fundingStream the ID of the fundingStream to use as filter or NULL for no funding stream filtering
|
1716
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
1717
|
// $startYear the start year to use as filter or NULL for no start year filtering
|
1718
|
// $endYear the end year to use as filter or NULL for no end year filtering
|
1719
|
// $$sc39 the SC-39 status to use as filter or NULL for no SC-39 status filtering
|
1720
|
// $page the page of results to retrieve
|
1721
|
// $size the size of the page of results to retrieve
|
1722
|
// $locale the locale to use
|
1723
|
// return a result (object) containing projects and statistics
|
1724
|
private function _browseProjects($funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale) {
|
1725
|
try {
|
1726
|
$time = microtime(TRUE);
|
1727
|
$query = self :: PROJECT_QUERY;
|
1728
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: PROJECT_FUNDER . ' exact "' . $funder . '")');
|
1729
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: PROJECT_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
1730
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: PROJECT_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
1731
|
$query .= ($startYear == NULL) ? '' : (' and (' . self :: PROJECT_START_YEAR . ' exact ' . $startYear . ')');
|
1732
|
$query .= ($endYear == NULL) ? '' : (' and (' . self :: PROJECT_END_YEAR . ' exact ' . $endYear . ')');
|
1733
|
$query .= ($sc39 === NULL) ? '' : (' and (' . self :: PROJECT_SC39 . ' exact ' . ($sc39 ? 'true' : 'false') . ')');
|
1734
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1735
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=projects_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PROJECT_FUNDER . '&fields=' . self :: PROJECT_FUNDING_STREAM . '&fields=' . self :: PROJECT_SCIENTIFIC_AREA . '&fields=' . self :: PROJECT_START_YEAR . '&fields=' . self :: PROJECT_END_YEAR . '&fields=' . self :: PROJECT_SC39 . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1736
|
throw new Exception('no HTTP response');
|
1737
|
if ($response -> code != self :: HTTP_OK)
|
1738
|
throw new Exception('HTTP response code ' . $response -> code);
|
1739
|
$document = new DOMDocument();
|
1740
|
$document -> recover = TRUE;
|
1741
|
if ($document -> loadXML($response -> body) == FALSE)
|
1742
|
throw new Exception('invalid XML response');
|
1743
|
$xpath = new DOMXPath($document);
|
1744
|
$result = new JObject();
|
1745
|
$result -> totalProjects = $this -> parseTotalResults($xpath);
|
1746
|
$result -> projects = $this -> parseProjects($xpath);
|
1747
|
$result -> statistics = $this -> createStatistics($xpath, array('funder', 'fundingStream', 'scientificArea', 'startYear', 'endYear', 'sc39'), array('FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'START_YEAR', 'END_YEAR', 'SPECIAL_CLAUSE_39'), array('NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_START_YEAR_STATISTICS_FOUND', 'NO_END_YEAR_STATISTICS_FOUND', 'NO_SPECIAL_CLAUSE_39_STATISTICS_FOUND'), array(self :: PROJECT_FUNDER, self :: PROJECT_FUNDING_STREAM, self :: PROJECT_SCIENTIFIC_AREA, self :: PROJECT_START_YEAR, self :: PROJECT_END_YEAR, self :: PROJECT_SC39));
|
1748
|
JLog :: add('Browse retrieved ' . count($result -> projects) . ' projects in ' . (microtime(TRUE) - $time) . ' s (funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', start year: ' . (($startYear == NULL) ? 'null' : $startYear) . ', end year: ' . (($endYear == NULL) ? 'null' : $endYear) . ', SC-39: ' . (($sc39 === NULL) ? 'null' : ($sc39 ? 'true' : 'false')) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1749
|
return $result;
|
1750
|
} catch (Exception $e) {
|
1751
|
JLog :: add('Error performing project browse (funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', start year: ' . (($startYear == NULL) ? 'null' : $startYear) . ', end year: ' . (($endYear == NULL) ? 'null' : $endYear) . ', SC-39: ' . (($sc39 === NULL) ? 'null' : ($sc39 ? 'true' : 'false')) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1752
|
return NULL;
|
1753
|
}
|
1754
|
}
|
1755
|
|
1756
|
// Perform a browse for people.
|
1757
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
1758
|
// $page the page of results to retrieve
|
1759
|
// $size the size of the page of results to retrieve
|
1760
|
// $locale the locale to use
|
1761
|
// return a result (object) containing people and statistics
|
1762
|
private function _browsePeople($country, $page, $size, $locale) {
|
1763
|
try {
|
1764
|
$time = microtime(TRUE);
|
1765
|
$query = self :: PERSON_QUERY;
|
1766
|
$query .= ($country == NULL) ? '' : (' and ('. self :: PERSON_COUNTRY . ' exact "' . $country . '")');
|
1767
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1768
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=persons_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PERSON_COUNTRY . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1769
|
throw new Exception('no HTTP response');
|
1770
|
if ($response -> code != self :: HTTP_OK)
|
1771
|
throw new Exception('HTTP response code ' . $response -> code);
|
1772
|
$document = new DOMDocument();
|
1773
|
$document -> recover = TRUE;
|
1774
|
if ($document -> loadXML($response -> body) == FALSE)
|
1775
|
throw new Exception('invalid XML response');
|
1776
|
$xpath = new DOMXPath($document);
|
1777
|
$result = new JObject();
|
1778
|
$result -> totalPeople = $this -> parseTotalResults($xpath);
|
1779
|
$result -> people = $this -> parsePeople($xpath);
|
1780
|
$result -> statistics = $this -> createStatistics($xpath, array('country'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: PERSON_COUNTRY));
|
1781
|
JLog :: add('Browse retrieved ' . count($result -> people) . ' people in ' . (microtime(TRUE) - $time) . ' s (country: ' . (($country == NULL) ? 'null' : $country) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1782
|
return $result;
|
1783
|
} catch (Exception $e) {
|
1784
|
JLog :: add('Error performing people browse (country: ' . (($country == NULL) ? 'null' : $country) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1785
|
return NULL;
|
1786
|
}
|
1787
|
}
|
1788
|
|
1789
|
// Perform a browse for organizations.
|
1790
|
// $country the ID of the country to use as filter or NULL for no country filtering
|
1791
|
// $type the ID of the organization type to use as filter or NULL for no organization type filtering
|
1792
|
// $page the page of results to retrieve
|
1793
|
// $size the size of the page of results to retrieve
|
1794
|
// $locale the locale to use
|
1795
|
// return a result (object) containing organizations and statistics
|
1796
|
private function _browseOrganizations($country, $type, $page, $size, $locale) {
|
1797
|
try {
|
1798
|
$time = microtime(TRUE);
|
1799
|
$query = self :: ORGANIZATION_QUERY;
|
1800
|
$query .= ($country == NULL) ? '' : (' and ('. self :: ORGANIZATION_COUNTRY . ' exact "' . $country . '")');
|
1801
|
switch ($type) {
|
1802
|
case 'legalBody':
|
1803
|
$query .= ' and (' . self :: ORGANIZATION_LEGAL_BODY . ' exact true)';
|
1804
|
break;
|
1805
|
case 'legalPerson':
|
1806
|
$query .= ' and (' . self :: ORGANIZATION_LEGAL_PERSON . ' exact true)';
|
1807
|
break;
|
1808
|
case 'nonProfit':
|
1809
|
$query .= ' and (' . self :: ORGANIZATION_NON_PROFIT . ' exact true)';
|
1810
|
break;
|
1811
|
case 'research':
|
1812
|
$query .= ' and (' . self :: ORGANIZATION_RESEARCH . ' exact true)';
|
1813
|
break;
|
1814
|
case 'euInterests':
|
1815
|
$query .= ' and (' . self :: ORGANIZATION_EU_INTERESTS . ' exact true)';
|
1816
|
break;
|
1817
|
case 'international':
|
1818
|
$query .= ' and (' . self :: ORGANIZATION_INTERNATIONAL . ' exact true)';
|
1819
|
break;
|
1820
|
case 'enterprise':
|
1821
|
$query .= ' and (' . self :: ORGANIZATION_ENTERPRISE . ' exact true)';
|
1822
|
break;
|
1823
|
case 'smallMediumEnterprise':
|
1824
|
$query .= ' and (' . self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE . ' exact true)';
|
1825
|
}
|
1826
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1827
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=organizations_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: ORGANIZATION_COUNTRY . '&fields=' . self :: ORGANIZATION_LEGAL_BODY . '&fields=' . self :: ORGANIZATION_LEGAL_PERSON . '&fields=' . self :: ORGANIZATION_NON_PROFIT . '&fields=' . self :: ORGANIZATION_RESEARCH . '&fields=' . self :: ORGANIZATION_EU_INTERESTS . '&fields=' . self :: ORGANIZATION_INTERNATIONAL . '&fields=' . self :: ORGANIZATION_ENTERPRISE . '&fields=' . self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1828
|
throw new Exception('no HTTP response');
|
1829
|
if ($response -> code != self :: HTTP_OK)
|
1830
|
throw new Exception('HTTP response code ' . $response -> code);
|
1831
|
$document = new DOMDocument();
|
1832
|
$document -> recover = TRUE;
|
1833
|
if ($document -> loadXML($response -> body) == FALSE)
|
1834
|
throw new Exception('invalid XML response');
|
1835
|
$xpath = new DOMXPath($document);
|
1836
|
$result = new JObject();
|
1837
|
$result -> totalOrganizations = $this -> parseTotalResults($xpath);
|
1838
|
$result -> organizations = $this -> parseOrganizations($xpath);
|
1839
|
$result -> statistics = $this -> createStatistics($xpath, array('country'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: ORGANIZATION_COUNTRY));
|
1840
|
$result -> statistics['type'] = new JObject();
|
1841
|
$result -> statistics['type'] -> id = 'type';
|
1842
|
$result -> statistics['type'] -> title = JText :: _('ORGANIZATION_TYPE');
|
1843
|
$result -> statistics['type'] -> error = JText :: _('NO_ORGANIZATION_TYPE_STATISTICS_FOUND');
|
1844
|
$result -> statistics['type'] -> data = array();
|
1845
|
$legalBody = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_BODY);
|
1846
|
if (($legalBody != NULL) && array_key_exists('true', $legalBody)) {
|
1847
|
$result -> statistics['type'] -> data['legalBody'] = new JObject();
|
1848
|
$result -> statistics['type'] -> data['legalBody'] -> id = 'legalBody';
|
1849
|
$result -> statistics['type'] -> data['legalBody'] -> name = JText :: _('LEGAL_BODY');
|
1850
|
$result -> statistics['type'] -> data['legalBody'] -> count = $legalBody['true'] -> count;
|
1851
|
}
|
1852
|
$legalPerson = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_PERSON);
|
1853
|
if (($legalPerson != NULL) && array_key_exists('true', $legalPerson)) {
|
1854
|
$result -> statistics['type'] -> data['legalPerson'] = new JObject();
|
1855
|
$result -> statistics['type'] -> data['legalPerson'] -> id = 'legalPerson';
|
1856
|
$result -> statistics['type'] -> data['legalPerson'] -> name = JText :: _('LEGAL_PERSON');
|
1857
|
$result -> statistics['type'] -> data['legalPerson'] -> count = $legalPerson['true'] -> count;
|
1858
|
}
|
1859
|
$nonProfit = $this -> parseStatistics($xpath, self :: ORGANIZATION_NON_PROFIT);
|
1860
|
if (($nonProfit != NULL) && array_key_exists('true', $nonProfit)) {
|
1861
|
$result -> statistics['type'] -> data['nonProfit'] = new JObject();
|
1862
|
$result -> statistics['type'] -> data['nonProfit'] -> id = 'nonProfit';
|
1863
|
$result -> statistics['type'] -> data['nonProfit'] -> name = JText :: _('NON_PROFIT_ORGANIZATION');
|
1864
|
$result -> statistics['type'] -> data['nonProfit'] -> count = $nonProfit['true'] -> count;
|
1865
|
}
|
1866
|
$research = $this -> parseStatistics($xpath, self :: ORGANIZATION_RESEARCH);
|
1867
|
if (($research != NULL) && array_key_exists('true', $research)) {
|
1868
|
$result -> statistics['type'] -> data['research'] = new JObject();
|
1869
|
$result -> statistics['type'] -> data['research'] -> id = 'research';
|
1870
|
$result -> statistics['type'] -> data['research'] -> name = JText :: _('RESEARCH_ORGANIZATION');
|
1871
|
$result -> statistics['type'] -> data['research'] -> count = $research['true'] -> count;
|
1872
|
}
|
1873
|
$euInterests = $this -> parseStatistics($xpath, self :: ORGANIZATION_EU_INTERESTS);
|
1874
|
if (($euInterests != NULL) && array_key_exists('true', $euInterests)) {
|
1875
|
$result -> statistics['type'] -> data['euInterests'] = new JObject();
|
1876
|
$result -> statistics['type'] -> data['euInterests'] -> id = 'euInterests';
|
1877
|
$result -> statistics['type'] -> data['euInterests'] -> name = JText :: _('EU_INTERESTS_ORGANIZATION');
|
1878
|
$result -> statistics['type'] -> data['euInterests'] -> count = $euInterests['true'] -> count;
|
1879
|
}
|
1880
|
$international = $this -> parseStatistics($xpath, self :: ORGANIZATION_INTERNATIONAL);
|
1881
|
if (($international != NULL) && array_key_exists('true', $international)) {
|
1882
|
$result -> statistics['type'] -> data['international'] = new JObject();
|
1883
|
$result -> statistics['type'] -> data['international'] -> id = 'international';
|
1884
|
$result -> statistics['type'] -> data['international'] -> name = JText :: _('INTERNATIONAL_ORGANIZATION');
|
1885
|
$result -> statistics['type'] -> data['international'] -> count = $international['true'] -> count;
|
1886
|
}
|
1887
|
$enterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_ENTERPRISE);
|
1888
|
if (($enterprise != NULL) && array_key_exists('true', $enterprise)) {
|
1889
|
$result -> statistics['type'] -> data['enterprise'] = new JObject();
|
1890
|
$result -> statistics['type'] -> data['enterprise'] -> id = 'enterprise';
|
1891
|
$result -> statistics['type'] -> data['enterprise'] -> name = JText :: _('ENTERPRISE');
|
1892
|
$result -> statistics['type'] -> data['enterprise'] -> count = $enterprise['true'] -> count;
|
1893
|
}
|
1894
|
$smallMediumEnterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE);
|
1895
|
if (($smallMediumEnterprise != NULL) && array_key_exists('true', $smallMediumEnterprise)) {
|
1896
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] = new JObject();
|
1897
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] -> id = 'smallMediumEnterprise';
|
1898
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] -> name = JText :: _('SMALL_MEDIUM_ENTERPRISE');
|
1899
|
$result -> statistics['type'] -> data['smallMediumEnterprise'] -> count = $smallMediumEnterprise['true'] -> count;
|
1900
|
}
|
1901
|
uasort($result -> statistics['type'] -> data, function ($row1, $row2) {return $row2 -> count - $row1 -> count;});
|
1902
|
JLog :: add('Browse retrieved ' . count($result -> organizations) . ' organizations in ' . (microtime(TRUE) - $time) . ' s (country: ' . (($country == NULL) ? 'null' : $country) . ', type: ' . (($type == NULL) ? 'null' : $type) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1903
|
return $result;
|
1904
|
} catch (Exception $e) {
|
1905
|
JLog :: add('Error performing organization browse (country: ' . (($country == NULL) ? 'null' : $country) . ', type: ' . (($type == NULL) ? 'null' : $type) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1906
|
return NULL;
|
1907
|
}
|
1908
|
}
|
1909
|
|
1910
|
// Perform a browse for datasources.
|
1911
|
// $type the ID of the datasource type to use as filter or NULL for no datasource type filtering
|
1912
|
// $language the ID of the datasource language to use as filter or NULL for no datasource language filtering
|
1913
|
// $content the ID of the content to use as filter or NULL for no content filtering
|
1914
|
// $compatibility the ID of the compatibility level to use as filter or NULL for no compatibility status filtering
|
1915
|
// $page the page of results to retrieve
|
1916
|
// $size the size of the page of results to retrieve
|
1917
|
// $locale the locale to use
|
1918
|
// return a result (object) containing datasources and statistics
|
1919
|
private function _browseDatasources($type, $language, $content, $compatibility, $page, $size, $locale) {
|
1920
|
try {
|
1921
|
$time = microtime(TRUE);
|
1922
|
$query = self :: DATASOURCE_QUERY;
|
1923
|
$query .= ($type == NULL) ? '' : (' and ('. self :: DATASOURCE_TYPE . ' exact "' . $type . '")');
|
1924
|
$query .= ($language == NULL) ? '' : (' and ('. self :: DATASOURCE_LANGUAGE . ' exact "' . $language . '")');
|
1925
|
$query .= ($content == NULL) ? '' : (' and ('. self :: DATASOURCE_CONTENT . ' exact "' . $content . '")');
|
1926
|
$query .= ($compatibility == NULL) ? '' : (' and ('. self :: DATASOURCE_COMPATIBILITY . ' exact "' . $compatibility . '")');
|
1927
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
1928
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=datasources_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: DATASOURCE_TYPE . '&fields=' . self :: DATASOURCE_LANGUAGE . '&fields=' . self :: DATASOURCE_CONTENT . '&fields=' . self :: DATASOURCE_COMPATIBILITY . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
1929
|
throw new Exception('no HTTP response');
|
1930
|
if ($response -> code != self :: HTTP_OK)
|
1931
|
throw new Exception('HTTP response code ' . $response -> code);
|
1932
|
$document = new DOMDocument();
|
1933
|
$document -> recover = TRUE;
|
1934
|
if ($document -> loadXML($response -> body) == FALSE)
|
1935
|
throw new Exception('invalid XML response');
|
1936
|
$xpath = new DOMXPath($document);
|
1937
|
$result = new JObject();
|
1938
|
$result -> totalDatasources = $this -> parseTotalResults($xpath);
|
1939
|
$result -> datasources = $this -> parseDatasources($xpath);
|
1940
|
$result -> statistics = $this -> createStatistics($xpath, array('type', 'languageFilter', 'content', 'compatibility'), array('DATASOURCE_TYPE', 'DATASOURCE_LANGUAGE', 'CONTENT', 'COMPATIBILITY'), array('NO_DATASOURCE_TYPE_STATISTICS_FOUND', 'NO_DATASOURCE_LANGUAGE_STATISTICS_FOUND', 'NO_CONTENT_STATISTICS_FOUND', 'NO_COMPATIBILITY_STATISTICS_FOUND'), array(self :: DATASOURCE_TYPE, self :: DATASOURCE_LANGUAGE, self :: DATASOURCE_CONTENT, self :: DATASOURCE_COMPATIBILITY));
|
1941
|
JLog :: add('Browse retrieved ' . count($result -> datasources) . ' datasources in ' . (microtime(TRUE) - $time) . ' s (type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', content: ' . (($content == NULL) ? 'null' : $content) . ', compatibility: ' . (($compatibility == NULL) ? 'null' : $compatibility) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
1942
|
return $result;
|
1943
|
} catch (Exception $e) {
|
1944
|
JLog :: add('Error performing datasource browse (type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', content: ' . (($content == NULL) ? 'null' : $content) . ', compatibility: ' . (($compatibility == NULL) ? 'null' : $compatibility) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
1945
|
return NULL;
|
1946
|
}
|
1947
|
}
|
1948
|
|
1949
|
// Perform an advanced search for publications.
|
1950
|
// $keywords the keywords to search for (array)
|
1951
|
// $fields the fields to match keywords with (array - possible values are TITLE, AUTHOR, PUBLISHER and SUBJECT)
|
1952
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
1953
|
// $types the IDs of the publication types to search for
|
1954
|
// $languages the IDs of the publication languages to search for
|
1955
|
// $funders the IDs of the funders to search for
|
1956
|
// $fundingStreams the IDs of the funding streams to search for
|
1957
|
// $scientificAreas the IDs of the scientific areas to search for
|
1958
|
// $date the publication date range to search for expressed in months before current date (if -1 search for any publication date, if 0 search explicitly using $fromMonth, $fromYear, $toMonth and $toYear)
|
1959
|
// $fromMonth start month of the publication date range to search for if $date has value 0
|
1960
|
// $fromYear start year of the publication date range to search for if $date has value 0
|
1961
|
// $toMonth end month of the publication date range to search for if $date has value 0
|
1962
|
// $toYear end year of the publication date range to search for if $date has value 0
|
1963
|
// $accessModes the IDs of the access modes to search for
|
1964
|
// $datasources the IDs of the datasources to search for
|
1965
|
// $type the ID of the publication type to use as filter or NULL for no publication type filtering
|
1966
|
// $language the ID of the publication language to use as filter or NULL for no publication language filtering
|
1967
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
1968
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
1969
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
1970
|
// $year the publication year to use as filter or NULL for no publication year filtering
|
1971
|
// $accessMode the ID of the access mode to use as filter or NULL for no access mode filtering
|
1972
|
// $datasource the ID of the datasource to use as filter or NULL for no datasource filtering
|
1973
|
// $page the page of results to retrieve
|
1974
|
// $size the size of the page of results to retrieve
|
1975
|
// $locale the locale to use
|
1976
|
// return a result (object) containing publications and statistics
|
1977
|
private function _advancedSearchPublications($keywords, $fields, $constraints, $types, $languages, $funders, $fundingStreams, $scientificAreas, $date, $fromMonth, $fromYear, $toMonth, $toYear, $accessModes, $datasources, $type, $language, $funder, $fundingStream, $scientificArea, $year, $accessMode, $datasource, $page, $size, $locale) {
|
1978
|
try {
|
1979
|
$time = microtime(TRUE);
|
1980
|
$query = self :: PUBLICATION_QUERY;
|
1981
|
for ($i = 0; ($i < count($keywords)) && ($i < count($fields)) && ($i < count($constraints)); $i++) {
|
1982
|
$tokens = preg_split('/\s/', $keywords[$i], NULL, PREG_SPLIT_NO_EMPTY);
|
1983
|
switch ($constraints[$i]) {
|
1984
|
case OpenAireViewAdvancedSearchPublications :: ALL:
|
1985
|
$operator = ' and ';
|
1986
|
break;
|
1987
|
case OpenAireViewAdvancedSearchPublications :: ANY:
|
1988
|
$operator = ' or ';
|
1989
|
break;
|
1990
|
default:
|
1991
|
$operator = NULL;
|
1992
|
}
|
1993
|
switch ($fields[$i]) {
|
1994
|
case OpenAireViewAdvancedSearchPublications :: TITLE:
|
1995
|
$field = self :: PUBLICATION_TITLE;
|
1996
|
break;
|
1997
|
case OpenAireViewAdvancedSearchPublications :: AUTHOR:
|
1998
|
$field = self :: PUBLICATION_AUTHOR;
|
1999
|
break;
|
2000
|
case OpenAireViewAdvancedSearchPublications :: PUBLISHER:
|
2001
|
$field = self :: PUBLICATION_PUBLISHER;
|
2002
|
break;
|
2003
|
case OpenAireViewAdvancedSearchPublications :: SUBJECT:
|
2004
|
$field = self :: PUBLICATION_SUBJECT;
|
2005
|
break;
|
2006
|
default:
|
2007
|
$field = NULL;
|
2008
|
}
|
2009
|
$query .= ($tokens == NULL) ? '' : (' and (' . implode($operator, array_map(function ($keyword) use ($field) {return '(' . (($field == NULL) ? '' : ($field . ' = ')) . '"' . str_replace('"', '\\"', $keyword) . '")';}, $tokens)) . ')');
|
2010
|
}
|
2011
|
$field = self :: PUBLICATION_TYPE;
|
2012
|
$query .= ($types == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($type) use ($field) {return '(' . $field . ' exact "' . $type . '")';}, $types)) . ')');
|
2013
|
$field = self :: PUBLICATION_LANGUAGE;
|
2014
|
$query .= ($languages == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($language) use ($field) {return '(' . $field . ' exact "' . $language . '")';}, $languages)) . ')');
|
2015
|
$field = self :: PUBLICATION_FUNDER;
|
2016
|
$query .= ($funders == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($funder) use ($field) {return '(' . $field . ' exact "' . $funder . '")';}, $funders)) . ')');
|
2017
|
$field = self :: PUBLICATION_FUNDING_STREAM;
|
2018
|
$query .= ($fundingStreams == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($fundingStream) use ($field) {return '(' . $field . ' exact "' . $fundingStream . '")';}, $fundingStreams)) . ')');
|
2019
|
$field = self :: PUBLICATION_SCIENTIFIC_AREA;
|
2020
|
$query .= ($scientificAreas == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($scientificArea) use ($field) {return '(' . $field . ' exact "' . $scientificArea . '")';}, $scientificAreas)) . ')');
|
2021
|
$from = new DateTime();
|
2022
|
$to = new DateTime();
|
2023
|
switch ($date) {
|
2024
|
case -1:
|
2025
|
break;
|
2026
|
case 0:
|
2027
|
$from -> setDate($fromYear, $fromMonth, 1);
|
2028
|
$to -> setDate($toYear, $toMonth, 1);
|
2029
|
$to -> setDate($toYear, $toMonth, date('t', $to -> getTimestamp())); // update to with the last day of that month
|
2030
|
$query .= ' and (' . self :: PUBLICATION_DATE . ' within "' . date('Y-m-d', $from -> getTimestamp()) . ' ' . date('Y-m-d', $to -> getTimestamp()) . '")';
|
2031
|
break;
|
2032
|
default:
|
2033
|
$from -> sub(new DateInterval('P' . $date . 'M'));
|
2034
|
$query .= ' and (' . self :: PUBLICATION_DATE . ' within "' . date('Y-m-d', $from -> getTimestamp()) . ' ' . date('Y-m-d', $to -> getTimestamp()) . '")';
|
2035
|
}
|
2036
|
$field = self :: PUBLICATION_ACCESS_MODE;
|
2037
|
$query .= ($accessModes == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($accessMode) use ($field) {return '(' . $field . ' exact "' . $accessMode . '")';}, $accessModes)) . ')');
|
2038
|
$field = self :: PUBLICATION_DATASOURCE;
|
2039
|
$query .= ($datasources == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($datasource) use ($field) {return '(' . $field . ' exact "' . $datasource . '")';}, $datasources)) . ')');
|
2040
|
$query .= ($type == NULL) ? '' : (' and (' . self :: PUBLICATION_TYPE . ' exact "' . $type . '")');
|
2041
|
$query .= ($language == NULL) ? '' : (' and (' . self :: PUBLICATION_LANGUAGE . ' exact "' . $language . '")');
|
2042
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: PUBLICATION_FUNDER . ' exact "' . $funder . '")');
|
2043
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: PUBLICATION_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
2044
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: PUBLICATION_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
2045
|
$query .= ($year == NULL) ? '' : (' and (' . self :: PUBLICATION_YEAR . ' exact "' . $year . '")');
|
2046
|
$query .= ($accessMode == NULL) ? '' : (' and (' . self :: PUBLICATION_ACCESS_MODE . ' exact "' . $accessMode . '")');
|
2047
|
$query .= ($datasource == NULL) ? '' : (' and (' . self :: PUBLICATION_DATASOURCE . ' exact "' . $datasource . '")');
|
2048
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2049
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=results_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PUBLICATION_TYPE . '&fields=' . self :: PUBLICATION_LANGUAGE . '&fields=' . self :: PUBLICATION_FUNDER . '&fields=' . self :: PUBLICATION_FUNDING_STREAM . '&fields=' . self :: PUBLICATION_SCIENTIFIC_AREA . '&fields=' . self :: PUBLICATION_YEAR . '&fields=' . self :: PUBLICATION_ACCESS_MODE . '&fields=' . self :: PUBLICATION_DATASOURCE . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2050
|
throw new Exception('no HTTP response');
|
2051
|
if ($response -> code != self :: HTTP_OK)
|
2052
|
throw new Exception('HTTP response code ' . $response -> code);
|
2053
|
$document = new DOMDocument();
|
2054
|
$document -> recover = TRUE;
|
2055
|
if ($document -> loadXML($response -> body) == FALSE)
|
2056
|
throw new Exception('invalid XML response');
|
2057
|
$xpath = new DOMXPath($document);
|
2058
|
$result = new JObject();
|
2059
|
$result -> totalPublications = $this -> parseTotalResults($xpath);
|
2060
|
$result -> publications = $this -> parsePublications($xpath);
|
2061
|
$result -> statistics = $this -> createStatistics($xpath, array('typeFilter', 'languageFilter', 'funderFilter', 'fundingStreamFilter', 'scientificAreaFilter', 'yearFilter', 'accessModeFilter', 'datasourceFilter'), array('DOCUMENT_TYPE', 'DOCUMENT_LANGUAGE', 'FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'PUBLICATION_YEAR', 'ACCESS_MODE', 'DATASOURCE'), array('NO_DOCUMENT_TYPE_STATISTICS_FOUND', 'NO_DOCUMENT_LANGUAGE_STATISTICS_FOUND', 'NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_PUBLICATION_YEAR_STATISTICS_FOUND', 'NO_ACCESS_MODE_STATISTICS_FOUND', 'NO_DATASOURCE_STATISTICS_FOUND'), array(self :: PUBLICATION_TYPE, self :: PUBLICATION_LANGUAGE, self :: PUBLICATION_FUNDER, self :: PUBLICATION_FUNDING_STREAM, self :: PUBLICATION_SCIENTIFIC_AREA, self :: PUBLICATION_YEAR, self :: PUBLICATION_ACCESS_MODE, self :: PUBLICATION_DATASOURCE));
|
2062
|
JLog :: add('Advanced search retrieved ' . count($result -> publications) . ' publications in ' . (microtime(TRUE) - $time) . ' s (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], types: [' . implode(', ', $types) . '], languages: [' . implode(', ', $languages) . '], funders: [' . implode(', ', $funders) . '], funding streams: [' . implode(', ', $fundingStreams) . '], scientific areas: [' . implode(', ', $scientificAreas) . '], date: ' . $date . ', from month: ' . $fromMonth . ', from year: ' . $fromYear . ', to month: ' . $toMonth . ', to year: ' . $toYear . ', access modes: [' . implode(', ', $accessModes) . '], datasources: [' . implode(', ', $datasources) . '], type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2063
|
return $result;
|
2064
|
} catch (Exception $e) {
|
2065
|
JLog :: add('Error performing publication advanced search (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], types: [' . implode(', ', $types) . '], languages: [' . implode(', ', $languages) . '], funders: [' . implode(', ', $funders) . '], funding streams: [' . implode(', ', $fundingStreams) . '], scientific areas: [' . implode(', ', $scientificAreas) . '], date: ' . $date . ', from month: ' . $fromMonth . ', from year: ' . $fromYear . ', to month: ' . $toMonth . ', to year: ' . $toYear . ', access modes: [' . implode(', ', $accessModes) . '], datasources: [' . implode(', ', $datasources) . '], type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', year: ' . (($year == NULL) ? 'null' : $year) . ', access mode: ' . (($accessMode == NULL) ? 'null' : $accessMode) . ', datasource: ' . (($datasource == NULL) ? 'null' : $datasource) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2066
|
return NULL;
|
2067
|
}
|
2068
|
}
|
2069
|
|
2070
|
// Perform an advanced search for projects.
|
2071
|
// $keywords the keywords to search for (array)
|
2072
|
// $fields the fields to match keywords with (array - possible values are ACRONYM, TITLE and KEYWORDS)
|
2073
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
2074
|
// $funders the IDs of the funders to search for
|
2075
|
// $fundingStreams the IDs of the funding streams to search for
|
2076
|
// $scientificAreas the IDs of the scientific areas to search for
|
2077
|
// $startDate the start date range to search for expressed in months before current date (if -1 search for any start date, if 0 search explicitly using $startFromMonth, $startFromYear, $startToMonth and $startToYear)
|
2078
|
// $startFromMonth start month of the start date range to search for if $startDate has value 0
|
2079
|
// $startFromYear start year of the start date range to search for if $startDate has value 0
|
2080
|
// $startToMonth end month of the start date range to search for if $startDate has value 0
|
2081
|
// $startToYear end year of the start date range to search for if $startDate has value 0
|
2082
|
// $endDate the end date range to search for expressed in months brefore current date (if -1 search for any end date, if 0 search explicitly using $endFromMonth, $endFromYear, $endToMonth and $endToYear)
|
2083
|
// $endFromMonth start month of the end date range to search for if $endDate has value 0
|
2084
|
// $endFromYear start year of the end date range to search for if $endDate has value 0
|
2085
|
// $endToMonth end month of the end date range to search for if $endDate has value 0
|
2086
|
// $endToYear end year of the end date range to search for if $endDate has value 0
|
2087
|
// $sc39s the IDs of the SC-39 statuses to search for
|
2088
|
// $funder the ID of the funder to use as filter or NULL for no funder filtering
|
2089
|
// $fundingStream the ID of the funding stream to use as filter or NULL for no funding stream filtering
|
2090
|
// $scientificArea the ID of the scientific area to use as filter or NULL for no scientific area filtering
|
2091
|
// $startYear the start year to use as filter or NULL for no start year filtering
|
2092
|
// $endYear the end year to use as filter or NULL for no end year filtering
|
2093
|
// $sc39 the ID of the SC-39 status to use as filter or NULL for no SC-39 status filtering
|
2094
|
// $page the page of results to retrieve
|
2095
|
// $size the size of the page of results to retrieve
|
2096
|
// $locale the locale to use
|
2097
|
// return a result (object) containing projects and statistics
|
2098
|
private function _advancedSearchProjects($keywords, $fields, $constraints, $funders, $fundingStreams, $scientificAreas, $startDate, $startFromMonth, $startFromYear, $startToMonth, $startToYear, $endDate, $endFromMonth, $endFromYear, $endToMonth, $endToYear, $sc39s, $funder, $fundingStream, $scientificArea, $startYear, $endYear, $sc39, $page, $size, $locale) {
|
2099
|
try {
|
2100
|
$time = microtime(TRUE);
|
2101
|
$query = self :: PROJECT_QUERY;
|
2102
|
for ($i = 0; ($i < count($keywords)) && ($i < count($fields)) && ($i < count($constraints)); $i++) {
|
2103
|
$tokens = preg_split('/\s/', $keywords[$i], NULL, PREG_SPLIT_NO_EMPTY);
|
2104
|
switch ($constraints[$i]) {
|
2105
|
case OpenAireViewAdvancedSearchProjects :: ALL:
|
2106
|
$operator = ' and ';
|
2107
|
break;
|
2108
|
case OpenAireViewAdvancedSearchProjects :: ANY:
|
2109
|
$operator = ' or ';
|
2110
|
break;
|
2111
|
default:
|
2112
|
$operator = NULL;
|
2113
|
}
|
2114
|
switch ($fields[$i]) {
|
2115
|
case OpenAireViewAdvancedSearchProjects :: ACRONYM:
|
2116
|
$field = self :: PROJECT_ACRONYM;
|
2117
|
break;
|
2118
|
case OpenAireViewAdvancedSearchProjects :: TITLE:
|
2119
|
$field = self :: PROJECT_TITLE;
|
2120
|
break;
|
2121
|
case OpenAireViewAdvancedSearchProjects :: KEYWORDS:
|
2122
|
$field = self :: PROJECT_KEYWORDS;
|
2123
|
break;
|
2124
|
default:
|
2125
|
$field = NULL;
|
2126
|
}
|
2127
|
$query .= ($tokens == NULL) ? '' : (' and (' . implode($operator, array_map(function ($keyword) use ($field) {return '(' . (($field == NULL) ? '' : ($field . ' = ')) . '"' . str_replace('"', '\\"', $keyword) . '")';}, $tokens)) . ')');
|
2128
|
}
|
2129
|
$field = self :: PROJECT_FUNDER;
|
2130
|
$query .= ($funders == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($funder) use ($field) {return '(' . $field . ' exact "' . $funder . '")';}, $funders)) . ')');
|
2131
|
$field = self :: PROJECT_FUNDING_STREAM;
|
2132
|
$query .= ($fundingStreams == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($fundingStream) use ($field) {return '(' . $field . ' exact "' . $fundingStream . '")';}, $fundingStreams)) . ')');
|
2133
|
$field = self :: PROJECT_SCIENTIFIC_AREA;
|
2134
|
$query .= ($scientificAreas == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($scientificArea) use ($field) {return '(' . $field . ' exact "' . $scientificArea . '")';}, $scientificAreas)) . ')');
|
2135
|
$from = new DateTime();
|
2136
|
$to = new DateTime();
|
2137
|
switch ($startDate) {
|
2138
|
case -1:
|
2139
|
break;
|
2140
|
case 0:
|
2141
|
$from -> setDate($startFromYear, $startFromMonth, 1);
|
2142
|
$to -> setDate($startToYear, $startToMonth, 1);
|
2143
|
$to -> setDate($startToYear, $startToMonth, date('t', $to -> getTimestamp())); // update to with the last day of that month
|
2144
|
$query .= ' and (' . self :: PROJECT_START_DATE . ' within "' . date('Y-m-d', $from -> getTimestamp()) . ' ' . date('Y-m-d', $to -> getTimestamp()) . '")';
|
2145
|
break;
|
2146
|
default:
|
2147
|
$from -> sub(new DateInterval('P' . $startDate . 'M'));
|
2148
|
$query .= ' and (' . self :: PROJECT_START_DATE . ' within "' . date('Y-m-d', $from -> getTimestamp()) . ' ' . date('Y-m-d', $to -> getTimestamp()) . '")';
|
2149
|
}
|
2150
|
$from = new DateTime();
|
2151
|
$to = new DateTime();
|
2152
|
switch ($endDate) {
|
2153
|
case -1:
|
2154
|
break;
|
2155
|
case 0:
|
2156
|
$from -> setDate($endFromYear, $endFromMonth, 1);
|
2157
|
$to -> setDate($endToYear, $endToMonth, 1);
|
2158
|
$to -> setDate($endToYear, $endToMonth, date('t', $to -> getTimestamp())); // update to with the last day of that month
|
2159
|
$query .= ' and (' . self :: PROJECT_END_DATE . ' within "' . date('Y-m-d', $from -> getTimestamp()) . ' ' . date('Y-m-d', $to -> getTimestamp()) . '")';
|
2160
|
break;
|
2161
|
default:
|
2162
|
$from -> sub(new DateInterval('P' . $endDate . 'M'));
|
2163
|
$query .= ' and (' . self :: PROJECT_END_DATE . ' within "' . date('Y-m-d', $from -> getTimestamp()) . ' ' . date('Y-m-d', $to -> getTimestamp()) . '")';
|
2164
|
}
|
2165
|
$field = self :: PROJECT_SC39;
|
2166
|
$query .= ($sc39s == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($sc39) use ($field) {return '(' . $field . ' exact "' . ($sc39 ? 'true' : 'false') . '")';}, $sc39s)) . ')');
|
2167
|
$query .= ($funder == NULL) ? '' : (' and (' . self :: PROJECT_FUNDER . ' exact "' . $funder . '")');
|
2168
|
$query .= ($fundingStream == NULL) ? '' : (' and (' . self :: PROJECT_FUNDING_STREAM . ' exact "' . $fundingStream . '")');
|
2169
|
$query .= ($scientificArea == NULL) ? '' : (' and (' . self :: PROJECT_SCIENTIFIC_AREA . ' exact "' . $scientificArea . '")');
|
2170
|
$query .= ($startYear == NULL) ? '' : (' and (' . self :: PROJECT_START_YEAR . ' exact "' . $startYear . '")');
|
2171
|
$query .= ($endYear == NULL) ? '' : (' and (' . self :: PROJECT_END_YEAR . ' exact "' . $endYear . '")');
|
2172
|
$query .= ($sc39 === NULL) ? '' : (' and (' . self :: PROJECT_SC39 . ' exact "' . ($sc39 ? 'true' : 'false') . '")');
|
2173
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2174
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=projects_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PROJECT_FUNDER . '&fields=' . self :: PROJECT_FUNDING_STREAM . '&fields=' . self :: PROJECT_SCIENTIFIC_AREA . '&fields=' . self :: PROJECT_START_YEAR . '&fields=' . self :: PROJECT_END_YEAR . '&fields=' . self :: PROJECT_SC39 . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2175
|
throw new Exception('no HTTP response');
|
2176
|
if ($response -> code != self :: HTTP_OK)
|
2177
|
throw new Exception('HTTP response code ' . $response -> code);
|
2178
|
$document = new DOMDocument();
|
2179
|
$document -> recover = TRUE;
|
2180
|
if ($document -> loadXML($response -> body) == FALSE)
|
2181
|
throw new Exception('invalid XML response');
|
2182
|
$xpath = new DOMXPath($document);
|
2183
|
$result = new JObject();
|
2184
|
$result -> totalProjects = $this -> parseTotalResults($xpath);
|
2185
|
$result -> projects = $this -> parseProjects($xpath);
|
2186
|
$result -> statistics = $this -> createStatistics($xpath, array('funderFilter', 'fundingStreamFilter', 'scientificAreaFilter', 'startYearFilter', 'endYearFilter', 'sc39Filter'), array('FUNDER', 'FUNDING_STREAM', 'SCIENTIFIC_AREA', 'START_YEAR', 'END_YEAR', 'SPECIAL_CLAUSE_39'), array('NO_FUNDER_STATISTICS_FOUND', 'NO_FUNDING_STREAM_STATISTICS_FOUND', 'NO_SCIENTIFIC_AREA_STATISTICS_FOUND', 'NO_START_YEAR_STATISTICS_FOUND', 'NO_END_YEAR_STATISTICS_FOUND', 'NO_SPECIAL_CLAUSE_39_STATISTICS_FOUND'), array(self :: PROJECT_FUNDER, self :: PROJECT_FUNDING_STREAM, self :: PROJECT_SCIENTIFIC_AREA, self :: PROJECT_START_YEAR, self :: PROJECT_END_YEAR, self :: PROJECT_SC39));
|
2187
|
JLog :: add('Advanced search retrieved ' . count($result -> projects) . ' projects in ' . (microtime(TRUE) - $time) . ' s (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], funders: [' . implode(', ', $funders) . '], funding streams: [' . implode(', ', $fundingStreams) . '], scientific areas: [' . implode(', ', $scientificAreas) . '], start date: ' . $startDate . ', start from month: ' . $startFromMonth . ', start from year: ' . $startFromYear . ', start to month: ' . $startToMonth . ', start to year: ' . $startToYear . ', end date: ' . $endDate . ', end from month: ' . $endFromMonth . ', end from year: ' . $endFromYear . ', end to month: ' . $endToMonth . ', end to year: ' . $endToYear . ', SC-39s: [' . implode(', ', array_map(function ($sc39) {return $sc39 ? 'true' : 'false';}, $sc39s)) . '], funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', start year: ' . (($startYear == NULL) ? 'null' : $startYear) . ', end year: ' . (($endYear == NULL) ? 'null' : $endYear) . ', SC-39: ' . (($sc39 === NULL) ? 'null' : ($sc39 ? 'true' : 'false')) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2188
|
return $result;
|
2189
|
} catch (Exception $e) {
|
2190
|
JLog :: add('Error performing publication advanced search (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], funders: [' . implode(', ', $funders) . '], funding streams: [' . implode(', ', $fundingStreams) . '], scientific areas: [' . implode(', ', $scientificAreas) . '], start date: ' . $startDate . ', start from month: ' . $startFromMonth . ', start from year: ' . $startFromYear . ', start to month: ' . $startToMonth . ', start to year: ' . $startToYear . ', end date: ' . $endDate . ', end from month: ' . $endFromMonth . ', end from year: ' . $endFromYear . ', end to month: ' . $endToMonth . ', end to year: ' . $endToYear . ', SC-39s: [' . implode(', ', array_map(function ($sc39) {return $sc39 ? 'true' : 'false';}, $sc39s)) . '], funder: ' . (($funder == NULL) ? 'null' : $funder) . ', funding stream: ' . (($fundingStream == NULL) ? 'null' : $fundingStream) . ', scientific area: ' . (($scientificArea == NULL) ? 'null' : $scientificArea) . ', start year: ' . (($startYear == NULL) ? 'null' : $startYear) . ', end year: ' . (($endYear == NULL) ? 'null' : $endYear) . ', SC-39: ' . (($sc39 === NULL) ? 'null' : ($sc39 ? 'true' : 'false')) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2191
|
return NULL;
|
2192
|
}
|
2193
|
}
|
2194
|
|
2195
|
// Perform an advanced search for people.
|
2196
|
// $keywords the keywords to search for (array)
|
2197
|
// $fields the fields to match keywords with (array - possible values are LAST_NAME, FIRST_NAME and FULL_NAME)
|
2198
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
2199
|
// $countries the IDs of the countries to search for
|
2200
|
// $country the ID of the coutnry to use as filter or NULL for no country filtering
|
2201
|
// $page the page of results to retrieve
|
2202
|
// $size the size of the page of results to retrieve
|
2203
|
// $locale the locale to use
|
2204
|
// return a result (object) containing people and statistics
|
2205
|
private function _advancedSearchPeople($keywords, $fields, $constraints, $countries, $country, $page, $size, $locale) {
|
2206
|
try {
|
2207
|
$time = microtime(TRUE);
|
2208
|
$query = self :: PERSON_QUERY;
|
2209
|
for ($i = 0; ($i < count($keywords)) && ($i < count($fields)) && ($i < count($constraints)); $i++) {
|
2210
|
$tokens = preg_split('/\s/', $keywords[$i], NULL, PREG_SPLIT_NO_EMPTY);
|
2211
|
switch ($constraints[$i]) {
|
2212
|
case OpenAireViewAdvancedSearchPeople :: ALL:
|
2213
|
$operator = ' and ';
|
2214
|
break;
|
2215
|
case OpenAireViewAdvancedSearchPeople :: ANY:
|
2216
|
$operator = ' or ';
|
2217
|
break;
|
2218
|
default:
|
2219
|
$operator = NULL;
|
2220
|
}
|
2221
|
switch ($fields[$i]) {
|
2222
|
case OpenAireViewAdvancedSearchPeople :: LAST_NAME:
|
2223
|
$field = self :: PERSON_LAST_NAME;
|
2224
|
break;
|
2225
|
case OpenAireViewAdvancedSearchPeople :: FIRST_NAME:
|
2226
|
$field = self :: PERSON_FIRST_NAME;
|
2227
|
break;
|
2228
|
case OpenAireViewAdvancedSearchPeople :: FULL_NAME:
|
2229
|
$field = self :: PERSON_FULL_NAME;
|
2230
|
break;
|
2231
|
default:
|
2232
|
$field = NULL;
|
2233
|
}
|
2234
|
$query .= ($tokens == NULL) ? '' : (' and (' . implode($operator, array_map(function ($keyword) use ($field) {return '(' . (($field == NULL) ? '' : ($field . ' = ')) . '"' . str_replace('"', '\\"', $keyword) . '")';}, $tokens)) . ')');
|
2235
|
}
|
2236
|
$field = self :: PERSON_COUNTRY;
|
2237
|
$query .= ($countries == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($country) use ($field) {return '(' . $field . ' exact "' . $country . '")';}, $countries)) . ')');
|
2238
|
$query .= ($country == NULL) ? '' : (' and (' . self :: PERSON_COUNTRY . ' exact "' . $country . '")');
|
2239
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2240
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=persons_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: PERSON_COUNTRY . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2241
|
throw new Exception('no HTTP response');
|
2242
|
if ($response -> code != self :: HTTP_OK)
|
2243
|
throw new Exception('HTTP response code ' . $response -> code);
|
2244
|
$document = new DOMDocument();
|
2245
|
$document -> recover = TRUE;
|
2246
|
if ($document -> loadXML($response -> body) == FALSE)
|
2247
|
throw new Exception('invalid XML response');
|
2248
|
$xpath = new DOMXPath($document);
|
2249
|
$result = new JObject();
|
2250
|
$result -> totalPeople = $this -> parseTotalResults($xpath);
|
2251
|
$result -> people = $this -> parsePeople($xpath);
|
2252
|
$result -> statistics = $this -> createStatistics($xpath, array('countryFilter'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: PERSON_COUNTRY));
|
2253
|
JLog :: add('Advanced search retrieved ' . count($result -> people) . ' people in ' . (microtime(TRUE) - $time) . ' s (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], countries: [' . implode(', ', $countries) . '], country: ' . (($country == NULL) ? 'null' : $country) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2254
|
return $result;
|
2255
|
} catch (Exception $e) {
|
2256
|
JLog :: add('Error performing datasource advanced search (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], countries: [' . implode(', ', $countries) . '], country: ' . (($country == NULL) ? 'null' : $country) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2257
|
return NULL;
|
2258
|
}
|
2259
|
}
|
2260
|
|
2261
|
// Perform an advanced search for organizations.
|
2262
|
// $keywords the keywords to search for (array)
|
2263
|
// $fields the fields to match keywords with (array - possible values are NAME and SHORT_NAME)
|
2264
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
2265
|
// $countries the IDs of the countries to search for
|
2266
|
// $types the IDs of the organization types to search for
|
2267
|
// $country the ID of the coutnry to use as filter or NULL for no country filtering
|
2268
|
// $type the ID of the organization type to use as filter or NULL for no organization type filtering
|
2269
|
// $page the page of results to retrieve
|
2270
|
// $size the size of the page of results to retrieve
|
2271
|
// $locale the locale to use
|
2272
|
// return a result (object) containing organizations and statistics
|
2273
|
private function _advancedSearchOrganizations($keywords, $fields, $constraints, $countries, $types, $country, $type, $page, $size, $locale) {
|
2274
|
try {
|
2275
|
$time = microtime(TRUE);
|
2276
|
$query = self :: ORGANIZATION_QUERY;
|
2277
|
for ($i = 0; ($i < count($keywords)) && ($i < count($fields)) && ($i < count($constraints)); $i++) {
|
2278
|
$tokens = preg_split('/\s/', $keywords[$i], NULL, PREG_SPLIT_NO_EMPTY);
|
2279
|
switch ($constraints[$i]) {
|
2280
|
case OpenAireViewAdvancedSearchPeople :: ALL:
|
2281
|
$operator = ' and ';
|
2282
|
break;
|
2283
|
case OpenAireViewAdvancedSearchPeople :: ANY:
|
2284
|
$operator = ' or ';
|
2285
|
break;
|
2286
|
default:
|
2287
|
$operator = NULL;
|
2288
|
}
|
2289
|
switch ($fields[$i]) {
|
2290
|
case OpenAireViewAdvancedSearchOrganizations :: NAME:
|
2291
|
$field = self :: ORGANIZATION_NAME;
|
2292
|
break;
|
2293
|
case OpenAireViewAdvancedSearchOrganizations :: SHORT_NAME:
|
2294
|
$field = self :: ORGANIZATION_SHORT_NAME;
|
2295
|
break;
|
2296
|
default:
|
2297
|
$field = NULL;
|
2298
|
}
|
2299
|
$query .= ($tokens == NULL) ? '' : (' and (' . implode($operator, array_map(function ($keyword) use ($field) {return '(' . (($field == NULL) ? '' : ($field . ' = ')) . '"' . str_replace('"', '\\"', $keyword) . '")';}, $tokens)) . ')');
|
2300
|
}
|
2301
|
$field = self :: ORGANIZATION_COUNTRY;
|
2302
|
$query .= ($countries == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($country) use ($field) {return '(' . $field . ' exact "' . $country . '")';}, $countries)) . ')');
|
2303
|
$organizationLegalBody = self :: ORGANIZATION_LEGAL_BODY;
|
2304
|
$organizationLegalPerson = self :: ORGANIZATION_LEGAL_PERSON;
|
2305
|
$organizationNonProfit = self :: ORGANIZATION_NON_PROFIT;
|
2306
|
$organizationResearch = self :: ORGANIZATION_RESEARCH;
|
2307
|
$organizationEuInterests = self :: ORGANIZATION_EU_INTERESTS;
|
2308
|
$organizationInternational = self :: ORGANIZATION_INTERNATIONAL;
|
2309
|
$organizationEnterprise = self :: ORGANIZATION_ENTERPRISE;
|
2310
|
$organizationSmallMediumEnterprise = self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE;
|
2311
|
$query .= ($types == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($type) use ($organizationLegalBody, $organizationLegalPerson, $organizationNonProfit, $organizationResearch, $organizationEuInterests, $organizationInternational, $organizationEnterprise, $organizationSmallMediumEnterprise) {switch ($type) {case 'legalBody': return '(' . $organizationLegalBody . ' exact true)'; case 'legalPerson': return '(' . $organizationLegalPerson . ' exact true)'; case 'nonProfit': return '(' . $organizationNonProfit . ' exact true)'; case 'research': return '(' . $organizationResearch . ' exact true)'; case 'euInterests': return '(' . $organizationEuInterests . ' exact true)'; case 'international': return '(' . $organizationInternational . ' exact true)'; case 'enterprise': return '(' . $organizationEnterprise . ' exact true)'; case 'smallMediumEnterprise': return '(' . $organizationSmallMediumEnterprise . ' exact true)';}}, $types)) . ')');
|
2312
|
$query .= ($country == NULL) ? '' : (' and (' . self :: ORGANIZATION_COUNTRY . ' exact "' . $country . '")');
|
2313
|
switch ($type) {
|
2314
|
case 'legalBody':
|
2315
|
$query .= ' and (' . self :: ORGANIZATION_LEGAL_BODY . ' exact true)';
|
2316
|
break;
|
2317
|
case 'legalPerson':
|
2318
|
$query .= ' and (' . self :: ORGANIZATION_LEGAL_PERSON . ' exact true)';
|
2319
|
break;
|
2320
|
case 'nonProfit':
|
2321
|
$query .= ' and (' . self :: ORGANIZATION_NON_PROFIT . ' exact true)';
|
2322
|
break;
|
2323
|
case 'research':
|
2324
|
$query .= ' and (' . self :: ORGANIZATION_RESEARCH . ' exact true)';
|
2325
|
break;
|
2326
|
case 'euInterests':
|
2327
|
$query .= ' and (' . self :: ORGANIZATION_EU_INTERESTS . ' exact true)';
|
2328
|
break;
|
2329
|
case 'international':
|
2330
|
$query .= ' and (' . self :: ORGANIZATION_INTERNATIONAL . ' exact true)';
|
2331
|
break;
|
2332
|
case 'enterprise':
|
2333
|
$query .= ' and (' . self :: ORGANIZATION_ENTERPRISE . ' exact true)';
|
2334
|
break;
|
2335
|
case 'smallMediumEnterprise':
|
2336
|
$query .= ' and (' . self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE . ' exact true)';
|
2337
|
}
|
2338
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2339
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=organizations_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: ORGANIZATION_COUNTRY . '&fields=' . self :: ORGANIZATION_LEGAL_BODY . '&fields=' . self :: ORGANIZATION_LEGAL_PERSON . '&fields=' . self :: ORGANIZATION_NON_PROFIT . '&fields=' . self :: ORGANIZATION_RESEARCH . '&fields=' . self :: ORGANIZATION_EU_INTERESTS . '&fields=' . self :: ORGANIZATION_INTERNATIONAL . '&fields=' . self :: ORGANIZATION_ENTERPRISE . '&fields=' . self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2340
|
throw new Exception('no HTTP response');
|
2341
|
if ($response -> code != self :: HTTP_OK)
|
2342
|
throw new Exception('HTTP response code ' . $response -> code);
|
2343
|
$document = new DOMDocument();
|
2344
|
$document -> recover = TRUE;
|
2345
|
if ($document -> loadXML($response -> body) == FALSE)
|
2346
|
throw new Exception('invalid XML response');
|
2347
|
$xpath = new DOMXPath($document);
|
2348
|
$result = new JObject();
|
2349
|
$result -> totalOrganizations = $this -> parseTotalResults($xpath);
|
2350
|
$result -> organizations = $this -> parseOrganizations($xpath);
|
2351
|
$result -> statistics = $this -> createStatistics($xpath, array('countryFilter'), array('COUNTRY'), array('NO_COUNTRY_STATISTICS_FOUND'), array(self :: ORGANIZATION_COUNTRY));
|
2352
|
$result -> statistics['typeFilter'] = new JObject();
|
2353
|
$result -> statistics['typeFilter'] -> id = 'typeFilter';
|
2354
|
$result -> statistics['typeFilter'] -> title = JText :: _('ORGANIZATION_TYPE');
|
2355
|
$result -> statistics['typeFilter'] -> error = JText :: _('NO_ORGANIZATION_TYPE_STATISTICS_FOUND');
|
2356
|
$result -> statistics['typeFilter'] -> data = array();
|
2357
|
$legalBody = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_BODY);
|
2358
|
if (($legalBody != NULL) && array_key_exists('true', $legalBody)) {
|
2359
|
$result -> statistics['typeFilter'] -> data['legalBody'] = new JObject();
|
2360
|
$result -> statistics['typeFilter'] -> data['legalBody'] -> id = 'legalBody';
|
2361
|
$result -> statistics['typeFilter'] -> data['legalBody'] -> name = JText :: _('LEGAL_BODY');
|
2362
|
$result -> statistics['typeFilter'] -> data['legalBody'] -> count = $legalBody['true'] -> count;
|
2363
|
}
|
2364
|
$legalPerson = $this -> parseStatistics($xpath, self :: ORGANIZATION_LEGAL_PERSON);
|
2365
|
if (($legalPerson != NULL) && array_key_exists('true', $legalPerson)) {
|
2366
|
$result -> statistics['typeFilter'] -> data['legalPerson'] = new JObject();
|
2367
|
$result -> statistics['typeFilter'] -> data['legalPerson'] -> id = 'legalPerson';
|
2368
|
$result -> statistics['typeFilter'] -> data['legalPerson'] -> name = JText :: _('LEGAL_PERSON');
|
2369
|
$result -> statistics['typeFilter'] -> data['legalPerson'] -> count = $legalPerson['true'] -> count;
|
2370
|
}
|
2371
|
$nonProfit = $this -> parseStatistics($xpath, self :: ORGANIZATION_NON_PROFIT);
|
2372
|
if (($nonProfit != NULL) && array_key_exists('true', $nonProfit)) {
|
2373
|
$result -> statistics['typeFilter'] -> data['nonProfit'] = new JObject();
|
2374
|
$result -> statistics['typeFilter'] -> data['nonProfit'] -> id = 'nonProfit';
|
2375
|
$result -> statistics['typeFilter'] -> data['nonProfit'] -> name = JText :: _('NON_PROFIT_ORGANIZATION');
|
2376
|
$result -> statistics['typeFilter'] -> data['nonProfit'] -> count = $nonProfit['true'] -> count;
|
2377
|
}
|
2378
|
$research = $this -> parseStatistics($xpath, self :: ORGANIZATION_RESEARCH);
|
2379
|
if (($research != NULL) && array_key_exists('true', $research)) {
|
2380
|
$result -> statistics['typeFilter'] -> data['research'] = new JObject();
|
2381
|
$result -> statistics['typeFilter'] -> data['research'] -> id = 'research';
|
2382
|
$result -> statistics['typeFilter'] -> data['research'] -> name = JText :: _('RESEARCH_ORGANIZATION');
|
2383
|
$result -> statistics['typeFilter'] -> data['research'] -> count = $research['true'] -> count;
|
2384
|
}
|
2385
|
$euInterests = $this -> parseStatistics($xpath, self :: ORGANIZATION_EU_INTERESTS);
|
2386
|
if (($euInterests != NULL) && array_key_exists('true', $euInterests)) {
|
2387
|
$result -> statistics['typeFilter'] -> data['euInterests'] = new JObject();
|
2388
|
$result -> statistics['typeFilter'] -> data['euInterests'] -> id = 'euInterests';
|
2389
|
$result -> statistics['typeFilter'] -> data['euInterests'] -> name = JText :: _('EU_INTERESTS_ORGANIZATION');
|
2390
|
$result -> statistics['typeFilter'] -> data['euInterests'] -> count = $euInterests['true'] -> count;
|
2391
|
}
|
2392
|
$international = $this -> parseStatistics($xpath, self :: ORGANIZATION_INTERNATIONAL);
|
2393
|
if (($international != NULL) && array_key_exists('true', $international)) {
|
2394
|
$result -> statistics['typeFilter'] -> data['international'] = new JObject();
|
2395
|
$result -> statistics['typeFilter'] -> data['international'] -> id = 'international';
|
2396
|
$result -> statistics['typeFilter'] -> data['international'] -> name = JText :: _('INTERNATIONAL_ORGANIZATION');
|
2397
|
$result -> statistics['typeFilter'] -> data['international'] -> count = $international['true'] -> count;
|
2398
|
}
|
2399
|
$enterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_ENTERPRISE);
|
2400
|
if (($enterprise != NULL) && array_key_exists('true', $enterprise)) {
|
2401
|
$result -> statistics['typeFilter'] -> data['enterprise'] = new JObject();
|
2402
|
$result -> statistics['typeFilter'] -> data['enterprise'] -> id = 'enterprise';
|
2403
|
$result -> statistics['typeFilter'] -> data['enterprise'] -> name = JText :: _('ENTERPRISE');
|
2404
|
$result -> statistics['typeFilter'] -> data['enterprise'] -> count = $enterprise['true'] -> count;
|
2405
|
}
|
2406
|
$smallMediumEnterprise = $this -> parseStatistics($xpath, self :: ORGANIZATION_SMALL_MEDIUM_ENTERPRISE);
|
2407
|
if (($smallMediumEnterprise != NULL) && array_key_exists('true', $smallMediumEnterprise)) {
|
2408
|
$result -> statistics['typeFilter'] -> data['smallMediumEnterprise'] = new JObject();
|
2409
|
$result -> statistics['typeFilter'] -> data['smallMediumEnterprise'] -> id = 'smallMediumEnterprise';
|
2410
|
$result -> statistics['typeFilter'] -> data['smallMediumEnterprise'] -> name = JText :: _('SMALL_MEDIUM_ENTERPRISE');
|
2411
|
$result -> statistics['typeFilter'] -> data['smallMediumEnterprise'] -> count = $smallMediumEnterprise['true'] -> count;
|
2412
|
}
|
2413
|
uasort($result -> statistics['typeFilter'] -> data, function ($row1, $row2) {return $row2 -> count - $row1 -> count;});
|
2414
|
JLog :: add('Advanced search retrieved ' . count($result -> organizations) . ' organizations in ' . (microtime(TRUE) - $time) . ' s (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], countries: [' . implode(', ', $countries) . '], types: [' . implode(', ', $types) . '], country: ' . (($country == NULL) ? 'null' : $country) . ', type: ' . (($type == NULL) ? 'null' : $type) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2415
|
return $result;
|
2416
|
} catch (Exception $e) {
|
2417
|
JLog :: add('Error performing organization advanced search (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], countries: [' . implode(', ', $countries) . '], types: [' . implode(', ', $types) . '], country: ' . (($country == NULL) ? 'null' : $country) . ', type: ' . (($type == NULL) ? 'null' : $type) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2418
|
return NULL;
|
2419
|
}
|
2420
|
}
|
2421
|
|
2422
|
// Perform an advanced search for datasources.
|
2423
|
// $keywords the keywords to search for (array)
|
2424
|
// $fields the fields to match keywords with (array - possible values are NAME, ENGLISH_NAME and SUBJECT)
|
2425
|
// $constraints the constraints to apply to keywords (array - possible values are ALL and ANY)
|
2426
|
// $types the IDs of the datasource types to search for
|
2427
|
// $languages the IDs of the datasource languages to search for
|
2428
|
// $contents the IDs of the contents to search for
|
2429
|
// $compatibilities the IDs of the compatibilities to search for
|
2430
|
// $type the ID of the datasource type to use as filter or NULL for no datasource type filtering
|
2431
|
// $language the ID of the datasource language to use as filter or NULL for no datasource language filtering
|
2432
|
// $content the ID of the content to use as filter or NULL for no content filtering
|
2433
|
// $compatibility the ID of the compatibility to use as filter or NULL for no compatibility filtering
|
2434
|
// $page the page of results to retrieve
|
2435
|
// $size the size of the page of results to retrieve
|
2436
|
// $locale the locale to use
|
2437
|
// return a result (object) containing datasources and statistics
|
2438
|
private function _advancedSearchDatasources($keywords, $fields, $constraints, $types, $languages, $contents, $compatibilities, $type, $language, $content, $compatibility, $page, $size, $locale) {
|
2439
|
try {
|
2440
|
$time = microtime(TRUE);
|
2441
|
$query = self :: DATASOURCE_QUERY;
|
2442
|
for ($i = 0; ($i < count($keywords)) && ($i < count($fields)) && ($i < count($constraints)); $i++) {
|
2443
|
$tokens = preg_split('/\s/', $keywords[$i], NULL, PREG_SPLIT_NO_EMPTY);
|
2444
|
switch ($constraints[$i]) {
|
2445
|
case OpenAireViewAdvancedSearchDatasources :: ALL:
|
2446
|
$operator = ' and ';
|
2447
|
break;
|
2448
|
case OpenAireViewAdvancedSearchDatasources :: ANY:
|
2449
|
$operator = ' or ';
|
2450
|
break;
|
2451
|
default:
|
2452
|
$operator = NULL;
|
2453
|
}
|
2454
|
switch ($fields[$i]) {
|
2455
|
case OpenAireViewAdvancedSearchDatasources :: NAME:
|
2456
|
$field = self :: DATASOURCE_NAME;
|
2457
|
break;
|
2458
|
case OpenAireViewAdvancedSearchDatasources :: ENGLISH_NAME:
|
2459
|
$field = self :: DATASOURCE_ENGLISH_NAME;
|
2460
|
break;
|
2461
|
case OpenAireViewAdvancedSearchDatasources :: SUBJECT:
|
2462
|
$field = self :: DATASOURCE_SUBJECT;
|
2463
|
break;
|
2464
|
default:
|
2465
|
$field = NULL;
|
2466
|
}
|
2467
|
$query .= ($tokens == NULL) ? '' : (' and (' . implode($operator, array_map(function ($keyword) use ($field) {return '(' . (($field == NULL) ? '' : ($field . ' = ')) . '"' . str_replace('"', '\\"', $keyword) . '")';}, $tokens)) . ')');
|
2468
|
}
|
2469
|
$field = self :: DATASOURCE_TYPE;
|
2470
|
$query .= ($types == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($type) use ($field) {return '(' . $field . ' exact "' . $type . '")';}, $types)) . ')');
|
2471
|
$field = self :: DATASOURCE_LANGUAGE;
|
2472
|
$query .= ($languages == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($language) use ($field) {return '(' . $field . ' exact "' . $language . '")';}, $languages)) . ')');
|
2473
|
$field = self :: DATASOURCE_CONTENT;
|
2474
|
$query .= ($contents == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($content) use ($field) {return '(' . $field . ' exact "' . $content . '")';}, $contents)) . ')');
|
2475
|
$field = self :: DATASOURCE_COMPATIBILITY;
|
2476
|
$query .= ($compatibilities == NULL) ? '' : (' and (' . implode(' or ', array_map(function ($compatibility) use ($field) {return '(' . $field . ' exact "' . $compatibility . '")';}, $compatibilities)) . ')');
|
2477
|
$query .= ($type == NULL) ? '' : (' and (' . self :: DATASOURCE_TYPE . ' exact "' . $type . '")');
|
2478
|
$query .= ($language == NULL) ? '' : (' and (' . self :: DATASOURCE_LANGUAGE . ' exact "' . $language . '")');
|
2479
|
$query .= ($content == NULL) ? '' : (' and (' . self :: DATASOURCE_CONTENT . ' exact "' . $content . '")');
|
2480
|
$query .= ($compatibility == NULL) ? '' : (' and (' . self :: DATASOURCE_COMPATIBILITY . ' exact "' . $compatibility . '")');
|
2481
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2482
|
if (($response = $this -> performGet('search?action=searchNrefine&sTransformer=datasources_openaire&rTransformer=results_openaire_browse&query=' . urlencode($query) . '&page=' . $page . '&size=' . $size . '&fields=' . self :: DATASOURCE_TYPE . '&fields=' . self :: DATASOURCE_LANGUAGE . '&fields=' . self :: DATASOURCE_CONTENT . '&fields=' . self :: DATASOURCE_COMPATIBILITY . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2483
|
throw new Exception('no HTTP response');
|
2484
|
if ($response -> code != self :: HTTP_OK)
|
2485
|
throw new Exception('HTTP response code ' . $response -> code);
|
2486
|
$document = new DOMDocument();
|
2487
|
$document -> recover = TRUE;
|
2488
|
if ($document -> loadXML($response -> body) == FALSE)
|
2489
|
throw new Exception('invalid XML response');
|
2490
|
$xpath = new DOMXPath($document);
|
2491
|
$result = new JObject();
|
2492
|
$result -> totalDatasources = $this -> parseTotalResults($xpath);
|
2493
|
$result -> datasources = $this -> parseDatasources($xpath);
|
2494
|
$result -> statistics = $this -> createStatistics($xpath, array('typeFilter', 'languageFilter', 'contentFilter', 'compatibilityFilter'), array('DATASOURCE_TYPE', 'DATASOURCE_LANGUAGE', 'CONTENT', 'COMPATIBILITY'), array('NO_DATASOURCE_TYPE_STATISTICS_FOUND', 'NO_DATASOURCE_LANGUAGE_STATISTICS_FOUND', 'NO_CONTENT_STATISTICS_FOUND', 'NO_COMPATIBILITY_STATISTICS_FOUND'), array(self :: DATASOURCE_TYPE, self :: DATASOURCE_LANGUAGE, self :: DATASOURCE_CONTENT, self :: DATASOURCE_COMPATIBILITY));
|
2495
|
JLog :: add('Advanced search retrieved ' . count($result -> datasources) . ' datasources in ' . (microtime(TRUE) - $time) . ' s (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], types: [' . implode(', ', $types) . '], languages: [' . implode(', ', $languages) . '], contents: [' . implode(', ', $contents) . '], compatibilities: [' . implode(', ', $compatibilities) . '], type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', content: ' . (($content == NULL) ? 'null' : $content) . ', compatibility: ' . (($compatibility == NULL) ? 'null' : $compatibility) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2496
|
return $result;
|
2497
|
} catch (Exception $e) {
|
2498
|
JLog :: add('Error performing datasource advanced search (keywords: [' . implode(', ', $keywords) . '], fields: [' . implode(', ', $fields) . '], constraints: [' . implode(', ', $constraints) . '], types: [' . implode(', ', $types) . '], languages: [' . implode(', ', $languages) . '], contents: [' . implode(', ', $contents) . '], compatibilities: [' . implode(', ', $compatibilities) . '], type: ' . (($type == NULL) ? 'null' : $type) . ', language: ' . (($language == NULL) ? 'null' : $language) . ', content: ' . (($content == NULL) ? 'null' : $content) . ', compatibility: ' . (($compatibility == NULL) ? 'null' : $compatibility) . ', page: ' . $page . ', size: ' . $size . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2499
|
return NULL;
|
2500
|
}
|
2501
|
}
|
2502
|
|
2503
|
// Retrieve a single publication by identifier.
|
2504
|
// $id the publication identifier
|
2505
|
// $locale the locale to use
|
2506
|
// return a publication (object) or NULL if no such publication exists
|
2507
|
private function _getPublication($id, $locale) {
|
2508
|
try {
|
2509
|
$time = microtime(TRUE);
|
2510
|
$query = self :: PUBLICATION_QUERY . ' and (' . self :: PUBLICATION_ID . ' exact "' . $id . '")';
|
2511
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2512
|
if (($response = $this -> performGet('search?action=search&sTransformer=results_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2513
|
throw new Exception('no HTTP response');
|
2514
|
if ($response -> code != self :: HTTP_OK)
|
2515
|
throw new Exception('HTTP response code ' . $response -> code);
|
2516
|
$document = new DOMDocument();
|
2517
|
$document -> recover = TRUE;
|
2518
|
if ($document -> loadXML($response -> body) == FALSE)
|
2519
|
throw new Exception('invalid XML response');
|
2520
|
$xpath = new DOMXPath($document);
|
2521
|
$publication = $this -> parsePublication($xpath, $locale);
|
2522
|
JLog :: add('Retrieved publication in ' . (microtime(TRUE) - $time) . ' s (id: ' . $id . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2523
|
return $publication;
|
2524
|
} catch (Exception $e) {
|
2525
|
JLog :: add('Error retrieving publication (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2526
|
return NULL;
|
2527
|
}
|
2528
|
}
|
2529
|
// Retrieve results by identifier.
|
2530
|
// $ids the result identifiers
|
2531
|
// $locale the locale to use
|
2532
|
// return a result (object) or NULL if no such result exists
|
2533
|
private function _getResults($ids, $locale) {
|
2534
|
try {
|
2535
|
$time = microtime(TRUE);
|
2536
|
$query = self :: RESULT_QUERY . ' and (';
|
2537
|
$parts = array();
|
2538
|
foreach ($ids as $id){
|
2539
|
$parts[] = ('(' . self :: RESULT_ID . ' exact "' . $id . '")');
|
2540
|
}
|
2541
|
$query .= join(" OR ", $parts);
|
2542
|
$query .= ')';
|
2543
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2544
|
if (($response = $this -> performGet('search?action=search&sTransformer=results_openaire&query=' . urlencode($query) . '&size=10000&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2545
|
throw new Exception('no HTTP response');
|
2546
|
if ($response -> code != self :: HTTP_OK)
|
2547
|
throw new Exception('HTTP response code ' . $response -> code);
|
2548
|
$document = new DOMDocument();
|
2549
|
$document -> recover = TRUE;
|
2550
|
if ($document -> loadXML($response -> body) == FALSE)
|
2551
|
throw new Exception('invalid XML response');
|
2552
|
$xpath = new DOMXPath($document);
|
2553
|
$results = $this -> parseResults($xpath, $locale);
|
2554
|
JLog :: add('Retrieved results in ' . (microtime(TRUE) - $time) . ' s (ids: ' . join(",", $ids) . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2555
|
return $results;
|
2556
|
} catch (Exception $e) {
|
2557
|
JLog :: add('Error retrieving results (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2558
|
return NULL;
|
2559
|
}
|
2560
|
}
|
2561
|
// Retrieve publications by identifier.
|
2562
|
// $ids the publication identifiers
|
2563
|
// $locale the locale to use
|
2564
|
// return a publication (object) or NULL if no such publication exists
|
2565
|
private function _getPublications($ids, $locale) {
|
2566
|
try {
|
2567
|
$time = microtime(TRUE);
|
2568
|
$query = self :: PUBLICATION_QUERY . ' and (';
|
2569
|
$parts = array();
|
2570
|
foreach ($ids as $id){
|
2571
|
$parts[] = '(' . self :: PUBLICATION_ID . ' exact "' . $id . '")';
|
2572
|
}
|
2573
|
$query .= join(" OR ", $parts);
|
2574
|
$query .= ')';
|
2575
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2576
|
if (($response = $this -> performGet('search?action=search&sTransformer=results_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2577
|
throw new Exception('no HTTP response');
|
2578
|
if ($response -> code != self :: HTTP_OK)
|
2579
|
throw new Exception('HTTP response code ' . $response -> code);
|
2580
|
$document = new DOMDocument();
|
2581
|
$document -> recover = TRUE;
|
2582
|
if ($document -> loadXML($response -> body) == FALSE)
|
2583
|
throw new Exception('invalid XML response');
|
2584
|
$xpath = new DOMXPath($document);
|
2585
|
$publications = $this -> parsePublications($xpath, $locale);
|
2586
|
JLog :: add('Retrieved publication in ' . (microtime(TRUE) - $time) . ' s (ids: ' . join(",", $ids) . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2587
|
return $publications;
|
2588
|
} catch (Exception $e) {
|
2589
|
JLog :: add('Error retrieving publication (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2590
|
return NULL;
|
2591
|
}
|
2592
|
}
|
2593
|
|
2594
|
// Retrieve publications by identifier.
|
2595
|
// $ids the publication identifiers
|
2596
|
// $locale the locale to use
|
2597
|
// return a publication (object) or NULL if no such publication exists
|
2598
|
private function _getProjects($ids, $locale) {
|
2599
|
try {
|
2600
|
$time = microtime(TRUE);
|
2601
|
$query = self :: PROJECT_QUERY . ' and (';
|
2602
|
$parts = array();
|
2603
|
foreach ($ids as $id){
|
2604
|
$parts[] = '(' . self :: PROJECT_ID . ' exact "' . $id . '")';
|
2605
|
}
|
2606
|
$query .= join(" OR ", $parts);
|
2607
|
$query .= ')';
|
2608
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2609
|
if (($response = $this -> performGet('search?action=search&sTransformer=projects_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2610
|
throw new Exception('no HTTP response');
|
2611
|
if ($response -> code != self :: HTTP_OK)
|
2612
|
throw new Exception('HTTP response code ' . $response -> code);
|
2613
|
$document = new DOMDocument();
|
2614
|
$document -> recover = TRUE;
|
2615
|
if ($document -> loadXML($response -> body) == FALSE)
|
2616
|
throw new Exception('invalid XML response');
|
2617
|
$xpath = new DOMXPath($document);
|
2618
|
$projects = $this -> parseProjects($xpath, $locale);
|
2619
|
JLog :: add('Retrieved projects in ' . (microtime(TRUE) - $time) . ' s (ids: ' . join(",", $ids) . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2620
|
return $projects;
|
2621
|
} catch (Exception $e) {
|
2622
|
JLog :: add('Error retrieving projects (ids: ' . join(",", $ids) . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2623
|
return NULL;
|
2624
|
}
|
2625
|
}
|
2626
|
|
2627
|
// Retrieve datasets by identifier.
|
2628
|
// $ids the datasets identifiers
|
2629
|
// $locale the locale to use
|
2630
|
// return datasets array of (object) or NULL if no such dataset exists
|
2631
|
private function _getDatasets($ids, $locale) {
|
2632
|
try {
|
2633
|
$time = microtime(TRUE);
|
2634
|
$query = self :: DATASET_QUERY . ' and (';
|
2635
|
$parts = array();
|
2636
|
foreach ($ids as $id){
|
2637
|
$parts[] = '(' . self :: DATASET_ID . ' exact "' . $id . '")';
|
2638
|
}
|
2639
|
$query .= join(" OR ", $parts);
|
2640
|
$query .= ')';
|
2641
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2642
|
if (($response = $this -> performGet('search?action=search&sTransformer=results_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2643
|
throw new Exception('no HTTP response');
|
2644
|
if ($response -> code != self :: HTTP_OK)
|
2645
|
throw new Exception('HTTP response code ' . $response -> code);
|
2646
|
$document = new DOMDocument();
|
2647
|
$document -> recover = TRUE;
|
2648
|
if ($document -> loadXML($response -> body) == FALSE)
|
2649
|
throw new Exception('invalid XML response');
|
2650
|
$xpath = new DOMXPath($document);
|
2651
|
$datasets = $this -> parseDatasets($xpath, $locale);
|
2652
|
JLog :: add('Retrieved publication in ' . (microtime(TRUE) - $time) . ' s (ids: ' . join(",", $ids) . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2653
|
return $datasets;
|
2654
|
} catch (Exception $e) {
|
2655
|
JLog :: add('Error retrieving publication (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2656
|
return NULL;
|
2657
|
}
|
2658
|
}
|
2659
|
// Retrieve a single dataset by identifier.
|
2660
|
// $id the dataset identifier
|
2661
|
// $locale the locale to use
|
2662
|
// return a dataset (object) or NULL if no such dataset exists
|
2663
|
private function _getDataset($id, $locale) {
|
2664
|
try {
|
2665
|
$time = microtime(TRUE);
|
2666
|
$query = self :: DATASET_QUERY . ' and (' . self :: DATASET_ID . ' exact "' . $id . '")';
|
2667
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2668
|
if (($response = $this -> performGet('search?action=search&sTransformer=results_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2669
|
throw new Exception('no HTTP response');
|
2670
|
if ($response -> code != self :: HTTP_OK)
|
2671
|
throw new Exception('HTTP response code ' . $response -> code);
|
2672
|
$document = new DOMDocument();
|
2673
|
$document -> recover = TRUE;
|
2674
|
if ($document -> loadXML($response -> body) == FALSE)
|
2675
|
throw new Exception('invalid XML response');
|
2676
|
$xpath = new DOMXPath($document);
|
2677
|
$dataset = $this -> parseDataset($xpath,$locale);
|
2678
|
JLog :: add('Retrieved dataset in ' . (microtime(TRUE) - $time) . ' s (id: ' . $id . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2679
|
return $dataset;
|
2680
|
} catch (Exception $e) {
|
2681
|
JLog :: add('Error retrieving dataset (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2682
|
return NULL;
|
2683
|
}
|
2684
|
}
|
2685
|
|
2686
|
// Retrieve a single project by identifier.
|
2687
|
// $id the project identifier
|
2688
|
// $locale the locale to use
|
2689
|
// return a project (object) or NULL if no such project exists
|
2690
|
private function _getProject($id, $locale) {
|
2691
|
try {
|
2692
|
$time = microtime(TRUE);
|
2693
|
$query = self :: PROJECT_QUERY . ' and (' . self :: PROJECT_ID . ' exact "' . $id . '")';
|
2694
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2695
|
if (($response = $this -> performGet('search?action=search&sTransformer=projects_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2696
|
throw new Exception('no HTTP response');
|
2697
|
if ($response -> code != self :: HTTP_OK)
|
2698
|
throw new Exception('HTTP response code ' . $response -> code);
|
2699
|
$document = new DOMDocument();
|
2700
|
$document -> recover = TRUE;
|
2701
|
if ($document -> loadXML($response -> body) == FALSE)
|
2702
|
throw new Exception('invalid XML response');
|
2703
|
$xpath = new DOMXPath($document);
|
2704
|
$project = $this -> parseProject($xpath);
|
2705
|
JLog :: add('Retrieved project in ' . (microtime(TRUE) - $time) . ' s (id: ' . $id . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2706
|
return $project;
|
2707
|
} catch (Exception $e) {
|
2708
|
JLog :: add('Error retrieving project (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2709
|
return NULL;
|
2710
|
}
|
2711
|
}
|
2712
|
|
2713
|
// Retrieve a single person by identifier.
|
2714
|
// $id the person identifier
|
2715
|
// $locale the locale to use
|
2716
|
// return a person (object) or NULL if no such person exists
|
2717
|
private function _getPerson($id, $locale) {
|
2718
|
try {
|
2719
|
$time = microtime(TRUE);
|
2720
|
$query = self :: PERSON_QUERY . ' and (' . self :: PERSON_ID . ' exact "' . $id . '")';
|
2721
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2722
|
if (($response = $this -> performGet('search?action=search&sTransformer=persons_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2723
|
throw new Exception('no HTTP response');
|
2724
|
if ($response -> code != self :: HTTP_OK)
|
2725
|
throw new Exception('HTTP response code ' . $response -> code);
|
2726
|
$document = new DOMDocument();
|
2727
|
$document -> recover = TRUE;
|
2728
|
if ($document -> loadXML($response -> body) == FALSE)
|
2729
|
throw new Exception('invalid XML response');
|
2730
|
$xpath = new DOMXPath($document);
|
2731
|
$person = $this -> parsePerson($xpath);
|
2732
|
JLog :: add('Retrieved person in ' . (microtime(TRUE) - $time) . ' s (id: ' . $id . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2733
|
return $person;
|
2734
|
} catch (Exception $e) {
|
2735
|
JLog :: add('Error retrieving person (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2736
|
return NULL;
|
2737
|
}
|
2738
|
}
|
2739
|
|
2740
|
// Retrieve a single organization by identifier.
|
2741
|
// $id the organization identifier
|
2742
|
// $locale the locale to use
|
2743
|
// return an organization (object) or NULL if no such organization exists
|
2744
|
private function _getOrganization($id, $locale) {
|
2745
|
try {
|
2746
|
$time = microtime(TRUE);
|
2747
|
$query = self :: ORGANIZATION_QUERY . ' and (' . self :: ORGANIZATION_ID . ' exact "' . $id . '")';
|
2748
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2749
|
if (($response = $this -> performGet('search?action=search&sTransformer=organizations_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2750
|
throw new Exception('no HTTP response');
|
2751
|
if ($response -> code != self :: HTTP_OK)
|
2752
|
throw new Exception('HTTP response code ' . $response -> code);
|
2753
|
$document = new DOMDocument();
|
2754
|
$document -> recover = TRUE;
|
2755
|
if ($document -> loadXML($response -> body) == FALSE)
|
2756
|
throw new Exception('invalid XML response');
|
2757
|
$xpath = new DOMXPath($document);
|
2758
|
$organization = $this -> parseOrganization($xpath);
|
2759
|
JLog :: add('Retrieved organization in ' . (microtime(TRUE) - $time) . ' s (id: ' . $id . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2760
|
return $organization;
|
2761
|
} catch (Exception $e) {
|
2762
|
JLog :: add('Error retrieving organization (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2763
|
return NULL;
|
2764
|
}
|
2765
|
}
|
2766
|
|
2767
|
// Retrieve the datasources of an organization.
|
2768
|
// $id the organization identifier
|
2769
|
// $size the maximum number of datasources to retrieve
|
2770
|
// $locale the locale to use
|
2771
|
// return a result (object) containing datasources and total
|
2772
|
private function _getOrganizationDatasources($id, $size, $locale) {
|
2773
|
try {
|
2774
|
$time = microtime(TRUE);
|
2775
|
$query = self :: DATASOURCE_QUERY . ' and (' . self :: DATASOURCE_ORGANIZATION . ' exact "' . $id . '")';
|
2776
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2777
|
if (($response = $this -> performGet('search?action=search&sTransformer=datasources_openaire&query=' . urlencode($query) . '&size=' . $size . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2778
|
throw new Exception('no HTTP response');
|
2779
|
if ($response -> code != self :: HTTP_OK)
|
2780
|
throw new Exception('HTTP response code ' . $response -> code);
|
2781
|
$document = new DOMDocument();
|
2782
|
$document -> recover = TRUE;
|
2783
|
if ($document -> loadXML($response -> body) == FALSE)
|
2784
|
throw new Exception('invalid XML response');
|
2785
|
$xpath = new DOMXPath($document);
|
2786
|
$result = new JObject();
|
2787
|
$result -> totalDatasources = $this -> parseTotalResults($xpath);
|
2788
|
$result -> datasources = $this -> parseDatasources($xpath);
|
2789
|
JLog :: add('Retrieved ' . count($result -> datasources) . ' organization datasources in ' . (microtime(TRUE) - $time) . ' s (id: ' . $id . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2790
|
return $result;
|
2791
|
} catch (Exception $e) {
|
2792
|
JLog :: add('Error retrieving organization datasources (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2793
|
return NULL;
|
2794
|
}
|
2795
|
}
|
2796
|
|
2797
|
// Retrieve a single datasource by identifier.
|
2798
|
// $id the datasource identifier
|
2799
|
// $locale the locale to use
|
2800
|
// return a datasource (object) or NULL if no such datasource exists
|
2801
|
private function _getDatasource($id, $locale, $compatibility = false) {
|
2802
|
try {
|
2803
|
$time = microtime(TRUE);
|
2804
|
$datasource_query = $compatibility?self::DATASOURCE_QUERY_COMPATIBILITY:self::DATASOURCE_QUERY;
|
2805
|
$query = $datasource_query . ' and (' . self :: DATASOURCE_ID . ' exact "' . $id . '")';
|
2806
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2807
|
if (($response = $this -> performGet('search?action=search&sTransformer=datasources_openaire&query=' . urlencode($query) . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2808
|
throw new Exception('no HTTP response');
|
2809
|
if ($response -> code != self :: HTTP_OK)
|
2810
|
throw new Exception('HTTP response code ' . $response -> code);
|
2811
|
$document = new DOMDocument();
|
2812
|
$document -> recover = TRUE;
|
2813
|
if ($document -> loadXML($response -> body) == FALSE)
|
2814
|
throw new Exception('invalid XML response');
|
2815
|
$xpath = new DOMXPath($document);
|
2816
|
$datasource = $this -> parseDatasource($xpath);
|
2817
|
JLog :: add('Retrieved datasource in ' . (microtime(TRUE) - $time) . ' s (id: ' . $id . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2818
|
return $datasource;
|
2819
|
} catch (Exception $e) {
|
2820
|
JLog :: add('Error retrieving datasource (id: ' . $id . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2821
|
return NULL;
|
2822
|
}
|
2823
|
}
|
2824
|
|
2825
|
// Retrieve all the OpenAIRE compatible datasources.
|
2826
|
// $locale the locale to use
|
2827
|
// return the datasources (array) or NULL if any errors occur
|
2828
|
private function _getCompatibleDatasources($locale) {
|
2829
|
try {
|
2830
|
$time = microtime(TRUE);
|
2831
|
$query = self :: DATASOURCE_QUERY . ' and (' . self :: DATASOURCE_COMPATIBILITY . ' <> "' . self :: DATASOURCE_COMPATIBILITY_NOT_COMPATIBLE . '")';
|
2832
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2833
|
if (($response = $this -> performGet('search?action=search&sTransformer=datasources_openaire&query=' . urlencode($query) . '&size=1&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2834
|
throw new Exception('no HTTP response');
|
2835
|
if ($response -> code != self :: HTTP_OK)
|
2836
|
throw new Exception('HTTP response code ' . $response -> code);
|
2837
|
$document = new DOMDocument();
|
2838
|
$document -> recover = TRUE;
|
2839
|
if ($document -> loadXML($response -> body) == FALSE)
|
2840
|
throw new Exception('invalid XML response');
|
2841
|
$xpath = new DOMXPath($document);
|
2842
|
$totalDatasources = $this -> parseTotalResults($xpath);
|
2843
|
if ($totalDatasources > 0) {
|
2844
|
if (($response = $this -> performGet('search?action=search&sTransformer=datasources_openaire&query=' . urlencode($query) . '&size=' . $totalDatasources . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2845
|
throw new Exception('no HTTP response');
|
2846
|
if ($response -> code != self :: HTTP_OK)
|
2847
|
throw new Exception('HTTP response code ' . $response -> code);
|
2848
|
$document = new DOMDocument();
|
2849
|
$document -> recover = TRUE;
|
2850
|
if ($document -> loadXML($response -> body) == FALSE)
|
2851
|
throw new Exception('invalid XML response');
|
2852
|
$xpath = new DOMXPath($document);
|
2853
|
$datasources = $this -> parseDatasources($xpath);
|
2854
|
} else
|
2855
|
$datasources = array();
|
2856
|
JLog :: add('Retrieved ' . count($datasources) . ' compatible datasources in ' . (microtime(TRUE) - $time) . ' s (locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2857
|
return $datasources;
|
2858
|
} catch (Exception $e) {
|
2859
|
JLog :: add('Error retrieving compatible datasources (locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2860
|
return NULL;
|
2861
|
}
|
2862
|
}
|
2863
|
|
2864
|
// Perform a quick search for projects, searching only by acronym, title or code and funder.
|
2865
|
// $keyword the keyword to search for
|
2866
|
// $funder the funder to search for
|
2867
|
// $limit the maximum number of results to retrieve
|
2868
|
// $locale the locale to use
|
2869
|
// return projects (array) or NULL if any errors occur
|
2870
|
private function _quickSearchProjects($keyword, $funder, $limit, $locale) {
|
2871
|
try {
|
2872
|
$time = microtime(TRUE);
|
2873
|
$query = self :: PROJECT_QUERY . ' and ((' . self :: PROJECT_TITLE . ' = "' . $keyword . '") or (' . self :: PROJECT_ACRONYM . ' = "' . $keyword . '") or (' . self :: PROJECT_CODE . ' = "' . $keyword . '")) and (' . self :: PROJECT_FUNDER . ' exact ' . $funder . ')';
|
2874
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2875
|
if (($response = $this -> performGet('search?action=search&sTransformer=projects_openaire&query=' . urlencode($query) . '&size=' . $limit . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2876
|
throw new Exception('no HTTP response');
|
2877
|
if ($response -> code != self :: HTTP_OK)
|
2878
|
throw new Exception('HTTP response code ' . $response -> code);
|
2879
|
$document = new DOMDocument();
|
2880
|
$document -> recover = TRUE;
|
2881
|
if ($document -> loadXML($response -> body) == FALSE)
|
2882
|
throw new Exception('invalid XML response');
|
2883
|
$xpath = new DOMXPath($document);
|
2884
|
$projects = $this -> parseProjects($xpath);
|
2885
|
JLog :: add('Retrieved ' . count($projects) . ' projects in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', funder: ' . $funder . ', limit: ' . $limit . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2886
|
return $projects;
|
2887
|
} catch (Exception $e) {
|
2888
|
JLog :: add('Error retrieving projects (keyword: ' . $keyword . ', funder: ' . $funder . ', limit: ' . $limit . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2889
|
return NULL;
|
2890
|
}
|
2891
|
}
|
2892
|
|
2893
|
// Perform a quick search for organizations, searching only by name or short name.
|
2894
|
// $keyword the keyword to search for
|
2895
|
// $limit the maximum number of results to retrieve
|
2896
|
// $locale the locale to use
|
2897
|
// return organizations (array) or NULL if any errors occur
|
2898
|
private function _quickSearchOrganizations($keyword, $limit, $locale) {
|
2899
|
try {
|
2900
|
$time = microtime(TRUE);
|
2901
|
$query = self :: ORGANIZATION_QUERY . ' and ((' . self :: ORGANIZATION_NAME . ' all "' . $keyword . '") or (' . self :: ORGANIZATION_SHORT_NAME . ' all "' . $keyword . '"))';
|
2902
|
JLog :: add('Generated query is \'' . $query . '\'', JLog :: INFO, self :: LOG);
|
2903
|
if (($response = $this -> performGet('search?action=search&sTransformer=organizations_openaire&query=' . urlencode($query) . '&size=' . $limit . '&locale=' . str_replace('-', '_', $locale))) == NULL)
|
2904
|
throw new Exception('no HTTP response');
|
2905
|
if ($response -> code != self :: HTTP_OK)
|
2906
|
throw new Exception('HTTP response code ' . $response -> code);
|
2907
|
$document = new DOMDocument();
|
2908
|
$document -> recover = TRUE;
|
2909
|
if ($document -> loadXML($response -> body) == FALSE)
|
2910
|
throw new Exception('invalid XML response');
|
2911
|
$xpath = new DOMXPath($document);
|
2912
|
$organizations = $this -> parseOrganizations($xpath);
|
2913
|
JLog :: add('Retrieved ' . count($organizations) . ' organizations in ' . (microtime(TRUE) - $time) . ' s (keyword: ' . $keyword . ', limit: ' . $limit . ', locale: ' . $locale . ')', JLog :: INFO, self :: LOG);
|
2914
|
return $organizations;
|
2915
|
} catch (Exception $e) {
|
2916
|
JLog :: add('Error retrieving organizations (keyword: ' . $keyword . ', limit: ' . $limit . ', locale: ' . $locale . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG);
|
2917
|
return NULL;
|
2918
|
}
|
2919
|
}
|
2920
|
|
2921
|
// Perform an HTTP GET request.
|
2922
|
// $request the relative URL to connect to
|
2923
|
// return the HTTP response (object)
|
2924
|
private function performGet($request) {
|
2925
|
$request = $this -> searchService . $request;
|
2926
|
JLog :: add('Requesting ' . $request, JLog :: INFO, self :: LOG);
|
2927
|
$time = microtime(TRUE);
|
2928
|
$response = $this -> http -> get($request);
|
2929
|
JLog :: add('Received response in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG);
|
2930
|
return $response;
|
2931
|
}
|
2932
|
|
2933
|
// Create statistics based on a search service XML response.
|
2934
|
// $xpath the DOMXPath to parse
|
2935
|
// $ids the identifiers of the statistics to create
|
2936
|
// $titles the titles of the statistics to create
|
2937
|
// $errors the error messages of the statistics to create
|
2938
|
// $data the field names of the statistics to create
|
2939
|
// return statistics (array)
|
2940
|
private function createStatistics($xpath, $ids, $titles, $errors, $data) {
|
2941
|
$statistics = array();
|
2942
|
array_map(function ($id, $title, $error, $data) use ($xpath, &$statistics) {$statistics[$id] = new JObject(); $statistics[$id] -> id = $id; $statistics[$id] -> title = JText :: _($title); $statistics[$id] -> error = JText :: _($error); $statistics[$id] -> data = OpenAireModelSearch :: parseStatistics($xpath, $data);}, $ids, $titles, $errors, $data);
|
2943
|
return $statistics;
|
2944
|
}
|
2945
|
|
2946
|
// Parse statistics from a search service XML response.
|
2947
|
// $xpath the DOMXPath to parse
|
2948
|
// $category the category to retrieve statistics for
|
2949
|
// return statistics (associative array)
|
2950
|
public function parseStatistics($xpath, $category) {
|
2951
|
if ((($browseResultsNodes = $xpath -> query('/response/browseResults')) == FALSE) || (($browseResultsNode = $browseResultsNodes -> item(0)) == NULL))
|
2952
|
throw new Exception('error parsing statistics');
|
2953
|
if (($fieldNodes = $xpath -> query('./result/field[@name = "' . $category . '"]', $browseResultsNode)) == FALSE)
|
2954
|
throw new Exception('error parsing statistics');
|
2955
|
$statistics = array();
|
2956
|
foreach ($fieldNodes as $fieldNode) {
|
2957
|
if ((($idNodes = $xpath -> query('./field[@name = "value"]/@value_original', $fieldNode)) == FALSE) || (($idNode = $idNodes -> item(0)) == NULL))
|
2958
|
throw new Exception('error parsing statistics');
|
2959
|
if ((($nameNodes = $xpath -> query('./field[@name = "value"]/@value', $fieldNode)) == FALSE) || (($nameNode = $nameNodes -> item(0)) == NULL))
|
2960
|
throw new Exception('error parsing statistics');
|
2961
|
if ((($countNodes = $xpath -> query('./field[@name = "count"]/@value', $fieldNode)) == FALSE) || (($countNode = $countNodes -> item(0)) == NULL))
|
2962
|
throw new Exception('error parsing statistics');
|
2963
|
$statistic = new JObject();
|
2964
|
$statistic -> id = trim($idNode -> nodeValue);
|
2965
|
$statistic -> name = trim($nameNode -> nodeValue);
|
2966
|
$statistic -> count = intval(trim($countNode -> nodeValue));
|
2967
|
$statistics[$statistic -> id] = $statistic;
|
2968
|
}
|
2969
|
return $statistics;
|
2970
|
}
|
2971
|
|
2972
|
// Parse total results from a search service XML response.
|
2973
|
// xpath the DOMXPath to parse
|
2974
|
// return total results (integer)
|
2975
|
private function parseTotalResults($xpath) {
|
2976
|
if ((($totalNodes = $xpath -> query('/response/header/total')) == FALSE) || (($totalNode = $totalNodes -> item(0)) == NULL))
|
2977
|
throw new Exception('error parsing total results');
|
2978
|
return intval(trim($totalNode -> nodeValue));
|
2979
|
}
|
2980
|
// Parse publications from a search service XML response.
|
2981
|
// xpath the DOMXPath to parse
|
2982
|
// return results (array)
|
2983
|
private function parseResults($xpath) {
|
2984
|
if (($resultNodes = $xpath -> query('/response/results/result')) == FALSE)
|
2985
|
throw new Exception('error parsing results');
|
2986
|
$publications = array();
|
2987
|
foreach ($resultNodes as $resultNode) {
|
2988
|
if (($idNodes = $xpath -> query('./field[@name = "resultId"]/@value', $resultNode)) == FALSE)
|
2989
|
throw new Exception('error parsing results');
|
2990
|
if (($datasourceNodes = $xpath -> query('./field[@name = "datasource"]', $resultNode)) == FALSE)
|
2991
|
throw new Exception('error parsing publications');
|
2992
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $resultNode)) == FALSE)
|
2993
|
throw new Exception('error parsing results');
|
2994
|
if (($subjectNodes = $xpath -> query('./field[@name = "subject"]', $resultNode)) == FALSE)
|
2995
|
throw new Exception('error parsing results');
|
2996
|
if (($relatedNodes = $xpath -> query('./field[@name = "related"]', $resultNode)) == FALSE)
|
2997
|
throw new Exception('error parsing results');
|
2998
|
if (($authorNodes = $xpath -> query('./field[@name = "author"]', $resultNode)) == FALSE)
|
2999
|
throw new Exception('error parsing results');
|
3000
|
if (($publisherNodes = $xpath -> query('./field[@name = "publisher"]/@value', $resultNode)) == FALSE)
|
3001
|
throw new Exception('error parsing results');
|
3002
|
if (($yearNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $resultNode)) == FALSE)
|
3003
|
throw new Exception('error parsing results');
|
3004
|
if (($languageNodes = $xpath -> query('./field[@name = "language"]/@value', $resultNode)) == FALSE)
|
3005
|
throw new Exception('error parsing results');
|
3006
|
if (($projectNodes = $xpath -> query('./field[@name = "project"]', $resultNode)) == FALSE)
|
3007
|
throw new Exception('error parsing results');
|
3008
|
if (($embargoEndDateNodes = $xpath -> query('./field[@name = "embargoenddate"]/@value', $resultNode)) == FALSE)
|
3009
|
throw new Exception('error parsing results');
|
3010
|
if (($descriptionNodes = $xpath -> query('./field[@name = "description"]/@value', $resultNode)) == FALSE)
|
3011
|
throw new Exception('error parsing results');
|
3012
|
$publication = new JObject();
|
3013
|
$publication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3014
|
$publication -> source = 'openaire';
|
3015
|
$publication -> url = NULL;
|
3016
|
$publication -> accessMode = NULL;
|
3017
|
$publication -> datasources = array();
|
3018
|
$publication -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3019
|
$publication -> authors = array();
|
3020
|
$publication -> publisher = (($publisherNode = $publisherNodes -> item(0)) == NULL) ? NULL : trim($publisherNode -> nodeValue);
|
3021
|
$publication -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
3022
|
$publication -> language = (($languageNode = $languageNodes -> item(0)) == NULL) ? NULL : trim($languageNode -> nodeValue);
|
3023
|
$publication -> projects = array();
|
3024
|
$publication -> subjects = array();
|
3025
|
$publication -> related = array();
|
3026
|
$publication -> embargoEndDate = (($embargoEndDateNode = $embargoEndDateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($embargoEndDateNode -> nodeValue));
|
3027
|
$publication -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue);
|
3028
|
foreach ($subjectNodes as $subjectNode) {
|
3029
|
if (($titleNodes = $xpath -> query('./@value', $subjectNode)) == FALSE)
|
3030
|
throw new Exception('error parsing results');
|
3031
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $subjectNode)) == FALSE)
|
3032
|
throw new Exception('error parsing results');
|
3033
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $subjectNode)) == FALSE)
|
3034
|
throw new Exception('error parsing results');
|
3035
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $subjectNode)) == FALSE)
|
3036
|
throw new Exception('error parsing results');
|
3037
|
$subject = new JObject();
|
3038
|
$subject -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3039
|
$subject -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3040
|
$subject -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3041
|
$subject -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3042
|
if (($subject -> title != NULL) || ($subject -> inferred != NULL) || ($subject -> trust != NULL) || ($subject -> provenance != NULL))
|
3043
|
$publication -> subjects[] = $subject;
|
3044
|
}
|
3045
|
|
3046
|
foreach ($relatedNodes as $relatedNode) {
|
3047
|
|
3048
|
if (($titleNodes = $xpath -> query('./field[@name= "title"]/@value', $relatedNode)) == FALSE)
|
3049
|
throw new Exception('error parsing results');
|
3050
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $relatedNode)) == FALSE)
|
3051
|
throw new Exception('error parsing results');
|
3052
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $relatedNode)) == FALSE)
|
3053
|
throw new Exception('error parsing results');
|
3054
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $relatedNode)) == FALSE)
|
3055
|
throw new Exception('error parsing results');
|
3056
|
$related = new JObject();
|
3057
|
$related -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3058
|
$related -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3059
|
$related -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3060
|
$related -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3061
|
if (($related -> title != NULL) || ($related -> inferred != NULL) || ($related -> trust != NULL) || ($related -> provenance != NULL))
|
3062
|
$publication -> related[] = $related;
|
3063
|
}
|
3064
|
|
3065
|
foreach ($datasourceNodes as $datasourceNode) {
|
3066
|
if (($urlNodes = $xpath -> query('./field[@name = "url"]/@value', $datasourceNode)) == FALSE)
|
3067
|
throw new Exception('error parsing results');
|
3068
|
if (($accessModeNodes = $xpath -> query('./field[@name = "licenceid"]/@value_original', $datasourceNode)) == FALSE)
|
3069
|
throw new Exception('error parsing results');
|
3070
|
$datasource = new JObject();
|
3071
|
$datasource -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
3072
|
$datasource -> accessMode = (($accessModeNode = $accessModeNodes -> item(0)) == NULL) ? NULL : trim($accessModeNode -> nodeValue);
|
3073
|
if (($datasource -> url != NULL) && ((($datasource -> accessMode == self :: DATASOURCE_ACCESS_OPEN) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN))) || (($datasource -> accessMode == self :: UNKNOWN) && ($publication -> accessMode == NULL)) || ((($datasource -> accessMode == NULL) && ($publication -> accessMode == NULL) && ($publication -> url == NULL))))) {
|
3074
|
$publication -> accessMode = $datasource -> accessMode;
|
3075
|
$publication -> url = $datasource -> url;
|
3076
|
}
|
3077
|
if (($datasource -> url != NULL) || ($datasource -> accessMode != NULL))
|
3078
|
$publication -> datasources[] = $datasource;
|
3079
|
}
|
3080
|
foreach ($authorNodes as $authorNode) {
|
3081
|
if (($idNodes = $xpath -> query('./field[@name = "personId"]/@value', $authorNode)) == FALSE)
|
3082
|
throw new Exception('error parsing results');
|
3083
|
if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $authorNode)) == FALSE)
|
3084
|
throw new Exception('error parsing results');
|
3085
|
if (($rankingNodes = $xpath -> query('./field[@name = "ranking"]/@value', $authorNode)) == FALSE)
|
3086
|
throw new Exception('error parsing results');
|
3087
|
$author = new JObject();
|
3088
|
$author -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3089
|
$author -> lastName = NULL;
|
3090
|
$author -> firstName = NULL;
|
3091
|
$author -> fullName = (($fullNameNode = $fullNameNodes -> item(0)) == NULL) ? NULL : trim($fullNameNode -> nodeValue);
|
3092
|
$author -> ranking = (($rankingNode = $rankingNodes -> item(0)) == NULL) ? 0 : intval(trim($rankingNode -> nodeValue));
|
3093
|
if (($author -> id != NULL) || ($author -> lastName != NULL) || ($author -> firstName != NULL) || ($author -> fullName != NULL))
|
3094
|
$publication -> authors[] = $author;
|
3095
|
usort($publication -> authors, function ($author1, $author2) {return $author1 -> ranking - $author2 -> ranking;});
|
3096
|
}
|
3097
|
foreach ($projectNodes as $projectNode) {
|
3098
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $projectNode)) == FALSE)
|
3099
|
throw new Exception('error parsing results');
|
3100
|
if (($acronymNodes = $xpath -> query('./field[@name = "projectacronym"]/@value', $projectNode)) == FALSE)
|
3101
|
throw new Exception('error parsing results');
|
3102
|
if (($titleNodes = $xpath -> query('./field[@name = "projecttitle"]/@value', $projectNode)) == FALSE)
|
3103
|
throw new Exception('error parsing results');
|
3104
|
if (($codeNodes = $xpath -> query('./field[@name = "projectcode"]/@value', $projectNode)) == FALSE)
|
3105
|
throw new Exception('error parsing results');
|
3106
|
$project = new JObject();
|
3107
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3108
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
3109
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3110
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
3111
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL))
|
3112
|
$publication -> projects[] = $project;
|
3113
|
}
|
3114
|
if (($publication -> id != NULL) || ($publication -> source != NULL) || ($publication -> url != NULL) || ($publication -> accessMode != NULL) || ($publication -> datasources != NULL) || ($publication -> title != NULL) || ($publication -> authors != NULL) || ($publication -> publisher != NULL) || ($publication -> year != NULL) || ($publication -> language != NULL) || ($publication -> projects != NULL) || ($publication -> embargoEndDate != NULL) || ($publication -> description != NULL))
|
3115
|
$publications[] = $publication;
|
3116
|
}
|
3117
|
return $publications;
|
3118
|
}
|
3119
|
// Parse publications from a search service XML response.
|
3120
|
// xpath the DOMXPath to parse
|
3121
|
// return publications (array)
|
3122
|
private function parsePublications($xpath) {
|
3123
|
if (($resultNodes = $xpath -> query('/response/results/result')) == FALSE)
|
3124
|
throw new Exception('error parsing publications');
|
3125
|
$publications = array();
|
3126
|
foreach ($resultNodes as $resultNode) {
|
3127
|
if (($idNodes = $xpath -> query('./field[@name = "resultId"]/@value', $resultNode)) == FALSE)
|
3128
|
throw new Exception('error parsing publications');
|
3129
|
if (($datasourceNodes = $xpath -> query('./field[@name = "datasource"]', $resultNode)) == FALSE)
|
3130
|
throw new Exception('error parsing publications');
|
3131
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $resultNode)) == FALSE)
|
3132
|
throw new Exception('error parsing publications');
|
3133
|
if (($subjectNodes = $xpath -> query('./field[@name = "subject"]', $resultNode)) == FALSE)
|
3134
|
throw new Exception('error parsing publications');
|
3135
|
if (($relatedNodes = $xpath -> query('./field[@name = "related"]', $resultNode)) == FALSE)
|
3136
|
throw new Exception('error parsing publications');
|
3137
|
if (($authorNodes = $xpath -> query('./field[@name = "hasAuthor"]', $resultNode)) == FALSE)
|
3138
|
throw new Exception('error parsing publications');
|
3139
|
if (($publisherNodes = $xpath -> query('./field[@name = "publisher"]/@value', $resultNode)) == FALSE)
|
3140
|
throw new Exception('error parsing publications');
|
3141
|
if (($yearNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $resultNode)) == FALSE)
|
3142
|
throw new Exception('error parsing publications');
|
3143
|
if (($languageNodes = $xpath -> query('./field[@name = "language"]/@value', $resultNode)) == FALSE)
|
3144
|
throw new Exception('error parsing publications');
|
3145
|
if (($projectNodes = $xpath -> query('./field[@name = "project"]', $resultNode)) == FALSE)
|
3146
|
throw new Exception('error parsing publications');
|
3147
|
if (($embargoEndDateNodes = $xpath -> query('./field[@name = "embargoenddate"]/@value', $resultNode)) == FALSE)
|
3148
|
throw new Exception('error parsing publications');
|
3149
|
if (($descriptionNodes = $xpath -> query('./field[@name = "description"]/@value', $resultNode)) == FALSE)
|
3150
|
throw new Exception('error parsing publications');
|
3151
|
$publication = new JObject();
|
3152
|
$publication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3153
|
$publication -> source = 'openaire';
|
3154
|
$publication -> url = NULL;
|
3155
|
$publication -> accessMode = NULL;
|
3156
|
$publication -> datasources = array();
|
3157
|
$publication -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3158
|
$publication -> authors = array();
|
3159
|
$publication -> publisher = (($publisherNode = $publisherNodes -> item(0)) == NULL) ? NULL : trim($publisherNode -> nodeValue);
|
3160
|
$publication -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
3161
|
$publication -> language = (($languageNode = $languageNodes -> item(0)) == NULL) ? NULL : trim($languageNode -> nodeValue);
|
3162
|
$publication -> projects = array();
|
3163
|
$publication -> subjects = array();
|
3164
|
$publication -> related = array();
|
3165
|
$publication -> embargoEndDate = (($embargoEndDateNode = $embargoEndDateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($embargoEndDateNode -> nodeValue));
|
3166
|
$publication -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue);
|
3167
|
foreach ($subjectNodes as $subjectNode) {
|
3168
|
if (($titleNodes = $xpath -> query('./@value', $subjectNode)) == FALSE)
|
3169
|
throw new Exception('error parsing publications');
|
3170
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $subjectNode)) == FALSE)
|
3171
|
throw new Exception('error parsing publications');
|
3172
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $subjectNode)) == FALSE)
|
3173
|
throw new Exception('error parsing publications');
|
3174
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $subjectNode)) == FALSE)
|
3175
|
throw new Exception('error parsing publications');
|
3176
|
$subject = new JObject();
|
3177
|
$subject -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3178
|
$subject -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3179
|
$subject -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3180
|
$subject -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3181
|
if (($subject -> title != NULL) || ($subject -> inferred != NULL) || ($subject -> trust != NULL) || ($subject -> provenance != NULL))
|
3182
|
$publication -> subjects[] = $subject;
|
3183
|
}
|
3184
|
|
3185
|
foreach ($relatedNodes as $relatedNode) {
|
3186
|
|
3187
|
if (($titleNodes = $xpath -> query('./field[@name= "title"]/@value', $relatedNode)) == FALSE)
|
3188
|
throw new Exception('error parsing publications');
|
3189
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $relatedNode)) == FALSE)
|
3190
|
throw new Exception('error parsing publications');
|
3191
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $relatedNode)) == FALSE)
|
3192
|
throw new Exception('error parsing publications');
|
3193
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $relatedNode)) == FALSE)
|
3194
|
throw new Exception('error parsing publications');
|
3195
|
$related = new JObject();
|
3196
|
$related -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3197
|
$related -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3198
|
$related -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3199
|
$related -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3200
|
if (($related -> title != NULL) || ($related -> inferred != NULL) || ($related -> trust != NULL) || ($related -> provenance != NULL))
|
3201
|
$publication -> related[] = $related;
|
3202
|
}
|
3203
|
|
3204
|
foreach ($datasourceNodes as $datasourceNode) {
|
3205
|
if (($urlNodes = $xpath -> query('./field[@name = "url"]/@value', $datasourceNode)) == FALSE)
|
3206
|
throw new Exception('error parsing publications');
|
3207
|
if (($accessModeNodes = $xpath -> query('./field[@name = "licenceid"]/@value_original', $datasourceNode)) == FALSE)
|
3208
|
throw new Exception('error parsing publications');
|
3209
|
$datasource = new JObject();
|
3210
|
$datasource -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
3211
|
$datasource -> accessMode = (($accessModeNode = $accessModeNodes -> item(0)) == NULL) ? NULL : trim($accessModeNode -> nodeValue);
|
3212
|
if (($datasource -> url != NULL) && ((($datasource -> accessMode == self :: DATASOURCE_ACCESS_OPEN) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN))) || (($datasource -> accessMode == self :: UNKNOWN) && ($publication -> accessMode == NULL)) || ((($datasource -> accessMode == NULL) && ($publication -> accessMode == NULL) && ($publication -> url == NULL))))) {
|
3213
|
$publication -> accessMode = $datasource -> accessMode;
|
3214
|
$publication -> url = $datasource -> url;
|
3215
|
}
|
3216
|
if (($datasource -> url != NULL) || ($datasource -> accessMode != NULL))
|
3217
|
$publication -> datasources[] = $datasource;
|
3218
|
}
|
3219
|
foreach ($authorNodes as $authorNode) {
|
3220
|
if (($idNodes = $xpath -> query('./field[@name = "personId"]/@value', $authorNode)) == FALSE)
|
3221
|
throw new Exception('error parsing publications');
|
3222
|
if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $authorNode)) == FALSE)
|
3223
|
throw new Exception('error parsing publications');
|
3224
|
if (($rankingNodes = $xpath -> query('./field[@name = "ranking"]/@value', $authorNode)) == FALSE)
|
3225
|
throw new Exception('error parsing publications');
|
3226
|
$author = new JObject();
|
3227
|
$author -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3228
|
$author -> lastName = NULL;
|
3229
|
$author -> firstName = NULL;
|
3230
|
$author -> fullName = (($fullNameNode = $fullNameNodes -> item(0)) == NULL) ? NULL : trim($fullNameNode -> nodeValue);
|
3231
|
$author -> ranking = (($rankingNode = $rankingNodes -> item(0)) == NULL) ? 0 : intval(trim($rankingNode -> nodeValue));
|
3232
|
if (($author -> id != NULL) || ($author -> lastName != NULL) || ($author -> firstName != NULL) || ($author -> fullName != NULL))
|
3233
|
$publication -> authors[] = $author;
|
3234
|
usort($publication -> authors, function ($author1, $author2) {return $author1 -> ranking - $author2 -> ranking;});
|
3235
|
}
|
3236
|
foreach ($projectNodes as $projectNode) {
|
3237
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $projectNode)) == FALSE)
|
3238
|
throw new Exception('error parsing publications');
|
3239
|
if (($acronymNodes = $xpath -> query('./field[@name = "projectacronym"]/@value', $projectNode)) == FALSE)
|
3240
|
throw new Exception('error parsing publications');
|
3241
|
if (($titleNodes = $xpath -> query('./field[@name = "projecttitle"]/@value', $projectNode)) == FALSE)
|
3242
|
throw new Exception('error parsing publications');
|
3243
|
if (($codeNodes = $xpath -> query('./field[@name = "projectcode"]/@value', $projectNode)) == FALSE)
|
3244
|
throw new Exception('error parsing publications');
|
3245
|
$project = new JObject();
|
3246
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3247
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
3248
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3249
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
3250
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL))
|
3251
|
$publication -> projects[] = $project;
|
3252
|
}
|
3253
|
if (($publication -> id != NULL) || ($publication -> source != NULL) || ($publication -> url != NULL) || ($publication -> accessMode != NULL) || ($publication -> datasources != NULL) || ($publication -> title != NULL) || ($publication -> authors != NULL) || ($publication -> publisher != NULL) || ($publication -> year != NULL) || ($publication -> language != NULL) || ($publication -> projects != NULL) || ($publication -> embargoEndDate != NULL) || ($publication -> description != NULL))
|
3254
|
$publications[] = $publication;
|
3255
|
}
|
3256
|
return $publications;
|
3257
|
}
|
3258
|
|
3259
|
// Parse datasets from a search service XML response.
|
3260
|
// xpath the DOMXPath to parse
|
3261
|
// return datasets (array)
|
3262
|
private function parseDatasets($xpath) {
|
3263
|
if (($resultNodes = $xpath -> query('/response/results/result')) == FALSE)
|
3264
|
throw new Exception('error parsing datasets');
|
3265
|
$datasets = array();
|
3266
|
foreach ($resultNodes as $resultNode) {
|
3267
|
if (($idNodes = $xpath -> query('./field[@name = "resultId"]/@value', $resultNode)) == FALSE)
|
3268
|
throw new Exception('error parsing datasets');
|
3269
|
if (($datasourceNodes = $xpath -> query('./field[@name = "datasource"]', $resultNode)) == FALSE)
|
3270
|
throw new Exception('error parsing datasets');
|
3271
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $resultNode)) == FALSE)
|
3272
|
throw new Exception('error parsing datasets');
|
3273
|
if (($authorNodes = $xpath -> query('./field[@name = "hasAuthor"]', $resultNode)) == FALSE)
|
3274
|
throw new Exception('error parsing datasets');
|
3275
|
if (($publisherNodes = $xpath -> query('./field[@name = "publisher"]/@value', $resultNode)) == FALSE)
|
3276
|
throw new Exception('error parsing datasets');
|
3277
|
if (($yearNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $resultNode)) == FALSE)
|
3278
|
throw new Exception('error parsing datasets');
|
3279
|
if (($languageNodes = $xpath -> query('./field[@name = "language"]/@value', $resultNode)) == FALSE)
|
3280
|
throw new Exception('error parsing datasets');
|
3281
|
if (($projectNodes = $xpath -> query('./field[@name = "project"]', $resultNode)) == FALSE)
|
3282
|
throw new Exception('error parsing datasets');
|
3283
|
if (($embargoEndDateNodes = $xpath -> query('./field[@name = "embargoenddate"]/@value', $resultNode)) == FALSE)
|
3284
|
throw new Exception('error parsing datasets');
|
3285
|
if (($descriptionNodes = $xpath -> query('./field[@name = "description"]/@value', $resultNode)) == FALSE)
|
3286
|
throw new Exception('error parsing datasets');
|
3287
|
$dataset = new JObject();
|
3288
|
$dataset -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3289
|
$dataset -> source = 'openaire';
|
3290
|
$dataset -> url = NULL;
|
3291
|
$dataset -> accessMode = NULL;
|
3292
|
$dataset -> datasources = array();
|
3293
|
$dataset -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3294
|
$dataset -> authors = array();
|
3295
|
$dataset -> publisher = (($publisherNode = $publisherNodes -> item(0)) == NULL) ? NULL : trim($publisherNode -> nodeValue);
|
3296
|
$dataset -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
3297
|
$dataset -> language = (($languageNode = $languageNodes -> item(0)) == NULL) ? NULL : trim($languageNode -> nodeValue);
|
3298
|
$dataset -> projects = array();
|
3299
|
$dataset -> embargoEndDate = (($embargoEndDateNode = $embargoEndDateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($embargoEndDateNode -> nodeValue));
|
3300
|
$dataset -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue);
|
3301
|
foreach ($datasourceNodes as $datasourceNode) {
|
3302
|
if (($urlNodes = $xpath -> query('./field[@name = "url"]/@value', $datasourceNode)) == FALSE)
|
3303
|
throw new Exception('error parsing datasets');
|
3304
|
if (($accessModeNodes = $xpath -> query('./field[@name = "licenceid"]/@value_original', $datasourceNode)) == FALSE)
|
3305
|
throw new Exception('error parsing datasets');
|
3306
|
$datasource = new JObject();
|
3307
|
$datasource -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
3308
|
$datasource -> accessMode = (($accessModeNode = $accessModeNodes -> item(0)) == NULL) ? NULL : trim($accessModeNode -> nodeValue);
|
3309
|
if (($datasource -> url != NULL) && ((($datasource -> accessMode == self :: DATASOURCE_ACCESS_OPEN) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_CLOSED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN))) || (($datasource -> accessMode == self :: UNKNOWN) && ($dataset -> accessMode == NULL)) || ((($datasource -> accessMode == NULL) && ($dataset -> accessMode == NULL) && ($dataset -> url == NULL))))) {
|
3310
|
$dataset -> accessMode = $datasource -> accessMode;
|
3311
|
$dataset -> url = $datasource -> url;
|
3312
|
}
|
3313
|
if (($datasource -> url != NULL) || ($datasource -> accessMode != NULL))
|
3314
|
$dataset -> datasources[] = $datasource;
|
3315
|
}
|
3316
|
foreach ($authorNodes as $authorNode) {
|
3317
|
if (($idNodes = $xpath -> query('./field[@name = "personId"]/@value', $authorNode)) == FALSE)
|
3318
|
throw new Exception('error parsing datasets');
|
3319
|
if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $authorNode)) == FALSE)
|
3320
|
throw new Exception('error parsing datasets');
|
3321
|
if (($rankingNodes = $xpath -> query('./field[@name = "ranking"]/@value', $authorNode)) == FALSE)
|
3322
|
throw new Exception('error parsing datasets');
|
3323
|
$author = new JObject();
|
3324
|
$author -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3325
|
$author -> lastName = NULL;
|
3326
|
$author -> firstName = NULL;
|
3327
|
$author -> fullName = (($fullNameNode = $fullNameNodes -> item(0)) == NULL) ? NULL : trim($fullNameNode -> nodeValue);
|
3328
|
$author -> ranking = (($rankingNode = $rankingNodes -> item(0)) == NULL) ? 0 : intval(trim($rankingNode -> nodeValue));
|
3329
|
if (($author -> id != NULL) || ($author -> lastName != NULL) || ($author -> firstName != NULL) || ($author -> fullName != NULL))
|
3330
|
$dataset -> authors[] = $author;
|
3331
|
usort($dataset -> authors, function ($author1, $author2) {return $author1 -> ranking - $author2 -> ranking;});
|
3332
|
}
|
3333
|
foreach ($projectNodes as $projectNode) {
|
3334
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $projectNode)) == FALSE)
|
3335
|
throw new Exception('error parsing datasets');
|
3336
|
if (($acronymNodes = $xpath -> query('./field[@name = "projectacronym"]/@value', $projectNode)) == FALSE)
|
3337
|
throw new Exception('error parsing datasets');
|
3338
|
if (($titleNodes = $xpath -> query('./field[@name = "projecttitle"]/@value', $projectNode)) == FALSE)
|
3339
|
throw new Exception('error parsing datasets');
|
3340
|
if (($codeNodes = $xpath -> query('./field[@name = "projectcode"]/@value', $projectNode)) == FALSE)
|
3341
|
throw new Exception('error parsing datasets');
|
3342
|
$project = new JObject();
|
3343
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3344
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
3345
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3346
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
3347
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL))
|
3348
|
$dataset -> projects[] = $project;
|
3349
|
}
|
3350
|
if (($dataset -> id != NULL) || ($dataset -> source != NULL) || ($dataset -> url != NULL) || ($dataset -> accessMode != NULL) || ($dataset -> datasources != NULL) || ($dataset -> title != NULL) || ($dataset -> authors != NULL) || ($dataset -> publisher != NULL) || ($dataset -> year != NULL) || ($dataset -> language != NULL) || ($dataset -> projects != NULL) || ($dataset -> embargoEndDate != NULL) || ($dataset -> description != NULL))
|
3351
|
$datasets[] = $dataset;
|
3352
|
}
|
3353
|
return $datasets;
|
3354
|
}
|
3355
|
|
3356
|
// Parse projects from a search service XML response.
|
3357
|
// xpath the DOMXPath to parse
|
3358
|
// return projects (array)
|
3359
|
private function parseProjects($xpath) {
|
3360
|
if (($resultNodes = $xpath -> query('/response/results/result')) == FALSE)
|
3361
|
throw new Exception('error parsing projects');
|
3362
|
$projects = array();
|
3363
|
foreach ($resultNodes as $resultNode) {
|
3364
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $resultNode)) == FALSE)
|
3365
|
throw new Exception('error parsing projects');
|
3366
|
if (($acronymNodes = $xpath -> query('./field[@name = "name"]/@value', $resultNode)) == FALSE)
|
3367
|
throw new Exception('error parsing projects');
|
3368
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $resultNode)) == FALSE)
|
3369
|
throw new Exception('error parsing projects');
|
3370
|
if (($codeNodes = $xpath -> query('./field[@name = "code"]/@value', $resultNode)) == FALSE)
|
3371
|
throw new Exception('error parsing projects');
|
3372
|
if (($sc39Nodes = $xpath -> query('./field[@name = "ec_sc39"]/@value', $resultNode)) == FALSE)
|
3373
|
throw new Exception('error parsing projects');
|
3374
|
if (($funderNodes = $xpath -> query('./field[@name = "funding_level_0"]/field[@name = "fundingname"]/@value', $resultNode)) == FALSE)
|
3375
|
throw new Exception('error parsing projects');
|
3376
|
if (($startYearNodes = $xpath -> query('./field[@name = "startyear"]/@value', $resultNode)) == FALSE)
|
3377
|
throw new Exception('error parsing projects');
|
3378
|
if (($endYearNodes = $xpath -> query('./field[@name = "endyear"]/@value', $resultNode)) == FALSE)
|
3379
|
throw new Exception('error parsing projects');
|
3380
|
if (($organizationNodes = $xpath -> query('./field[@name = "organization"]', $resultNode)) == FALSE)
|
3381
|
throw new Exception('error parsing projects');
|
3382
|
$project = new JObject();
|
3383
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3384
|
$project -> acronym = ((($acronymNode = $acronymNodes -> item(0)) == NULL) || (trim($acronymNode -> nodeValue) == self :: UNKNOWN)) ? NULL : trim($acronymNode -> nodeValue);
|
3385
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3386
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
3387
|
$project -> sc39 = (($sc39Node = $sc39Nodes -> item(0)) == NULL) ? NULL : trim($sc39Node -> nodeValue);
|
3388
|
switch ($project -> sc39) {
|
3389
|
case 'true':
|
3390
|
$project -> sc39 = TRUE;
|
3391
|
break;
|
3392
|
case 'false':
|
3393
|
$project -> sc39 = FALSE;
|
3394
|
break;
|
3395
|
default:
|
3396
|
$project -> sc39 = NULL;
|
3397
|
}
|
3398
|
$project -> funder = (($funderNode = $funderNodes -> item(0)) == NULL) ? NULL : trim($funderNode -> nodeValue);
|
3399
|
$project -> startYear = (($startYearNode = $startYearNodes -> item(0)) == NULL) ? NULL : intval(trim($startYearNode -> nodeValue));
|
3400
|
$project -> endYear = (($endYearNode = $endYearNodes -> item(0)) == NULL) ? NULL : intval(trim($endYearNode -> nodeValue));
|
3401
|
$project -> organizations = array();
|
3402
|
foreach ($organizationNodes as $organizationNode) {
|
3403
|
if (($idNodes = $xpath -> query('./field[@name = "organizationid"]/@value', $organizationNode)) == FALSE)
|
3404
|
throw new Exception('error parsing projects');
|
3405
|
if (($shortNameNodes = $xpath -> query('./field[@name = "legalshortname"]/@value', $organizationNode)) == FALSE)
|
3406
|
throw new Exception('error parsing projects');
|
3407
|
if (($nameNodes = $xpath -> query('./field[@name = "legalname"]/@value', $organizationNode)) == FALSE)
|
3408
|
throw new Exception('error parsing projects');
|
3409
|
$organization = new JObject();
|
3410
|
$organization -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3411
|
$organization -> shortName = (($shortNameNode = $shortNameNodes -> item(0)) == NULL) ? NULL : trim($shortNameNode -> nodeValue);
|
3412
|
$organization -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
3413
|
if (($organization -> id != NULL) || ($organization -> shortName != NULL) || ($organization -> name != NULL))
|
3414
|
$project -> organizations[] = $organization;
|
3415
|
}
|
3416
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL) || ($project -> sc39 != NULL) || ($project -> funder != NULL) || ($project -> startYear != NULL) || ($project -> endYear != NULL) || ($project -> organizations != NULL))
|
3417
|
$projects[] = $project;
|
3418
|
}
|
3419
|
return $projects;
|
3420
|
}
|
3421
|
|
3422
|
// Parse people from a search service XML response.
|
3423
|
// xpath the DOMXPath to parse
|
3424
|
// return people (array)
|
3425
|
private function parsePeople($xpath) {
|
3426
|
if (($resultNodes = $xpath -> query('/response/results/record')) == FALSE)
|
3427
|
throw new Exception('error parsing people');
|
3428
|
$people = array();
|
3429
|
foreach ($resultNodes as $resultNode) {
|
3430
|
if (($idNodes = $xpath -> query('./field[@name = "personId"]/@value', $resultNode)) == FALSE)
|
3431
|
throw new Exception('error parsing people');
|
3432
|
if (($lastNameNodes = $xpath -> query('./field[@name = "secondnames"]/@value', $resultNode)) == FALSE)
|
3433
|
throw new Exception('error parsing people');
|
3434
|
if (($firstNameNodes = $xpath -> query('./field[@name = "firstname"]/@value', $resultNode)) == FALSE)
|
3435
|
throw new Exception('error parsing people');
|
3436
|
if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $resultNode)) == FALSE)
|
3437
|
throw new Exception('error parsing people');
|
3438
|
if (($countryNodes = $xpath -> query('./field[@name = "nationalityid"]/@value', $resultNode)) == FALSE)
|
3439
|
throw new Exception('error parsing people');
|
3440
|
$person = new JObject();
|
3441
|
$person -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3442
|
$person -> lastName = (($lastNameNode = $lastNameNodes -> item(0)) == NULL) ? NULL : trim($lastNameNode -> nodeValue);
|
3443
|
$person -> firstName = (($firstNameNode = $firstNameNodes -> item(0)) == NULL) ? NULL : trim($firstNameNode -> nodeValue);
|
3444
|
$person -> fullName = (($fullNameNode = $fullNameNodes -> item(0)) == NULL) ? NULL : trim($fullNameNode -> nodeValue);
|
3445
|
$person -> country = (($countryNode = $countryNodes -> item(0)) == NULL) ? NULL : trim($countryNode -> nodeValue);
|
3446
|
if (($person -> id != NULL) || ($person -> lastName != NULL) || ($person -> firstName != NULL) || ($person -> fullName != NULL) || ($person -> country != NULL))
|
3447
|
$people[] = $person;
|
3448
|
}
|
3449
|
return $people;
|
3450
|
}
|
3451
|
|
3452
|
// Parse organizations from a search service XML response.
|
3453
|
// xpath the DOMXPath to parse
|
3454
|
// return organizations (array)
|
3455
|
private function parseOrganizations($xpath) {
|
3456
|
if (($resultNodes = $xpath -> query('/response/results/result')) == FALSE)
|
3457
|
throw new Exception('error parsing organizations');
|
3458
|
$organizations = array();
|
3459
|
foreach ($resultNodes as $resultNode) {
|
3460
|
if (($idNodes = $xpath -> query('./field[@name = "organizationId"]/@value', $resultNode)) == FALSE)
|
3461
|
throw new Exception('error parsing organizations');
|
3462
|
if (($shortNameNodes = $xpath -> query('./field[@name = "legalshortname"]/@value', $resultNode)) == FALSE)
|
3463
|
throw new Exception('error parsing organizations');
|
3464
|
if (($nameNodes = $xpath -> query('./field[@name = "legalname"]/@value', $resultNode)) == FALSE)
|
3465
|
throw new Exception('error parsing organizations');
|
3466
|
if (($countryNodes = $xpath -> query('./field[@name = "countryname"]/@value', $resultNode)) == FALSE)
|
3467
|
throw new Exception('error parsing organizations');
|
3468
|
if (($projectNodes = $xpath -> query('./field[@name = "project"]', $resultNode)) == FALSE)
|
3469
|
throw new Exception('error parsing organizations');
|
3470
|
$organization = new JObject();
|
3471
|
$organization -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3472
|
$organization -> shortName = (($shortNameNode = $shortNameNodes -> item(0)) == NULL) ? NULL : trim($shortNameNode -> nodeValue);
|
3473
|
$organization -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
3474
|
$organization -> country = (($countryNode = $countryNodes -> item(0)) == NULL) ? NULL : trim($countryNode -> nodeValue);
|
3475
|
$organization -> projects = array();
|
3476
|
foreach ($projectNodes as $projectNode) {
|
3477
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $projectNode)) == FALSE)
|
3478
|
throw new Exception('error parsing organizations');
|
3479
|
if (($acronymNodes = $xpath -> query('./field[@name = "projectacronym"]/@value', $projectNode)) == FALSE)
|
3480
|
throw new Exception('error parsing organizations');
|
3481
|
if (($titleNodes = $xpath -> query('./field[@name = "projecttitle"]/@value', $projectNode)) == FALSE)
|
3482
|
throw new Exception('error parsing organizations');
|
3483
|
if (($codeNodes = $xpath -> query('./field[@name = "projectcode"]/@value', $projectNode)) == FALSE)
|
3484
|
throw new Exception('error parsing organizations');
|
3485
|
$project = new JObject();
|
3486
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3487
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
3488
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3489
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
3490
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL))
|
3491
|
$organization -> projects[] = $project;
|
3492
|
}
|
3493
|
if (($organization -> id != NULL) || ($organization -> shortName != NULL) || ($organization -> name != NULL) || ($organization -> country != NULL) || ($organization -> projects != NULL))
|
3494
|
$organizations[] = $organization;
|
3495
|
}
|
3496
|
return $organizations;
|
3497
|
}
|
3498
|
|
3499
|
// Parse datasources from a search service XML response.
|
3500
|
// xpath the DOMXPath to parse
|
3501
|
// return datasources (array)
|
3502
|
private function parseDatasources($xpath) {
|
3503
|
if (($resultNodes = $xpath -> query('/response/results/result')) == FALSE)
|
3504
|
throw new Exception('error parsing datasources');
|
3505
|
$datasources = array();
|
3506
|
foreach ($resultNodes as $resultNode) {
|
3507
|
if (($idNodes = $xpath -> query('./field[@name = "datasourceId"]/@value', $resultNode)) == FALSE)
|
3508
|
throw new Exception('error parsing datasources');
|
3509
|
if (($typeNodes = $xpath -> query('./field[@name = "datasourcetypeuiid"]/@value', $resultNode)) == FALSE)
|
3510
|
throw new Exception('error parsing datasources');
|
3511
|
if (($typeIdNodes = $xpath -> query('./field[@name = "datasourcetypeuiid"]/@value_original', $resultNode)) == FALSE)
|
3512
|
throw new Exception('error parsing datasources');
|
3513
|
if (($compatibilityNodes = $xpath -> query('./field[@name = "openairecompatibilityid"]/@value', $resultNode)) == FALSE)
|
3514
|
throw new Exception('error parsing datasources');
|
3515
|
if (($urlNodes = $xpath -> query('./field[@name = "websiteurl"]/@value', $resultNode)) == FALSE)
|
3516
|
throw new Exception('error parsing datasources');
|
3517
|
if (($nameNodes = $xpath -> query('./field[@name = "officialname"]/@value', $resultNode)) == FALSE)
|
3518
|
throw new Exception('error parsing datasources');
|
3519
|
if (($englishNameNodes = $xpath -> query('./field[@name = "englishname"]/@value', $resultNode)) == FALSE)
|
3520
|
throw new Exception('error parsing datasources');
|
3521
|
if (($itemsNodes = $xpath -> query('./field[@name = "odnumberofitems"]/@value', $resultNode)) == FALSE)
|
3522
|
throw new Exception('error parsing datasources');
|
3523
|
if (($dateNodes = $xpath -> query('./field[@name = "odnumberofitemsdate"]/@value', $resultNode)) == FALSE)
|
3524
|
throw new Exception('error parsing datasources');
|
3525
|
if (($languageNodes = $xpath -> query('./field[@name = "odlanguages"]/@value', $resultNode)) == FALSE)
|
3526
|
throw new Exception('error parsing datasources');
|
3527
|
if (($policyNodes = $xpath -> query('./field[@name = "odpolicies"]/@value', $resultNode)) == FALSE)
|
3528
|
throw new Exception('error parsing datasources');
|
3529
|
if (($contentNodes = $xpath -> query('./field[@name = "odcontenttypes"]/@value', $resultNode)) == FALSE)
|
3530
|
throw new Exception('error parsing datasources');
|
3531
|
if (($oaiPmhNodes = $xpath -> query('./field[@name = "accessinfopackage"]/@value', $resultNode)) == FALSE)
|
3532
|
throw new Exception('error parsing datasources');
|
3533
|
if (($descriptionNodes = $xpath -> query('./field[@name = "oddescription"]/@value', $resultNode)) == FALSE)
|
3534
|
throw new Exception('error parsing datasources');
|
3535
|
if (($organizationNodes = $xpath -> query('./field[@name = "organization"]', $resultNode)) == FALSE)
|
3536
|
throw new Exception('error parsing datasources');
|
3537
|
$datasource = new JObject();
|
3538
|
$datasource -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3539
|
$datasource -> type = (($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue);
|
3540
|
$datasource -> typeId = (($typeIdNode = $typeIdNodes -> item(0)) == NULL) ? NULL : trim($typeIdNode -> nodeValue);
|
3541
|
$datasource -> compatibility = (($compatibilityNode = $compatibilityNodes -> item(0)) == NULL) ? NULL : trim($compatibilityNode -> nodeValue);
|
3542
|
$datasource -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
3543
|
$datasource -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
3544
|
$datasource -> englishName = (($englishNameNode = $englishNameNodes -> item(0)) == NULL) ? NULL : trim($englishNameNode -> nodeValue);
|
3545
|
$datasource -> items = (($itemsNode = $itemsNodes -> item(0)) == NULL) ? NULL : intval(trim($itemsNode -> nodeValue));
|
3546
|
$datasource -> date = (($dateNode = $dateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($dateNode -> nodeValue));
|
3547
|
$datasource -> languages = array();
|
3548
|
$datasource -> policies = array();
|
3549
|
$datasource -> contents = array();
|
3550
|
$datasource -> oaiPmhUrls = array();
|
3551
|
$datasource -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue);
|
3552
|
$datasource -> organizations = array();
|
3553
|
foreach ($languageNodes as $languageNode) {
|
3554
|
if (trim($languageNode -> nodeValue) != NULL)
|
3555
|
$datasource -> languages[] = trim($languageNode -> nodeValue);
|
3556
|
}
|
3557
|
foreach ($policyNodes as $policyNode) {
|
3558
|
if (trim($policyNode -> nodeValue) != NULL)
|
3559
|
$datasource -> policies[] = trim($policyNode -> nodeValue);
|
3560
|
}
|
3561
|
foreach ($contentNodes as $contentNode) {
|
3562
|
if (trim($contentNode -> nodeValue) != NULL)
|
3563
|
$datasource -> contents[] = trim($contentNode -> nodeValue);
|
3564
|
}
|
3565
|
foreach ($oaiPmhNodes as $oaiPmhNode) {
|
3566
|
if (trim($oaiPmhNode -> nodeValue) != NULL)
|
3567
|
$datasource -> oaiPmhUrls[] = trim($oaiPmhNode -> nodeValue);
|
3568
|
}
|
3569
|
foreach ($organizationNodes as $organizationNode) {
|
3570
|
if (($idNodes = $xpath -> query('./field[@name = "organizationid"]/@value', $organizationNode)) == FALSE)
|
3571
|
throw new Exception('error parsing datasources');
|
3572
|
if (($shortNameNodes = $xpath -> query('./field[@name = "legalname"]/@value', $organizationNode)) == FALSE)
|
3573
|
throw new Exception('error parsing datasources');
|
3574
|
if (($nameNodes = $xpath -> query('./field[@name = "legalshortname"]/@value', $organizationNode)) == FALSE)
|
3575
|
throw new Exception('error parsing datasources');
|
3576
|
if (($countryNodes = $xpath -> query('./field[@name = "countryname"]/@value', $organizationNode)) == FALSE)
|
3577
|
throw new Exception('error parsing datasources');
|
3578
|
$organization = new JObject();
|
3579
|
$organization -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3580
|
$organization -> shortName = (($shortNameNode = $shortNameNodes -> item(0)) == NULL) ? NULL : trim($shortNameNode -> nodeValue);
|
3581
|
$organization -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
3582
|
$organization -> country = (($countryNode = $countryNodes -> item(0)) == NULL) ? NULL : trim($countryNode -> nodeValue);
|
3583
|
if (($organization -> id != NULL) || ($organization -> shortName != NULL) || ($organization -> name != NULL) || ($organization -> country != NULL))
|
3584
|
$datasource -> organizations[] = $organization;
|
3585
|
}
|
3586
|
if (($datasource -> id != NULL) || ($datasource -> type != NULL) || ($datasource -> compatibility != NULL) || ($datasource -> url != NULL) || ($datasource -> name != NULL) || ($datasource -> englishName != NULL) || ($datasource -> items != NULL) || ($datasource -> date != NULL) || ($datsource -> languages != NULL) || ($datasource -> policies != NULL) || ($datasource -> contents != NULL) || ($datasource -> oaiPmhUrls != NULL) || ($datasource -> description != NULL) || ($datasource -> organizations != NULL))
|
3587
|
$datasources[] = $datasource;
|
3588
|
}
|
3589
|
return $datasources;
|
3590
|
}
|
3591
|
|
3592
|
// Parse a single publication from a search service XML response.
|
3593
|
// xpath the DOMXPath to parse
|
3594
|
// return publication (object)
|
3595
|
private function parsePublication($xpath,$locale) {
|
3596
|
if ((($resultsNodes = $xpath -> query('/response/results/result')) == FALSE) || (($resultNode = $resultsNodes -> item(0)) == NULL)) // result
|
3597
|
throw new Exception('error parsing publication');
|
3598
|
if (($idNodes = $xpath -> query('./field[@name = "resultId"]/@value', $resultNode)) == FALSE)
|
3599
|
throw new Exception('error parsing publication');
|
3600
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $resultNode)) == FALSE)
|
3601
|
throw new Exception('error parsing publication');
|
3602
|
if (($authorNodes = $xpath -> query('./field[@name = "hasAuthor"]', $resultNode)) == FALSE)
|
3603
|
throw new Exception('error parsing publication');
|
3604
|
if (($dateNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $resultNode)) == FALSE)
|
3605
|
throw new Exception('error parsing publication');
|
3606
|
if (($publisherNodes = $xpath -> query('./field[@name = "publisher"]/@value', $resultNode)) == FALSE)
|
3607
|
throw new Exception('error parsing publication');
|
3608
|
if (($languageNodes = $xpath -> query('./field[@name = "language"]/@value', $resultNode)) == FALSE)
|
3609
|
throw new Exception('error parsing publication');
|
3610
|
if (($typeNodes = $xpath -> query('./field[@name ="resulttypename"]/@value', $resultNode)) == FALSE)
|
3611
|
throw new Exception('error parsing publication');
|
3612
|
if (($subjectNodes = $xpath -> query('./field[@name = "subject" and field[@name="inferred" and @value="false"]]', $resultNode)) == FALSE)
|
3613
|
throw new Exception('error parsing publication');
|
3614
|
if (($inferredSubjectNodes = $xpath -> query('./field[@name = "subject" and field[@name="inferred" and @value="true"]]', $resultNode)) == FALSE)
|
3615
|
throw new Exception('error parsing publication');
|
3616
|
if (($embargoEndDateNodes = $xpath -> query('./field[@name = "embargoenddate"]/@value', $resultNode)) == FALSE)
|
3617
|
throw new Exception('error parsing publication');
|
3618
|
if (($descriptionNodes = $xpath -> query('./field[@name = "description"]/@value', $resultNode)) == FALSE)
|
3619
|
throw new Exception('error parsing publication');
|
3620
|
if (($datasourceNodes = $xpath -> query('./field[@name = "datasource"]', $resultNode)) == FALSE)
|
3621
|
throw new Exception('error parsing publication');
|
3622
|
if (($collectedFromNodes = $xpath -> query('./field[@name = "collectedfrom"]', $resultNode)) == FALSE)
|
3623
|
throw new Exception('error parsing publication');
|
3624
|
if (($sourceNodes = $xpath -> query('./field[@name = "source"]/@value', $resultNode)) == FALSE)
|
3625
|
throw new Exception('error parsing publication');
|
3626
|
if (($projectNodes = $xpath -> query('./field[@name = "project"]', $resultNode)) == FALSE)
|
3627
|
throw new Exception('error parsing publication');
|
3628
|
if (($pidNodes = $xpath -> query('./field[@name = "pid"]', $resultNode)) == FALSE)
|
3629
|
throw new Exception('error parsing publication');
|
3630
|
if (($similarNodes = $xpath -> query('./field[@name = "hasAmongTopNSimilarDocuments"]', $resultNode)) == FALSE)
|
3631
|
throw new Exception('error parsing publication');
|
3632
|
if (($relatedNodes = $xpath -> query('./field[@name = "isRelatedTo"]', $resultNode)) == FALSE)
|
3633
|
throw new Exception('error parsing publication');
|
3634
|
if (($externalReferenceNodes = $xpath -> query('./field[@name = "externalreference"]', $resultNode)) == FALSE)
|
3635
|
throw new Exception('error parsing publication');
|
3636
|
if (($contextNodes = $xpath -> query('./field[@name = "context"]', $resultNode)) == FALSE)
|
3637
|
throw new Exception('error parsing publication');
|
3638
|
if (($citationNodes = $xpath -> query('./field[@name = "citation"]', $resultNode)) == FALSE)
|
3639
|
throw new Exception('error parsing publication');
|
3640
|
$publication = new JObject();
|
3641
|
$publication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3642
|
$publication -> source = 'openaire';
|
3643
|
$publication -> accessMode = NULL;
|
3644
|
$publication -> url = NULL;
|
3645
|
$publication -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3646
|
$publication -> authors = array();
|
3647
|
$publication -> year = (($dateNode = $dateNodes -> item(0)) == NULL) ? NULL : intval(trim($dateNode -> nodeValue));
|
3648
|
$publication -> date = ($dateNode == NULL) ? NULL : strtotime(trim($dateNode -> nodeValue));
|
3649
|
$publication -> publisher = (($publisherNode = $publisherNodes -> item(0)) == NULL) ? NULL : trim($publisherNode -> nodeValue);
|
3650
|
$publication -> languages = array();
|
3651
|
$publication -> type = array();
|
3652
|
$publication -> subjects = array();
|
3653
|
$publication -> inferredSubjects = array();
|
3654
|
$publication -> embargoEndDate = (($embargoEndDateNode = $embargoEndDateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($embargoEndDateNode -> nodeValue));
|
3655
|
$publication -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue);
|
3656
|
$publication -> datasources = array();
|
3657
|
$publication -> collectedFrom = array();
|
3658
|
$publication -> sources = array();
|
3659
|
$publication -> projects = array();
|
3660
|
$publication -> pids = array();
|
3661
|
$publication -> similarPublications = array();
|
3662
|
$publication -> relatedPublications = array();
|
3663
|
$publication -> relatedDatasets = array();
|
3664
|
$publication -> externalPublications = array();
|
3665
|
$publication -> externalDatasets = array();
|
3666
|
$publication -> contexts = array();
|
3667
|
$publication -> citations = array();
|
3668
|
foreach ($authorNodes as $authorNode) {
|
3669
|
if (($idNodes = $xpath -> query('./field[@name = "personId"]/@value', $authorNode)) == FALSE)
|
3670
|
throw new Exception('error parsing publication');
|
3671
|
if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $authorNode)) == FALSE)
|
3672
|
throw new Exception('error parsing publication');
|
3673
|
if (($rankingNodes = $xpath -> query('./field[@name = "ranking"]/@value', $authorNode)) == FALSE)
|
3674
|
throw new Exception('error parsing publication');
|
3675
|
$author = new JObject();
|
3676
|
$author -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3677
|
$author -> lastName = NULL;
|
3678
|
$author -> firstName = NULL;
|
3679
|
$author -> fullName = (($fullNameNode = $fullNameNodes -> item(0)) == NULL) ? NULL : trim($fullNameNode -> nodeValue);
|
3680
|
$author -> ranking = (($rankingNode = $rankingNodes -> item(0)) == NULL) ? 0 : intval(trim($rankingNode -> nodeValue));
|
3681
|
if (($author -> id != NULL) || ($author -> lastName != NULL) || ($author -> firstName != NULL) || ($author -> fullName != NULL))
|
3682
|
$publication -> authors[] = $author;
|
3683
|
usort($publication -> authors, function ($author1, $author2) {return $author1 -> ranking - $author2 -> ranking;});
|
3684
|
}
|
3685
|
foreach ($languageNodes as $languageNode) {
|
3686
|
if ((($language = trim($languageNode -> nodeValue)) != NULL) && ($language != self :: UNDETERMINED))
|
3687
|
$publication -> languages[] = $language;
|
3688
|
}
|
3689
|
foreach ($subjectNodes as $subjectNode) {
|
3690
|
if (($titleNodes = $xpath -> query('./@value', $subjectNode)) == FALSE)
|
3691
|
throw new Exception('error parsing publications');
|
3692
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $subjectNode)) == FALSE)
|
3693
|
throw new Exception('error parsing publications');
|
3694
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $subjectNode)) == FALSE)
|
3695
|
throw new Exception('error parsing publications');
|
3696
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $subjectNode)) == FALSE)
|
3697
|
throw new Exception('error parsing publications');
|
3698
|
$subject = new JObject();
|
3699
|
$subject -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3700
|
$subject -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3701
|
$subject -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3702
|
$subject -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3703
|
if (($subject -> title != NULL) || ($subject -> inferred != NULL) || ($subject -> trust != NULL) || ($subject -> provenance != NULL))
|
3704
|
$publication -> subjects[] = $subject;
|
3705
|
}
|
3706
|
$inferredSubjectsTempArray=array();
|
3707
|
foreach ($inferredSubjectNodes as $subjectNode) {
|
3708
|
if (($titleNodes = $xpath -> query('./@value', $subjectNode)) == FALSE)
|
3709
|
throw new Exception('error parsing publications');
|
3710
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $subjectNode)) == FALSE)
|
3711
|
throw new Exception('error parsing publications');
|
3712
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $subjectNode)) == FALSE)
|
3713
|
throw new Exception('error parsing publications');
|
3714
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $subjectNode)) == FALSE)
|
3715
|
throw new Exception('error parsing publications');
|
3716
|
if (($taxonomyNodes = $xpath -> query('./field[@name = "taxonomy"]/@value', $subjectNode)) == FALSE)
|
3717
|
throw new Exception('error parsing publications');
|
3718
|
|
3719
|
$subject = new JObject();
|
3720
|
$subject -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3721
|
$subject -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3722
|
$subject -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3723
|
$subject -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3724
|
$subject -> taxonomy = (($taxonomyNode = $taxonomyNodes -> item(0)) == NULL) ? NULL : trim($taxonomyNode -> nodeValue);
|
3725
|
|
3726
|
if (($subject -> title != NULL) || ($subject -> inferred != NULL) || ($subject -> trust != NULL) || ($subject -> provenance != NULL)|| ($subject -> taxonomy != NULL)){
|
3727
|
$miniSubject=new JObject();
|
3728
|
$miniSubject->title=$subject->title;
|
3729
|
$miniSubject->trust=$subject->trust;
|
3730
|
$inferredSubjectsTempArray[$subject -> taxonomy][]= $miniSubject;
|
3731
|
}
|
3732
|
}
|
3733
|
//Sort the subjects on trust
|
3734
|
foreach($inferredSubjectsTempArray as $taxonomyKey => $subjectsValues){
|
3735
|
usort($subjectsValues, function ($a, $b) {if ($a->trust == $b->trust) {return 0;}return ($a->trust > $b->trust) ? -1 : 1;});
|
3736
|
$publication -> inferredSubjects[$taxonomyKey]=$subjectsValues;
|
3737
|
}
|
3738
|
|
3739
|
foreach ($datasourceNodes as $datasourceNode) {
|
3740
|
if (($idNodes = $xpath -> query('./field[@name = "hostedby"]/@value_original', $datasourceNode)) == FALSE)
|
3741
|
throw new Exception('error parsing publication');
|
3742
|
if (($nameNodes = $xpath -> query('./field[@name = "hostedby"]/@value', $datasourceNode)) == FALSE)
|
3743
|
throw new Exception('error parsing publication');
|
3744
|
if (($urlNodes = $xpath -> query('./field[@name = "url"]/@value', $datasourceNode)) == FALSE)
|
3745
|
throw new Exception('error parsing publication');
|
3746
|
if (($accessModeNodes = $xpath -> query('./field[@name = "licenceid"]/@value_original', $datasourceNode)) == FALSE)
|
3747
|
throw new Exception('error parsing publication');
|
3748
|
if (($typeNameNodes = $xpath -> query('./field[@name = "typename"]/@value', $datasourceNode)) == FALSE)
|
3749
|
throw new Exception('error parsing publication');
|
3750
|
$datasource = new JObject();
|
3751
|
$datasource -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3752
|
$datasource -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
3753
|
$datasource -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
3754
|
$datasource -> accessMode = (($accessModeNode = $accessModeNodes -> item(0)) == NULL) ? NULL : trim($accessModeNode -> nodeValue);
|
3755
|
$datasource -> type = (($typeNameNode = $typeNameNodes -> item(0)) == NULL) ? NULL : trim($typeNameNode -> nodeValue);
|
3756
|
|
3757
|
if (($datasource -> url != NULL) && ((($datasource -> accessMode == self :: DATASOURCE_ACCESS_OPEN) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN) || ($publication -> accessMode == self :: DATASOURCE_ACCESS_CLOSED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) && (($publication -> accessMode == NULL) || ($publication -> accessMode == self :: UNKNOWN))) || (($datasource -> accessMode == self :: UNKNOWN) && ($publication -> accessMode == NULL)) || ((($datasource -> accessMode == NULL) && ($publication -> accessMode == NULL) && ($publication -> url == NULL))))) {
|
3758
|
$publication -> accessMode = $datasource -> accessMode;
|
3759
|
$publication -> url = $datasource -> url;
|
3760
|
|
3761
|
if (!in_array($datasource->type, $publication->type)) {
|
3762
|
array_push ($publication -> type, $datasource -> type);
|
3763
|
}
|
3764
|
}
|
3765
|
if (($datasource -> id != NULL) || ($datasource -> name != NULL) || ($datasource -> url != NULL) || ($datasource -> accessMode != NULL))
|
3766
|
$publication -> datasources[] = $datasource;
|
3767
|
}
|
3768
|
foreach ($collectedFromNodes as $collectedFromNode) {
|
3769
|
if (($idNodes = $xpath -> query('./@value_original', $collectedFromNode)) == FALSE)
|
3770
|
throw new Exception('error parsing publication');
|
3771
|
if (($nameNodes = $xpath -> query('./@value', $collectedFromNode)) == FALSE)
|
3772
|
throw new Exception('error parsing publication');
|
3773
|
$collectedFrom = new JObject();
|
3774
|
$collectedFrom -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3775
|
$collectedFrom -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
3776
|
if (($collectedFrom -> id != NULL) || ($collectedFrom -> name != NULL))
|
3777
|
$publication -> collectedFrom[] = $collectedFrom;
|
3778
|
}
|
3779
|
foreach ($sourceNodes as $sourceNode) {
|
3780
|
if (($source = trim($sourceNode -> nodeValue)) != NULL)
|
3781
|
$publication -> sources[] = $source;
|
3782
|
}
|
3783
|
foreach ($projectNodes as $projectNode) {
|
3784
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $projectNode)) == FALSE)
|
3785
|
throw new Exception('error parsing publication');
|
3786
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $projectNode)) == FALSE)
|
3787
|
throw new Exception('error parsing publication');
|
3788
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $projectNode)) == FALSE)
|
3789
|
throw new Exception('error parsing publication');
|
3790
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $projectNode)) == FALSE)
|
3791
|
throw new Exception('error parsing publication');
|
3792
|
if (($acronymNodes = $xpath -> query('./field[@name = "projectacronym"]/@value', $projectNode)) == FALSE)
|
3793
|
throw new Exception('error parsing publication');
|
3794
|
if (($titleNodes = $xpath -> query('./field[@name = "projecttitle"]/@value', $projectNode)) == FALSE)
|
3795
|
throw new Exception('error parsing publication');
|
3796
|
if (($codeNodes = $xpath -> query('./field[@name = "projectcode"]/@value', $projectNode)) == FALSE)
|
3797
|
throw new Exception('error parsing publication');
|
3798
|
if (($fundingNodes = $xpath -> query('./field[@name = "funding"]', $projectNode)) == FALSE)
|
3799
|
throw new Exception('error parsing publication');
|
3800
|
|
3801
|
|
3802
|
$project = new JObject();
|
3803
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3804
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
3805
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3806
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
3807
|
$project -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3808
|
$project -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3809
|
$project -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3810
|
/* $project -> funding = new JObject();
|
3811
|
if (($fundingNode = $fundingNodes -> item(0)) == NULL) ;
|
3812
|
else
|
3813
|
{
|
3814
|
if (($funding0Nodes = $xpath -> query('./field[@name = "funding_level_0"]/@value', $fundingNode)) == FALSE)
|
3815
|
throw new Exception('error parsing publication test');
|
3816
|
$project -> funding->funding_level_0 = (($funding0Node = $funding0Nodes -> item(0)) == NULL) ? NULL : trim($funding0Node -> nodeValue);
|
3817
|
}*/
|
3818
|
|
3819
|
$project -> funding = new JObject();
|
3820
|
$project -> funding->funding_level_0 = NULL;
|
3821
|
$project -> funding->funding_level_1 = NULL;
|
3822
|
$project -> funding->funding_level_2 = NULL;
|
3823
|
|
3824
|
if (($fundingNode = $fundingNodes -> item(0)) == NULL);
|
3825
|
else{
|
3826
|
if (($funding0Nodes = $xpath -> query('./field[@name = "funding_level_0"]', $fundingNode)) == FALSE)
|
3827
|
throw new Exception('error parsing project');
|
3828
|
if (($funding1Nodes = $xpath -> query('./field[@name = "funding_level_1"]', $fundingNode)) == FALSE)
|
3829
|
throw new Exception('error parsing project');
|
3830
|
if (($funding2Nodes = $xpath -> query('./field[@name = "funding_level_2"]', $fundingNode)) == FALSE)
|
3831
|
throw new Exception('error parsing project');
|
3832
|
if (($funding0Node = $funding0Nodes -> item(0)) == NULL) ;
|
3833
|
else
|
3834
|
{
|
3835
|
if (($funding0NameNodes = $xpath -> query('./@value_original', $funding0Node)) == FALSE)
|
3836
|
throw new Exception('error parsing publication test');
|
3837
|
$project -> funding -> funding_level_0 = (($funding0NameNode = $funding0NameNodes -> item(0)) == NULL) ? NULL : trim($funding0NameNode -> nodeValue);
|
3838
|
$array=explode("::",$project -> funding -> funding_level_0 );
|
3839
|
$project -> funding -> funding_level_0 =$array[sizeof($array)-1];
|
3840
|
}
|
3841
|
if (($funding1Node = $funding1Nodes -> item(0)) == NULL) ;
|
3842
|
else
|
3843
|
{
|
3844
|
if (($funding1NameNodes = $xpath -> query('./@value_original', $funding1Node)) == FALSE)
|
3845
|
throw new Exception('error parsing publication test');
|
3846
|
$project -> funding -> funding_level_1 = (($funding1NameNode = $funding1NameNodes -> item(0)) == NULL) ? NULL : trim($funding1NameNode -> nodeValue);
|
3847
|
$array=explode("::",$project -> funding -> funding_level_1 );
|
3848
|
$project -> funding -> funding_level_1 =$array[sizeof($array)-1];
|
3849
|
}
|
3850
|
if (($funding2Node = $funding2Nodes -> item(0)) == NULL) ;
|
3851
|
else
|
3852
|
{
|
3853
|
if (($funding2NameNodes = $xpath -> query('./@value_original', $funding2Node)) == FALSE)
|
3854
|
throw new Exception('error parsing publication test');
|
3855
|
$project -> funding -> funding_level_2 = (($funding2NameNode = $funding2NameNodes -> item(0)) == NULL) ? NULL : trim($funding2NameNode -> nodeValue);
|
3856
|
$array=explode("::",$project -> funding -> funding_level_2 );
|
3857
|
$project -> funding -> funding_level_2 =$array[sizeof($array)-1];
|
3858
|
}
|
3859
|
}
|
3860
|
//!!!!
|
3861
|
|
3862
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL))
|
3863
|
$publication -> projects[] = $project;
|
3864
|
}
|
3865
|
foreach ($pidNodes as $pidNode) {
|
3866
|
if (($classNodes = $xpath -> query('./field[@name = "classid"]/@value', $pidNode)) == FALSE)
|
3867
|
throw new Exception('error parsing publication');
|
3868
|
if (($valueNodes = $xpath -> query('./field[@name = "value"]/@value', $pidNode)) == FALSE)
|
3869
|
throw new Exception('error parsing publication');
|
3870
|
$pid = new JObject();
|
3871
|
$pid -> clazz = (($classNode = $classNodes -> item(0)) == NULL) ? NULL : trim($classNode -> nodeValue);
|
3872
|
$pid -> value = (($valueNode = $valueNodes -> item(0)) == NULL) ? NULL : trim($valueNode -> nodeValue);
|
3873
|
if (($pid -> clazz != NULL) && ($pid -> value != NULL))
|
3874
|
$publication -> pids[] = $pid;
|
3875
|
}
|
3876
|
foreach ($similarNodes as $similarNode) {
|
3877
|
if (($typeNodes = $xpath -> query('./field[@name = "resulttypeid"]/@value', $similarNode)) == FALSE)
|
3878
|
throw new Exception('error parsing publication');
|
3879
|
if (($typeNameNodes = $xpath -> query('./field[@name = "resulttypename"]/@value', $similarNode)) == FALSE)
|
3880
|
throw new Exception('error parsing publication');
|
3881
|
if (($idNodes = $xpath -> query('./field[@name = "resultid"]/@value', $similarNode)) == FALSE)
|
3882
|
throw new Exception('error parsing publication');
|
3883
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $similarNode)) == FALSE)
|
3884
|
throw new Exception('error parsing publication');
|
3885
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $similarNode)) == FALSE)
|
3886
|
throw new Exception('error parsing publication');
|
3887
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $similarNode)) == FALSE)
|
3888
|
throw new Exception('error parsing publication');
|
3889
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $similarNode)) == FALSE)
|
3890
|
throw new Exception('error parsing publication');
|
3891
|
if (($yearNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $similarNode)) == FALSE)
|
3892
|
throw new Exception('error parsing publication');
|
3893
|
|
3894
|
$similarPublication = new JObject();
|
3895
|
$similarPublication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3896
|
$similarPublication -> source = 'openaire';
|
3897
|
$similarPublication -> url = NULL;
|
3898
|
$similarPublication -> accessMode = NULL;
|
3899
|
$similarPublication -> datasources = array();
|
3900
|
$similarPublication -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3901
|
$similarPublication -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3902
|
$similarPublication -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3903
|
$similarPublication -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3904
|
$similarPublication -> authors = array();
|
3905
|
$similarPublication -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
3906
|
$similarPublication -> projects = array();
|
3907
|
$similarPublication -> embargoEndDate = NULL;
|
3908
|
$similarPublication -> description = NULL;
|
3909
|
if (($similarPublication -> id != NULL) || ($similarPublication -> title != NULL) || ($similarPublication -> year != NULL)){
|
3910
|
$publication -> similarPublications[] = $similarPublication;
|
3911
|
}
|
3912
|
}
|
3913
|
foreach ($relatedNodes as $relatedNode) {
|
3914
|
if (($typeNodes = $xpath -> query('./field[@name = "resulttypeid"]/@value', $relatedNode)) == FALSE)
|
3915
|
throw new Exception('error parsing publication');
|
3916
|
if (($idNodes = $xpath -> query('./field[@name = "resultid"]/@value', $relatedNode)) == FALSE)
|
3917
|
throw new Exception('error parsing publication');
|
3918
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $relatedNode)) == FALSE)
|
3919
|
throw new Exception('error parsing publication');
|
3920
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $relatedNode)) == FALSE)
|
3921
|
throw new Exception('error parsing publication');
|
3922
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $relatedNode)) == FALSE)
|
3923
|
throw new Exception('error parsing publication');
|
3924
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $relatedNode)) == FALSE)
|
3925
|
throw new Exception('error parsing publication');
|
3926
|
if (($yearNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $relatedNode)) == FALSE)
|
3927
|
throw new Exception('error parsing publication');
|
3928
|
switch ((($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue)) {
|
3929
|
case self :: PUBLICATION:
|
3930
|
$relatedPublication = new JObject();
|
3931
|
$relatedPublication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3932
|
$relatedPublication -> source = 'openaire';
|
3933
|
$relatedPublication -> url = NULL;
|
3934
|
$relatedPublication -> accessMode = NULL;
|
3935
|
$relatedPublication -> datasources = array();
|
3936
|
$relatedPublication -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3937
|
$relatedPublication -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3938
|
$relatedPublication -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3939
|
$relatedPublication -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3940
|
$relatedPublication -> authors = array();
|
3941
|
$relatedPublication -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
3942
|
$relatedPublication -> projects = array();
|
3943
|
$relatedPublication -> embargoEndDate = NULL;
|
3944
|
$relatedPublication -> description = NULL;
|
3945
|
if (($relatedPublication -> id != NULL) || ($relatedPublication -> title != NULL) || ($relatedPublication -> year != NULL))
|
3946
|
$publication -> relatedPublications[] = $relatedPublication;
|
3947
|
break;
|
3948
|
case self :: DATASET:
|
3949
|
$relatedDataset = new JObject();
|
3950
|
$relatedDataset -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3951
|
$relatedDataset -> source = 'openaire';
|
3952
|
$relatedDataset -> url = NULL;
|
3953
|
$relatedDataset -> accessMode = NULL;
|
3954
|
$relatedDataset -> datasources = array();
|
3955
|
$relatedDataset -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
3956
|
$relatedDataset -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
3957
|
$relatedDataset -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
3958
|
$relatedDataset -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
3959
|
$relatedDataset -> authors = array();
|
3960
|
$relatedDataset -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
3961
|
$relatedDataset -> projects = array();
|
3962
|
$relatedDataset -> embargoEndDate = NULL;
|
3963
|
$relatedDataset -> description = NULL;
|
3964
|
if (($relatedDataset -> id != NULL) || ($relatedDataset -> title != NULL) || ($relatedDataset -> year != NULL))
|
3965
|
$publication -> relatedDatasets[] = $relatedDataset;
|
3966
|
break;
|
3967
|
}
|
3968
|
}
|
3969
|
foreach ($externalReferenceNodes as $externalReferenceNode) {
|
3970
|
if (($typeNodes = $xpath -> query('./field[@name = "typeid"]/@value', $externalReferenceNode)) == FALSE)
|
3971
|
throw new Exception('error parsing publication');
|
3972
|
if (($idNodes = $xpath -> query('./field[@name = "refidentifier"]/@value', $externalReferenceNode)) == FALSE)
|
3973
|
throw new Exception('error parsing publication');
|
3974
|
if (($urlNodes = $xpath -> query('./field[@name = "url"]/@value', $externalReferenceNode)) == FALSE)
|
3975
|
throw new Exception('error parsing publication');
|
3976
|
if (($labelNodes = $xpath -> query('./field[@name = "label"]/@value', $externalReferenceNode)) == FALSE)
|
3977
|
throw new Exception('error parsing publication');
|
3978
|
if (($siteNameNodes = $xpath -> query('./field[@name = "sitename"]/@value', $externalReferenceNode)) == FALSE)
|
3979
|
throw new Exception('error parsing publication');
|
3980
|
switch ((($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue)) {
|
3981
|
case self :: PUBLICATION:
|
3982
|
$externalPublication = new JObject();
|
3983
|
$externalPublication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
3984
|
$externalPublication -> source = NULL;
|
3985
|
$externalPublication -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
3986
|
$externalPublication -> accessMode = NULL;
|
3987
|
$externalPublication -> datasources = array();
|
3988
|
$externalPublication -> title = (($labelNode = $labelNodes -> item(0)) == NULL) ? NULL : trim($labelNode -> nodeValue);
|
3989
|
$externalPublication -> authors = array();
|
3990
|
$site = new JObject();
|
3991
|
$site -> id = NULL;
|
3992
|
$site -> lastName = NULL;
|
3993
|
$site -> firstName = NULL;
|
3994
|
$site -> fullName = (($siteNameNode = $siteNameNodes -> item(0)) == NULL) ? NULL : trim($siteNameNode -> nodeValue);
|
3995
|
if ($site -> fullName != NULL)
|
3996
|
$externalPublication -> authors[] = $site;
|
3997
|
$externalPublication -> year = NULL;
|
3998
|
$externalPublication -> projects = array();
|
3999
|
$externalPublication -> embargoEndDate = NULL;
|
4000
|
$externalPublication -> description = NULL;
|
4001
|
if (($externalPublication -> id != NULL) || ($externalPublication -> url != NULL) || ($externalPublication -> title != NULL))
|
4002
|
$publication -> externalPublications[] = $externalPublication;
|
4003
|
break;
|
4004
|
case self :: DATASET:
|
4005
|
$externalDataset = new JObject();
|
4006
|
$externalDataset -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4007
|
$externalDataset -> source = NULL;
|
4008
|
$externalDataset -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
4009
|
$externalDataset -> accessMode = NULL;
|
4010
|
$externalDataset -> datasources = array();
|
4011
|
$externalDataset -> title = (($labelNode = $labelNodes -> item(0)) == NULL) ? NULL : trim($labelNode -> nodeValue);
|
4012
|
$externalDataset -> authors = array();
|
4013
|
$site = new JObject();
|
4014
|
$site -> id = NULL;
|
4015
|
$site -> lastName = NULL;
|
4016
|
$site -> firstName = NULL;
|
4017
|
$site -> fullName = (($siteNameNode = $siteNameNodes -> item(0)) == NULL) ? NULL : trim($siteNameNode -> nodeValue);
|
4018
|
if ($site -> fullName != NULL)
|
4019
|
$externalDataset -> authors[] = $site;
|
4020
|
$externalDataset -> year = NULL;
|
4021
|
$externalDataset -> projects = array();
|
4022
|
$externalDataset -> embargoEndDate = NULL;
|
4023
|
$externalDataset -> description = NULL;
|
4024
|
if (($externalDataset -> id != NULL) || ($externalDataset -> url != NULL) || ($externalDataset -> title != NULL))
|
4025
|
$publication -> externalDatasets[] = $externalDataset;
|
4026
|
}
|
4027
|
}
|
4028
|
foreach ($contextNodes as $contextNode) {
|
4029
|
if (($idNodes = $xpath -> query('./@value', $contextNode)) == FALSE)
|
4030
|
throw new Exception('error parsing publication');
|
4031
|
if (($nameNodes = $xpath -> query('./@value_original', $contextNode)) == FALSE)
|
4032
|
throw new Exception('error parsing publication');
|
4033
|
if (($typeNodes = $xpath -> query('./field[@name = "contexttype"]/@value', $contextNode)) == FALSE)
|
4034
|
throw new Exception('error parsing publication');
|
4035
|
if (($categoryNodes = $xpath -> query('./field[@name = "category"]', $contextNode)) == FALSE)
|
4036
|
throw new Exception('error parsing publication');
|
4037
|
$context = new JObject();
|
4038
|
$context -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4039
|
$context -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4040
|
$context -> type = (($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue);
|
4041
|
$context -> categories = array();
|
4042
|
foreach ($categoryNodes as $categoryNode) {
|
4043
|
if (($idNodes = $xpath -> query('./@value_original', $categoryNode)) == FALSE)
|
4044
|
throw new Exception('error parsing publication');
|
4045
|
if (($nameNodes = $xpath -> query('./@value', $categoryNode)) == FALSE)
|
4046
|
throw new Exception('error parsing publication');
|
4047
|
if (($conceptNodes = $xpath -> query('./field[@name = "concept"]', $categoryNode)) == FALSE)
|
4048
|
throw new Exception('error parsing publication');
|
4049
|
$category = new JObject();
|
4050
|
$category -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4051
|
$category -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4052
|
$category -> concepts = array();
|
4053
|
foreach ($conceptNodes as $conceptNode) {
|
4054
|
if (($idNodes = $xpath -> query('./@value_original', $conceptNode)) == FALSE)
|
4055
|
throw new Exception('error parsing publication');
|
4056
|
if (($nameNodes = $xpath -> query('./@value', $conceptNode)) == FALSE)
|
4057
|
throw new Exception('error parsing publication');
|
4058
|
$concept = new JObject();
|
4059
|
$concept -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4060
|
$concept -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4061
|
if (($concept -> id != NULL) || ($concept -> name != NULL))
|
4062
|
$category -> concepts[] = $concept;
|
4063
|
}
|
4064
|
if (($category -> id != NULL) || ($category -> name != NULL) || ($category -> concepts != NULL))
|
4065
|
$context -> categories[] = $category;
|
4066
|
}
|
4067
|
if (($context -> id != NULL) || ($context -> name != NULL) || ($context -> categories != NULL))
|
4068
|
$publication -> contexts[] = $context;
|
4069
|
}
|
4070
|
foreach ($citationNodes as $citationNode) {
|
4071
|
if (($titleNodes = $xpath -> query('./field[@name = "rawText"]/@value', $citationNode)) == FALSE)
|
4072
|
throw new Exception('error parsing publications');
|
4073
|
if (($idsNodes = $xpath -> query('./field[@name = "citationId"]', $citationNode)) == FALSE)
|
4074
|
throw new Exception('error parsing publications');
|
4075
|
$citation = new JObject();
|
4076
|
$citation -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
4077
|
$citation -> ids=array();
|
4078
|
foreach ($idsNodes as $citationIdNode) {
|
4079
|
if (($idNodes = $xpath -> query('./field[@name = "id"]/@value', $citationIdNode)) == FALSE)
|
4080
|
throw new Exception('error parsing publications');
|
4081
|
if (($typeNodes = $xpath -> query('./field[@name = "type"]/@value', $citationIdNode)) == FALSE)
|
4082
|
throw new Exception('error parsing publications');
|
4083
|
if (($confidenceLevelNodes = $xpath -> query('./field[@name = "confidenceLevel"]/@value', $citationIdNode)) == FALSE)
|
4084
|
throw new Exception('error parsing publications');
|
4085
|
$ids=new JObject();
|
4086
|
$ids->id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4087
|
$ids->type = (($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue);
|
4088
|
$ids->confidenceLevel = (($confidenceLevelNode = $confidenceLevelNodes -> item(0)) == NULL) ? NULL : trim($confidenceLevelNode -> nodeValue);
|
4089
|
$citation -> ids[]=$ids;
|
4090
|
}
|
4091
|
|
4092
|
$publication->citations[]=$citation;
|
4093
|
/* $subject -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
4094
|
$subject -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
4095
|
$subject -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
4096
|
$subject -> taxonomy = (($taxonomyNode = $taxonomyNodes -> item(0)) == NULL) ? NULL : trim($taxonomyNode -> nodeValue);
|
4097
|
*/
|
4098
|
}
|
4099
|
return $publication;
|
4100
|
}
|
4101
|
|
4102
|
// Parse a single dataset from a search service XML response.
|
4103
|
// xpath the DOMXPath to parse
|
4104
|
// return dataset (object)
|
4105
|
private function parseDataset($xpath,$locale) {
|
4106
|
if ((($resultsNodes = $xpath -> query('/response/results/result')) == FALSE) || (($resultNode = $resultsNodes -> item(0)) == NULL)) // result
|
4107
|
throw new Exception('error parsing dataset');
|
4108
|
if (($idNodes = $xpath -> query('./field[@name = "resultId"]/@value', $resultNode)) == FALSE)
|
4109
|
throw new Exception('error parsing dataset');
|
4110
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $resultNode)) == FALSE)
|
4111
|
throw new Exception('error parsing dataset');
|
4112
|
if (($authorNodes = $xpath -> query('./field[@name = "hasAuthor"]', $resultNode)) == FALSE)
|
4113
|
throw new Exception('error parsing dataset');
|
4114
|
if (($dateNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $resultNode)) == FALSE)
|
4115
|
throw new Exception('error parsing dataset');
|
4116
|
if (($publisherNodes = $xpath -> query('./field[@name = "publisher"]/@value', $resultNode)) == FALSE)
|
4117
|
throw new Exception('error parsing dataset');
|
4118
|
if (($languageNodes = $xpath -> query('./field[@name = "language"]/@value', $resultNode)) == FALSE)
|
4119
|
throw new Exception('error parsing dataset');
|
4120
|
if (($typeNodes = $xpath -> query('./field[@name ="resulttypename"]/@value', $resultNode)) == FALSE)
|
4121
|
throw new Exception('error parsing dataset');
|
4122
|
if (($subjectNodes = $xpath -> query('./field[@name = "subject"]/@value', $resultNode)) == FALSE)
|
4123
|
throw new Exception('error parsing dataset');
|
4124
|
if (($embargoEndDateNodes = $xpath -> query('./field[@name = "embargoenddate"]/@value', $resultNode)) == FALSE)
|
4125
|
throw new Exception('error parsing dataset');
|
4126
|
if (($descriptionNodes = $xpath -> query('./field[@name = "description"]/@value', $resultNode)) == FALSE)
|
4127
|
throw new Exception('error parsing dataset');
|
4128
|
if (($datasourceNodes = $xpath -> query('./field[@name = "datasource"]', $resultNode)) == FALSE)
|
4129
|
throw new Exception('error parsing dataset');
|
4130
|
if (($collectedFromNodes = $xpath -> query('./field[@name = "collectedfrom"]', $resultNode)) == FALSE)
|
4131
|
throw new Exception('error parsing dataset');
|
4132
|
if (($sourceNodes = $xpath -> query('./field[@name = "source"]/@value', $resultNode)) == FALSE)
|
4133
|
throw new Exception('error parsing dataset');
|
4134
|
if (($projectNodes = $xpath -> query('./field[@name = "project"]', $resultNode)) == FALSE)
|
4135
|
throw new Exception('error parsing dataset');
|
4136
|
if (($pidNodes = $xpath -> query('./field[@name = "pid"]', $resultNode)) == FALSE)
|
4137
|
throw new Exception('error parsing dataset');
|
4138
|
if (($relatedNodes = $xpath -> query('./field[@name = "isRelatedTo"]', $resultNode)) == FALSE)
|
4139
|
throw new Exception('error parsing dataset');
|
4140
|
if (($externalReferenceNodes = $xpath -> query('./field[@name = "externalreference"]', $resultNode)) == FALSE)
|
4141
|
throw new Exception('error parsing dataset');
|
4142
|
if (($contextNodes = $xpath -> query('./field[@name = "context"]', $resultNode)) == FALSE)
|
4143
|
throw new Exception('error parsing dataset');
|
4144
|
$dataset = new JObject();
|
4145
|
$dataset -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4146
|
$dataset -> source = 'openaire';
|
4147
|
$dataset -> accessMode = NULL;
|
4148
|
$dataset -> url = NULL;
|
4149
|
$dataset -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
4150
|
$dataset -> authors = array();
|
4151
|
$dataset -> year = (($dateNode = $dateNodes -> item(0)) == NULL) ? NULL : intval(trim($dateNode -> nodeValue));
|
4152
|
$dataset -> date = ($dateNode == NULL) ? NULL : strtotime(trim($dateNode -> nodeValue));
|
4153
|
$dataset -> publisher = (($publisherNode = $publisherNodes -> item(0)) == NULL) ? NULL : trim($publisherNode -> nodeValue);
|
4154
|
$dataset -> languages = array();
|
4155
|
$dataset -> type = (($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue);
|
4156
|
$dataset -> subjects = array();
|
4157
|
$dataset -> embargoEndDate = (($embargoEndDateNode = $embargoEndDateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($embargoEndDateNode -> nodeValue));
|
4158
|
$dataset -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue);
|
4159
|
$dataset -> datasources = array();
|
4160
|
$dataset -> collectedFrom = array();
|
4161
|
$dataset -> sources = array();
|
4162
|
$dataset -> projects = array();
|
4163
|
$dataset -> pids = array();
|
4164
|
$dataset -> relatedPublications = array();
|
4165
|
$dataset -> relatedDatasets = array();
|
4166
|
$dataset -> externalPublications = array();
|
4167
|
$dataset -> externalDatasets = array();
|
4168
|
$dataset -> contexts = array();
|
4169
|
foreach ($authorNodes as $authorNode) {
|
4170
|
if (($idNodes = $xpath -> query('./field[@name = "personId"]/@value', $authorNode)) == FALSE)
|
4171
|
throw new Exception('error parsing dataset');
|
4172
|
if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $authorNode)) == FALSE)
|
4173
|
throw new Exception('error parsing dataset');
|
4174
|
if (($rankingNodes = $xpath -> query('./field[@name = "ranking"]/@value', $authorNode)) == FALSE)
|
4175
|
throw new Exception('error parsing publication');
|
4176
|
$author = new JObject();
|
4177
|
$author -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4178
|
$author -> lastName = NULL;
|
4179
|
$author -> firstName = NULL;
|
4180
|
$author -> fullName = (($fullNameNode = $fullNameNodes -> item(0)) == NULL) ? NULL : trim($fullNameNode -> nodeValue);
|
4181
|
$author -> ranking = (($rankingNode = $rankingNodes -> item(0)) == NULL) ? 0 : intval(trim($rankingNode -> nodeValue));
|
4182
|
if (($author -> id != NULL) || ($author -> lastName != NULL) || ($author -> firstName != NULL) || ($author -> fullName != NULL))
|
4183
|
$dataset -> authors[] = $author;
|
4184
|
usort($dataset -> authors, function ($author1, $author2) {return $author1 -> ranking - $author2 -> ranking;});
|
4185
|
}
|
4186
|
foreach ($languageNodes as $languageNode) {
|
4187
|
if ((($language = trim($languageNode -> nodeValue)) != NULL) && ($language != self :: UNDETERMINED))
|
4188
|
$dataset -> languages[] = $language;
|
4189
|
}
|
4190
|
foreach ($subjectNodes as $subjectNode) {
|
4191
|
if (($subject = trim($subjectNode -> nodeValue)) != NULL)
|
4192
|
$dataset -> subjects[] = $subject;
|
4193
|
}
|
4194
|
foreach ($datasourceNodes as $datasourceNode) {
|
4195
|
if (($idNodes = $xpath -> query('./field[@name = "hostedby"]/@value_original', $datasourceNode)) == FALSE)
|
4196
|
throw new Exception('error parsing dataset');
|
4197
|
if (($nameNodes = $xpath -> query('./field[@name = "hostedby"]/@value', $datasourceNode)) == FALSE)
|
4198
|
throw new Exception('error parsing dataset');
|
4199
|
if (($urlNodes = $xpath -> query('./field[@name = "url"]/@value', $datasourceNode)) == FALSE)
|
4200
|
throw new Exception('error parsing dataset');
|
4201
|
if (($accessModeNodes = $xpath -> query('./field[@name = "licenceid"]/@value_original', $datasourceNode)) == FALSE)
|
4202
|
throw new Exception('error parsing dataset');
|
4203
|
$datasource = new JObject();
|
4204
|
$datasource -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4205
|
$datasource -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4206
|
$datasource -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
4207
|
// TODO
|
4208
|
if (substr($datasource -> url, 0, strlen('http://dx.doi.org/http://zenodo.org/record/')) == 'http://dx.doi.org/http://zenodo.org/record/') {
|
4209
|
$url = substr($datasource -> url, strlen('http://dx.doi.org/'));
|
4210
|
JLog :: add('Converting datasource URL ' . $datasource -> url . ' to ' . $url, JLog :: DEBUG, self :: LOG);
|
4211
|
$datasource -> url = $url;
|
4212
|
}
|
4213
|
// TODO
|
4214
|
$datasource -> accessMode = (($accessModeNode = $accessModeNodes -> item(0)) == NULL) ? NULL : trim($accessModeNode -> nodeValue);
|
4215
|
if (($datasource -> url != NULL) && ((($datasource -> accessMode == self :: DATASOURCE_ACCESS_OPEN) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_EMBARGO) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_RESTRICTED) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN) || ($dataset -> accessMode == self :: DATASOURCE_ACCESS_CLOSED))) || (($datasource -> accessMode == self :: DATASOURCE_ACCESS_CLOSED) && (($dataset -> accessMode == NULL) || ($dataset -> accessMode == self :: UNKNOWN))) || (($datasource -> accessMode == self :: UNKNOWN) && ($dataset -> accessMode == NULL)) || ((($datasource -> accessMode == NULL) && ($dataset -> accessMode == NULL) && ($dataset -> url == NULL))))) {
|
4216
|
$dataset -> accessMode = $datasource -> accessMode;
|
4217
|
$dataset -> url = $datasource -> url;
|
4218
|
}
|
4219
|
if (($datasource -> id != NULL) || ($datasource -> name != NULL) || ($datasource -> url != NULL) || ($datasource -> accessMode != NULL))
|
4220
|
$dataset -> datasources[] = $datasource;
|
4221
|
}
|
4222
|
foreach ($collectedFromNodes as $collectedFromNode) {
|
4223
|
if (($idNodes = $xpath -> query('./@value_original', $collectedFromNode)) == FALSE)
|
4224
|
throw new Exception('error parsing dataset');
|
4225
|
if (($nameNodes = $xpath -> query('./@value', $collectedFromNode)) == FALSE)
|
4226
|
throw new Exception('error parsing dataset');
|
4227
|
$collectedFrom = new JObject();
|
4228
|
$collectedFrom -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4229
|
$collectedFrom -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4230
|
if (($collectedFrom -> id != NULL) || ($collectedFrom -> name != NULL))
|
4231
|
$dataset -> collectedFrom[] = $collectedFrom;
|
4232
|
}
|
4233
|
foreach ($sourceNodes as $sourceNode) {
|
4234
|
if (($source = trim($sourceNode -> nodeValue)) != NULL)
|
4235
|
$dataset -> sources[] = $source;
|
4236
|
}
|
4237
|
foreach ($projectNodes as $projectNode) {
|
4238
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $projectNode)) == FALSE)
|
4239
|
throw new Exception('error parsing dataset');
|
4240
|
if (($acronymNodes = $xpath -> query('./field[@name = "projectacronym"]/@value', $projectNode)) == FALSE)
|
4241
|
throw new Exception('error parsing dataset');
|
4242
|
if (($titleNodes = $xpath -> query('./field[@name = "projecttitle"]/@value', $projectNode)) == FALSE)
|
4243
|
throw new Exception('error parsing dataset');
|
4244
|
if (($codeNodes = $xpath -> query('./field[@name = "projectcode"]/@value', $projectNode)) == FALSE)
|
4245
|
throw new Exception('error parsing dataset');
|
4246
|
$project = new JObject();
|
4247
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4248
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
4249
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
4250
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
4251
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL))
|
4252
|
$dataset -> projects[] = $project;
|
4253
|
}
|
4254
|
foreach ($pidNodes as $pidNode) {
|
4255
|
if (($classNodes = $xpath -> query('./field[@name = "classid"]/@value', $pidNode)) == FALSE)
|
4256
|
throw new Exception('error parsing dataset');
|
4257
|
if (($valueNodes = $xpath -> query('./field[@name = "value"]/@value', $pidNode)) == FALSE)
|
4258
|
throw new Exception('error parsing dataset');
|
4259
|
$pid = new JObject();
|
4260
|
$pid -> clazz = (($classNode = $classNodes -> item(0)) == NULL) ? NULL : trim($classNode -> nodeValue);
|
4261
|
$pid -> value = (($valueNode = $valueNodes -> item(0)) == NULL) ? NULL : trim($valueNode -> nodeValue);
|
4262
|
if (($pid -> clazz != NULL) && ($pid -> value != NULL))
|
4263
|
$dataset -> pids[] = $pid;
|
4264
|
}
|
4265
|
foreach ($relatedNodes as $relatedNode) {
|
4266
|
if (($typeNodes = $xpath -> query('./field[@name = "resulttypeid"]/@value', $relatedNode)) == FALSE)
|
4267
|
throw new Exception('error parsing publication');
|
4268
|
if (($idNodes = $xpath -> query('./field[@name = "resultid"]/@value', $relatedNode)) == FALSE)
|
4269
|
throw new Exception('error parsing publication');
|
4270
|
if (($inferredNodes = $xpath -> query('./field[@name = "inferred"]/@value', $relatedNode)) == FALSE)
|
4271
|
throw new Exception('error parsing publication');
|
4272
|
if (($trustNodes = $xpath -> query('./field[@name = "trust"]/@value', $relatedNode)) == FALSE)
|
4273
|
throw new Exception('error parsing publication');
|
4274
|
if (($provenanceNodes = $xpath -> query('./field[@name = "provenance"]/@value', $relatedNode)) == FALSE)
|
4275
|
throw new Exception('error parsing publication');
|
4276
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $relatedNode)) == FALSE)
|
4277
|
throw new Exception('error parsing publication');
|
4278
|
if (($yearNodes = $xpath -> query('./field[@name = "dateofacceptance"]/@value', $relatedNode)) == FALSE)
|
4279
|
throw new Exception('error parsing publication');
|
4280
|
switch ((($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue)) {
|
4281
|
case self :: PUBLICATION:
|
4282
|
$relatedPublication = new JObject();
|
4283
|
$relatedPublication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4284
|
$relatedPublication -> source = 'openaire';
|
4285
|
$relatedPublication -> url = NULL;
|
4286
|
$relatedPublication -> accessMode = NULL;
|
4287
|
$relatedPublication -> datasources = array();
|
4288
|
$relatedPublication -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
4289
|
$relatedPublication -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
4290
|
$relatedPublication -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
4291
|
$relatedPublication -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
4292
|
$relatedPublication -> authors = array();
|
4293
|
$relatedPublication -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
4294
|
$relatedPublication -> projects = array();
|
4295
|
$relatedPublication -> embargoEndDate = NULL;
|
4296
|
$relatedPublication -> description = NULL;
|
4297
|
if (($relatedPublication -> id != NULL) || ($relatedPublication -> title != NULL) || ($relatedPublication -> year != NULL))
|
4298
|
$dataset -> relatedPublications[] = $relatedPublication;
|
4299
|
break;
|
4300
|
case self :: DATASET:
|
4301
|
$relatedDataset = new JObject();
|
4302
|
$relatedDataset -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4303
|
$relatedDataset -> source = 'openaire';
|
4304
|
$relatedDataset -> url = NULL;
|
4305
|
$relatedDataset -> accessMode = NULL;
|
4306
|
$relatedDataset -> datasources = array();
|
4307
|
$relatedDataset -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
4308
|
$relatedDataset -> inferred = (($inferredNode = $inferredNodes -> item(0)) == NULL) ? NULL : trim($inferredNode -> nodeValue)=="true"?true:false;
|
4309
|
$relatedDataset -> trust = (($trustNode = $trustNodes -> item(0)) == NULL) ? NULL : trim($trustNode -> nodeValue);
|
4310
|
$relatedDataset -> provenance = (($provenanceNode = $provenanceNodes -> item(0)) == NULL) ? NULL : trim($provenanceNode -> nodeValue);
|
4311
|
$relatedDataset -> authors = array();
|
4312
|
$relatedDataset -> year = (($yearNode = $yearNodes -> item(0)) == NULL) ? NULL : intval(trim($yearNode -> nodeValue));
|
4313
|
$relatedDataset -> projects = array();
|
4314
|
$relatedDataset -> embargoEndDate = NULL;
|
4315
|
$relatedDataset -> description = NULL;
|
4316
|
if (($relatedDataset -> id != NULL) || ($relatedDataset -> title != NULL) || ($relatedDataset -> year != NULL))
|
4317
|
$dataset -> relatedDatasets[] = $relatedDataset;
|
4318
|
break;
|
4319
|
}
|
4320
|
}
|
4321
|
foreach ($externalReferenceNodes as $externalReferenceNode) {
|
4322
|
if (($typeNodes = $xpath -> query('./field[@name = "typeid"]/@value', $externalReferenceNode)) == FALSE)
|
4323
|
throw new Exception('error parsing publication');
|
4324
|
if (($idNodes = $xpath -> query('./field[@name = "refidentifier"]/@value', $externalReferenceNode)) == FALSE)
|
4325
|
throw new Exception('error parsing publication');
|
4326
|
if (($urlNodes = $xpath -> query('./field[@name = "url"]/@value', $externalReferenceNode)) == FALSE)
|
4327
|
throw new Exception('error parsing publication');
|
4328
|
if (($labelNodes = $xpath -> query('./field[@name = "label"]/@value', $externalReferenceNode)) == FALSE)
|
4329
|
throw new Exception('error parsing publication');
|
4330
|
if (($siteNameNodes = $xpath -> query('./field[@name = "sitename"]/@value', $externalReferenceNode)) == FALSE)
|
4331
|
throw new Exception('error parsing publication');
|
4332
|
switch ((($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue)) {
|
4333
|
case self :: PUBLICATION:
|
4334
|
$externalPublication = new JObject();
|
4335
|
$externalPublication -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4336
|
$externalPublication -> source = NULL;
|
4337
|
$externalPublication -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
4338
|
$externalPublication -> accessMode = NULL;
|
4339
|
$externalPublication -> datasources = array();
|
4340
|
$externalPublication -> title = (($labelNode = $labelNodes -> item(0)) == NULL) ? NULL : trim($labelNode -> nodeValue);
|
4341
|
$externalPublication -> authors = array();
|
4342
|
$site = new JObject();
|
4343
|
$site -> id = NULL;
|
4344
|
$site -> lastName = NULL;
|
4345
|
$site -> firstName = NULL;
|
4346
|
$site -> fullName = (($siteNameNode = $siteNameNodes -> item(0)) == NULL) ? NULL : trim($siteNameNode -> nodeValue);
|
4347
|
if ($site -> fullName != NULL)
|
4348
|
$externalPublication -> authors[] = $site;
|
4349
|
$externalPublication -> year = NULL;
|
4350
|
$externalPublication -> projects = array();
|
4351
|
$externalPublication -> embargoEndDate = NULL;
|
4352
|
$externalPublication -> description = NULL;
|
4353
|
if (($externalPublication -> id != NULL) || ($externalPublication -> url != NULL) || ($externalPublication -> title != NULL))
|
4354
|
$dataset -> externalPublications[] = $externalPublication;
|
4355
|
break;
|
4356
|
case self :: DATASET:
|
4357
|
$externalDataset = new JObject();
|
4358
|
$externalDataset -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4359
|
$externalDataset -> source = NULL;
|
4360
|
$externalDataset -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
4361
|
$externalDataset -> accessMode = NULL;
|
4362
|
$externalDataset -> datasources = array();
|
4363
|
$externalDataset -> title = (($labelNode = $labelNodes -> item(0)) == NULL) ? NULL : trim($labelNode -> nodeValue);
|
4364
|
$externalDataset -> authors = array();
|
4365
|
$site = new JObject();
|
4366
|
$site -> id = NULL;
|
4367
|
$site -> lastName = NULL;
|
4368
|
$site -> firstName = NULL;
|
4369
|
$site -> fullName = (($siteNameNode = $siteNameNodes -> item(0)) == NULL) ? NULL : trim($siteNameNode -> nodeValue);
|
4370
|
if ($site -> fullName != NULL)
|
4371
|
$externalDataset -> authors[] = $site;
|
4372
|
$externalDataset -> year = NULL;
|
4373
|
$externalDataset -> projects = array();
|
4374
|
$externalDataset -> embargoEndDate = NULL;
|
4375
|
$externalDataset -> description = NULL;
|
4376
|
if (($externalDataset -> id != NULL) || ($externalDataset -> url != NULL) || ($externalDataset -> title != NULL))
|
4377
|
$dataset -> externalDatasets[] = $externalDataset;
|
4378
|
}
|
4379
|
}
|
4380
|
foreach ($contextNodes as $contextNode) {
|
4381
|
if (($idNodes = $xpath -> query('./@value', $contextNode)) == FALSE)
|
4382
|
throw new Exception('error parsing dataset');
|
4383
|
if (($nameNodes = $xpath -> query('./@value_original', $contextNode)) == FALSE)
|
4384
|
throw new Exception('error parsing dataset');
|
4385
|
if (($categoryNodes = $xpath -> query('./field[@name = "category"]', $contextNode)) == FALSE)
|
4386
|
throw new Exception('error parsing dataset');
|
4387
|
$context = new JObject();
|
4388
|
$context -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4389
|
$context -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4390
|
$context -> categories = array();
|
4391
|
foreach ($categoryNodes as $categoryNode) {
|
4392
|
if (($idNodes = $xpath -> query('./@value', $categoryNode)) == FALSE)
|
4393
|
throw new Exception('error parsing dataset');
|
4394
|
if (($nameNodes = $xpath -> query('./@value_original', $categoryNode)) == FALSE)
|
4395
|
throw new Exception('error parsing dataset');
|
4396
|
if (($conceptNodes = $xpath -> query('./field[@name = "concept"]', $categoryNode)) == FALSE)
|
4397
|
throw new Exception('error parsing dataset');
|
4398
|
$category = new JObject();
|
4399
|
$category -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4400
|
$category -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4401
|
$category -> concepts = array();
|
4402
|
foreach ($conceptNodes as $conceptNode) {
|
4403
|
if (($idNodes = $xpath -> query('./@value', $conceptNode)) == FALSE)
|
4404
|
throw new Exception('error parsing dataset');
|
4405
|
if (($nameNodes = $xpath -> query('./@value_original', $conceptNode)) == FALSE)
|
4406
|
throw new Exception('error parsing dataset');
|
4407
|
$concept = new JObject();
|
4408
|
$concept -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4409
|
$concept -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4410
|
if (($concept -> id != NULL) || ($concept -> name != NULL))
|
4411
|
$category -> concepts[] = $concept;
|
4412
|
}
|
4413
|
if (($category -> id != NULL) || ($category -> name != NULL) || ($category -> concepts != NULL))
|
4414
|
$context -> categories[] = $category;
|
4415
|
}
|
4416
|
if (($context -> id != NULL) || ($context -> name != NULL) || ($context -> categories != NULL))
|
4417
|
$dataset -> contexts[] = $context;
|
4418
|
}
|
4419
|
return $dataset;
|
4420
|
}
|
4421
|
|
4422
|
// Parse a single project from a search service XML response.
|
4423
|
// xpath the DOMXPath to parse
|
4424
|
// return project (object)
|
4425
|
private function parseProject($xpath) {
|
4426
|
if ((($resultsNodes = $xpath -> query('/response/results/result')) == FALSE) || (($resultNode = $resultsNodes -> item(0)) == NULL))
|
4427
|
throw new Exception('error parsing project');
|
4428
|
if (($acronymNodes = $xpath -> query('./field[@name = "name"]/@value', $resultNode)) == FALSE)
|
4429
|
throw new Exception('error parsing project');
|
4430
|
if (($titleNodes = $xpath -> query('./field[@name = "title"]/@value', $resultNode)) == FALSE)
|
4431
|
throw new Exception('error parsing project');
|
4432
|
if (($funderNodes = $xpath -> query('./field[@name = "funding_level_0"]/field[@name = "fundingname"]/@value', $resultNode)) == FALSE)
|
4433
|
throw new Exception('error parsing project');
|
4434
|
if (($fundingStreamNodes = $xpath -> query('./field[@name = "funding_level_1"]/field[@name = "fundingname"]/@value', $resultNode)) == FALSE)
|
4435
|
throw new Exception('error parsing project');
|
4436
|
if (($scientificAreaNodes = $xpath -> query('./field[@name = "funding_level_2"]/field[@name = "fundingname"]/@value', $resultNode)) == FALSE)
|
4437
|
throw new Exception('error parsing project');
|
4438
|
if (($callNodes = $xpath -> query('./field[@name = "call_identifier"]/@value', $resultNode)) == FALSE)
|
4439
|
throw new Exception('error parsing project');
|
4440
|
if (($codeNodes = $xpath -> query('./field[@name = "code"]/@value', $resultNode)) == FALSE)
|
4441
|
throw new Exception('error parsing project');
|
4442
|
if (($startYearNodes = $xpath -> query('./field[@name = "startyear"]/@value', $resultNode)) == FALSE)
|
4443
|
throw new Exception('error parsing project');
|
4444
|
if (($startDateNodes = $xpath -> query('./field[@name = "startdate"]/@value', $resultNode)) == FALSE)
|
4445
|
throw new Exception('error parsing project');
|
4446
|
if (($endYearNodes = $xpath -> query('./field[@name = "endyear"]/@value', $resultNode)) == FALSE)
|
4447
|
throw new Exception('error parsing project');
|
4448
|
if (($endDateNodes = $xpath -> query('./field[@name = "enddate"]/@value', $resultNode)) == FALSE)
|
4449
|
throw new Exception('error parsing project');
|
4450
|
if (($sc39Nodes = $xpath -> query('./field[@name = "ec_sc39"]/@value', $resultNode)) == FALSE)
|
4451
|
throw new Exception('error parsing project');
|
4452
|
if (($funding0Nodes = $xpath -> query('./field[@name = "funding_level_0"]', $resultNode)) == FALSE)
|
4453
|
throw new Exception('error parsing project');
|
4454
|
if (($funding1Nodes = $xpath -> query('./field[@name = "funding_level_1"]', $resultNode)) == FALSE)
|
4455
|
throw new Exception('error parsing project');
|
4456
|
if (($funding2Nodes = $xpath -> query('./field[@name = "funding_level_2"]', $resultNode)) == FALSE)
|
4457
|
throw new Exception('error parsing project');
|
4458
|
if (($organizationNodes = $xpath -> query('./field[@name = "organization"]', $resultNode)) == FALSE)
|
4459
|
throw new Exception('error parsing project');
|
4460
|
$project = new JObject();
|
4461
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
4462
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
4463
|
$project -> funder = (($funderNode = $funderNodes -> item(0)) == NULL) ? NULL : trim($funderNode -> nodeValue);
|
4464
|
$project -> fundingStream = (($fundingStreamNode = $fundingStreamNodes -> item(0)) == NULL) ? NULL : trim($fundingStreamNode -> nodeValue);
|
4465
|
$project -> scientificArea = (($scientificAreaNode = $scientificAreaNodes -> item(0)) == NULL) ? NULL : trim($scientificAreaNode -> nodeValue);
|
4466
|
$project -> call = (($callNode = $callNodes -> item(0)) == NULL) ? NULL : trim($callNode -> nodeValue);
|
4467
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
4468
|
$project -> startYear = (($startYearNode = $startYearNodes -> item(0)) == NULL) ? NULL : intval(trim($startYearNode -> nodeValue));
|
4469
|
$project -> startDate = (($startDateNode = $startDateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($startDateNode -> nodeValue));
|
4470
|
$project -> endYear = (($endYearNode = $endYearNodes -> item(0)) == NULL) ? NULL : intval(trim($endYearNode -> nodeValue));
|
4471
|
$project -> endDate = (($endDateNode = $endDateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($endDateNode -> nodeValue));
|
4472
|
$project -> sc39 = (($sc39Node = $sc39Nodes -> item(0)) == NULL) ? NULL : trim($sc39Node -> nodeValue);
|
4473
|
switch ($project -> sc39) {
|
4474
|
case 'true':
|
4475
|
$project -> sc39 = TRUE;
|
4476
|
break;
|
4477
|
case 'false':
|
4478
|
$project -> sc39 = FALSE;
|
4479
|
break;
|
4480
|
default:
|
4481
|
$project -> sc39 = NULL;
|
4482
|
}
|
4483
|
$project -> funding = new JObject();
|
4484
|
$project -> funding->funding_level_0 = NULL;
|
4485
|
$project -> funding->funding_level_1 = NULL;
|
4486
|
$project -> funding->funding_level_2 = NULL;
|
4487
|
if (($funding0Node = $funding0Nodes -> item(0)) == NULL) ;
|
4488
|
else
|
4489
|
{
|
4490
|
if (($funding0NameNodes = $xpath -> query('./field[@name = "fundingname"]/@value', $funding0Node)) == FALSE)
|
4491
|
throw new Exception('error parsing publication test');
|
4492
|
$project -> funding -> funding_level_0 = (($funding0NameNode = $funding0NameNodes -> item(0)) == NULL) ? NULL : trim($funding0NameNode -> nodeValue);
|
4493
|
}
|
4494
|
if (($funding1Node = $funding1Nodes -> item(0)) == NULL) ;
|
4495
|
else
|
4496
|
{
|
4497
|
if (($funding1NameNodes = $xpath -> query('./field[@name = "fundingname"]/@value', $funding1Node)) == FALSE)
|
4498
|
throw new Exception('error parsing publication test');
|
4499
|
$project -> funding -> funding_level_1 = (($funding1NameNode = $funding1NameNodes -> item(0)) == NULL) ? NULL : trim($funding1NameNode -> nodeValue);
|
4500
|
}
|
4501
|
if (($funding2Node = $funding2Nodes -> item(0)) == NULL) ;
|
4502
|
else
|
4503
|
{
|
4504
|
if (($funding2NameNodes = $xpath -> query('./field[@name = "fundingname"]/@value', $funding2Node)) == FALSE)
|
4505
|
throw new Exception('error parsing publication test');
|
4506
|
$project -> funding -> funding_level_2 = (($funding2NameNode = $funding2NameNodes -> item(0)) == NULL) ? NULL : trim($funding2NameNode -> nodeValue);
|
4507
|
}
|
4508
|
$project -> organizations = array();
|
4509
|
foreach ($organizationNodes as $organizationNode) {
|
4510
|
if (($idNodes = $xpath -> query('./field[@name = "organizationid"]/@value', $organizationNode)) == FALSE)
|
4511
|
throw new Exception('error parsing project');
|
4512
|
if (($shortNameNodes = $xpath -> query('./field[@name = "legalshortname"]/@value', $organizationNode)) == FALSE)
|
4513
|
throw new Exception('error parsing project');
|
4514
|
if (($nameNodes = $xpath -> query('./field[@name = "legalname"]/@value', $organizationNode)) == FALSE)
|
4515
|
throw new Exception('error parsing project');
|
4516
|
$organization = new JObject();
|
4517
|
$organization -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4518
|
$organization -> shortName = (($shortNameNode = $shortNameNodes -> item(0)) == NULL) ? NULL : trim($shortNameNode -> nodeValue);
|
4519
|
$organization -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4520
|
if (($organization -> id != NULL) || ($organization -> shortName != NULL) || ($organization -> name != NULL))
|
4521
|
$project -> organizations[] = $organization;
|
4522
|
}
|
4523
|
return $project;
|
4524
|
}
|
4525
|
|
4526
|
// Parse a single person from a search service XML response.
|
4527
|
// xpath the DOMXPath to parse
|
4528
|
// return person (object)
|
4529
|
private function parsePerson($xpath) {
|
4530
|
if ((($resultsNodes = $xpath -> query('/response/results/record')) == FALSE) || (($resultNode = $resultsNodes -> item(0)) == NULL))
|
4531
|
throw new Exception('error parsing person');
|
4532
|
if (($lastNameNodes = $xpath -> query('./field[@name = "secondnames"]/@value', $resultNode)) == FALSE)
|
4533
|
throw new Exception('error parsing person');
|
4534
|
if (($firstNameNodes = $xpath -> query('./field[@name = "firstname"]/@value', $resultNode)) == FALSE)
|
4535
|
throw new Exception('error parsing person');
|
4536
|
if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $resultNode)) == FALSE)
|
4537
|
throw new Exception('error parsing person');
|
4538
|
if (($countryNodes = $xpath -> query('./field[@name = "nationalityname"]/@value', $resultNode)) == FALSE)
|
4539
|
throw new Exception('error parsing person');
|
4540
|
$person = new JObject();
|
4541
|
$person -> lastName = (($lastNameNode = $lastNameNodes -> item(0)) == NULL) ? NULL : trim($lastNameNode -> nodeValue);
|
4542
|
$person -> firstName = (($firstNameNode = $firstNameNodes -> item(0)) == NULL) ? NULL : trim($firstNameNode -> nodeValue);
|
4543
|
$person -> fullName = (($fullNameNode = $fullNameNodes -> item(0)) == NULL) ? NULL : trim($fullNameNode -> nodeValue);
|
4544
|
$person -> country = (($countryNode = $countryNodes -> item(0)) == NULL) ? NULL : trim($countryNode -> nodeValue);
|
4545
|
return $person;
|
4546
|
}
|
4547
|
|
4548
|
// Parse a single organization from a search service XML response.
|
4549
|
// xpath the DOMXPath to parse
|
4550
|
// return organization (object)
|
4551
|
private function parseOrganization($xpath) {
|
4552
|
if ((($resultNodes = $xpath -> query('/response/results/result')) == FALSE) || (($resultNode = $resultNodes -> item(0)) == NULL))
|
4553
|
throw new Exception('error parsing organization');
|
4554
|
if (($shortNameNodes = $xpath -> query('./field[@name = "legalshortname"]/@value', $resultNode)) == FALSE)
|
4555
|
throw new Exception('error parsing organization');
|
4556
|
if (($nameNodes = $xpath -> query('./field[@name = "legalname"]/@value', $resultNode)) == FALSE)
|
4557
|
throw new Exception('error parsing organization');
|
4558
|
if (($urlNodes = $xpath -> query('./field[@name = "websiteurl"]/@value', $resultNode)) == FALSE)
|
4559
|
throw new Exception('error parsing organization');
|
4560
|
if (($countryNodes = $xpath -> query('./field[@name = "countryname"]/@value', $resultNode)) == FALSE)
|
4561
|
throw new Exception('error parsing organization');
|
4562
|
if (($projectNodes = $xpath -> query('./field[@name = "project"]', $resultNode)) == FALSE)
|
4563
|
throw new Exception('error parsing organization');
|
4564
|
$organization = new JObject();
|
4565
|
$organization -> shortName = (($shortNameNode = $shortNameNodes -> item(0)) == NULL) ? NULL : trim($shortNameNode -> nodeValue);
|
4566
|
$organization -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4567
|
$organization -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
4568
|
$organization -> country = (($countryNode = $countryNodes -> item(0)) == NULL) ? NULL : trim($countryNode -> nodeValue);
|
4569
|
$organization -> projects = array();
|
4570
|
foreach ($projectNodes as $projectNode) {
|
4571
|
if (($idNodes = $xpath -> query('./field[@name = "projectId"]/@value', $projectNode)) == FALSE)
|
4572
|
throw new Exception('error parsing organization');
|
4573
|
if (($acronymNodes = $xpath -> query('./field[@name = "projectacronym"]/@value', $projectNode)) == FALSE)
|
4574
|
throw new Exception('error parsing organization');
|
4575
|
if (($titleNodes = $xpath -> query('./field[@name = "projecttitle"]/@value', $projectNode)) == FALSE)
|
4576
|
throw new Exception('error parsing organization');
|
4577
|
if (($codeNodes = $xpath -> query('./field[@name = "projectcode"]/@value', $projectNode)) == FALSE)
|
4578
|
throw new Exception('error parsing organization');
|
4579
|
$project = new JObject();
|
4580
|
$project -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue);
|
4581
|
$project -> acronym = (($acronymNode = $acronymNodes -> item(0)) == NULL) ? NULL : ((trim($acronymNode -> nodeValue) == self :: UNKNOWN) ? NULL : trim($acronymNode -> nodeValue));
|
4582
|
$project -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue);
|
4583
|
$project -> code = (($codeNode = $codeNodes -> item(0)) == NULL) ? NULL : trim($codeNode -> nodeValue);
|
4584
|
if (($project -> id != NULL) || ($project -> acronym != NULL) || ($project -> title != NULL) || ($project -> code != NULL))
|
4585
|
$organization -> projects[] = $project;
|
4586
|
}
|
4587
|
return $organization;
|
4588
|
}
|
4589
|
|
4590
|
// Parse a single datasource from a search service XML response.
|
4591
|
// xpath the DOMXPath to parse
|
4592
|
// return datasource (object)
|
4593
|
private function parseDatasource($xpath) {
|
4594
|
if ((($resultsNodes = $xpath -> query('/response/results/result')) == FALSE) || (($resultNode = $resultsNodes -> item(0)) == NULL))
|
4595
|
throw new Exception('error parsing datasource');
|
4596
|
if (($nameNodes = $xpath -> query('./field[@name = "officialname"]/@value', $resultNode)) == FALSE)
|
4597
|
throw new Exception('error parsing datasource');
|
4598
|
if (($englishNameNodes = $xpath -> query('./field[@name = "englishname"]/@value', $resultNode)) == FALSE)
|
4599
|
throw new Exception('error parsing datasource');
|
4600
|
if (($urlNodes = $xpath -> query('./field[@name = "websiteurl"]/@value', $resultNode)) == FALSE)
|
4601
|
throw new Exception('error parsing datasource');
|
4602
|
if (($logoNodes = $xpath -> query('./field[@name = "logourl"]/@value', $resultNode)) == FALSE)
|
4603
|
throw new Exception('error parsing datasource');
|
4604
|
if (($typeNodes = $xpath -> query('./field[@name = "datasourcetypeuiid"]/@value', $resultNode)) == FALSE)
|
4605
|
throw new Exception('error pasrsing datasource');
|
4606
|
if (($itemsNodes = $xpath -> query('./field[@name = "odnumberofitems"]/@value', $resultNode)) == FALSE)
|
4607
|
throw new Exception('error parsing datasource');
|
4608
|
if (($dateNodes = $xpath -> query('./field[@name = "odnumberofitemsdate"]/@value', $resultNode)) == FALSE)
|
4609
|
throw new Exception('error parsing datasource');
|
4610
|
if (($subjectsNodes = $xpath -> query('./field[@name = "odsubjects"]/@value', $resultNode)) == FALSE)
|
4611
|
throw new Exception('error parsing datasource');
|
4612
|
if (($languagesNodes = $xpath -> query('./field[@name = "odlanguages"]/@value', $resultNode)) == FALSE)
|
4613
|
throw new Exception('error parsing datasource');
|
4614
|
if (($contentsNodes = $xpath -> query('./field[@name = "odcontenttypes"]/@value', $resultNode)) == FALSE)
|
4615
|
throw new Exception('error parsing datasource');
|
4616
|
if (($policiesNodes = $xpath -> query('./field[@name = "odpolicies"]/@value', $resultNode)) == FALSE)
|
4617
|
throw new Exception('error parsing datasource');
|
4618
|
if (($compatibilityNodes = $xpath -> query('./field[@name = "openairecompatibilityid"]/@value', $resultNode)) == FALSE)
|
4619
|
throw new Exception('error parsing datasource');
|
4620
|
if (($oaiPmhNodes = $xpath -> query('./field[@name = "accessinfopackage"]/@value', $resultNode)) == FALSE)
|
4621
|
throw new Exception('error parsing datasources');
|
4622
|
if (($descriptionNodes = $xpath -> query('./field[@nam = "oddescription"]/@value', $resultNode)) == FALSE)
|
4623
|
throw new Exception('error parsing datasource');
|
4624
|
$datasource = new JObject();
|
4625
|
$datasource -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue);
|
4626
|
$datasource -> englishName = (($englishNameNode = $englishNameNodes -> item(0)) == NULL) ? NULL : trim($englishNameNode -> nodeValue);
|
4627
|
$datasource -> url = (($urlNode = $urlNodes -> item(0)) == NULL) ? NULL : trim($urlNode -> nodeValue);
|
4628
|
$datasource -> logo = (($logoNode = $logoNodes -> item(0)) == NULL) ? NULL : trim($logoNode -> nodeValue);
|
4629
|
$datasource -> type = (($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue);
|
4630
|
$datasource -> items = (($itemsNode = $itemsNodes -> item(0)) == NULL) ? NULL : intval(trim($itemsNode -> nodeValue));
|
4631
|
$datasource -> date = (($dateNode = $dateNodes -> item(0)) == NULL) ? NULL : strtotime(trim($dateNode -> nodeValue));
|
4632
|
$datasource -> subjects = (($subjectsNode = $subjectsNodes -> item(0)) == NULL) ? NULL : trim($subjectsNode -> nodeValue);
|
4633
|
$datasource -> languages = (($languagesNode = $languagesNodes -> item(0)) == NULL) ? NULL : trim($languagesNode -> nodeValue);
|
4634
|
$datasource -> contents = (($contentsNode = $contentsNodes -> item(0)) == NULL) ? NULL : trim($contentsNode -> nodeValue);
|
4635
|
$datasource -> policies = (($policiesNode = $policiesNodes -> item(0)) == NULL) ? NULL : trim($policiesNode -> nodeValue);
|
4636
|
$datasource -> compatibility = (($compatibilityNode = $compatibilityNodes -> item(0)) == NULL) ? NULL : trim($compatibilityNode -> nodeValue);
|
4637
|
$datasource -> oaiPmh = (($oaiPmhNode = $oaiPmhNodes -> item(0)) == NULL) ? NULL : trim($oaiPmhNode -> nodeValue);
|
4638
|
$datasource -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue);
|
4639
|
return $datasource;
|
4640
|
}
|
4641
|
}
|
4642
|
|