@zazuko/cube-hierarchy-query
Advanced tools
Comparing version 1.0.0 to 1.0.1
# @zazuko/cube-hierarchy-query | ||
## 1.0.1 | ||
### Patch Changes | ||
- a00f28a: Roots without children were not returned by the `getHierarchy` function | ||
## 1.0.0 | ||
@@ -4,0 +10,0 @@ |
@@ -28,6 +28,5 @@ import clownface from 'clownface'; | ||
export function getHierarchy(hierarchy) { | ||
const query = DESCRIBE `*` | ||
.WHERE ` | ||
${topDown(hierarchy)} | ||
`; | ||
const { described, where } = topDown(hierarchy); | ||
const query = DESCRIBE `${described}` | ||
.WHERE `${where}`; | ||
return { | ||
@@ -34,0 +33,0 @@ query, |
@@ -9,3 +9,6 @@ import { Term } from 'rdf-js'; | ||
export declare function bottomUp(hierarchyLevel: MultiPointer, { restrictTypes, firstLevel }: GetHierarchyPatterns): SparqlTemplateResult; | ||
export declare function topDown(hierarchy: GraphPointer): SparqlTemplateResult; | ||
export declare function topDown(hierarchy: GraphPointer): { | ||
described: SparqlTemplateResult; | ||
where: SparqlTemplateResult; | ||
}; | ||
export {}; |
@@ -54,6 +54,8 @@ import rdf from '@rdfjs/data-model'; | ||
export function topDown(hierarchy) { | ||
const roots = hierarchy.out(meta.hierarchyRoot).terms.map((term) => ({ root: term })); | ||
const rootTerms = hierarchy.out(meta.hierarchyRoot).terms; | ||
const roots = rootTerms.map((term) => ({ root: term })); | ||
let level = 0; | ||
let currentLevel = hierarchy.out(meta.nextInHierarchy); | ||
const levelPatterns = []; | ||
const levels = []; | ||
while (currentLevel) { | ||
@@ -67,2 +69,5 @@ const path = currentLevel.out(sh.path); | ||
let currentLevelPatterns = sparql `${subject} ${toSparql(path)} ${nextLevelSubject} .`; | ||
if (level !== 0) { | ||
levels.push(subject); | ||
} | ||
const targetClass = currentLevel.out(sh.targetClass).term; | ||
@@ -89,3 +94,4 @@ if (targetClass) { | ||
}, ''); | ||
return sparql ` | ||
const described = sparql `${rootTerms} ${levels}`; | ||
const where = sparql ` | ||
${VALUES(...roots)} | ||
@@ -95,2 +101,6 @@ | ||
`; | ||
return { | ||
described, | ||
where, | ||
}; | ||
} |
{ | ||
"name": "@zazuko/cube-hierarchy-query", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Facilitates querying RDF cube hierarchies", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22774
381