From f5c8976f0b240129d409ce78d4086dd693b28af0 Mon Sep 17 00:00:00 2001 From: haider Date: Mon, 28 Oct 2024 15:23:20 +0000 Subject: [PATCH 1/2] Update cardinality handling --- frontend/src/components/ClassExpression.tsx | 27 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ClassExpression.tsx b/frontend/src/components/ClassExpression.tsx index 22e7ab6f6..f469bc28d 100644 --- a/frontend/src/components/ClassExpression.tsx +++ b/frontend/src/components/ClassExpression.tsx @@ -28,7 +28,17 @@ export default function ClassExpression({ const types = asArray(expr['type']) - if(types && types.indexOf('datatype') !== -1) { + function getCardinality(value) { + if (value === null || value === undefined) { + return []; + } else if (Array.isArray(value)) { + return value; + } else { + return [value]; + } + } + + if(types && types.indexOf('datatype') !== -1) { // rdfs:Datatype let equivClass = expr['http://www.w3.org/2002/07/owl#equivalentClass']; if(equivClass) { @@ -301,9 +311,12 @@ export default function ClassExpression({ ); } - const minCardinality = asArray( + let minCardinality = getCardinality( expr["http://www.w3.org/2002/07/owl#minCardinality"] )[0]; + if(typeof minCardinality === 'number') { + minCardinality = minCardinality.toString() + } if (minCardinality) { return ( @@ -314,9 +327,12 @@ export default function ClassExpression({ ); } - let maxCardinality = asArray( + let maxCardinality = getCardinality( expr["http://www.w3.org/2002/07/owl#maxCardinality"] )[0]; + if(typeof maxCardinality === 'number') { + maxCardinality = maxCardinality.toString() + } if (maxCardinality) { return ( @@ -326,9 +342,12 @@ export default function ClassExpression({ ); } - let exactCardinality = asArray( + let exactCardinality = getCardinality( expr["http://www.w3.org/2002/07/owl#cardinality"] )[0]; + if(typeof exactCardinality === 'number') { + exactCardinality = exactCardinality.toString() + } if (exactCardinality) { return ( From 05b62973450f93ae636cd96874c18cb44b169029 Mon Sep 17 00:00:00 2001 From: haider Date: Mon, 4 Nov 2024 12:11:11 +0000 Subject: [PATCH 2/2] Update handling of data properties and oneOf --- frontend/src/components/ClassExpression.tsx | 7 ++++++- .../IndividualPropertyAssertionsSection.tsx | 20 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/ClassExpression.tsx b/frontend/src/components/ClassExpression.tsx index f469bc28d..9cb630d6e 100644 --- a/frontend/src/components/ClassExpression.tsx +++ b/frontend/src/components/ClassExpression.tsx @@ -160,7 +160,7 @@ export default function ClassExpression({ , ]; - for (const subExpr of oneOf) { + for (let subExpr of oneOf) { if (nodes.length > 1) { nodes.push( @@ -168,6 +168,11 @@ export default function ClassExpression({ ); } + + if (typeof subExpr === "number") { + subExpr = subExpr.toString(); + } + nodes.push(   - { - + {typeof v === "string" && v.includes("http") ? ( + @@ -107,7 +107,21 @@ export default function IndividualPropertyAssertionsSection({ linkedEntities={linkedEntities} /> - } + ) : ( + + + + )} ); }