1 package de.dlr.shepard.context.version.io; 2 3 import com.fasterxml.jackson.annotation.JsonFormat; 4 import de.dlr.shepard.context.version.entities.Version; 5 import java.util.Date; 6 import java.util.UUID; 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 = "Version") 14 public class VersionIO { 15 16 @Schema(readOnly = true, required = true) 17 private UUID uid; 18 19 private String name; 20 21 private String description; 22 23 private boolean isHEADVersion; 24 25 @JsonFormat(shape = JsonFormat.Shape.STRING) 26 @Schema(readOnly = true, format = "date-time", example = "2024-08-15T11:18:44.632+00:00") 27 private Date createdAt; 28 29 @Schema(readOnly = true) 30 private String createdBy; 31 32 @Schema(readOnly = true) 33 private UUID predecessorUUID; 34 35 public VersionIO(Version version) { 36 this.uid = version.getUid(); 37 this.name = version.getName(); 38 this.isHEADVersion = version.isHEADVersion(); 39 this.description = version.getDescription(); 40 this.createdAt = version.getCreatedAt(); 41 this.createdBy = version.getCreatedBy().getUsername(); 42 if (version.getPredecessor() != null) this.predecessorUUID = version.getPredecessor().getUid(); 43 else this.predecessorUUID = null; 44 } 45 }