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