[Timeline] Use indexes instead of UUIDs

This commit is contained in:
Victor Woeltjen 2016-05-25 12:07:35 -07:00
parent 87fe407739
commit 463f7ccf65
4 changed files with 23 additions and 11 deletions

View File

@ -30,8 +30,9 @@ define([], function () {
* @constructor
* @implements {platform/features/timeline.TimelineCSVColumn}
*/
function CompositionColumn(index) {
function CompositionColumn(index, idMap) {
this.index = index;
this.idMap = idMap;
}
CompositionColumn.prototype.name = function () {
@ -41,7 +42,9 @@ define([], function () {
CompositionColumn.prototype.value = function (domainObject) {
var model = domainObject.getModel(),
composition = model.composition || [];
return (composition[this.index]) || "";
return composition.length > this.index ?
this.idMap[composition[this.index]] : "";
};
return CompositionColumn;

View File

@ -27,15 +27,16 @@ define([], function () {
* @constructor
* @implements {platform/features/timeline.TimelineCSVColumn}
*/
function IdColumn() {
function IdColumn(idMap) {
this.idMap = idMap;
}
IdColumn.prototype.name = function () {
return "Identifier";
return "Index";
};
IdColumn.prototype.value = function (domainObject) {
return domainObject.getId();
return this.idMap[domainObject.getId()];
};
return IdColumn;

View File

@ -29,8 +29,9 @@ define([], function () {
* element associated with this column
* @implements {platform/features/timeline.TimelineCSVColumn}
*/
function ModeColumn(index) {
function ModeColumn(index, idMap) {
this.index = index;
this.idMap = idMap;
}
ModeColumn.prototype.name = function () {
@ -39,8 +40,9 @@ define([], function () {
ModeColumn.prototype.value = function (domainObject) {
var model = domainObject.getModel(),
composition = (model.relationships || {}).modes || [];
return (composition[this.index]) || "";
modes = (model.relationships || {}).modes || [];
return modes.length > this.index ?
this.idMap[modes[this.index]] : "";
};
return ModeColumn;

View File

@ -74,6 +74,7 @@ define([
columnNames = {},
columns = [],
foundTimespan = false,
idMap,
i;
function addMetadataProperty(property) {
@ -92,7 +93,12 @@ define([
});
}
columns.push(new IdColumn());
idMap = domainObjects.reduce(function (map, domainObject, index) {
map[domainObject.getId()] = index + 1;
return map;
}, {});
columns.push(new IdColumn(idMap));
domainObjects.forEach(function (domainObject) {
var model = domainObject.getModel(),
@ -128,11 +134,11 @@ define([
});
for (i = 0; i < maxComposition; i += 1) {
columns.push(new CompositionColumn(i));
columns.push(new CompositionColumn(i, idMap));
}
for (i = 0; i < maxRelationships; i += 1) {
columns.push(new ModeColumn(i));
columns.push(new ModeColumn(i, idMap));
}
this.domainObjects = domainObjects;