/** * @since 2.0 * @param Query $query * * @return QueryResult|string */ public function getQueryResult(Query $query) { if ((!$this->engineOptions->get('smwgIgnoreQueryErrors') || $query->getDescription() instanceof ThingDescription) && $query->querymode != Query::MODE_DEBUG && count($query->getErrors()) > 0) { return $this->queryResultFactory->newEmptyQueryResult($query, false); } // don't query, but return something to the printer if ($query->querymode == Query::MODE_NONE || $query->getLimit() < 1) { return $this->queryResultFactory->newEmptyQueryResult($query, true); } $this->compoundConditionBuilder->setSortKeys($query->sortkeys); $compoundCondition = $this->compoundConditionBuilder->getConditionFrom($query->getDescription()); $query->addErrors($this->compoundConditionBuilder->getErrors()); if ($query->querymode == Query::MODE_DEBUG) { return $this->getDebugQueryResult($query, $compoundCondition); } elseif ($query->querymode == Query::MODE_COUNT) { return $this->getCountQueryResult($query, $compoundCondition); } return $this->getInstanceQueryResult($query, $compoundCondition); }
public function testSingletonLikeConditionForSolitaryWpgValue() { $description = new ValueDescription(new DIWikiPage("Foo*", NS_MAIN), null, SMW_CMP_LIKE); $instance = new CompoundConditionBuilder($this->descriptionInterpreterFactory); $condition = $instance->getConditionFrom($description); $this->assertInstanceOf('\\SMW\\SPARQLStore\\QueryEngine\\Condition\\SingletonCondition', $condition); $expectedConditionString = $this->stringBuilder->addString('FILTER( regex( ?v1, "^Foo.*$", "s") )')->addNewLine()->addString('?result swivt:wikiPageSortKey ?v1 .')->addNewLine()->addString(' OPTIONAL { ?result swivt:redirectsTo ?o2 } .')->addNewLine()->addString(' FILTER ( !bound( ?o2 ) ) .')->addNewLine()->getString(); $this->assertEquals($expectedConditionString, $instance->convertConditionToString($condition)); }