cache = JCache :: getInstance(); $this -> http = new JHttp(); $parameters = JComponentHelper :: getParams('com_openaire'); $socket = new TSocket($parameters -> 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 -> transport -> open(); } // Close Thrift transport public function __destruct() { $this -> transport -> close(); } // Get the selected projects stored in session. // return the selected projects (array) or NULL if any errors occur public function getSelectedProjects($suffix = self :: CLAIM) { try { $projects = unserialize(JFactory :: getSession() -> get(self :: SELECTED_PROJECTS . $suffix, serialize(array()))); JLog :: add('Retrieved ' . count($projects) . ' selected projects', JLog :: INFO, self :: LOG); return $projects; } catch (Exception $e) { JLog :: add('Error retrieving selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Add a project to the selected projects stored in session. // $project the project to add public function addSelectedProject($project, $suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $projects = unserialize($session -> get(self :: SELECTED_PROJECTS . $suffix, serialize(array()))); $projects[$project -> id] = $project; $session -> set(self :: SELECTED_PROJECTS . $suffix, serialize($projects)); JLog :: add('Added project ' . $project -> id . ' to selected projects', JLog :: INFO, self :: LOG); } catch (Exception $e) { JLog :: add('Error adding project ' . $project -> id . ' to selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); } } // Remove a project from the selected projects stored in session. // $projectId the identifier of the project to remove public function removeSelectedProject($projectId, $suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $projects = unserialize($session -> get(self :: SELECTED_PROJECTS . $suffix, serialize(array()))); unset($projects[$projectId]); $session -> set(self :: SELECTED_PROJECTS . $suffix, serialize($projects)); JLog :: add('Removed project ' . $projectId . ' from selected projects', JLog :: INFO, self :: LOG); } catch (Exception $e) { JLog :: add('Error removing project ' . $projectId . ' from selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); } } //empties selected concepts public function emptySelectedProjects($suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $session -> set(self :: SELECTED_PROJECTS . $suffix, serialize(array())); } catch (Exception $e) { ; } } //empties selected publications public function emptySelectedPublications($suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $session -> set(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array())); } catch (Exception $e) { ; } } //Get concept using id //returns concept object or error public function getConcept($conceptId, $withChildren = false){ $contexts = $this->getContexts(); $concept = new JObject(); $concept->context = new JObject(); $concept->category = new JObject(); $concept->concepts = array(); $concept->id = $conceptId; $data = explode("::", $conceptId); if (count($data) > 1){ list ($context, $category) = $data; $category = $context . "::" . $category; } else{ $context = $data[0]; $category = null; } if (!isset($contexts[$context])) return NULL; $concept->context->id = $context; $concept->context->name = $contexts[$context]->name; if ($category == null){ $concept->category = null; $concept->path = $this->getConceptPath($concept); return $concept; } if (!isset($contexts[$context]->categories[$category])) return NULL; $concept->category->id = $category; $concept->category->name = $contexts[$context]->categories[$category]->name; $concepts = $contexts[$context]->categories[$category]->concepts; $conceptId2 = $category; for ($i = 2; $i < count($data); $i++){ $conceptId2 = $conceptId2 . "::" . $data[$i]; $concept_s = new JObject(); $concept_s -> id = $conceptId2; $concept_s -> name = $concepts[$conceptId2] -> name; $concepts = isset($concepts[$conceptId2] -> concepts)?$concepts[$conceptId2] -> concepts:array(); $concept_s -> concepts = $concepts; $concept -> concepts[] = $concept_s; } $concept->path = $this->getConceptPath($concept); return $concept; } //Get concept using id //returns concept object or error public function getConceptPath($concept){ $path = $concept->context->name . ($concept->category != null?" > " . $concept->category->name:""); $concept_parts = array(); foreach ($concept -> concepts as $concept_part){ $concept_parts[] = $concept_part -> name; } $path = $path . (count($concept_parts)?" > " . implode(" > ", $concept_parts):""); return $path; } // Get the selected concepts stored in session. // return the selected concepts (array) or NULL if any errors occur public function getSelectedConcepts($suffix = self :: CLAIM) { try { $concepts = unserialize(JFactory :: getSession() -> get(self :: SELECTED_CONCEPTS . $suffix, serialize(array()))); JLog :: add('Retrieved ' . count($concepts) . ' selected concepts', JLog :: INFO, self :: LOG); return $concepts; } catch (Exception $e) { JLog :: add('Error retrieving selected concepts: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Add a project to the selected projects stored in session. // $project the project to add public function addSelectedConcept($concept, $suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $concepts = unserialize($session -> get(self :: SELECTED_CONCEPTS . $suffix, serialize(array()))); $concepts[$concept -> id] = $concept; $session -> set(self :: SELECTED_CONCEPTS . $suffix, serialize($concepts)); JLog :: add('Added project ' . $concept -> id . ' to selected projects', JLog :: INFO, self :: LOG); } catch (Exception $e) { JLog :: add('Error adding project ' . $concept -> id . ' to selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); } } // Remove a project from the selected projects stored in session. // $projectId the identifier of the project to remove public function removeSelectedConcept($conceptId, $suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $concepts = unserialize($session -> get(self :: SELECTED_CONCEPTS . $suffix, serialize(array()))); unset($concepts[$conceptId]); $session -> set(self :: SELECTED_CONCEPTS . $suffix, serialize($concepts)); JLog :: add('Removed project ' . $conceptId . ' from selected projects', JLog :: INFO, self :: LOG); } catch (Exception $e) { JLog :: add('Error removing project ' . $conceptId . ' from selected projects: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); } } //empties selected concepts public function emptySelectedConcepts($suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $session -> set(self :: SELECTED_CONCEPTS . $suffix, serialize(array())); } catch (Exception $e) { ; } } // Get the selected publications stored in session. // return the selected publications (arary) or NULL if any errors occur public function getSelectedPublications($suffix = self :: CLAIM) { try { $publications = unserialize(JFactory :: getSession() -> get(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array()))); JLog :: add('Retrieved ' . count($publications) . ' selected publications', JLog :: INFO, self :: LOG); return $publications; } catch (Exception $e) { JLog :: add('Error retrieving selected publications: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Add a publication to the selected publications stored in session. // $publication the publication to add public function addSelectedPublication($publication, $suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $publications = unserialize($session -> get(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array()))); $publications[$publication -> source . $publication -> id] = $publication; $session -> set(self :: SELECTED_PUBLICATIONS . $suffix, serialize($publications)); JLog :: add('Added ' . $publication -> source . ' publication ' . $publication -> id . ' to selected publications', JLog :: INFO, self :: LOG); } catch (Exception $e) { JLog :: add('Error adding ' . $publication -> source . ' publication ' . $publication -> id . ' to selected publications: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); } } // Remove a publication from the selected publications stored in session. // $source the source of the publication to remove // $publicationId the identifier of the publication to remove public function removeSelectedPublication($source, $publicationId, $suffix = self :: CLAIM) { try { $session = JFactory :: getSession(); $publications = unserialize($session -> get(self :: SELECTED_PUBLICATIONS . $suffix, serialize(array()))); unset($publications[$source . $publicationId]); $session -> set(self :: SELECTED_PUBLICATIONS. $suffix, serialize($publications)); JLog :: add('Removed ' . $source . ' publication ' . $publicationId . ' from selected publications', JLog :: INFO, self :: LOG); } catch (Exception $e) { JLog :: add('Error removing ' . $source . ' publication ' . $publicationId . ' from selected publications: ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); } } // Claim all the selected publications. // $user the user to claim publications for public function claimSelectedPublications($user, $mode = self :: CLAIM, $activePublication = NULL, $suffix = "", $activePublicationType = "publication") { try { $projects = array_map(function ($project) { $p = array(); $p['projectId'] = $project -> id; $p['funder'] = $project -> funder; $p['fundingStreamLevel0'] = $project -> fundingStream; $p['fundingStreamLevel1'] = $project -> scientificArea; $p['fundingStreamLevel2'] = $project -> fundingStreamLevel2; $p['name'] = $project -> title; $p['code'] = $project -> code; $p['acronym'] = $project -> acronym; $p['type'] = NULL; return new Project4Index($p);}, $this -> getSelectedProjects($mode.$suffix)); $projects_mini = array_map(function ($project) { $project2 = new Project(); $project2 -> projectId = $project -> id; $project2 -> type = NULL; return $project2;}, $this -> getSelectedProjects($mode.$suffix)); $concepts = array_map(function ($concept) {return $concept -> id;}, $this -> getSelectedConcepts($mode.$suffix)); if ($mode != self :: CLAIMINLINE){ $selectedPublications = $this -> getSelectedPublications($mode.$suffix); } else { $selectedPublications = array($activePublication); } $dcSource = NULL; $subjects = array(); $category = NULL; foreach ($selectedPublications as $publication) { $authors = array_map(function ($author) { $a = array(); $a['id'] = $author -> id; $a['firstName'] = $author -> firstName; $a['lastName'] = $author -> lastName; if (($author -> lastName == NULL) && ($author -> fullName != NULL)) $a['lastName'] = $author -> fullName; return new Author($a); }, $publication -> authors); $doi = (($publication -> source == self :: DOI) || ($publication -> source == self :: DATACITE)) ? $publication -> id : NULL; if ($mode != self :: CLAIMINLINE and $publication -> source != "openaire"){ JLog :: add("Projects--->". print_r($projects,true), JLog :: DEBUG, self :: LOG); JLog :: add("Concepts--->". print_r($concepts,true), JLog :: DEBUG, self :: LOG); $docId = $this -> client -> insertDocument($publication -> id, $publication -> source, $publication -> title, $publication -> description, isset($publication -> license)?$publication -> license:"", $publication -> embargoEndDate, $authors, $publication -> url, $dcSource, $user -> email, $subjects, $publication -> year, $publication -> publisher, $publication -> language, $category, $doi, $projects, $concepts); }else{ $docId = $publication->id; } foreach ($concepts as $concept) $this -> client -> insertConcept($docId, $publication -> source, $concept, $user -> email, $doi ); foreach ($projects_mini as $project){ //TODO Check if project is ok after $this -> client -> insertProjectRelation($docId, $publication -> source, $project, $user -> email); } if ($activePublication != NULL && $mode === self::CLAIMINLINE2){ $this -> client -> insertResultRelation($activePublication -> id, $activePublicationType, $activePublication -> source, $docId, $publication -> claim_type, $user -> email); } } if ($this -> cache -> getCaching()){ $cacheId = self :: CLAIMED_PUBLICATIONS_CACHE_ID . '.' . $user -> username; $this -> cache ->remove($cacheId); } JLog :: add('Claimed ' . count($selectedPublications) . ' publications (user: ' . $user -> username . ')', JLog :: INFO, self :: LOG); return true; } catch (Exception $e) { JLog :: add('Error claiming selected publications (user: ' . $user -> username . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return false; } } // Get the publications claimed by a user using caching if enabled. // $user the user whose claimed publications to retrieve // return an array of publications public function getClaimedPublications($user) { /* if ($this -> cache -> getCaching()) { $cacheId = self :: CLAIMED_PUBLICATIONS_CACHE_ID . '.' . $user -> username; $publications = $this -> cache -> get($cacheId, self :: CACHE_GROUP); if ($publications === FALSE) { $publications = $this -> _getClaimedPublications($user); if ($publications !== NULL) $this -> cache -> store($publications, $cacheId, self :: CACHE_GROUP); } } else */ $publications = $this -> _getClaimedPublications($user); return $publications; } // Get the publications claimed by a user using caching if enabled. // $user the user whose claimed publications to retrieve // return an array of publications public function getAllClaimedPublications($from, $to) { /*if ($this -> cache -> getCaching()) { $cacheId = self :: CLAIMED_PUBLICATIONS_CACHE_ID . '.' . $from . "." . $to; $publications = $this -> cache -> get($cacheId, self :: CACHE_GROUP); if ($publications === FALSE) { $publications = $this -> _getAllClaimedPublications($from, $to); if ($publications !== NULL) $this -> cache -> store($publications, $cacheId, self :: CACHE_GROUP); } } else*/ $publications = $this -> _getAllClaimedPublicationsExtended($from, $to); return $publications; } // Get the publications claimed by a user. // $user the user whose claimed publications to retrieve // return an array of publications or NULL if any errors occur private function _getClaimedPublications($user) { try { $locale = JFactory :: getLanguage()->getTag(); $claimedPublications = array(); $claimedPublicationsGrouped = array(); $time = microtime(TRUE); $claims = $this -> client -> getClaimedPublications($user -> email); foreach ($claims as $claim){ $parsedClaim = $this -> parseClaimedPublication($claim); if ($parsedClaim == null) continue; $claimedPublications[] = $parsedClaim; } $resultsToGet = array(); $projectsToGet = array(); $claimedDocuments = array(); foreach ($claimedPublications as $claimedPublication){ if ($claimedPublication -> publication != null and $claimedPublication -> publication -> id != null) $claimedDocuments[$claimedPublication->publicationId] = $claimedPublication -> publication; if ($claimedPublication -> projectId !== null){ $projectsToGet[] = $claimedPublication -> projectId; } if ($claimedPublication -> targetPublicationId !== null){ $resultsToGet[] = $claimedPublication -> targetPublicationId; } if ($claimedPublication -> targetDatasetId !== null){ $resultsToGet[] = $claimedPublication -> targetDatasetId; } if (($claimedPublication -> publication == null || ($claimedPublication -> publication != null and $claimedPublication -> publication -> id == null))){ $resultsToGet[] = $claimedPublication -> publicationId; } if ($claimedPublication -> publication == null && $claimedPublication -> type == "dataset"){ $resultsToGet[] = $claimedPublication -> publicationId; } } $resultsToGet = array_unique($resultsToGet); $projectsToGet = array_unique($projectsToGet); $searchModel = new OpenAireModelSearch(); $results = $searchModel->getResults($resultsToGet, $locale); $projects = $searchModel->getProjects($projectsToGet, $locale); $keydResults = array(); $keydProjects = array(); foreach ($results as $result) $keydResults[$result->id] = $result; foreach ($projects as $project) $keydProjects[$project->id] = $project; foreach ($claimedPublications as $claimedPublication){ if (!isset($claimedPublicationsGrouped[$claimedPublication -> publicationId])){ if ($claimedPublication -> publication == null || $claimedPublication -> publication -> id == null){ $publication = isset($keydResults[$claimedPublication -> publicationId])?$keydResults[$claimedPublication -> publicationId]:null; } else{ $publication = $claimedPublication -> publication; } if ($publication == null || $publication -> id == null) continue; $claimedPublicationsGrouped[$claimedPublication -> publicationId] = new stdClass(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publicationId = $claimedPublication -> publicationId; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date = $claimedPublication -> date; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publication = $publication; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publications = array(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> datasets = array(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> projects = array(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts = array(); } if ($claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date < $claimedPublication -> date) $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date = $claimedPublication -> date; if ($claimedPublication -> publication != null){ $claimedConcepts = array(); foreach ($claimedPublication -> publication -> concepts as $concept){ $concept = $this->getConcept($concept); $claimedConcept = new stdClass(); $claimedConcept->id = $concept->id; $claimedConcept->title = $concept->path; $claimedConcept->date = $claimedPublication->date; $claimedConcepts[] = $claimedConcept; } $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts = array_merge($claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts, $claimedConcepts); } if ($claimedPublication -> targetPublicationId !== null){ $claimedPublication->title = isset($keydResults[$claimedPublication -> targetPublicationId ])?$keydResults[$claimedPublication -> targetPublicationId ]->title:null; if ($claimedPublication->title == null){ $claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; } $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publications[] = $claimedPublication; } if ($claimedPublication -> targetDatasetId !== null){ $claimedPublication->title = isset($keydResults[$claimedPublication -> targetDatasetId ])?$keydResults[$claimedPublication -> targetDatasetId ]->title:null; if ($claimedPublication->title == null){ $claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; } $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> datasets[] = $claimedPublication; } if ($claimedPublication -> projectId !== null){ $claimedPublication->title = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->title:null; $claimedPublication->acronym = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->acronym:null; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> projects[] = $claimedPublication; } } JLog :: add('Retrieved ' . count($claimedPublications) . ' claimed publications (user: ' . $user -> username . ') in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); return $claimedPublicationsGrouped; } catch (Exception $e) { JLog :: add('Error retrieving claimed publications (user: ' . $user -> username . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } public function _getAllClaimedPublications($from, $to) { try { // submit the docs $claimedPublications = array(); $time1 = strtotime(str_replace("/", "-", $from)) * 1000; $time2 = strtotime(str_replace("/", "-", $to)) * 1000; $list = $this->client ->getAllClaimedPublications($time1, $time2); foreach ($list as $claim){ $claimedPublications[] = $this -> parseClaimedPublication($claim); } } catch (Exception $e) { JLog :: add('Error retrieving all claims (from: ' . $from . ', to: '. $to .'): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } return $claimedPublications; } // Get the publications claimed // return an array of publications or NULL if any errors occur private function _getAllClaimedPublicationsExtended($from, $to) { try { $locale = JFactory :: getLanguage()->getTag(); $claimedPublications = array(); $claimedPublicationsExtended = array(); $time = microtime(TRUE); $time1 = strtotime(str_replace("/", "-", $from)) * 1000; $time2 = strtotime(str_replace("/", "-", $to)) * 1000; $claims = $this->client ->getAllClaimedPublications($time1, $time2); foreach ($claims as $claim){ $parsedClaim = $this -> parseClaimedPublication($claim); if ($parsedClaim == null) continue; $claimedPublications[] = $parsedClaim; } $resultsToGet = array(); $projectsToGet = array(); $claimedDocuments = array(); foreach ($claimedPublications as $claimedPublication){ if ($claimedPublication -> publication != null and $claimedPublication -> publication -> id != null) $claimedDocuments[$claimedPublication->publicationId] = $claimedPublication -> publication; if ($claimedPublication -> projectId !== null){ $projectsToGet[] = $claimedPublication -> projectId; } if ($claimedPublication -> targetPublicationId !== null){ $resultsToGet[] = $claimedPublication -> targetPublicationId; } if ($claimedPublication -> targetDatasetId !== null){ $resultsToGet[] = $claimedPublication -> targetDatasetId; } if (($claimedPublication -> publication == null || ($claimedPublication -> publication != null and $claimedPublication -> publication -> id == null))){ $resultsToGet[] = $claimedPublication -> publicationId; } if ($claimedPublication -> publication == null && $claimedPublication -> type == "dataset"){ $resultsToGet[] = $claimedPublication -> publicationId; } } $resultsToGet = array_unique($resultsToGet); $projectsToGet = array_unique($projectsToGet); $searchModel = new OpenAireModelSearch(); $results = $searchModel->getResults($resultsToGet, $locale); $projects = $searchModel->getProjects($projectsToGet, $locale); $keydResults = array(); $keydProjects = array(); foreach ($results as $result) $keydResults[$result->id] = $result; foreach ($projects as $project) $keydProjects[$project->id] = $project; foreach ($claimedPublications as $claimedPublication){ /* if ($claimedPublication -> publication == null || $claimedPublication -> publication -> id == null){ //print_r($claimedPublication -> publication -> concepts); $claimedPublication -> publication = isset($keydResults[$claimedPublication -> publicationId])?$keydResults[$claimedPublication -> publicationId]:null; } */ $claimedPublication->targetConceptId=null; if ($claimedPublication -> publication != null && isset($claimedPublication -> publication -> concepts )){ $claimedConcepts = array(); foreach ($claimedPublication -> publication -> concepts as $concept){ $concept = $this->getConcept($concept); $claimedConcept = new stdClass(); $claimedConcept->id = $concept->id; $claimedConcept->title = $concept->path; $claimedConcept->date = $claimedPublication->date; $claimedConcepts[] = $claimedConcept; $claimedPublication->title=$concept->path; $claimedPublication->targetConceptId= $concept->id; } $claimedPublication -> concepts= $claimedConcepts; } if ($claimedPublication -> targetPublicationId !== null){ $claimedPublication->title = isset($keydResults[$claimedPublication -> targetPublicationId ])?$keydResults[$claimedPublication -> targetPublicationId ]->title:null; if ($claimedPublication->title == null){ $claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; } } if ($claimedPublication -> targetDatasetId !== null){ $claimedPublication->title = isset($keydResults[$claimedPublication -> targetDatasetId ])?$keydResults[$claimedPublication -> targetDatasetId ]->title:null; if ($claimedPublication->title == null){ $claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; } } if ($claimedPublication -> projectId !== null){ $claimedPublication->title = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->title:null; $claimedPublication->acronym = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->acronym:null; } if ($claimedPublication -> publication == null || $claimedPublication -> publication -> id == null){ //print_r($claimedPublication -> publication -> concepts); $claimedPublication -> publication = isset($keydResults[$claimedPublication -> publicationId])?$keydResults[$claimedPublication -> publicationId]:null; } } JLog :: add('Retrieved ' . count($claimedPublications) . ' claimed publications in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); return $claimedPublications; } catch (Exception $e) { JLog :: add('Error retrieving claimed publications (user: ' . $user -> username . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } private function parseClaimedPublication($claim) { $claimedPublication = new JObject(); $claimedPublication -> date = $claim -> date; $claimedPublication -> claimType=$claim -> type; $claimedPublication -> claimId=isset($claim -> id)?$claim -> id:''; $document = new DOMDocument(); $document -> recover = TRUE; if ($document -> loadXML(trim($claim -> xml)) == FALSE) throw new Exception('invalid XML response'); $xPath = new DOMXPath($document); switch ($claim -> type) { case self :: RELATION: if ((($relationNodes = $xPath -> query('/RELATIONS/RELATION')) == FALSE) || (($relationNode = $relationNodes -> item(0)) == NULL)) throw new Exception('error parsing relation'); if ((($sourceNodes = $xPath -> query('./@source', $relationNode)) == FALSE) || (($sourceNode = $sourceNodes -> item(0)) == NULL)) throw new Exception('error parsing relation source'); if ((($targetNodes = $xPath -> query('./@target', $relationNode)) == FALSE) || (($targetNode = $targetNodes -> item(0)) == NULL)) throw new Exception('error parsing relation target'); if ((($relationTypeNodes = $xPath -> query('./@type', $relationNode)) == FALSE) || (($relationTypeNode = $relationTypeNodes -> item(0)) == NULL)) throw new Exception('error parsing relation type'); $claimedPublication -> projectId = NULL; $claimedPublication -> targetDatasetId = NULL; $claimedPublication -> targetPublicationId = NULL; $claimedPublication -> date = $claim -> date; $claimedPublication -> type = "publication"; if ($relationTypeNode -> nodeValue == "resultProject"){ $claimedPublication -> projectId = trim(str_replace("40|", "", $targetNode -> nodeValue)); $claimedPublication -> type = "publication"; } else if ($relationTypeNode -> nodeValue == "resultResult_publicationpublication_isRelatedTo"){ $sourceNode -> nodeValue = str_replace("50|", "", $sourceNode -> nodeValue); $claimedPublication -> targetPublicationId = trim(str_replace("50|", "", $targetNode -> nodeValue)); $claimedPublication -> type = "publication"; } else if ($relationTypeNode -> nodeValue == "resultResult_publicationdataset_isRelatedTo"){ $sourceNode -> nodeValue = str_replace("50|", "", $sourceNode -> nodeValue); $claimedPublication -> targetDatasetId = trim(str_replace("50|", "", $targetNode -> nodeValue)); $claimedPublication -> type = "publication"; } else if ($relationTypeNode -> nodeValue == "resultResult_datasetpublication_isRelatedTo"){// openaire dataset me publ $sourceNode -> nodeValue = str_replace("50|", "", $sourceNode -> nodeValue); $claimedPublication -> targetPublicationId = trim(str_replace("50|", "", $targetNode -> nodeValue)); $claimedPublication -> type = "dataset"; } else if ($relationTypeNode -> nodeValue == "resultResult_datasetdataset_isRelatedTo"){// openaire dataset me ext dataset $sourceNode -> nodeValue = str_replace("50|", "", $sourceNode -> nodeValue); $claimedPublication -> targetDatasetId = trim(str_replace("50|", "", $targetNode -> nodeValue)); $claimedPublication -> type = "dataset"; } else { return null; } $claimedPublication -> publication = NULL; $claimedPublication -> publicationId = str_replace("50|", "",trim($sourceNode -> nodeValue)); $claimedPublication -> userEmail = $claim -> userEmail; break; case self :: DMF: $claimedPublication -> targetDatasetId = NULL; $claimedPublication -> targetPublicationId = NULL; $claimedPublication -> date = $claim -> date; $claimedPublication -> publication = $this -> parseDMF($xPath); $claimedPublication -> publicationId = $claim->resultid; $claimedPublication -> projectId = NULL; $claimedPublication -> userEmail = $claim -> userEmail; break; case self :: UPDATES2ACTIONS: $claimedPublication -> targetDatasetId = NULL; $claimedPublication -> targetPublicationId = NULL; $claimedPublication -> date = $claim -> date; $claimedPublication -> publication = $this -> parseDMF($xPath); $claimedPublication -> publicationId = $claim->resultid; $claimedPublication -> projectId = NULL; $claimedPublication -> userEmail = $claim -> userEmail; break; } return $claimedPublication; } private function parseDMF($xpath) { $xpath -> registerNamespace('openaire', 'http://namespace.openaire.eu/'); $xpath -> registerNamespace('dc', 'http://purl.org/dc/elements/1.1/'); $xpath -> registerNamespace('oaf', 'http://namespace.openaire.eu/oaf'); $xpath -> registerNamespace('dr', 'http://www.driver-repository.eu/namespace/dr'); $conceptNodes = $xpath -> query('/record/openaire:metadata/oaf:concept/@id'); $publication = new JObject(); $publication -> id = NULL; $publication -> source = NULL; $publication -> languages = array(); $publication -> url = NULL; $publication -> authors = array(); $publication -> subjects = array(); $publication -> concepts = array(); $publication -> embargoEndDate = NULL; $publication -> datasources = array(); $publication -> collectedFrom = array(); $publication -> sources = array(); $publication -> projects = array(); $publication -> pids = array(); $publication -> relatedPublications = array(); $publication -> relatedDatasets = array(); $publication -> externalPublications = array(); $publication -> externalDatasets = array(); if (($identifierNodes = $xpath -> query('/record/openaire:metadata/dc:identifier|/record/openaire:metadata/oaf:identifier')) == FALSE){ //throw new Exception('error parsing DMF'); } if (($accessModeNodes = $xpath -> query('/record/openaire:metadata/oaf:accessrights/text()')) == FALSE){ //throw new Exception('error parsing DMF'); } if (($titleNodes = $xpath -> query('/record/openaire:metadata/dc:title/text()')) == FALSE){ //throw new Exception('error parsing DMF'); } if (($authorNodes = $xpath -> query('/record/openaire:metadata/dc:creator/text()')) == FALSE){ //throw new Exception('error parsing DMF'); } if (($dateNodes = $xpath -> query('/record/openaire:metadata/dc:dateAccepted/text()')) == FALSE){ //throw new Exception('error parsing DMF'); } if (($publisherNodes = $xpath -> query('/record/openaire:metadata/dc:publisher/text()')) != FALSE){ $publication -> publisher = (($publisherNode = $publisherNodes -> item(0)) == NULL) ? NULL : trim($publisherNode -> nodeValue); } if (($languageNodes = $xpath -> query('/record/openaire:metadata/dc:language/text()')) != FALSE){ foreach ($languageNodes as $languageNode) { if ((($language = trim($languageNode -> nodeValue)) != NULL) && ($language != self :: UNDETERMINED)) $publication -> languages[] = $language; } } if (($typeNodes = $xpath -> query('/record/openaire:metadata/dr:CObjCategory/text()')) != FALSE){ $publication -> type = (($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue); } if (($descriptionNodes = $xpath -> query('/record/openaire:metadata/dc:description/text()')) != FALSE){ $publication -> description = (($descriptionNode = $descriptionNodes -> item(0)) == NULL) ? NULL : trim($descriptionNode -> nodeValue); } if (($datasourceNodes = $xpath -> query('/record/openaire:metadata/oaf:hostedBy')) != FALSE){ foreach ($datasourceNodes as $datasourceNode) { if (($idNodes = $xpath -> query('./@id', $datasourceNode)) == FALSE){ //throw new Exception('error parsing DMF'); } if (($nameNodes = $xpath -> query('./@name', $datasourceNode)) == FALSE){ //throw new Exception('error parsing DMF'); } $datasource = new JObject(); $datasource -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue); $datasource -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue); $datasource -> url = NULL; $datasource -> accessMode = NULL; if (($datasource -> id != NULL) || ($datasource -> name != NULL)) $publication -> datasources[] = $datasource; } } if (($collectedFromNodes = $xpath -> query('/record/openaire:metadata/oaf:collectedFrom')) != FALSE){ foreach ($collectedFromNodes as $collectedFromNode) { if (($idNodes = $xpath -> query('./@id', $collectedFromNode)) == FALSE){ //throw new Exception('error parsing DMF'); } if (($nameNodes = $xpath -> query('./@name', $collectedFromNode)) == FALSE){ //throw new Exception('error parsing DMF'); } $collectedFrom = new JObject(); $collectedFrom -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue); $collectedFrom -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue); if (($collectedFrom -> id != NULL) || ($collectedFrom -> name != NULL)) $publication -> collectedFrom[] = $collectedFrom; } } if (($sourceNodes = $xpath -> query('/record/openaire:metadata/dc:source/text()')) != FALSE){ foreach ($sourceNodes as $sourceNode) { if (($source = trim($sourceNode -> nodeValue)) != NULL) $publication -> sources[] = $source; } } if (($projectNodes = $xpath -> query('/record/openaire:metadata/oaf:projectid/text()')) != FALSE){ foreach ($projectNodes as $projectNode) { $project = new JObject(); $project -> id = trim($projectNode -> nodeValue); $project -> acronym = NULL; $project -> title = NULL; $project -> code = NULL; if ($project -> id != NULL) $publication -> projects[] = $project; } } $publication -> accessMode = (($accessModeNode = $accessModeNodes -> item(0)) == NULL) ? NULL : trim($accessModeNode -> nodeValue); $publication -> title = (($titleNode = $titleNodes -> item(0)) == NULL) ? NULL : trim($titleNode -> nodeValue); $publication -> year = (($dateNode = $dateNodes -> item(0)) == NULL) ? NULL : intval(trim($dateNode -> nodeValue)); $publication -> date = ($dateNode == NULL) ? NULL : strtotime(trim($dateNode -> nodeValue)); if ($conceptNodes !== false){ foreach ($conceptNodes as $conceptNode) { $publication -> concepts[] = trim($conceptNode -> nodeValue); } } foreach ($authorNodes as $authorNode) { if (($idNodes = $xpath -> query('./field[@name = "personId"]/@value', $authorNode)) == FALSE){ // throw new Exception('error parsing publication'); } if (($fullNameNodes = $xpath -> query('./field[@name = "fullname"]/@value', $authorNode)) == FALSE){ // throw new Exception('error parsing publication'); } if (($rankingNodes = $xpath -> query('./field[@name = "ranking"]/@value', $authorNode)) == FALSE){ //throw new Exception('error parsing publication'); } $author = new JObject(); $author -> id = NULL; $author -> lastName = NULL; $author -> firstName = NULL; $author -> fullName = trim($authorNode -> nodeValue); $author -> ranking = 0; if ($author -> fullName != NULL) $publication -> authors[] = $author; usort($publication -> authors, function ($author1, $author2) {return $author1 -> ranking - $author2 -> ranking;}); } foreach ($identifierNodes as $identifierNode) { $pid = new JObject(); $pid -> clazz=NULL; $pid -> value=NULL; if (($typeNodes = $xpath -> query('./@identifierType', $identifierNode)) != FALSE) $pid -> clazz = (($typeNode = $typeNodes -> item(0)) == NULL) ? NULL : trim($typeNode -> nodeValue); if (($textNodes = $xpath -> query('./text()', $identifierNode)) != FALSE) $pid -> value = (($textNode = $textNodes -> item(0)) == NULL) ? NULL : trim($textNode -> nodeValue); if ($pid -> value != NULL) { if ($pid -> clazz == NULL && strpos($pid -> value , 'http') !==false){ $publication -> url = $pid -> value; }else if ($pid -> clazz == NULL && strpos($pid -> value , 'http')===false ){ $publication -> id = $pid -> value; $publication -> source = 'other'; $publication -> pids[] = $pid; } else if($pid -> clazz != NULL){ $publication -> id = $pid -> value; $publication -> source = $pid -> clazz; $publication -> pids[] = $pid; } } } return $publication; } private function _parseContextsConcepts($conceptNodes, &$parent, $xpath){ foreach ($conceptNodes as $conceptNode) { if (($includeNodes = $xpath -> query('./@claim', $conceptNode)) == FALSE) throw new Exception('error parsing publication'); if (($idNodes = $xpath -> query('./@id', $conceptNode)) == FALSE) throw new Exception('error parsing publication'); if (($nameNodes = $xpath -> query('./@label', $conceptNode)) == FALSE) throw new Exception('error parsing publication'); if (($subConceptNodes = $xpath -> query('./concept', $conceptNode)) == FALSE) throw new Exception('error parsing publication'); $concept = new JObject(); $concept -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue); $concept -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue); $concept -> claim = (($includeNode = $includeNodes -> item(0)) == NULL) ? NULL : trim($includeNode -> nodeValue); if ($concept -> claim != NULL){ $concept -> claim = ($concept -> claim == "true") ? true : false; } $concept -> concepts = array(); $this->_parseContextsConcepts($subConceptNodes, $concept -> concepts, $xpath); if (($concept -> id != NULL) || ($concept -> name != NULL)) $parent[$concept -> id] = $concept; } } public function parseContexts($context_source){ $document = new DOMDocument(); $document -> recover = TRUE; if ($document -> loadXML($context_source) == FALSE) throw new Exception('invalid XML response'); $xpath = new DOMXPath($document); if ((($configurationNodes = $xpath -> query('./BODY/CONFIGURATION')) == FALSE) || (($configurationNode = $configurationNodes -> item(0)) == NULL)) throw new Exception('error parsing contexts'); if (($contextNodes = $xpath -> query('./context', $configurationNode)) == FALSE) throw new Exception('error parsing contexts'); $contexts = array(); foreach ($contextNodes as $contextNode) { if (($includeNodes = $xpath -> query('./@claim', $contextNode)) == FALSE) throw new Exception('error parsing publication'); if (($idNodes = $xpath -> query('./@id', $contextNode)) == FALSE) throw new Exception('error parsing publication'); if (($nameNodes = $xpath -> query('./@label', $contextNode)) == FALSE) throw new Exception('error parsing publication'); if (($categoryNodes = $xpath -> query('./category', $contextNode)) == FALSE) throw new Exception('error parsing publication'); $context = new JObject(); $context -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue); $context -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue); $context -> claim = (($includeNode = $includeNodes -> item(0)) == NULL) ? NULL : trim($includeNode -> nodeValue); if ($context -> claim != NULL){ $context -> claim = ($context -> claim == "true") ? true : false; } $context -> categories = array(); foreach ($categoryNodes as $categoryNode) { if (($includeNodes = $xpath -> query('./@claim', $categoryNode)) == FALSE) throw new Exception('error parsing publication'); if (($idNodes = $xpath -> query('./@id', $categoryNode)) == FALSE) throw new Exception('error parsing publication'); if (($nameNodes = $xpath -> query('./@label', $categoryNode)) == FALSE) throw new Exception('error parsing publication'); if (($conceptNodes = $xpath -> query('./concept', $categoryNode)) == FALSE) throw new Exception('error parsing publication'); $category = new JObject(); $category -> id = (($idNode = $idNodes -> item(0)) == NULL) ? NULL : trim($idNode -> nodeValue); $category -> name = (($nameNode = $nameNodes -> item(0)) == NULL) ? NULL : trim($nameNode -> nodeValue); $category -> claim = (($includeNode = $includeNodes -> item(0)) == NULL) ? NULL : trim($includeNode -> nodeValue); if ($category -> claim != NULL){ $category -> claim = ($category -> claim == "true") ? true : false; } $category -> concepts = array(); $this->_parseContextsConcepts($conceptNodes, $category -> concepts, $xpath); if ((($category -> id != NULL) || ($category -> name != NULL) || ($category -> concepts != NULL) ) && ( $category -> claim!= null && $category -> claim == true)) $context -> categories[$category -> id] = $category; } if ((($context -> id != NULL) || ($context -> name != NULL)) && ($context -> categories != NULL && sizeof($context -> categories)>0)) $contexts[$context -> id] = $context; } return $contexts; } public function getContexts() { try { $time = microtime(TRUE); $contexts = $this -> client -> getContexts(); if(!isset($contexts[0])){ throw new Exception('error retrieving contexts:'. print_r($contexts,true)); } $parsedContexts = array(); foreach($contexts as $context){ $parsedContexts = array_merge($parsedContexts, $this -> parseContexts($context)); } $contexts= $parsedContexts; JLog :: add('Retrieved ' . count($contexts) . ' contexts in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); return $contexts; } catch (Exception $e) { JLog :: add('Error retrieving contexts ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Get the publications claimed by a user using caching if enabled. // $user the user whose claimed publications to retrieve // return an array of publications public function getClaimedDocsByUser($user) { try { $time = microtime(TRUE); $claimedDocs = $this -> client -> getClaimedPublications($user -> email); $publications = $this -> parseClaimedDocs($claimedDocs); JLog :: add('Retrieved ' . count($publications) . ' claimed publications (user: ' . $user -> username . ') in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); return $publications; } catch (Exception $e) { JLog :: add('Error retrieving claimed publications (user: ' . $user -> username . '): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } // Get the publications claimed by a user using caching if enabled. // $user the user whose claimed publications to retrieve // return an array of publications public function getClaimedDocsByTime($from, $to) { try { $time = microtime(TRUE); $time1 = strtotime(str_replace("/", "-", $from)) * 1000; $time2 = (strtotime(str_replace("/", "-", $to.' 23:59:59' ))) * 1000; $claimedDocs = $this->client ->getAllClaimedPublications($time1, $time2); $publications = $this -> parseClaimedDocs($claimedDocs); JLog :: add('Retrieved ' . count($claimedDocs) .' Parsed ' . count($publications) . ' claimed publications(from: ' . $from . ', to: '. $to .') in ' . (microtime(TRUE) - $time) . ' s', JLog :: INFO, self :: LOG); JLog :: add('Time1 : '.strtotime(str_replace("/", "-", $from)).' from: ' . $time1 . ', to :'. strtotime(str_replace("/", "-", $to)).' time2: '. $time2 .') time: '.$time , JLog :: INFO, self :: LOG); return $publications; } catch (Exception $e) { JLog :: add('Error retrieving all claims (from: ' . $from . ', to: '. $to .'): ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); return NULL; } } public function deleteClaim($email, $id) { try { $this->client ->deleteClaim($email, $id); JLog :: add('Deleting claim', JLog :: INFO, self :: LOG); } catch (Exception $e) { JLog :: add('Error deleting claim ' . $e -> getMessage(), JLog :: ERROR, self :: LOG); } } public function parseClaimedDocs($claimedDocs ) { $locale = JFactory :: getLanguage()->getTag(); $claimedPublications = array(); $claimedPublicationsGrouped = array(); $time = microtime(TRUE); foreach ($claimedDocs as $claim){ $parsedClaim = $this -> parseClaimedPublication($claim); if ($parsedClaim == null){ continue; } $claimedPublications[] = $parsedClaim; } $resultsToGet = array(); $projectsToGet = array(); $claimedDocuments = array(); foreach ($claimedPublications as $claimedPublication){ if ($claimedPublication -> publication != null and $claimedPublication -> publication -> id != null){ $claimedDocuments[$claimedPublication->publicationId] = $claimedPublication -> publication; } if ($claimedPublication -> projectId !== null){ $projectsToGet[] = $claimedPublication -> projectId; } if ($claimedPublication -> targetPublicationId !== null){ $resultsToGet[] = $claimedPublication -> targetPublicationId; } if ($claimedPublication -> targetDatasetId !== null){ $resultsToGet[] = $claimedPublication -> targetDatasetId; } if (($claimedPublication -> publication == null || ($claimedPublication -> publication != null and $claimedPublication -> publication -> id == null))){ $resultsToGet[] = $claimedPublication -> publicationId; } if ($claimedPublication -> publication == null && $claimedPublication -> type == "dataset"){ $resultsToGet[] = $claimedPublication -> publicationId; } } $resultsToGet = array_unique($resultsToGet); $projectsToGet = array_unique($projectsToGet); $searchModel = new OpenAireModelSearch(); $results = $searchModel->getResults($resultsToGet, $locale); $projects = $searchModel->getProjects($projectsToGet, $locale); $keydResults = array(); $keydProjects = array(); foreach ($results as $result){ $keydResults[$result->id] = $result; } foreach ($projects as $project) $keydProjects[$project->id] = $project; foreach ($claimedPublications as $claimedPublication){ if (!isset($claimedPublicationsGrouped[$claimedPublication -> publicationId])){ if ($claimedPublication -> publication == null || $claimedPublication -> publication -> id == null||isset($keydResults[$claimedPublication -> publicationId])){ $publication = isset($keydResults[$claimedPublication -> publicationId])?$keydResults[$claimedPublication -> publicationId]:null; } else{ $publication = $claimedPublication -> publication; } if ($publication == null ) continue; $claimedPublicationsGrouped[$claimedPublication -> publicationId] = new stdClass(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publicationId = $claimedPublication -> publicationId; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date = $claimedPublication -> date; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publication = $publication; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publications = array(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> datasets = array(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> projects = array(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts = array(); $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> type = isset($claimedPublication -> type)?$claimedPublication -> type:'Publication'; //$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> claimType = $claimedPublication -> claimType; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publication -> userEmail = $claimedPublication -> userEmail; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publication -> claimId = $claimedPublication -> claimId; } if ($claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date < $claimedPublication -> date) $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> date = $claimedPublication -> date; if ($claimedPublication -> publication != null){ // $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publication=(isset($keydResults[$claimedPublication -> publicationId])&&($keydResults[$claimedPublication -> publicationId]!==null))? $keydResults[$claimedPublication -> publicationId]:$claimedPublication -> publication; $claimedConcepts = array(); foreach ($claimedPublication -> publication -> concepts as $concept){ $concept = $this->getConcept($concept); if(!isset( $concept)){ $concept = new stdClass(); } $claimedConcept = new stdClass(); $claimedConcept->id = isset($concept->id)?$concept->id:''; $claimedConcept->title = isset($concept->path)?$concept->path:''; $claimedConcept->date = $claimedPublication->date; $claimedConcept-> userEmail = $claimedPublication -> userEmail; $claimedConcept -> claimId = $claimedPublication -> claimId; //$claimedConcepts[] = $claimedConcept; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts[]=$claimedConcept; } //$claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts = array_merge($claimedPublicationsGrouped[$claimedPublication -> publicationId] -> concepts, $claimedConcepts); } if ($claimedPublication -> targetPublicationId !== null){ $claimedPublication->title = isset($keydResults[$claimedPublication -> targetPublicationId ])?$keydResults[$claimedPublication -> targetPublicationId ]->title:null; if ($claimedPublication->title == null){ $claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetPublicationId ])?$claimedDocuments[$claimedPublication -> targetPublicationId ]->title:null; } $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> publications[] = $claimedPublication; } if ($claimedPublication -> targetDatasetId !== null){ $claimedPublication->title = isset($keydResults[$claimedPublication -> targetDatasetId ])?$keydResults[$claimedPublication -> targetDatasetId ]->title:null; if ($claimedPublication->title == null){ $claimedPublication->title = isset($claimedDocuments[$claimedPublication -> targetDatasetId ])?$claimedDocuments[$claimedPublication -> targetDatasetId ]->title:null; } $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> datasets[] = $claimedPublication; } if ($claimedPublication -> projectId !== null){ $claimedPublication->title = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->title:null; $claimedPublication->acronym = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->acronym:null; $claimedPublication->funder = isset($keydProjects[$claimedPublication -> projectId ])?$keydProjects[$claimedPublication -> projectId ]->funder:null; $claimedPublicationsGrouped[$claimedPublication -> publicationId] -> projects[] = $claimedPublication; } } return $claimedPublicationsGrouped; } }