get('thriftHost'), intval($parameters -> get('thriftPort'))); $socket -> setRecvTimeout(intval($parameters -> get('thriftTimeout'))); $this -> transport = new TBufferedTransport($socket); $this -> client = new OpenAIREConnectorClient(new TBinaryProtocol($this -> transport)); $this -> cache = JCache :: getInstance(); $this -> transport -> open(); } // Close Thrift transport. public function __destruct() { $this -> transport -> close(); } // Retrieve statistics using cache if enabled. // return statistics (object) public function getStatistics() { /* if ($this -> cache -> getCaching()) { $statistics = $this -> cache -> get(self :: STATISTICS_CACHE_ID, self :: CACHE_GROUP); if ($statistics === NULL) { $statistics = $this -> _getStatistics(); $this -> cache -> store($statistics, self :: STATISTICS_CACHE_ID, self :: CACHE_GROUP); } } else */ $statistics = $this -> _getStatistics(); return $statistics; } // Retrieve publications by access mode using cache if enabled. // return publications by access mode (array) public function getPublicationsByAccessMode() { /* if ($this -> cache -> getCaching()) { $publicationsByAccessMode = $this -> cache -> get(self :: PUBLICATIONS_BY_ACCESS_MODE_CACHE_ID, self :: CACHE_GROUP); if ($publications === NULL) { $publicationsByAccessMode = $this -> _getPublicationsByAccessMode(); $this -> cache -> store($publicationsByAccessMode, self :: PUBLICATIONS_BY_ACCESS_MODE_CACHE_ID, self :: CACHE_GROUP); } } else */ $publicationsByAccessMode = $this -> _getPublicationsByAccessMode(); return $publicationsByAccessMode; } // Retrieve publications by programme using cache if enabled. // limit the maximum number of programmes to retrieve // return publications by programme (array) public function getPublicationsByProgramme($limit) { /* if ($this -> cache -> getCaching()) { $id = self :: PUBLICATIONS_BY_PROGRAMME_CACHE_ID . '.' . $limit; $publicationsByProgramme = $this -> cache -> get($id, self :: CACHE_GROUP); if ($publicationsByProgramme === NULL) { $publicationsByProgramme = $this -> _getPublicationsByProgramme($limit); $this -> cache -> store($publicationsByProgramme, $id, self :: CACHE_GROUP); } } else */ $publicationsByProgramme = $this -> _getPublicationsByProgramme($limit); return $publicationsByProgramme; } // Retrieve publications by scientific area using cache if enabled. // limit the maximum number of scientific areas to retrieve // return publications by scientific area (array) public function getPublicationsByScientificArea($limit) { /* if ($this -> cache -> getCaching()) { $id = self :: PUBLICATIONS_BY_SCIENTIFIC_AREA_CACHE_ID . '.' . $limit; $publicationsByScientificArea = $this -> cache -> get($id, self :: CACHE_GROUP); if ($publicationsByScientificArea === NULL) { $publicationsByScientificArea = $this -> _getPublicationsByScientificArea($limit); $this -> cache -> store($publicationsByScientificArea, $limit, self :: CACHE_GROUP); } } else */ $publicationsByScientificArea = $this -> _getPublicationsByScientificArea($limit); return $publicationsByScientificArea; } // Retrieve publications by country using cache if enabled. // limit the maximum number of countries to retrieve // return publications by country (array) public function getPublicationsByCountry($limit) { /* if ($this -> cache -> getCaching()) { $id = self :: PUBLICATIONS_BY_COUNTRY_CACHE_ID . '.' . $limit; $publicationsByCountry = $this -> cache -> get($id, self :: CACHE_GROUP); if ($publicationsByCountry === NULL) { $publicationsByCountry = $this -> _getPublicationsByCountry($limit); $this -> cache -> store($publicationsByCountry, $id, self :: CACHE_GROUP); } } else */ $publicationsByCountry = $this -> _getPublicationsByCountry($limit); return $publicationsByCountry; } // Retrieve publications by institution using cache if enabled. // limit the maximum number of institutions to retrieve // return publications by institution (array) public function getPublicationsByInstitution($limit) { /* if ($this -> cache -> getCaching()) { $id = self :: PUBLICATIONS_BY_INSTITUTION_CACHE_ID . '.' . $limit; $publicationsByInstitution = $this -> cache -> get($id, self :: CACHE_GROUP); if ($publicationsByInstitution === NULL) { $publicationsByInstitution = $this -> _getPublicationsByInstitution($limit); $this -> cache -> store($publicationsByInstitution, $id, self :: CACHE_GROUP); } } else */ $publicationsByInstitution = $this -> _getPublicationsByInstitution($limit); return $publicationsByInstitution; } // Retrieve statistics. // return the statistics (object) or NULL if any errors occur private function _getStatistics() { try { $time = microtime(TRUE); $statistics = $this -> client -> getStatistics(); JLog :: add('Retrieved statistics in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); return $statistics; } catch (Exception $e) { JLog :: add('Error retrieving statistics: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Retrieve publications by access mode. // return publications by access mode (array) or NULL if any errors occur private function _getPublicationsByAccessMode() { try { $time = microtime(TRUE); $publicationsByAccessMode = $this -> client -> getPublicationsByAccessMode(); JLog :: add('Retrieved ' . count($publicationsByAccessMode) . ' publications by access mode entries in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); return $publicationsByAccessMode; } catch (Exception $e) { JLog :: add('Error retrieving publications by acces mode: ' . $e -> getMessage()); return NULL; } } // Retrieve publications by programme. // limit the maximum number of programmes to retrieve // return publications by programme (array) or NULL if any errors occur private function _getPublicationsByProgramme($limit) { try { $time = microtime(TRUE); $publicationsByProgramme = $this -> client -> getPublicationsByProgramme($limit); JLog :: add('Retrieved ' . count($publicationsByProgramme) . ' publications by programme entries in ' . (microtime(TRUE) - $time) . ' s (limit: ' . $limit . ')', JLog :: INFO, self :: LOG); return $publicationsByProgramme; } catch (Exception $e) { JLog :: add('Error retrieving publications by programme (limit: ' . $limit . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Retrieve publications by scientific area. // limit the maximum number of scientific areas to retrieve // return publications by scientific area (array) or NULL if any errors occur private function _getPublicationsByScientificArea($limit) { try { $time = microtime(TRUE); $publicationsByScientificArea = $this -> client -> getPublicationsByScientificArea($limit); JLog :: add('Retrieved ' . count($publicationsByScientificArea) . ' publications by scientific area entries in ' . (microtime(TRUE) - $time) . ' s (limit: ' . $limit . ')', JLog :: INFO, self :: LOG); return $publicationsByScientificArea; } catch (Exception $e) { JLog :: add('Error retrieving publications by scientific area (limit: ' . $limit . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Retrieve publications by country. // limit the maximum number of countries to retrieve // return publications by country (array) or NULL if any errors occur private function _getPublicationsByCountry($limit) { try { $time = microtime(TRUE); $publicationsByCountry = $this -> client -> getPublicationsByCountry($limit); JLog :: add('Retrieved ' . count($publicationsByCountry) . ' publications by country entries in ' . (microtime(TRUE) - $time) . ' s (limit: ' . $limit . ')', JLog :: INFO, self :: LOG); return $publicationsByCountry; } catch (Exception $e) { JLog :: add('Error retrieving publications by country (limit: ' . $limit . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Retrieve publications by institution. // limit the maximum number of institutions to retrieve // return publications by institution (array) or NULL if any errors occur private function _getPublicationsByInstitution($limit) { try { $time = microtime(TRUE); $publicationsByInstitution = $this -> client -> getPublicationsByInstitution($limit); JLog :: add('Retrieved ' . count($publicationsByInstitution) . ' publications by institution entries in ' . (microtime(TRUE) - $time) . ' s (limit: ' . $limit . ')', JLog :: INFO, self :: LOG); return $publicationsByInstitution; } catch (Exception $e) { JLog :: add('Error retrieving publications by institution (limit: ' . $limit . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } }