1 package de.dlr.shepard.context.semantic.io;
2
3 import de.dlr.shepard.common.neo4j.entities.Named;
4 import de.dlr.shepard.common.util.HasId;
5 import de.dlr.shepard.context.semantic.entities.SemanticAnnotation;
6 import jakarta.validation.constraints.NotBlank;
7 import jakarta.validation.constraints.NotNull;
8 import lombok.Data;
9 import lombok.NoArgsConstructor;
10 import org.eclipse.microprofile.openapi.annotations.media.Schema;
11
12 @Data
13 @NoArgsConstructor
14 @Schema(name = "SemanticAnnotation")
15 public class SemanticAnnotationIO implements HasId, Named {
16
17 @Schema(readOnly = true, required = true)
18 private Long id;
19
20 @Deprecated
21 @Schema(readOnly = true, required = true)
22 private String name;
23
24 @Schema(readOnly = true, required = true)
25 private String propertyName;
26
27 @NotBlank
28 @Schema(required = true)
29 private String propertyIRI;
30
31 @Schema(readOnly = true, required = true)
32 private String valueName;
33
34 @NotBlank
35 @Schema(required = true)
36 private String valueIRI;
37
38 @NotNull
39 @Schema(required = true)
40 private long propertyRepositoryId;
41
42 @NotNull
43 @Schema(required = true)
44 private long valueRepositoryId;
45
46 public SemanticAnnotationIO(SemanticAnnotation ref) {
47 this.id = ref.getId();
48 this.name = ref.getName();
49 this.propertyIRI = ref.getPropertyIRI();
50 this.valueIRI = ref.getValueIRI();
51 this.propertyRepositoryId = ref.getPropertyRepository() != null ? ref.getPropertyRepository().getId() : -1;
52 this.valueRepositoryId = ref.getValueRepository() != null ? ref.getValueRepository().getId() : -1;
53 this.propertyName = ref.getPropertyName();
54 this.valueName = ref.getValueName();
55 }
56
57 @Override
58 public String getUniqueId() {
59 return id.toString();
60 }
61 }