View Javadoc
1   /*
2    * Copyright (c) 2023. Roland T. Lichti, Kaiserpfalz EDV-Service.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16   */
17  
18  package de.kaiserpfalzedv.commons.core.workflow;
19  
20  import java.util.UUID;
21  
22  import org.eclipse.microprofile.openapi.annotations.media.Schema;
23  
24  import com.fasterxml.jackson.annotation.JsonInclude;
25  
26  import de.kaiserpfalzedv.commons.api.workflow.WorkflowInfo;
27  import lombok.AllArgsConstructor;
28  import lombok.Builder;
29  import lombok.EqualsAndHashCode;
30  import lombok.Getter;
31  import lombok.NoArgsConstructor;
32  import lombok.ToString;
33  import lombok.extern.jackson.Jacksonized;
34  
35  /**
36   * WorkflowInfo -- Default workflow information of a request.
37   *
38   * This info should be generated on the northbound interface of a system. It should be passed to other system calls.
39   * Normally as out-of-band information. So the encoding may change (HTTP-Headers, JMS properties, ...).
40   *
41   * @author klenkes74 {@literal <rlichti@kaiserpfalz-edv.de>}
42   * @since 2.0.0  2022-01-04
43   */
44  @Jacksonized
45  @Builder(toBuilder = true)
46  @AllArgsConstructor
47  @NoArgsConstructor
48  @ToString
49  @EqualsAndHashCode
50  @Getter
51  @JsonInclude(JsonInclude.Include.NON_ABSENT)
52  @Schema(name = "WorkflowInfo", description = "Information of a workflow call.")
53  public class WorkflowInfoImpl implements WorkflowInfo {
54          private static final long serialVersionUID = 0L;
55  
56      @Builder.Default
57      private final WorkflowDetailInfoImpl workflow = WorkflowDetailInfoImpl.builder().build();
58  
59      @Schema(
60              description = "The action within the workflow this call belongs to.",
61              required = true,
62              example = "{\"name\": \"check-duplicate\", \"id\": \"81f76259-e9fa-4af2-bba7-255f7370fe41\", \"created\": \"2022-01-04T14:22:00.023000Z\", \"ttl\": \"2022-01-04T14:22:02.023000Z\"}"
63      )
64      @Builder.Default
65      private final WorkflowDetailInfoImpl action = WorkflowDetailInfoImpl.builder().build();
66  
67      @Schema(
68              description = "The actual service call.",
69              required = true,
70              example = "{\"name\": \"get-user\", \"id\": \"69de33eb-6a9d-4010-9fb9-e35a4ac56eb8\", \"created\": \"2022-01-04T14:22:00.028000Z\", \"ttl\": \"2022-01-04T14:22:01.028000Z\"}"
71      )
72      @Builder.Default
73      private final WorkflowDetailInfoImpl call = WorkflowDetailInfoImpl.builder().build();
74  
75      @Schema(
76              description = "The owner of this request. Can be an ID, a name or anything else. Please keep GDPR in mind!",
77              example = "klenkes74",
78              defaultValue = "Random UUID",
79              nullable = true,
80              minLength = 1,
81              maxLength = 100
82      )
83      @Builder.Default
84      private final String user = UUID.randomUUID().toString();
85  }