Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1371 → Rev 1977

/tags/v2.0-narmer/api/js/dojo/src/data/old/Type.js
New file
0,0 → 1,17
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.Type");
dojo.require("dojo.data.old.Item");
dojo.data.old.Type = function (dataProvider) {
dojo.data.old.Item.call(this, dataProvider);
};
dojo.inherits(dojo.data.old.Type, dojo.data.old.Item);
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/Attribute.js
New file
0,0 → 1,33
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.Attribute");
dojo.require("dojo.data.old.Item");
dojo.require("dojo.lang.assert");
dojo.data.old.Attribute = function (dataProvider, attributeId) {
dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional:true});
dojo.lang.assertType(attributeId, String);
dojo.data.old.Item.call(this, dataProvider);
this._attributeId = attributeId;
};
dojo.inherits(dojo.data.old.Attribute, dojo.data.old.Item);
dojo.data.old.Attribute.prototype.toString = function () {
return this._attributeId;
};
dojo.data.old.Attribute.prototype.getAttributeId = function () {
return this._attributeId;
};
dojo.data.old.Attribute.prototype.getType = function () {
return this.get("type");
};
dojo.data.old.Attribute.prototype.setType = function (type) {
this.set("type", type);
};
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/Observable.js
New file
0,0 → 1,38
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.Observable");
dojo.require("dojo.lang.common");
dojo.require("dojo.lang.assert");
dojo.data.old.Observable = function () {
};
dojo.data.old.Observable.prototype.addObserver = function (observer) {
dojo.lang.assertType(observer, Object);
dojo.lang.assertType(observer.observedObjectHasChanged, Function);
if (!this._arrayOfObservers) {
this._arrayOfObservers = [];
}
if (!dojo.lang.inArray(this._arrayOfObservers, observer)) {
this._arrayOfObservers.push(observer);
}
};
dojo.data.old.Observable.prototype.removeObserver = function (observer) {
if (!this._arrayOfObservers) {
return;
}
var index = dojo.lang.indexOf(this._arrayOfObservers, observer);
if (index != -1) {
this._arrayOfObservers.splice(index, 1);
}
};
dojo.data.old.Observable.prototype.getObservers = function () {
return this._arrayOfObservers;
};
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/Kind.js
New file
0,0 → 1,17
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.Kind");
dojo.require("dojo.data.old.Item");
dojo.data.old.Kind = function (dataProvider) {
dojo.data.old.Item.call(this, dataProvider);
};
dojo.inherits(dojo.data.old.Kind, dojo.data.old.Item);
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/__package__.js
New file
0,0 → 1,15
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.require("dojo.experimental");
dojo.experimental("dojo.data.old.*");
dojo.kwCompoundRequire({common:["dojo.data.old.Item", "dojo.data.old.ResultSet", "dojo.data.old.provider.FlatFile"]});
dojo.provide("dojo.data.old.*");
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/to_do.txt
New file
0,0 → 1,45
Existing Features
* can import data from .json or .csv format files
* can import data from del.icio.us
* can create and modify data programmatically
* can bind data to dojo.widget.Chart
* can bind data to dojo.widget.SortableTable
* can bind one data set to multiple widgets
* notifications: widgets are notified when data changes
* notification available per-item or per-resultSet
* can create ad-hoc attributes
* attributes can be loosely-typed
* attributes can have meta-data like type and display name
* half-implemented support for sorting
* half-implemented support for export to .json
* API for getting data in simple arrays
* API for getting ResultSets with iterators (precursor to support for something like the openrico.org live grid)
~~~~~~~~~~~~~~~~~~~~~~~~
To-Do List
* be able to import data from an html <table></table>
* think about being able to import data from some type of XML
* think about integration with dojo.undo.Manager
* think more about how to represent the notion of different data types
* think about what problems we'll run into when we have a MySQL data provider
* in TableBindingHack, improve support for data types in the SortableTable binding
* deal with ids (including MySQL multi-field keys)
* add support for item-references: employeeItem.set('department', departmentItem);
* deal with Attributes as instances of Items, not just subclasses of Items
* unit tests for compare/sort code
* unit tests for everything
* implement item.toString('json') and item.toString('xml')
* implement dataProvider.newItem({name: 'foo', age: 26})
* deal better with transactions
* add support for deleting items
* don't send out multiple notifications to the same observer
* deal with item versions
* prototype a Yahoo data provider -- http://developer.yahoo.net/common/json.html
* prototype a data provider that enforces strong typing
* prototype a data provider that prevents ad-hoc attributes
* prototype a data provider that enforces single-kind item
* prototype a data provider that allows for login/authentication
* have loosely typed result sets play nicely with widgets that expect strong typing
* prototype an example of spreadsheet-style formulas or derivation rules
* experiment with some sort of fetch() that returns only a subset of a data provider's items
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/ResultSet.js
New file
0,0 → 1,50
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.ResultSet");
dojo.require("dojo.lang.assert");
dojo.require("dojo.collections.Collections");
dojo.data.old.ResultSet = function (dataProvider, arrayOfItems) {
dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional:true});
dojo.lang.assertType(arrayOfItems, Array, {optional:true});
dojo.data.old.Observable.call(this);
this._dataProvider = dataProvider;
this._arrayOfItems = [];
if (arrayOfItems) {
this._arrayOfItems = arrayOfItems;
}
};
dojo.inherits(dojo.data.old.ResultSet, dojo.data.old.Observable);
dojo.data.old.ResultSet.prototype.toString = function () {
var returnString = this._arrayOfItems.join(", ");
return returnString;
};
dojo.data.old.ResultSet.prototype.toArray = function () {
return this._arrayOfItems;
};
dojo.data.old.ResultSet.prototype.getIterator = function () {
return new dojo.collections.Iterator(this._arrayOfItems);
};
dojo.data.old.ResultSet.prototype.getLength = function () {
return this._arrayOfItems.length;
};
dojo.data.old.ResultSet.prototype.getItemAt = function (index) {
return this._arrayOfItems[index];
};
dojo.data.old.ResultSet.prototype.indexOf = function (item) {
return dojo.lang.indexOf(this._arrayOfItems, item);
};
dojo.data.old.ResultSet.prototype.contains = function (item) {
return dojo.lang.inArray(this._arrayOfItems, item);
};
dojo.data.old.ResultSet.prototype.getDataProvider = function () {
return this._dataProvider;
};
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/Value.js
New file
0,0 → 1,33
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.Value");
dojo.require("dojo.lang.assert");
dojo.data.old.Value = function (value) {
this._value = value;
this._type = null;
};
dojo.data.old.Value.prototype.toString = function () {
return this._value.toString();
};
dojo.data.old.Value.prototype.getValue = function () {
return this._value;
};
dojo.data.old.Value.prototype.getType = function () {
dojo.unimplemented("dojo.data.old.Value.prototype.getType");
return this._type;
};
dojo.data.old.Value.prototype.compare = function () {
dojo.unimplemented("dojo.data.old.Value.prototype.compare");
};
dojo.data.old.Value.prototype.isEqual = function () {
dojo.unimplemented("dojo.data.old.Value.prototype.isEqual");
};
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/format/Json.js
New file
0,0 → 1,69
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.format.Json");
dojo.require("dojo.lang.assert");
dojo.data.old.format.Json = new function () {
this.loadDataProviderFromFileContents = function (dataProvider, jsonFileContents) {
dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base);
dojo.lang.assertType(jsonFileContents, String);
var arrayOfJsonData = eval("(" + jsonFileContents + ")");
this.loadDataProviderFromArrayOfJsonData(dataProvider, arrayOfJsonData);
};
this.loadDataProviderFromArrayOfJsonData = function (dataProvider, arrayOfJsonData) {
dojo.lang.assertType(arrayOfJsonData, Array, {optional:true});
if (arrayOfJsonData && (arrayOfJsonData.length > 0)) {
var firstRow = arrayOfJsonData[0];
dojo.lang.assertType(firstRow, [Array, "pureobject"]);
if (dojo.lang.isArray(firstRow)) {
_loadDataProviderFromArrayOfArrays(dataProvider, arrayOfJsonData);
} else {
dojo.lang.assertType(firstRow, "pureobject");
_loadDataProviderFromArrayOfObjects(dataProvider, arrayOfJsonData);
}
}
};
this.getJsonStringFromResultSet = function (resultSet) {
dojo.unimplemented("dojo.data.old.format.Json.getJsonStringFromResultSet");
var jsonString = null;
return jsonString;
};
function _loadDataProviderFromArrayOfArrays(dataProvider, arrayOfJsonData) {
var arrayOfKeys = arrayOfJsonData[0];
for (var i = 1; i < arrayOfJsonData.length; ++i) {
var row = arrayOfJsonData[i];
var item = dataProvider.getNewItemToLoad();
for (var j in row) {
var value = row[j];
var key = arrayOfKeys[j];
item.load(key, value);
}
}
}
function _loadDataProviderFromArrayOfObjects(dataProvider, arrayOfJsonData) {
for (var i in arrayOfJsonData) {
var row = arrayOfJsonData[i];
var item = dataProvider.getNewItemToLoad();
for (var key in row) {
var value = row[key];
if (dojo.lang.isArray(value)) {
var arrayOfValues = value;
for (var j in arrayOfValues) {
value = arrayOfValues[j];
item.load(key, value);
}
} else {
item.load(key, value);
}
}
}
}
}();
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/format/Csv.js
New file
0,0 → 1,79
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.format.Csv");
dojo.require("dojo.lang.assert");
dojo.data.old.format.Csv = new function () {
this.getArrayStructureFromCsvFileContents = function (csvFileContents) {
dojo.lang.assertType(csvFileContents, String);
var lineEndingCharacters = new RegExp("\r\n|\n|\r");
var leadingWhiteSpaceCharacters = new RegExp("^\\s+", "g");
var trailingWhiteSpaceCharacters = new RegExp("\\s+$", "g");
var doubleQuotes = new RegExp("\"\"", "g");
var arrayOfOutputRecords = [];
var arrayOfInputLines = csvFileContents.split(lineEndingCharacters);
for (var i in arrayOfInputLines) {
var singleLine = arrayOfInputLines[i];
if (singleLine.length > 0) {
var listOfFields = singleLine.split(",");
var j = 0;
while (j < listOfFields.length) {
var space_field_space = listOfFields[j];
var field_space = space_field_space.replace(leadingWhiteSpaceCharacters, "");
var field = field_space.replace(trailingWhiteSpaceCharacters, "");
var firstChar = field.charAt(0);
var lastChar = field.charAt(field.length - 1);
var secondToLastChar = field.charAt(field.length - 2);
var thirdToLastChar = field.charAt(field.length - 3);
if ((firstChar == "\"") && ((lastChar != "\"") || ((lastChar == "\"") && (secondToLastChar == "\"") && (thirdToLastChar != "\"")))) {
if (j + 1 === listOfFields.length) {
return null;
}
var nextField = listOfFields[j + 1];
listOfFields[j] = field_space + "," + nextField;
listOfFields.splice(j + 1, 1);
} else {
if ((firstChar == "\"") && (lastChar == "\"")) {
field = field.slice(1, (field.length - 1));
field = field.replace(doubleQuotes, "\"");
}
listOfFields[j] = field;
j += 1;
}
}
arrayOfOutputRecords.push(listOfFields);
}
}
return arrayOfOutputRecords;
};
this.loadDataProviderFromFileContents = function (dataProvider, csvFileContents) {
dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base);
dojo.lang.assertType(csvFileContents, String);
var arrayOfArrays = this.getArrayStructureFromCsvFileContents(csvFileContents);
if (arrayOfArrays) {
var arrayOfKeys = arrayOfArrays[0];
for (var i = 1; i < arrayOfArrays.length; ++i) {
var row = arrayOfArrays[i];
var item = dataProvider.getNewItemToLoad();
for (var j in row) {
var value = row[j];
var key = arrayOfKeys[j];
item.load(key, value);
}
}
}
};
this.getCsvStringFromResultSet = function (resultSet) {
dojo.unimplemented("dojo.data.old.format.Csv.getCsvStringFromResultSet");
var csvString = null;
return csvString;
};
}();
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/Item.js
New file
0,0 → 1,221
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.Item");
dojo.require("dojo.data.old.Observable");
dojo.require("dojo.data.old.Value");
dojo.require("dojo.lang.common");
dojo.require("dojo.lang.assert");
dojo.data.old.Item = function (dataProvider) {
dojo.lang.assertType(dataProvider, dojo.data.old.provider.Base, {optional:true});
dojo.data.old.Observable.call(this);
this._dataProvider = dataProvider;
this._dictionaryOfAttributeValues = {};
};
dojo.inherits(dojo.data.old.Item, dojo.data.old.Observable);
dojo.data.old.Item.compare = function (itemOne, itemTwo) {
dojo.lang.assertType(itemOne, dojo.data.old.Item);
if (!dojo.lang.isOfType(itemTwo, dojo.data.old.Item)) {
return -1;
}
var nameOne = itemOne.getName();
var nameTwo = itemTwo.getName();
if (nameOne == nameTwo) {
var attributeArrayOne = itemOne.getAttributes();
var attributeArrayTwo = itemTwo.getAttributes();
if (attributeArrayOne.length != attributeArrayTwo.length) {
if (attributeArrayOne.length > attributeArrayTwo.length) {
return 1;
} else {
return -1;
}
}
for (var i in attributeArrayOne) {
var attribute = attributeArrayOne[i];
var arrayOfValuesOne = itemOne.getValues(attribute);
var arrayOfValuesTwo = itemTwo.getValues(attribute);
dojo.lang.assert(arrayOfValuesOne && (arrayOfValuesOne.length > 0));
if (!arrayOfValuesTwo) {
return 1;
}
if (arrayOfValuesOne.length != arrayOfValuesTwo.length) {
if (arrayOfValuesOne.length > arrayOfValuesTwo.length) {
return 1;
} else {
return -1;
}
}
for (var j in arrayOfValuesOne) {
var value = arrayOfValuesOne[j];
if (!itemTwo.hasAttributeValue(value)) {
return 1;
}
}
return 0;
}
} else {
if (nameOne > nameTwo) {
return 1;
} else {
return -1;
}
}
};
dojo.data.old.Item.prototype.toString = function () {
var arrayOfStrings = [];
var attributes = this.getAttributes();
for (var i in attributes) {
var attribute = attributes[i];
var arrayOfValues = this.getValues(attribute);
var valueString;
if (arrayOfValues.length == 1) {
valueString = arrayOfValues[0];
} else {
valueString = "[";
valueString += arrayOfValues.join(", ");
valueString += "]";
}
arrayOfStrings.push(" " + attribute + ": " + valueString);
}
var returnString = "{ ";
returnString += arrayOfStrings.join(",\n");
returnString += " }";
return returnString;
};
dojo.data.old.Item.prototype.compare = function (otherItem) {
return dojo.data.old.Item.compare(this, otherItem);
};
dojo.data.old.Item.prototype.isEqual = function (otherItem) {
return (this.compare(otherItem) == 0);
};
dojo.data.old.Item.prototype.getName = function () {
return this.get("name");
};
dojo.data.old.Item.prototype.get = function (attributeId) {
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
return null;
}
if (literalOrValueOrArray instanceof dojo.data.old.Value) {
return literalOrValueOrArray.getValue();
}
if (dojo.lang.isArray(literalOrValueOrArray)) {
var dojoDataValue = literalOrValueOrArray[0];
return dojoDataValue.getValue();
}
return literalOrValueOrArray;
};
dojo.data.old.Item.prototype.getValue = function (attributeId) {
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
return null;
}
if (literalOrValueOrArray instanceof dojo.data.old.Value) {
return literalOrValueOrArray;
}
if (dojo.lang.isArray(literalOrValueOrArray)) {
var dojoDataValue = literalOrValueOrArray[0];
return dojoDataValue;
}
var literal = literalOrValueOrArray;
dojoDataValue = new dojo.data.old.Value(literal);
this._dictionaryOfAttributeValues[attributeId] = dojoDataValue;
return dojoDataValue;
};
dojo.data.old.Item.prototype.getValues = function (attributeId) {
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
return null;
}
if (literalOrValueOrArray instanceof dojo.data.old.Value) {
var array = [literalOrValueOrArray];
this._dictionaryOfAttributeValues[attributeId] = array;
return array;
}
if (dojo.lang.isArray(literalOrValueOrArray)) {
return literalOrValueOrArray;
}
var literal = literalOrValueOrArray;
var dojoDataValue = new dojo.data.old.Value(literal);
array = [dojoDataValue];
this._dictionaryOfAttributeValues[attributeId] = array;
return array;
};
dojo.data.old.Item.prototype.load = function (attributeId, value) {
this._dataProvider.registerAttribute(attributeId);
var literalOrValueOrArray = this._dictionaryOfAttributeValues[attributeId];
if (dojo.lang.isUndefined(literalOrValueOrArray)) {
this._dictionaryOfAttributeValues[attributeId] = value;
return;
}
if (!(value instanceof dojo.data.old.Value)) {
value = new dojo.data.old.Value(value);
}
if (literalOrValueOrArray instanceof dojo.data.old.Value) {
var array = [literalOrValueOrArray, value];
this._dictionaryOfAttributeValues[attributeId] = array;
return;
}
if (dojo.lang.isArray(literalOrValueOrArray)) {
literalOrValueOrArray.push(value);
return;
}
var literal = literalOrValueOrArray;
var dojoDataValue = new dojo.data.old.Value(literal);
array = [dojoDataValue, value];
this._dictionaryOfAttributeValues[attributeId] = array;
};
dojo.data.old.Item.prototype.set = function (attributeId, value) {
this._dataProvider.registerAttribute(attributeId);
this._dictionaryOfAttributeValues[attributeId] = value;
this._dataProvider.noteChange(this, attributeId, value);
};
dojo.data.old.Item.prototype.setValue = function (attributeId, value) {
this.set(attributeId, value);
};
dojo.data.old.Item.prototype.addValue = function (attributeId, value) {
this.load(attributeId, value);
this._dataProvider.noteChange(this, attributeId, value);
};
dojo.data.old.Item.prototype.setValues = function (attributeId, arrayOfValues) {
dojo.lang.assertType(arrayOfValues, Array);
this._dataProvider.registerAttribute(attributeId);
var finalArray = [];
this._dictionaryOfAttributeValues[attributeId] = finalArray;
for (var i in arrayOfValues) {
var value = arrayOfValues[i];
if (!(value instanceof dojo.data.old.Value)) {
value = new dojo.data.old.Value(value);
}
finalArray.push(value);
this._dataProvider.noteChange(this, attributeId, value);
}
};
dojo.data.old.Item.prototype.getAttributes = function () {
var arrayOfAttributes = [];
for (var key in this._dictionaryOfAttributeValues) {
arrayOfAttributes.push(this._dataProvider.getAttribute(key));
}
return arrayOfAttributes;
};
dojo.data.old.Item.prototype.hasAttribute = function (attributeId) {
return (attributeId in this._dictionaryOfAttributeValues);
};
dojo.data.old.Item.prototype.hasAttributeValue = function (attributeId, value) {
var arrayOfValues = this.getValues(attributeId);
for (var i in arrayOfValues) {
var candidateValue = arrayOfValues[i];
if (candidateValue.isEqual(value)) {
return true;
}
}
return false;
};
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/provider/Base.js
New file
0,0 → 1,122
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.provider.Base");
dojo.require("dojo.lang.assert");
dojo.data.old.provider.Base = function () {
this._countOfNestedTransactions = 0;
this._changesInCurrentTransaction = null;
};
dojo.data.old.provider.Base.prototype.beginTransaction = function () {
if (this._countOfNestedTransactions === 0) {
this._changesInCurrentTransaction = [];
}
this._countOfNestedTransactions += 1;
};
dojo.data.old.provider.Base.prototype.endTransaction = function () {
this._countOfNestedTransactions -= 1;
dojo.lang.assert(this._countOfNestedTransactions >= 0);
if (this._countOfNestedTransactions === 0) {
var listOfChangesMade = this._saveChanges();
this._changesInCurrentTransaction = null;
if (listOfChangesMade.length > 0) {
this._notifyObserversOfChanges(listOfChangesMade);
}
}
};
dojo.data.old.provider.Base.prototype.getNewItemToLoad = function () {
return this._newItem();
};
dojo.data.old.provider.Base.prototype.newItem = function (itemName) {
dojo.lang.assertType(itemName, String, {optional:true});
var item = this._newItem();
if (itemName) {
item.set("name", itemName);
}
return item;
};
dojo.data.old.provider.Base.prototype.newAttribute = function (attributeId) {
dojo.lang.assertType(attributeId, String, {optional:true});
var attribute = this._newAttribute(attributeId);
return attribute;
};
dojo.data.old.provider.Base.prototype.getAttribute = function (attributeId) {
dojo.unimplemented("dojo.data.old.provider.Base");
var attribute;
return attribute;
};
dojo.data.old.provider.Base.prototype.getAttributes = function () {
dojo.unimplemented("dojo.data.old.provider.Base");
return this._arrayOfAttributes;
};
dojo.data.old.provider.Base.prototype.fetchArray = function () {
dojo.unimplemented("dojo.data.old.provider.Base");
return [];
};
dojo.data.old.provider.Base.prototype.fetchResultSet = function () {
dojo.unimplemented("dojo.data.old.provider.Base");
var resultSet;
return resultSet;
};
dojo.data.old.provider.Base.prototype.noteChange = function (item, attribute, value) {
var change = {item:item, attribute:attribute, value:value};
if (this._countOfNestedTransactions === 0) {
this.beginTransaction();
this._changesInCurrentTransaction.push(change);
this.endTransaction();
} else {
this._changesInCurrentTransaction.push(change);
}
};
dojo.data.old.provider.Base.prototype.addItemObserver = function (item, observer) {
dojo.lang.assertType(item, dojo.data.old.Item);
item.addObserver(observer);
};
dojo.data.old.provider.Base.prototype.removeItemObserver = function (item, observer) {
dojo.lang.assertType(item, dojo.data.old.Item);
item.removeObserver(observer);
};
dojo.data.old.provider.Base.prototype._newItem = function () {
var item = new dojo.data.old.Item(this);
return item;
};
dojo.data.old.provider.Base.prototype._newAttribute = function (attributeId) {
var attribute = new dojo.data.old.Attribute(this);
return attribute;
};
dojo.data.old.provider.Base.prototype._saveChanges = function () {
var arrayOfChangesMade = this._changesInCurrentTransaction;
return arrayOfChangesMade;
};
dojo.data.old.provider.Base.prototype._notifyObserversOfChanges = function (arrayOfChanges) {
var arrayOfResultSets = this._getResultSets();
for (var i in arrayOfChanges) {
var change = arrayOfChanges[i];
var changedItem = change.item;
var arrayOfItemObservers = changedItem.getObservers();
for (var j in arrayOfItemObservers) {
var observer = arrayOfItemObservers[j];
observer.observedObjectHasChanged(changedItem, change);
}
for (var k in arrayOfResultSets) {
var resultSet = arrayOfResultSets[k];
var arrayOfResultSetObservers = resultSet.getObservers();
for (var m in arrayOfResultSetObservers) {
observer = arrayOfResultSetObservers[m];
observer.observedObjectHasChanged(resultSet, change);
}
}
}
};
dojo.data.old.provider.Base.prototype._getResultSets = function () {
dojo.unimplemented("dojo.data.old.provider.Base");
return [];
};
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/provider/Delicious.js
New file
0,0 → 1,31
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.provider.Delicious");
dojo.require("dojo.data.old.provider.FlatFile");
dojo.require("dojo.data.old.format.Json");
dojo.data.old.provider.Delicious = function () {
dojo.data.old.provider.FlatFile.call(this);
if (Delicious && Delicious.posts) {
dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, Delicious.posts);
} else {
}
var u = this.registerAttribute("u");
var d = this.registerAttribute("d");
var t = this.registerAttribute("t");
u.load("name", "Bookmark");
d.load("name", "Description");
t.load("name", "Tags");
u.load("type", "String");
d.load("type", "String");
t.load("type", "String");
};
dojo.inherits(dojo.data.old.provider.Delicious, dojo.data.old.provider.FlatFile);
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/provider/JotSpot.js
New file
0,0 → 1,17
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.provider.JotSpot");
dojo.require("dojo.data.old.provider.Base");
dojo.data.old.provider.JotSpot = function () {
dojo.unimplemented("dojo.data.old.provider.JotSpot");
};
dojo.inherits(dojo.data.old.provider.JotSpot, dojo.data.old.provider.Base);
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/provider/MySql.js
New file
0,0 → 1,17
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.provider.MySql");
dojo.require("dojo.data.old.provider.Base");
dojo.data.old.provider.MySql = function () {
dojo.unimplemented("dojo.data.old.provider.MySql");
};
dojo.inherits(dojo.data.old.provider.MySql, dojo.data.old.provider.Base);
 
