[CSV Export] Begin implementing

Begin implementing initial step, wherein timelines composition
is traversed to build up a list of objects to export.
This commit is contained in:
Victor Woeltjen 2016-02-08 13:36:25 -08:00
parent 5033e2cdbb
commit d8b1e570d9

View File

@ -36,7 +36,63 @@ define([], function () {
this.domainObject = domainObject;
}
/**
* @private
*/
ExportTimelineAsCSVTask.prototype.buildObjectList = function () {
var idSet = {},
objects = [];
function addObject(domainObject) {
var id = domainObject.getId(),
subtasks = [];
function addCompositionObjects() {
return domainObject.useCapability('composition')
.then(function (childObjects) {
return Promise.all(childObjects.map(addObject));
});
}
function addRelationships() {
var relationship = domainObject.getCapability('relationship');
relationship.getRelatedObjects('modes')
.then(function (modeObjects) {
return Promise.all(modeObjects.map(addObject));
});
}
if (!idSet[id]) {
idSet[id] = true;
objects.push(domainObject);
if (domainObject.hasCapability('composition')) {
subtasks.push(addCompositionObjects());
}
if (domainObject.hasCapability('relationship')) {
subtasks.push(addRelationships());
}
}
return Promise.all(subtasks);
}
return addObject(this.domainObject).then(function () {
return objects;
});
};
ExportTimelineAsCSVTask.prototype.run = function (progressCallback) {
var name = this.domainObject.getModel().name;
progressCallback({
title: "Preparing to export " + name
});
this.buildObjectList().then(function (objects) {
});
};
return ExportTimelineAsCSVTask;
});