getSPARQLPlusParser() static public method

static public getSPARQLPlusParser ( $a = '' )
 public function testBlockUpdateWithoutGraph()
 {
     global $prefixSparql, $graph1;
     $q = $prefixSparql . " \n\t\t\tINSERT DATA { \n\t\t\t\ta:A b:Name \"Test2\" . \n    \t\t}";
     $p = ARC2::getSPARQLPlusParser();
     $p->parse($q);
     $infos = $p->getQueryInfos();
     $t1 = ARC2::mtime();
     $err = $p->getErrors();
     if ($err) {
         print_r($err);
         $this->assertTrue(true);
     } else {
         $this->assertTrue(false);
     }
     $q = $prefixSparql . " \n\t\t\tDELETE DATA { \n\t\t\t\ta:A b:Name \"Test2\" . \n    \t\t}";
     $p = ARC2::getSPARQLPlusParser();
     $p->parse($q);
     $infos = $p->getQueryInfos();
     $t1 = ARC2::mtime();
     $err = $p->getErrors();
     if ($err) {
         print_r($err);
         $this->assertTrue(true);
     } else {
         $this->assertTrue(false);
     }
 }
 function __construct()
 {
     parent::__construct('SPARQLEndpoint');
     # Set up some stuff
     $this->sparqlendpointconfig = $this->getSPARQLEndpointConfig();
     $this->sparqlendpoint = ARC2::getStoreEndpoint($this->sparqlendpointconfig);
     $this->sparqlparser = ARC2::getSPARQLPlusParser();
     $this->store = new RDFIOARC2StoreWrapper();
     $this->user = new RDFIOUser();
     $this->requestdata = null;
 }
    function __construct() {
        global $wgUser, $rdfiogQueryByOrigURI;

        parent::__construct( 'SPARQLEndpoint' );
        $this->m_sparqlendpointconfig = $this->getSPARQLEndpointConfig();
        $this->m_sparqlendpoint = ARC2::getStoreEndpoint( $this->m_sparqlendpointconfig );
        $this->m_sparqlparser = ARC2::getSPARQLPlusParser();
        $this->m_store = new RDFIOStore();

        $userrights = $wgUser->getRights();
        if ( in_array( 'edit', $userrights ) && in_array( 'createpage', $userrights ) ) {
            $this->m_haswriteaccess = true;
        } else {
            $this->m_haswriteaccess = false;
        }
        if ( in_array( 'edit', $userrights ) && in_array( 'delete', $userrights ) ) {
            $this->m_hasdeleteaccess = true;
        } else {
            $this->m_hasdeleteaccess = false;
        }
    }
Example #4
0
 /**
  * This function parse a SPARQL query, send the query and parse the SPARQL result in a array. 
  * You can custom the result with the parameter $result_format : 
  * <ul>
  * <li>rows to return array of results
  * <li>row to return array of first result
  * <li>raw to return boolean for request ask, insert and delete
  * </ul>
  * @param string $q : Query SPARQL 
  * @param string $result_format : Optional,  rows, row or raw
  * @return array|boolean in function of parameter $result_format
  * @access public
  */
 public function query($q, $result_format = '')
 {
     if ($this->_debug) {
         print date('Y-m-d\\TH:i:s\\Z', time()) . ' : ' . $q . '' . "\n\n";
     }
     $p = ARC2::getSPARQLPlusParser();
     $p->parse($q);
     $infos = $p->getQueryInfos();
     $t1 = ARC2::mtime();
     if (!($errs = $p->getErrors())) {
         $qt = $infos['query']['type'];
         $r = array('query_type' => $qt, 'result' => $this->runQuery($q, $qt, $infos));
     } else {
         $r = array('result' => '');
         if ($this->_debug) {
             print date('Y-m-d\\TH:i:s\\Z', time()) . ' : ERROR ' . $q . '' . "\n\n";
             print_r($errs);
         }
         return $this->_arc2_RemoteStore->addError($p->getErrors());
     }
     $t2 = ARC2::mtime();
     $r['query_time'] = $t2 - $t1;
     /* query result */
     if ($result_format == 'raw') {
         return $r['result'];
     }
     if ($result_format == 'rows') {
         return $this->_arc2_RemoteStore->v('rows', array(), $r['result']);
     }
     if ($result_format == 'row') {
         if (!isset($r['result']['rows'])) {
             return array();
         }
         return $r['result']['rows'] ? $r['result']['rows'][0] : array();
     }
     return $r;
 }