API Docs for: 0.6.0
Show:

sgvizler.Query Class

Defined in: src/Query.js:2

Available since 0.5

Important class. Runs SPARQL query against SPARQL endpoints.

Dependencies:

  • sgvizler.util
  • sgvizler.namespace
  • sgvizler.registry
  • sgvizler.parser
  • sgvizler.loader
  • sgvizler.logger
  • sgvizler.defaults
  • jQuery
  • google.visualization

Example of how to use the Query class:

var sparqlQueryString = "SELECT * {?s ?p ?o} LIMIT 10",
    containerID = "myElementID",
    Q = new sgvizler.Query();

// Note that default values may be set in the sgvizler object.
Q.query(sparqlQueryString)
    .endpointURL("http://dbpedia.org/sparql")
    .endpointOutputFormat("json")                    // Possible values 'xml', 'json', 'jsonp'.
    .chartFunction("google.visualization.BarChart")  // The name of the function to draw the chart.
    .draw(containerID);                              // Draw the chart in the designated HTML element.

Constructor

sgvizler.Query

(
  • queryOptions
  • chartOptions
)

Defined in src/Query.js:2

Available since 0.5

Parameters:

Methods

addFrom

(
  • url
)
public

Defined in src/Query.js:138

Available since 0.5

Add a url as an RDF source to be included in the SPARQL query in the FROM block.

Parameters:

addListener

(
  • name
  • func
)
private

Defined in src/Query.js:419

Available since 0.6.0

Add a function which is to be fired when the listener named name is fired.

See fireListener

Parameters:

  • name String

    The name of the listener.

  • func Function

    The function to fire.

Example:

addListener("ready", function () { console.log("Ready!") });

chartFunction

(
  • functionName
)
public chainable

Defined in src/Query.js:294

Available since 0.5

Set the name of chart function. The function should be availble in the global object, or registered with dependencies in Sgvizler's registry; see TODO

Parameters:

chartFunction

() String public

Defined in src/Query.js:287

Available since 0.5

Get the name of chart function.

Returns:

chartHeight

() String public

Defined in src/Query.js:308

Available since 0.5

Get the height of the chart container.

Returns:

chartHeight

(
  • height
)
public chainable

Defined in src/Query.js:315

Available since 0.5

Set the height of the chart container.

Parameters:

chartWidth

(
  • width
)
public chainable

Defined in src/Query.js:334

Available since 0.5

Set the width of the chart container.

Parameters:

chartWidth

() String public

Defined in src/Query.js:327

Available since 0.5

Get the width of the chart container.

Returns:

clearFroms

() public

Defined in src/Query.js:150

Available since 0.5

Remove all registered FROMs.

See also addFrom.

datatableFunction

() String public

Defined in src/Query.js:265

Available since 0.5

Get the name of datatable preprocessing function.

Returns:

datatableFunction

(
  • functionName
)
public chainable

Defined in src/Query.js:272

Available since 0.5

Set the name of datatable preprocessing function. The function should be availble in the global object, or registered with dependencies in Sgvizler's registry; see TODO

Parameters:

draw

(
  • containerId
)
public

Defined in src/Query.js:610

Available since 0.5

Draws the result of the query in a given container.

Parameters:

  • containerId String

    The elementId of the container to draw the result of the query.

endpointOutputFormat

() String public

Defined in src/Query.js:207

Available since 0.5

Get endpoint output format.

Returns:

endpointOutputFormat

(
  • format
)
public chainable

Defined in src/Query.js:214

Available since 0.5

Set endpoint output format. Legal values are 'xml', 'json', 'jsonp'.

Parameters:

endpointURL

() String public

Defined in src/Query.js:185

Available since 0.5

Get endpoint URL.

Returns:

endpointURL

(
  • url
)
public chainable

Defined in src/Query.js:192

Available since 0.5

Set endpoint URL.

Parameters:

Example:

sgvizler.endpointURL('http://sparql.dbpedia.org');

sets this Query object's endpoint to DBpedia.

fireListener

(
  • name
)
private

Defined in src/Query.js:442

Available since 0.6.0

Fires (runs, executes) all functions registered on the listener name.

See addListener.

Parameters:

  • name String

    The name of the listener.

getDataTable

(
  • success
  • fail
)
public async

Defined in src/Query.js:694

Parameters:

getEncodedQuery

() String public

Defined in src/Query.js:346

Available since 0.5

Get the query string with prefixes added and encoded for URL insertion.

Returns:

getGoogleJSON

(
  • data
)
JSON private

Defined in src/Query.js:397

Available since 0.5

Converts "raw" query results into Google JSON, using sgvizler.parser.

Parameters:

  • data Object

    Query result set

Returns:

JSON:

JSON edable by google.visualization.DataTable

getResultRowCount

(
  • dataTable
)
Number private

Defined in src/Query.js:377

Available since 0.5

Sets and returns noOfResults, i.e., the number of rows in the query result.

Parameters:

  • dataTable google.visualization.DataTable

Returns:

insertFrom

() private

Defined in src/Query.js:358

Available since 0.5

Extends the query string by including the urls in from as FROM statements in the (SPARQL) query.

query

(
  • queryString
)
public chainable

Defined in src/Query.js:172

Set query string.

Parameters:

query

() String public

Defined in src/Query.js:166

Get query string.

Returns:

saveDataTable

() jQuery.Promise private async

Defined in src/Query.js:557

Available since 0.5

Converts the the query result set into a google.visualization.DataTable, and if specified, applies datatable preprocessing function, and saves the datatable in the private property dataTable.

Returns:

jQuery.Promise:

A Promise which resolves when the datatable is saved.

saveQueryResults.

() jQuery.Promise private async

Defined in src/Query.js:517

Available since 0.5

Saves the query result set in the private property results. Works like a wrapper for sendQuery().

See also saveDataTable().

Returns:

jQuery.Promise:

A Promise which resolves when the results are saved.

sendQuery

() jQuery.Promise private async

Defined in src/Query.js:461

Available since 0.5

Sends query to endpoint using AJAX. "Low level" method, consider using saveQueryResults().

Returns:

jQuery.Promise:

A Promise containing the query results.

validatorURL

() String public

Defined in src/Query.js:232

Available since 0.5

Get URL to online SPARQL query validator.

Returns:

validatorURL

(
  • url
)
public chainable

Defined in src/Query.js:239

Available since 0.5

Set URL to online SPARQL query validator. Appending a SPARQL query to the end of this URL should give a page which validates the given query.

Parameters:

Example:

TODO

Properties

chartOptions

Object private

Defined in src/Query.js:78

Available since 0.5

Contains properties relevant for chart drawing business. Get and set values using get/setter functions.

Default values are found in sgvizler.defaults (these may be get/set with the get/setter function on the sgvizler class) and are loaded on construction---and get overwritten by properties in the constructed parameter.

dataTable

google.visualization.DataTable private

Defined in src/Query.js:98

Available since 0.5

DataTable query results.

noOfResults

Number public

Defined in src/Query.js:116

Available since 0.5

The number of rows in the query results.

queryOptions

Object private

Defined in src/Query.js:62

Available since 0.5

Contains properties relevant for query business. Get and set values using get/setter functions.

Default values are found in sgvizler.defaults (these may be get/set with the get/setter function on the sgvizler class) and are loaded on construction---and get overwritten by properties in the constructed parameter.

queryResult

Object either XML or JSON private

Defined in src/Query.js:107

Available since 0.5

The raw results as retuned by the endpoint.