From e4d640e99e6987dfda9b1dcfdc7b925524d9e844 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Wed, 26 Aug 2026 15:13:06 +0200 Subject: [PATCH] Use isAnyOf and lists for multiple purposes --- controller/src/classes/utils/PolicyInterpreter.ts | 10 ++++++++-- loama/src/components/policy-view/RuleForm.vue | 10 ++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/controller/src/classes/utils/PolicyInterpreter.ts b/controller/src/classes/utils/PolicyInterpreter.ts index b6802a9..b3509f7 100644 --- a/controller/src/classes/utils/PolicyInterpreter.ts +++ b/controller/src/classes/utils/PolicyInterpreter.ts @@ -1,6 +1,6 @@ import { getLoggedInIdentifier } from './Authentication'; import { Constraint, ISpecificTargetInfo, Policy, Rule } from "../../types/modules"; -import { DataFactory, Store, Writer } from "n3"; +import { DataFactory, Store, Writer, Quad_Object } from 'n3'; import { ODRL } from "./PolicyParser"; const { namedNode, literal } = DataFactory; @@ -178,6 +178,7 @@ export class PolicyInterpreter { } if (constraint.rightOperand && constraint.rightOperand.length > 0) { + const rightValues: Quad_Object[] = []; for (const operand of constraint.rightOperand) { let rightValue; @@ -199,7 +200,12 @@ export class PolicyInterpreter { rightValue = literal(cleanValue); } - writer.addQuad(constraintNode, namedNode(`${ODRL}rightOperand`), rightValue); + rightValues.push(rightValue); + } + if (rightValues.length === 1) { + writer.addQuad(constraintNode, namedNode(`${ODRL}rightOperand`), rightValues[0]); + } else { + writer.addQuad(constraintNode, namedNode(`${ODRL}rightOperand`), writer.list(rightValues)); } } } diff --git a/loama/src/components/policy-view/RuleForm.vue b/loama/src/components/policy-view/RuleForm.vue index a41ec26..1f19622 100644 --- a/loama/src/components/policy-view/RuleForm.vue +++ b/loama/src/components/policy-view/RuleForm.vue @@ -242,12 +242,10 @@ const handleSave = async () => { const constraints: Constraint[] = []; - form.purposes.forEach(purpose => { - constraints.push({ - leftOperand: 'http://www.w3.org/ns/odrl/2/purpose', - operator: 'http://www.w3.org/ns/odrl/2/eq', - rightOperand: [purpose] - }); + constraints.push({ + leftOperand: 'http://www.w3.org/ns/odrl/2/purpose', + operator: 'http://www.w3.org/ns/odrl/2/isAnyOf', + rightOperand: form.purposes, }); if (form.startTime) {