Classes and instances in ontology menu
This commit is contained in:
@@ -2,15 +2,47 @@
|
||||
* @module Ontology
|
||||
*/
|
||||
|
||||
export class Ontology {
|
||||
#data;
|
||||
|
||||
/**
|
||||
* @param {Object} data The parsed ontology object (from JSON)
|
||||
*/
|
||||
set data(data) {
|
||||
this.#data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} id
|
||||
*/
|
||||
getInstanceById(id) {
|
||||
return this.#data.instancesById[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array<{en: string, it: string}>} The bloody array of label objects
|
||||
*/
|
||||
getInstanceLabels() {
|
||||
const data = this.#data;
|
||||
const instances = [];
|
||||
|
||||
for (const key of Object.keys(data.instancesById)) {
|
||||
instances.push(data.instancesById[key]?.label);
|
||||
}
|
||||
|
||||
return instances;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Temporarily returns domains and ontology labels only
|
||||
* Traverse an ontology from its JSON description
|
||||
* @param {String} jsonPath The path (URI) of the ontology JSON file
|
||||
* @param {Object} ontologyObject The parsed ontology JSON
|
||||
* @returns {Object}
|
||||
*/
|
||||
export async function traverseOntology(jsonPath) {
|
||||
const ontology = await loadOntology(jsonPath);
|
||||
const modules = ontology.modules;
|
||||
export async function traverseOntology(ontologyObject) {
|
||||
//const ontology = await loadOntology(jsonPath);
|
||||
const modules = ontologyObject.domains;
|
||||
|
||||
const domains = [];
|
||||
|
||||
@@ -20,7 +52,7 @@ export async function traverseOntology(jsonPath) {
|
||||
traverseClasses(classTree, tree);
|
||||
}
|
||||
domains.push({
|
||||
id: module.id,
|
||||
id: module.label.it ?? module.label.en,
|
||||
tree
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user