/** * Send the HTTP query to the endpoint. This function should be called * once all the settings/parameters of the query have been previously * configured. * * @param $query_extension - an optional QueryExtension * object * * @author Frederick Giasson, Structured Dynamics LLC. */ public function send($query_extension = NULL) { $parameters = ""; if ($query_extension !== NULL) { $query_extension->alterParams($this, $this->params); } foreach ($this->params as $param => $value) { $parameters .= $param . "=" . $value . "&"; } $parameters = trim($parameters, "&"); $wsq = new WebServiceQuerier(rtrim($this->network, "/") . "/" . $this->endpoint, $this->method, $this->mime == "resultset" ? "text/xml" : $this->mime, $parameters, $this->timeout, $query_extension); $this->httpStatus = $wsq->getStatus(); $this->httpStatusMessage = $wsq->getStatusMessage(); $this->httpStatusMessageDescription = $wsq->getStatusMessageDescription(); $this->error = $wsq->error; if ($wsq->getStatus() == 200) { if ($this->mime != "resultset") { $this->resultset = $wsq->getResultset(); } else { $data = $wsq->getResultset(); if ($data != "") { $resultset = new Resultset(); $resultset->importStructXMLResultset($data); $this->resultset = $resultset; } } } unset($wsq); return $this; }
private function fixURIReference($unexistingURI, $affectedURI, $dataset) { $crudRead = new CrudReadQuery($this->network); $crudRead->dataset($dataset)->uri($affectedURI)->excludeLinksback()->includeReification()->mime('resultset')->send(); if ($crudRead->isSuccessful()) { $resultset = $crudRead->getResultset()->getResultset(); // Remove that triple from the record's description foreach ($resultset[$dataset][$affectedURI] as $property => $values) { if (is_array($values) && $property != 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') { foreach ($values as $key => $value) { if (isset($value['uri']) && $value['uri'] == $unexistingURI) { unset($resultset[$dataset][$affectedURI][$property][$key]); $rset = new Resultset($this->network); $rset->setResultset($resultset); // Use the CRUD: Update endpoint to do the modifications. That way we will revision all the changes // performed by this fix procedure. $crudUpdate = new CrudUpdateQuery($this->network); $crudUpdate->dataset($dataset)->createRevision()->isPublished()->document($rset->getResultsetRDFN3())->documentMimeIsRdfN3()->send(); if ($crudUpdate->isSuccessful()) { cecho(' -> <' . $dataset . '> <' . $affectedURI . '> <' . $property . '> <' . $unexistingURI . "> (fixed)\n", 'LIGHT_BLUE'); if (!isset($this->deletedNTriples[$dataset])) { $this->deletedNTriples[$dataset] = array(); } if (!isset($this->deletedNTriples[$dataset][$affectedURI])) { $this->deletedNTriples[$dataset][$affectedURI] = array(); } if (!isset($this->deletedNTriples[$dataset][$affectedURI][$property])) { $this->deletedNTriples[$dataset][$affectedURI][$property] = array(); } $this->deletedNTriples[$dataset][$affectedURI][$property][] = $unexistingURI; } else { cecho("We couldn't update the description of an affected record from the structWSF instance\n", 'YELLOW'); $this->errors[] = array('id' => 'URI-EXISTENCE-53', 'type' => 'warning', ''); } } } } } } else { cecho("We couldn't read the description of an affected record from the structWSF instance\n", 'YELLOW'); $this->errors[] = array('id' => 'URI-EXISTENCE-52', 'type' => 'warning'); } }