コード例 #1
0
 private function getInstanceQueryResult(Query $query, Condition $compoundCondition)
 {
     if ($this->isSingletonConditionWithElementMatch($compoundCondition)) {
         $matchElement = $compoundCondition->matchElement;
         if ($compoundCondition->condition === '') {
             // all URIs exist, no querying
             $results = array(array($matchElement));
         } else {
             $condition = $this->compoundConditionBuilder->convertConditionToString($compoundCondition);
             $namespaces = $compoundCondition->namespaces;
             $askQueryResult = $this->connection->ask($condition, $namespaces);
             $results = $askQueryResult->isBooleanTrue() ? array(array($matchElement)) : array();
         }
         $repositoryResult = new RepositoryResult(array(self::RESULT_VARIABLE => 0), $results);
     } elseif ($compoundCondition instanceof FalseCondition) {
         $repositoryResult = new RepositoryResult(array(self::RESULT_VARIABLE => 0), array());
     } else {
         $condition = $this->compoundConditionBuilder->convertConditionToString($compoundCondition);
         $namespaces = $compoundCondition->namespaces;
         $options = $this->getOptions($query, $compoundCondition);
         $options['DISTINCT'] = true;
         $repositoryResult = $this->connection->select('?' . self::RESULT_VARIABLE, $condition, $options, $namespaces);
     }
     return $this->queryResultFactory->newQueryResult($repositoryResult, $query);
 }
コード例 #2
0
ファイル: QueryEngine.php プロジェクト: Rikuforever/wiki
 /**
  * Get the results for a query in instance retrieval mode.
  *
  * @param Query $query
  *
  * @return QueryResult
  */
 public function getInstanceQueryResult(Query $query)
 {
     $this->sortkeys = $query->sortkeys;
     $this->compoundConditionBuilder->setSortKeys($this->sortkeys);
     $sparqlCondition = $this->compoundConditionBuilder->buildCondition($query->getDescription());
     $query->addErrors($this->compoundConditionBuilder->getErrors());
     if ($sparqlCondition instanceof SingletonCondition) {
         $matchElement = $sparqlCondition->matchElement;
         if ($sparqlCondition->condition === '') {
             // all URIs exist, no querying
             $results = array(array($matchElement));
         } else {
             $condition = $this->compoundConditionBuilder->convertConditionToString($sparqlCondition);
             $namespaces = $sparqlCondition->namespaces;
             $askQueryResult = $this->connection->ask($condition, $namespaces);
             $results = $askQueryResult->isBooleanTrue() ? array(array($matchElement)) : array();
         }
         $repositoryResult = new RepositoryResult(array(self::RESULT_VARIABLE => 0), $results);
     } elseif ($sparqlCondition instanceof FalseCondition) {
         $repositoryResult = new RepositoryResult(array(self::RESULT_VARIABLE => 0), array());
     } else {
         $condition = $this->compoundConditionBuilder->convertConditionToString($sparqlCondition);
         $namespaces = $sparqlCondition->namespaces;
         $options = $this->getOptions($query, $sparqlCondition);
         $options['DISTINCT'] = true;
         $repositoryResult = $this->connection->select('?' . self::RESULT_VARIABLE, $condition, $options, $namespaces);
     }
     return $this->queryResultFactory->newQueryResult($repositoryResult, $query);
 }
コード例 #3
0
 private function lookupResourceUriTargetFromDatabase(ExpNsResource $expNsResource)
 {
     $resourceUri = TurtleSerializer::getTurtleNameForExpElement($expNsResource);
     $rediUri = TurtleSerializer::getTurtleNameForExpElement(Exporter::getInstance()->getSpecialPropertyResource('_REDI'));
     $skeyUri = TurtleSerializer::getTurtleNameForExpElement(Exporter::getInstance()->getSpecialPropertyResource('_SKEY'));
     $respositoryResult = $this->repositoryConnection->select('*', "{$resourceUri} {$skeyUri} ?s  OPTIONAL { {$resourceUri} {$rediUri} ?r }", array('LIMIT' => 1), array($expNsResource->getNamespaceId() => $expNsResource->getNamespace()));
     return $respositoryResult->current();
 }