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);
 }
Example #2
0
 /**
  * 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);
 }