Skip to content

Commit 53bbc1b

Browse files
authored
Fix/findings on rc (#91)
* Remove validatePackage endpoint and service method Deleted the validatePackage method from PackageService and its corresponding endpoint from PackageController. This streamlines the API by removing unused or deprecated validation functionality for uploaded ZIP files. * Update ESMF SDK version and refactor imports Bump esmf-sdk-version to 2.11.1 in pom.xml. Refactor imports in ModelUtils, ViolationFormatter, and ValidationUtils to use new locations for ProcessingViolation and InvalidSyntaxViolation, and update method signature in ModelUtils to use AspectModelFile. * Refactor model file handling and validation logic Replaces usage of StructuredModelsRoot with AspectModelLoader for file deletion. Updates validation and formatting methods to filter aspect model files by 'inmemory' source scheme instead of checking for empty source location. * Refactor services to use CompletedFileUpload for model input Service methods now accept CompletedFileUpload and URI instead of raw Turtle strings for aspect model input, improving file handling and consistency. Added MockFileUpload for testing, updated tests and utility methods, and enhanced model grouping logic to support filtering by aspect models. * Remove FileWriteException and related references Deleted the FileWriteException class and removed its usage from GlobalExceptionHandler. Also cleaned up unused code in ApplicationSettings, ModelService, ModelUtils, and refactored MockFileUpload to use a record for simplicity. * Refactor model version handling and update URI scheme Replaces 'inmemory' URI scheme with 'blob' throughout service and tests. Adds version field to Model, updates grouping logic to extract and assign meta model version, and refines version processing in ModelService to skip non-latest versions and improve file creation logic. * Refactor aspect model versioning and file handling Simplifies the process of saving aspect model files by removing the saveAspectModelFiles method and updating logic to use AspectSerializer directly. The applyNamespaceVersionChange method now accepts an errors list and throws a FileHandlingException for missing filenames, improving error reporting and exception handling. * Refactor model file creation and validation logic Introduces improved file creation methods in ModelUtils, adds duplicate element checks, and refactors ModelService to use new validation and file creation utilities. Exception handling and violation checks are now more robust and modular. * Increase logging for native image build in CI Adds SLF4J simple logger properties to Maven commands in the native image build steps for Mac, Linux, and Windows in the pull request workflow. This change sets the default log level to info and enables info-level logging for org.apache.jena, improving build output visibility. * Move SLF4J log level config from workflow to pom.xml Removes SLF4J log level and Apache Jena logger configuration from GitHub Actions workflow and sets them as system properties in the Maven Surefire plugin configuration in the respective pom.xml files. This centralizes logging configuration within the project build files for consistency across environments. * Move Jena log level config from pom.xml to logback.xml Removed SLF4J simple logger system properties for org.apache.jena from the Maven plugin configurations in both runtime and service modules. Added explicit logger configuration for org.apache.jena at INFO level in logback.xml to centralize logging configuration. * Set root logger level to INFO and update logback config Added logger.levels.root=INFO to all application properties files to explicitly set the root logging level. Removed redundant org.apache.jena logger entry from logback.xml to streamline logging configuration. * Remove verbose options from native image build config Eliminated the <verbose> and --verbose options from the native image build configuration in pom.xml to reduce build output verbosity. * Remove unused GraalVM native-image arguments Deleted the -H:+ReportExceptionStackTraces and -H:+PrintClassInitialization arguments from the native-image configuration in pom.xml as they are no longer needed. * Add test logging configuration files Introduce application-test.properties and logback.xml for configuring logging during tests in aspect-model-editor-service. Sets root logger level to ERROR and defines logback appenders and logger levels for Micronaut components. * Refactor workspace migration to accept storage path Updated ModelService and related calls to require an explicit metaModelStoragePath parameter for workspace migration, removing reliance on ApplicationSettings within the service. Adjusted tests, controller, and properties to support this change and improved configuration clarity. * Normalize file paths for URI creation in tests Introduced a toUriPath helper method to ensure file paths are converted to URI-compatible format, especially handling Windows path separators. Updated all test usages to apply this normalization when constructing URIs from file paths. * Fix file path handling for URIs in tests Introduced a toUriPath helper to ensure file paths are correctly formatted as URI paths, especially on Windows. Updated validateModel and migrateModel test calls to use this helper for consistent cross-platform behavior. * Switch API requests to multipart form with file upload Updated multiple Bruno API request definitions to use multipart form data and file upload for aspect models, replacing previous usage of plain text bodies. Added references to new test files in the TestingFiles directory to support file-based testing. * Update ModelService.java
1 parent bd963aa commit 53bbc1b

File tree

58 files changed

+3498
-2923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+3498
-2923
lines changed

aspect-model-editor-core/src/main/java/org/eclipse/esmf/ame/config/ApplicationSettings.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,4 @@ private ApplicationSettings() {
4444
public static Path getMetaModelStoragePath() {
4545
return Path.of( META_MODEL_PATH );
4646
}
47-
48-
public static Path getEndFilePath() {
49-
return Path.of( END_FILE_PATH );
50-
}
5147
}

aspect-model-editor-core/src/main/java/org/eclipse/esmf/ame/exceptions/CreateFileException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ public class CreateFileException extends RuntimeException {
1919
@Serial
2020
private static final long serialVersionUID = 1L;
2121

22+
/**
23+
* Constructs a CreateFileException with message and cause.
24+
*
25+
* @param message the message of the exception
26+
*/
27+
public CreateFileException( final String message ) {
28+
super( message );
29+
}
30+
2231
/**
2332
* Constructs a CreateFileException with message and cause.
2433
*

aspect-model-editor-core/src/main/java/org/eclipse/esmf/ame/exceptions/FileWriteException.java renamed to aspect-model-editor-core/src/main/java/org/eclipse/esmf/ame/exceptions/UriNotDefinedException.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515

1616
import java.io.Serial;
1717

18-
public class FileWriteException extends RuntimeException {
18+
public class UriNotDefinedException extends RuntimeException {
1919
@Serial
2020
private static final long serialVersionUID = 1L;
2121

2222
/**
23-
* Constructs a FileWriteException with message and cause.
23+
* Constructs a UriNotDefinedException with message, cause and value.
2424
*
2525
* @param message the message of the exception
26-
* @param cause of the exception
2726
*/
28-
public FileWriteException( final String message, final Throwable cause ) {
29-
super( message, cause );
27+
public UriNotDefinedException( final String message ) {
28+
super( message );
3029
}
3130
}

aspect-model-editor-runtime/bruno/FormateAspectModel.bru

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ meta {
66

77
post {
88
url: http://localhost:{{port}}/ame/api/models/format
9-
body: text
9+
body: multipartForm
1010
auth: none
1111
}
1212

1313
headers {
14-
Content-Type: text/plain
14+
uri: blob://movement.ttl
1515
}
1616

1717
body:text {
@@ -110,6 +110,14 @@ body:text {
110110

111111
}
112112

113+
body:multipart-form {
114+
aspectModel: @file(./TestingFiles/Movement.ttl)
115+
}
116+
117+
body:file {
118+
~file: @file()
119+
}
120+
113121
tests {
114122
test("Status code is 200", function() {
115123
expect(res.getStatus()).to.equal(200);})
Lines changed: 125 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,125 @@
1-
meta {
2-
name: GenerateAASX
3-
type: http
4-
seq: 27
5-
}
6-
7-
post {
8-
url: http://localhost:{{port}}/ame/api/generate/aasx
9-
body: text
10-
auth: none
11-
}
12-
13-
headers {
14-
Content-Type: text/plain
15-
}
16-
17-
body:text {
18-
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
19-
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
20-
@prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:2.2.0#> .
21-
@prefix unit: <urn:samm:org.eclipse.esmf.samm:unit:2.2.0#> .
22-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
23-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
24-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
25-
@prefix : <urn:samm:org.eclipse.examples:1.0.0#> .
26-
27-
:Movement a samm:Aspect ;
28-
samm:preferredName "movement"@en ;
29-
samm:description "Aspect for movement information"@en ;
30-
samm:properties ( :isMoving :position :speed :speedLimitWarning ) ;
31-
samm:operations ( ) ;
32-
samm:events ( ) .
33-
34-
:isMoving a samm:Property ;
35-
samm:preferredName "is moving"@en ;
36-
samm:description "Flag indicating whether the asset is currently moving"@en ;
37-
samm:characteristic samm-c:Boolean .
38-
39-
:position a samm:Property ;
40-
samm:preferredName "position"@en ;
41-
samm:description "Indicates a position"@en ;
42-
samm:characteristic :SpatialPositionCharacteristic .
43-
44-
:speed a samm:Property ;
45-
samm:preferredName "speed"@en ;
46-
samm:description "speed of vehicle"@en ;
47-
samm:characteristic :Speed .
48-
49-
:speedLimitWarning a samm:Property ;
50-
samm:preferredName "speed limit warning"@en ;
51-
samm:description "Indicates if the speed limit is adhered to."@en ;
52-
samm:characteristic :TrafficLight .
53-
54-
:SpatialPositionCharacteristic a samm-c:SingleEntity ;
55-
samm:preferredName "spatial position characteristic"@en ;
56-
samm:description "Represents a single position in space with optional z coordinate."@en ;
57-
samm:dataType :SpatialPosition .
58-
59-
:Speed a samm-c:Measurement ;
60-
samm:preferredName "speed"@en ;
61-
samm:description "Scalar representation of speed of an object in kilometers per hour."@en ;
62-
samm:dataType xsd:float ;
63-
samm-c:unit unit:kilometrePerHour .
64-
65-
:TrafficLight a samm-c:Enumeration ;
66-
samm:preferredName "warning level"@en ;
67-
samm:description "Represents if speed of position change is within specification (green), within tolerance (yellow), or outside specification (red)."@en ;
68-
samm:dataType xsd:string ;
69-
samm-c:values ( "green" "yellow" "red" ) .
70-
71-
:SpatialPosition a samm:Entity ;
72-
samm:preferredName "spatial position"@en ;
73-
samm:description "Represents latitude, longitude and altitude information in the WGS84 geodetic reference datum"@en ;
74-
samm:see <https://www.w3.org/2003/01/geo/> ;
75-
samm:properties ( :latitude :longitude [ samm:property :altitude; samm:optional true ] ) .
76-
77-
:latitude a samm:Property ;
78-
samm:preferredName "latitude"@en ;
79-
samm:description "latitude coordinate in space (WGS84)"@en ;
80-
samm:see <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ;
81-
samm:characteristic :Coordinate ;
82-
samm:exampleValue "9.1781"^^xsd:decimal .
83-
84-
:longitude a samm:Property ;
85-
samm:preferredName "longitude"@en ;
86-
samm:description "longitude coordinate in space (WGS84)"@en ;
87-
samm:see <http://www.w3.org/2003/01/geo/wgs84_pos#long> ;
88-
samm:characteristic :Coordinate ;
89-
samm:exampleValue "48.80835"^^xsd:decimal .
90-
91-
:altitude a samm:Property ;
92-
samm:preferredName "altitude"@en ;
93-
samm:description "Elevation above sea level zero"@en ;
94-
samm:see <http://www.w3.org/2003/01/geo/wgs84_pos#alt> ;
95-
samm:characteristic :MetresAboveMeanSeaLevel ;
96-
samm:exampleValue "153"^^xsd:float .
97-
98-
:Coordinate a samm-c:Measurement ;
99-
samm:preferredName "coordinate"@en ;
100-
samm:description "Representing the geographical coordinate"@en ;
101-
samm:dataType xsd:decimal ;
102-
samm-c:unit unit:degreeUnitOfAngle .
103-
104-
:MetresAboveMeanSeaLevel a samm-c:Measurement ;
105-
samm:preferredName "metres above mean sea level"@en ;
106-
samm:description "Signifies the vertical distance in reference to a historic mean sea level as a vertical datum"@en ;
107-
samm:see <https://en.wikipedia.org/wiki/Height_above_sea_level> ;
108-
samm:dataType xsd:float ;
109-
samm-c:unit unit:metre .
110-
111-
}
112-
113-
tests {
114-
test("Status code is 200", function() {
115-
expect(res.getStatus()).to.equal(200);
116-
});
117-
test("Response body is valid", function () {
118-
const data = res.getBody();
119-
expect(data).to.contains("aasx");
120-
})
121-
}
1+
meta {
2+
name: GenerateAASX
3+
type: http
4+
seq: 27
5+
}
6+
7+
post {
8+
url: http://localhost:{{port}}/ame/api/generate/aasx
9+
body: multipartForm
10+
auth: none
11+
}
12+
13+
headers {
14+
uri: blob://movement.ttl
15+
}
16+
17+
body:text {
18+
@prefix samm: <urn:samm:org.eclipse.esmf.samm:meta-model:2.2.0#> .
19+
@prefix samm-c: <urn:samm:org.eclipse.esmf.samm:characteristic:2.2.0#> .
20+
@prefix samm-e: <urn:samm:org.eclipse.esmf.samm:entity:2.2.0#> .
21+
@prefix unit: <urn:samm:org.eclipse.esmf.samm:unit:2.2.0#> .
22+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
23+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
24+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
25+
@prefix : <urn:samm:org.eclipse.examples:1.0.0#> .
26+
27+
:Movement a samm:Aspect ;
28+
samm:preferredName "movement"@en ;
29+
samm:description "Aspect for movement information"@en ;
30+
samm:properties ( :isMoving :position :speed :speedLimitWarning ) ;
31+
samm:operations ( ) ;
32+
samm:events ( ) .
33+
34+
:isMoving a samm:Property ;
35+
samm:preferredName "is moving"@en ;
36+
samm:description "Flag indicating whether the asset is currently moving"@en ;
37+
samm:characteristic samm-c:Boolean .
38+
39+
:position a samm:Property ;
40+
samm:preferredName "position"@en ;
41+
samm:description "Indicates a position"@en ;
42+
samm:characteristic :SpatialPositionCharacteristic .
43+
44+
:speed a samm:Property ;
45+
samm:preferredName "speed"@en ;
46+
samm:description "speed of vehicle"@en ;
47+
samm:characteristic :Speed .
48+
49+
:speedLimitWarning a samm:Property ;
50+
samm:preferredName "speed limit warning"@en ;
51+
samm:description "Indicates if the speed limit is adhered to."@en ;
52+
samm:characteristic :TrafficLight .
53+
54+
:SpatialPositionCharacteristic a samm-c:SingleEntity ;
55+
samm:preferredName "spatial position characteristic"@en ;
56+
samm:description "Represents a single position in space with optional z coordinate."@en ;
57+
samm:dataType :SpatialPosition .
58+
59+
:Speed a samm-c:Measurement ;
60+
samm:preferredName "speed"@en ;
61+
samm:description "Scalar representation of speed of an object in kilometers per hour."@en ;
62+
samm:dataType xsd:float ;
63+
samm-c:unit unit:kilometrePerHour .
64+
65+
:TrafficLight a samm-c:Enumeration ;
66+
samm:preferredName "warning level"@en ;
67+
samm:description "Represents if speed of position change is within specification (green), within tolerance (yellow), or outside specification (red)."@en ;
68+
samm:dataType xsd:string ;
69+
samm-c:values ( "green" "yellow" "red" ) .
70+
71+
:SpatialPosition a samm:Entity ;
72+
samm:preferredName "spatial position"@en ;
73+
samm:description "Represents latitude, longitude and altitude information in the WGS84 geodetic reference datum"@en ;
74+
samm:see <https://www.w3.org/2003/01/geo/> ;
75+
samm:properties ( :latitude :longitude [ samm:property :altitude; samm:optional true ] ) .
76+
77+
:latitude a samm:Property ;
78+
samm:preferredName "latitude"@en ;
79+
samm:description "latitude coordinate in space (WGS84)"@en ;
80+
samm:see <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ;
81+
samm:characteristic :Coordinate ;
82+
samm:exampleValue "9.1781"^^xsd:decimal .
83+
84+
:longitude a samm:Property ;
85+
samm:preferredName "longitude"@en ;
86+
samm:description "longitude coordinate in space (WGS84)"@en ;
87+
samm:see <http://www.w3.org/2003/01/geo/wgs84_pos#long> ;
88+
samm:characteristic :Coordinate ;
89+
samm:exampleValue "48.80835"^^xsd:decimal .
90+
91+
:altitude a samm:Property ;
92+
samm:preferredName "altitude"@en ;
93+
samm:description "Elevation above sea level zero"@en ;
94+
samm:see <http://www.w3.org/2003/01/geo/wgs84_pos#alt> ;
95+
samm:characteristic :MetresAboveMeanSeaLevel ;
96+
samm:exampleValue "153"^^xsd:float .
97+
98+
:Coordinate a samm-c:Measurement ;
99+
samm:preferredName "coordinate"@en ;
100+
samm:description "Representing the geographical coordinate"@en ;
101+
samm:dataType xsd:decimal ;
102+
samm-c:unit unit:degreeUnitOfAngle .
103+
104+
:MetresAboveMeanSeaLevel a samm-c:Measurement ;
105+
samm:preferredName "metres above mean sea level"@en ;
106+
samm:description "Signifies the vertical distance in reference to a historic mean sea level as a vertical datum"@en ;
107+
samm:see <https://en.wikipedia.org/wiki/Height_above_sea_level> ;
108+
samm:dataType xsd:float ;
109+
samm-c:unit unit:metre .
110+
111+
}
112+
113+
body:multipart-form {
114+
aspectModel: @file(./TestingFiles/Movement.ttl)
115+
}
116+
117+
tests {
118+
test("Status code is 200", function() {
119+
expect(res.getStatus()).to.equal(200);
120+
});
121+
test("Response body is valid", function () {
122+
const data = res.getBody();
123+
expect(data).to.contains("aasx");
124+
})
125+
}

0 commit comments

Comments
 (0)