[Telemetry] include type telemetry metadata

Read telemetry metadata from type and include in telemetry.

Allows telemetry service to work with SWG.
This commit is contained in:
Pete Richards 2016-12-09 13:39:49 -08:00 committed by Henry
parent 215e9b26a8
commit 799c418124
2 changed files with 9 additions and 2 deletions

View File

@ -257,9 +257,12 @@ define([
*/
TelemetryAPI.prototype.getMetadata = function (domainObject) {
if (!this.metadataCache.has(domainObject)) {
if (!this.typeService) {
this.typeService = this.MCT.$injector.get('typeService');
}
this.metadataCache.set(
domainObject,
new TelemetryMetadataManager(domainObject)
new TelemetryMetadataManager(domainObject, this.typeService)
);
}
return this.metadataCache.get(domainObject);

View File

@ -84,12 +84,16 @@ define([
* Wraps old format metadata to new format metadata.
* Provides methods for interrogating telemetry metadata.
*/
function TelemetryMetadataManager(domainObject) {
function TelemetryMetadataManager(domainObject, typeService) {
this.metadata = domainObject.telemetry || {};
if (this.metadata.values) {
this.valueMetadatas = this.metadata.values;
} else {
var typeMetadata = typeService
.getType(domainObject.type).typeDef.telemetry;
_.extend(this.metadata, typeMetadata);
this.valueMetadatas = valueMetadatasFromOldFormat(this.metadata);
}