CrudRead.php
Go to the documentation of this file.
00001 <?php 00002 00005 00026 class CrudRead extends WebService 00027 { 00029 private $db; 00030 00032 private $conneg; 00033 00035 private $dtdURL; 00036 00038 private $include_linksback = ""; 00039 00041 private $include_reification = ""; 00042 00044 private $resourceUri = ""; 00045 00047 private $requester_ip = ""; 00048 00050 private $registered_ip = ""; 00051 00053 private $dataset = ""; 00054 00056 private $datasetsDescription = array(); 00057 00059 private $globalDataset = FALSE; 00060 00062 private $namespaces = 00063 array ("http://www.w3.org/2002/07/owl#" => "owl", "http://www.w3.org/1999/02/22-rdf-syntax-ns#" => "rdf", 00064 "http://www.w3.org/2000/01/rdf-schema#" => "rdfs", "http://purl.org/ontology/wsf#" => "wsf"); 00065 00067 public $subjectTriples = array(); 00068 00070 public $objectTriples = array(); 00071 00073 public $reificationTriples = array(); 00074 00076 public static $supportedSerializations = 00077 array ("application/bib+json", "application/iron+json", "application/json", "application/rdf+xml", 00078 "application/rdf+n3", "application/*", "text/xml", "text/*", "*/*"); 00079 00081 private $errorMessenger = 00082 '{ 00083 "ws": "/ws/crud/read/", 00084 "_200": { 00085 "id": "WS-CRUD-READ-200", 00086 "level": "Warning", 00087 "name": "No URI specified for any resource", 00088 "description": "No record URI defined for this query" 00089 }, 00090 "_201": { 00091 "id": "WS-CRUD-READ-201", 00092 "level": "Warning", 00093 "name": "Missing Dataset URIs", 00094 "description": "Not all dataset URIs have been defined for each requested record URI. Remember that each URI of the list of URIs have to have a matching dataset URI in the datasets list." 00095 }, 00096 "_202": { 00097 "id": "WS-CRUD-READ-202", 00098 "level": "Warning", 00099 "name": "Record URI(s) not existing or not accessible", 00100 "description": "The requested record URI(s) are not existing in this structWSF instance, or are not accessible to the requester. This error is only sent when no data URI are defined." 00101 }, 00102 "_300": { 00103 "id": "WS-CRUD-READ-300", 00104 "level": "Warning", 00105 "name": "This resource is not existing", 00106 "description": "The target resource to be read is not existing in the system" 00107 }, 00108 "_301": { 00109 "id": "WS-CRUD-READ-301", 00110 "level": "Warning", 00111 "name": "You can\'t read more than 64 resources at once", 00112 "description": "You are limited to read maximum 64 resources for each query to the CrudRead web service endpoint" 00113 }, 00114 "_302": { 00115 "id": "WS-CRUD-READ-302", 00116 "level": "Fatal", 00117 "name": "Can\'t get the description of the resource(s)", 00118 "description": "An error occured when we tried to get the description of the resource(s)" 00119 }, 00120 "_303": { 00121 "id": "WS-CRUD-READ-303", 00122 "level": "Fatal", 00123 "name": "Can\'t get the links-to the resource(s)", 00124 "description": "An error occured when we tried to get the links-to the resource(s)" 00125 }, 00126 "_304": { 00127 "id": "WS-CRUD-READ-304", 00128 "level": "Fatal", 00129 "name": "Can\'t get the reification statements for that resource(s)", 00130 "description": "An error occured when we tried to get the reification statements of the resource(s)" 00131 } 00132 00133 }'; 00134 00135 00158 function __construct($uri, $dataset, $include_linksback, $include_reification, $registered_ip, $requester_ip) 00159 { 00160 parent::__construct(); 00161 00162 $this->db = new DB_Virtuoso($this->db_username, $this->db_password, $this->db_dsn, $this->db_host); 00163 00164 $this->dataset = $dataset; 00165 00166 // If no dataset URI is defined for this query, we simply query all datasets accessible by the requester. 00167 if($this->dataset == "") 00168 { 00169 $this->globalDataset = TRUE; 00170 } 00171 00172 $this->resourceUri = $uri; 00173 00174 $this->include_linksback = $include_linksback; 00175 $this->include_reification = $include_reification; 00176 $this->requester_ip = $requester_ip; 00177 00178 if($registered_ip == "") 00179 { 00180 $this->registered_ip = $requester_ip; 00181 } 00182 else 00183 { 00184 $this->registered_ip = $registered_ip; 00185 } 00186 00187 if(strtolower(substr($this->registered_ip, 0, 4)) == "self") 00188 { 00189 $pos = strpos($this->registered_ip, "::"); 00190 00191 if($pos !== FALSE) 00192 { 00193 $account = substr($this->registered_ip, $pos + 2, strlen($this->registered_ip) - ($pos + 2)); 00194 00195 $this->registered_ip = $requester_ip . "::" . $account; 00196 } 00197 else 00198 { 00199 $this->registered_ip = $requester_ip; 00200 } 00201 } 00202 00203 $this->uri = $this->wsf_base_url . "/wsf/ws/crud/read/"; 00204 $this->title = "Crud Read Web Service"; 00205 $this->crud_usage = new CrudUsage(FALSE, TRUE, FALSE, FALSE); 00206 $this->endpoint = $this->wsf_base_url . "/ws/crud/read/"; 00207 00208 $this->dtdURL = "crud/crudRead.dtd"; 00209 00210 $this->errorMessenger = json_decode($this->errorMessenger); 00211 } 00212 00213 function __destruct() 00214 { 00215 parent::__destruct(); 00216 00217 if(isset($this->db)) 00218 { 00219 @$this->db->close(); 00220 } 00221 } 00222 00235 protected function validateQuery() 00236 { 00237 /* 00238 Check if dataset(s) URI(s) have been defined for this request. If not, then we query the 00239 AuthLister web service endpoint to get the list of datasets accessible by this user to see 00240 if the URI he wants to read is defined in one of these accessible dataset. 00241 */ 00242 if($this->globalDataset === TRUE) 00243 { 00244 include_once("../../auth/lister/AuthLister.php"); 00245 00246 $ws_al = new AuthLister("access_user", "", $this->registered_ip, $this->wsf_local_ip); 00247 00248 $ws_al->pipeline_conneg($this->conneg->getAccept(), $this->conneg->getAcceptCharset(), 00249 $this->conneg->getAcceptEncoding(), $this->conneg->getAcceptLanguage()); 00250 00251 $ws_al->process(); 00252 00253 $xml = new ProcessorXML(); 00254 $xml->loadXML($ws_al->pipeline_getResultset()); 00255 00256 $accesses = $xml->getSubjectsByType("wsf:Access"); 00257 00258 $accessibleDatasets = array(); 00259 00260 foreach($accesses as $access) 00261 { 00262 $predicates = $xml->getPredicatesByType($access, "wsf:datasetAccess"); 00263 $objects = $xml->getObjects($predicates->item(0)); 00264 $datasetUri = $xml->getURI($objects->item(0)); 00265 00266 $predicates = $xml->getPredicatesByType($access, "wsf:read"); 00267 $objects = $xml->getObjects($predicates->item(0)); 00268 $read = $xml->getContent($objects->item(0)); 00269 00270 if(strtolower($read) == "true") 00271 { 00272 $this->dataset .= "$datasetUri;"; 00273 array_push($accessibleDatasets, $datasetUri); 00274 } 00275 } 00276 00277 if(count($accessibleDatasets) <= 0) 00278 { 00279 $this->conneg->setStatus(400); 00280 $this->conneg->setStatusMsg("Bad Request"); 00281 $this->conneg->setStatusMsgExt($this->errorMessenger->_202->name); 00282 $this->conneg->setError($this->errorMessenger->_202->id, $this->errorMessenger->ws, 00283 $this->errorMessenger->_202->name, $this->errorMessenger->_202->description, "", 00284 $this->errorMessenger->_202->level); 00285 00286 return; 00287 } 00288 00289 unset($ws_al); 00290 00291 $this->dataset = rtrim($this->dataset, ";"); 00292 } 00293 else 00294 { 00295 $datasets = explode(";", $this->dataset); 00296 00297 $datasets = array_unique($datasets); 00298 00299 // Validate for each requested records of each dataset 00300 foreach($datasets as $dataset) 00301 { 00302 // Validation of the "requester_ip" to make sure the system that is sending the query as the rights. 00303 $ws_av = new AuthValidator($this->requester_ip, $dataset, $this->uri); 00304 00305 $ws_av->pipeline_conneg("text/xml", $this->conneg->getAcceptCharset(), $this->conneg->getAcceptEncoding(), 00306 $this->conneg->getAcceptLanguage()); 00307 00308 $ws_av->process(); 00309 00310 if($ws_av->pipeline_getResponseHeaderStatus() != 200) 00311 { 00312 $this->conneg->setStatus($ws_av->pipeline_getResponseHeaderStatus()); 00313 $this->conneg->setStatusMsg($ws_av->pipeline_getResponseHeaderStatusMsg()); 00314 $this->conneg->setStatusMsgExt($ws_av->pipeline_getResponseHeaderStatusMsgExt()); 00315 $this->conneg->setError($ws_av->pipeline_getError()->id, $ws_av->pipeline_getError()->webservice, 00316 $ws_av->pipeline_getError()->name, $ws_av->pipeline_getError()->description, 00317 $ws_av->pipeline_getError()->debugInfo, $ws_av->pipeline_getError()->level); 00318 00319 return; 00320 } 00321 00322 unset($ws_av); 00323 00324 // Validation of the "registered_ip" to make sure the user of this system has the rights 00325 $ws_av = new AuthValidator($this->registered_ip, $dataset, $this->uri); 00326 00327 $ws_av->pipeline_conneg("text/xml", $this->conneg->getAcceptCharset(), $this->conneg->getAcceptEncoding(), 00328 $this->conneg->getAcceptLanguage()); 00329 00330 $ws_av->process(); 00331 00332 if($ws_av->pipeline_getResponseHeaderStatus() != 200) 00333 { 00334 $this->conneg->setStatus($ws_av->pipeline_getResponseHeaderStatus()); 00335 $this->conneg->setStatusMsg($ws_av->pipeline_getResponseHeaderStatusMsg()); 00336 $this->conneg->setStatusMsgExt($ws_av->pipeline_getResponseHeaderStatusMsgExt()); 00337 $this->conneg->setError($ws_av->pipeline_getError()->id, $ws_av->pipeline_getError()->webservice, 00338 $ws_av->pipeline_getError()->name, $ws_av->pipeline_getError()->description, 00339 $ws_av->pipeline_getError()->debugInfo, $ws_av->pipeline_getError()->level); 00340 return; 00341 } 00342 } 00343 } 00344 } 00345 00356 public function pipeline_getError() { return ($this->conneg->error); } 00357 00358 00369 public function pipeline_getResultset() 00370 { 00371 $xml = new ProcessorXML(); 00372 00373 // Creation of the RESULTSET 00374 $resultset = $xml->createResultset(); 00375 00376 // Creation of the prefixes elements. 00377 $void = $xml->createPrefix("owl", "http://www.w3.org/2002/07/owl#"); 00378 $resultset->appendChild($void); 00379 $rdf = $xml->createPrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); 00380 $resultset->appendChild($rdf); 00381 $dcterms = $xml->createPrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); 00382 $resultset->appendChild($dcterms); 00383 $dcterms = $xml->createPrefix("wsf", "http://purl.org/ontology/wsf#"); 00384 $resultset->appendChild($dcterms); 00385 00386 $subject; 00387 00388 foreach($this->subjectTriples as $u => $sts) 00389 { 00390 if(isset($sts["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"])) 00391 { 00392 foreach($sts["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"] as $key => $type) 00393 { 00394 if($key > 0) 00395 { 00396 $pred = $xml->createPredicate("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); 00397 $object = $xml->createObject("", $type[0]); 00398 $pred->appendChild($object); 00399 $subject->appendChild($pred); 00400 } 00401 else 00402 { 00403 $subject = $xml->createSubject($type[0], $u); 00404 } 00405 } 00406 } 00407 else 00408 { 00409 $subject = $xml->createSubject("http://www.w3.org/2002/07/owl#Thing", $u); 00410 } 00411 00412 foreach($sts as $property => $values) 00413 { 00414 if($property != "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") 00415 { 00416 foreach($values as $value) 00417 { 00418 if($value[1] != NULL) 00419 { 00420 /* 00421 @TODO The internal XML structure of structWSF should be enhanced with datatypes such as xsd:double, int, 00422 literal, etc. 00423 */ 00424 $pred = $xml->createPredicate($property); 00425 $object = $xml->createObjectContent($value[0]); 00426 $pred->appendChild($object); 00427 00428 if(isset($this->reificationTriples[$u][$property][$value[0]])) 00429 { 00430 foreach($this->reificationTriples[$u][$property][$value[0]] as $rStatement => $rValue) 00431 { 00432 foreach($rValue as $rv) 00433 { 00434 $reify = $xml->createReificationStatement($rStatement, $rv); 00435 $object->appendChild($reify); 00436 } 00437 } 00438 } 00439 00440 $subject->appendChild($pred); 00441 } 00442 else 00443 { 00444 $pred = $xml->createPredicate($property); 00445 $object = $xml->createObject("", $value[0]); 00446 $pred->appendChild($object); 00447 00448 if(isset($this->reificationTriples[$u][$property][$value[0]])) 00449 { 00450 foreach($this->reificationTriples[$u][$property][$value[0]] as $rStatement => $rValue) 00451 { 00452 foreach($rValue as $rv) 00453 { 00454 $reify = $xml->createReificationStatement($rStatement, $rv); 00455 $object->appendChild($reify); 00456 } 00457 } 00458 } 00459 00460 $subject->appendChild($pred); 00461 } 00462 } 00463 } 00464 } 00465 00466 $resultset->appendChild($subject); 00467 00468 // Now let add object references 00469 if(count($this->objectTriples[$u]) > 0) 00470 { 00471 foreach($this->objectTriples[$u] as $property => $propertyValue) 00472 { 00473 foreach($propertyValue as $resource) 00474 { 00475 $subject = $xml->createSubject("http://www.w3.org/2002/07/owl#Thing", $resource); 00476 00477 $pred = $xml->createPredicate($property); 00478 $object = $xml->createObject("", $u); 00479 $pred->appendChild($object); 00480 $subject->appendChild($pred); 00481 00482 $resultset->appendChild($subject); 00483 } 00484 } 00485 } 00486 } 00487 00488 return ($this->injectDoctype($xml->saveXML($resultset))); 00489 } 00490 00503 public function injectDoctype($xmlDoc) 00504 { 00505 $posHeader = strpos($xmlDoc, '"?>') + 3; 00506 $xmlDoc = substr($xmlDoc, 0, $posHeader) 00507 . "\n<!DOCTYPE resultset PUBLIC \"-//Structured Dynamics LLC//Crud Read DTD 0.1//EN\" \"" . $this->dtdBaseURL 00508 . $this->dtdURL . "\">" . substr($xmlDoc, $posHeader, strlen($xmlDoc) - $posHeader); 00509 00510 return ($xmlDoc); 00511 } 00512 00531 public function ws_conneg($accept, $accept_charset, $accept_encoding, $accept_language) 00532 { 00533 $this->conneg = 00534 new Conneg($accept, $accept_charset, $accept_encoding, $accept_language, CrudRead::$supportedSerializations); 00535 00536 // Validate query 00537 $this->validateQuery(); 00538 00539 // If the query is still valid 00540 if($this->conneg->getStatus() == 200) 00541 { 00542 // Check for errors 00543 if($this->resourceUri == "") 00544 { 00545 $this->conneg->setStatus(400); 00546 $this->conneg->setStatusMsg("Bad Request"); 00547 $this->conneg->setStatusMsgExt($this->errorMessenger->_200->name); 00548 $this->conneg->setError($this->errorMessenger->_200->id, $this->errorMessenger->ws, 00549 $this->errorMessenger->_200->name, $this->errorMessenger->_200->description, "", 00550 $this->errorMessenger->_200->level); 00551 00552 return; 00553 } 00554 } 00555 00556 // Check if we have the same number of URIs than Dataset URIs (only if at least one dataset URI is defined). 00557 if($this->globalDataset === FALSE) 00558 { 00559 $uris = explode(";", $this->resourceUri); 00560 $datasets = explode(";", $this->dataset); 00561 00562 if(count($uris) != count($datasets)) 00563 { 00564 $this->conneg->setStatus(400); 00565 $this->conneg->setStatusMsg("Bad Request"); 00566 $this->conneg->setStatusMsgExt($this->errorMessenger->_201->name); 00567 $this->conneg->setError($this->errorMessenger->_201->id, $this->errorMessenger->ws, 00568 $this->errorMessenger->_201->name, $this->errorMessenger->_201->description, "", 00569 $this->errorMessenger->_201->level); 00570 00571 return; 00572 } 00573 } 00574 } 00575 00594 public function pipeline_conneg($accept, $accept_charset, $accept_encoding, $accept_language) 00595 { $this->ws_conneg($accept, $accept_charset, $accept_encoding, $accept_language); } 00596 00607 public function pipeline_getResponseHeaderStatus() { return $this->conneg->getStatus(); } 00608 00619 public function pipeline_getResponseHeaderStatusMsg() { return $this->conneg->getStatusMsg(); } 00620 00633 public function pipeline_getResponseHeaderStatusMsgExt() { return $this->conneg->getStatusMsgExt(); } 00634 00645 public function pipeline_serialize() 00646 { 00647 $rdf_part = ""; 00648 00649 switch($this->conneg->getMime()) 00650 { 00651 case "application/bib+json": 00652 case "application/iron+json": 00653 include_once("../../converter/irjson/ConverterIrJSON.php"); 00654 include_once("../../converter/irjson/Dataset.php"); 00655 include_once("../../converter/irjson/InstanceRecord.php"); 00656 include_once("../../converter/irjson/LinkageSchema.php"); 00657 include_once("../../converter/irjson/StructureSchema.php"); 00658 include_once("../../converter/irjson/irJSONParser.php"); 00659 00660 // Include more information about the dataset (at least the ID) 00661 $documentToConvert = $this->pipeline_getResultset(); 00662 00663 $datasets = explode(";", $this->dataset); 00664 00665 $datasets = array_unique($datasets); 00666 00667 // Note: this is temporary. A more consistent dataset-URI/resource-URIs has to be implemented in conStruct 00669 $d = $datasets[0]; 00670 00671 $d = str_replace("/wsf/datasets/", "/conStruct/datasets/", $d) . "resource/"; 00673 00674 00675 /* 00676 @TODO In the future, we will have to include the dataset's meta-data information in the data to convert. 00677 This meta-data include: its name, description, creator, maintainer, owner, schema and linkage. 00678 00679 This will be done by querying the DatasetRead web service endpoint for the "$d" dataset 00680 */ 00681 00682 $ws_irv = 00683 new ConverterIrJSON($documentToConvert, "text/xml", "true", $this->registered_ip, $this->requester_ip); 00684 00685 $ws_irv->pipeline_conneg("application/iron+json", $this->conneg->getAcceptCharset(), 00686 $this->conneg->getAcceptEncoding(), $this->conneg->getAcceptLanguage()); 00687 00688 $ws_irv->process(); 00689 00690 if($ws_irv->pipeline_getResponseHeaderStatus() != 200) 00691 { 00692 $this->conneg->setStatus($ws_irv->pipeline_getResponseHeaderStatus()); 00693 $this->conneg->setStatusMsg($ws_irv->pipeline_getResponseHeaderStatusMsg()); 00694 $this->conneg->setStatusMsgExt($ws_irv->pipeline_getResponseHeaderStatusMsgExt()); 00695 $this->conneg->setError($ws_irv->pipeline_getError()->id, $ws_irv->pipeline_getError()->webservice, 00696 $ws_irv->pipeline_getError()->name, $ws_irv->pipeline_getError()->description, 00697 $ws_irv->pipeline_getError()->debugInfo, $ws_irv->pipeline_getError()->level); 00698 return; 00699 } 00700 00701 return ($ws_irv->pipeline_serialize()); 00702 00703 break; 00704 00705 case "application/json": 00706 $json_part = ""; 00707 $xml = new ProcessorXML(); 00708 $xml->loadXML($this->pipeline_getResultset()); 00709 00710 $subjects = $xml->getSubjects(); 00711 00712 $nsId = 0; 00713 00714 foreach($subjects as $subject) 00715 { 00716 $subjectURI = $xml->getURI($subject); 00717 $subjectType = $xml->getType($subject); 00718 00719 $ns = $this->getNamespace($subjectType); 00720 00721 if(!isset($this->namespaces[$ns[0]])) 00722 { 00723 $this->namespaces[$ns[0]] = "ns" . $nsId; 00724 $nsId++; 00725 } 00726 00727 $json_part .= " { \n"; 00728 $json_part .= " \"uri\": \"" . parent::jsonEncode($subjectURI) . "\", \n"; 00729 $json_part .= " \"type\": \"" . parent::jsonEncode($this->namespaces[$ns[0]] . ":" . $ns[1]) 00730 . "\", \n"; 00731 00732 $predicates = $xml->getPredicates($subject); 00733 00734 $nbPredicates = 0; 00735 00736 foreach($predicates as $predicate) 00737 { 00738 $objects = $xml->getObjects($predicate); 00739 00740 foreach($objects as $object) 00741 { 00742 $nbPredicates++; 00743 00744 if($nbPredicates == 1) 00745 { 00746 $json_part .= " \"predicate\": [ \n"; 00747 } 00748 00749 $objectType = $xml->getType($object); 00750 $predicateType = $xml->getType($predicate); 00751 00752 if($objectType == "rdfs:Literal") 00753 { 00754 $objectValue = $xml->getContent($object); 00755 00756 $ns = $this->getNamespace($predicateType); 00757 00758 if(!isset($this->namespaces[$ns[0]])) 00759 { 00760 $this->namespaces[$ns[0]] = "ns" . $nsId; 00761 $nsId++; 00762 } 00763 00764 $json_part .= " { \n"; 00765 $json_part .= " \"" . parent::jsonEncode($this->namespaces[$ns[0]] . ":" . $ns[1]) . "\": \"" 00766 . parent::jsonEncode($objectValue) . "\" \n"; 00767 $json_part .= " },\n"; 00768 } 00769 else 00770 { 00771 $objectURI = $xml->getURI($object); 00772 00773 $ns = $this->getNamespace($predicateType); 00774 00775 if(!isset($this->namespaces[$ns[0]])) 00776 { 00777 $this->namespaces[$ns[0]] = "ns" . $nsId; 00778 $nsId++; 00779 } 00780 00781 $json_part .= " { \n"; 00782 $json_part .= " \"" . parent::jsonEncode($this->namespaces[$ns[0]] . ":" . $ns[1]) 00783 . "\": { \n"; 00784 $json_part .= " \"uri\": \"" . parent::jsonEncode($objectURI) . "\",\n"; 00785 00786 // Check if there is a reification statement for this object. 00787 $reifies = $xml->getReificationStatements($object, "wsf:objectLabel"); 00788 00789 $nbReification = 0; 00790 00791 foreach($reifies as $reify) 00792 { 00793 $nbReification++; 00794 00795 if($nbReification > 0) 00796 { 00797 $json_part .= " \"reify\": [\n"; 00798 } 00799 00800 $json_part .= " { \n"; 00801 $json_part .= " \"type\": \"wsf:objectLabel\", \n"; 00802 $json_part .= " \"value\": \"" . parent::jsonEncode($xml->getValue($reify)) 00803 . "\" \n"; 00804 $json_part .= " },\n"; 00805 } 00806 00807 if($nbReification > 0) 00808 { 00809 $json_part = substr($json_part, 0, strlen($json_part) - 2) . "\n"; 00810 00811 $json_part .= " ]\n"; 00812 } 00813 else 00814 { 00815 $json_part = substr($json_part, 0, strlen($json_part) - 2) . "\n"; 00816 } 00817 00818 $json_part .= " } \n"; 00819 $json_part .= " },\n"; 00820 } 00821 } 00822 } 00823 00824 if(strlen($json_part) > 0) 00825 { 00826 $json_part = substr($json_part, 0, strlen($json_part) - 2) . "\n"; 00827 } 00828 00829 if($nbPredicates > 0) 00830 { 00831 $json_part .= " ]\n"; 00832 } 00833 00834 $json_part .= " },\n"; 00835 } 00836 00837 if(strlen($json_part) > 0) 00838 { 00839 $json_part = substr($json_part, 0, strlen($json_part) - 2) . "\n"; 00840 } 00841 00842 $json_header .= " \"prefixes\": [ \n"; 00843 $json_header .= " {\n"; 00844 $json_header .= " \"rdf\": \"http://www.w3.org/1999/02/22-rdf-syntax-ns#\",\n"; 00845 $json_header .= " \"wsf\": \"http://purl.org/ontology/wsf#\",\n"; 00846 00847 foreach($this->namespaces as $ns => $prefix) 00848 { 00849 $json_header .= " \"$prefix\": \"$ns\",\n"; 00850 } 00851 00852 if(strlen($json_header) > 0) 00853 { 00854 $json_header = substr($json_header, 0, strlen($json_header) - 2) . "\n"; 00855 } 00856 00857 $json_header .= " } \n"; 00858 $json_header .= " ],\n"; 00859 $json_header .= " \"resultset\": {\n"; 00860 $json_header .= " \"subject\": [\n"; 00861 $json_header .= $json_part; 00862 $json_header .= " ]\n"; 00863 $json_header .= " }\n"; 00864 00865 return ($json_header); 00866 /* 00867 $json_part = ""; 00868 $xml = new ProcessorXML(); 00869 $xml->loadXML($this->pipeline_getResultset()); 00870 00871 $subjects = $xml->getSubjects(); 00872 00873 foreach($subjects as $subject) 00874 { 00875 $subjectURI = $xml->getURI($subject); 00876 $subjectType = $xml->getType($subject); 00877 00878 $json_part .= " { \n"; 00879 $json_part .= " \"uri\": \"".parent::jsonEncode($subjectURI)."\", \n"; 00880 $json_part .= " \"type\": \"".parent::jsonEncode($subjectType)."\", \n"; 00881 00882 $predicates = $xml->getPredicates($subject); 00883 00884 $nbPredicates = 0; 00885 00886 foreach($predicates as $predicate) 00887 { 00888 $objects = $xml->getObjects($predicate); 00889 00890 foreach($objects as $object) 00891 { 00892 $nbPredicates++; 00893 00894 if($nbPredicates == 1) 00895 { 00896 $json_part .= " \"predicates\": [ \n"; 00897 } 00898 00899 $objectType = $xml->getType($object); 00900 $predicateType = $xml->getType($predicate); 00901 00902 if($objectType == "rdfs:Literal") 00903 { 00904 $objectValue = $xml->getContent($object); 00905 00906 $json_part .= " { \n"; 00907 $json_part .= " \"".parent::jsonEncode($predicateType)."\": \"".parent::jsonEncode($objectValue)."\" \n"; 00908 $json_part .= " },\n"; 00909 } 00910 else 00911 { 00912 $objectURI = $xml->getURI($object); 00913 $rdf_part .= " <$predicateType> <$objectURI> ;\n"; 00914 00915 $json_part .= " { \n"; 00916 $json_part .= " \"".parent::jsonEncode($predicateType)."\": { \n"; 00917 $json_part .= " \"uri\": \"".parent::jsonEncode($objectURI)."\", \n"; 00918 00919 // Check if there is a reification statement for this object. 00920 $reifies = $xml->getReificationStatements($object); 00921 00922 $nbReification = 0; 00923 00924 foreach($reifies as $reify) 00925 { 00926 $nbReification++; 00927 00928 if($nbReification > 0) 00929 { 00930 $json_part .= " \"reifies\": [\n"; 00931 } 00932 00933 $json_part .= " { \n"; 00934 $json_part .= " \"type\": \"wsf:objectLabel\", \n"; 00935 $json_part .= " \"value\": \"".parent::jsonEncode($xml->getValue($reify))."\" \n"; 00936 $json_part .= " },\n"; 00937 } 00938 00939 if($nbReification > 0) 00940 { 00941 $json_part = substr($json_part, 0, strlen($json_part) - 2)."\n"; 00942 00943 $json_part .= " ]\n"; 00944 } 00945 else 00946 { 00947 $json_part = substr($json_part, 0, strlen($json_part) - 2)."\n"; 00948 } 00949 00950 00951 $json_part .= " } \n"; 00952 $json_part .= " },\n"; 00953 } 00954 } 00955 } 00956 00957 if(strlen($json_part) > 0) 00958 { 00959 $json_part = substr($json_part, 0, strlen($json_part) - 2)."\n"; 00960 } 00961 00962 if($nbPredicates > 0) 00963 { 00964 $json_part .= " ]\n"; 00965 } 00966 00967 $json_part .= " },\n"; 00968 } 00969 00970 if(strlen($json_part) > 0) 00971 { 00972 $json_part = substr($json_part, 0, strlen($json_part) - 2)."\n"; 00973 } 00974 00975 00976 return($json_part); 00977 */ 00978 break; 00979 00980 case "application/rdf+n3": 00981 00982 $xml = new ProcessorXML(); 00983 $xml->loadXML($this->pipeline_getResultset()); 00984 00985 $subjects = $xml->getSubjects(); 00986 00987 foreach($subjects as $subject) 00988 { 00989 $subjectURI = $xml->getURI($subject); 00990 $subjectType = $xml->getType($subject, FALSE); 00991 00992 $rdf_part .= "\n <$subjectURI> a <$subjectType> ;\n"; 00993 00994 $predicates = $xml->getPredicates($subject); 00995 00996 foreach($predicates as $predicate) 00997 { 00998 $objects = $xml->getObjects($predicate); 00999 01000 foreach($objects as $object) 01001 { 01002 $objectType = $xml->getType($object); 01003 $predicateType = $xml->getType($predicate, FALSE); 01004 01005 if($objectType == "rdfs:Literal") 01006 { 01007 $objectValue = $xml->getContent($object); 01008 $rdf_part .= " <$predicateType> \"\"\"" . str_replace(array( "\\" ), "\\\\", $objectValue) 01009 . "\"\"\" ;\n"; 01010 } 01011 else 01012 { 01013 $objectURI = $xml->getURI($object); 01014 $rdf_part .= " <$predicateType> <$objectURI> ;\n"; 01015 } 01016 } 01017 } 01018 01019 if(strlen($rdf_part) > 0) 01020 { 01021 $rdf_part = substr($rdf_part, 0, strlen($rdf_part) - 2) . ". \n"; 01022 } 01023 } 01024 01025 return ($rdf_part); 01026 break; 01027 01028 case "application/rdf+xml": 01029 $xml = new ProcessorXML(); 01030 $xml->loadXML($this->pipeline_getResultset()); 01031 01032 $subjects = $xml->getSubjects(); 01033 01034 $nsId = 0; 01035 01036 foreach($subjects as $subject) 01037 { 01038 $subjectURI = $xml->getURI($subject); 01039 $subjectType = $xml->getType($subject); 01040 01041 $ns1 = $this->getNamespace($subjectType); 01042 01043 if(!isset($this->namespaces[$ns1[0]])) 01044 { 01045 $this->namespaces[$ns1[0]] = "ns" . $nsId; 01046 $nsId++; 01047 } 01048 01049 $rdf_part .= "\n <" . $this->namespaces[$ns1[0]] . ":" . $ns1[1] . " rdf:about=\"". 01050 $this->xmlEncode($subjectURI)."\">\n"; 01051 01052 $predicates = $xml->getPredicates($subject); 01053 01054 foreach($predicates as $predicate) 01055 { 01056 $objects = $xml->getObjects($predicate); 01057 01058 foreach($objects as $object) 01059 { 01060 $objectType = $xml->getType($object); 01061 $predicateType = $xml->getType($predicate); 01062 01063 if($objectType == "rdfs:Literal") 01064 { 01065 $objectValue = $xml->getContent($object); 01066 01067 $ns = $this->getNamespace($predicateType); 01068 01069 if(!isset($this->namespaces[$ns[0]])) 01070 { 01071 $this->namespaces[$ns[0]] = "ns" . $nsId; 01072 $nsId++; 01073 } 01074 01075 $rdf_part .= " <" . $this->namespaces[$ns[0]] . ":" . $ns[1] . ">" 01076 . $this->xmlEncode($objectValue) . "</" . $this->namespaces[$ns[0]] . ":" . $ns[1] . ">\n"; 01077 } 01078 else 01079 { 01080 $objectURI = $xml->getURI($object); 01081 01082 $ns = $this->getNamespace($predicateType); 01083 01084 if(!isset($this->namespaces[$ns[0]])) 01085 { 01086 $this->namespaces[$ns[0]] = "ns" . $nsId; 01087 $nsId++; 01088 } 01089 01090 $rdf_part .= " <" . $this->namespaces[$ns[0]] . ":" . $ns[1] 01091 . " rdf:resource=\"".$this->xmlEncode($objectURI)."\" />\n"; 01092 } 01093 } 01094 } 01095 01096 $rdf_part .= " </" . $this->namespaces[$ns1[0]] . ":" . $ns1[1] . ">\n"; 01097 } 01098 01099 $rdf_header = "<rdf:RDF "; 01100 01101 foreach($this->namespaces as $ns => $prefix) 01102 { 01103 $rdf_header .= " xmlns:$prefix=\"$ns\""; 01104 } 01105 01106 $rdf_header .= ">\n\n"; 01107 01108 $rdf_part = $rdf_header . $rdf_part; 01109 01110 return ($rdf_part); 01111 break; 01112 } 01113 } 01114 01127 private function getNamespace($uri) 01128 { 01129 $pos = strrpos($uri, "#"); 01130 01131 if($pos !== FALSE) 01132 { 01133 return array (substr($uri, 0, $pos) . "#", substr($uri, $pos + 1, strlen($uri) - ($pos + 1))); 01134 } 01135 else 01136 { 01137 $pos = strrpos($uri, "/"); 01138 01139 if($pos !== FALSE) 01140 { 01141 return array (substr($uri, 0, $pos) . "/", substr($uri, $pos + 1, strlen($uri) - ($pos + 1))); 01142 } 01143 else 01144 { 01145 $pos = strpos($uri, ":"); 01146 01147 if($pos !== FALSE) 01148 { 01149 $nsUri = explode(":", $uri, 2); 01150 01151 foreach($this->namespaces as $uri2 => $prefix2) 01152 { 01153 $uri2 = urldecode($uri2); 01154 01155 if($prefix2 == $nsUri[0]) 01156 { 01157 return (array ($uri2, $nsUri[1])); 01158 } 01159 } 01160 01161 return explode(":", $uri, 2); 01162 } 01163 } 01164 } 01165 01166 return (FALSE); 01167 } 01168 01177 public function pipeline_serialize_reification() 01178 { 01179 $rdf_reification = ""; 01180 01181 switch($this->conneg->getMime()) 01182 { 01183 case "application/rdf+n3": 01184 $xml = new ProcessorXML(); 01185 $xml->loadXML($this->pipeline_getResultset()); 01186 01187 $subjects = $xml->getSubjects(); 01188 01189 $bnodeCounter = 0; 01190 01191 foreach($subjects as $subject) 01192 { 01193 $predicates = $xml->getPredicates($subject); 01194 01195 foreach($predicates as $predicate) 01196 { 01197 $predicateType = $xml->getType($predicate, FALSE); 01198 01199 $objects = $xml->getObjects($predicate); 01200 01201 foreach($objects as $object) 01202 { 01203 $reifies = $xml->getReificationStatements($object); 01204 01205 foreach($reifies as $reify) 01206 { 01207 $reifyPredicate = $xml->getType($reify, FALSE); 01208 01209 $ns = $this->getNamespace($reifyPredicate); 01210 01211 if(!isset($this->namespaces[$ns[0]])) 01212 { 01213 $this->namespaces[$ns[0]] = "ns" . $nsId; 01214 $nsId++; 01215 } 01216 01217 $rdf_reification .= "_:" . md5($xml->getURI($subject) . $predicateType . $xml->getURI($object)) 01218 . " a rdf:Statement ;\n"; 01219 $bnodeCounter++; 01220 $rdf_reification .= " rdf:subject <" . $xml->getURI($subject) . "> ;\n"; 01221 $rdf_reification .= " rdf:predicate <" . $predicateType . "> ;\n"; 01222 $rdf_reification .= " rdf:object <" . $xml->getURI($object) . "> ;\n"; 01223 $rdf_reification .= " " . $this->namespaces[$ns[0]] . ":" . $ns[1] . " \"" . $xml->getValue($reify) 01224 . "\" .\n\n"; 01225 $bnodeCounter++; 01226 } 01227 } 01228 } 01229 } 01230 01231 return ($rdf_reification); 01232 01233 break; 01234 01235 case "application/rdf+xml": 01236 $xml = new ProcessorXML(); 01237 $xml->loadXML($this->pipeline_getResultset()); 01238 01239 $subjects = $xml->getSubjects(); 01240 01241 foreach($subjects as $subject) 01242 { 01243 $predicates = $xml->getPredicates($subject); 01244 01245 foreach($predicates as $predicate) 01246 { 01247 $predicateType = $xml->getType($predicate, FALSE); 01248 01249 $objects = $xml->getObjects($predicate); 01250 01251 foreach($objects as $object) 01252 { 01253 $reifies = $xml->getReificationStatements($object); 01254 01255 foreach($reifies as $reify) 01256 { 01257 $reifyPredicate = $xml->getType($reify, FALSE); 01258 01259 $ns = $this->getNamespace($reifyPredicate); 01260 01261 if(!isset($this->namespaces[$ns[0]])) 01262 { 01263 $this->namespaces[$ns[0]] = "ns" . $nsId; 01264 $nsId++; 01265 } 01266 01267 $rdf_reification .= "<rdf:Statement rdf:about=\"" 01268 . $this->xmlEncode(md5($xml->getURI($subject) . $predicateType . $xml->getURI($object))) . "\">\n"; 01269 $rdf_reification .= " <rdf:subject rdf:resource=\"" . $xml->getURI($this->xmlEncode($subject)) . "\" />\n"; 01270 $rdf_reification .= " <rdf:predicate rdf:resource=\"" . $this->xmlEncode($predicateType) . "\" />\n"; 01271 $rdf_reification .= " <rdf:object rdf:resource=\"" . $this->xmlEncode($xml->getURI($object)) . "\" />\n"; 01272 $rdf_reification .= " <" . $this->namespaces[$ns[0]] . ":" . $ns[1] . ">" 01273 . $this->xmlEncode($xml->getValue($reify)) . "</$reifyPredicate>\n"; 01274 $rdf_reification .= "</rdf:Statement> \n\n"; 01275 } 01276 } 01277 } 01278 } 01279 01280 return ($rdf_reification); 01281 01282 break; 01283 } 01284 } 01285 01296 public function ws_serialize() 01297 { 01298 switch($this->conneg->getMime()) 01299 { 01300 case "application/rdf+n3": 01301 $rdf_document = ""; 01302 $rdf_document .= "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n"; 01303 01304 $rdf_document .= $this->pipeline_serialize(); 01305 01306 $rdf_document .= $this->pipeline_serialize_reification(); 01307 01308 return $rdf_document; 01309 break; 01310 01311 case "application/rdf+xml": 01312 $rdf_document = ""; 01313 $rdf_document .= "<?xml version=\"1.0\"?>\n"; 01314 01315 $rdf_document .= $this->pipeline_serialize(); 01316 01317 $rdf_document .= $this->pipeline_serialize_reification(); 01318 01319 $rdf_document .= "</rdf:RDF>"; 01320 01321 return $rdf_document; 01322 break; 01323 01324 case "text/xml": 01325 return $this->pipeline_getResultset(); 01326 break; 01327 01328 case "application/json": 01329 /* 01330 $json_document = ""; 01331 $json_document .= "{\n"; 01332 $json_document .= " \"resultset\": {\n"; 01333 $json_document .= " \"subject\": [\n"; 01334 $json_document .= $this->pipeline_serialize(); 01335 $json_document .= " ]\n"; 01336 $json_document .= " }\n"; 01337 $json_document .= "}"; 01338 01339 return($json_document); 01340 */ 01341 $json_document = ""; 01342 $json_document .= "{\n"; 01343 $json_document .= $this->pipeline_serialize(); 01344 $json_document .= "}"; 01345 01346 return ($json_document); 01347 break; 01348 01349 case "application/bib+json": 01350 case "application/iron+json": 01351 return ($this->pipeline_serialize()); 01352 break; 01353 } 01354 } 01355 01368 public function ws_respond($content) 01369 { 01370 // First send the header of the request 01371 $this->conneg->respond(); 01372 01373 // second, send the content of the request 01374 01375 // Make sure there is no error. 01376 if($this->conneg->getStatus() == 200) 01377 { 01378 echo $content; 01379 } 01380 01381 $this->__destruct(); 01382 } 01383 01384 01393 public function process() 01394 { 01395 // Make sure there was no conneg error prior to this process call 01396 if($this->conneg->getStatus() == 200) 01397 { 01398 $uris = explode(";", $this->resourceUri); 01399 $datasets = explode(";", $this->dataset); 01400 01401 if(count($uris) > 64) 01402 { 01403 $this->conneg->setStatus(400); 01404 $this->conneg->setStatusMsg("Bad Request"); 01405 $this->conneg->setStatusMsgExt($this->errorMessenger->_301->name); 01406 $this->conneg->setError($this->errorMessenger->_301->id, $this->errorMessenger->ws, 01407 $this->errorMessenger->_301->name, $this->errorMessenger->_301->description, "", 01408 $this->errorMessenger->_301->level); 01409 01410 return; 01411 } 01412 01413 foreach($uris as $key => $u) 01414 { 01415 01416 // Decode potentially encoded ";" character. 01417 $u = str_ireplace("%3B", ";", $u); 01418 $d = str_ireplace("%3B", ";", $datasets[$key]); 01419 01420 $query = ""; 01421 01422 if($this->globalDataset === FALSE) 01423 { 01424 $d = str_ireplace("%3B", ";", $datasets[$key]); 01425 01426 // Archiving suject triples 01427 $query = $this->db->build_sparql_query("select ?p ?o (DATATYPE(?o)) as ?otype (LANG(?o)) as ?olang " 01428 . "from <" . $d . "> where {<" . $u 01429 . "> ?p ?o.}", array ('p', 'o', 'otype', 'olang'), FALSE); 01430 } 01431 else 01432 { 01433 $d = ""; 01434 01435 foreach($datasets as $dataset) 01436 { 01437 if($dataset != "") 01438 { 01439 $d .= " from named <$dataset> "; 01440 } 01441 } 01442 01443 // Archiving suject triples 01444 $query = $this->db->build_sparql_query("select ?p ?o (DATATYPE(?o)) as ?otype (LANG(?o)) as ?olang " 01445 . " $d where {graph ?g{<" . $u 01446 . "> ?p ?o.}}", array ('p', 'o', 'otype', 'olang'), FALSE); 01447 } 01448 01449 $resultset = $this->db->query($query); 01450 01451 if(odbc_error()) 01452 { 01453 $this->conneg->setStatus(500); 01454 $this->conneg->setStatusMsg("Internal Error"); 01455 $this->conneg->setStatusMsgExt($this->errorMessenger->_302->name); 01456 $this->conneg->setError($this->errorMessenger->_302->id, $this->errorMessenger->ws, 01457 $this->errorMessenger->_302->name, $this->errorMessenger->_302->description, odbc_errormsg(), 01458 $this->errorMessenger->_302->level); 01459 } 01460 01461 while(odbc_fetch_row($resultset)) 01462 { 01463 $p = odbc_result($resultset, 1); 01464 $o = odbc_result($resultset, 2); 01465 01466 $otype = odbc_result($resultset, 3); 01467 $olang = odbc_result($resultset, 4); 01468 01469 if(!isset($this->subjectTriples[$u][$p])) 01470 { 01471 $this->subjectTriples[$u][$p] = array(); 01472 } 01473 01474 $objectType = ""; 01475 if($olang && $olang != "") 01476 { 01477 /* If a language is defined for an object, we force its type to be xsd:string */ 01478 $objectType = "http://www.w3.org/2001/XMLSchema#string"; 01479 } 01480 else 01481 { 01482 $objectType = $otype; 01483 } 01484 01485 if($this->globalDataset === TRUE) 01486 { 01492 $found = FALSE; 01493 foreach($this->subjectTriples[$u][$p] as $value) 01494 { 01495 if($o == $value[0]) 01496 { 01497 $found = TRUE; 01498 } 01499 } 01500 01501 if($found === FALSE) 01502 { 01503 array_push($this->subjectTriples[$u][$p], array ($o, $objectType)); 01504 } 01505 } 01506 else 01507 { 01508 array_push($this->subjectTriples[$u][$p], array ($o, $objectType)); 01509 } 01510 } 01511 01512 if(count($this->subjectTriples) <= 0) 01513 { 01514 $this->conneg->setStatus(400); 01515 $this->conneg->setStatusMsg("Bad Request"); 01516 $this->conneg->setStatusMsgExt($this->errorMessenger->_300->name); 01517 $this->conneg->setError($this->errorMessenger->_300->id, $this->errorMessenger->ws, 01518 $this->errorMessenger->_300->name, $this->errorMessenger->_300->description, "", 01519 $this->errorMessenger->_300->level); 01520 01521 return; 01522 } 01523 01524 // Archiving object triples 01525 if(strtolower($this->include_linksback) == "true") 01526 { 01527 $query = ""; 01528 01529 if($this->globalDataset === FALSE) 01530 { 01531 $query = $this->db->build_sparql_query("select ?s ?p from <" . $d . "> where {?s ?p <" . $u . ">.}", 01532 array ('s', 'p'), FALSE); 01533 } 01534 else 01535 { 01536 $d = ""; 01537 01538 foreach($datasets as $dataset) 01539 { 01540 if($dataset != "") 01541 { 01542 $d .= " from named <$dataset> "; 01543 } 01544 } 01545 01546 $query = 01547 $this->db->build_sparql_query("select ?s ?p $d where {graph ?g{?s ?p <" . $u . ">.}}", array ('s', 'p'), 01548 FALSE); 01549 } 01550 01551 $resultset = $this->db->query($query); 01552 01553 if(odbc_error()) 01554 { 01555 $this->conneg->setStatus(500); 01556 $this->conneg->setStatusMsg("Internal Error"); 01557 $this->conneg->setStatusMsgExt($this->errorMessenger->_303 > name); 01558 $this->conneg->setError($this->errorMessenger->_303->id, $this->errorMessenger->ws, 01559 $this->errorMessenger->_303->name, $this->errorMessenger->_303->description, odbc_errormsg(), 01560 $this->errorMessenger->_303->level); 01561 } 01562 01563 while(odbc_fetch_row($resultset)) 01564 { 01565 $s = odbc_result($resultset, 1); 01566 $p = odbc_result($resultset, 2); 01567 01568 if(!isset($this->objectTriples[$u][$p])) 01569 { 01570 $this->objectTriples[$u][$p] = array(); 01571 } 01572 01573 array_push($this->objectTriples[$u][$p], $s); 01574 } 01575 01576 unset($resultset); 01577 } 01578 01579 // Get reification triples 01580 if(strtolower($this->include_reification) == "true") 01581 { 01582 01583 $query = ""; 01584 01585 if($this->globalDataset === FALSE) 01586 { 01587 $query = " select ?rei_p ?rei_o ?p ?o from <" . $d . "reification/> 01588 where 01589 { 01590 ?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <" 01591 . $u 01592 . ">. 01593 ?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> ?rei_p. 01594 ?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?rei_o. 01595 ?statement ?p ?o. 01596 }"; 01597 } 01598 else 01599 { 01600 $d = ""; 01601 01602 foreach($datasets as $dataset) 01603 { 01604 if($dataset != "") 01605 { 01606 $d .= " from named <" . $dataset . "reification/> "; 01607 } 01608 } 01609 01610 $query = " select ?rei_p ?rei_o ?p ?o $d 01611 where 01612 { 01613 graph ?g 01614 { 01615 ?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <" 01616 . $u 01617 . ">. 01618 ?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> ?rei_p. 01619 ?statement <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> ?rei_o. 01620 ?statement ?p ?o. 01621 } 01622 }"; 01623 } 01624 01625 $query = $this->db->build_sparql_query(str_replace(array ("\n", "\r", "\t"), " ", $query), 01626 array ('rei_p', 'rei_o', 'p', 'o'), FALSE); 01627 01628 $resultset = $this->db->query($query); 01629 01630 if(odbc_error()) 01631 { 01632 $this->conneg->setStatus(500); 01633 $this->conneg->setStatusMsg("Internal Error"); 01634 $this->conneg->setStatusMsgExt($this->errorMessenger->_304->name); 01635 $this->conneg->setError($this->errorMessenger->_304->id, $this->errorMessenger->ws, 01636 $this->errorMessenger->_304->name, $this->errorMessenger->_304->description, odbc_errormsg(), 01637 $this->errorMessenger->_304->level); 01638 } 01639 01640 while(odbc_fetch_row($resultset)) 01641 { 01642 $rei_p = odbc_result($resultset, 1); 01643 $rei_o = odbc_result($resultset, 2); 01644 $p = odbc_result($resultset, 3); 01645 $o = odbc_result($resultset, 4); 01646 01647 if($p != "http://www.w3.org/1999/02/22-rdf-syntax-ns#subject" 01648 && $p != "http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate" 01649 && $p != "http://www.w3.org/1999/02/22-rdf-syntax-ns#object" 01650 && $p != "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") 01651 { 01652 if(!isset($this->reificationTriples[$u][$rei_p][$rei_o][$p])) 01653 { 01654 $this->reificationTriples[$u][$rei_p][$rei_o][$p] = array(); 01655 } 01656 01657 array_push($this->reificationTriples[$u][$rei_p][$rei_o][$p], $o); 01658 } 01659 } 01660 01661 unset($resultset); 01662 } 01663 } 01664 } 01665 } 01666 } 01667 01668 01670 01671 ?>
