1e390701dfccb7a32ae59e2ba69c529de56ee256
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
4  * ================================================================================
5  * Copyright (C) 2017 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.so.bpmn.servicedecomposition.generalobjects;
22
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.onap.so.logger.MsoLogger;
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
37 @JsonRootName(value = "requestParameters")
38 @JsonInclude(Include.NON_DEFAULT)
39 public class RequestParameters implements Serializable {
40
41         private static final MsoLogger log = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, RequestParameters.class);
42
43         private static final long serialVersionUID = -5979049912538894930L;
44         @JsonProperty("subscriptionServiceType")
45         private String subscriptionServiceType;
46         @JsonProperty("userParams")
47         private List<Map<String, Object>> userParams = new ArrayList<>();
48         @JsonProperty("aLaCarte")
49         private Boolean aLaCarte;
50         @JsonProperty("payload")
51         private String payload;
52         @JsonProperty("usePreload")
53         private Boolean usePreload;
54
55         public String getSubscriptionServiceType() {
56                 return subscriptionServiceType;
57         }
58
59         public void setSubscriptionServiceType(String subscriptionServiceType) {
60                 this.subscriptionServiceType = subscriptionServiceType;
61         }
62         @JsonProperty("aLaCarte")
63         public Boolean getALaCarte() {
64                 return aLaCarte;
65         }
66         @JsonProperty("aLaCarte")
67         public void setaLaCarte(Boolean aLaCarte) {
68                 this.aLaCarte = aLaCarte;
69         }
70
71         public Boolean isaLaCarte() {
72                 return aLaCarte;
73         }
74         
75         public String getPayload(){
76                 return payload;
77         }
78         public void setPayload(String value){
79                 this.payload = value;
80         }
81
82         public List<Map<String, Object>> getUserParams() {
83                 return userParams;
84         }
85
86         public void setUserParams(List<Map<String, Object>> userParams) {
87                 this.userParams = userParams;
88         }
89
90         public Object getUserParamValue(String name) {
91                 if (userParams != null) {
92                         for (Map<String, Object> param : userParams) {
93                                 if (param.get(name) != null) {
94                                         return param.get(name);
95                                 }
96                         }
97                 }
98                 return null;
99         }
100         
101         public Boolean isUsePreload() {
102                 return usePreload;
103         }
104         
105         @JsonProperty("usePreload")
106         public Boolean getUsePreload() {
107                 return usePreload;
108         }
109         
110         @JsonProperty("usePreload")
111         public void setUsePreload(Boolean usePreload) {
112                 this.usePreload = usePreload;
113         }
114
115
116         @JsonInclude(Include.NON_NULL)
117         public String toJsonString(){
118                 String json = "";
119                 ObjectMapper mapper = new ObjectMapper();
120                 mapper.setSerializationInclusion(Include.NON_NULL);
121                 ObjectWriter ow = mapper.writer();
122                 try{
123                         json = ow.writeValueAsString(this);
124                 }catch (Exception e){
125                         log.error("Unable to convert Sniro Manager Request to string", e);
126                 }
127                 return json;
128         }
129
130         @Override
131         public String toString() {
132                 return "RequestParameters [subscriptionServiceType="
133                                 + subscriptionServiceType + ", userParams=" + userParams
134                                 + ", aLaCarte=" + aLaCarte + "]";
135         }
136 }