[Code Style] Rename shadowing variables
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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...
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user