/tags/v2.0-narmer/api/js/dojo/src/data/old/provider/FlatFile.js
New file
0,0 → 1,111
/*
Copyright (c) 2004-2006, The Dojo Foundation
All Rights Reserved.
 
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
 
http://dojotoolkit.org/community/licensing.shtml
*/
 
dojo.provide("dojo.data.old.provider.FlatFile");
dojo.require("dojo.data.old.provider.Base");
dojo.require("dojo.data.old.Item");
dojo.require("dojo.data.old.Attribute");
dojo.require("dojo.data.old.ResultSet");
dojo.require("dojo.data.old.format.Json");
dojo.require("dojo.data.old.format.Csv");
dojo.require("dojo.lang.assert");
dojo.data.old.provider.FlatFile = function (keywordParameters) {
dojo.lang.assertType(keywordParameters, "pureobject", {optional:true});
dojo.data.old.provider.Base.call(this);
this._arrayOfItems = [];
this._resultSet = null;
this._dictionaryOfAttributes = {};
if (keywordParameters) {
var jsonObjects = keywordParameters["jsonObjects"];
var jsonString = keywordParameters["jsonString"];
var fileUrl = keywordParameters["url"];
if (jsonObjects) {
dojo.data.old.format.Json.loadDataProviderFromArrayOfJsonData(this, jsonObjects);
}
if (jsonString) {
dojo.data.old.format.Json.loadDataProviderFromFileContents(this, jsonString);
}
if (fileUrl) {
var arrayOfParts = fileUrl.split(".");
var lastPart = arrayOfParts[(arrayOfParts.length - 1)];
var formatParser = null;
if (lastPart == "json") {
formatParser = dojo.data.old.format.Json;
}
if (lastPart == "csv") {
formatParser = dojo.data.old.format.Csv;
}
if (formatParser) {
var fileContents = dojo.hostenv.getText(fileUrl);
formatParser.loadDataProviderFromFileContents(this, fileContents);
} else {
dojo.lang.assert(false, "new dojo.data.old.provider.FlatFile({url: }) was passed a file without a .csv or .json suffix");
}
}
}
};
dojo.inherits(dojo.data.old.provider.FlatFile, dojo.data.old.provider.Base);
dojo.data.old.provider.FlatFile.prototype.getProviderCapabilities = function (keyword) {
dojo.lang.assertType(keyword, String, {optional:true});
if (!this._ourCapabilities) {
this._ourCapabilities = {transactions:false, undo:false, login:false, versioning:false, anonymousRead:true, anonymousWrite:false, permissions:false, queries:false, strongTyping:false, datatypes:[String, Date, Number]};
}
if (keyword) {
return this._ourCapabilities[keyword];
} else {
return this._ourCapabilities;
}
};
dojo.data.old.provider.FlatFile.prototype.registerAttribute = function (attributeId) {
var registeredAttribute = this.getAttribute(attributeId);
if (!registeredAttribute) {
var newAttribute = new dojo.data.old.Attribute(this, attributeId);
this._dictionaryOfAttributes[attributeId] = newAttribute;
registeredAttribute = newAttribute;
}
return registeredAttribute;
};
dojo.data.old.provider.FlatFile.prototype.getAttribute = function (attributeId) {
var attribute = (this._dictionaryOfAttributes[attributeId] || null);
return attribute;
};
dojo.data.old.provider.FlatFile.prototype.getAttributes = function () {
var arrayOfAttributes = [];
for (var key in this._dictionaryOfAttributes) {
var attribute = this._dictionaryOfAttributes[key];
arrayOfAttributes.push(attribute);
}
return arrayOfAttributes;
};
dojo.data.old.provider.FlatFile.prototype.fetchArray = function (query) {
return this._arrayOfItems;
};
dojo.data.old.provider.FlatFile.prototype.fetchResultSet = function (query) {
if (!this._resultSet) {
this._resultSet = new dojo.data.old.ResultSet(this, this.fetchArray(query));
}
return this._resultSet;
};
dojo.data.old.provider.FlatFile.prototype._newItem = function () {
var item = new dojo.data.old.Item(this);
this._arrayOfItems.push(item);
return item;
};
dojo.data.old.provider.FlatFile.prototype._newAttribute = function (attributeId) {
dojo.lang.assertType(attributeId, String);
dojo.lang.assert(this.getAttribute(attributeId) === null);
var attribute = new dojo.data.old.Attribute(this, attributeId);
this._dictionaryOfAttributes[attributeId] = attribute;
return attribute;
};
dojo.data.old.provider.Base.prototype._getResultSets = function () {
return [this._resultSet];
};