private function getDebugQueryResult(Query $query, Condition $compoundCondition) { $entries = array(); if ($this->isSingletonConditionWithElementMatch($compoundCondition)) { if ($compoundCondition->condition === '') { // all URIs exist, no querying $sparql = 'None (no conditions).'; } else { $condition = $this->compoundConditionBuilder->convertConditionToString($compoundCondition); $namespaces = $compoundCondition->namespaces; $sparql = $this->connection->getSparqlForAsk($condition, $namespaces); } } elseif ($compoundCondition instanceof FalseCondition) { $sparql = 'None (conditions can not be satisfied by anything).'; } else { $condition = $this->compoundConditionBuilder->convertConditionToString($compoundCondition); $namespaces = $compoundCondition->namespaces; $options = $this->getOptions($query, $compoundCondition); $options['DISTINCT'] = true; $sparql = $this->connection->getSparqlForSelect('?' . self::RESULT_VARIABLE, $condition, $options, $namespaces); } $sparql = str_replace(array('[', ':', ' '), array('[', ':', ' '), $sparql); $entries['SPARQL Query'] = '<div class="smwpre">' . $sparql . '</div>'; return DebugOutputFormatter::formatOutputFor('SPARQLStore', $entries, $query); }
/** * Get the output string for a query in debugging mode. * * @param Query $query * * @return string */ public function getDebugQueryResult(Query $query) { $this->sortkeys = $query->sortkeys; $this->compoundConditionBuilder->setSortKeys($this->sortkeys); $sparqlCondition = $this->compoundConditionBuilder->buildCondition($query->getDescription()); $query->addErrors($this->compoundConditionBuilder->getErrors()); $entries = array(); if ($sparqlCondition instanceof SingletonCondition) { if ($sparqlCondition->condition === '') { // all URIs exist, no querying $sparql = 'None (no conditions).'; } else { $condition = $this->compoundConditionBuilder->convertConditionToString($sparqlCondition); $namespaces = $sparqlCondition->namespaces; $sparql = $this->connection->getSparqlForAsk($condition, $namespaces); } } elseif ($sparqlCondition instanceof FalseCondition) { $sparql = 'None (conditions can not be satisfied by anything).'; } else { $condition = $this->compoundConditionBuilder->convertConditionToString($sparqlCondition); $namespaces = $sparqlCondition->namespaces; $options = $this->getOptions($query, $sparqlCondition); $options['DISTINCT'] = true; $sparql = $this->connection->getSparqlForSelect('?' . self::RESULT_VARIABLE, $condition, $options, $namespaces); } $sparql = str_replace(array('[', ':', ' '), array('[', ':', ' '), $sparql); $entries['SPARQL Query'] = "<pre>{$sparql}</pre>"; return QueryOutputFormatter::formatDebugOutput('SPARQLStore', $entries, $query); }
private function getDebugQueryResult(Query $query, Condition $compoundCondition) { $entries = array(); if ($this->isSingletonConditionWithElementMatch($compoundCondition)) { if ($compoundCondition->condition === '') { // all URIs exist, no querying $sparql = 'None (no conditions).'; } else { $condition = $this->compoundConditionBuilder->convertConditionToString($compoundCondition); $namespaces = $compoundCondition->namespaces; $sparql = $this->connection->getSparqlForAsk($condition, $namespaces); } } elseif ($compoundCondition instanceof FalseCondition) { $sparql = 'None (conditions can not be satisfied by anything).'; } else { $condition = $this->compoundConditionBuilder->convertConditionToString($compoundCondition); $namespaces = $compoundCondition->namespaces; $options = $this->getOptions($query, $compoundCondition); $options['DISTINCT'] = true; $sparql = $this->connection->getSparqlForSelect('?' . self::RESULT_VARIABLE, $condition, $options, $namespaces); } $entries['SPARQL Query'] = QueryDebugOutputFormatter::doFormatSPARQLStatement($sparql); return QueryDebugOutputFormatter::getStringFrom('SPARQLStore', $entries, $query); }