Add time and date attributes to DecisionRequest
[policy/models.git] / models-decisions / src / main / java / org / onap / policy / models / decisions / concepts / DecisionRequest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Decision Models
4  * ================================================================================
5  * Copyright (C) 2019, 2021 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.models.decisions.concepts;
22
23 import com.google.gson.annotations.SerializedName;
24 import java.time.LocalDate;
25 import java.time.OffsetDateTime;
26 import java.time.OffsetTime;
27 import java.time.ZoneOffset;
28 import java.util.HashMap;
29 import java.util.Map;
30 import lombok.Data;
31 import lombok.NoArgsConstructor;
32
33 /**
34  * This class is for a Decision Request to a Decision PDP Engine.
35  *
36  * @author pameladragosh
37  *
38  */
39 @Data
40 @NoArgsConstructor
41 public class DecisionRequest {
42     @SerializedName("ONAPName")
43     private String  onapName;
44
45     @SerializedName("ONAPComponent")
46     private String  onapComponent;
47
48     @SerializedName("ONAPInstance")
49     private String  onapInstance;
50
51     @SerializedName("requestId")
52     private String  requestId;
53
54     @SerializedName("context")
55     private Map<String, Object> context;
56
57     @SerializedName("action")
58     private String  action;
59
60     @SerializedName("currentDateTime")
61     private OffsetDateTime currentDateTime;
62
63     @SerializedName("currentDate")
64     private LocalDate currentDate;
65
66     @SerializedName("currentTime")
67     private OffsetTime currentTime;
68
69     @SerializedName("timeZone")
70     private ZoneOffset timeZone;
71
72     @SerializedName("resource")
73     private Map<String, Object> resource;
74
75     /**
76      * Copy constructor.
77      *
78      * @param request Incoming DecisionRequest
79      */
80     public DecisionRequest(DecisionRequest request) {
81         this.setOnapName(request.getOnapName());
82         this.setOnapComponent(request.getOnapComponent());
83         this.setOnapInstance(request.getOnapInstance());
84         this.setRequestId(request.getRequestId());
85         if (request.getContext() != null) {
86             this.setContext(new HashMap<>());
87             this.getContext().putAll(request.getContext());
88         }
89         this.setAction(request.getAction());
90         this.setCurrentDate(request.getCurrentDate());
91         this.setCurrentDateTime(request.getCurrentDateTime());
92         this.setCurrentTime(request.getCurrentTime());
93         this.setTimeZone(request.getTimeZone());
94         if (request.getResource() != null) {
95             this.setResource(new HashMap<>());
96             this.getResource().putAll(request.getResource());
97         }
98     }
99 }