Added Time agnostic Onset and Abated classes
[policy/models.git] / models-interactions / model-impl / events / src / main / java / org / onap / policy / controlloop / ControlLoopEvent.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * controlloop
4  * ================================================================================
5  * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.controlloop;
23
24 import com.google.gson.annotations.SerializedName;
25 import java.io.Serializable;
26 import java.util.Map;
27 import java.util.UUID;
28 import lombok.Data;
29 import lombok.NoArgsConstructor;
30
31 @Data
32 @NoArgsConstructor
33 public abstract class ControlLoopEvent implements Serializable {
34
35     private static final long serialVersionUID = 2391252138583119195L;
36
37     @SerializedName("requestID")
38     protected UUID requestId;
39     @SerializedName("target_type")
40     protected String targetType;
41     protected String closedLoopControlName;
42     protected String version = "1.0.2";
43     protected String closedLoopEventClient;
44     protected String target;
45     protected String from;
46     protected String policyScope;
47     protected String policyName;
48     protected String policyVersion;
49     protected ControlLoopEventStatus closedLoopEventStatus;
50     protected Map<String, String> additionalEventParams;
51
52     /**
53      * Construct an instance from an existing instance.
54      *
55      * @param event the existing instance
56      */
57     public ControlLoopEvent(ControlLoopEvent event) {
58         if (event == null) {
59             return;
60         }
61         this.version =  event.version;
62         this.closedLoopControlName = event.closedLoopControlName;
63         this.requestId = event.requestId;
64         this.closedLoopEventClient = event.closedLoopEventClient;
65         this.targetType = event.targetType;
66         this.target = event.target;
67         this.from = event.from;
68         this.policyScope = event.policyScope;
69         this.policyName = event.policyName;
70         this.policyVersion = event.policyVersion;
71         this.closedLoopEventStatus = event.closedLoopEventStatus;
72         this.additionalEventParams = event.additionalEventParams;
73     }
74
75     public boolean isEventStatusValid() {
76         return this.closedLoopEventStatus != null;
77     }
78 }