Draft ontology menu
This commit is contained in:
@@ -2,6 +2,33 @@
|
||||
* @module Ontology
|
||||
*/
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @returns {Object}
|
||||
*/
|
||||
export async function traverseOntology(jsonPath) {
|
||||
const ontology = await loadOntology(jsonPath);
|
||||
const domains = [];
|
||||
|
||||
for (const k of Object.keys(ontology)) {
|
||||
if (k === 'domains') {
|
||||
for (const domainKey of Object.keys(ontology[k])) {
|
||||
domains.push({
|
||||
label: domainKey,
|
||||
child: ontology[k][domainKey][0].label,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ontology: ontology.ontology,
|
||||
domains
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an ontology from its JSON description
|
||||
* @param {String} jsonPath The path (URI) of the ontology JSON file
|
||||
|
||||
Reference in New Issue
Block a user