This repository was archived by the owner on Feb 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +77
-32
lines changed
dataformat-json/src/test/java/io/adminshell/aas/v3/dataformat/json
main/java/io/adminshell/aas/v3/dataformat/rdf
test/java/io/adminshell/aas/v3/dataformat/rdf
dataformat-xml/src/test/java/io/adminshell/aas/v3/dataformat/xml Expand file tree Collapse file tree 5 files changed +77
-32
lines changed Original file line number Diff line number Diff line change 1818import java .util .List ;
1919import java .util .Objects ;
2020
21- import io .adminshell .aas .v3 .model .Constraint ;
22- import io .adminshell .aas .v3 .model .EmbeddedDataSpecification ;
23- import io .adminshell .aas .v3 .model .LangString ;
24- import io .adminshell .aas .v3 .model .ModelingKind ;
25- import io .adminshell .aas .v3 .model .Property ;
26- import io .adminshell .aas .v3 .model .Reference ;
21+ import io .adminshell .aas .v3 .model .*;
2722
2823public class CustomProperty implements Property {
2924
@@ -49,6 +44,8 @@ public class CustomProperty implements Property {
4944
5045 protected String idShort ;
5146
47+ protected List <Extension > extensions ;
48+
5249 protected CustomProperty () {
5350 }
5451
@@ -188,4 +185,14 @@ final public Reference getSemanticId() {
188185 final public void setSemanticId (Reference semanticId ) {
189186 this .semanticId = semanticId ;
190187 }
188+
189+ @ Override
190+ public List <Extension > getExtensions () {
191+ return extensions ;
192+ }
193+
194+ @ Override
195+ public void setExtensions (List <Extension > list ) {
196+ this .extensions = list ;
197+ }
191198}
Original file line number Diff line number Diff line change @@ -28,13 +28,34 @@ public class JsonLdEnumSerializer extends JsonSerializer<Enum<?>> {
2828
2929 @ Override
3030 public void serialize (Enum value , JsonGenerator gen , SerializerProvider provider ) throws IOException {
31+ //Generated Enum classes of the admin shell have @IRI annotations, which need to be used to provide proper RDF
3132 if (value .getClass ().isEnum () && value .getClass ().getName ().startsWith ("io.adminshell.aas." ))
3233 {
34+ //Try to get annotation value to get the IRI used in the ontology
3335 if (value .getClass ().getAnnotation (IRI .class ) != null && value .getClass ().getAnnotation (IRI .class ).value ().length > 0 )
3436 {
3537 gen .writeStartObject ();
3638 gen .writeStringField ("@type" , value .getClass ().getAnnotation (IRI .class ).value ()[0 ]);
37- gen .writeStringField ("@id" , translate (value .getClass (), value .name ()));
39+
40+ //Try to extract exact IRI of the enum value, if present
41+ try {
42+ var annotation = value .getClass ().getField (value .name ()).getAnnotation (IRI .class );
43+ if (annotation != null && annotation .value ().length > 0 )
44+ {
45+ gen .writeStringField ("@id" , annotation .value ()[0 ]);
46+ }
47+ else
48+ {
49+ //Didn't find an @IRI annotation - fall back to using class annotation + field name
50+ gen .writeStringField ("@id" , translate (value .getClass (), value .name ()));
51+ }
52+ }
53+ //Should be impossible
54+ catch (NoSuchFieldException e )
55+ {
56+ //Didn't find an @IRI annotation - fall back to using class annotation + field name
57+ gen .writeStringField ("@id" , translate (value .getClass (), value .name ()));
58+ }
3859 gen .writeEndObject ();
3960 }
4061 else
Original file line number Diff line number Diff line change 1515 */
1616package io .adminshell .aas .v3 .dataformat .rdf ;
1717
18- import io .adminshell .aas .v3 .dataformat .rdf .Serializer ;
1918import io .adminshell .aas .v3 .model .*;
2019import io .adminshell .aas .v3 .model .impl .*;
2120import org .apache .jena .riot .RDFLanguages ;
Original file line number Diff line number Diff line change 1818import java .util .List ;
1919import java .util .Objects ;
2020
21- import io .adminshell .aas .v3 .model .Constraint ;
22- import io .adminshell .aas .v3 .model .EmbeddedDataSpecification ;
23- import io .adminshell .aas .v3 .model .LangString ;
24- import io .adminshell .aas .v3 .model .ModelingKind ;
25- import io .adminshell .aas .v3 .model .Property ;
26- import io .adminshell .aas .v3 .model .Reference ;
21+ import io .adminshell .aas .v3 .model .*;
2722
2823public class CustomProperty implements Property {
2924
@@ -49,6 +44,8 @@ public class CustomProperty implements Property {
4944
5045 protected String idShort ;
5146
47+ protected List <Extension > extensions ;
48+
5249 protected CustomProperty () {
5350 }
5451
@@ -188,4 +185,14 @@ final public Reference getSemanticId() {
188185 final public void setSemanticId (Reference semanticId ) {
189186 this .semanticId = semanticId ;
190187 }
188+
189+ @ Override
190+ public List <Extension > getExtensions () {
191+ return extensions ;
192+ }
193+
194+ @ Override
195+ public void setExtensions (List <Extension > list ) {
196+ this .extensions = list ;
197+ }
191198}
Original file line number Diff line number Diff line change 158158 </execution >
159159 </executions >
160160 </plugin >
161- <plugin >
162- <groupId >org.apache.maven.plugins</groupId >
163- <artifactId >maven-gpg-plugin</artifactId >
164- <version >3.0.1</version >
165- <configuration >
166- <keyname >${gpg.keyname} </keyname >
167- <passphraseServerId >${gpg.keyname} </passphraseServerId >
168- </configuration >
169- <executions >
170- <execution >
171- <id >sign-artifacts</id >
172- <phase >verify</phase >
173- <goals >
174- <goal >sign</goal >
175- </goals >
176- </execution >
177- </executions >
178- </plugin >
179161 </plugins >
180162 </build >
181163
164+ <!-- This profile is for the continuous integration pipeline for deploying to the central repository, which requires artifacts to be signed -->
165+ <profiles >
166+ <profile >
167+ <id >CI</id >
168+ <build >
169+ <plugins >
170+ <plugin >
171+ <groupId >org.apache.maven.plugins</groupId >
172+ <artifactId >maven-gpg-plugin</artifactId >
173+ <version >3.0.1</version >
174+ <configuration >
175+ <keyname >${gpg.keyname} </keyname >
176+ <passphraseServerId >${gpg.keyname} </passphraseServerId >
177+ </configuration >
178+ <executions >
179+ <execution >
180+ <id >sign-artifacts</id >
181+ <phase >verify</phase >
182+ <goals >
183+ <goal >sign</goal >
184+ </goals >
185+ </execution >
186+ </executions >
187+ </plugin >
188+ </plugins >
189+ </build >
190+ </profile >
191+ </profiles >
192+
182193 <dependencyManagement >
183194 <dependencies >
184195 <dependency >
You can’t perform that action at this time.
0 commit comments