Skip to content

Commit

Permalink
Update cardinality handling
Browse files Browse the repository at this point in the history
  • Loading branch information
haideriqbal committed Oct 28, 2024
1 parent 36f314f commit f5c8976
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions frontend/src/components/ClassExpression.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 (
<span>
Expand All @@ -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 (
<span>
Expand All @@ -326,9 +342,12 @@ export default function ClassExpression({
</span>
);
}
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 (
<span>
Expand Down

0 comments on commit f5c8976

Please sign in to comment.