This is a library specific extension to the RDF API and RDFa API. * \note For further information see the section * \htmllink{page_w3cspecs.html,W3C Specifications Overview and Library Compatibility} * \author Christian Langanke * \author Adrian Gschwend * \date 2011 */ class SparqlQuery { /** * Version of the class */ const version = '1.0.0'; /** * Name of the fDebug context */ const debugcontext = 'RDFA_SPARQLQUERY'; private $debugger; private $endpoint; private $statement; // --------------------------------------- /** * Creates a SPARQL qery class instance. * * \param endpoint instance of SparqlEndpoint holding the endpoint configuration * \param statement SPARQL CONSTRUCT query statement to execute. * * \exception Exception The parameter endpoint is not of object rdfa::SparqlEndpoint * * \note To effectively execute the query, invoke the method * - rdfa::SparqlQuery::run() */ public function __construct( $endpoint, $statement) { // setup debugger $this->debugger = \fDebug::getInstance(); // check for required class if ((!is_object( $endpoint)) || ('\\' . get_class( $endpoint) != '\\rdfa\\SparqlEndpoint')) throw new \Exception( get_class().'::__construct: Parameter $endpoint is not object of class \rdfa\SparqlEndpoint.'); // check for statement, may not be empty if (strlen( $statement) < 1) throw new \Exception( get_class().'::__construct: Parameter $statement is empty.'); // initialize instance vars $this->endpoint = $endpoint; $this->statement = $statement; $debugmessage = "Creating SPARQL query object\n" . "SPARQL query statement: \n" . $this->getStatement(); $this->debugger->sendMessage( $debugmessage, self::debugcontext); } // public function __construct // --------------------------------------- /** * Gets the SPARQL query statementof the object. * * \retval string SPARQL statement */ public function getStatement() { return $this->statement; } // --------------------------------------- /** * Runs the SPARQL query of the object. * * \retval array indexed RDF data in internal format */ public function run() { $debugmessage = "Executing SPARQL query\n" . "SPARQL query statement: \n" . $this->getStatement(); $this->debugger->sendMessage( $debugmessage, self::debugcontext); $core = new \rdfint_core\Core(); return $core->runQuery( $this->endpoint->getConfigurationValues(), $this->statement); } } // class SparqlEndpoint ?>