dojox/data/CdfStore (version 1.10)

Summary

IMPORTANT: The CDF Store is designed to work with Tibco GI, and references Tibco's JSX3 JavaScript library and will not work without it.

The CDF Store implements dojo.data.Read, Write, and Identity api's. It is a local (in memory) store that handles XML documents formatted according to the Common Data Format (CDF) spec: http://www.tibco.com/devnet/resources/gi/3_1/tips_and_techniques/CommonDataFormatCDF.pdf

The purpose of this store is to provide a glue between a jsx3 CDF file and a Dijit.

While a CDF document is an XML file, other than the initial input, all data returned from and written to this store should be in object format.

Usage

var foo = new CdfStore(args);
dojox/data/CdfStore
Parameter Type Description
args Object

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

Property Summary

  • dataA object that will be converted into the xmlStr property, and then parsed into a CDF.
  • identityThe unique identifier for each item.
  • labelThe property within each item used to define the item.
  • mode
  • url
  • xmlStrA string that can be parsed into an XML document and should be formatted according to the CDF spec.

Method Summary

  • _getItems(cdfDoc,request) Internal method.
  • _loadCDF() Internal method.
  • _makeDirty(item) Internal method.
  • _makeXmlString(obj) Internal method.
  • byId(args)
  • close(request) See dojo/data/api/Read.close()
  • containsValue(item,property,value) Check whether an item contains a value
  • deleteItem(item) Delete an jsx3.xml.Entity (wrapper to a XML element).
  • fetch(request) Returns an Array of items based on the request arguments.
  • fetchItemByIdentity(args) See dojo/data/api/Identity.fetchItemByIdentity(keywordArgs).
  • getAttributes(item) Return an array of property names
  • getFeatures() Return supported data APIs
  • getIdentity(item) Returns the identifier for an item.
  • getIdentityAttributes(item) Returns the property used for the identity.
  • getLabel(item) See dojo/data/api/Read.getLabel()
  • getLabelAttributes(item) returns an array of what properties of the item that were used to generate its label See dojo/data/api/Read.getLabelAttributes()
  • getValue(item,property,defaultValue) Return an property value of an item
  • getValues(item,property) Return an array of values
  • hasAttribute(item,property) Check whether an item has a property
  • hasProperty(item,property) Alias for hasAttribute
  • isDirty(item) Check whether an item is new, modified or deleted.
  • isItem(something) Check whether the object is an item (jsx3.xml.Entity)
  • isItemLoaded(something) Check whether the object is a jsx3.xml.Entity object and loaded
  • loadItem(keywordArgs) Load an item
  • newItem(keywordArgs,parentInfo) Creates a jsx3.xml.Entity item and inserts it either inside the parent or appends it to the root
  • revert() Invalidate changes (new and/or modified elements) Resets data by simply deleting the reference to the cdfDoc.
  • setValue(item,property,value) Set an property value
  • setValues(item,property,values) Set property values.
  • unsetAttribute(item,property) Remove an property

Properties

data
Defined by: dojox/data/CdfStore

A object that will be converted into the xmlStr property, and then parsed into a CDF.

identity
Defined by: dojox/data/CdfStore

The unique identifier for each item. Defaults to "jsxid" which is standard for a CDF document. Should not be changed.

label
Defined by: dojox/data/CdfStore

The property within each item used to define the item.

mode
Defined by: dojox/data/CdfStore
url
Defined by: dojox/data/CdfStore
xmlStr
Defined by: dojox/data/CdfStore

A string that can be parsed into an XML document and should be formatted according to the CDF spec.

Methods

_getItems(cdfDoc,request)
Defined by dojox/data/CdfStore

Internal method. Requests the items from jsx3.xml.Entity with an xpath query.

Parameter Type Description
cdfDoc jsx3.xml.Entity
request Object
Returns:Array
_loadCDF()
Defined by dojox/data/CdfStore

Internal method. If a cdfDoc exists, return it. Otherwise, get one from JSX3, load the data or url, and return the doc or a deferred.

Returns:undefined | instance
_makeDirty(item)
Defined by dojox/data/CdfStore

Internal method. Marks items as modified, deleted or new.

Parameter Type Description
item undefined
_makeXmlString(obj)
Defined by dojox/data/CdfStore

Internal method. Converts an object into an XML string.

Parameter Type Description
obj undefined
Returns:undefined
byId(args)
Defined by dojox/data/CdfStore
Parameter Type Description
args Object | String
close(request)
Defined by dojox/data/CdfStore

See dojo/data/api/Read.close()

Parameter Type Description
request dojo/data/api/Request | Object
Optional
containsValue(item,property,value)
Defined by dojox/data/CdfStore

Check whether an item contains a value

Parameter Type Description
item jsx3.xml.Entity
property String
value anything
Returns:boolean
deleteItem(item)
Defined by dojox/data/CdfStore

Delete an jsx3.xml.Entity (wrapper to a XML element).

Parameter Type Description
item jsx3.xml.Entity
Returns:boolean
fetch(request)
Defined by dojox/data/CdfStore

Returns an Array of items based on the request arguments.

Returns an Array of items based on the request arguments. If the store is in ASYNC mode, the items should be expected in an onComplete method passed in the request object. If store is in SYNC mode, the items will be return directly as well as within the onComplete method.

