[Persistence] Add JSDoc

Add JSDoc to classes added/modified to support multiple persistence
spaces, nasa/openmctweb#245.
This commit is contained in:
Victor Woeltjen 2015-11-10 14:16:07 -08:00
parent a14f30c03c
commit 04ce2f985a
6 changed files with 57 additions and 3 deletions

View File

@ -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) {

View File

@ -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;
};

View File

@ -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);
};

View File

@ -62,6 +62,8 @@ define(
* @constructor
* @private
* @memberof platform/entanglement
* @param {PolicyService} policyService the policy service to use to
* verify that variants of this action are allowed
* @param {platform/entanglement.LocationService} locationService a
* service to request destinations from the user
* @param {platform/entanglement.AbstractComposeService} composeService

View File

@ -33,6 +33,14 @@ define(
"compose"
];
/**
* This policy prevents performing move/copy/link actions across
* different persistence spaces (e.g. linking to an object in
* a private space from an object in a public space.)
* @memberof {platform/entanglement}
* @constructor
* @implements {Policy}
*/
function CrossSpacePolicy() {
}

View File

@ -36,10 +36,13 @@ define(
};
/**
* Aggregates multiple persistence providers, such that they can be
* utilized as if they were a single object.
* @memberof platform/persistence/aggregator
* @constructor
* @implements {PersistenceService}
* @param q Angular's $q, for promises
* @param $q Angular's $q, for promises
* @param {PersistenceService[]} providers the providers to aggregate
*/
function PersistenceAggregator($q, providers) {
var providerMap = {};