-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1216 from NASA-AMMOS/AERIE-1117---Return_Compilat…
…ion_Errors_with_Constraints [Aerie-1117] Return compilation errors with constraints
- Loading branch information
Showing
12 changed files
with
216 additions
and
92 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
constraints/src/main/java/gov/nasa/jpl/aerie/constraints/ConstraintCompilationException.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/ConstraintError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package gov.nasa.jpl.aerie.e2e.types; | ||
|
||
import javax.json.JsonObject; | ||
|
||
public record ConstraintError(String message, String stack, Location location ){ | ||
record Location(int column, int line){ | ||
public static Location fromJSON(JsonObject json){ | ||
return new Location(json.getJsonNumber("column").intValue(), json.getJsonNumber("line").intValue()); | ||
} | ||
}; | ||
|
||
public static ConstraintError fromJSON(JsonObject json){ | ||
return new ConstraintError(json.getString("message"),json.getString("stack"),Location.fromJSON(json.getJsonObject("location"))); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
e2e-tests/src/test/java/gov/nasa/jpl/aerie/e2e/types/ConstraintResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package gov.nasa.jpl.aerie.e2e.types; | ||
|
||
import javax.json.JsonNumber; | ||
import javax.json.JsonObject; | ||
import javax.json.JsonString; | ||
import java.util.List; | ||
|
||
public record ConstraintResult(int constraintId, | ||
String constraintName, | ||
String type, | ||
List<String> resourceIds, | ||
List<ConstraintResult.ConstraintViolation> violations, | ||
List<ConstraintResult.Interval> gaps){ | ||
public record ConstraintViolation(List<Integer> activityInstanceIds, List<Interval> windows) { | ||
|
||
public static ConstraintViolation fromJSON(JsonObject json) { | ||
return new ConstraintViolation( | ||
json.getJsonArray("activityInstanceIds") | ||
.getValuesAs(JsonNumber::intValue), | ||
json.getJsonArray("windows") | ||
.getValuesAs(Interval::fromJSON)); | ||
} | ||
} | ||
|
||
public record Interval(long start, long end) { | ||
public static Interval fromJSON(JsonObject json) { | ||
return new Interval(json.getJsonNumber("start").longValue(), json.getJsonNumber("end").longValue()); | ||
} | ||
} | ||
|
||
public static ConstraintResult fromJSON(JsonObject json) { | ||
final var resourceIds = json.getJsonArray("resourceIds").getValuesAs(JsonString::getString); | ||
final var gaps = json.getJsonArray("gaps").getValuesAs(Interval::fromJSON); | ||
final var violations = json.getJsonArray("violations").getValuesAs(ConstraintViolation::fromJSON); | ||
|
||
return new ConstraintResult( | ||
json.getInt("constraintId"), | ||
json.getString("constraintName"), | ||
json.getString("type"), | ||
resourceIds, | ||
violations, | ||
gaps | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...main/java/gov/nasa/jpl/aerie/merlin/server/exceptions/ConstraintCompilationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package gov.nasa.jpl.aerie.merlin.server.exceptions; | ||
|
||
import gov.nasa.jpl.aerie.merlin.server.services.ConstraintsDSLCompilationService; | ||
|
||
public class ConstraintCompilationException extends Exception { | ||
String constraintName; | ||
ConstraintsDSLCompilationService.ConstraintsDSLCompilationResult.Error error; | ||
public ConstraintCompilationException(String constraintName, ConstraintsDSLCompilationService.ConstraintsDSLCompilationResult.Error error) { | ||
super("Constraint "+constraintName+" compilation failed:\n"+error.toString()); | ||
this.constraintName = constraintName; | ||
this.error = error; | ||
} | ||
|
||
public String getConstraintName() { | ||
return constraintName; | ||
} | ||
|
||
public ConstraintsDSLCompilationService.ConstraintsDSLCompilationResult.Error getErrors() { | ||
return error; | ||
} | ||
} |
Oops, something went wrong.