mirror of
https://github.com/nasa/openmct.git
synced 2024-12-30 01:48:51 +00:00
[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:
parent
5033e2cdbb
commit
d8b1e570d9
@ -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;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user