Merge "Add debugging of REST call"
[policy/drools-applications.git] / controlloop / common / model-impl / events / src / main / java / org / onap / policy / controlloop / ControlLoopOperation.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * controlloop
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.controlloop;
22
23 import java.io.Serializable;
24 import java.time.Instant;
25
26 public class ControlLoopOperation implements Serializable {
27
28     private static final long serialVersionUID = 8662706581293017099L;
29
30     private String actor;
31     private String operation;
32     private String target;
33     private Instant start = Instant.now();
34     private Instant end;
35     private String subRequestId;
36     private String outcome;
37     private String message;
38
39     public ControlLoopOperation() {
40
41     }
42
43     /**
44      * Construct an instance from an existing instance.
45      * 
46      * @param op the existing instance
47      */
48     public ControlLoopOperation(ControlLoopOperation op) {
49         if (op == null) {
50             return;
51         }
52
53         this.actor = op.actor;
54         this.operation = op.operation;
55         this.target = op.target;
56         this.start = op.start;
57         this.end = op.end;
58         this.subRequestId = op.subRequestId;
59         this.outcome = op.outcome;
60         this.message = op.message;
61     }
62
63     public String toMessage() {
64         return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",subRequestId=" + subRequestId;
65     }
66
67     public String toHistory() {
68         return "actor=" + actor + ",operation=" + operation + ",target=" + target + ",start=" + start + ",end=" + end
69                 + ",subRequestId=" + subRequestId + ",outcome=" + outcome + ",message=" + message;
70     }
71
72     public String getActor() {
73         return actor;
74     }
75
76     public void setActor(String actor) {
77         this.actor = actor;
78     }
79
80     public String getOperation() {
81         return operation;
82     }
83
84     public void setOperation(String operation) {
85         this.operation = operation;
86     }
87
88     public String getTarget() {
89         return target;
90     }
91
92     public void setTarget(String target) {
93         this.target = target;
94     }
95
96     public Instant getStart() {
97         return start;
98     }
99
100     public void setStart(Instant start) {
101         this.start = start;
102     }
103
104     public Instant getEnd() {
105         return end;
106     }
107
108     public void setEnd(Instant end) {
109         this.end = end;
110     }
111
112     public String getSubRequestId() {
113         return subRequestId;
114     }
115
116     public void setSubRequestId(String subRequestId) {
117         this.subRequestId = subRequestId;
118     }
119
120     public String getOutcome() {
121         return outcome;
122     }
123
124     public void setOutcome(String outcome) {
125         this.outcome = outcome;
126     }
127
128     public String getMessage() {
129         return message;
130     }
131
132     public void setMessage(String message) {
133         this.message = message;
134     }
135
136     @Override
137     public String toString() {
138         return "ControlLoopOperation [actor=" + actor + ", operation=" + operation + ", target=" + target + ", start="
139                 + start + ", end=" + end + ", subRequestId=" + subRequestId + ", outcome=" + outcome + ", message="
140                 + message + "]";
141     }
142
143     @Override
144     public int hashCode() {
145         final int prime = 31;
146         int result = 1;
147         result = prime * result + ((actor == null) ? 0 : actor.hashCode());
148         result = prime * result + ((end == null) ? 0 : end.hashCode());
149         result = prime * result + ((message == null) ? 0 : message.hashCode());
150         result = prime * result + ((operation == null) ? 0 : operation.hashCode());
151         result = prime * result + ((outcome == null) ? 0 : outcome.hashCode());
152         result = prime * result + ((start == null) ? 0 : start.hashCode());
153         result = prime * result + ((subRequestId == null) ? 0 : subRequestId.hashCode());
154         result = prime * result + ((target == null) ? 0 : target.hashCode());
155         return result;
156     }
157
158     @Override
159     public boolean equals(Object obj) {
160         if (this == obj) {
161             return true;
162         }
163         if (obj == null) {
164             return false;
165         }
166         if (getClass() != obj.getClass()) {
167             return false;
168         }
169         ControlLoopOperation other = (ControlLoopOperation) obj;
170         if (actor == null) {
171             if (other.actor != null) {
172                 return false;
173             }
174         } else if (!actor.equals(other.actor)) {
175             return false;
176         }
177         if (end == null) {
178             if (other.end != null) {
179                 return false;
180             }
181         } else if (!end.equals(other.end)) {
182             return false;
183         }
184         if (message == null) {
185             if (other.message != null) {
186                 return false;
187             }
188         } else if (!message.equals(other.message)) {
189             return false;
190         }
191         if (operation == null) {
192             if (other.operation != null) {
193                 return false;
194             }
195         } else if (!operation.equals(other.operation)) {
196             return false;
197         }
198         if (outcome == null) {
199             if (other.outcome != null) {
200                 return false;
201             }
202         } else if (!outcome.equals(other.outcome)) {
203             return false;
204         }
205         if (start == null) {
206             if (other.start != null) {
207                 return false;
208             }
209         } else if (!start.equals(other.start)) {
210             return false;
211         }
212         if (subRequestId == null) {
213             if (other.subRequestId != null) {
214                 return false;
215             }
216         } else if (!subRequestId.equals(other.subRequestId)) {
217             return false;
218         }
219         if (target == null) {
220             if (other.target != null) {
221                 return false;
222             }
223         } else if (!target.equals(other.target)) {
224             return false;
225         }
226         return true;
227     }
228
229 }