Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion frontend/src/pages/ontologies/entities/EntityTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export default function EntityTree({
showCountsEnabled &&
childNode.numDescendants > 0 && (
<span style={{ color: "gray" }}>
{" (" + childNode.numDescendants.toLocaleString() + ")"}
{" (" + (getNumDescendants(childNode.numHierarchicalDescendants, childNode.numDescendants)).toLocaleString() + ")"}
</span>
)}
{isExpanded &&
Expand Down Expand Up @@ -445,6 +445,16 @@ export default function EntityTree({
);
}

function getNumDescendants(hierarchicalDescendents: number, descendents: number): number {
if (descendents === hierarchicalDescendents) {
return descendents;
} else if (descendents > hierarchicalDescendents) {
return descendents;
} else {
return hierarchicalDescendents;
}
}

function TreeLink({
ontology,
entity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export default function createTreeFromEntities(
title: node.getName(),
expandable: node.hasChildren(),
entity: node,
numDescendants:
node.getNumHierarchicalDescendants() || node.getNumDescendants(),
numDescendants: node.getNumDescendants(),
numHierarchicalDescendants: node.getNumHierarchicalDescendants(),
parentRelationToChild,
childRelationToParent
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ export default function IndividualPropertyAssertionsSection({
);

let objectProperties = propertyIris.filter(
(k) =>
linkedEntities.get(k) &&
linkedEntities.get(k)!.type.indexOf("objectProperty") !== -1
(k) => {
const linkedEntity = linkedEntities.get(k);
return linkedEntity && Array.isArray(linkedEntity.type) && linkedEntity.type.indexOf("objectProperty") !== -1;
}
);

let dataProperties = propertyIris.filter(
(k) =>
linkedEntities.get(k) &&
linkedEntities.get(k)!.type.indexOf("dataProperty") !== -1
(k) => {
const linkedEntity = linkedEntities.get(k);
return linkedEntity && Array.isArray(linkedEntity.type) && linkedEntity.type.indexOf("dataProperty") !== -1;
}
);

let propertyAssertions: JSX.Element[] = [];
Expand Down
47 changes: 34 additions & 13 deletions frontend/src/pages/ontologies/ontologiesSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface TreeNode {
expandable: boolean;
entity: Entity;
numDescendants: number;
numHierarchicalDescendants: number;
parentRelationToChild: string | null; // if applicable, relation from the parent node to this node (e.g. has_part)
childRelationToParent: string | null; // if applicable, relation from this node to the parent node (e.g. part_of)
}
Expand Down Expand Up @@ -420,17 +421,37 @@ export const getNodeChildren = createAsyncThunk(
const doubleEncodedUri = encodeURIComponent(encodeURIComponent(entityIri));
var childrenPage: any;
if (entityTypePlural === "classes") {
childrenPage = await getPaginated<any>(
`api/v2/ontologies/${ontologyId}/classes/${doubleEncodedUri}/hierarchicalChildren?${new URLSearchParams(
{
size: "1000",
lang,
includeObsoleteEntities: showObsoleteEnabled,
}
)}`,
undefined,
apiUrl
);
const hierarchicalChildrenPromise = getPaginated<any>(
`api/v2/ontologies/${ontologyId}/classes/${doubleEncodedUri}/hierarchicalChildren?${new URLSearchParams({
size: "1000",
lang,
includeObsoleteEntities: showObsoleteEnabled,
})}`,
undefined,
apiUrl
);
const directChildrenPromise = getPaginated<any>(
`api/v2/ontologies/${ontologyId}/classes/${doubleEncodedUri}/children?${new URLSearchParams({
size: "1000",
lang,
includeObsoleteEntities: showObsoleteEnabled,
})}`,
undefined,
apiUrl
);

const [hierarchicalChildren, directChildren] = await Promise.all([
hierarchicalChildrenPromise,
directChildrenPromise,
]);

// Merge the elements from both responses
childrenPage = {
elements: [
...hierarchicalChildren.elements,
...directChildren.elements,
],
};
} else if (entityTypePlural === "individuals") {
childrenPage = await getPaginated<any>(
`api/v2/ontologies/${ontologyId}/classes/${doubleEncodedUri}/individuals?${new URLSearchParams(
Expand Down Expand Up @@ -469,8 +490,8 @@ export const getNodeChildren = createAsyncThunk(
title: term.getName(),
expandable: term.hasChildren(),
entity: term,
numDescendants:
term.getNumHierarchicalDescendants() || term.getNumDescendants(),
numDescendants: term.getNumDescendants(),
numHierarchicalDescendants: term.getNumHierarchicalDescendants(),
parentRelationToChild:
(parenthoodMetadata &&
parenthoodMetadata["parentRelationToChild"]?.[0]) ||
Expand Down
Loading