1616package io .flamingock .cloud .api .request ;
1717
1818
19+ import com .fasterxml .jackson .annotation .JsonInclude ;
20+ import io .flamingock .cloud .api .vo .CloudChangeStatus ;
1921import io .flamingock .cloud .api .vo .CloudTargetSystemAuditMarkType ;
2022
2123//TODO add recoveryStrategy, so we can determin the acction in the server
@@ -25,26 +27,51 @@ public class ChangeRequest {
2527
2628 private CloudTargetSystemAuditMarkType ongoingStatus ;
2729
30+ /**
31+ * Per-change status reported by the client — mirrors the operation-side
32+ * {@code ChangeResult.status} currently held on the client's {@code PipelineRun}. The
33+ * server uses this as informational input when synthesising the response: it never
34+ * contradicts the client's positive report (e.g. {@code APPLIED} stays {@code APPLIED},
35+ * not downgraded to {@code ALREADY_APPLIED}), and it respects {@code FAILED} /
36+ * {@code ROLLED_BACK} reports so it doesn't ask the client to retry indefinitely.
37+ *
38+ * <p>{@code null} on the wire means the operation has nothing to report yet
39+ * (equivalent to {@code NOT_REACHED}). Serialised as field-absence so the wire shape is
40+ * forward-compatible with older mocks/expectations that don't set this field.
41+ */
42+ @ JsonInclude (JsonInclude .Include .NON_NULL )
43+ private CloudChangeStatus currentStatus ;
44+
2845 private boolean transactional ;
2946
3047 public ChangeRequest () {
3148 }
3249
3350 public static ChangeRequest change (String id , boolean transactional ) {
34- return new ChangeRequest (id , CloudTargetSystemAuditMarkType .NONE , transactional );
51+ return new ChangeRequest (id , CloudTargetSystemAuditMarkType .NONE , null , transactional );
3552 }
3653
3754 public static ChangeRequest ongoingExecution (String id , boolean transactional ) {
38- return new ChangeRequest (id , CloudTargetSystemAuditMarkType .APPLIED , transactional );
55+ return new ChangeRequest (id , CloudTargetSystemAuditMarkType .APPLIED , null , transactional );
3956 }
4057
4158 public static ChangeRequest ongoingRollback (String id , boolean transactional ) {
42- return new ChangeRequest (id , CloudTargetSystemAuditMarkType .ROLLED_BACK , transactional );
59+ return new ChangeRequest (id , CloudTargetSystemAuditMarkType .ROLLED_BACK , null , transactional );
60+ }
61+
62+ public ChangeRequest (String id ,
63+ CloudTargetSystemAuditMarkType ongoingStatus ,
64+ boolean transactional ) {
65+ this (id , ongoingStatus , null , transactional );
4366 }
4467
45- public ChangeRequest (String id , CloudTargetSystemAuditMarkType ongoingStatus , boolean transactional ) {
68+ public ChangeRequest (String id ,
69+ CloudTargetSystemAuditMarkType ongoingStatus ,
70+ CloudChangeStatus currentStatus ,
71+ boolean transactional ) {
4672 this .id = id ;
4773 this .ongoingStatus = ongoingStatus ;
74+ this .currentStatus = currentStatus ;
4875 this .transactional = transactional ;
4976 }
5077
@@ -56,6 +83,10 @@ public CloudTargetSystemAuditMarkType getOngoingStatus() {
5683 return ongoingStatus ;
5784 }
5885
86+ public CloudChangeStatus getCurrentStatus () {
87+ return currentStatus ;
88+ }
89+
5990 public boolean isTransactional () {
6091 return transactional ;
6192 }
@@ -68,6 +99,10 @@ public void setOngoingStatus(CloudTargetSystemAuditMarkType ongoingStatus) {
6899 this .ongoingStatus = ongoingStatus ;
69100 }
70101
102+ public void setCurrentStatus (CloudChangeStatus currentStatus ) {
103+ this .currentStatus = currentStatus ;
104+ }
105+
71106 public void setTransactional (boolean transactional ) {
72107 this .transactional = transactional ;
73108 }
@@ -79,11 +114,12 @@ public boolean equals(Object o) {
79114 ChangeRequest that = (ChangeRequest ) o ;
80115 return transactional == that .transactional
81116 && java .util .Objects .equals (id , that .id )
82- && java .util .Objects .equals (ongoingStatus , that .ongoingStatus );
117+ && java .util .Objects .equals (ongoingStatus , that .ongoingStatus )
118+ && java .util .Objects .equals (currentStatus , that .currentStatus );
83119 }
84120
85121 @ Override
86122 public int hashCode () {
87- return java .util .Objects .hash (id , ongoingStatus , transactional );
123+ return java .util .Objects .hash (id , ongoingStatus , currentStatus , transactional );
88124 }
89125}
0 commit comments