From 502ef8ea7fdce333ba2b07fbe98a96165c138447 Mon Sep 17 00:00:00 2001 From: "Florian (Feuermagier)" Date: Thu, 19 Sep 2024 14:52:34 +0200 Subject: [PATCH 1/2] mutable annotations, lazy value synchronization fix --- .../sdq/artemis4j/LazyNetworkValue.java | 2 +- .../sdq/artemis4j/grading/Annotation.java | 25 ++++++++++++++++--- .../grading/penalty/ThresholdPenaltyRule.java | 4 +++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java index 674d81f..b214bee 100644 --- a/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java +++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/LazyNetworkValue.java @@ -20,8 +20,8 @@ public T get() throws ArtemisNetworkException { // Second synchronized check to avoid double initialization if (this.value == null) { this.value = this.supplier.get(); - localValue = this.value; } + localValue = this.value; } } diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java index 6f2cc32..d9bb78d 100644 --- a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java +++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/Annotation.java @@ -21,9 +21,9 @@ public final class Annotation { private final String filePath; private final int startLine; private final int endLine; - private final String customMessage; - private final Double customScore; private final AnnotationSource source; + private String customMessage; + private Double customScore; /** * Deserializes an annotation from its metajson format @@ -34,9 +34,9 @@ public Annotation(AnnotationDTO dto, MistakeType mistakeType) { this.filePath = dto.classFilePath(); this.startLine = dto.startLine(); this.endLine = dto.endLine(); + this.source = dto.source() != null ? dto.source() : AnnotationSource.UNKNOWN; this.customMessage = dto.customMessageForJSON(); this.customScore = dto.customPenaltyForJSON(); - this.source = dto.source() != null ? dto.source() : AnnotationSource.UNKNOWN; } Annotation( @@ -126,6 +126,14 @@ public Optional getCustomMessage() { return Optional.ofNullable(customMessage); } + public void setCustomMessage(String message) { + if (this.type.isCustomAnnotation() && message == null) { + throw new IllegalArgumentException("A custom message is required for custom annotation types."); + } + + this.customMessage = message; + } + /** * The custom score associated with this message, if any. Is always empty for * predefined annotations, and never empty for custom annotations. @@ -134,6 +142,17 @@ public Optional getCustomScore() { return Optional.ofNullable(customScore); } + public void setCustomScore(Double score) { + if (!this.type.isCustomAnnotation() && score != null) { + throw new IllegalArgumentException("A custom score is not allowed for non-custom annotation types."); + } + if (this.type.isCustomAnnotation() && score == null) { + throw new IllegalArgumentException("A custom score is required for custom annotation types."); + } + + this.customScore = score; + } + public AnnotationSource getSource() { return source; } diff --git a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java index df84625..88481b1 100644 --- a/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java +++ b/src/main/java/edu/kit/kastel/sdq/artemis4j/grading/penalty/ThresholdPenaltyRule.java @@ -26,4 +26,8 @@ public Points calculatePoints(List annotations) { } return new Points(0.0, false); } + + public int getThreshold() { + return threshold; + } } From 96f3900f4f4fa6c2e6633334c5f0753afddbeeb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Fuch=C3=9F?= Date: Thu, 19 Sep 2024 13:13:35 +0000 Subject: [PATCH 2/2] Set version to 7.5.0-SNAPSHOT as this is the current version of our artemis instance --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc3e8b5..a1a13c9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ edu.kit.kastel.sdq artemis4j - 7.4.2-SNAPSHOT + 7.5.0-SNAPSHOT Artemis4J Artemis4J is a Java library for interacting with the Artemis teaching system.