r97416 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97415‎ | r97416 | r97417 >
Date:13:01, 18 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
finished up alpha of ask api
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/api/ApiAsk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/api/ApiAskArgs.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/api/ApiSMWQuery.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiAskArgs.php
@@ -69,7 +69,8 @@
7070
7171 public function getDescription() {
7272 return array(
73 - 'API module to query SMW by providing a query specified as a list of conditions, printeouts and parameters.'
 73+ 'API module to query SMW by providing a query specified as a list of conditions, printeouts and parameters.
 74+ This API module is in alpha stage, and likely to see changes in upcomming versions of SMW.'
7475 );
7576 }
7677
Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiSMWQuery.php
@@ -55,8 +55,20 @@
5656 }
5757
5858 protected function addQueryResult( SMWQueryResult $queryResult ) {
59 - // TODO: create general SMWQueryResult serialization method that can then also be used for JSON printer
60 - $this->getResult()->addValue( 'query', null, $queryResult->serializeToArray() );
 59+ $serialized = $queryResult->serializeToArray();
 60+ $result = $this->getResult();
 61+
 62+ $result->setIndexedTagName( $serialized['results'], 'result' );
 63+ $result->setIndexedTagName( $serialized['printrequests'], 'printrequest' );
 64+
 65+ $result->addValue( 'query', null, $serialized );
 66+
 67+ if ( $queryResult->hasFurtherResults() ) {
 68+ // TODO: obtain continuation data from store
 69+ $result->disableSizeCheck();
 70+ $result->addValue( 'query-continue', null, 0 );
 71+ $result->enableSizeCheck();
 72+ }
6173 }
6274
6375 public function getPossibleErrors() {
Index: trunk/extensions/SemanticMediaWiki/includes/api/ApiAsk.php
@@ -18,9 +18,17 @@
1919 $params = $this->extractRequestParams();
2020 $this->requireParameters( $params, array( 'query' ) );
2121
22 - // SMWQueryProcessor::processFunctionParams( $rawparams, $queryString, $m_params, $m_printouts);
 22+ $rawParams = explode( '|', $params['query'] );
 23+ $queryString = '';
 24+ $printeouts = array();
2325
24 - $queryResult = $this->getQueryResult( $this->getQuery( $params['query'] ) );
 26+ SMWQueryProcessor::processFunctionParams( $rawParams, $queryString, $this->parameters, $printeouts );
 27+
 28+ $queryResult = $this->getQueryResult( $this->getQuery(
 29+ $queryString,
 30+ $printeouts
 31+ ) );
 32+
2533 $this->addQueryResult( $queryResult );
2634 }
2735
@@ -40,7 +48,8 @@
4149
4250 public function getDescription() {
4351 return array(
44 - 'API module to query SMW by providing a query in the ask language.'
 52+ 'API module to query SMW by providing a query in the ask language.
 53+ This API module is in alpha stage, and likely to see changes in upcomming versions of SMW.'
4554 );
4655 }
4756