dojox/data/WikipediaStore (version 1.10)

dojox/data/ServiceStore

Summary

Initializer for the Wikipedia data store interface.

The WikipediaStore is a data store interface to Wikipedia, using the Wikipedia SMD spec from dojox.rpc. It currently is useful only for finding articles that contain some particular text or grabbing single articles by full name; no wildcards or other filtering are supported.

Usage

var foo = new WikipediaStore(options);
dojox/data/WikipediaStore
Parameter Type Description
options undefined

See the dojox/data/WikipediaStore reference documentation for more information.

Examples

Example 1

var store = new dojox.data.WikipediaStore();
store.fetch({
    query: {title:"Dojo Toolkit"},
    onItem: function(item){
        dojo.byId("somediv").innerHTML = item.text["*"];
    }
});

Property Summary

  • _currentId
  • estimateCountFactorThis parameter is used by the ServiceStore to estimate the total count.
  • idAttributeDefaults to 'id'.
  • labelAttribute
  • loadLazyValues
  • schemaThis is a schema object for this store.
  • serviceThis is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded
  • syncModeSetting this to true will set the store to using synchronous calls by default.

Method Summary

  • _doQuery(args)
  • _processResults(results,def)
  • close(request)
  • containsValue(item,attribute,value) Checks to see if 'item' has 'value' at 'attribute'
  • fetch(request) Fetch a page or some partially-loaded search results from Wikipedia.
  • fetchItemByIdentity(args) fetch an item by its identity, by looking in our index of what we have loaded
  • getAttributes(item) Gets the available attributes of an item's 'property' and returns it as an array.
  • getFeatures() return the store feature set
  • getIdentity(item)
  • getIdentityAttributes(item) returns the attributes which are used to make up the identity of an item.
  • getLabel(item) returns the label for an item.
  • getLabelAttributes(item) returns an array of attributes that are used to create the label of an item
  • getSchema() Returns a reference to the JSON Schema
  • getValue(item,property,defaultValue) Gets the value of an item's 'property'
  • getValues(item,property) Gets the value of an item's 'property' and returns it.
  • hasAttribute(item,attribute) Checks to see if item has attribute
  • isItem(item) Checks to see if the argument is an item
  • isItemLoaded(item) Checks to see if the item is loaded.
  • loadItem(args) Loads an item and calls the callback handler.

Properties

_currentId
estimateCountFactor

This parameter is used by the ServiceStore to estimate the total count. When paging is indicated in a fetch and the response includes the full number of items requested by the fetch's count parameter, then the total count will be estimated to be estimateCountFactor multiplied by the provided count. If this is 1, then it is assumed that the server does not support paging, and the response is the full set of items, where the total count is equal to the numer of items returned. If the server does support paging, an estimateCountFactor of 2 is a good value for estimating the total count It is also possible to override _processResults if the server can provide an exact total count.

idAttribute

Defaults to 'id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index.

labelAttribute
loadLazyValues
schema

This is a schema object for this store. This should be JSON Schema format.

service

This is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded

syncMode

Setting this to true will set the store to using synchronous calls by default. Sync calls return their data immediately from the calling function, so callbacks are unnecessary. This will only work with a synchronous capable service.

Methods

_doQuery(args)
Parameter Type Description
args undefined
Returns:undefined
_processResults(results,def)
Parameter Type Description
results undefined
def undefined
Returns:undefined
close(request)
Parameter Type Description
request undefined
Returns:undefined
containsValue(item,attribute,value)

Checks to see if 'item' has 'value' at 'attribute'

Parameter Type Description
item Object
attribute String
value Anything
Returns:boolean
fetch(request)

Fetch a page or some partially-loaded search results from Wikipedia. Note that there isn't a way to sort data coming in from the API, so we just ignore the sort parameter.

Parameter Type Description
request object
Returns:undefined

Examples

Example 1

Loading a page:

store.fetch({
    query: {title:"Dojo Toolkit"},
    // define your handlers here
});

Example 2

Searching for pages containing "dojo":

store.fetch({
    query: {
        action: "query",
        text: "dojo"
    },
    // define your handlers here
});

Example 3

Searching for the next 50 pages containing "dojo":

store.fetch({
    query: {
        action: "query",
        text: "dojo",
        start: 10,
        count: 50 // max 500; will be capped if necessary
    },
    // define your handlers here
});
fetchItemByIdentity(args)

fetch an item by its identity, by looking in our index of what we have loaded

Parameter Type Description
args undefined
Returns:undefined
getAttributes(item)

Gets the available attributes of an item's 'property' and returns it as an array.

Parameter Type Description
item Object
Returns:Array
getFeatures()

return the store feature set

Returns:object
getIdentity(item)
Parameter Type Description
item undefined
Returns:undefined
getIdentityAttributes(item)

returns the attributes which are used to make up the identity of an item. Basically returns this.idAttribute

Parameter Type Description
item undefined
Returns:Array
getLabel(item)

returns the label for an item. Just gets the "label" attribute.

Parameter Type Description
item undefined
Returns:undefined
getLabelAttributes(item)

returns an array of attributes that are used to create the label of an item

Parameter Type Description
item undefined
Returns:Array
getSchema()

Returns a reference to the JSON Schema

Returns:Object | undefined
getValue(item,property,defaultValue)

Gets the value of an item's 'property'

Parameter Type Description
item Object

The item to get the value from

property String

property to look up value for

defaultValue value
Optional

the default value

Returns:return the plain value since it was found;
getValues(item,property)

Gets the value of an item's 'property' and returns it. If this value is an array it is just returned, if not, the value is added to an array and that is returned.

Parameter Type Description
item Object
property String

property to look up value for

Returns:Array
hasAttribute(item,attribute)

Checks to see if item has attribute

Parameter Type Description
item Object
attribute String
Returns:boolean
isItem(item)

Checks to see if the argument is an item

Parameter Type Description
item Object
Returns:boolean
isItemLoaded(item)

Checks to see if the item is loaded.

Parameter Type Description
item object
Returns:undefined
loadItem(args)

Loads an item and calls the callback handler. Note, that this will call the callback handler even if the item is loaded. Consequently, you can use loadItem to ensure that an item is loaded is situations when the item may or may not be loaded yet. If you access a value directly through property access, you can use this to load a lazy value as well (doesn't need to be an item).

Parameter Type Description
args undefined
Returns:undefined

Examples

Example 1

store.loadItem({
    item: item, // this item may or may not be loaded
    onItem: function(item){
        // do something with the item
    }
});
Error in the documentation? Can’t find what you are looking for? Let us know!