mirror of
https://github.com/nasa/openmct.git
synced 2025-02-08 03:50:39 +00:00
[Code Style] Rename shadowing variables
This commit is contained in:
parent
e468080373
commit
ad5691142e
@ -152,7 +152,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("validates selection types using policy", function () {
|
it("validates selection types using policy", function () {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject',
|
'domainObject',
|
||||||
['getCapability']
|
['getCapability']
|
||||||
),
|
),
|
||||||
@ -166,8 +166,8 @@ define(
|
|||||||
rows = structure.sections[sections.length - 1].rows,
|
rows = structure.sections[sections.length - 1].rows,
|
||||||
locationRow = rows[rows.length - 1];
|
locationRow = rows[rows.length - 1];
|
||||||
|
|
||||||
mockDomainObject.getCapability.andReturn(mockOtherType);
|
mockDomainObj.getCapability.andReturn(mockOtherType);
|
||||||
locationRow.validate(mockDomainObject);
|
locationRow.validate(mockDomainObj);
|
||||||
|
|
||||||
// Should check policy to see if the user-selected location
|
// Should check policy to see if the user-selected location
|
||||||
// can actually contain objects of this type
|
// can actually contain objects of this type
|
||||||
|
@ -63,10 +63,10 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showDialog(type) {
|
function showDialog(objType) {
|
||||||
// Create a dialog object to generate the form structure, etc.
|
// Create a dialog object to generate the form structure, etc.
|
||||||
var dialog =
|
var dialog =
|
||||||
new PropertiesDialog(type, domainObject.getModel());
|
new PropertiesDialog(objType, domainObject.getModel());
|
||||||
|
|
||||||
// Show the dialog
|
// Show the dialog
|
||||||
return dialogService.getUserInput(
|
return dialogService.getUserInput(
|
||||||
|
@ -75,8 +75,8 @@ define(
|
|||||||
* Invoke persistence on a domain object. This will be called upon
|
* Invoke persistence on a domain object. This will be called upon
|
||||||
* the removed object's parent (as its composition will have changed.)
|
* the removed object's parent (as its composition will have changed.)
|
||||||
*/
|
*/
|
||||||
function doPersist(domainObject) {
|
function doPersist(domainObj) {
|
||||||
var persistence = domainObject.getCapability('persistence');
|
var persistence = domainObj.getCapability('persistence');
|
||||||
return persistence && persistence.persist();
|
return persistence && persistence.persist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ define(
|
|||||||
|
|
||||||
// Update value for this property in all elements of the
|
// Update value for this property in all elements of the
|
||||||
// selection which have this property.
|
// selection which have this property.
|
||||||
function updateProperties(property, value) {
|
function updateProperties(property, val) {
|
||||||
var changed = false;
|
var changed = false;
|
||||||
|
|
||||||
// Update property in a selected element
|
// Update property in a selected element
|
||||||
@ -233,12 +233,12 @@ define(
|
|||||||
// Check if this is a setter, or just assignable
|
// Check if this is a setter, or just assignable
|
||||||
if (typeof selected[property] === 'function') {
|
if (typeof selected[property] === 'function') {
|
||||||
changed =
|
changed =
|
||||||
changed || (selected[property]() !== value);
|
changed || (selected[property]() !== val);
|
||||||
selected[property](value);
|
selected[property](val);
|
||||||
} else {
|
} else {
|
||||||
changed =
|
changed =
|
||||||
changed || (selected[property] !== value);
|
changed || (selected[property] !== val);
|
||||||
selected[property] = value;
|
selected[property] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,11 +133,11 @@ define(
|
|||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
// Initialize toolbar (expose object to parent scope)
|
// Initialize toolbar (expose object to parent scope)
|
||||||
function initialize(definition) {
|
function initialize(def) {
|
||||||
// If we have been asked to expose toolbar state...
|
// If we have been asked to expose toolbar state...
|
||||||
if (self.attrs.toolbar) {
|
if (self.attrs.toolbar) {
|
||||||
// Initialize toolbar object
|
// Initialize toolbar object
|
||||||
self.toolbar = new EditToolbar(definition, self.commit);
|
self.toolbar = new EditToolbar(def, self.commit);
|
||||||
// Ensure toolbar state is exposed
|
// Ensure toolbar state is exposed
|
||||||
self.exposeToolbar();
|
self.exposeToolbar();
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,11 @@ define(
|
|||||||
model = { x: "initial value" };
|
model = { x: "initial value" };
|
||||||
properties = ["x", "y", "z"].map(function (k) {
|
properties = ["x", "y", "z"].map(function (k) {
|
||||||
return {
|
return {
|
||||||
getValue: function (model) {
|
getValue: function (m) {
|
||||||
return model[k];
|
return m[k];
|
||||||
},
|
},
|
||||||
setValue: function (model, v) {
|
setValue: function (m, v) {
|
||||||
model[k] = v;
|
m[k] = v;
|
||||||
},
|
},
|
||||||
getDefinition: function () {
|
getDefinition: function () {
|
||||||
return { control: 'textfield '};
|
return { control: 'textfield '};
|
||||||
|
@ -50,8 +50,8 @@ define(
|
|||||||
var context = domainObject &&
|
var context = domainObject &&
|
||||||
domainObject.getCapability('context'),
|
domainObject.getCapability('context'),
|
||||||
objectPath = context ? context.getPath() : [],
|
objectPath = context ? context.getPath() : [],
|
||||||
ids = objectPath.map(function (domainObject) {
|
ids = objectPath.map(function (domainObj) {
|
||||||
return domainObject.getId();
|
return domainObj.getId();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Parses the path together. Starts with the
|
// Parses the path together. Starts with the
|
||||||
|
@ -105,8 +105,8 @@ define([
|
|||||||
function getIdPath(domainObject) {
|
function getIdPath(domainObject) {
|
||||||
var context = domainObject && domainObject.getCapability('context');
|
var context = domainObject && domainObject.getCapability('context');
|
||||||
|
|
||||||
function getId(domainObject) {
|
function getId(domainObj) {
|
||||||
return domainObject.getId();
|
return domainObj.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
return context ? context.getPath().map(getId) : [];
|
return context ? context.getPath().map(getId) : [];
|
||||||
|
@ -62,8 +62,8 @@ define([
|
|||||||
var self = this,
|
var self = this,
|
||||||
domainObject = this.activeObject;
|
domainObject = this.activeObject;
|
||||||
|
|
||||||
function addNode(domainObject, index) {
|
function addNode(domainObj, index) {
|
||||||
self.nodeViews[index].model(domainObject);
|
self.nodeViews[index].model(domainObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNodes(domainObjects) {
|
function addNodes(domainObjects) {
|
||||||
|
@ -36,7 +36,7 @@ define([
|
|||||||
treeView;
|
treeView;
|
||||||
|
|
||||||
function makeMockDomainObject(id, model, capabilities) {
|
function makeMockDomainObject(id, model, capabilities) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
[
|
[
|
||||||
'getId',
|
'getId',
|
||||||
@ -46,18 +46,18 @@ define([
|
|||||||
'useCapability'
|
'useCapability'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObj.getId.andReturn(id);
|
||||||
mockDomainObject.getModel.andReturn(model);
|
mockDomainObj.getModel.andReturn(model);
|
||||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
mockDomainObj.hasCapability.andCallFake(function (c) {
|
||||||
return !!(capabilities[c]);
|
return !!(capabilities[c]);
|
||||||
});
|
});
|
||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||||
return capabilities[c];
|
return capabilities[c];
|
||||||
});
|
});
|
||||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
mockDomainObj.useCapability.andCallFake(function (c) {
|
||||||
return capabilities[c] && capabilities[c].invoke();
|
return capabilities[c] && capabilities[c].invoke();
|
||||||
});
|
});
|
||||||
return mockDomainObject;
|
return mockDomainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@ -99,24 +99,16 @@ define([
|
|||||||
var mockComposition;
|
var mockComposition;
|
||||||
|
|
||||||
function makeGenericCapabilities() {
|
function makeGenericCapabilities() {
|
||||||
var mockContext =
|
var mockStatus =
|
||||||
jasmine.createSpyObj('context', ['getPath']),
|
|
||||||
mockType =
|
|
||||||
jasmine.createSpyObj('type', ['getGlyph']),
|
|
||||||
mockLocation =
|
|
||||||
jasmine.createSpyObj('location', ['isLink']),
|
|
||||||
mockMutation =
|
|
||||||
jasmine.createSpyObj('mutation', ['listen']),
|
|
||||||
mockStatus =
|
|
||||||
jasmine.createSpyObj('status', ['listen', 'list']);
|
jasmine.createSpyObj('status', ['listen', 'list']);
|
||||||
|
|
||||||
mockStatus.list.andReturn([]);
|
mockStatus.list.andReturn([]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
context: mockContext,
|
context: jasmine.createSpyObj('context', ['getPath']),
|
||||||
type: mockType,
|
type: jasmine.createSpyObj('type', ['getGlyph']),
|
||||||
mutation: mockMutation,
|
location: jasmine.createSpyObj('location', ['isLink']),
|
||||||
location: mockLocation,
|
mutation: jasmine.createSpyObj('mutation', ['listen']),
|
||||||
status: mockStatus
|
status: mockStatus
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -133,11 +125,11 @@ define([
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
||||||
var testCapabilities = makeGenericCapabilities(),
|
var testCaps = makeGenericCapabilities(),
|
||||||
mockChild =
|
mockChild =
|
||||||
makeMockDomainObject(id, {}, testCapabilities);
|
makeMockDomainObject(id, {}, testCaps);
|
||||||
|
|
||||||
testCapabilities.context.getPath
|
testCaps.context.getPath
|
||||||
.andReturn([mockDomainObject, mockChild]);
|
.andReturn([mockDomainObject, mockChild]);
|
||||||
|
|
||||||
return mockChild;
|
return mockChild;
|
||||||
@ -207,11 +199,11 @@ define([
|
|||||||
|
|
||||||
describe("when a context-less object is selected", function () {
|
describe("when a context-less object is selected", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var testCapabilities = makeGenericCapabilities(),
|
var testCaps = makeGenericCapabilities(),
|
||||||
mockDomainObject =
|
mockDomainObj =
|
||||||
makeMockDomainObject('xyz', {}, testCapabilities);
|
makeMockDomainObject('xyz', {}, testCaps);
|
||||||
delete testCapabilities.context;
|
delete testCaps.context;
|
||||||
treeView.value(mockDomainObject);
|
treeView.value(mockDomainObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears all selection state", function () {
|
it("clears all selection state", function () {
|
||||||
|
@ -79,8 +79,8 @@ define(
|
|||||||
// On any touch on the body, default body touches/events
|
// On any touch on the body, default body touches/events
|
||||||
// are prevented, the bubble is dismissed, and the touchstart
|
// are prevented, the bubble is dismissed, and the touchstart
|
||||||
// body event is unbound, reallowing gestures
|
// body event is unbound, reallowing gestures
|
||||||
body.on('touchstart', function (event) {
|
body.on('touchstart', function (evt) {
|
||||||
event.preventDefault();
|
evt.preventDefault();
|
||||||
hideBubble();
|
hideBubble();
|
||||||
body.unbind('touchstart');
|
body.unbind('touchstart');
|
||||||
});
|
});
|
||||||
|
@ -69,7 +69,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("detects display orientation", function () {
|
it("detects display orientation", function () {
|
||||||
var agentService = new AgentService(testWindow);
|
agentService = new AgentService(testWindow);
|
||||||
testWindow.innerWidth = 1024;
|
testWindow.innerWidth = 1024;
|
||||||
testWindow.innerHeight = 400;
|
testWindow.innerHeight = 400;
|
||||||
expect(agentService.isPortrait()).toBeFalsy();
|
expect(agentService.isPortrait()).toBeFalsy();
|
||||||
|
@ -81,8 +81,8 @@ define(
|
|||||||
// additionally fills in the action's getMetadata method
|
// additionally fills in the action's getMetadata method
|
||||||
// with the extension definition (if no getMetadata
|
// with the extension definition (if no getMetadata
|
||||||
// method was supplied.)
|
// method was supplied.)
|
||||||
function instantiateAction(Action, context) {
|
function instantiateAction(Action, ctxt) {
|
||||||
var action = new Action(context),
|
var action = new Action(ctxt),
|
||||||
metadata;
|
metadata;
|
||||||
|
|
||||||
// Provide a getMetadata method that echos
|
// Provide a getMetadata method that echos
|
||||||
@ -90,7 +90,7 @@ define(
|
|||||||
// unless the action has defined its own.
|
// unless the action has defined its own.
|
||||||
if (!action.getMetadata) {
|
if (!action.getMetadata) {
|
||||||
metadata = Object.create(Action.definition || {});
|
metadata = Object.create(Action.definition || {});
|
||||||
metadata.context = context;
|
metadata.context = ctxt;
|
||||||
action.getMetadata = function () {
|
action.getMetadata = function () {
|
||||||
return metadata;
|
return metadata;
|
||||||
};
|
};
|
||||||
@ -103,14 +103,14 @@ define(
|
|||||||
// applicable in a given context, according to the static
|
// applicable in a given context, according to the static
|
||||||
// appliesTo method of given actions (if defined), and
|
// appliesTo method of given actions (if defined), and
|
||||||
// instantiate those applicable actions.
|
// instantiate those applicable actions.
|
||||||
function createIfApplicable(actions, context) {
|
function createIfApplicable(actions, ctxt) {
|
||||||
function isApplicable(Action) {
|
function isApplicable(Action) {
|
||||||
return Action.appliesTo ? Action.appliesTo(context) : true;
|
return Action.appliesTo ? Action.appliesTo(ctxt) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function instantiate(Action) {
|
function instantiate(Action) {
|
||||||
try {
|
try {
|
||||||
return instantiateAction(Action, context);
|
return instantiateAction(Action, ctxt);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
$log.error([
|
$log.error([
|
||||||
"Could not instantiate action",
|
"Could not instantiate action",
|
||||||
|
@ -82,7 +82,7 @@ define(
|
|||||||
return mutationResult && self.invoke().then(findObject);
|
return mutationResult && self.invoke().then(findObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addIdToModel(model) {
|
function addIdToModel(objModel) {
|
||||||
// Pick a specific index if needed.
|
// Pick a specific index if needed.
|
||||||
index = isNaN(index) ? composition.length : index;
|
index = isNaN(index) ? composition.length : index;
|
||||||
// Also, don't put past the end of the array
|
// Also, don't put past the end of the array
|
||||||
@ -90,11 +90,11 @@ define(
|
|||||||
|
|
||||||
// Remove the existing instance of the id
|
// Remove the existing instance of the id
|
||||||
if (oldIndex !== -1) {
|
if (oldIndex !== -1) {
|
||||||
model.composition.splice(oldIndex, 1);
|
objModel.composition.splice(oldIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...and add it back at the appropriate index.
|
// ...and add it back at the appropriate index.
|
||||||
model.composition.splice(index, 0, id);
|
objModel.composition.splice(index, 0, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no index has been specified already and the id is already
|
// If no index has been specified already and the id is already
|
||||||
|
@ -62,9 +62,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Package capabilities as key-value pairs
|
// Package capabilities as key-value pairs
|
||||||
function packageCapabilities(capabilities) {
|
function packageCapabilities(caps) {
|
||||||
var result = {};
|
var result = {};
|
||||||
capabilities.forEach(function (capability) {
|
caps.forEach(function (capability) {
|
||||||
if (capability.key) {
|
if (capability.key) {
|
||||||
result[capability.key] =
|
result[capability.key] =
|
||||||
result[capability.key] || capability;
|
result[capability.key] || capability;
|
||||||
|
@ -124,9 +124,9 @@ define(
|
|||||||
clone = JSON.parse(JSON.stringify(model)),
|
clone = JSON.parse(JSON.stringify(model)),
|
||||||
useTimestamp = arguments.length > 1;
|
useTimestamp = arguments.length > 1;
|
||||||
|
|
||||||
function notifyListeners(model) {
|
function notifyListeners(newModel) {
|
||||||
generalTopic.notify(domainObject);
|
generalTopic.notify(domainObject);
|
||||||
specificTopic.notify(model);
|
specificTopic.notify(newModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to handle copying values to the actual
|
// Function to handle copying values to the actual
|
||||||
|
@ -124,8 +124,8 @@ define(
|
|||||||
this.persistenceService.createObject;
|
this.persistenceService.createObject;
|
||||||
|
|
||||||
// Update persistence timestamp...
|
// Update persistence timestamp...
|
||||||
domainObject.useCapability("mutation", function (model) {
|
domainObject.useCapability("mutation", function (m) {
|
||||||
model.persisted = modified;
|
m.persisted = modified;
|
||||||
}, modified);
|
}, modified);
|
||||||
|
|
||||||
// ...and persist
|
// ...and persist
|
||||||
|
@ -82,9 +82,9 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Package the result as id->model
|
// Package the result as id->model
|
||||||
function packageResult(parsedIds, models) {
|
function packageResult(parsedIdsToPackage, models) {
|
||||||
var result = {};
|
var result = {};
|
||||||
parsedIds.forEach(function (parsedId, index) {
|
parsedIdsToPackage.forEach(function (parsedId, index) {
|
||||||
var id = parsedId.id;
|
var id = parsedId.id;
|
||||||
if (models[index]) {
|
if (models[index]) {
|
||||||
result[id] = models[index];
|
result[id] = models[index];
|
||||||
@ -93,11 +93,11 @@ define(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadModels(parsedIds) {
|
function loadModels(parsedIdsToLoad) {
|
||||||
return $q.all(parsedIds.map(loadModel))
|
return $q.all(parsedIdsToLoad.map(loadModel))
|
||||||
.then(function (models) {
|
.then(function (models) {
|
||||||
return packageResult(
|
return packageResult(
|
||||||
parsedIds,
|
parsedIdsToLoad,
|
||||||
models.map(addPersistedTimestamp)
|
models.map(addPersistedTimestamp)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -58,14 +58,14 @@ define(
|
|||||||
* corresponding keys in the recursive step.
|
* corresponding keys in the recursive step.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param a the first object to be merged
|
* @param modelA the first object to be merged
|
||||||
* @param b the second object to be merged
|
* @param modelB the second object to be merged
|
||||||
* @param merger the merger, as described above
|
* @param merger the merger, as described above
|
||||||
* @returns {*} the result of merging `a` and `b`
|
* @returns {*} the result of merging `modelA` and `modelB`
|
||||||
* @constructor
|
* @constructor
|
||||||
* @memberof platform/core
|
* @memberof platform/core
|
||||||
*/
|
*/
|
||||||
function mergeModels(a, b, merger) {
|
function mergeModels(modelA, modelB, merger) {
|
||||||
var mergeFunction;
|
var mergeFunction;
|
||||||
|
|
||||||
function mergeArrays(a, b) {
|
function mergeArrays(a, b) {
|
||||||
@ -93,11 +93,11 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
|
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
|
||||||
(Array.isArray(a) && Array.isArray(b)) ? mergeArrays :
|
(Array.isArray(modelA) && Array.isArray(modelB)) ? mergeArrays :
|
||||||
(a instanceof Object && b instanceof Object) ? mergeObjects :
|
(modelA instanceof Object && modelB instanceof Object) ? mergeObjects :
|
||||||
mergeOther;
|
mergeOther;
|
||||||
|
|
||||||
return mergeFunction(a, b);
|
return mergeFunction(modelA, modelB);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mergeModels;
|
return mergeModels;
|
||||||
|
@ -159,8 +159,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function lookupTypeDef(typeKey) {
|
function lookupTypeDef(typeKey) {
|
||||||
function buildTypeDef(typeKey) {
|
function buildTypeDef(typeKeyToBuild) {
|
||||||
var typeDefs = typeDefinitions[typeKey] || [],
|
var typeDefs = typeDefinitions[typeKeyToBuild] || [],
|
||||||
inherits = typeDefs.map(function (typeDef) {
|
inherits = typeDefs.map(function (typeDef) {
|
||||||
return asArray(typeDef.inherits || []);
|
return asArray(typeDef.inherits || []);
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
|
@ -105,15 +105,15 @@ define(
|
|||||||
// Check if an object has all capabilities designated as `needs`
|
// Check if an object has all capabilities designated as `needs`
|
||||||
// for a view. Exposing a capability via delegation is taken to
|
// for a view. Exposing a capability via delegation is taken to
|
||||||
// satisfy this filter if `allowDelegation` is true.
|
// satisfy this filter if `allowDelegation` is true.
|
||||||
function capabilitiesMatch(domainObject, capabilities, allowDelegation) {
|
function capabilitiesMatch(domainObj, capabilities, allowDelegation) {
|
||||||
var delegation = domainObject.getCapability("delegation");
|
var delegation = domainObj.getCapability("delegation");
|
||||||
|
|
||||||
allowDelegation = allowDelegation && (delegation !== undefined);
|
allowDelegation = allowDelegation && (delegation !== undefined);
|
||||||
|
|
||||||
// Check if an object has (or delegates, if allowed) a
|
// Check if an object has (or delegates, if allowed) a
|
||||||
// capability.
|
// capability.
|
||||||
function hasCapability(c) {
|
function hasCapability(c) {
|
||||||
return domainObject.hasCapability(c) ||
|
return domainObj.hasCapability(c) ||
|
||||||
(allowDelegation && delegation.doesDelegateCapability(c));
|
(allowDelegation && delegation.doesDelegateCapability(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,13 +128,13 @@ define(
|
|||||||
|
|
||||||
// Check if a view and domain object type can be paired;
|
// Check if a view and domain object type can be paired;
|
||||||
// both can restrict the others they accept.
|
// both can restrict the others they accept.
|
||||||
function viewMatchesType(view, type) {
|
function viewMatchesType(view, objType) {
|
||||||
var views = type && (type.getDefinition() || {}).views,
|
var views = objType && (objType.getDefinition() || {}).views,
|
||||||
matches = true;
|
matches = true;
|
||||||
|
|
||||||
// View is restricted to a certain type
|
// View is restricted to a certain type
|
||||||
if (view.type) {
|
if (view.type) {
|
||||||
matches = matches && type && type.instanceOf(view.type);
|
matches = matches && objType && objType.instanceOf(view.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type wishes to restrict its specific views
|
// Type wishes to restrict its specific views
|
||||||
|
@ -73,16 +73,16 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("uses the instantiate service to create domain objects", function () {
|
it("uses the instantiate service to create domain objects", function () {
|
||||||
var mockDomainObject = jasmine.createSpyObj('domainObject', [
|
var mockDomainObj = jasmine.createSpyObj('domainObject', [
|
||||||
'getId',
|
'getId',
|
||||||
'getModel',
|
'getModel',
|
||||||
'getCapability',
|
'getCapability',
|
||||||
'useCapability',
|
'useCapability',
|
||||||
'hasCapability'
|
'hasCapability'
|
||||||
]), testModel = { someKey: "some value" };
|
]), testModel = { someKey: "some value" };
|
||||||
mockInstantiate.andReturn(mockDomainObject);
|
mockInstantiate.andReturn(mockDomainObj);
|
||||||
expect(instantiation.instantiate(testModel))
|
expect(instantiation.instantiate(testModel))
|
||||||
.toBe(mockDomainObject);
|
.toBe(mockDomainObj);
|
||||||
expect(mockInstantiate)
|
expect(mockInstantiate)
|
||||||
.toHaveBeenCalledWith({
|
.toHaveBeenCalledWith({
|
||||||
someKey: "some value",
|
someKey: "some value",
|
||||||
|
@ -99,7 +99,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("ensures a single object instance, even for multiple concurrent calls", function () {
|
it("ensures a single object instance, even for multiple concurrent calls", function () {
|
||||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
var promiseA, promiseB;
|
||||||
|
|
||||||
promiseA = fakePromise();
|
promiseA = fakePromise();
|
||||||
promiseB = fakePromise();
|
promiseB = fakePromise();
|
||||||
@ -126,7 +126,7 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("is robust against updating with undefined values", function () {
|
it("is robust against updating with undefined values", function () {
|
||||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
var promiseA, promiseB;
|
||||||
|
|
||||||
promiseA = fakePromise();
|
promiseA = fakePromise();
|
||||||
promiseB = fakePromise();
|
promiseB = fakePromise();
|
||||||
|
@ -109,7 +109,7 @@ define(
|
|||||||
it("restricts typed views to matching types", function () {
|
it("restricts typed views to matching types", function () {
|
||||||
var testType = "testType",
|
var testType = "testType",
|
||||||
testView = { key: "x", type: testType },
|
testView = { key: "x", type: testType },
|
||||||
provider = new ViewProvider([testView], mockLog);
|
viewProvider = new ViewProvider([testView], mockLog);
|
||||||
|
|
||||||
// Include a "type" capability
|
// Include a "type" capability
|
||||||
capabilities.type = jasmine.createSpyObj(
|
capabilities.type = jasmine.createSpyObj(
|
||||||
@ -120,21 +120,21 @@ define(
|
|||||||
|
|
||||||
// Should be included when types match
|
// Should be included when types match
|
||||||
capabilities.type.instanceOf.andReturn(true);
|
capabilities.type.instanceOf.andReturn(true);
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([testView]);
|
.toEqual([testView]);
|
||||||
expect(capabilities.type.instanceOf)
|
expect(capabilities.type.instanceOf)
|
||||||
.toHaveBeenCalledWith(testType);
|
.toHaveBeenCalledWith(testType);
|
||||||
|
|
||||||
// ...but not when they don't
|
// ...but not when they don't
|
||||||
capabilities.type.instanceOf.andReturn(false);
|
capabilities.type.instanceOf.andReturn(false);
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([]);
|
.toEqual([]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("enforces view restrictions from types", function () {
|
it("enforces view restrictions from types", function () {
|
||||||
var testView = { key: "x" },
|
var testView = { key: "x" },
|
||||||
provider = new ViewProvider([testView], mockLog);
|
viewProvider = new ViewProvider([testView], mockLog);
|
||||||
|
|
||||||
// Include a "type" capability
|
// Include a "type" capability
|
||||||
capabilities.type = jasmine.createSpyObj(
|
capabilities.type = jasmine.createSpyObj(
|
||||||
@ -146,13 +146,13 @@ define(
|
|||||||
// Should be included when view keys match
|
// Should be included when view keys match
|
||||||
capabilities.type.getDefinition
|
capabilities.type.getDefinition
|
||||||
.andReturn({ views: [testView.key]});
|
.andReturn({ views: [testView.key]});
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([testView]);
|
.toEqual([testView]);
|
||||||
|
|
||||||
// ...but not when they don't
|
// ...but not when they don't
|
||||||
capabilities.type.getDefinition
|
capabilities.type.getDefinition
|
||||||
.andReturn({ views: ["somethingElse"]});
|
.andReturn({ views: ["somethingElse"]});
|
||||||
expect(provider.getViews(mockDomainObject))
|
expect(viewProvider.getViews(mockDomainObject))
|
||||||
.toEqual([]);
|
.toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -126,11 +126,11 @@ define(
|
|||||||
|
|
||||||
label = this.verb + " To";
|
label = this.verb + " To";
|
||||||
|
|
||||||
validateLocation = function (newParent) {
|
validateLocation = function (newParentObj) {
|
||||||
var newContext = self.cloneContext();
|
var newContext = self.cloneContext();
|
||||||
newContext.selectedObject = object;
|
newContext.selectedObject = object;
|
||||||
newContext.domainObject = newParent;
|
newContext.domainObject = newParentObj;
|
||||||
return composeService.validate(object, newParent) &&
|
return composeService.validate(object, newParentObj) &&
|
||||||
self.policyService.allow("action", self, newContext);
|
self.policyService.allow("action", self, newContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -139,8 +139,8 @@ define(
|
|||||||
label,
|
label,
|
||||||
validateLocation,
|
validateLocation,
|
||||||
currentParent
|
currentParent
|
||||||
).then(function (newParent) {
|
).then(function (newParentObj) {
|
||||||
return composeService.perform(object, newParent);
|
return composeService.perform(object, newParentObj);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,11 +83,11 @@ define(
|
|||||||
|
|
||||||
// Combines caller-provided filter (if any) with the
|
// Combines caller-provided filter (if any) with the
|
||||||
// baseline behavior of respecting creation policy.
|
// baseline behavior of respecting creation policy.
|
||||||
function filterWithPolicy(domainObject) {
|
function filterWithPolicy(domainObj) {
|
||||||
return (!filter || filter(domainObject)) &&
|
return (!filter || filter(domainObj)) &&
|
||||||
policyService.allow(
|
policyService.allow(
|
||||||
"creation",
|
"creation",
|
||||||
domainObject.getCapability("type")
|
domainObj.getCapability("type")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ define(
|
|||||||
|
|
||||||
return dialogService
|
return dialogService
|
||||||
.getUserInput(formStructure, formState)
|
.getUserInput(formStructure, formState)
|
||||||
.then(function (formState) {
|
.then(function (userFormState) {
|
||||||
return formState.location;
|
return userFormState.location;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -458,17 +458,17 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("throws an error", function () {
|
it("throws an error", function () {
|
||||||
var copyService =
|
var service =
|
||||||
new CopyService(mockQ, policyService);
|
new CopyService(mockQ, policyService);
|
||||||
|
|
||||||
function perform() {
|
function perform() {
|
||||||
copyService.perform(object, newParent);
|
service.perform(object, newParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
spyOn(copyService, "validate");
|
spyOn(service, "validate");
|
||||||
copyService.validate.andReturn(true);
|
service.validate.andReturn(true);
|
||||||
expect(perform).not.toThrow();
|
expect(perform).not.toThrow();
|
||||||
copyService.validate.andReturn(false);
|
service.validate.andReturn(false);
|
||||||
expect(perform).toThrow();
|
expect(perform).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -120,7 +120,7 @@ define(
|
|||||||
|
|
||||||
it("on changes in form values, updates the object model", function () {
|
it("on changes in form values, updates the object model", function () {
|
||||||
var scopeConfiguration = mockScope.configuration,
|
var scopeConfiguration = mockScope.configuration,
|
||||||
model = mockDomainObject.getModel();
|
objModel = mockDomainObject.getModel();
|
||||||
|
|
||||||
scopeConfiguration.plot.yAxis.autoScale = true;
|
scopeConfiguration.plot.yAxis.autoScale = true;
|
||||||
scopeConfiguration.plot.yAxis.key = 'eu';
|
scopeConfiguration.plot.yAxis.key = 'eu';
|
||||||
@ -130,10 +130,10 @@ define(
|
|||||||
mockScope.$watchCollection.calls[0].args[1]();
|
mockScope.$watchCollection.calls[0].args[1]();
|
||||||
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
|
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
|
||||||
|
|
||||||
mockDomainObject.useCapability.mostRecentCall.args[1](model);
|
mockDomainObject.useCapability.mostRecentCall.args[1](objModel);
|
||||||
expect(model.configuration.plot.yAxis.autoScale).toBe(true);
|
expect(objModel.configuration.plot.yAxis.autoScale).toBe(true);
|
||||||
expect(model.configuration.plot.yAxis.key).toBe('eu');
|
expect(objModel.configuration.plot.yAxis.key).toBe('eu');
|
||||||
expect(model.configuration.plot.xAxis.key).toBe('lst');
|
expect(objModel.configuration.plot.xAxis.key).toBe('lst');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,15 +32,15 @@ define(
|
|||||||
/**
|
/**
|
||||||
* Set default values for optional parameters on a given scope
|
* Set default values for optional parameters on a given scope
|
||||||
*/
|
*/
|
||||||
function setDefaults($scope) {
|
function setDefaults(scope) {
|
||||||
if (typeof $scope.enableFilter === 'undefined') {
|
if (typeof scope.enableFilter === 'undefined') {
|
||||||
$scope.enableFilter = true;
|
scope.enableFilter = true;
|
||||||
$scope.filters = {};
|
scope.filters = {};
|
||||||
}
|
}
|
||||||
if (typeof $scope.enableSort === 'undefined') {
|
if (typeof scope.enableSort === 'undefined') {
|
||||||
$scope.enableSort = true;
|
scope.enableSort = true;
|
||||||
$scope.sortColumn = undefined;
|
scope.sortColumn = undefined;
|
||||||
$scope.sortDirection = undefined;
|
scope.sortDirection = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,13 +485,13 @@ define(
|
|||||||
/**
|
/**
|
||||||
* Returns true if row matches all filters.
|
* Returns true if row matches all filters.
|
||||||
*/
|
*/
|
||||||
function matchRow(filters, row) {
|
function matchRow(filterMap, row) {
|
||||||
return Object.keys(filters).every(function (key) {
|
return Object.keys(filterMap).every(function (key) {
|
||||||
if (!row[key]) {
|
if (!row[key]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var testVal = String(row[key].text).toLowerCase();
|
var testVal = String(row[key].text).toLowerCase();
|
||||||
return testVal.indexOf(filters[key]) !== -1;
|
return testVal.indexOf(filterMap[key]) !== -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,25 +52,25 @@ define(
|
|||||||
// Set the start time associated with this object
|
// Set the start time associated with this object
|
||||||
function setStart(value) {
|
function setStart(value) {
|
||||||
var end = getEnd();
|
var end = getEnd();
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.start.timestamp = Math.max(value, 0);
|
m.start.timestamp = Math.max(value, 0);
|
||||||
// Update duration to keep end time
|
// Update duration to keep end time
|
||||||
model.duration.timestamp = Math.max(end - value, 0);
|
m.duration.timestamp = Math.max(end - value, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the duration associated with this object
|
// Set the duration associated with this object
|
||||||
function setDuration(value) {
|
function setDuration(value) {
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.duration.timestamp = Math.max(value, 0);
|
m.duration.timestamp = Math.max(value, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the end time associated with this object
|
// Set the end time associated with this object
|
||||||
function setEnd(value) {
|
function setEnd(value) {
|
||||||
var start = getStart();
|
var start = getStart();
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.duration.timestamp = Math.max(value - start, 0);
|
m.duration.timestamp = Math.max(value - start, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,21 +53,21 @@ define(
|
|||||||
|
|
||||||
// Initialize the data values
|
// Initialize the data values
|
||||||
function initializeValues() {
|
function initializeValues() {
|
||||||
var values = [],
|
var vals = [],
|
||||||
slope = 0,
|
slope = 0,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
// Add a point (or points, if needed) reaching to the provided
|
// Add a point (or points, if needed) reaching to the provided
|
||||||
// domain and/or range value
|
// domain and/or range value
|
||||||
function addPoint(domain, range) {
|
function addPoint(domain, range) {
|
||||||
var previous = values[values.length - 1],
|
var previous = vals[vals.length - 1],
|
||||||
delta = domain - previous.domain, // time delta
|
delta = domain - previous.domain, // time delta
|
||||||
change = delta * slope * rate, // change
|
change = delta * slope * rate, // change
|
||||||
next = previous.range + change;
|
next = previous.range + change;
|
||||||
|
|
||||||
// Crop to minimum boundary...
|
// Crop to minimum boundary...
|
||||||
if (next < minimum) {
|
if (next < minimum) {
|
||||||
values.push({
|
vals.push({
|
||||||
domain: intercept(
|
domain: intercept(
|
||||||
previous.domain,
|
previous.domain,
|
||||||
previous.range,
|
previous.range,
|
||||||
@ -81,7 +81,7 @@ define(
|
|||||||
|
|
||||||
// ...and maximum boundary
|
// ...and maximum boundary
|
||||||
if (next > maximum) {
|
if (next > maximum) {
|
||||||
values.push({
|
vals.push({
|
||||||
domain: intercept(
|
domain: intercept(
|
||||||
previous.domain,
|
previous.domain,
|
||||||
previous.range,
|
previous.range,
|
||||||
@ -95,19 +95,19 @@ define(
|
|||||||
|
|
||||||
// Add the new data value
|
// Add the new data value
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
values.push({ domain: domain, range: next });
|
vals.push({ domain: domain, range: next });
|
||||||
}
|
}
|
||||||
|
|
||||||
slope = range;
|
slope = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
values.push({ domain: 0, range: initial });
|
vals.push({ domain: 0, range: initial });
|
||||||
|
|
||||||
for (i = 0; i < graph.getPointCount(); i += 1) {
|
for (i = 0; i < graph.getPointCount(); i += 1) {
|
||||||
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
|
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return values;
|
return vals;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertToPercent(point) {
|
function convertToPercent(point) {
|
||||||
|
@ -72,13 +72,13 @@ define(
|
|||||||
|
|
||||||
// If there are sequences of points with the same timestamp,
|
// If there are sequences of points with the same timestamp,
|
||||||
// allow only the first and last.
|
// allow only the first and last.
|
||||||
function filterPoint(value, index, values) {
|
function filterPoint(value, index, vals) {
|
||||||
// Allow the first or last point as a base case; aside from
|
// Allow the first or last point as a base case; aside from
|
||||||
// that, allow only points that have different timestamps
|
// that, allow only points that have different timestamps
|
||||||
// from their predecessor or successor.
|
// from their predecessor or successor.
|
||||||
return (index === 0) || (index === values.length - 1) ||
|
return (index === 0) || (index === vals.length - 1) ||
|
||||||
(value.domain !== values[index - 1].domain) ||
|
(value.domain !== vals[index - 1].domain) ||
|
||||||
(value.domain !== values[index + 1].domain);
|
(value.domain !== vals[index + 1].domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a step up or down (Step 3c above)
|
// Add a step up or down (Step 3c above)
|
||||||
|
@ -57,8 +57,8 @@ define(
|
|||||||
|
|
||||||
// Set the start time associated with this object
|
// Set the start time associated with this object
|
||||||
function setStart(value) {
|
function setStart(value) {
|
||||||
mutation.mutate(function (model) {
|
mutation.mutate(function (m) {
|
||||||
model.start.timestamp = Math.max(value, 0);
|
m.start.timestamp = Math.max(value, 0);
|
||||||
}, model.modified);
|
}, model.modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,13 +120,13 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Look up a specific object's resource utilization
|
// Look up a specific object's resource utilization
|
||||||
function lookupUtilization(domainObject) {
|
function lookupUtilization(object) {
|
||||||
return domainObject.useCapability('utilization');
|
return object.useCapability('utilization');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up a specific object's resource utilization keys
|
// Look up a specific object's resource utilization keys
|
||||||
function lookupUtilizationResources(domainObject) {
|
function lookupUtilizationResources(object) {
|
||||||
var utilization = domainObject.getCapability('utilization');
|
var utilization = object.getCapability('utilization');
|
||||||
return utilization && utilization.resources();
|
return utilization && utilization.resources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,19 +47,19 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the timespan associated with this domain object
|
// Get the timespan associated with this domain object
|
||||||
function populateCapabilityMaps(domainObject) {
|
function populateCapabilityMaps(object) {
|
||||||
var id = domainObject.getId(),
|
var id = object.getId(),
|
||||||
timespanPromise = domainObject.useCapability('timespan');
|
timespanPromise = object.useCapability('timespan');
|
||||||
if (timespanPromise) {
|
if (timespanPromise) {
|
||||||
timespanPromise.then(function (timespan) {
|
timespanPromise.then(function (timespan) {
|
||||||
// Cache that timespan
|
// Cache that timespan
|
||||||
timespans[id] = timespan;
|
timespans[id] = timespan;
|
||||||
// And its mutation capability
|
// And its mutation capability
|
||||||
mutations[id] = domainObject.getCapability('mutation');
|
mutations[id] = object.getCapability('mutation');
|
||||||
// Also cache the persistence capability for later
|
// Also cache the persistence capability for later
|
||||||
persists[id] = domainObject.getCapability('persistence');
|
persists[id] = object.getCapability('persistence');
|
||||||
// And the composition, for bulk moves
|
// And the composition, for bulk moves
|
||||||
compositions[id] = domainObject.getModel().composition || [];
|
compositions[id] = object.getModel().composition || [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,8 +199,8 @@ define(
|
|||||||
minStart;
|
minStart;
|
||||||
|
|
||||||
// Update start & end, in that order
|
// Update start & end, in that order
|
||||||
function updateStartEnd(id) {
|
function updateStartEnd(spanId) {
|
||||||
var timespan = timespans[id], start, end;
|
var timespan = timespans[spanId], start, end;
|
||||||
if (timespan) {
|
if (timespan) {
|
||||||
// Get start/end so we don't get fooled by our
|
// Get start/end so we don't get fooled by our
|
||||||
// own adjustments
|
// own adjustments
|
||||||
@ -210,7 +210,7 @@ define(
|
|||||||
timespan.setStart(start + delta);
|
timespan.setStart(start + delta);
|
||||||
timespan.setEnd(end + delta);
|
timespan.setEnd(end + delta);
|
||||||
// Mark as dirty for subsequent persistence
|
// Mark as dirty for subsequent persistence
|
||||||
dirty[toId(id)] = true;
|
dirty[toId(spanId)] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,12 +228,12 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the minimum start time
|
// Find the minimum start time
|
||||||
minStart = Object.keys(ids).map(function (id) {
|
minStart = Object.keys(ids).map(function (spanId) {
|
||||||
// Get the start time; default to +Inf if not
|
// Get the start time; default to +Inf if not
|
||||||
// found, since this will not survive a min
|
// found, since this will not survive a min
|
||||||
// test if any real timespans are present
|
// test if any real timespans are present
|
||||||
return timespans[id] ?
|
return timespans[spanId] ?
|
||||||
timespans[id].getStart() :
|
timespans[spanId].getStart() :
|
||||||
Number.POSITIVE_INFINITY;
|
Number.POSITIVE_INFINITY;
|
||||||
}).reduce(function (a, b) {
|
}).reduce(function (a, b) {
|
||||||
// Reduce with a minimum test
|
// Reduce with a minimum test
|
||||||
|
@ -75,11 +75,14 @@ define(
|
|||||||
|
|
||||||
// Look up resources for a domain object
|
// Look up resources for a domain object
|
||||||
function lookupResources(swimlane) {
|
function lookupResources(swimlane) {
|
||||||
var graphs = swimlane.domainObject.useCapability('graph');
|
var graphPromise =
|
||||||
|
swimlane.domainObject.useCapability('graph');
|
||||||
function getKeys(obj) {
|
function getKeys(obj) {
|
||||||
return Object.keys(obj);
|
return Object.keys(obj);
|
||||||
}
|
}
|
||||||
return $q.when(graphs ? (graphs.then(getKeys)) : []);
|
return $q.when(
|
||||||
|
graphPromise ? (graphPromise.then(getKeys)) : []
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all graph assignments appropriate for this swimlane
|
// Add all graph assignments appropriate for this swimlane
|
||||||
|
@ -34,8 +34,8 @@ define(
|
|||||||
var actionMap = {};
|
var actionMap = {};
|
||||||
|
|
||||||
// Populate available Create actions for this domain object
|
// Populate available Create actions for this domain object
|
||||||
function populateActionMap(domainObject) {
|
function populateActionMap(object) {
|
||||||
var actionCapability = domainObject.getCapability('action'),
|
var actionCapability = object.getCapability('action'),
|
||||||
actions = actionCapability ?
|
actions = actionCapability ?
|
||||||
actionCapability.getActions('add') : [];
|
actionCapability.getActions('add') : [];
|
||||||
actions.forEach(function (action) {
|
actions.forEach(function (action) {
|
||||||
|
@ -45,9 +45,9 @@ define(
|
|||||||
if (arguments.length > 0 && Array.isArray(value)) {
|
if (arguments.length > 0 && Array.isArray(value)) {
|
||||||
if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) {
|
if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) {
|
||||||
// Update the relationships
|
// Update the relationships
|
||||||
mutator.mutate(function (model) {
|
mutator.mutate(function (m) {
|
||||||
model.relationships = model.relationships || {};
|
m.relationships = m.relationships || {};
|
||||||
model.relationships[ACTIVITY_RELATIONSHIP] = value;
|
m.relationships[ACTIVITY_RELATIONSHIP] = value;
|
||||||
}).then(persister.persist);
|
}).then(persister.persist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,8 +61,8 @@ define(
|
|||||||
if (arguments.length > 0 && (typeof value === 'string') &&
|
if (arguments.length > 0 && (typeof value === 'string') &&
|
||||||
value !== model.link) {
|
value !== model.link) {
|
||||||
// Update the link
|
// Update the link
|
||||||
mutator.mutate(function (model) {
|
mutator.mutate(function (m) {
|
||||||
model.link = value;
|
m.link = value;
|
||||||
}).then(persister.persist);
|
}).then(persister.persist);
|
||||||
}
|
}
|
||||||
return model.link;
|
return model.link;
|
||||||
|
@ -51,7 +51,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if pathA entirely contains pathB
|
// Check if pathA entirely contains pathB
|
||||||
function pathContains(swimlane, id) {
|
function pathContains(swimlaneToCheck, id) {
|
||||||
// Check if id at a specific index matches (for map below)
|
// Check if id at a specific index matches (for map below)
|
||||||
function matches(pathId) {
|
function matches(pathId) {
|
||||||
return pathId === id;
|
return pathId === id;
|
||||||
@ -59,18 +59,18 @@ define(
|
|||||||
|
|
||||||
// Path A contains Path B if it is longer, and all of
|
// Path A contains Path B if it is longer, and all of
|
||||||
// B's ids match the ids in A.
|
// B's ids match the ids in A.
|
||||||
return swimlane.idPath.map(matches).reduce(or, false);
|
return swimlaneToCheck.idPath.map(matches).reduce(or, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a swimlane contains a child with the specified id
|
// Check if a swimlane contains a child with the specified id
|
||||||
function contains(swimlane, id) {
|
function contains(swimlaneToCheck, id) {
|
||||||
// Check if a child swimlane has a matching domain object id
|
// Check if a child swimlane has a matching domain object id
|
||||||
function matches(child) {
|
function matches(child) {
|
||||||
return child.domainObject.getId() === id;
|
return child.domainObject.getId() === id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find any one child id that matches this id
|
// Find any one child id that matches this id
|
||||||
return swimlane.children.map(matches).reduce(or, false);
|
return swimlaneToCheck.children.map(matches).reduce(or, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initiate mutation of a domain object
|
// Initiate mutation of a domain object
|
||||||
|
@ -61,8 +61,8 @@ define(
|
|||||||
swimlane;
|
swimlane;
|
||||||
|
|
||||||
// For the recursive step
|
// For the recursive step
|
||||||
function populate(childSubgraph, index) {
|
function populate(childSubgraph, nextIndex) {
|
||||||
populateSwimlanes(childSubgraph, swimlane, index);
|
populateSwimlanes(childSubgraph, swimlane, nextIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we have a valid object instance...
|
// Make sure we have a valid object instance...
|
||||||
|
@ -41,13 +41,13 @@ define(
|
|||||||
filter;
|
filter;
|
||||||
|
|
||||||
// Check object existence (for criterion-less filtering)
|
// Check object existence (for criterion-less filtering)
|
||||||
function exists(domainObject) {
|
function exists(object) {
|
||||||
return !!domainObject;
|
return !!object;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for capability matching criterion
|
// Check for capability matching criterion
|
||||||
function hasCapability(domainObject) {
|
function hasCapability(object) {
|
||||||
return domainObject && domainObject.hasCapability(criterion);
|
return object && object.hasCapability(criterion);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the recursive step...
|
// For the recursive step...
|
||||||
@ -61,8 +61,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Avoid infinite recursion
|
// Avoid infinite recursion
|
||||||
function notVisiting(domainObject) {
|
function notVisiting(object) {
|
||||||
return !visiting[domainObject.getId()];
|
return !visiting[object.getId()];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the composition of this domain object into the result
|
// Put the composition of this domain object into the result
|
||||||
|
@ -55,8 +55,8 @@ define([
|
|||||||
if (!!model.composition) {
|
if (!!model.composition) {
|
||||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||||
return c === 'composition' &&
|
return c === 'composition' &&
|
||||||
Promise.resolve(model.composition.map(function (id) {
|
Promise.resolve(model.composition.map(function (cid) {
|
||||||
return mockDomainObjects[id];
|
return mockDomainObjects[cid];
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -68,8 +68,8 @@ define([
|
|||||||
);
|
);
|
||||||
mockRelationships.getRelatedObjects.andCallFake(function (k) {
|
mockRelationships.getRelatedObjects.andCallFake(function (k) {
|
||||||
var ids = model.relationships[k] || [];
|
var ids = model.relationships[k] || [];
|
||||||
return Promise.resolve(ids.map(function (id) {
|
return Promise.resolve(ids.map(function (objId) {
|
||||||
return mockDomainObjects[id];
|
return mockDomainObjects[objId];
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||||
|
@ -69,8 +69,8 @@ define(
|
|||||||
resources: function () {
|
resources: function () {
|
||||||
return Object.keys(costs).sort();
|
return Object.keys(costs).sort();
|
||||||
},
|
},
|
||||||
cost: function (c) {
|
cost: function (k) {
|
||||||
return costs[c];
|
return costs[k];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -56,22 +56,22 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeMockDomainObject(id, composition) {
|
function makeMockDomainObject(id, composition) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObj.getId.andReturn(id);
|
||||||
mockDomainObject.getModel.andReturn({ composition: composition });
|
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||||
mockDomainObject.useCapability.andReturn(asPromise(mockTimespans[id]));
|
mockDomainObj.useCapability.andReturn(asPromise(mockTimespans[id]));
|
||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||||
return {
|
return {
|
||||||
persistence: mockPersists[id],
|
persistence: mockPersists[id],
|
||||||
mutation: mockMutations[id]
|
mutation: mockMutations[id]
|
||||||
}[c];
|
}[c];
|
||||||
});
|
});
|
||||||
|
|
||||||
return mockDomainObject;
|
return mockDomainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@ -42,16 +42,16 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function makeMockDomainObject(id, composition) {
|
function makeMockDomainObject(id, composition) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockDomainObj = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||||
);
|
);
|
||||||
|
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockDomainObj.getId.andReturn(id);
|
||||||
mockDomainObject.getModel.andReturn({ composition: composition });
|
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||||
mockDomainObject.useCapability.andReturn(asPromise(false));
|
mockDomainObj.useCapability.andReturn(asPromise(false));
|
||||||
|
|
||||||
return mockDomainObject;
|
return mockDomainObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subgraph(domainObject, objects) {
|
function subgraph(domainObject, objects) {
|
||||||
|
@ -164,15 +164,15 @@ define(
|
|||||||
|
|
||||||
// Examine a group of resolved dependencies to determine
|
// Examine a group of resolved dependencies to determine
|
||||||
// which extension categories still need to be satisfied.
|
// which extension categories still need to be satisfied.
|
||||||
function findEmptyExtensionDependencies(extensionGroup) {
|
function findEmptyExtensionDependencies(extGroup) {
|
||||||
var needed = {},
|
var needed = {},
|
||||||
categories = Object.keys(extensionGroup),
|
categories = Object.keys(extGroup),
|
||||||
allExtensions = [];
|
allExtensions = [];
|
||||||
|
|
||||||
// Build up an array of all extensions
|
// Build up an array of all extensions
|
||||||
categories.forEach(function (category) {
|
categories.forEach(function (category) {
|
||||||
allExtensions =
|
allExtensions =
|
||||||
allExtensions.concat(extensionGroup[category]);
|
allExtensions.concat(extGroup[category]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Track all extension dependencies exposed therefrom
|
// Track all extension dependencies exposed therefrom
|
||||||
@ -197,10 +197,9 @@ define(
|
|||||||
// Register any extension categories that are depended-upon but
|
// Register any extension categories that are depended-upon but
|
||||||
// have not been declared anywhere; such dependencies are then
|
// have not been declared anywhere; such dependencies are then
|
||||||
// satisfied by an empty array, instead of not at all.
|
// satisfied by an empty array, instead of not at all.
|
||||||
function registerEmptyDependencies(extensionGroup) {
|
function registerEmptyDependencies(extGroup) {
|
||||||
findEmptyExtensionDependencies(
|
findEmptyExtensionDependencies(extGroup)
|
||||||
extensionGroup
|
.forEach(function (name) {
|
||||||
).forEach(function (name) {
|
|
||||||
$log.info("Registering empty extension category " + name);
|
$log.info("Registering empty extension category " + name);
|
||||||
app.factory(name, [staticFunction([])]);
|
app.factory(name, [staticFunction([])]);
|
||||||
});
|
});
|
||||||
|
@ -58,11 +58,11 @@ define(
|
|||||||
var loader = this.loader,
|
var loader = this.loader,
|
||||||
$log = this.$log;
|
$log = this.$log;
|
||||||
|
|
||||||
function loadImplementation(extension) {
|
function loadImplementation(ext) {
|
||||||
var implPromise = extension.hasImplementationValue() ?
|
var implPromise = ext.hasImplementationValue() ?
|
||||||
Promise.resolve(extension.getImplementationValue()) :
|
Promise.resolve(ext.getImplementationValue()) :
|
||||||
loader.load(extension.getImplementationPath()),
|
loader.load(ext.getImplementationPath()),
|
||||||
definition = extension.getDefinition();
|
definition = ext.getDefinition();
|
||||||
|
|
||||||
// Wrap a constructor function (to avoid modifying the original)
|
// Wrap a constructor function (to avoid modifying the original)
|
||||||
function constructorFor(impl) {
|
function constructorFor(impl) {
|
||||||
@ -94,7 +94,7 @@ define(
|
|||||||
result.definition = definition;
|
result.definition = definition;
|
||||||
|
|
||||||
// Log that this load was successful
|
// Log that this load was successful
|
||||||
$log.info("Resolved " + extension.getLogName());
|
$log.info("Resolved " + ext.getLogName());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -105,7 +105,7 @@ define(
|
|||||||
// Build up a log message from parts
|
// Build up a log message from parts
|
||||||
var message = [
|
var message = [
|
||||||
"Could not load implementation for extension ",
|
"Could not load implementation for extension ",
|
||||||
extension.getLogName(),
|
ext.getLogName(),
|
||||||
" due to ",
|
" due to ",
|
||||||
err.message
|
err.message
|
||||||
].join("");
|
].join("");
|
||||||
@ -113,16 +113,16 @@ define(
|
|||||||
// Log that the extension was not loaded
|
// Log that the extension was not loaded
|
||||||
$log.warn(message);
|
$log.warn(message);
|
||||||
|
|
||||||
return extension.getDefinition();
|
return ext.getDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extension.hasImplementationValue()) {
|
if (!ext.hasImplementationValue()) {
|
||||||
// Log that loading has begun
|
// Log that loading has begun
|
||||||
$log.info([
|
$log.info([
|
||||||
"Loading implementation ",
|
"Loading implementation ",
|
||||||
extension.getImplementationPath(),
|
ext.getImplementationPath(),
|
||||||
" for extension ",
|
" for extension ",
|
||||||
extension.getLogName()
|
ext.getLogName()
|
||||||
].join(""));
|
].join(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ define(
|
|||||||
if ((response || {}).status === CONFLICT) {
|
if ((response || {}).status === CONFLICT) {
|
||||||
error.key = "revision";
|
error.key = "revision";
|
||||||
// Load the updated model, then reject the promise
|
// Load the updated model, then reject the promise
|
||||||
return this.get(key).then(function (response) {
|
return this.get(key).then(function (res) {
|
||||||
error.model = response[SRC];
|
error.model = res[SRC];
|
||||||
return $q.reject(error);
|
return $q.reject(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Retry persistence (overwrite) for this set of failed attempts
|
// Retry persistence (overwrite) for this set of failed attempts
|
||||||
function retry(failures) {
|
function retry(failuresToRetry) {
|
||||||
var models = {};
|
var models = {};
|
||||||
|
|
||||||
// Cache a copy of the model
|
// Cache a copy of the model
|
||||||
@ -92,17 +92,17 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache the object models we might want to save
|
// Cache the object models we might want to save
|
||||||
failures.forEach(cacheModel);
|
failuresToRetry.forEach(cacheModel);
|
||||||
|
|
||||||
// Strategy here:
|
// Strategy here:
|
||||||
// * Cache all of the models we might want to save (above)
|
// * Cache all of the models we might want to save (above)
|
||||||
// * Refresh all domain objects (so they are latest versions)
|
// * Refresh all domain objects (so they are latest versions)
|
||||||
// * Re-insert the cached domain object models
|
// * Re-insert the cached domain object models
|
||||||
// * Invoke persistence again
|
// * Invoke persistence again
|
||||||
return $q.all(failures.map(refresh)).then(function () {
|
return $q.all(failuresToRetry.map(refresh)).then(function () {
|
||||||
return $q.all(failures.map(remutate));
|
return $q.all(failuresToRetry.map(remutate));
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return $q.all(failures.map(persist));
|
return $q.all(failuresToRetry.map(persist));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Discard changes associated with a failed save
|
// Discard changes associated with a failed save
|
||||||
function discardAll(failures) {
|
function discardAll(failuresToDiscard) {
|
||||||
return $q.all(failures.map(discard));
|
return $q.all(failuresToDiscard.map(discard));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle user input (did they choose to overwrite?)
|
// Handle user input (did they choose to overwrite?)
|
||||||
|
@ -57,20 +57,20 @@ define(
|
|||||||
failureHandler = this.failureHandler;
|
failureHandler = this.failureHandler;
|
||||||
|
|
||||||
// Handle a group of persistence invocations
|
// Handle a group of persistence invocations
|
||||||
function persistGroup(ids, persistences, domainObjects, queue) {
|
function persistGroup(groupIds, persistenceCaps, domainObjs, pQueue) {
|
||||||
var failures = [];
|
var failures = [];
|
||||||
|
|
||||||
// Try to persist a specific domain object
|
// Try to persist a specific domain object
|
||||||
function tryPersist(id) {
|
function tryPersist(id) {
|
||||||
// Look up its persistence capability from the provided
|
// Look up its persistence capability from the provided
|
||||||
// id->persistence object.
|
// id->persistence object.
|
||||||
var persistence = persistences[id],
|
var persistence = persistenceCaps[id],
|
||||||
domainObject = domainObjects[id];
|
domainObject = domainObjs[id];
|
||||||
|
|
||||||
// Put a domain object back in the queue
|
// Put a domain object back in the queue
|
||||||
// (e.g. after Overwrite)
|
// (e.g. after Overwrite)
|
||||||
function requeue() {
|
function requeue() {
|
||||||
return queue.put(domainObject, persistence);
|
return pQueue.put(domainObject, persistence);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle success
|
// Handle success
|
||||||
@ -103,7 +103,7 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to persist everything, then handle any failures
|
// Try to persist everything, then handle any failures
|
||||||
return $q.all(ids.map(tryPersist)).then(handleFailure);
|
return $q.all(groupIds.map(tryPersist)).then(handleFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
return persistGroup(ids, persistences, domainObjects, queue);
|
return persistGroup(ids, persistences, domainObjects, queue);
|
||||||
|
@ -154,12 +154,12 @@ define(
|
|||||||
activeTemplateUrl = templateUrl;
|
activeTemplateUrl = templateUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeTemplate(ext) {
|
function changeTemplate(templateExt) {
|
||||||
ext = ext || {};
|
templateExt = templateExt || {};
|
||||||
if (ext.templateUrl) {
|
if (templateExt.templateUrl) {
|
||||||
changeTemplateUrl(self.getPath(ext));
|
changeTemplateUrl(self.getPath(templateExt));
|
||||||
} else if (ext.template) {
|
} else if (templateExt.template) {
|
||||||
showTemplate(ext.template);
|
showTemplate(templateExt.template);
|
||||||
} else {
|
} else {
|
||||||
removeElement();
|
removeElement();
|
||||||
}
|
}
|
||||||
|
@ -178,8 +178,8 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Array.isArray(model.composition)) {
|
if (Array.isArray(model.composition)) {
|
||||||
model.composition.forEach(function (id) {
|
model.composition.forEach(function (idToIndex) {
|
||||||
provider.scheduleForIndexing(id);
|
provider.scheduleForIndexing(idToIndex);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -93,11 +93,11 @@ define(
|
|||||||
|
|
||||||
// Look up an object in the queue that does not have a value
|
// Look up an object in the queue that does not have a value
|
||||||
// assigned to this key (or, add a new one)
|
// assigned to this key (or, add a new one)
|
||||||
function getFreeObject(key) {
|
function getFreeObject(k) {
|
||||||
var index = counts[key] || 0, object;
|
var index = counts[k] || 0, object;
|
||||||
|
|
||||||
// Track the largest free position for this key
|
// Track the largest free position for this key
|
||||||
counts[key] = index + 1;
|
counts[k] = index + 1;
|
||||||
|
|
||||||
// If it's before the end of the queue, add it there
|
// If it's before the end of the queue, add it there
|
||||||
if (index < queue.length) {
|
if (index < queue.length) {
|
||||||
|
@ -84,8 +84,8 @@ define(
|
|||||||
// Look up domain objects which have telemetry capabilities.
|
// Look up domain objects which have telemetry capabilities.
|
||||||
// This will either be the object in view, or object that
|
// This will either be the object in view, or object that
|
||||||
// this object delegates its telemetry capability to.
|
// this object delegates its telemetry capability to.
|
||||||
function promiseRelevantObjects(domainObject) {
|
function promiseRelevantObjects(domainObj) {
|
||||||
return delegator.promiseTelemetryObjects(domainObject);
|
return delegator.promiseTelemetryObjects(domainObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateValuesFromPool() {
|
function updateValuesFromPool() {
|
||||||
@ -114,16 +114,16 @@ define(
|
|||||||
|
|
||||||
|
|
||||||
// Look up metadata associated with an object's telemetry
|
// Look up metadata associated with an object's telemetry
|
||||||
function lookupMetadata(domainObject) {
|
function lookupMetadata(domainObj) {
|
||||||
var telemetryCapability =
|
var telemetryCapability =
|
||||||
domainObject.getCapability("telemetry");
|
domainObj.getCapability("telemetry");
|
||||||
return telemetryCapability &&
|
return telemetryCapability &&
|
||||||
telemetryCapability.getMetadata();
|
telemetryCapability.getMetadata();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the latest telemetry data for a specific
|
// Update the latest telemetry data for a specific
|
||||||
// domain object. This will notify listeners.
|
// domain object. This will notify listeners.
|
||||||
function update(domainObject, series) {
|
function update(domainObj, series) {
|
||||||
var count = series && series.getPointCount();
|
var count = series && series.getPointCount();
|
||||||
|
|
||||||
// Only schedule notification if there isn't already
|
// Only schedule notification if there isn't already
|
||||||
@ -136,21 +136,21 @@ define(
|
|||||||
|
|
||||||
// Update the latest-value table
|
// Update the latest-value table
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
pool.put(domainObject.getId(), {
|
pool.put(domainObj.getId(), {
|
||||||
domain: series.getDomainValue(count - 1),
|
domain: series.getDomainValue(count - 1),
|
||||||
range: series.getRangeValue(count - 1),
|
range: series.getRangeValue(count - 1),
|
||||||
datum: self.makeDatum(domainObject, series, count - 1)
|
datum: self.makeDatum(domainObj, series, count - 1)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare a subscription to a specific telemetry-providing
|
// Prepare a subscription to a specific telemetry-providing
|
||||||
// domain object.
|
// domain object.
|
||||||
function subscribe(domainObject) {
|
function subscribe(domainObj) {
|
||||||
var telemetryCapability =
|
var telemetryCapability =
|
||||||
domainObject.getCapability("telemetry");
|
domainObj.getCapability("telemetry");
|
||||||
return telemetryCapability.subscribe(function (telemetry) {
|
return telemetryCapability.subscribe(function (telemetry) {
|
||||||
update(domainObject, telemetry);
|
update(domainObj, telemetry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ define(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockProvider(key, index) {
|
function makeMockProvider(key, index) {
|
||||||
var provider = jasmine.createSpyObj(
|
var provider = jasmine.createSpyObj(
|
||||||
"provider" + index,
|
"provider" + index,
|
||||||
["requestTelemetry", "subscribe"]
|
["requestTelemetry", "subscribe"]
|
||||||
@ -57,7 +57,7 @@ define(
|
|||||||
mockQ.all.andReturn(mockPromise([]));
|
mockQ.all.andReturn(mockPromise([]));
|
||||||
|
|
||||||
mockUnsubscribes = [];
|
mockUnsubscribes = [];
|
||||||
mockProviders = ["a", "b", "c"].map(mockProvider);
|
mockProviders = ["a", "b", "c"].map(makeMockProvider);
|
||||||
|
|
||||||
aggregator = new TelemetryAggregator(mockQ, mockProviders);
|
aggregator = new TelemetryAggregator(mockQ, mockProviders);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user