001package ca.cdr.api.model.json;
002
003/*
004 * #%L
005 * Smile CDR - CDR
006 * %%
007 * Copyright (C) 2016 - 2025 Smile CDR, Inc.
008 * %%
009 * All rights reserved.
010 * #L%
011 */
012
013import ca.cdr.api.model.enm.TransactionLogEventSubTypeEnum;
014import ca.cdr.api.model.enm.TransactionLogEventTypeEnum;
015import ca.cdr.api.model.enm.TransactionLogOutcomeEnum;
016import ca.uhn.fhir.model.api.IModelJson;
017import com.fasterxml.jackson.annotation.JsonProperty;
018import com.fasterxml.jackson.annotation.JsonPropertyOrder;
019import com.fasterxml.jackson.annotation.JsonRawValue;
020import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
021import com.fasterxml.jackson.databind.annotation.JsonSerialize;
022import io.swagger.v3.oas.annotations.media.Schema;
023
024import java.sql.Timestamp;
025import java.util.ArrayList;
026import java.util.Date;
027import java.util.List;
028
029@JsonPropertyOrder({"moduleId", "from", "to", "pageIndex", "pageSize", "events"})
030public class TransactionLogEventsJson implements IModelJson {
031
032        @JsonProperty("events")
033        private List<TransactionLogEventJson> myEvents;
034
035        @JsonProperty("from")
036        @JsonSerialize(using = JsonDateSerializer.class)
037        @JsonDeserialize(using = JsonDateDeserializer.class)
038        private Date myFrom;
039
040        @JsonProperty("pageSize")
041        private int myPageSize;
042
043        @JsonProperty("to")
044        @JsonSerialize(using = JsonDateSerializer.class)
045        @JsonDeserialize(using = JsonDateDeserializer.class)
046        private Date myTo;
047
048        @JsonProperty("pageIndex")
049        private int myPageIndex;
050
051        @Schema(
052                        description = "Module Id of the Module that stores the transaction records.",
053                        example = "transaction",
054                        requiredMode = Schema.RequiredMode.NOT_REQUIRED)
055        @JsonProperty("moduleId")
056        private String myModuleId;
057
058        public List<TransactionLogEventJson> getEvents() {
059                if (myEvents == null) {
060                        myEvents = new ArrayList<>();
061                }
062                return myEvents;
063        }
064
065        public Date getFrom() {
066                return myFrom;
067        }
068
069        public void setFrom(Date theFrom) {
070                myFrom = theFrom;
071        }
072
073        public int getPageSize() {
074                return myPageSize;
075        }
076
077        public void setPageSize(int thePageSize) {
078                myPageSize = thePageSize;
079        }
080
081        public Date getTo() {
082                return myTo;
083        }
084
085        public void setTo(Date theTo) {
086                myTo = theTo;
087        }
088
089        public int getPageIndex() {
090                return myPageIndex;
091        }
092
093        public void setPageIndex(int thePageIndex) {
094                myPageIndex = thePageIndex;
095        }
096
097        public String getModuleId() {
098                return myModuleId;
099        }
100
101        public void setModuleId(String theModuleId) {
102                myModuleId = theModuleId;
103        }
104
105        @JsonPropertyOrder({
106                "id",
107                "initialTimestamp",
108                "type",
109                "subType",
110                "outcome",
111                "endpointNodeId",
112                "endpointModuleId",
113                "processingTime",
114                "endpointLocalHost",
115                "endpointLocalPort",
116                "endpointRemoteHost",
117                "endpointRemotePort",
118                "requestId",
119                "events",
120                "additionalJson"
121        })
122        // TODO KHS move toplevel
123        public static class TransactionLogEventJson implements IModelJson {
124
125                @JsonProperty("endpointLocalHost")
126                private String myEndpointLocalHost;
127
128                @JsonProperty("endpointLocalPort")
129                private Integer myEndpointLocalPort;
130
131                @Schema(
132                                description = "Module Id of the Endpoint Module that received the request generated the record.",
133                                example = "fhir_endpoint",
134                                requiredMode = Schema.RequiredMode.NOT_REQUIRED)
135                @JsonProperty("endpointModuleId")
136                private String myEndpointModuleId;
137
138                @JsonProperty("endpointNodeId")
139                private String myEndpointNodeId;
140
141                @JsonProperty("endpointRemoteHost")
142                private String myEndpointRemoteHost;
143
144                @JsonProperty("endpointRemotePort")
145                private Integer myEndpointRemotePort;
146
147                @JsonProperty("events")
148                private List<TransactionLogStepJson> myEvents_;
149
150                @JsonProperty("id")
151                private Long myId;
152
153                @JsonProperty("initialTimestamp")
154                @JsonSerialize(using = JsonDateSerializer.class)
155                @JsonDeserialize(using = JsonDateDeserializer.class)
156                private Date myInitialTimestamp;
157
158                @JsonProperty("outcome")
159                private TransactionLogOutcomeEnum myOutcome;
160
161                @JsonProperty("processingTime")
162                private long myProcessingTime;
163
164                @JsonProperty("subType")
165                private TransactionLogEventSubTypeEnum mySubType;
166
167                @JsonProperty("type")
168                private TransactionLogEventTypeEnum myType;
169
170                @JsonProperty("requestId")
171                private String myRequestId;
172
173                private Long myUserId;
174
175                @Schema(
176                                description =
177                                                "Module Id of the Module that manages the security for the user that generated the record.",
178                                example = "local_security",
179                                requiredMode = Schema.RequiredMode.NOT_REQUIRED)
180                @JsonProperty("userModuleId")
181                private String myUserModuleId;
182
183                @JsonProperty("userNodeId")
184                private String myUserNodeId;
185
186                @JsonProperty("userName")
187                private String username;
188
189                @JsonProperty("userFamilyName")
190                private String myUserFamilyName;
191
192                @JsonProperty("userGivenName")
193                private String myUserGivenName;
194
195                @JsonProperty("clientId")
196                private String myClientId;
197
198                @JsonProperty("clientNodeId")
199                private String myClientNodeId;
200
201                @JsonProperty("clientModuleId")
202                private String myClientModuleId;
203
204                private Long myClientPid;
205
206                @JsonProperty("clientName")
207                private String myClientName;
208
209                @JsonProperty("transactionGuid")
210                private String myTransactionGuid;
211
212                @JsonDeserialize(using = RawJsonDeserializer.class)
213                @JsonRawValue
214                @JsonProperty("additionalJson")
215                private String myAdditionalJson;
216
217                public String getEndpointLocalHost() {
218                        return myEndpointLocalHost;
219                }
220
221                public void setEndpointLocalHost(String theEndpointLocalHost) {
222                        myEndpointLocalHost = theEndpointLocalHost;
223                }
224
225                public Integer getEndpointLocalPort() {
226                        return myEndpointLocalPort;
227                }
228
229                public void setEndpointLocalPort(Integer theEndpointLocalPort) {
230                        myEndpointLocalPort = theEndpointLocalPort;
231                }
232
233                public String getEndpointModuleId() {
234                        return myEndpointModuleId;
235                }
236
237                public void setEndpointModuleId(String theEntpointId) {
238                        myEndpointModuleId = theEntpointId;
239                }
240
241                public String getEndpointNodeId() {
242                        return myEndpointNodeId;
243                }
244
245                public void setEndpointNodeId(String theNodeId) {
246                        myEndpointNodeId = theNodeId;
247                }
248
249                public String getEndpointRemoteHost() {
250                        return myEndpointRemoteHost;
251                }
252
253                public void setEndpointRemoteHost(String theEndpointRemoteHost) {
254                        myEndpointRemoteHost = theEndpointRemoteHost;
255                }
256
257                public Integer getEndpointRemotePort() {
258                        return myEndpointRemotePort;
259                }
260
261                public void setEndpointRemotePort(Integer theEndpointRemotePort) {
262                        myEndpointRemotePort = theEndpointRemotePort;
263                }
264
265                public List<TransactionLogStepJson> getEvents() {
266                        if (myEvents_ == null) {
267                                myEvents_ = new ArrayList<>();
268                        }
269                        return myEvents_;
270                }
271
272                public Long getId() {
273                        return myId;
274                }
275
276                public void setId(Long thePid) {
277                        myId = thePid;
278                }
279
280                public Date getInitialTimestamp() {
281                        return myInitialTimestamp;
282                }
283
284                public void setInitialTimestamp(Date theTimestamp) {
285                        myInitialTimestamp = theTimestamp;
286                        if (myInitialTimestamp instanceof Timestamp) {
287                                myInitialTimestamp = new Date(myInitialTimestamp.getTime());
288                        }
289                }
290
291                public TransactionLogOutcomeEnum getOutcome() {
292                        return myOutcome;
293                }
294
295                public void setOutcome(TransactionLogOutcomeEnum theOutcome) {
296                        myOutcome = theOutcome;
297                }
298
299                public long getProcessingTime() {
300                        return myProcessingTime;
301                }
302
303                public void setProcessingTime(long theProcessingTime) {
304                        myProcessingTime = theProcessingTime;
305                }
306
307                public TransactionLogEventSubTypeEnum getSubType() {
308                        return mySubType;
309                }
310
311                public void setSubType(TransactionLogEventSubTypeEnum theSubType) {
312                        mySubType = theSubType;
313                }
314
315                public TransactionLogEventTypeEnum getType() {
316                        return myType;
317                }
318
319                public void setType(TransactionLogEventTypeEnum theTransactionLogEventTypeEnum) {
320                        myType = theTransactionLogEventTypeEnum;
321                }
322
323                public String getRequestId() {
324                        return myRequestId;
325                }
326
327                public void setRequestId(String theRequestId) {
328                        myRequestId = theRequestId;
329                }
330
331                public Long getUserId() {
332                        return myUserId;
333                }
334
335                public void setUserId(Long userId) {
336                        this.myUserId = userId;
337                }
338
339                public String getUserModuleId() {
340                        return myUserModuleId;
341                }
342
343                public void setUserModuleId(String userModuleId) {
344                        this.myUserModuleId = userModuleId;
345                }
346
347                public String getUserNodeId() {
348                        return myUserNodeId;
349                }
350
351                public void setUserNodeId(String userNodeId) {
352                        this.myUserNodeId = userNodeId;
353                }
354
355                public String getUsername() {
356                        return username;
357                }
358
359                public void setUsername(String username) {
360                        this.username = username;
361                }
362
363                public String getUserFamilyName() {
364                        return myUserFamilyName;
365                }
366
367                public void setUserFamilyName(String userFamilyName) {
368                        this.myUserFamilyName = userFamilyName;
369                }
370
371                public String getUserGivenName() {
372                        return myUserGivenName;
373                }
374
375                public void setUserGivenName(String userGivenName) {
376                        this.myUserGivenName = userGivenName;
377                }
378
379                public String getClientId() {
380                        return myClientId;
381                }
382
383                public void setClientId(String clientId) {
384                        this.myClientId = clientId;
385                }
386
387                public String getClientModuleId() {
388                        return myClientModuleId;
389                }
390
391                public void setClientModuleId(String clientModuleId) {
392                        this.myClientModuleId = clientModuleId;
393                }
394
395                public String getClientNodeId() {
396                        return myClientNodeId;
397                }
398
399                public void setClientNodeId(String clientNodeId) {
400                        this.myClientNodeId = clientNodeId;
401                }
402
403                public Long getClientPid() {
404                        return myClientPid;
405                }
406
407                public void setClientPid(Long clientPid) {
408                        this.myClientPid = clientPid;
409                }
410
411                public String getClientName() {
412                        return myClientName;
413                }
414
415                public void setClientName(String clientName) {
416                        this.myClientName = clientName;
417                }
418
419                public String getTransactionGuid() {
420                        return myTransactionGuid;
421                }
422
423                public void setTransactionGuid(String theTransactionGuid) {
424                        myTransactionGuid = theTransactionGuid;
425                }
426
427                public String getAdditionalJson() {
428                        return myAdditionalJson;
429                }
430
431                public void setAdditionalJson(String theAdditionalJson) {
432                        this.myAdditionalJson = theAdditionalJson;
433                }
434        }
435}