ca3f73a176b4a6c116906636c2a1686e08625dee
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.bpmn.servicedecomposition.generalobjects;
24
25 import java.io.Serializable;
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.Map;
29 import com.fasterxml.jackson.annotation.JsonInclude;
30 import com.fasterxml.jackson.annotation.JsonInclude.Include;
31 import com.fasterxml.jackson.databind.ObjectMapper;
32 import com.fasterxml.jackson.databind.ObjectWriter;
33 import com.fasterxml.jackson.annotation.JsonProperty;
34 import com.fasterxml.jackson.annotation.JsonRootName;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
37
38 @JsonRootName(value = "requestParameters")
39 @JsonInclude(Include.NON_DEFAULT)
40 public class RequestParameters implements Serializable {
41
42     private static final Logger logger = LoggerFactory.getLogger(RequestParameters.class);
43
44     private static final long serialVersionUID = -5979049912538894930L;
45     @JsonProperty("subscriptionServiceType")
46     private String subscriptionServiceType;
47     @JsonProperty("userParams")
48     private List<Map<String, Object>> userParams = new ArrayList<>();
49     @JsonProperty("aLaCarte")
50     private Boolean aLaCarte;
51     @JsonProperty("payload")
52     private String payload;
53     @JsonProperty("usePreload")
54     private Boolean usePreload;
55
56     public String getSubscriptionServiceType() {
57         return subscriptionServiceType;
58     }
59
60     public void setSubscriptionServiceType(String subscriptionServiceType) {
61         this.subscriptionServiceType = subscriptionServiceType;
62     }
63
64     @JsonProperty("aLaCarte")
65     public Boolean getALaCarte() {
66         return aLaCarte;
67     }
68
69     @JsonProperty("aLaCarte")
70     public void setaLaCarte(Boolean aLaCarte) {
71         this.aLaCarte = aLaCarte;
72     }
73
74     public Boolean isaLaCarte() {
75         return aLaCarte;
76     }
77
78     public String getPayload() {
79         return payload;
80     }
81
82     public void setPayload(String value) {
83         this.payload = value;
84     }
85
86     public List<Map<String, Object>> getUserParams() {
87         return userParams;
88     }
89
90     public void setUserParams(List<Map<String, Object>> userParams) {
91         this.userParams = userParams;
92     }
93
94     public Object getUserParamValue(String name) {
95         if (userParams != null) {
96             for (Map<String, Object> param : userParams) {
97                 if (param.get(name) != null) {
98                     return param.get(name);
99                 }
100             }
101         }
102         return null;
103     }
104
105     public Boolean isUsePreload() {
106         return usePreload;
107     }
108
109     @JsonProperty("usePreload")
110     public Boolean getUsePreload() {
111         return usePreload;
112     }
113
114     @JsonProperty("usePreload")
115     public void setUsePreload(Boolean usePreload) {
116         this.usePreload = usePreload;
117     }
118
119
120     @JsonInclude(Include.NON_NULL)
121     public String toJsonString() {
122         String json = "";
123         ObjectMapper mapper = new ObjectMapper();
124         mapper.setSerializationInclusion(Include.NON_NULL);
125         ObjectWriter ow = mapper.writer();
126         try {
127             json = ow.writeValueAsString(this);
128         } catch (Exception e) {
129             logger.error("Unable to convert Sniro Manager Request to string", e);
130         }
131         return json;
132     }
133
134     @Override
135     public String toString() {
136         return "RequestParameters [subscriptionServiceType=" + subscriptionServiceType + ", userParams=" + userParams
137                 + ", aLaCarte=" + aLaCarte + "]";
138     }
139 }