[Code Style] Rename shadowing variables

This commit is contained in:
Victor Woeltjen 2016-05-20 11:39:49 -07:00
parent e468080373
commit ad5691142e
56 changed files with 256 additions and 262 deletions

View File

@ -152,7 +152,7 @@ define(
});
it("validates selection types using policy", function () {
var mockDomainObject = jasmine.createSpyObj(
var mockDomainObj = jasmine.createSpyObj(
'domainObject',
['getCapability']
),
@ -166,8 +166,8 @@ define(
rows = structure.sections[sections.length - 1].rows,
locationRow = rows[rows.length - 1];
mockDomainObject.getCapability.andReturn(mockOtherType);
locationRow.validate(mockDomainObject);
mockDomainObj.getCapability.andReturn(mockOtherType);
locationRow.validate(mockDomainObj);
// Should check policy to see if the user-selected location
// can actually contain objects of this type

View File

@ -63,10 +63,10 @@ define(
});
}
function showDialog(type) {
function showDialog(objType) {
// Create a dialog object to generate the form structure, etc.
var dialog =
new PropertiesDialog(type, domainObject.getModel());
new PropertiesDialog(objType, domainObject.getModel());
// Show the dialog
return dialogService.getUserInput(

View File

@ -75,8 +75,8 @@ define(
* Invoke persistence on a domain object. This will be called upon
* the removed object's parent (as its composition will have changed.)
*/
function doPersist(domainObject) {
var persistence = domainObject.getCapability('persistence');
function doPersist(domainObj) {
var persistence = domainObj.getCapability('persistence');
return persistence && persistence.persist();
}

View File

@ -223,7 +223,7 @@ define(
// Update value for this property in all elements of the
// selection which have this property.
function updateProperties(property, value) {
function updateProperties(property, val) {
var changed = false;
// Update property in a selected element
@ -233,12 +233,12 @@ define(
// Check if this is a setter, or just assignable
if (typeof selected[property] === 'function') {
changed =
changed || (selected[property]() !== value);
selected[property](value);
changed || (selected[property]() !== val);
selected[property](val);
} else {
changed =
changed || (selected[property] !== value);
selected[property] = value;
changed || (selected[property] !== val);
selected[property] = val;
}
}
}

View File

@ -133,11 +133,11 @@ define(
self = this;
// Initialize toolbar (expose object to parent scope)
function initialize(definition) {
function initialize(def) {
// If we have been asked to expose toolbar state...
if (self.attrs.toolbar) {
// Initialize toolbar object
self.toolbar = new EditToolbar(definition, self.commit);
self.toolbar = new EditToolbar(def, self.commit);
// Ensure toolbar state is exposed
self.exposeToolbar();
}

View File

@ -37,11 +37,11 @@ define(
model = { x: "initial value" };
properties = ["x", "y", "z"].map(function (k) {
return {
getValue: function (model) {
return model[k];
getValue: function (m) {
return m[k];
},
setValue: function (model, v) {
model[k] = v;
setValue: function (m, v) {
m[k] = v;
},
getDefinition: function () {
return { control: 'textfield '};

View File

@ -50,8 +50,8 @@ define(
var context = domainObject &&
domainObject.getCapability('context'),
objectPath = context ? context.getPath() : [],
ids = objectPath.map(function (domainObject) {
return domainObject.getId();
ids = objectPath.map(function (domainObj) {
return domainObj.getId();
});
// Parses the path together. Starts with the

View File

@ -105,8 +105,8 @@ define([
function getIdPath(domainObject) {
var context = domainObject && domainObject.getCapability('context');
function getId(domainObject) {
return domainObject.getId();
function getId(domainObj) {
return domainObj.getId();
}
return context ? context.getPath().map(getId) : [];

View File

@ -62,8 +62,8 @@ define([
var self = this,
domainObject = this.activeObject;
function addNode(domainObject, index) {
self.nodeViews[index].model(domainObject);
function addNode(domainObj, index) {
self.nodeViews[index].model(domainObj);
}
function addNodes(domainObjects) {

View File

@ -36,7 +36,7 @@ define([
treeView;
function makeMockDomainObject(id, model, capabilities) {
var mockDomainObject = jasmine.createSpyObj(
var mockDomainObj = jasmine.createSpyObj(
'domainObject-' + id,
[
'getId',
@ -46,18 +46,18 @@ define([
'useCapability'
]
);
mockDomainObject.getId.andReturn(id);
mockDomainObject.getModel.andReturn(model);
mockDomainObject.hasCapability.andCallFake(function (c) {
mockDomainObj.getId.andReturn(id);
mockDomainObj.getModel.andReturn(model);
mockDomainObj.hasCapability.andCallFake(function (c) {
return !!(capabilities[c]);
});
mockDomainObject.getCapability.andCallFake(function (c) {
mockDomainObj.getCapability.andCallFake(function (c) {
return capabilities[c];
});
mockDomainObject.useCapability.andCallFake(function (c) {
mockDomainObj.useCapability.andCallFake(function (c) {
return capabilities[c] && capabilities[c].invoke();
});
return mockDomainObject;
return mockDomainObj;
}
beforeEach(function () {
@ -99,24 +99,16 @@ define([
var mockComposition;
function makeGenericCapabilities() {
var mockContext =
jasmine.createSpyObj('context', ['getPath']),
mockType =
jasmine.createSpyObj('type', ['getGlyph']),
mockLocation =
jasmine.createSpyObj('location', ['isLink']),
mockMutation =
jasmine.createSpyObj('mutation', ['listen']),
mockStatus =
var mockStatus =
jasmine.createSpyObj('status', ['listen', 'list']);
mockStatus.list.andReturn([]);
return {
context: mockContext,
type: mockType,
mutation: mockMutation,
location: mockLocation,
context: jasmine.createSpyObj('context', ['getPath']),
type: jasmine.createSpyObj('type', ['getGlyph']),
location: jasmine.createSpyObj('location', ['isLink']),
mutation: jasmine.createSpyObj('mutation', ['listen']),
status: mockStatus
};
}
@ -133,11 +125,11 @@ define([
beforeEach(function () {
mockComposition = ['a', 'b', 'c'].map(function (id) {
var testCapabilities = makeGenericCapabilities(),
var testCaps = makeGenericCapabilities(),
mockChild =
makeMockDomainObject(id, {}, testCapabilities);
makeMockDomainObject(id, {}, testCaps);
testCapabilities.context.getPath
testCaps.context.getPath
.andReturn([mockDomainObject, mockChild]);
return mockChild;
@ -207,11 +199,11 @@ define([
describe("when a context-less object is selected", function () {
beforeEach(function () {
var testCapabilities = makeGenericCapabilities(),
mockDomainObject =
makeMockDomainObject('xyz', {}, testCapabilities);
delete testCapabilities.context;
treeView.value(mockDomainObject);
var testCaps = makeGenericCapabilities(),
mockDomainObj =
makeMockDomainObject('xyz', {}, testCaps);
delete testCaps.context;
treeView.value(mockDomainObj);
});
it("clears all selection state", function () {

View File

@ -79,8 +79,8 @@ define(
// On any touch on the body, default body touches/events
// are prevented, the bubble is dismissed, and the touchstart
// body event is unbound, reallowing gestures
body.on('touchstart', function (event) {
event.preventDefault();
body.on('touchstart', function (evt) {
evt.preventDefault();
hideBubble();
body.unbind('touchstart');
});

View File

@ -69,7 +69,7 @@ define(
});
it("detects display orientation", function () {
var agentService = new AgentService(testWindow);
agentService = new AgentService(testWindow);
testWindow.innerWidth = 1024;
testWindow.innerHeight = 400;
expect(agentService.isPortrait()).toBeFalsy();

View File

@ -81,8 +81,8 @@ define(
// additionally fills in the action's getMetadata method
// with the extension definition (if no getMetadata
// method was supplied.)
function instantiateAction(Action, context) {
var action = new Action(context),
function instantiateAction(Action, ctxt) {
var action = new Action(ctxt),
metadata;
// Provide a getMetadata method that echos
@ -90,7 +90,7 @@ define(
// unless the action has defined its own.
if (!action.getMetadata) {
metadata = Object.create(Action.definition || {});
metadata.context = context;
metadata.context = ctxt;
action.getMetadata = function () {
return metadata;
};
@ -103,14 +103,14 @@ define(
// applicable in a given context, according to the static
// appliesTo method of given actions (if defined), and
// instantiate those applicable actions.
function createIfApplicable(actions, context) {
function createIfApplicable(actions, ctxt) {
function isApplicable(Action) {
return Action.appliesTo ? Action.appliesTo(context) : true;
return Action.appliesTo ? Action.appliesTo(ctxt) : true;
}
function instantiate(Action) {
try {
return instantiateAction(Action, context);
return instantiateAction(Action, ctxt);
} catch (e) {
$log.error([
"Could not instantiate action",

View File

@ -82,7 +82,7 @@ define(
return mutationResult && self.invoke().then(findObject);
}
function addIdToModel(model) {
function addIdToModel(objModel) {
// Pick a specific index if needed.
index = isNaN(index) ? composition.length : index;
// Also, don't put past the end of the array
@ -90,11 +90,11 @@ define(
// Remove the existing instance of the id
if (oldIndex !== -1) {
model.composition.splice(oldIndex, 1);
objModel.composition.splice(oldIndex, 1);
}
// ...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

View File

@ -62,9 +62,9 @@ define(
}
// Package capabilities as key-value pairs
function packageCapabilities(capabilities) {
function packageCapabilities(caps) {
var result = {};
capabilities.forEach(function (capability) {
caps.forEach(function (capability) {
if (capability.key) {
result[capability.key] =
result[capability.key] || capability;

View File

@ -124,9 +124,9 @@ define(
clone = JSON.parse(JSON.stringify(model)),
useTimestamp = arguments.length > 1;
function notifyListeners(model) {
function notifyListeners(newModel) {
generalTopic.notify(domainObject);
specificTopic.notify(model);
specificTopic.notify(newModel);
}
// Function to handle copying values to the actual

View File

@ -124,8 +124,8 @@ define(
this.persistenceService.createObject;
// Update persistence timestamp...
domainObject.useCapability("mutation", function (model) {
model.persisted = modified;
domainObject.useCapability("mutation", function (m) {
m.persisted = modified;
}, modified);
// ...and persist

View File

@ -82,9 +82,9 @@ define(
}
// Package the result as id->model
function packageResult(parsedIds, models) {
function packageResult(parsedIdsToPackage, models) {
var result = {};
parsedIds.forEach(function (parsedId, index) {
parsedIdsToPackage.forEach(function (parsedId, index) {
var id = parsedId.id;
if (models[index]) {
result[id] = models[index];
@ -93,11 +93,11 @@ define(
return result;
}
function loadModels(parsedIds) {
return $q.all(parsedIds.map(loadModel))
function loadModels(parsedIdsToLoad) {
return $q.all(parsedIdsToLoad.map(loadModel))
.then(function (models) {
return packageResult(
parsedIds,
parsedIdsToLoad,
models.map(addPersistedTimestamp)
);
});

View File

@ -58,14 +58,14 @@ define(
* corresponding keys in the recursive step.
*
*
* @param a the first object to be merged
* @param b the second object to be merged
* @param modelA the first object to be merged
* @param modelB the second object to be merged
* @param merger the merger, as described above
* @returns {*} the result of merging `a` and `b`
* @returns {*} the result of merging `modelA` and `modelB`
* @constructor
* @memberof platform/core
*/
function mergeModels(a, b, merger) {
function mergeModels(modelA, modelB, merger) {
var mergeFunction;
function mergeArrays(a, b) {
@ -93,11 +93,11 @@ define(
}
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
(Array.isArray(a) && Array.isArray(b)) ? mergeArrays :
(a instanceof Object && b instanceof Object) ? mergeObjects :
(Array.isArray(modelA) && Array.isArray(modelB)) ? mergeArrays :
(modelA instanceof Object && modelB instanceof Object) ? mergeObjects :
mergeOther;
return mergeFunction(a, b);
return mergeFunction(modelA, modelB);
}
return mergeModels;

View File

@ -159,8 +159,8 @@ define(
}
function lookupTypeDef(typeKey) {
function buildTypeDef(typeKey) {
var typeDefs = typeDefinitions[typeKey] || [],
function buildTypeDef(typeKeyToBuild) {
var typeDefs = typeDefinitions[typeKeyToBuild] || [],
inherits = typeDefs.map(function (typeDef) {
return asArray(typeDef.inherits || []);
}).reduce(function (a, b) {
@ -175,7 +175,7 @@ define(
// Always provide a default name
def.model = def.model || {};
def.model.name = def.model.name ||
("Unnamed " + (def.name || "Object"));
("Unnamed " + (def.name || "Object"));
return def;
}

View File

@ -105,15 +105,15 @@ define(
// Check if an object has all capabilities designated as `needs`
// for a view. Exposing a capability via delegation is taken to
// satisfy this filter if `allowDelegation` is true.
function capabilitiesMatch(domainObject, capabilities, allowDelegation) {
var delegation = domainObject.getCapability("delegation");
function capabilitiesMatch(domainObj, capabilities, allowDelegation) {
var delegation = domainObj.getCapability("delegation");
allowDelegation = allowDelegation && (delegation !== undefined);
// Check if an object has (or delegates, if allowed) a
// capability.
function hasCapability(c) {
return domainObject.hasCapability(c) ||
return domainObj.hasCapability(c) ||
(allowDelegation && delegation.doesDelegateCapability(c));
}
@ -128,13 +128,13 @@ define(
// Check if a view and domain object type can be paired;
// both can restrict the others they accept.
function viewMatchesType(view, type) {
var views = type && (type.getDefinition() || {}).views,
function viewMatchesType(view, objType) {
var views = objType && (objType.getDefinition() || {}).views,
matches = true;
// View is restricted to a certain 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

View File

@ -73,16 +73,16 @@ define(
});
it("uses the instantiate service to create domain objects", function () {
var mockDomainObject = jasmine.createSpyObj('domainObject', [
var mockDomainObj = jasmine.createSpyObj('domainObject', [
'getId',
'getModel',
'getCapability',
'useCapability',
'hasCapability'
]), testModel = { someKey: "some value" };
mockInstantiate.andReturn(mockDomainObject);
mockInstantiate.andReturn(mockDomainObj);
expect(instantiation.instantiate(testModel))
.toBe(mockDomainObject);
.toBe(mockDomainObj);
expect(mockInstantiate)
.toHaveBeenCalledWith({
someKey: "some value",

View File

@ -99,7 +99,7 @@ define(
});
it("ensures a single object instance, even for multiple concurrent calls", function () {
var promiseA, promiseB, mockCallback = jasmine.createSpy();
var promiseA, promiseB;
promiseA = fakePromise();
promiseB = fakePromise();
@ -126,7 +126,7 @@ define(
});
it("is robust against updating with undefined values", function () {
var promiseA, promiseB, mockCallback = jasmine.createSpy();
var promiseA, promiseB;
promiseA = fakePromise();
promiseB = fakePromise();

View File

@ -109,7 +109,7 @@ define(
it("restricts typed views to matching types", function () {
var testType = "testType",
testView = { key: "x", type: testType },
provider = new ViewProvider([testView], mockLog);
viewProvider = new ViewProvider([testView], mockLog);
// Include a "type" capability
capabilities.type = jasmine.createSpyObj(
@ -120,21 +120,21 @@ define(
// Should be included when types match
capabilities.type.instanceOf.andReturn(true);
expect(provider.getViews(mockDomainObject))
expect(viewProvider.getViews(mockDomainObject))
.toEqual([testView]);
expect(capabilities.type.instanceOf)
.toHaveBeenCalledWith(testType);
// ...but not when they don't
capabilities.type.instanceOf.andReturn(false);
expect(provider.getViews(mockDomainObject))
expect(viewProvider.getViews(mockDomainObject))
.toEqual([]);
});
it("enforces view restrictions from types", function () {
var testView = { key: "x" },
provider = new ViewProvider([testView], mockLog);
viewProvider = new ViewProvider([testView], mockLog);
// Include a "type" capability
capabilities.type = jasmine.createSpyObj(
@ -146,13 +146,13 @@ define(
// Should be included when view keys match
capabilities.type.getDefinition
.andReturn({ views: [testView.key]});
expect(provider.getViews(mockDomainObject))
expect(viewProvider.getViews(mockDomainObject))
.toEqual([testView]);
// ...but not when they don't
capabilities.type.getDefinition
.andReturn({ views: ["somethingElse"]});
expect(provider.getViews(mockDomainObject))
expect(viewProvider.getViews(mockDomainObject))
.toEqual([]);
});

View File

@ -126,11 +126,11 @@ define(
label = this.verb + " To";
validateLocation = function (newParent) {
validateLocation = function (newParentObj) {
var newContext = self.cloneContext();
newContext.selectedObject = object;
newContext.domainObject = newParent;
return composeService.validate(object, newParent) &&
newContext.domainObject = newParentObj;
return composeService.validate(object, newParentObj) &&
self.policyService.allow("action", self, newContext);
};
@ -139,8 +139,8 @@ define(
label,
validateLocation,
currentParent
).then(function (newParent) {
return composeService.perform(object, newParent);
).then(function (newParentObj) {
return composeService.perform(object, newParentObj);
});
};

View File

@ -83,11 +83,11 @@ define(
// Combines caller-provided filter (if any) with the
// baseline behavior of respecting creation policy.
function filterWithPolicy(domainObject) {
return (!filter || filter(domainObject)) &&
function filterWithPolicy(domainObj) {
return (!filter || filter(domainObj)) &&
policyService.allow(
"creation",
domainObject.getCapability("type")
domainObj.getCapability("type")
);
}

View File

@ -77,8 +77,8 @@ define(
return dialogService
.getUserInput(formStructure, formState)
.then(function (formState) {
return formState.location;
.then(function (userFormState) {
return userFormState.location;
});
}
};

View File

@ -458,17 +458,17 @@ define(
});
it("throws an error", function () {
var copyService =
var service =
new CopyService(mockQ, policyService);
function perform() {
copyService.perform(object, newParent);
service.perform(object, newParent);
}
spyOn(copyService, "validate");
copyService.validate.andReturn(true);
spyOn(service, "validate");
service.validate.andReturn(true);
expect(perform).not.toThrow();
copyService.validate.andReturn(false);
service.validate.andReturn(false);
expect(perform).toThrow();
});
});

View File

@ -120,7 +120,7 @@ define(
it("on changes in form values, updates the object model", function () {
var scopeConfiguration = mockScope.configuration,
model = mockDomainObject.getModel();
objModel = mockDomainObject.getModel();
scopeConfiguration.plot.yAxis.autoScale = true;
scopeConfiguration.plot.yAxis.key = 'eu';
@ -130,10 +130,10 @@ define(
mockScope.$watchCollection.calls[0].args[1]();
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
mockDomainObject.useCapability.mostRecentCall.args[1](model);
expect(model.configuration.plot.yAxis.autoScale).toBe(true);
expect(model.configuration.plot.yAxis.key).toBe('eu');
expect(model.configuration.plot.xAxis.key).toBe('lst');
mockDomainObject.useCapability.mostRecentCall.args[1](objModel);
expect(objModel.configuration.plot.yAxis.autoScale).toBe(true);
expect(objModel.configuration.plot.yAxis.key).toBe('eu');
expect(objModel.configuration.plot.xAxis.key).toBe('lst');
});

View File

@ -32,15 +32,15 @@ define(
/**
* Set default values for optional parameters on a given scope
*/
function setDefaults($scope) {
if (typeof $scope.enableFilter === 'undefined') {
$scope.enableFilter = true;
$scope.filters = {};
function setDefaults(scope) {
if (typeof scope.enableFilter === 'undefined') {
scope.enableFilter = true;
scope.filters = {};
}
if (typeof $scope.enableSort === 'undefined') {
$scope.enableSort = true;
$scope.sortColumn = undefined;
$scope.sortDirection = undefined;
if (typeof scope.enableSort === 'undefined') {
scope.enableSort = true;
scope.sortColumn = undefined;
scope.sortDirection = undefined;
}
}
@ -485,13 +485,13 @@ define(
/**
* Returns true if row matches all filters.
*/
function matchRow(filters, row) {
return Object.keys(filters).every(function (key) {
function matchRow(filterMap, row) {
return Object.keys(filterMap).every(function (key) {
if (!row[key]) {
return false;
}
var testVal = String(row[key].text).toLowerCase();
return testVal.indexOf(filters[key]) !== -1;
return testVal.indexOf(filterMap[key]) !== -1;
});
}

View File

@ -52,25 +52,25 @@ define(
// Set the start time associated with this object
function setStart(value) {
var end = getEnd();
mutation.mutate(function (model) {
model.start.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.start.timestamp = Math.max(value, 0);
// Update duration to keep end time
model.duration.timestamp = Math.max(end - value, 0);
m.duration.timestamp = Math.max(end - value, 0);
}, model.modified);
}
// Set the duration associated with this object
function setDuration(value) {
mutation.mutate(function (model) {
model.duration.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.duration.timestamp = Math.max(value, 0);
}, model.modified);
}
// Set the end time associated with this object
function setEnd(value) {
var start = getStart();
mutation.mutate(function (model) {
model.duration.timestamp = Math.max(value - start, 0);
mutation.mutate(function (m) {
m.duration.timestamp = Math.max(value - start, 0);
}, model.modified);
}

View File

@ -53,21 +53,21 @@ define(
// Initialize the data values
function initializeValues() {
var values = [],
var vals = [],
slope = 0,
i;
// Add a point (or points, if needed) reaching to the provided
// domain and/or range value
function addPoint(domain, range) {
var previous = values[values.length - 1],
var previous = vals[vals.length - 1],
delta = domain - previous.domain, // time delta
change = delta * slope * rate, // change
next = previous.range + change;
// Crop to minimum boundary...
if (next < minimum) {
values.push({
vals.push({
domain: intercept(
previous.domain,
previous.range,
@ -81,7 +81,7 @@ define(
// ...and maximum boundary
if (next > maximum) {
values.push({
vals.push({
domain: intercept(
previous.domain,
previous.range,
@ -95,19 +95,19 @@ define(
// Add the new data value
if (delta > 0) {
values.push({ domain: domain, range: next });
vals.push({ domain: domain, range: next });
}
slope = range;
}
values.push({ domain: 0, range: initial });
vals.push({ domain: 0, range: initial });
for (i = 0; i < graph.getPointCount(); i += 1) {
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
}
return values;
return vals;
}
function convertToPercent(point) {

View File

@ -72,13 +72,13 @@ define(
// If there are sequences of points with the same timestamp,
// 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
// that, allow only points that have different timestamps
// from their predecessor or successor.
return (index === 0) || (index === values.length - 1) ||
(value.domain !== values[index - 1].domain) ||
(value.domain !== values[index + 1].domain);
return (index === 0) || (index === vals.length - 1) ||
(value.domain !== vals[index - 1].domain) ||
(value.domain !== vals[index + 1].domain);
}
// Add a step up or down (Step 3c above)

View File

@ -57,8 +57,8 @@ define(
// Set the start time associated with this object
function setStart(value) {
mutation.mutate(function (model) {
model.start.timestamp = Math.max(value, 0);
mutation.mutate(function (m) {
m.start.timestamp = Math.max(value, 0);
}, model.modified);
}

View File

@ -120,13 +120,13 @@ define(
}
// Look up a specific object's resource utilization
function lookupUtilization(domainObject) {
return domainObject.useCapability('utilization');
function lookupUtilization(object) {
return object.useCapability('utilization');
}
// Look up a specific object's resource utilization keys
function lookupUtilizationResources(domainObject) {
var utilization = domainObject.getCapability('utilization');
function lookupUtilizationResources(object) {
var utilization = object.getCapability('utilization');
return utilization && utilization.resources();
}

View File

@ -47,19 +47,19 @@ define(
}
// Get the timespan associated with this domain object
function populateCapabilityMaps(domainObject) {
var id = domainObject.getId(),
timespanPromise = domainObject.useCapability('timespan');
function populateCapabilityMaps(object) {
var id = object.getId(),
timespanPromise = object.useCapability('timespan');
if (timespanPromise) {
timespanPromise.then(function (timespan) {
// Cache that timespan
timespans[id] = timespan;
// And its mutation capability
mutations[id] = domainObject.getCapability('mutation');
mutations[id] = object.getCapability('mutation');
// Also cache the persistence capability for later
persists[id] = domainObject.getCapability('persistence');
persists[id] = object.getCapability('persistence');
// And the composition, for bulk moves
compositions[id] = domainObject.getModel().composition || [];
compositions[id] = object.getModel().composition || [];
});
}
}
@ -199,8 +199,8 @@ define(
minStart;
// Update start & end, in that order
function updateStartEnd(id) {
var timespan = timespans[id], start, end;
function updateStartEnd(spanId) {
var timespan = timespans[spanId], start, end;
if (timespan) {
// Get start/end so we don't get fooled by our
// own adjustments
@ -210,7 +210,7 @@ define(
timespan.setStart(start + delta);
timespan.setEnd(end + delta);
// Mark as dirty for subsequent persistence
dirty[toId(id)] = true;
dirty[toId(spanId)] = true;
}
}
@ -228,12 +228,12 @@ define(
}
// 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
// found, since this will not survive a min
// test if any real timespans are present
return timespans[id] ?
timespans[id].getStart() :
return timespans[spanId] ?
timespans[spanId].getStart() :
Number.POSITIVE_INFINITY;
}).reduce(function (a, b) {
// Reduce with a minimum test

View File

@ -75,11 +75,14 @@ define(
// Look up resources for a domain object
function lookupResources(swimlane) {
var graphs = swimlane.domainObject.useCapability('graph');
var graphPromise =
swimlane.domainObject.useCapability('graph');
function getKeys(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

View File

@ -34,8 +34,8 @@ define(
var actionMap = {};
// Populate available Create actions for this domain object
function populateActionMap(domainObject) {
var actionCapability = domainObject.getCapability('action'),
function populateActionMap(object) {
var actionCapability = object.getCapability('action'),
actions = actionCapability ?
actionCapability.getActions('add') : [];
actions.forEach(function (action) {

View File

@ -45,9 +45,9 @@ define(
if (arguments.length > 0 && Array.isArray(value)) {
if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) {
// Update the relationships
mutator.mutate(function (model) {
model.relationships = model.relationships || {};
model.relationships[ACTIVITY_RELATIONSHIP] = value;
mutator.mutate(function (m) {
m.relationships = m.relationships || {};
m.relationships[ACTIVITY_RELATIONSHIP] = value;
}).then(persister.persist);
}
}
@ -61,8 +61,8 @@ define(
if (arguments.length > 0 && (typeof value === 'string') &&
value !== model.link) {
// Update the link
mutator.mutate(function (model) {
model.link = value;
mutator.mutate(function (m) {
m.link = value;
}).then(persister.persist);
}
return model.link;

View File

@ -51,7 +51,7 @@ define(
}
// 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)
function matches(pathId) {
return pathId === id;
@ -59,18 +59,18 @@ define(
// Path A contains Path B if it is longer, and all of
// 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
function contains(swimlane, id) {
function contains(swimlaneToCheck, id) {
// Check if a child swimlane has a matching domain object id
function matches(child) {
return child.domainObject.getId() === 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

View File

@ -61,8 +61,8 @@ define(
swimlane;
// For the recursive step
function populate(childSubgraph, index) {
populateSwimlanes(childSubgraph, swimlane, index);
function populate(childSubgraph, nextIndex) {
populateSwimlanes(childSubgraph, swimlane, nextIndex);
}
// Make sure we have a valid object instance...

View File

@ -41,13 +41,13 @@ define(
filter;
// Check object existence (for criterion-less filtering)
function exists(domainObject) {
return !!domainObject;
function exists(object) {
return !!object;
}
// Check for capability matching criterion
function hasCapability(domainObject) {
return domainObject && domainObject.hasCapability(criterion);
function hasCapability(object) {
return object && object.hasCapability(criterion);
}
// For the recursive step...
@ -61,8 +61,8 @@ define(
}
// Avoid infinite recursion
function notVisiting(domainObject) {
return !visiting[domainObject.getId()];
function notVisiting(object) {
return !visiting[object.getId()];
}
// Put the composition of this domain object into the result

View File

@ -55,8 +55,8 @@ define([
if (!!model.composition) {
mockDomainObject.useCapability.andCallFake(function (c) {
return c === 'composition' &&
Promise.resolve(model.composition.map(function (id) {
return mockDomainObjects[id];
Promise.resolve(model.composition.map(function (cid) {
return mockDomainObjects[cid];
}));
});
}
@ -68,8 +68,8 @@ define([
);
mockRelationships.getRelatedObjects.andCallFake(function (k) {
var ids = model.relationships[k] || [];
return Promise.resolve(ids.map(function (id) {
return mockDomainObjects[id];
return Promise.resolve(ids.map(function (objId) {
return mockDomainObjects[objId];
}));
});
mockDomainObject.getCapability.andCallFake(function (c) {

View File

@ -69,8 +69,8 @@ define(
resources: function () {
return Object.keys(costs).sort();
},
cost: function (c) {
return costs[c];
cost: function (k) {
return costs[k];
}
});
},

View File

@ -56,22 +56,22 @@ define(
}
function makeMockDomainObject(id, composition) {
var mockDomainObject = jasmine.createSpyObj(
var mockDomainObj = jasmine.createSpyObj(
'domainObject-' + id,
['getId', 'getModel', 'getCapability', 'useCapability']
);
mockDomainObject.getId.andReturn(id);
mockDomainObject.getModel.andReturn({ composition: composition });
mockDomainObject.useCapability.andReturn(asPromise(mockTimespans[id]));
mockDomainObject.getCapability.andCallFake(function (c) {
mockDomainObj.getId.andReturn(id);
mockDomainObj.getModel.andReturn({ composition: composition });
mockDomainObj.useCapability.andReturn(asPromise(mockTimespans[id]));
mockDomainObj.getCapability.andCallFake(function (c) {
return {
persistence: mockPersists[id],
mutation: mockMutations[id]
}[c];
});
return mockDomainObject;
return mockDomainObj;
}
beforeEach(function () {

View File

@ -42,16 +42,16 @@ define(
}
function makeMockDomainObject(id, composition) {
var mockDomainObject = jasmine.createSpyObj(
var mockDomainObj = jasmine.createSpyObj(
'domainObject-' + id,
['getId', 'getModel', 'getCapability', 'useCapability']
);
mockDomainObject.getId.andReturn(id);
mockDomainObject.getModel.andReturn({ composition: composition });
mockDomainObject.useCapability.andReturn(asPromise(false));
mockDomainObj.getId.andReturn(id);
mockDomainObj.getModel.andReturn({ composition: composition });
mockDomainObj.useCapability.andReturn(asPromise(false));
return mockDomainObject;
return mockDomainObj;
}
function subgraph(domainObject, objects) {

View File

@ -164,15 +164,15 @@ define(
// Examine a group of resolved dependencies to determine
// which extension categories still need to be satisfied.
function findEmptyExtensionDependencies(extensionGroup) {
function findEmptyExtensionDependencies(extGroup) {
var needed = {},
categories = Object.keys(extensionGroup),
categories = Object.keys(extGroup),
allExtensions = [];
// Build up an array of all extensions
categories.forEach(function (category) {
allExtensions =
allExtensions.concat(extensionGroup[category]);
allExtensions.concat(extGroup[category]);
});
// Track all extension dependencies exposed therefrom
@ -197,10 +197,9 @@ define(
// Register any extension categories that are depended-upon but
// have not been declared anywhere; such dependencies are then
// satisfied by an empty array, instead of not at all.
function registerEmptyDependencies(extensionGroup) {
findEmptyExtensionDependencies(
extensionGroup
).forEach(function (name) {
function registerEmptyDependencies(extGroup) {
findEmptyExtensionDependencies(extGroup)
.forEach(function (name) {
$log.info("Registering empty extension category " + name);
app.factory(name, [staticFunction([])]);
});

View File

@ -58,11 +58,11 @@ define(
var loader = this.loader,
$log = this.$log;
function loadImplementation(extension) {
var implPromise = extension.hasImplementationValue() ?
Promise.resolve(extension.getImplementationValue()) :
loader.load(extension.getImplementationPath()),
definition = extension.getDefinition();
function loadImplementation(ext) {
var implPromise = ext.hasImplementationValue() ?
Promise.resolve(ext.getImplementationValue()) :
loader.load(ext.getImplementationPath()),
definition = ext.getDefinition();
// Wrap a constructor function (to avoid modifying the original)
function constructorFor(impl) {
@ -94,7 +94,7 @@ define(
result.definition = definition;
// Log that this load was successful
$log.info("Resolved " + extension.getLogName());
$log.info("Resolved " + ext.getLogName());
return result;
}
@ -105,7 +105,7 @@ define(
// Build up a log message from parts
var message = [
"Could not load implementation for extension ",
extension.getLogName(),
ext.getLogName(),
" due to ",
err.message
].join("");
@ -113,16 +113,16 @@ define(
// Log that the extension was not loaded
$log.warn(message);
return extension.getDefinition();
return ext.getDefinition();
}
if (!extension.hasImplementationValue()) {
if (!ext.hasImplementationValue()) {
// Log that loading has begun
$log.info([
"Loading implementation ",
extension.getImplementationPath(),
ext.getImplementationPath(),
" for extension ",
extension.getLogName()
ext.getLogName()
].join(""));
}

View File

@ -92,8 +92,8 @@ define(
if ((response || {}).status === CONFLICT) {
error.key = "revision";
// Load the updated model, then reject the promise
return this.get(key).then(function (response) {
error.model = response[SRC];
return this.get(key).then(function (res) {
error.model = res[SRC];
return $q.reject(error);
});
}

View File

@ -68,7 +68,7 @@ define(
}
// Retry persistence (overwrite) for this set of failed attempts
function retry(failures) {
function retry(failuresToRetry) {
var models = {};
// Cache a copy of the model
@ -92,17 +92,17 @@ define(
}
// Cache the object models we might want to save
failures.forEach(cacheModel);
failuresToRetry.forEach(cacheModel);
// Strategy here:
// * Cache all of the models we might want to save (above)
// * Refresh all domain objects (so they are latest versions)
// * Re-insert the cached domain object models
// * Invoke persistence again
return $q.all(failures.map(refresh)).then(function () {
return $q.all(failures.map(remutate));
return $q.all(failuresToRetry.map(refresh)).then(function () {
return $q.all(failuresToRetry.map(remutate));
}).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
function discardAll(failures) {
return $q.all(failures.map(discard));
function discardAll(failuresToDiscard) {
return $q.all(failuresToDiscard.map(discard));
}
// Handle user input (did they choose to overwrite?)

View File

@ -57,20 +57,20 @@ define(
failureHandler = this.failureHandler;
// Handle a group of persistence invocations
function persistGroup(ids, persistences, domainObjects, queue) {
function persistGroup(groupIds, persistenceCaps, domainObjs, pQueue) {
var failures = [];
// Try to persist a specific domain object
function tryPersist(id) {
// Look up its persistence capability from the provided
// id->persistence object.
var persistence = persistences[id],
domainObject = domainObjects[id];
var persistence = persistenceCaps[id],
domainObject = domainObjs[id];
// Put a domain object back in the queue
// (e.g. after Overwrite)
function requeue() {
return queue.put(domainObject, persistence);
return pQueue.put(domainObject, persistence);
}
// Handle success
@ -103,7 +103,7 @@ define(
}
// 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);

View File

@ -154,12 +154,12 @@ define(
activeTemplateUrl = templateUrl;
}
function changeTemplate(ext) {
ext = ext || {};
if (ext.templateUrl) {
changeTemplateUrl(self.getPath(ext));
} else if (ext.template) {
showTemplate(ext.template);
function changeTemplate(templateExt) {
templateExt = templateExt || {};
if (templateExt.templateUrl) {
changeTemplateUrl(self.getPath(templateExt));
} else if (templateExt.template) {
showTemplate(templateExt.template);
} else {
removeElement();
}

View File

@ -178,8 +178,8 @@ define([
});
if (Array.isArray(model.composition)) {
model.composition.forEach(function (id) {
provider.scheduleForIndexing(id);
model.composition.forEach(function (idToIndex) {
provider.scheduleForIndexing(idToIndex);
});
}
};

View File

@ -93,11 +93,11 @@ define(
// Look up an object in the queue that does not have a value
// assigned to this key (or, add a new one)
function getFreeObject(key) {
var index = counts[key] || 0, object;
function getFreeObject(k) {
var index = counts[k] || 0, object;
// 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 (index < queue.length) {

View File

@ -84,8 +84,8 @@ define(
// Look up domain objects which have telemetry capabilities.
// This will either be the object in view, or object that
// this object delegates its telemetry capability to.
function promiseRelevantObjects(domainObject) {
return delegator.promiseTelemetryObjects(domainObject);
function promiseRelevantObjects(domainObj) {
return delegator.promiseTelemetryObjects(domainObj);
}
function updateValuesFromPool() {
@ -114,16 +114,16 @@ define(
// Look up metadata associated with an object's telemetry
function lookupMetadata(domainObject) {
function lookupMetadata(domainObj) {
var telemetryCapability =
domainObject.getCapability("telemetry");
domainObj.getCapability("telemetry");
return telemetryCapability &&
telemetryCapability.getMetadata();
}
// Update the latest telemetry data for a specific
// domain object. This will notify listeners.
function update(domainObject, series) {
function update(domainObj, series) {
var count = series && series.getPointCount();
// Only schedule notification if there isn't already
@ -136,21 +136,21 @@ define(
// Update the latest-value table
if (count > 0) {
pool.put(domainObject.getId(), {
pool.put(domainObj.getId(), {
domain: series.getDomainValue(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
// domain object.
function subscribe(domainObject) {
function subscribe(domainObj) {
var telemetryCapability =
domainObject.getCapability("telemetry");
domainObj.getCapability("telemetry");
return telemetryCapability.subscribe(function (telemetry) {
update(domainObject, telemetry);
update(domainObj, telemetry);
});
}

View File

@ -38,7 +38,7 @@ define(
};
}
function mockProvider(key, index) {
function makeMockProvider(key, index) {
var provider = jasmine.createSpyObj(
"provider" + index,
["requestTelemetry", "subscribe"]
@ -57,7 +57,7 @@ define(
mockQ.all.andReturn(mockPromise([]));
mockUnsubscribes = [];
mockProviders = ["a", "b", "c"].map(mockProvider);
mockProviders = ["a", "b", "c"].map(makeMockProvider);
aggregator = new TelemetryAggregator(mockQ, mockProviders);
});