From 4080da54707dd4dd9558a971f1636b93f347d18d Mon Sep 17 00:00:00 2001 From: rubenseggers <rubenseggers@gmail.com> Date: Tue, 28 Jul 2020 15:58:50 +0200 Subject: [PATCH] bugfix inheritance test --- tools/test.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/test.js b/tools/test.js index 3178619..4a5aa89 100644 --- a/tools/test.js +++ b/tools/test.js @@ -43,15 +43,16 @@ let predicateHierarchy = {}; } console.log('\nCheck for duplicate properties and edges (inherited and redefined)...'); - for (const entity of Object.keys(entityHierarchy)) { - if (entityHierarchy[entity]['children']) { - const fields = entityHierarchy[entity]['properties'].concat(Object.keys(entityHierarchy[entity]['relations'])); - for (const child of entityHierarchy[entity]['children']) { - const childFields = entityHierarchy[child]['properties'].concat(Object.keys(entityHierarchy[child]['relations'])); - for (const childField of childFields) { - if (fields.includes(childField)) { - console.log(`E: ${child} redefines ${childField} that is already in ${entity}.`); - } + for (const [entityName, entity] of Object.entries(entityHierarchy)) { + if (['Edge', 'UserState', 'ViewArguments'].includes(entityName)) continue; + let ancestry = helpers.getAncestry(entity['path'].split('/')); + delete ancestry[entityName]; + const propertiesAndEdges = entity['properties'].concat(Object.keys(entity['relations'])); + for (const ancestor of Object.keys(ancestry)) { + const ancestorFields = entityHierarchy[ancestor]['properties'].concat(Object.keys(entityHierarchy[ancestor]['relations'])); + for (const field of propertiesAndEdges) { + if (ancestorFields.includes(field)) { + console.log(`E: ${entityName} redefines ${field} that is already in ${ancestor}.`); } } } @@ -101,5 +102,5 @@ let predicateHierarchy = {}; } } - // TODO check if properties are shared over all children of an Item, so they could be inherited -})(); +// TODO check if properties are shared over all children of an Item, so they could be inherited +})(); \ No newline at end of file -- GitLab