/**
* Copyright (c) 2014, Oracle and/or its affiliates.
* All rights reserved.
*/
/**
* Base class for all tree structure DataSource
* @param {Object} data data supported by the component
* @export
* @extends oj.DataSource
* @constructor
*/
oj.TreeDataSource = function(data)
{
oj.TreeDataSource.superclass.constructor.call(this, data);
};
// Subclass TreeDataSource to DataSource
oj.Object.createSubclass(oj.TreeDataSource, oj.DataSource, "oj.TreeDataSource");
/**
* Returns the number of children for a specified parent. If the value returned is not >= 0 then it is automatically assumed
* that the child count is unknown.
* @param {Object} parent the parent key. Specify null if inquiring child count of the root.
* @return {number} the number of children for the specified parent.
* @export
*/
oj.TreeDataSource.prototype.getChildCount = function(parent)
{
return -1;
};
/**
* Fetch the children
* @param {Object} parent the parent key. Specify null if fetching children from the root.
* @param {Object} range information about the range, it must contain the following properties: start, count.
* @param {number} range.start the start index of the range in which the children are fetched.
* @param {number} range.count the size of the range in which the children are fetched.
* @param {Object} callbacks the callbacks to be invoke when fetch children operation is completed. The valid callback
* types are "success" and "error".
* @param {function(oj.NodeSet)} callbacks.success the callback to invoke when fetch completed successfully.
* @param {function({status: Object})} callbacks.error the callback to invoke when fetch children failed.
* @param {Object=} options optional parameters for this operation.
* @param {boolean=} options.queueOnly true if this fetch request is to be queued and not execute yet. The implementation must maintain
* the order of the fetch operations. When queueOnly is false/null/undefined, any queued fetch operations are then
* flushed and executed in the order they are queued. This flag is ignored if the datasource does not support batching.
* @export
*/
oj.TreeDataSource.prototype.fetchChildren = function(parent, range, callbacks, options)
{
oj.Assert.failedInAbstractFunction();
};
/**
* Fetch all children and their children recursively from a specified parent.
* @param {Object} parent the parent key. Specify null to fetch everything from the root (i.e. expand all)
* @param {Object} callbacks the callbacks to be invoke when fetch children operation is completed. The valid callback
* types are "success" and "error".
* @param {function(oj.NodeSet)} callbacks.success the callback to invoke when fetch completed successfully.
* @param {function({status: Object})} callbacks.error the callback to invoke when fetch children failed.
* @param {Object=} options optional parameters for this operation.
* @param {number=} options.start the index related to parent in which to begin fetching descendants from. If this is not specified, then
* @param {number=} options.maxCount the maximum number of children to fetch. If a non-positive number is specified, then the value is ignored and
* there is no maximum fetch count.
* @export
*/
oj.TreeDataSource.prototype.fetchDescendants = function(parent, callbacks, options)
{
oj.Assert.failedInAbstractFunction();
};
/**
* Performs a sort operation on the tree data.
* @param {Object} criteria the sort criteria. It must contain the following properties: key, direction
* @param {Object} criteria.key the key identifying the attribute (column) to sort on
* {string} criteria.direction the sort direction, valid values are "ascending", "descending", "none" (default)
* @param {function()} callbacks.success the callback to invoke when the sort completed successfully.
* @param {function({status: Object})} callbacks.error the callback to invoke when sort failed.
* @export
*/
oj.TreeDataSource.prototype.sort = function(criteria, callbacks)
{
oj.Assert.failedInAbstractFunction();
};
/**
* Returns the current sort criteria of the tree data.
* @return {Object} the current sort criteria. It should contain the following properties: key, direction where
* criteria.key the key identifying the attribute (column) to sort on. Value is null if it's not sorted.
* criteria.direction the sort direction, valid values are "ascending", "descending", "none" (default)
* @export
*/
oj.TreeDataSource.prototype.getSortCriteria = function()
{
return {'key': null, 'direction': 'none'};
};
/**
* Moves a row from one location to another (different position within the same parent or a completely different parent)
* @param {Object} rowToMove the key of the row to move
* @param {Object} referenceRow the key of the reference row which combined with position are used to determine
* the destination of where the row should moved to.
* @param {number|string} position The position of the moved row relative to the reference row.
* This can be a string: "before", "after", "inside", "first", "last", or the zero based index to position
* the element at a specific point among the reference row's current children.
* @param {function()} callbacks.success the callback to invoke when the move completed successfully.
* @param {function({status: Object})} callbacks.error the callback to invoke when move failed.
* @export
*/
oj.TreeDataSource.prototype.move = function(rowToMove, referenceRow, position, callbacks)
{
oj.Assert.failedInAbstractFunction();
};
/**
* Checks whether a move operation is valid.
* @param {Object} rowToMove the key of the row to move
* @param {Object} referenceRow the key of the reference row which combined with position are used to determine
* the destination of where the row should moved to.
* @param {number|string} position The position of the moved row relative to the reference row.
* This can be a string: "before", "after", "inside", "first", "last", or the zero based index to position
* the element at a specific point among the reference row's current children.
* @return {string} returns "valid" if the move is valid, "invalid" otherwise.
* @export
*/
oj.TreeDataSource.prototype.moveOK = function(rowToMove, referenceRow, position)
{
return "valid";
};
/**
* Determines whether this TreeDataSource supports the specified feature.
* @param {string} feature the feature in which its capabilities is inquired. Currently the valid features "sort",
* "move", "fetchDescendants", "batchFetch"
* @return {string|null} the name of the feature. Returns null if the feature is not recognized.
* For "sort", the valid return values are: "default", "none".
* For "fetchDescendants", the valid return values are: "enable", "disable", "suboptimal".
* For "move", the valid return values are: "default", "none".
* For "batchFetch", the valid return values are: "enable", "disable".
* @export
*/
oj.TreeDataSource.prototype.getCapability = function(feature)
{
return null;
};
Source: src/main/javascript/oracle/oj/ojdatacollection-common/TreeDataSource.js
Oracle® JavaScript Extension Toolkit (JET)
1.1.2
E65298-01