Esempio n. 1
0
 /**
  * Replace URI:s with an accompanying "Equivalent URI" with that one. If 
  * there are móre than one Equivalent URI for a given URI, the others than 
  * the first one will be ignored.
  * @param array $sparql_resultstructure
  * @param string $p_uris_filter
  * @return array $sparql_resultstructure
  */
 function urisToEquivURIsInSparqlResults($sparql_resultstructure)
 {
     $rows = $sparql_resultstructure['result']['rows'];
     $sparql_varnames = $sparql_resultstructure['result']['variables'];
     foreach ($rows as $rowid => $row) {
         foreach ($sparql_varnames as $sparql_varname) {
             $typekey = "{$sparql_varname} type";
             $type = $row[$typekey];
             $uri = $row[$sparql_varname];
             if ($type === 'uri') {
                 $equivuris = $this->store->getEquivURIsForURI($uri);
                 if (!RDFIOUtils::arrayEmpty($equivuris)) {
                     $equivuri = $equivuris[0];
                     # Replace the URI with the Equivalent URI
                     $rows[$rowid][$sparql_varname] = $equivuri;
                 }
             }
         }
     }
     # Put back the modified rows into the results structure
     $sparql_resultstructure['result']['rows'] = $rows;
     return $sparql_resultstructure;
 }