Bug Fix: OHIF Study Metadata API implementation not correctly reading Study and Series level data + Adding ES5.1 properties to Study Metadata API abstract classes to prevent protected attribute override

This commit is contained in:
Emanuel F. Oliveira authored and Eloízio Salgado committed 2017-03-02 10:16:09 -03:00
1 parent 5d5df29e09
commit 2b22aecc15
8 files changed
+140 -38

No files matched your search

@@ -7,16 +7,47 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
/**
* @param {Object} Instance object.
*/
constructor(data) {
constructor(data, series, study) {
super(data);
this._cache = Object.create(null); // Object with null prototype for fast and safe lookups...
this.init();
this.init(series, study);
}
init() {
const data = this.getData();
// set protected property...
this._sopInstanceUID = data.sopInstanceUid;
init(series, study) {
const instance = this.getData();
// Initialize Private Properties
Object.defineProperties(this, {
_sopInstanceUID: {
configurable: false,
enumerable: false,
writable: false,
value: instance.sopInstanceUid
},
_study: {
configurable: false,
enumerable: false,
writable: false,
value: study
},
_series: {
configurable: false,
enumerable: false,
writable: false,
value: series
},
_instance: {
configurable: false,
enumerable: false,
writable: false,
value: instance
},
_cache: {
configurable: false,
enumerable: false,
writable: false,
value: Object.create(null)
}
});
}
// Override
@@ -28,8 +59,16 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
}
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
const data = this.getData();
const rawValue = data[propertyName];
// Search property value in the whole study metadata chain...
let rawValue;
if (propertyName in this._instance) {
rawValue = this._instance[propertyName];
} else if (propertyName in this._series) {
rawValue = this._series[propertyName];
} else if (propertyName in this._study) {
rawValue = this._study[propertyName];
}
if (rawValue !== void 0) {
// if rawValue value is not undefined, cache result...
@@ -44,9 +83,7 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
tagExists(tagOrProperty) {
const propertyName = OHIFInstanceMetadata.getPropertyName(tagOrProperty);
const data = this.getData();
return (propertyName in data);
return (propertyName in this._instance || propertyName in this._series || propertyName in this._study);
}
// Override
@@ -72,7 +109,7 @@ export class OHIFInstanceMetadata extends InstanceMetadata {
if (tagInfo.propertyName !== null) {
// This function tries to translate standard DICOM property names into local naming convention.
propertyName = tagInfo.propertyName.replace(/^SOP/, 'sop').replace(/UID$/, 'Uid');
propertyName = tagInfo.propertyName.replace(/^SOP/, 'sop').replace(/UID$/, 'Uid').replace(/ID$/, 'Id');
propertyName = propertyName.charAt(0).toLowerCase() + propertyName.substr(1);
}