View Javadoc
1   package de.dlr.shepard.context.labJournal.io;
2   
3   import com.fasterxml.jackson.annotation.JsonFormat;
4   import de.dlr.shepard.context.labJournal.entities.LabJournalEntry;
5   import jakarta.validation.constraints.NotNull;
6   import java.util.Date;
7   import lombok.Data;
8   import org.eclipse.microprofile.openapi.annotations.media.Schema;
9   
10  @Data
11  @Schema(name = "LabJournalEntry")
12  public class LabJournalEntryIO {
13  
14    @Schema(readOnly = true, required = true)
15    @NotNull
16    private long dataObjectId;
17  
18    @NotNull
19    private String journalContent;
20  
21    @Schema(readOnly = true, required = true)
22    private Long id;
23  
24    @JsonFormat(shape = JsonFormat.Shape.STRING)
25    @Schema(readOnly = true, required = true, format = "date-time", example = "2024-08-15T11:18:44.632+00:00")
26    private Date createdAt;
27  
28    @Schema(readOnly = true, required = true)
29    private String createdBy;
30  
31    @JsonFormat(shape = JsonFormat.Shape.STRING)
32    @Schema(
33      readOnly = true,
34      nullable = true,
35      required = true,
36      format = "date-time",
37      example = "2024-08-15T11:18:44.632+00:00"
38    )
39    private Date updatedAt;
40  
41    @Schema(readOnly = true, nullable = true, required = true)
42    private String updatedBy;
43  
44    public LabJournalEntryIO() {}
45  
46    public LabJournalEntryIO(LabJournalEntry labJournalEntry) {
47      this.dataObjectId = labJournalEntry.getDataObject().getShepardId();
48      this.journalContent = labJournalEntry.getContent();
49      this.id = labJournalEntry.getId();
50      this.createdAt = labJournalEntry.getCreatedAt();
51      this.createdBy = labJournalEntry.getCreatedBy() != null ? labJournalEntry.getCreatedBy().getUsername() : null;
52      this.updatedAt = labJournalEntry.getUpdatedAt();
53      this.updatedBy = labJournalEntry.getUpdatedBy() != null ? labJournalEntry.getUpdatedBy().getUsername() : null;
54    }
55  }