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
10 changes: 8 additions & 2 deletions controller/src/classes/utils/PolicyInterpreter.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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));
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions loama/src/components/policy-view/RuleForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down