note: The mode can be set on store initialization or during a fetch as one of the parameters.

See:

See dojo.data.Read.fetch():

  • onBegin
  • onComplete
  • onItem
  • onError
  • scope
  • start
  • count
  • sort
Parameter Type Description
request String
Optional

The items in the store are treated as objects, but this is reading an XML document. Further, the actual querying of the items takes place in Tibco GI's jsx3.xml.Entity. Therefore, we are using their syntax which is xpath.

Note: As conforming to a CDF document, most, if not all nodes are considered "records" and their tagNames are as such. The root node is named "data".

Returns:boolean | undefined

Examples

Example 1

All items:

store.fetch({query:"*"});

Example 2

Item with a jsxid attribute equal to "1" (note you could use byId for this)

store.fetch({query:"//record[@jsxid='1']"});

Example 3

All items with any jsxid attribute:

"//record[@jsxid='*']"

Example 4

The items with a jsxid of '1' or '4':

"//record[@jsxid='4' or @jsxid='1']"

Example 5

All children within a "group" node (could be multiple group nodes): "//group/record"

Example 6

All children within a specific group node: "//group[@name='mySecondGroup']/record"

Example 7

Any record, anywhere in the document:

"//record"

Only the records beneath the root (data) node:

"//data/record"
fetchItemByIdentity(args)
Defined by dojox/data/CdfStore

See dojo/data/api/Identity.fetchItemByIdentity(keywordArgs).

Note: This method can be synchronous if mode is set. Also, there is a more finger friendly alias of this method, byId();

Parameter Type Description
args Object | String
Returns:undefined
getAttributes(item)
Defined by dojox/data/CdfStore

Return an array of property names

Parameter Type Description
item jsx3.xml.Entity
Returns:undefined
getFeatures()
Defined by dojox/data/CdfStore

Return supported data APIs

Returns:object
getIdentity(item)
Defined by dojox/data/CdfStore

Returns the identifier for an item.

Parameter Type Description
item jsx3.xml.Entity
Returns:undefined
getIdentityAttributes(item)
Defined by dojox/data/CdfStore

Returns the property used for the identity.

Parameter Type Description
item jsx3.xml.Entity
Returns:Array
getLabel(item)
Defined by dojox/data/CdfStore

See dojo/data/api/Read.getLabel()

Parameter Type Description
item jsx3.xml.Entity
Returns:undefined | object
getLabelAttributes(item)
Defined by dojox/data/CdfStore

returns an array of what properties of the item that were used to generate its label See dojo/data/api/Read.getLabelAttributes()

Parameter Type Description
item jsx3.xml.Entity
Returns:Array | null
getValue(item,property,defaultValue)
Defined by dojox/data/CdfStore

Return an property value of an item

Parameter Type Description
item jsx3.xml.Entity
property String
defaultValue value
Optional
Returns:undefined
getValues(item,property)
Defined by dojox/data/CdfStore

Return an array of values

Parameter Type Description
item jsx3.xml.Entity
property String
Returns:Array
hasAttribute(item,property)
Defined by dojox/data/CdfStore

Check whether an item has a property

Parameter Type Description
item jsx3.xml.Entity
property String
Returns:boolean
hasProperty(item,property)
Defined by dojox/data/CdfStore

Alias for hasAttribute

Parameter Type Description
item jsx3.xml.Entity
property String
Returns:undefined
isDirty(item)
Defined by dojox/data/CdfStore

Check whether an item is new, modified or deleted. If no item is passed, checks if anything in the store has changed.

Parameter Type Description
item jsx3.xml.Entity
Optional
Returns:boolean
isItem(something)
Defined by dojox/data/CdfStore

Check whether the object is an item (jsx3.xml.Entity)

Parameter Type Description
something anything
Returns:boolean
isItemLoaded(something)
Defined by dojox/data/CdfStore

Check whether the object is a jsx3.xml.Entity object and loaded

Parameter Type Description
something anything
Returns:undefined
loadItem(keywordArgs)
Defined by dojox/data/CdfStore

Load an item

The store always loads all items, so if it's an item, then it's loaded.

Parameter Type Description
keywordArgs object
newItem(keywordArgs,parentInfo)
Defined by dojox/data/CdfStore

Creates a jsx3.xml.Entity item and inserts it either inside the parent or appends it to the root

Parameter Type Description
keywordArgs object
Optional
parentInfo Object | String
Optional
Returns:undefined
revert()
Defined by dojox/data/CdfStore

Invalidate changes (new and/or modified elements) Resets data by simply deleting the reference to the cdfDoc. Subsequent fetches will load the new data.

Note: Any items outside the store will no longer be valid and may cause errors.

Returns:boolean
setValue(item,property,value)
Defined by dojox/data/CdfStore

Set an property value

Parameter Type Description
item jsx3.xml.Entity
property String
value almost anything
Returns:boolean
setValues(item,property,values)
Defined by dojox/data/CdfStore

Set property values.

Parameter Type Description
item jsx3.xml.Entity
property String
values array
Returns:undefined
unsetAttribute(item,property)
Defined by dojox/data/CdfStore

Remove an property

Parameter Type Description
item jsx3.xml.Entity
property String
Returns:boolean
Error in the documentation? Can’t find what you are looking for? Let us know!