Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: serialize the leftOperand as an @id #4185

Merged
merged 2 commits into from
May 16, 2024
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
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ maven/mavencentral/io.netty/netty-tcnative-classes/2.0.56.Final, Apache-2.0, app
maven/mavencentral/io.netty/netty-transport-native-unix-common/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926
maven/mavencentral/io.netty/netty-transport/4.1.86.Final, Apache-2.0 AND BSD-3-Clause AND MIT, approved, CQ20926
maven/mavencentral/io.opentelemetry.instrumentation/opentelemetry-instrumentation-annotations/1.32.0, Apache-2.0, approved, #11684
maven/mavencentral/io.opentelemetry.proto/opentelemetry-proto/1.3.1-alpha, None, restricted, #14688
maven/mavencentral/io.opentelemetry.proto/opentelemetry-proto/1.3.1-alpha, Apache-2.0, approved, #14688
maven/mavencentral/io.opentelemetry/opentelemetry-api/1.32.0, Apache-2.0, approved, #11682
maven/mavencentral/io.opentelemetry/opentelemetry-context/1.32.0, Apache-2.0, approved, #11683
maven/mavencentral/io.prometheus/simpleclient/0.16.0, Apache-2.0, approved, clearlydefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ private JsonObject visitMultiplicityConstraint(String operandType, MultiplicityC
public JsonObject visitAtomicConstraint(AtomicConstraint atomicConstraint) {
var constraintBuilder = jsonFactory.createObjectBuilder();

constraintBuilder.add(ODRL_LEFT_OPERAND_ATTRIBUTE, atomicConstraint.getLeftExpression().accept(this));
var leftOperand = atomicConstraint.getLeftExpression().accept((expression) -> expression.getValue().toString());
constraintBuilder.add(ODRL_LEFT_OPERAND_ATTRIBUTE, jsonFactory.createArrayBuilder().add(jsonFactory.createObjectBuilder().add(ID, leftOperand)));
var operator = atomicConstraint.getOperator().getOdrlRepresentation();
constraintBuilder.add(ODRL_OPERATOR_ATTRIBUTE, jsonFactory.createArrayBuilder().add(jsonFactory.createObjectBuilder().add(ID, operator)));
constraintBuilder.add(ODRL_RIGHT_OPERAND_ATTRIBUTE, atomicConstraint.getRightExpression().accept(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void transform_actionWithAllAttributes_returnJsonObject() {
assertThat(actionJson.getJsonObject(ODRL_REFINEMENT_ATTRIBUTE)).isNotNull();

var constraintJson = actionJson.getJsonObject(ODRL_REFINEMENT_ATTRIBUTE);
assertThat(constraintJson.getJsonObject(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonString(VALUE).getString())
assertThat(constraintJson.getJsonArray(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(((LiteralExpression) constraint.getLeftExpression()).getValue());
assertThat(constraintJson.getJsonArray(ODRL_OPERATOR_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(constraint.getOperator().getOdrlRepresentation());
Expand Down Expand Up @@ -221,7 +221,7 @@ void transform_permissionWithConstraintAndDuty_returnJsonObject() {
assertThat(permissionJson.getJsonArray(ODRL_DUTY_ATTRIBUTE)).hasSize(1);

var constraintJson = permissionJson.getJsonArray(ODRL_CONSTRAINT_ATTRIBUTE).get(0).asJsonObject();
assertThat(constraintJson.getJsonObject(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonString(VALUE).getString())
assertThat(constraintJson.getJsonArray(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(((LiteralExpression) constraint.getLeftExpression()).getValue());
assertThat(constraintJson.getJsonArray(ODRL_OPERATOR_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(constraint.getOperator().getOdrlRepresentation());
Expand Down Expand Up @@ -253,7 +253,7 @@ void transform_prohibitionWithConstraint_returnJsonObject() {
assertThat(prohibitionJson.getJsonArray(ODRL_CONSTRAINT_ATTRIBUTE)).hasSize(1);

var constraintJson = prohibitionJson.getJsonArray(ODRL_CONSTRAINT_ATTRIBUTE).get(0).asJsonObject();
assertThat(constraintJson.getJsonObject(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonString(VALUE).getString())
assertThat(constraintJson.getJsonArray(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(((LiteralExpression) constraint.getLeftExpression()).getValue());
assertThat(constraintJson.getJsonArray(ODRL_OPERATOR_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(constraint.getOperator().getOdrlRepresentation());
Expand Down Expand Up @@ -289,7 +289,7 @@ void transform_dutyWithConstraintAndConsequence_returnJsonObject() {
assertThat(dutyJson.getJsonArray(ODRL_CONSTRAINT_ATTRIBUTE)).hasSize(1);

var constraintJson = dutyJson.getJsonArray(ODRL_CONSTRAINT_ATTRIBUTE).get(0).asJsonObject();
assertThat(constraintJson.getJsonObject(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonString(VALUE).getString())
assertThat(constraintJson.getJsonArray(ODRL_LEFT_OPERAND_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(((LiteralExpression) constraint.getLeftExpression()).getValue());
assertThat(constraintJson.getJsonArray(ODRL_OPERATOR_ATTRIBUTE).getJsonObject(0).getString(ID))
.isEqualTo(constraint.getOperator().getOdrlRepresentation());
Expand Down
Loading