Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
runTest: function(datastore, t){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
var store = new datastore(tests.data.readOnlyItemFileTestTemplates.getTestData("countries"));
var features = store.getFeatures();
t.assertTrue(features["dojo.data.api.Read"] != null);
t.assertTrue(features["dojo.data.api.Identity"] != null);
}
},
function test_getFeatures(){
// summary:
// Simple test of the getFeatures function of the store
// description:
// Simple test of the getFeatures function of the store
var store = new dojo.data.ItemFileWriteStore(tests.data.readOnlyItemFileTestTemplates.getTestData("countries"));
var features = store.getFeatures();
// make sure we have the expected features:
doh.assertTrue(features["dojo.data.api.Read"] !== null);
doh.assertTrue(features["dojo.data.api.Identity"] !== null);
doh.assertTrue(features["dojo.data.api.Write"] !== null);
doh.assertTrue(features["dojo.data.api.Notification"] !== null);
doh.assertFalse(features["iggy"]);
// and only the expected features:
var count = 0;
for(var i in features){
doh.assertTrue((i === "dojo.data.api.Read" ||
i === "dojo.data.api.Identity" ||
i === "dojo.data.api.Write" ||
i === "dojo.data.api.Notification"));
count++;
}
doh.assertEqual(count, 4);
},
function testWriteAPI_setValue(){
_getIdentifierAttribute: function(){
var identifierAttribute = this.getFeatures()['dojo.data.api.Identity'];
// this._assert((identifierAttribute === Number) || (dojo.isString(identifierAttribute)));
return identifierAttribute;
},
postCreate: function(){
// summary:
// sets up our event handling that we need for functioning
// as a select
this.inherited(arguments);
// Make our event connections for updating state
this.connect(this, "onChange", "_updateSelection");
// moved from startup
// Connects in our store, if we have one defined
var store = this.store;
if(store && (store.getIdentity || store.getFeatures()["dojo.data.api.Identity"])){
// Temporarily set our store to null so that it will get set
// and connected appropriately
this.store = null;
this.setStore(store, this._oValue);
}
},
_getIdentifierAttribute: function(){
// this._assert((identifierAttribute === Number) || (dojo.isString(identifierAttribute)));
return this.getFeatures()['dojo.data.api.Identity'];
},
startup: function(){
// summary:
// Connects in our store, if we have one defined
this.inherited(arguments);
var store = this.store, fetchArgs = {};
dojo.forEach(["query", "queryOptions", "onFetch"], function(i){
if(this[i]){
fetchArgs[i] = this[i];
}
delete this[i];
}, this);
if(store && store.getFeatures()["dojo.data.api.Identity"]){
// Temporarily set our store to null so that it will get set
// and connected appropriately
this.store = null;
this.setStore(store, this._oValue, fetchArgs);
}
},
var fetchParentItems = dojo.hitch(this, function(/*item*/ item, /*function*/callback){
// summary:
// Fetches the parent items for the given item
var store = this.store, id;
if(this.parentAttr && store.getFeatures()["dojo.data.api.Identity"] &&
((id = this.store.getValue(item, this.parentAttr)) || id === "")){
// Fetch by parent attribute
var cb = function(i){
if(store.getIdentity(i) == store.getIdentity(item)){
callback(null);
}else{
callback([i]);
}
};
if(id === ""){
callback(null);
}else if(typeof id == "string"){
store.fetchItemByIdentity({identity: id, onItem: cb});
}else if(store.isItem(id)){
cb(id);
}
this._storeRefPropName += "_";
}
while(allAttributeNames[this._itemNumPropName]){
this._itemNumPropName += "_";
}
// Step 4: Some data files specify an optional 'identifier', which is
// the name of an attribute that holds the identity of each item.
// If this data file specified an identifier attribute, then build a
// hash table of items keyed by the identity of the items.
var arrayOfValues;
var identifier = dataObject.identifier;
if(identifier){
this._itemsByIdentity = {};
this._features['dojo.data.api.Identity'] = identifier;
for(i = 0; i < this._arrayOfAllItems.length; ++i){
item = this._arrayOfAllItems[i];
arrayOfValues = item[identifier];
var identity = arrayOfValues[0];
if(!this._itemsByIdentity[identity]){
this._itemsByIdentity[identity] = item;
}else{
if(this._jsonFileUrl){
throw new Error("dojo.data.ItemFileReadStore: The json data as specified by: [" + this._jsonFileUrl + "] is malformed. Items within the list have identifier: [" + identifier + "]. Value collided: [" + identity + "]");
}else if(this._jsonData){
throw new Error("dojo.data.ItemFileReadStore: The json data provided by the creation arguments is malformed. Items within the list have identifier: [" + identifier + "]. Value collided: [" + identity + "]");
}
}
}
}else{
this._features['dojo.data.api.Identity'] = Number;
_getIdentifierAttribute: function(){
var identifierAttribute = this.getFeatures()['dojo.data.api.Identity'];
// this._assert((identifierAttribute === Number) || (dojo.isString(identifierAttribute)));
return identifierAttribute;
},
postMixInProperties: function(){
this.tree = this;
this.lastFocused = this.labelNode;
this._itemNodeMap={};
this._hideRoot = !this.label;
if(!this.store.getFeatures()['dojo.data.api.Identity']){
throw new Error("dijit.tree requires access to a store supporting the dojo.data Identity api");
}
if(!this.cookieName){
this.cookieName = this.id + "SaveStateCookie";
}
// if the store supports Notification, subscribe to the notification events
if(this.store.getFeatures()['dojo.data.api.Notification']){
this.connect(this.store, "onNew", "_onNewItem");
this.connect(this.store, "onDelete", "_onDeleteItem");
this.connect(this.store, "onSet", "_onSetItem");
}
},