mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 22:58:14 +00:00
[Persistence] Add JSDoc
Add JSDoc to classes added/modified to support multiple persistence spaces, nasa/openmctweb#245.
This commit is contained in:
@ -33,6 +33,7 @@ define(
|
||||
* @constructor
|
||||
* @memberof platform/core
|
||||
* @param $injector Angular's `$injector`
|
||||
* @implements {Capability}
|
||||
*/
|
||||
function InstantiationCapability($injector, identifierService, domainObject) {
|
||||
this.$injector = $injector;
|
||||
@ -47,6 +48,7 @@ define(
|
||||
* have been persisted, nor will it have been added to the
|
||||
* composition of the object which exposed this capability.
|
||||
*
|
||||
* @param {object} the model for the new domain object
|
||||
* @returns {DomainObject} the new domain object
|
||||
*/
|
||||
InstantiationCapability.prototype.instantiate = function (model) {
|
||||
|
@ -29,8 +29,15 @@ define(
|
||||
var SEPARATOR = ":";
|
||||
|
||||
/**
|
||||
* Provides an interface for interpreting domain object
|
||||
* identifiers.
|
||||
* Provides an interface for interpreting domain object identifiers;
|
||||
* in particular, parses out persistence space/key pairs associated
|
||||
* with the domain object.
|
||||
*
|
||||
* @memberof platform/core
|
||||
* @constructor
|
||||
* @param {string} id the domain object identifier
|
||||
* @param {string} defaultSpace the persistence space to use if
|
||||
* one is not encoded in the identifier
|
||||
*/
|
||||
function Identifier(id, defaultSpace) {
|
||||
var separatorIndex = id.indexOf(SEPARATOR);
|
||||
@ -46,14 +53,30 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the key under which the identified domain object's model
|
||||
* should be persisted, within its persistence space.
|
||||
* @returns {string} the key within its persistence space
|
||||
*/
|
||||
Identifier.prototype.getKey = function () {
|
||||
return this.key;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the space in which the identified domain object's model should
|
||||
* be persisted.
|
||||
* @returns {string} the persistence space
|
||||
*/
|
||||
Identifier.prototype.getSpace = function () {
|
||||
return this.space;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the persistence space, if any, which has been explicitly
|
||||
* encoded in this domain object's identifier. Returns undefined
|
||||
* if no such space has been specified.
|
||||
* @returns {string} the persistence space, or undefined
|
||||
*/
|
||||
Identifier.prototype.getDefinedSpace = function () {
|
||||
return this.definedSpace;
|
||||
};
|
||||
|
@ -28,11 +28,22 @@ define(
|
||||
|
||||
/**
|
||||
* Parses and generates domain object identifiers.
|
||||
* @param {string} defaultSpace the default persistence space
|
||||
* @constructor
|
||||
* @memberof {platform/core}
|
||||
*/
|
||||
function IdentifierProvider(defaultSpace) {
|
||||
this.defaultSpace = defaultSpace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new domain object identifier. A persistence space
|
||||
* may optionally be included; if not specified, no space will
|
||||
* be encoded into the identifier.
|
||||
* @param {string} [space] the persistence space to encode
|
||||
* in this identifier
|
||||
* @returns {string} a new domain object identifier
|
||||
*/
|
||||
IdentifierProvider.prototype.generate = function (space) {
|
||||
var id = uuid();
|
||||
if (space !== undefined) {
|
||||
@ -41,6 +52,11 @@ define(
|
||||
return id;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse a domain object identifier to examine its component
|
||||
* parts (e.g. its persistence space.)
|
||||
* @returns {platform/core.Identifier} the parsed identifier
|
||||
*/
|
||||
IdentifierProvider.prototype.parse = function (id) {
|
||||
return new Identifier(id, this.defaultSpace);
|
||||
};
|
||||
|
Reference in New Issue
Block a user