3761d26d0b509220c2b68b5a31d1772a2f4554b2
[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
30 import com.fasterxml.jackson.annotation.JsonInclude;
31 import com.fasterxml.jackson.annotation.JsonInclude.Include;
32 import com.fasterxml.jackson.databind.ObjectMapper;
33 import com.fasterxml.jackson.databind.ObjectWriter;
34 import com.fasterxml.jackson.annotation.JsonProperty;
35 import com.fasterxml.jackson.annotation.JsonRootName;
36 import org.slf4j.Logger;
37 import org.slf4j.LoggerFactory;
38
39 @JsonRootName(value = "requestParameters")
40 @JsonInclude(Include.NON_DEFAULT)
41 public class RequestParameters implements Serializable {
42
43         private static final Logger logger = LoggerFactory.getLogger(RequestParameters.class);
44
45         private static final long serialVersionUID = -5979049912538894930L;
46         @JsonProperty("subscriptionServiceType")
47         private String subscriptionServiceType;
48         @JsonProperty("userParams")
49         private List<Map<String, Object>> userParams = new ArrayList<>();
50         @JsonProperty("aLaCarte")
51         private Boolean aLaCarte;
52         @JsonProperty("payload")
53         private String payload;
54         @JsonProperty("usePreload")
55         private Boolean usePreload;
56
57         public String getSubscriptionServiceType() {
58                 return subscriptionServiceType;
59         }
60
61         public void setSubscriptionServiceType(String subscriptionServiceType) {
62                 this.subscriptionServiceType = subscriptionServiceType;
63         }
64         @JsonProperty("aLaCarte")
65         public Boolean getALaCarte() {
66                 return aLaCarte;
67         }
68         @JsonProperty("aLaCarte")
69         public void setaLaCarte(Boolean aLaCarte) {
70                 this.aLaCarte = aLaCarte;
71         }
72
73         public Boolean isaLaCarte() {
74                 return aLaCarte;
75         }
76         
77         public String getPayload(){
78                 return payload;
79         }
80         public void setPayload(String value){
81                 this.payload = value;
82         }
83
84         public List<Map<String, Object>> getUserParams() {
85                 return userParams;
86         }
87
88         public void setUserParams(List<Map<String, Object>> userParams) {
89                 this.userParams = userParams;
90         }
91
92         public Object getUserParamValue(String name) {
93                 if (userParams != null) {
94                         for (Map<String, Object> param : userParams) {
95                                 if (param.get(name) != null) {
96                                         return param.get(name);
97                                 }
98                         }
99                 }
100                 return null;
101         }
102         
103         public Boolean isUsePreload() {
104                 return usePreload;
105         }
106         
107         @JsonProperty("usePreload")
108         public Boolean getUsePreload() {
109                 return usePreload;
110         }
111         
112         @JsonProperty("usePreload")
113         public void setUsePreload(Boolean usePreload) {
114                 this.usePreload = usePreload;
115         }
116
117
118         @JsonInclude(Include.NON_NULL)
119         public String toJsonString(){
120                 String json = "";
121                 ObjectMapper mapper = new ObjectMapper();
122                 mapper.setSerializationInclusion(Include.NON_NULL);
123                 ObjectWriter ow = mapper.writer();
124                 try{
125                         json = ow.writeValueAsString(this);
126                 }catch (Exception e){
127                         logger.error("Unable to convert Sniro Manager Request to string", e);
128                 }
129                 return json;
130         }
131
132         @Override
133         public String toString() {
134                 return "RequestParameters [subscriptionServiceType="
135                                 + subscriptionServiceType + ", userParams=" + userParams
136                                 + ", aLaCarte=" + aLaCarte + "]";
137         }
138 }