Idiotic instance panel...
This commit is contained in:
@@ -19,6 +19,31 @@ export class Ontology {
|
||||
return this.#data.instancesById[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Revise loop approach...
|
||||
* @param {String} label
|
||||
* @param {String} lang The language identifier, either 'en' or 'it'
|
||||
* @returns {Object} The instance object as per onto JSON... (document it!!)
|
||||
*/
|
||||
getInstanceByLabel(label, lang) {
|
||||
if (!['en','it'].includes(lang)) {
|
||||
throw new Error(`Invalid language string provided: '${lang}'`);
|
||||
}
|
||||
|
||||
let instance = {};
|
||||
|
||||
for (const key of Object.keys(this.#data.instancesById)) {
|
||||
const currentInstance = this.#data.instancesById[key];
|
||||
const currentLabel = currentInstance.label[lang];
|
||||
if (currentLabel === label) {
|
||||
instance = currentInstance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array<{en: string, it: string}>} The bloody array of label objects
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user